Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

na, nb = [0], [0]
for i in range(n):
    na.append(na[i] + a[i])
for j in range(m):
    nb.append(nb[i] + b[i])

ans, j = 0, m
for i in range(n + 1):
    if na[i] > k:
        break
    while nb[j] > k - na[i]:
        j -= 1
    ans = max(ans, i + j)
    
print(ans)
  
  
      

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

na, nb = [0], [0]
for i in range(n):
    na.append(na[i] + a[i])
for j in range(m):
    nb.append(nb[j] + b[j])

ans, j = 0, m
for i in range(n + 1):
    if na[i] > k:
        break
    while nb[j] > k - na[i]:
        j -= 1
    ans = max(ans, i + j)
    
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

na, nb = [0], [0]
for i in range(n):
    na.append(na[i] + a[i])
for j in range(m):
    nb.append(nb[i] + b[i])

ans, j = 0, m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
    
print(ans)
  
  
      

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

na, nb = [0], [0]
for i in range(n):
    na.append(na[i] + a[i])
for j in range(m):
    nb.append(nb[j] + b[j])

ans, j = 0, m
for i in range(n + 1):
    if na[i] > k:
        break
    while nb[j] > k - na[i]:
        j -= 1
    ans = max(ans, i + j)
    
print(ans)

Buggy python submission (verdict: Runtime Error):
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(10 ** 10)
b.append(10 ** 10)
na = a.popleft()
nb = b.popleft()

cnt = 0
min = 0
while min <= k:
    if na <= nb:
        cnt += 1
        min += na
        na = a.popleft()
    elif na > nb:
        cnt += 1
        min += nb
        nb = b.popleft()
    elif na == 10 ** 10 and nb == 10 ** 10:
        cnt += 1
        break
print(cnt-1)

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

na, nb = [0], [0]
for i in range(n):
    na.append(na[i] + a[i])
for j in range(m):
    nb.append(nb[j] + b[j])

ans, j = 0, m
for i in range(n + 1):
    if na[i] > k:
        break
    while nb[j] > k - na[i]:
        j -= 1
    ans = max(ans, i + j)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input()
q = int(input())
l = [list(map(str, input().split())) for _ in range(q)]

for i in range(q):
    if l[i][0] in a:
        a = a.replace(l[i][0], l[i][1])
        new_a = a.split()
        new_a = [int(j) for j in new_a]
    print(sum(new_a))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())

count = [0] * (10 ** 5 + 1)
for i in a:
    count[i] += 1

a_sum = sum(a)
for i in range(q):
    b, c = map(int, input().split())
    a_sum += (c - b) * count[b]
    count[c] += count[b]
    count[b] = 0
    print(a_sum)
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))
min = float('inf')

for i in range(1, 101)[::-1]:
    if abs(x - i) <= min:
        if i not in p:
            min = abs(x - i)
            ans = i

print(ans)


Fixed submission:
x, n = map(int, input().split())
p = list(map(int, input().split()))
min = float('inf')

for i in range(0, 102)[::-1]:
    if abs(x - i) <= min:
        if i not in p:
            min = abs(x - i)
            ans = i

print(ans)

Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = []
min = float('inf')

for i in range(1, 101)[::-1]:
    if abs(x - i) < min:
        if i not in p:
            min = abs(x - i)
            ans = i

print(ans)


Fixed submission:
x, n = map(int, input().split())
p = list(map(int, input().split()))
min = float('inf')

for i in range(0, 102)[::-1]:
    if abs(x - i) <= min:
        if i not in p:
            min = abs(x - i)
            ans = i

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = int(input())
print(a * b)

Fixed submission:
a, b = map(int, input().split())
print(a * b)
Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
count = 0
temp = True
z = []

if n == 1:
    print(0)
    exit()

for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
        temp = False
        z.append(i)

if temp == True:
    print(1)
    exit()

for j in range(7):
    for k in z:
        if k > 1000000:
            break
        z.append(k ** j)

for l in z:
    if n % l == 0:
        count += 1
        n = n // l

print(count)


Fixed submission:
import math

n = int(input())
count = 0
p = n

for z in range(2, int(math.sqrt(n)) + 1):
    e = 1
    while n % z ** e == 0:
        n //= z ** e
        count += 1
        e += 1
    if n % z == 0: #これを行わなければ，素因数同士でかける場合も含んでしまう．
        while n % z == 0:
            n //= z

