Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
h, n = map(int, input().split())
magics = [list(map(int, input().split())) for _ in range(n)]

dp = [0] * (h+1)

for i in range(1,h+1):
    dp[i] = min(dp[i-a]+b for a, b in magics)
print(dp[h])

Fixed submission:
h, n = map(int, input().split())
magics = [list(map(int, input().split())) for _ in range(n)]
max_a = max(a for a,b in magics)
dp = [0] * (h+max_a)

for i in range(1,h+max_a):
    dp[i] = min(dp[i-a]+b for a, b in magics)
print(dp[h])
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

ab = []

for i in range(m):
    a, b = map(int, input().split())
    ab.append((a,b))

ab = sorted(ab, key = lambda x: x[[1])

left = 0
ans = 0


for a, b in ab:
    if a < left:
        ans += 1
        left = b-1
    
print(ans)
        

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

ab = []

for i in range(m):
    a, b = map(int, input().split())
    ab.append((a,b))

ab = sorted(ab, key = lambda x: x[1])

left = 0
ans = 0


for a, b in ab:
    if a > left:
        ans += 1
        left = b-1
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n = INT()
    p = LIST()
    ans = 0

    for i in range(n):
        #print(p[:i+1])
        if p[i] <= min(p[:i+1]):
            ans += 1
    print(ans)

if __name__=='__main__':
    main()


Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n = INT()
    p = LIST()
    ans = 0

    mi = p[0]
    for x in p:
        if x <= mi:
            ans += 1
            mi = x
    print(ans)


if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n = INT()
    l = LIST()
    lis = list(combinations(l, 3))
    #print(lis)
    ans = 0
    for x in lis:
        #print(abs(x[0] - x[1]) , x[2] , x[0] + x[1])
        #print(abs(x[0] - x[1]) < x[2] < x[0] + x[1])
        if abs(x[0] - x[1]) < x[2] < x[0] + x[1]:
            ans +=1
    
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left

def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n = INT()
    l = LIST()
    l.sort()
    ans = 0
    #print(l)

    for i in range(n-1):
        for j in range(i+1, n):
            low = l[i]
            high = l[j]

            p = bisect_left(l, low + high)
            #print('i:', i, 'j:', j, '→', max(0, p-j-1))
            ans += max(0, p - j - 1)

    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n = INT()
    a = LIST()
    ans = [a.index(i)+1 for i in range(1, n+1)]

    print(*ans)

if  __name__=='__main__':
    main()


Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n = INT()
    a = LIST()
    l = [[a[i], i+1] for i in range(n)]
    l.sort()
    ans = [x[1] for x in l]
    print(*ans)

if  __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n,a,b=INT()
    print(min(n*a,b))

if  __name__=='__main__':
    main()


Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n,a,b=MAP()
    print(min(n*a,b))

if  __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    P=list(input())
    ct_a=0
    ct_s=0
    for x in P:
        if x=='A' :
            ct_a+=1
        elif x=='S':
            ct_s+=1
    if ct_a==2 an ct_s==2:
        print('Yes')
    else:
        print('No')




if  __name__=='__main__':
    main()


Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    s=list(input())
    t=set(s)
    if len(t)==2:
        print('Yes')
    else:
        print('No')


if  __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a,p=int(input().split())

print(int((a*3+p)/2))

Fixed submission:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from copy import copy
import numpy as np
from numpy.fft import fft, ifft
from fractions import gcd


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a, p = MAP()

print(int((a*3+p)/2))

Buggy python submission (verdict: Runtime Error):
a,p=input().split()

print(int((a*3+p)/2))

Fixed submission:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from copy import copy
import numpy as np
from numpy.fft import fft, ifft
from fractions import gcd


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a, p = MAP()

print(int((a*3+p)/2))
Buggy python submission (verdict: Runtime Error):
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a,b,t=MAP()

print(int((t+0.5)/a)*b)
                                                                                    
                                                                            32,0-1       全て


Fixed submission:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a,b,t=MAP()

print(int((t+0.5)/a)*b)
Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline

s = list(input().rstrip())

lis = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    for j in range(4):
        if (s[i] == lis[j]):
            s[i] = 'う～えす～ぎさ～ん'
            break


ct = 0
ct_lis = []

for i, x in enumerate(s):
    if (x == 'う～えす～ぎさ～ん'):
        ct += 1
    else:
        ct_lis.append([ct])
        ct = 0

print(max(ct_lis)[0])


Fixed submission:
import sys

input = sys.stdin.readline

s = list(input().rstrip())

lis = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    for j in range(4):
        if (s[i] == lis[j]):
            s[i] = 'AYATASO'
            break

ct = 0
ct_lis = []

for i, x in enumerate(s):
    if (x == 'AYATASO'):
        ct += 1
    else:
        ct_lis.append(ct)
        ct = 0

ct_lis.append(ct)

print(max(ct_lis))

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

input = sys.stdin.readline

s = list(input().rstrip())

lis = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    for j in range(4):
        if (s[i] == lis[j]):
            s[i] = 'う～えす～ぎさ～ん'


ct = 0
ct_lis = []

for i, x in enumerate(s):
    if (x == 'う～えす～ぎさ～ん'):
        ct += 1
    else:
        ct_lis.append([ct])
        ct = 0

print(max(ct_lis)[0])


Fixed submission:
import sys

input = sys.stdin.readline

s = list(input().rstrip())

lis = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    for j in range(4):
        if (s[i] == lis[j]):
            s[i] = 'AYATASO'
            break

ct = 0
ct_lis = []

for i, x in enumerate(s):
    if (x == 'AYATASO'):
        ct += 1
    else:
        ct_lis.append(ct)
        ct = 0

ct_lis.append(ct)

print(max(ct_lis))

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

input = sys.stdin.readline

s = list(input().rstrip())

lis = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    for j in range(4):
        if (s[i] == lis[j]):
            s[i] = 'う～えす～ぎさ～ん'


ct = 0
ct_lis = []

for i, x in enumerate(s):
    if (x == 'う～えす～ぎさ～ん'):
        ct += 1
    else:
        ct_lis.append([ct])
        ct = 0

print(max(ct_lis))


Fixed submission:
import sys

input = sys.stdin.readline

s = list(input().rstrip())

lis = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    for j in range(4):
        if (s[i] == lis[j]):
            s[i] = 'AYATASO'
            break

ct = 0
ct_lis = []

for i, x in enumerate(s):
    if (x == 'AYATASO'):
        ct += 1
    else:
        ct_lis.append(ct)
        ct = 0

ct_lis.append(ct)

print(max(ct_lis))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, Q = MAP()
S = input()
lr = [LIST() for _ in range(Q)]


def func(s, l, r):
    lis = []
    ret = 0
    for i in range(l-1, r):
        lis.append(s[i])

    for i, x in enumerate(lis):
        if(i == r-l):
            break
        else:
            if x == 'A' and lis[i + 1] == 'C':
                ret += 1

    return ret


for i in range(Q):
    print(func(S, lr[i][0], lr[i][1]))


Fixed submission:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, Q = MAP()
S = list(input())
lr = [LIST() for _ in range(Q)]

lis = [0]*N

for i, x in enumerate(S):
    if (i == N-1):
        break
    else:
        if x == 'A' and S[i + 1] == 'C':
            lis[i+1] = lis[i]+1
        else:
            lis[i+1] = lis[i]


for i in range(Q):
    print(lis[lr[i][1]-1]-lis[lr[i][0]-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = (int(_) for _ in input().split())
ab_list = [[int(i) for i in input().split()] for i in range(n)]

ab_list = sorted(ab_list)

buy = 0
money = 0
j = 0
lst = []

for i in range(n):
    lst.append(ab_list[n - i - 1][1])
    b_sum = sum(lst)

while (buy < m):
    buy += ab_list[j][1]
    money += ab_list[j][0] * ab_list[j][1]
    j += 1

print(money-(ab_list[j-1][0]*(buy-m)))


Fixed submission:
n, m = (int(_) for _ in input().split())
ab_list = [[int(i) for i in input().split()] for i in range(n)]

ab_list = sorted(ab_list)

buy = 0
money = 0
j = 0


while (buy < m):
    buy += ab_list[j][1]
    money += ab_list[j][0] * ab_list[j][1]
    j += 1

print(money-(ab_list[j-1][0]*(buy-m)))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = (int(_) for _ in input().split())
ab_list = [[int(i) for i in input().split()] for i in range(n)]
a_list = []
b_list = []
for i in range(n):
    a_list.append(ab_list[i][0])
    b_list.append(ab_list[i][1])


buy = 0
money = 0
while (n >= 0):
    min_a = min(a_list)
    min_index = a_list.index(min_a)
    if (buy + b_list[min_index] < m):
        money += b_list[min_index] * a_list[min_index]
        buy += b_list[min_index]
    else:
        money += (m - buy) * a_list[min_index]
        break

    a_list.pop(min_index)
    b_list.pop(min_index)

    n -= 1

print(money)


Fixed submission:
n, m = (int(_) for _ in input().split())
ab_list = [[int(i) for i in input().split()] for i in range(n)]

ab_list = sorted(ab_list)

buy = 0
money = 0
j = 0


while (buy < m):
    buy += ab_list[j][1]
    money += ab_list[j][0] * ab_list[j][1]
    j += 1

print(money-(ab_list[j-1][0]*(buy-m)))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n, k = MAP()

h = LIST()

dp = [INF] * n
dp[0] = 0

for i in range(n):
    for j in range(1, k+1):
        if (i < n - j):
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))


print(dp[-1])


Fixed submission:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n, k = MAP()

h = LIST()

dp = [INF] * n
dp[0] = 0

for i, hi in enumerate(h):
    if i == 0:
        continue
    s = i-k if i-k >= 0 else 0
    dp[i] = min([dpk + abs(hi-hk) for dpk, hk in zip(dp[s:i], h[s:i])])

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n,x = MAP()
    L = [1]*n
    P = [1]*n

    for  i in range(1,n):
        L[i] = 2* L[i-1] +3
        P[i] = 2* P[i-1] + 1

    def func(N, X):
        if N==0:
            return 0 if X <= 0 else 1

        elif X<= L[N-1] + 1:
            return func(N-1, X-1)

        else:
            return P[N-1] + 1 + func(N-1, X-L[N-1] -2)

    print(func(n,x))

if  __name__=='__main__':
    main()

Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    p = [INT() for _ in range(n)]

    p_max = max(p)

    print(sum(p) - int((p_max/2)))

if  __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
x = ((N - (N % 111)) / 111) * 111

Fixed submission:
N = int(input())
if N % 111 == 0:
        x = ((N - (N % 111)) / 111) * 111
else:
        x = (((N - (N % 111)) / 111) + 1) * 111
print(int(x))
Buggy python submission (verdict: Runtime Error):
s = input().sorted()
t = input().sorted(reverse=True)
if(new_s < new_t): print("Yes")
else: print("No")

Fixed submission:
s = sorted(input())
t = sorted(input(),reverse=True)
if(s < t): print("Yes")
else: print("No")
Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout
input = stdin.readline
print = stdout.write
n, m, k = map(int, input().split())
a, b = [0], [0]
a += list(map(int, input().split())),
b += list(map(int, input().split())),
for i in range(1, n + 1):
    a[i] += a[i - 1]
for i in range(1, m + 1):
    b[i] += b[i - 1]
i, j, z = 0, m, 0
while i <= n and a[i] <= k:
    while b[j] > k - a[i]:
        j -= 1
    z = max(z, i + j)
    i += 1
print(str(z))

Fixed submission:
from sys import stdin, stdout
input = stdin.readline
print = stdout.write 
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    a[i] += a[i - 1]
for i in range(1, m + 1):
    b[i] += b[i - 1]
i, j, z = 0, m, 0
while i <= n and a[i] <= k:
    while b[j] > k - a[i]:
        j -= 1
    z = max(z, i + j)
    i += 1
print(str(z))