output_description: Print the value a + a^2 + a^3 as an integer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      a
attempt: from collections import deque
  
  N, M, K = map(int, input().split())
  A = deque(map(int, input().split()))
  B = deque(map(int, input().split()))
  
  A.append(float("inf"))
  B.append(float("inf"))
  
  time = K
  count = 0
  sum_A = sum(list(A)[:-1])
  sum_B = sum(list(A)[:-1])
  for _ in range(len(A) + len(B)):
      if A[0] > B[0]:
          target = B.popleft()
          if (target > (sum_A - A[0])) and len(A) != 1:
              sum_A -= A[0]
              B.appendleft(target)
              target = A.popleft()
          time -= target
          count += 1
      else:
          target = A.popleft()
          if (target > (sum_B - B[0])) and len(B) != 1:
              sum_B -= B[0]
              A.appendleft(target)
              target = B.popleft()
          time -= target
          count += 1
      if len(A) == len(B) == 1:
          break
      if time < 0:
          count -= 1
          break
      elif time == 0:
          break
  print(count)
  
problem_description: Statement
  
  Given an integer a as input, print the value a + a^2 + a^3.
samples: [{"input": "2", "output": "14\n    \n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as `14.0` will be judged as\nincorrect.\n\n* * *"}, {"input": "10", "output": "1110"}]