if n != 1:
    count += 1
if count == 0 and p != 1:
    count = 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(1, n + 1):
    print(a.count(i))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

ans = [0]*n
for i in a:
    ans[i - 1] += 1

for j in ans:
    print(j)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)

hantei = sum(a) / (4 * m)
if a[m-1] > hantei:
    print("Yes")
else:
    print("No")


Fixed submission:
x,y,z = map(int, input().split())
print(z,x,y)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

print(min(n % k), (k - (n % k)))


Fixed submission:
n,k = map(int, input().split())
print(min(n % k , k - (n % k)))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
print()(n * (n - 1) / 2) + (m * (m - 1) / 2))


Fixed submission:
N,M = map(int, input().split())
print(int((N * (N - 1) / 2 ) + (M * (M - 1) / 2 )))
Buggy python submission (verdict: Runtime Error):
s = input()
s1 = s[:(n - 2) / 2]
s2 = s[(n - 2) / 2:]

if s == s[:: -1] and s1 == s1[:: -1] amd s2 == s2[:: -1]:
    print('Yes')
else:
    print('No')


Fixed submission:
S = input()
N = len(S)
S2 = S[:((N - 1) // 2)]
S3 = S[((N + 1) // 2):]

S_rev1 = S[::-1]
S_rev2 = S2[::-1]
S_rev3 = S3[::-1]

if S == S_rev1 and S2 == S_rev2 and S3 == S_rev3 :
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
s = input()

if s[0] == s[1] and s[2] == s[3] and s[3] == s[1]:
    print('No')
else:
    print('Yes')


Fixed submission:
S = input()
if S[0] == S[1] and S[1] == S[2]:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
ans = 0
MIN = n + 1

for i in range(n):
    if MIN > p[i]:
        ans += 1
    MIN = min(MIH, p[i])

print(ans)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
min = float('inf')
ans = 0

for i in p:
    if i <= min:
        min = i; ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
c = input()

print(chr(c + 1))

Fixed submission:
c = input()

print(chr(ord(c) + 1))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
AC = [0] * n
WA = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and a[p] == 0:
        AC[p] += 1
        w += W[p]
    elif s == 'WA' and a[p] == 0:
        WA[p] += 1

print(sum(a), w)


Fixed submission:
n, m = map(int, input().split())
AC = [0] * n
WA = [0] * n
w = 0

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and AC[p] == 0:
        AC[p] += 1
        w += WA[p]
    elif s == 'WA' and AC[p] == 0:
        WA[p] += 1

print(sum(AC), w)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
AC = [0] * n
WA = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC': and a[p] == 0:
        AC[p] += 1
        w += W[p]
    elif s == 'WA' and a[p] == 0:
        WA[p] += 1

print(sum(a), w)


Fixed submission:
n, m = map(int, input().split())
AC = [0] * n
WA = [0] * n
w = 0

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and AC[p] == 0:
        AC[p] += 1
        w += WA[p]
    elif s == 'WA' and AC[p] == 0:
        WA[p] += 1

print(sum(AC), w)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

for i in range(n - 2):
    if s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C':
        count += 1
print(count)


Fixed submission:
n = int(input())
s = input()
count = 0

for i in range(n - 2):
    if s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C':
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
l = [i for i in range(1, n + 1)]
count = 0

for i in itertools.permutations(l, n):
    count += 1
    if i == p:
        a = count
    elif i == q:
        b = count

print(max(a, b) - min(a, b))


Fixed submission:
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
l = [i for i in range(1, n + 1)]
count = 0

if p == q:
    print(0)
    exit()
    
for i in itertools.permutations(l, n):
    count += 1
    if i == p:
        a = count
    elif i == q:
        b = count

print(max(a, b) - min(a, b))
Buggy python submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())

print(a * b // math.gcd(a, b))


Fixed submission:
import fractions

a, b = map(int, input().split())

print(a * b // fractions.gcd(a, b))

Buggy python submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())

print(a * b // math.gcd(a, b))


Fixed submission:
import fractions

a, b = map(int, input().split())

print(a * b // fractions.gcd(a, b))
Buggy python submission (verdict: Runtime Error):
a = list(map9int, input().split())

if sum(a) >= 22:
    print('bust')
else:
    print('win')

Fixed submission:
a = list(map(int, input().split()))

if sum(a) >= 22:
    print('bust')
else:
    print('win')
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
l = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') * 2
a = ''

for i in s:
    a += l[l.index(i) + n]

pritn(a)

Fixed submission:
n = int(input())
s = input()
l = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') * 2
a = ''

for i in s:
    a += l[l.index(i) + n]

print(a)
Buggy python submission (verdict: Runtime Error):
n = int(input().split())

a = []
for i in range(1, 10):
    for j in range(1, 10):
        a.append(i * j)

if n in a:
    print('Yes')
else:
    print('No')


Fixed submission:
n = int(input())

a = []
for i in range(1, 10):
    for j in range(1, 10):
        a.append(i * j)

if n in a:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

for i in range(n - 1):
    if s[i] != s[i + 1]:
        count += 1

print(count)

Fixed submission:
n = int(input())
s = input()
count = 0

for i in range(n - 1):
    if s[i] != s[i + 1]:
        count += 1

print(count + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
l = []

for i in range(n):
    l.append(a.index(i + 1) + 1)

print(*l)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
l = [0] * n

for i, j in enumerate(a, 1):
    l[j - 1] = i

print(* l)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
l = [k for _ in range(n)]

for i in range(q):
    a = int(input())
    l = list(map(lambda x: x - 1, l))
    l[a - 1] += 1

for j in range(n):
    if l[j] > 0:
        print('Yes')
    else:
        print('No')


Fixed submission:
n, k, q = map(int, input().split())
l = [k for _ in range(n)]

l = list(map(lambda x: x - q, l))

for i in range(q):
    a = int(input())
    l[a - 1] += 1

for j in range(n):
    if l[j] > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = input()

if a >= 3200:
  print(s)
 else:
  print('red')

Fixed submission:
a = int(input())
s = input()

if a >= 3200:
  print(s)
else:
  print('red')
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(max(max((a + b), (a - b)), (a * b))

Fixed submission:
a, b = map(int, input().split())
print(max(max((a + b), (a - b)), (a * b)))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
l = [k for k in range(n)]

count = []
for i in range(n)[::-1]:
    count.append(Counter(s[i]))

ans = 0
for j in itertools.combinations(l, 2):
    if count[j[0]] == count[j[1]]:
        ans += 1

print(ans)


Fixed submission:
n = int(input())

element = {}
count = 0
for i in range(n):
    s = ''.join(sorted(input()))
    if s in element:
        element[s] += 1
        count += element[s]
    else:
        element[s] = 0

print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]

max_1st = max(a)
max_2nd = sorted(a)[-2]
for i in range(n):
    if a[i] == max_1st:
        print(max_2nd)
    else:
        print(max_1st)


Fixed submission:
r = int(input())
print(3 * r ** 2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [input() for _ in range(n)]

for i in range(n):
    l = a.pop(i)
    print(max(a))
    a.insert(i, l)


Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]

max_1st = max(a)
max_2nd = sorted(a)[-2]
for i in range(n):
    if a[i] == max_1st:
        print(max_2nd)
    else:
        print(max_1st)
Buggy python submission (verdict: Runtime Error):
w, h, x, y = map(int, input().split())

judge = (w == 2 * x and h == 2 * y)
s = w * h / 2
print(area, 1 if judge else 0)


Fixed submission:
w, h, x, y = map(int, input().split())

s = w * h / 2
if w == 2 * x and h == 2 * y:
    print(s, 1)
else:
    print(s, 0)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()

if s[k-1] == 'A':
    s[k-1] = 'a'
elif s[k-1] == 'B':
    s[k-1] = 'b'
else:
    s[k-1] = 'c'

Fixed submission:
n, k = map(int, input().split())
s = list(input())

if s[k-1] == 'A':
    s[k-1] = 'a'
elif s[k-1] == 'B':
    s[k-1] = 'b'
else:
    s[k-1] = 'c'

print(''.join(s))
Buggy python submission (verdict: Runtime Error):
s = input()
if s[:2] == '00' or s[2:] == '00':
    print('NA')
elif s[:2] > 12 and 0 <= s[2:] <= 12:
    print('YYMM')
elif 0 <= s[:2] <= 12 and 0 <= s[2:] <= 12:
    print('AMBIGUOUS')
else:
    print('MMYY')


Fixed submission:
s = input()

f = (0 < int(s[:2]) < 13)
s = (0 < int(s[2:]) < 13)
ans = 'NA'
if f and s:
    ans = 'AMBIGUOUS'
elif s:
    ans = 'YYMM'
elif f:
    ans = 'MMYY'
print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq as hp
import numpy as np

h, w = map(int, input().split())
s = np.array([list(input()) for _ in range(h)])
s = np.pad(s, 1, 'constant')
visited = np.zeros_like(s, dtype=np.bool)

judge = np.inf

q = []
hp.heappush(q, (0, 1, 1))

while h:
    cnt, y, x = hp.heappop(q)
    if y == h and x == w:
        judge = cnt
        break
    for dy, dx in [[0, 1], [1, 0], [-1, 0], [0, -1]]:
        ny, nx = y + dy, x + dx
        if s[ny, nx] == '.' and not visited[ny, nx]:
            visited[ny, nx] = True
            hp.heappush(q, (cnt + 1, ny, nx))

if judge == np.inf:
    print(-1)
else:
    print((s == '.').sum() - judge - 1)


Fixed submission:
from collections import deque

h, w = map(int, input().split())
s = [input() for _ in range(h)]

cnt = 0
for i in s:
    cnt += i.count('.')

queue = deque([[0, 0]])
visited = [[1] * w for _ in range(h)]
visited[0][0] = 0

def bfs():
    while len(queue) > 0:
        h1, w1 = queue.popleft()
        if h1 == h - 1 and w1 == w - 1:
            return visited[h1][w1]
        for k, l in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            n_h, n_w = h1 + k, w1 + l
            if n_h < 0 or n_w < 0 or n_h >= h or n_w >= w:
                continue
            if visited[n_h][n_w] == 1 and s[n_h][n_w] == '.':
                queue.append([n_h, n_w])
                visited[n_h][n_w] += visited[h1][w1]
    return -1
    
bfs = bfs()
ans = 0
if bfs == -1:
    ans = -1
else:
    ans = cnt - bfs - 1
print(ans)
Buggy python submission (verdict: Runtime Error):
k, s = map(int, input().split())
count = 0

for x in range(k + 1):
    x = i
    for y in range(k + 1):
        if (s - x - y >= 0 and s - x - y <= k):
            count += 1
            
print(count)


Fixed submission:
k, s = map(int, input().split())
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        if (s - x - y >= 0 and s - x - y <= k):
            count += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0

for i in range(k + 1):
    x = i
    for j in range(k + 1):
        y = j
        for l in range(k + 1):
            z = l
            if x + y + z == s:
                count += 1
print(count)


Fixed submission:
k, s = map(int, input().split())
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        if (s - x - y >= 0 and s - x - y <= k):
            count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
k, s = int(input().split())
count = 0

for i in range(k):
    x = i
    for j in range(k):
        y = j
        for l in range(k):
            z = l
            if x + y + z == s:
                count += 1
print(count)


Fixed submission:
k, s = map(int, input().split())
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        if (s - x - y >= 0 and s - x - y <= k):
            count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
L, R, d= int(input().split())
counter=0
for i in range(R+1-L):
  num = i+L
  if num%d == 0:
    counter+=1
print(counter)

Fixed submission:

L, R ,d= map(int,input().split())
counter=0
for i in range(R+1-L):
  num = i+L
  if num%d == 0:
    counter+=1
print(counter)

Buggy python submission (verdict: Runtime Error):
L, R , d= int(input().split())

counter=0
for i in range(R-L):
  num = i+L
  if num%d:
    counter+=1
print(counter)

Fixed submission:

L, R ,d= map(int,input().split())
counter=0
for i in range(R+1-L):
  num = i+L
  if num%d == 0:
    counter+=1
print(counter)

Buggy python submission (verdict: Runtime Error):
L, R d = input().split()
counter=0
for i in range(R-L):
  num = i+L
  if num%d:
    counter+=1
print(counter)

Fixed submission:

L, R ,d= map(int,input().split())
counter=0
for i in range(R+1-L):
  num = i+L
  if num%d == 0:
    counter+=1
print(counter)
Buggy python submission (verdict: Runtime Error):
N= map(int, input())
a = list(map(int,input().split()))

counter=0
for i in range(N):
  print(a[i])

Fixed submission:
N= int(input())
a = list(map(int,input().split()))

counter=0
for i in range(N):
  if (i+1)%2==1:
    if a[i]%2==1:
      counter+=1
print(counter)

Buggy python submission (verdict: Runtime Error):
N= map(int, input())
a = list(map(int,input().split()))

counter=0
for i in range(N):
  if (i+1)%2==1:
    if a[i]%2==1:
        counter+=1
print(counter)

Fixed submission:
N= int(input())
a = list(map(int,input().split()))

counter=0
for i in range(N):
  if (i+1)%2==1:
    if a[i]%2==1:
      counter+=1
print(counter)

Buggy python submission (verdict: Runtime Error):
N= map(int, input())
a = list(map(int,input().split()))

counter=0
for i in range(N):
  if (i+1)%2==1:
    if a[i]%2==1:
      counter+=1
print(counter)

Fixed submission:
N= int(input())
a = list(map(int,input().split()))

counter=0
for i in range(N):
  if (i+1)%2==1:
    if a[i]%2==1:
      counter+=1
print(counter)
Buggy python submission (verdict: Runtime Error):
A=input()
 
if A in "7":
  print("Yes")
  
  else:
  	print("No")

Fixed submission:
n = input()
 
print('Yes' if '7' in n else 'No')

Buggy python submission (verdict: Runtime Error):
A=input()

if A in "7":
  print("Yes")

else:
  print("No
")

Fixed submission:
n = input()
 
print('Yes' if '7' in n else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))
max = 0
for i in range(len(A)+1):
  time_a = 0
  if i > 0:
    time_a = sum(A[:i])
  if time_a > K:
    break
  for j in range(len(B)+1):
    time = time_a
    if j > 0:
    	time += sum(B[:j])
    if time > K:
      break
    elif max < i+j:
      max = i+j
print(max)

Fixed submission:
N, M, K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))

sumA = [0] * (N+1)
sumB = [0] * (M+1)
for i in range(N):
  sumA[i+1] = sumA[i] + A[i]
for i in range(M):
  sumB[i+1] = sumB[i] + B[i]

b_i = M
max_count = 0
for i in range(N+1):
  a = sumA[i]
  if a > K:
    continue
  if b_i>0:
    while a + sumB[b_i] > K:
      b_i -= 1
      if b_i==0:
        break
  max_count = max(max_count, i + b_i)
print(max_count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))
max = 0
memo = {"A":0, "B":0, "time":0}
for i in range(len(A)+1):
  for j in range(len(B)+1):
    time = 0
    if i > 0:
    	time += sum(A[:i])
    if j > 0:
    	time += sum(B[:j])
    if time > K:
      break
    elif max < i+j:
      max = i+j
      memo["A"] = i
      memo["B"] = j
      memo["time"] = time
      
print(max) # , memo)

Fixed submission:
N, M, K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))

sumA = [0] * (N+1)
sumB = [0] * (M+1)
for i in range(N):
  sumA[i+1] = sumA[i] + A[i]
for i in range(M):
  sumB[i+1] = sumB[i] + B[i]

b_i = M
max_count = 0
for i in range(N+1):
  a = sumA[i]
  if a > K:
    continue
  if b_i>0:
    while a + sumB[b_i] > K:
      b_i -= 1
      if b_i==0:
        break
  max_count = max(max_count, i + b_i)
print(max_count)
Buggy python submission (verdict: Runtime Error):
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s); sys.stdout.write('\n')
def wi(n): sys.stdout.write(str(n)); sys.stdout.write('\n')
def wia(a, sep=' '): sys.stdout.write(sep.join([str(x) for x in a])); sys.stdout.write('\n')


def main():
    n = ri()
    for nn in range(1, n+1):
        s = int(nn**0.5) + 2
        cnt = 0
        for x in range(1, s):
            for y in range(1, s):
                r1 = x*x + y*y + x*y
                if r1 > nn:
                    break
                for z in range(1, s):
                    r = x*x + y*y + z*z + x*y + y*z + z*x
                    if r > nn:
                        break
                    if r == nn:
                        cnt += 1
        wi(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s); sys.stdout.write('\n')
def wi(n): sys.stdout.write(str(n)); sys.stdout.write('\n')
def wia(a, sep=' '): sys.stdout.write(sep.join([str(x) for x in a])); sys.stdout.write('\n')


def main():
    l, r, d = ria()
    cnt = 0
    for x in range(l, r+1):
        if x % d == 0:
            cnt += 1
    wi(cnt)


if __name__ == '__main__':
    main()