Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
ans=0
for i in range(1000):
    one=str(i//100)
    two=str((i%100)//10)
    three=str(i%10)
    f1,f2,f3=False,False,False
    ptr=0
    for j in range(ptr,N-2):
        if S[j]==one:
            f1=True
            ptr=j+1
            break
    if f1:
        for j in range(ptr,N-1):
            if S[j]==two:
                f2=True
                ptr=j+1
                break
        if f2:
            for j in range(ptr,N):
                if S[j]==three:
                    f3=True
                    ans+=1
                    break
print(ans)

Fixed submission:
N=int(input())
S=input()
ans=0
for i in range(1000):
    one=str(i//100)
    two=str((i%100)//10)
    three=str(i%10)
    f1,f2,f3=False,False,False
    ptr=0
    for j in range(ptr,N-2):
        if S[j]==one:
            f1=True
            ptr=j+1
            break
    if f1:
        for j in range(ptr,N-1):
            if S[j]==two:
                f2=True
                ptr=j+1
                break
        if f2:
            for j in range(ptr,N):
                if S[j]==three:
                    f3=True
                    ans+=1
                    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
ans=0
for i in range(1000):
    one=str(i//100)
    two=str((i%100)//10)
    three=str(i%10)
    f1,f2,f3=False,False,False
    ptr=0
    for j in range(ptr,N-2):
        if S[j]==one:
            f1=True
            ptr=j+1
            break
    for j in range(ptr,N-1):
        if S[j]==two:
            f2=True
            ptr=j+1
            break
    for j in range(ptr,N):
        if S[j]==three:
            f3=True
            break
    if f1 and f2 and f3:
        ans+=1
print(ans)

Fixed submission:
N=int(input())
S=input()
ans=0
for i in range(1000):
    one=str(i//100)
    two=str((i%100)//10)
    three=str(i%10)
    f1,f2,f3=False,False,False
    ptr=0
    for j in range(ptr,N-2):
        if S[j]==one:
            f1=True
            ptr=j+1
            break
    if f1:
        for j in range(ptr,N-1):
            if S[j]==two:
                f2=True
                ptr=j+1
                break
        if f2:
            for j in range(ptr,N):
                if S[j]==three:
                    f3=True
                    ans+=1
                    break
print(ans)
Buggy python submission (verdict: Runtime Error):
l,r=map(int,input().split())
i=l//2019
d=list(range(l,r+1))
for j in range(len(d)):
    d[j]%=2019
    d2=sorted(d)
    print(d2[0]*d2[1])


Fixed submission:
l,r=map(int,input().split())
x=l//2019
if 2019*x<l and r<2019*(x+1):
    ans=float("inf")
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans=min(ans,(i*j)%2019)
    print(ans)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
count=0
i=min(A,B)
while count<K:
    i-=1
    if A%i==0 and B%i==0:
        count+=1
print(i)

Fixed submission:
A,B,K=map(int,input().split())
count=0
for i in range(max(A,B),0,-1):
    if A%i==0 and B%i==0:
        count+=1
        if count==K:
            print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
H=list(map(int,input().split()))

dp=[0]+[float('inf')]*(N-1)
for n in range(1,N):
    for i in range(max(0,n-K),n):
        dp[n]=min(dp[n],dp[i]+abs(H[n]-H[i]))

print(dp[N-1])

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

dp=[float('inf')]*N
dp[0]=0
dp[1]=abs(H[1]-H[0])

for n in range(2,N):
    if n-K>0:
        dp[n]=min([(dp[i]+abs(H[n]-H[i]))for i in range(n-K,n)])
    else:
        dp[n]=min([dp[i]+abs(H[n]-H[i])for i in range(0,n)])

print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
H=list(map(int,input().split()))

dp=[float('inf')]*N
dp[0]=0
dp[1]=abs(H[1]-H[0])

for n in range(2,N):
    if n-K>0:
        s=n-K
    else:
        s=0
    l=[]
    for i in range(s,n):
        l.append(dp[i]+abs(H[n]-H[i]))
    dp[n]=min(l)

print(dp[N-1])

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

dp=[float('inf')]*N
dp[0]=0
dp[1]=abs(H[1]-H[0])

for n in range(2,N):
    if n-K>0:
        dp[n]=min([(dp[i]+abs(H[n]-H[i]))for i in range(n-K,n)])
    else:
        dp[n]=min([dp[i]+abs(H[n]-H[i])for i in range(0,n)])

print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
H=list(map(int,input().split()))

dp=[float('inf')]*N
dp[0]=0
dp[1]=abs(H[1]-H[0])

for n in range(2,N):
    if n-K>0:
        s=n-K
    else:
        s=0
    l=[]
    for i in range(n-K,n):
        l.append(dp[i]+abs(H[n]-H[i]))
    dp[n]=min(l)

print(dp[N-1])

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

dp=[float('inf')]*N
dp[0]=0
dp[1]=abs(H[1]-H[0])

for n in range(2,N):
    if n-K>0:
        dp[n]=min([(dp[i]+abs(H[n]-H[i]))for i in range(n-K,n)])
    else:
        dp[n]=min([dp[i]+abs(H[n]-H[i])for i in range(0,n)])

print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
H=list(map(int,input().split()))
dp=[float('inf')]*N
dp[0]=0

for i in range(1,N):
    for k in range(1,K+1):
        if i-k<0:
            break
        dp[i]=min(dp[i],dp[i-k]+abs(H[i]-H[i-k]))

print(dp[N-1])

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

dp=[float('inf')]*N
dp[0]=0
dp[1]=abs(H[1]-H[0])

for n in range(2,N):
    if n-K>0:
        dp[n]=min([(dp[i]+abs(H[n]-H[i]))for i in range(n-K,n)])
    else:
        dp[n]=min([dp[i]+abs(H[n]-H[i])for i in range(0,n)])

print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
input=sys.stdin.readline

def dp(N,W):
    ans=np.zeros(W+1,dtype=np.int)
    for _ in range(N):
        w,v=map(int,input().split())
        for i in range(W,w-1,-1):
            tmp=ans[i-w]+v
            if ans[i]<tmp:
                ans[i]=tmp
    print(ans[-1])

N,W=map(int,input().split())
dp(N,W)

Fixed submission:
def opt(N,W):
    dp=[0]*(W+1)
    for _ in range(N):
        w,v=map(int,input().split())
        for i in range(W,w-1,-1):
            tmp=dp[i-w]+v
            if tmp>dp[i]:
                dp[i]=tmp
    print(dp[W])

N,W=map(int,input().split())
opt(N,W)

Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
dp=[0]*(W+1)
for _ in range(N):
    w,v=map(int,input().split())
    for i in range(W,w-1,-1):
        tmp=dp[i-w]+v
        if tmp>dp[i]:
            dp[i]=tmp
print(dp[W])


Fixed submission:
def opt(N,W):
    dp=[0]*(W+1)
    for _ in range(N):
        w,v=map(int,input().split())
        for i in range(W,w-1,-1):
            tmp=dp[i-w]+v
            if tmp>dp[i]:
                dp[i]=tmp
    print(dp[W])

N,W=map(int,input().split())
opt(N,W)

Buggy python submission (verdict: Time Limit Exceeded):
def opt(N,W):
    dp=[0]*(W+1)
    for _ in range(N):
        w,v=map(int,input().split())
        for i in range(W,w-1,-1):
            dp[i]=max(dp[i],dp[i-w]+v)
    print(dp[W])

N,W=map(int,input().split())
opt(N,W)

Fixed submission:
def opt(N,W):
    dp=[0]*(W+1)
    for _ in range(N):
        w,v=map(int,input().split())
        for i in range(W,w-1,-1):
            tmp=dp[i-w]+v
            if tmp>dp[i]:
                dp[i]=tmp
    print(dp[W])

N,W=map(int,input().split())
opt(N,W)

Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
dp=[0]*(W+1)
for _ in range(N):
    w,v=map(int,input().split())
    for i in range(W,w-1,-1):
        dp[i]=max(dp[i],dp[i-w]+v)
print(dp[W])

Fixed submission:
def opt(N,W):
    dp=[0]*(W+1)
    for _ in range(N):
        w,v=map(int,input().split())
        for i in range(W,w-1,-1):
            tmp=dp[i-w]+v
            if tmp>dp[i]:
                dp[i]=tmp
    print(dp[W])

N,W=map(int,input().split())
opt(N,W)

Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(N)]
dp=[[0]*(W+1)for _ in range(N+1)]
for n in range(1,N+1):
    for w in range(1,W+1):
        if w<wv[n-1][0]:
            dp[n][w]=dp[n-1][w]
        else:
            dp[n][w]=max(dp[n-1][w],dp[n-1][w-wv[n-1][0]]+wv[n-1][1])

print(dp[N][W])

Fixed submission:
def opt(N,W):
    dp=[0]*(W+1)
    for _ in range(N):
        w,v=map(int,input().split())
        for i in range(W,w-1,-1):
            tmp=dp[i-w]+v
            if tmp>dp[i]:
                dp[i]=tmp
    print(dp[W])

N,W=map(int,input().split())
opt(N,W)
Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
wv=[[0,0]]+[list(map(int,input().split()))for _ in range(N)]
v_max=sum(wv[i][1]for i in range(N+1))

dp=[[0]*(N+1)]+[[float('inf')]*(N+1)for _ in range(v_max)]
for v in range(1,v_max+1):
    for n in range(1,N+1):
        dp[v][n]=min((dp[v][n-1],dp[v-wv[n][1]][n-1]+wv[n][0]))

print(max(v for v in range(v_max+1) if dp[v][N]<=W))

Fixed submission:
N,W=map(int,input().split())
wv=[[0,0]]+[list(map(int,input().split()))for _ in range(N)]
v_max=sum(wv[i][1]for i in range(N+1))

dp=[[0]*(N+1)]+[[float('inf')]*(N+1)for _ in range(v_max)]
for v in range(1,v_max+1):
    for n in range(1,N+1):
        dp[v][n]=min((dp[v][n-1],dp[v-wv[n][1]][n-1]+wv[n][0]))

print(max(v for v in range(v_max+1) if dp[v][N]<=W))
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()
m,n=len(s),len(t)
dp=[[0]*(n+1)for _ in range(m+1)]
for i in range(m):
    for j in range(n):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            if dp[i+1][j]>dp[i][j+1]:
                dp[i+1][j+1]=dp[i+1][j]
            else:
                dp[i+1][j+1]=dp[i][j+1]
a,b=m,n
tmp=''
while a and b:
    if s[a-1]==t[b-1]:
        a-=1
        b-=1
        tmp+=s[a]
    elif dp[a][b]==dp[a-1][b]:
        a-=1
    else:
        b-=1
print(tmp[::-1])


Fixed submission:
s=input()
t=input()
m,n=len(s),len(t)
dp=[[0]*(n+1)for _ in range(m+1)]
for i in range(m):
    for j in range(n):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            if dp[i+1][j]>dp[i][j+1]:
                dp[i+1][j+1]=dp[i+1][j]
            else:
                dp[i+1][j+1]=dp[i][j+1]
a,b=m,n
tmp=''
while a and b:
    if s[a-1]==t[b-1]:
        a-=1
        b-=1
        tmp+=s[a]
    elif dp[a][b]==dp[a-1][b]:
        a-=1
    else:
        b-=1
print(tmp[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

N=int(input())
p=list(map(float,input().split()))

dp=[[0]*(N+1)for _ in range(N+1)]
for i in range(N+1):
    for j in range(N+1):
        if i==0 and j==0:
            dp[i][j]=1
        elif i==0:
            continue
        elif j==0:
            dp[i][j]=dp[i-1][j]*(1-p[i-1])
        else:
            dp[i][j]=(dp[i-1][j]*(1-p[i-1]))+(dp[i-1][j-1]*p[i-1])

ans=0
for j in range(((N//2)+1),N+1):
    ans+=dp[N][j]
print(ans)


Fixed submission:
import sys
input=sys.stdin.readline

N=int(input())
p=list(map(float,input().split()))

dp=[[0]*(N+1)for _ in range(N+1)]
for i in range(N+1):
    for j in range(N+1):
        if i==0 and j==0:
            dp[i][j]=1
        elif j==0:
            dp[i][j]=dp[i-1][j]*(1-p[i-1])
        elif i>=j:
            dp[i][j]=(dp[i-1][j]*(1-p[i-1]))+(dp[i-1][j-1]*p[i-1])

ans=0
for j in range(((N//2)+1),N+1):
    ans+=dp[N][j]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
ans=len(str(N))
for a in range(2,math.sqrt(N)+1):
    if N%a==0:
        b=N//a
        ans=min(ans,len(str(b)))
print(ans)

Fixed submission:
N=int(input())
ans=len(str(N))
for a in range(2,int(N**0.5)+1):
    if N%a==0:
        b=N//a
        ans=min(ans,len(str(b)))
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
ans=len(str(N))
for a in range(2,math.sqrt(N**0.5)+1):
    if N%a==0:
        b=N//a
        ans=min(ans,len(str(b)))
print(ans)

Fixed submission:
N=int(input())
ans=len(str(N))
for a in range(2,int(N**0.5)+1):
    if N%a==0:
        b=N//a
        ans=min(ans,len(str(b)))
print(ans)
Buggy python submission (verdict: Runtime Error):
x, y = [int(_) for _ in input().split(' ')]

M = int(1e9+7)

def modpow(a, n):
    if n == 0:
        return 1
    elif n == 1:
        return a
    elif n % 2 == 0:
        tmp = modpow(a, n // 2)
        return (tmp * tmp) % M
    else:
        tmp = modpow(a, n // 2)
        return (tmp * tmp * a) % M

def modinv(a):
    return modpow(a, M - 2)


if (x + y) % 3 == 0:
    a, b = (-x + 2 * y) // 3, (2 * x - y) // 3

    f = [1] * (a + b + 1)
    for i in range(1, a + b + 1):
        f[i] = f[i - 1] * i % M

    answer = (f[a + b] * modinv(f[a]) * modinv(f[b])) % M
    print(answer)
else:
    print(0)


Fixed submission:
x, y = [int(_) for _ in input().split(' ')]

M = int(1e9+7)

def modpow(a, n):
    if n == 0:
        return 1
    elif n == 1:
        return a
    elif n % 2 == 0:
        tmp = modpow(a, n // 2)
        return (tmp * tmp) % M
    else:
        tmp = modpow(a, n // 2)
        return (tmp * tmp * a) % M

def modinv(a):
    return modpow(a, M - 2)

if (x + y) % 3 == 0:
    a, b = (-x + 2 * y) // 3, (2 * x - y) // 3

    if a >= 0 and b >= 0:
        f = [1] * (a + b + 1)
        for i in range(1, a + b + 1):
            f[i] = f[i - 1] * i % M

        answer = (f[a + b] * modinv(f[a]) * modinv(f[b])) % M
        print(answer)
    else:
        print(0)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = [int(_) for _ in input().split(' ')]
print(max([i for i in range(1, m // n + 1) if m % i == 0]))


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

ds = [i for i in range(1, int(m ** 0.5) + 1) if m % i == 0]
ds.extend([m // i for i in ds])
print(max([i for i in ds if i <= m // n]))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()

count = len(T)

for i in range(len(T)):
    for j in range(len(S)):
        if T[i] == S[j]:
            start = j - i
            end = j + (len(T) - i)
            if start < 0 or end > len(S):
                continue
            else:
                s = S[start:end]
                c = 0
                for k in range(len(T)):
                    if T[k] != s[k]:
                        c += 1
                count = min(count, c)
print(count)


Fixed submission:
n_gram = lambda t, n: [t[i:i+n] for i in range(len(t) - n + 1)]

S = input()
T = input()

t_len = len(T)
count = t_len

s_list = n_gram(S, t_len)

for s in s_list:
    c = 0
    for i in range(len(s)):
        if s[i] != T[i]:
            c += 1
    count = min(count, c)

print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = int(input(), 2)

f = {}


def calcF(i, count):
    if i == 0:
        return count
    if i in f:
        return count + f[i]
    icount = bin(i).count("1")
    if icount == 0:
        return count + 1
    r = i % icount
    if r != 0:
        return calcF(r, count + 1)
    else:
        return count + 1


for i in range(1, 2 ** N):
    f[i] = calcF(i, 0)

for i in range(1, N + 1):
    a = X ^ 2 ** ((N - 1) - (i - 1))
    if a == 0:
        print(0)
    else:
        print(f[a])


Fixed submission:
L, R, d = map(int, input().split())
count = 0
for i in range(L, R + 1):
    if i % d == 0:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
h = list(map(int, input().split()))

dp = [0] * N

for i in range(1, N):
    dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
    for j in range(2, min(i, K) + 1):
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))

print(dp[-1])


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

dp = [0] * N

for i in range(1, N):
    dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
    for j in range(2, min(i, K) + 1):
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N, X, M = map(int, input().split())

nxt = X
lst = []
dic = {}

for i in range(M):
    if nxt in dic:
        loop_st = dic[nxt]
        loop_ed = i - 1
        break

    lst.append(nxt)
    dic[nxt] = i

    nxt = (nxt ** 2) % M


v = N - loop_st
q, r = divmod(v, loop_ed - loop_st + 1)

pre_sum = sum(lst[:loop_st])
loop_sum = q * sum(lst[loop_st:])
post_sum = sum(lst[loop_st:loop_st + r])
print(pre_sum + loop_sum + post_sum)

Fixed submission:
N, X, M = map(int, input().split())

nxt = X
lst = []
dic = {}

for i in range(M + 1):
    if nxt in dic:
        loop_st = dic[nxt]
        loop_ed = i - 1
        break

    lst.append(nxt)
    dic[nxt] = i

    nxt = (nxt ** 2) % M


v = N - loop_st
q, r = divmod(v, loop_ed - loop_st + 1)

pre_sum = sum(lst[:loop_st])
loop_sum = q * sum(lst[loop_st:])
post_sum = sum(lst[loop_st:loop_st + r])
print(pre_sum + loop_sum + post_sum)

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

nxt = X
lst = []
dic = {}

for i in range(M):
    if nxt in dic:
        loop_st = dic[nxt]
        loop_ed = i - 1
        break

    lst.append(nxt)
    dic[nxt] = i

    nxt = (nxt ** 2) % M


v = N - loop_st
q, r = divmod(v, loop_ed - loop_st + 1)

pre_sum = sum(lst[:loop_st])
loop_sum = q * sum(lst[loop_st:])
post_sum = sum(lst[loop_st:loop_st + r])


Fixed submission:
N, X, M = map(int, input().split())

nxt = X
lst = []
dic = {}

for i in range(M + 1):
    if nxt in dic:
        loop_st = dic[nxt]
        loop_ed = i - 1
        break

    lst.append(nxt)
    dic[nxt] = i

    nxt = (nxt ** 2) % M


v = N - loop_st
q, r = divmod(v, loop_ed - loop_st + 1)

pre_sum = sum(lst[:loop_st])
loop_sum = q * sum(lst[loop_st:])
post_sum = sum(lst[loop_st:loop_st + r])
print(pre_sum + loop_sum + post_sum)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

P = [None] + P
C = [None] + C

all_max = C[1]
for st in range(1, N + 1):
    scores = []
    visit = set()
    p = st

    while p not in visit and len(visit) < K:
        next_p = P[p]
        scores.append(C[next_p])
        visit.add(p)
        p = next_p

    num_elem = len(scores)
    all_sum = sum(scores)

    q, r = divmod(K, num_elem)

    max_ = scores[0]
    temp = scores[0]

    max_r = scores[0]
    temp_r = scores[0]
    for x in range(1, num_elem):
        if x < r:
            temp_r += scores[x]
            max_r = max(max_r, temp_r)

        temp += scores[x]
        max_ = max(max_, temp)

    temp_max = scores[0]
    if all_sum > 0 and q > 0:
        if r > 0:
            temp_max = max(all_sum * (q - 1) + max_, all_sum * q + max_r)
        else:
            temp_max = all_sum * (q - 1) + max_
    else:
        temp_max = max_

    all_max = max(all_max, temp_max)

print(all_max)


Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

P = [None] + P
C = [None] + C

all_max = C[1]
for st in range(1, N + 1):
    scores = []
    visit = set()
    p = st

    while p not in visit and len(visit) < K:
        next_p = P[p]
        scores.append(C[next_p])
        visit.add(p)
        p = next_p

    num_elem = len(scores)
    all_sum = sum(scores)

    q, r = divmod(K, num_elem)

    max_ = scores[0]
    temp = scores[0]

    max_r = scores[0]
    temp_r = scores[0]
    for x in range(1, num_elem):
        if x < r:
            temp_r += scores[x]
            max_r = max(max_r, temp_r)

        temp += scores[x]
        max_ = max(max_, temp)

    temp_max = scores[0]
    if all_sum > 0 and q > 0:
        if r > 0:
            temp_max = max(all_sum * (q - 1) + max_, all_sum * q + max_r)
        else:
            temp_max = all_sum * (q - 1) + max_
    else:
        temp_max = max_

    all_max = max(all_max, temp_max)


print(all_max)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(500000)

N, M, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))


class X:
    def __init__(self, K, A, B, N, M):
        self.A = A
        self.B = B
        self.K = K
        self.N = N
        self.M = M
        self.ret = 0

    def helper(self, i, j, time, num_a, num_b):
        if time > self.K:
            return

        self.ret = max(self.ret, num_a + num_b)

        if num_a < self.N:
            self.helper(i + 1, j, time + self.A[i], num_a + 1, num_b)

        if num_b < self.M:
            self.helper(i, j + 1, time + self.B[j], num_a, num_b + 1)

        return

    def run(self):
        self.helper(0, 0, 0, 0, 0)
        return self.ret


c = X(K, A, B, N, M)
print(c.run())



Fixed submission:
import bisect

N, M, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_sum = A.copy()
B_sum = B.copy()

for i in range(1, N):
    A_sum[i] = A_sum[i - 1] + A[i]

A_sum = [0] + A_sum

for i in range(1, M):
    B_sum[i] = B_sum[i - 1] + B[i]


max_ = 0
for i, n in enumerate(A_sum):
    if n > K:
        continue

    target = K - n
    v = bisect.bisect_left(B_sum, target)

    if v != M and B_sum[v] == target:
        v += 1

    max_ = max(max_, i + v)

print(max_)

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()))


class X:
    def __init__(self, K, A, B, N, M):
        self.A = A
        self.B = B
        self.K = K
        self.N = N
        self.M = M
        self.ret = 0

    def helper(self, i, j, time, num_a, num_b):
        if time > self.K:
            return

        self.ret = max(self.ret, num_a + num_b)

        if num_a < self.N:
            self.helper(i + 1, j, time + self.A[i], num_a + 1, num_b)

        if num_b < self.M:
            self.helper(i, j + 1, time + self.B[j], num_a, num_b + 1)

        return

    def run(self):
        self.helper(0, 0, 0, 0, 0)

        return self.ret


c = X(K, A, B, N, M)
print(c.run())


Fixed submission:
import bisect

N, M, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_sum = A.copy()
B_sum = B.copy()

for i in range(1, N):
    A_sum[i] = A_sum[i - 1] + A[i]

A_sum = [0] + A_sum

for i in range(1, M):
    B_sum[i] = B_sum[i - 1] + B[i]


max_ = 0
for i, n in enumerate(A_sum):
    if n > K:
        continue

    target = K - n
    v = bisect.bisect_left(B_sum, target)

    if v != M and B_sum[v] == target:
        v += 1

    max_ = max(max_, i + v)

print(max_)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

sum_ = 0
for i in range(1, N + 1):
    n = int(N / i)
    sum_ += (n / 2) * (2 * i + (n - 1) * i)

print(int(sum_))


Fixed submission:
N = int(input())

sum_ = 0
for i in range(1, N + 1):
    n = int(N / i)
    sum_ += (n / 2) * (2 * i + (n - 1) * i)

print(int(sum_))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

r = 1
for a in A:
    r *= a

if r > pow(10, 18):
    print(-1)
else:
    print(r)


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

A.sort(reverse=True)

for i in range(N - 1, -1, -1):
    if A[i] == 0:
        print(0)
        exit()

r = 1
upper = pow(10, 18)
for i in range(N):
    r *= A[i]

    if r > upper:
        print(-1)
        exit()

print(r)
Buggy python submission (verdict: Runtime Error):
A, B = input().split()

A = int(A)

B = float(B)
B *= 100
B = round(B)

print(int(A * B // 100))


print(int(res))



Fixed submission:
A, B = input().split()

A = int(A)

B = float(B)
B *= 100
B = round(B)

print(int(A * B // 100))