Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import array
n, k = map(int, input().split())
tel = array.array('i', list(map(int, input().split())))
log = array.array('i', [1])
end = True
while(end):
    log.append(tel[log[-1] - 1])
    for i in range(len(log) - 1):
        if(log[i] == log[-1]):
            star = i
            mod = len(log) - star - 1
            end = False
if(k < len(log)):
    print(log[k])
else:
    print(log[(k - star) % mod + star])


Fixed submission:
n, k = map(int, input().split())
tel = list(map(int, input().split()))
log = [1]
record = [0] * n
while(True):
    log.append(tel[log[-1] - 1])
    if(record[log[-1] - 1] == 1):
        break
    record[log[-1] - 1] += 1
for i in range(len(log) - 1):
    if(log[i] == log[-1]):
        star = i
        mod = len(log) - star - 1
        break
if(k < len(log)):
    print(log[k])
else:
    print(log[(k - star) % mod + star])

Buggy python submission (verdict: Time Limit Exceeded):
import array
n, k = map(int, input().split())
tel = list(map(int, input().split()))
log = array.array('l', [1])
end = True
while(end):
    log.append(tel[log[-1] - 1])
    for i in range(len(log) - 1):
        if(log[i] == log[-1]):
            star = i
            mod = len(log) - star - 1
            end = False
if(k < len(log)):
    print(log[k])
else:
    print(log[(k - star) % mod + star])

Fixed submission:
n, k = map(int, input().split())
tel = list(map(int, input().split()))
log = [1]
record = [0] * n
while(True):
    log.append(tel[log[-1] - 1])
    if(record[log[-1] - 1] == 1):
        break
    record[log[-1] - 1] += 1
for i in range(len(log) - 1):
    if(log[i] == log[-1]):
        star = i
        mod = len(log) - star - 1
        break
if(k < len(log)):
    print(log[k])
else:
    print(log[(k - star) % mod + star])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
tel = list(map(int, input().split()))
log = [1]
end = True
while(end):
    log.append(tel[log[-1] - 1])
    for i in range(len(log) - 1):
        if(log[i] == log[-1]):
            star = i
            mod = len(log) - star - 1
            end = False
if(k < len(log)):
    print(log[k])
else:
    print(log[(k - star) % mod + star])

Fixed submission:
n, k = map(int, input().split())
tel = list(map(int, input().split()))
log = [1]
record = [0] * n
while(True):
    log.append(tel[log[-1] - 1])
    if(record[log[-1] - 1] == 1):
        break
    record[log[-1] - 1] += 1
for i in range(len(log) - 1):
    if(log[i] == log[-1]):
        star = i
        mod = len(log) - star - 1
        break
if(k < len(log)):
    print(log[k])
else:
    print(log[(k - star) % mod + star])
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
n = n % k
if abs(n - k) > abs(k - n):
    if n > abs(k - n)
        print(abs (k - n))
    else:
        print(n)  
else:
    if n > abs(n - k)
        print(abs (n - k))
    else:
        print(n)   


Fixed submission:
n, k = map(int, input().split())
n = n % k
if abs(n - k) > abs(k - n):
    if n > abs(k - n):
        print(abs (k - n))
    else:
        print(n)  
else:
    if n > abs(n - k):
        print(abs (n - k))
    else:
        print(n)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
alp =list("abcdefghijklmnopqrstuvwxyz")
sl = [0] * 26
tl = [0] * 26
for i in s:
    for j in range(26):
        sl[j] = s.count(alp[j])
for i in t:
    for j in range(26):
        tl[j] = t.count(alp[j])
sl.sort()
tl.sort()
if(sl == tl):
    print("Yes")
else:
    print("No")

Fixed submission:
s = input()
t = input()
alp =list("abcdefghijklmnopqrstuvwxyz")
sl = [0] * 26
tl = [0] * 26
for j in range(26):
        sl[j] = s.count(alp[j])
for j in range(26):
        tl[j] = t.count(alp[j])
sl.sort()
tl.sort()
if(sl == tl):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
An = list(map(int, input().split()))
Q = int(input())


for i in range(Q):
    b, c = map(int, input().split())
    for j, name in enumerate(An):
        if An[j] == b:
            An[j] = c
    
    print(sum(An))

Fixed submission:
data = input()

if data.isupper():
    print("A")
elif data.islower():
    print("a")

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

bc = [map(int, input().split()) for _ in range(Q)]
b, c = [list(i) for i in zip(*bc)]

for i in range(Q):
    for j, name in enumerate(An):
        if An[j] == b[i]:
            An[j] = c[i]
    
    print(sum(An))

Fixed submission:
data = input()

if data.isupper():
    print("A")
elif data.islower():
    print("a")
Buggy python submission (verdict: Runtime Error):
num, select = map(int, input())
l = list(map(int, input()))

sum = 0
l = l.sort()
for i in l:
  sum += l[i]

print(sum)

Fixed submission:
N_syu, K_ko = map(int, input().split())
prices = list(map(int, input().split()))

prices.sort()

sum = 0
for i in range(K_ko):
    sum += prices[i]
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
An = list(map(int, input().split()))
Q = int(input())


for i in range(Q):
    b, c = map(int, input().split())
    for j, name in enumerate(An):
        if An[j] == b:
            An[j] = c
    
    print(sum(An))

Fixed submission:
N = int(input())

An = list(map(int, input().split()))
Q = int(input())

L = [0] * 100001
for item in An:
    L[item] += 1

sum = sum(An)

for i in range(Q):
    b, c = map(int, input().split())
    sum += (c-b) * L[b]
    L[c] += L[b]
    L[b] = 0
    print(sum)

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


for i in range(Q):
    b, c = map(int, input().split())
    for j, name in enumerate(An):
        if An[j] == b:
            An[j] = c
    
    print(sum(An))

Fixed submission:
N = int(input())

An = list(map(int, input().split()))
Q = int(input())

L = [0] * 100001
for item in An:
    L[item] += 1

sum = sum(An)

for i in range(Q):
    b, c = map(int, input().split())
    sum += (c-b) * L[b]
    L[c] += L[b]
    L[b] = 0
    print(sum)

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

bc = [map(int, input().split()) for _ in range(Q)]
b, c = [list(i) for i in zip(*bc)]

for i in range(Q):
    for j, name in enumerate(An):
        if An[j] == b[i]:
            An[j] = c[i]
    
    print(sum(An))

Fixed submission:
N = int(input())

An = list(map(int, input().split()))
Q = int(input())

L = [0] * 100001
for item in An:
    L[item] += 1

sum = sum(An)

for i in range(Q):
    b, c = map(int, input().split())
    sum += (c-b) * L[b]
    L[c] += L[b]
    L[b] = 0
    print(sum)

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

bc = [map(int, input().split()) for _ in range(Q)]
b, c = [list(i) for i in zip(*bc)]


for i in range(Q):
    for j, name in enumerate(An):
        if An[j] == b[i]:
            An[j] = c[i]
    
    print(sum(An))


Fixed submission:
N = int(input())

An = list(map(int, input().split()))
Q = int(input())

L = [0] * 100001
for item in An:
    L[item] += 1

sum = sum(An)

for i in range(Q):
    b, c = map(int, input().split())
    sum += (c-b) * L[b]
    L[c] += L[b]
    L[b] = 0
    print(sum)
Buggy python submission (verdict: Runtime Error):
k=int(input())
print(k*ACL)

Fixed submission:
k=int(input())
if k==1:
  print('ACL')
elif k==2:
  print('ACLACL')
elif k==3:
  print('ACLACLACL')
elif k==4:
  print('ACLACLACLACL')
elif k==5:
  print('ACLACLACLACLACL')
Buggy python submission (verdict: Runtime Error):
from pattern.en import pluralize, singularize
s=input()
print(pluralize(s))

Fixed submission:
s=input()
if s[-1]=='s':
    print(s+'es')
else:
    print(s+'s')
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N%9 == 0:
  print(Yes)
else:
  print(No)

Fixed submission:
N=int(input())
if N%9 == 0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
int(input())
N = input()
if(N%9=0)
print(Yes)
if(N%9=!0)
print(No)

Fixed submission:
N=int(input())
if N%9 == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1,n):
  for j in range(1,int(n/i)+2):
    if i*j < n:
      ans += 1
print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n):
  if n%i == 0:
    ans += int(n/i)-1
  else:
    ans += int(n/i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1,n):
  for j in range(1,n):
    if i*j < n:
      ans += 1
print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n):
  if n%i == 0:
    ans += int(n/i)-1
  else:
    ans += int(n/i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
A = list(map(int,input().split()))
ass = 1
for i in range(k):
  ass *= A[i]
for j in range(n-k):
  if ass < ass*A[j+k]/A[j]:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k = map(int,input().split())
A = list(map(int,input().split()))
for i in range(n-k):
  if A[i]<A[i+k]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
from math import gcd
print(int(a*b/gcd(a,b)))

Fixed submission:
a,b = map(int, input().split())
from fractions import gcd
print(int(a*b/gcd(a,b)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
num = 1
ans = 0
for i in range(n):
  if A[i] == num:
    num += 1
    ans += 1
if ans == 0:
  print("-1")
else:
print(n-ans)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
num = 1
ans = 0
for i in range(n):
  if A[i] == num:
    num += 1
    ans += 1
if ans == 0:
  print("-1")
else:
  print(n-ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
num = 1
ans = 0
for i in range(n):
  if A[i] == num:
    num += 1
    ans += 1
if ans = 0:
  print("-1")
else:
print(n-ans)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
num = 1
ans = 0
for i in range(n):
  if A[i] == num:
    num += 1
    ans += 1
if ans == 0:
  print("-1")
else:
  print(n-ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list1 = [str(input()) for  _ in range(N)]
list2 =  ["".join(sorted(list1[i])) for i in range(N)]
ans = 0
for i in range(N):
  for j in range(i+1,N):
    if list2[i] == list2[j]:
      ans += 1
print(ans)

Fixed submission:
N=int(input())
dictionary={}
count=0
for i in range(N):
    s="".join(sorted(input()))
    if s in dictionary:
        dictionary[s]+=1
        count+=dictionary[s]
    else:
        dictionary[s]=0
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
import fractions
g = fractions.gcd(A[0],A[1])
for i in range(2,n):
  g = fracitons.gcd(g,A[i])
print(g)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
import fractions
g = fractions.gcd(A[0],A[1])
for i in range(2,n):
  g = fractions.gcd(g,A[i])
print(g)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
ans = []
ref = sorted(set(s))
for i in ref:
    for j in range(len(s)):
        if s[j] == i:
            ans += [s[j:j+k] for k in range(1,len(s)-j+1)]
            ans = sorted(set(ans))
    if len(ans)>=k:
        print(ans[k-1])
        break
    else:
        continue
    break

Fixed submission:
S = input()
N = len(S)
K = int(input())
top_k = []
for i in range(N):
    for j in range(i + 1, min([i + K, N]) + 1):
            st = S[i:j]
            top_k.append(st)
            if len(top_k) > K:
                top_k = list(set(top_k))
                top_k.sort()
                top_k = top_k[:K]
top_k.sort()
print(top_k[-1])
Buggy python submission (verdict: Runtime Error):
num = list(map(int, input().split())
k = int(input())
print(max(num)*(2**k-1)+sum(num))

Fixed submission:
num = list(map(int, input().split()))
k = int(input())
print(max(num)*(2**k-1)+sum(num))
Buggy python submission (verdict: Runtime Error):
n = int(input())
import fractions
print(fractions.floor(n**0.5)**2)

Fixed submission:
n = int(input())
a = 1
while a**2 <= n:
    a += 1
print((a-1)**2)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
A = set()
B = set()
for _ in range(m):
    x = list(map(int,input().split()))
    if x[0]==1:
        A = A|set(x)
    elif x[1]==n:
        B = B|set(x)
if len(A&B)>0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
N,M=map(int,input().split())
sa=set()
sb=set()
for i in range(M):
    a,b=map(int,input().split())
    if a==1:sb.add(b)
    if b==N:sa.add(a)
print("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
A = set()
B = set()
for _ in range(m):
    x = list(map(int,input().split()))
    if x[0]==1:
        A = A|set(x)
    elif x[1]==n:
        B = B|set(x)
if len(A&B)>0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
N,M=map(int,input().split())
sa=set()
sb=set()
for i in range(M):
    a,b=map(int,input().split())
    if a==1:sb.add(b)
    if b==N:sa.add(a)
print("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE")
Buggy python submission (verdict: Runtime Error):
for o,e in zip(input(),input()):
  print(o,e,end="",sep="")
if len(O)>len(E):
    print(O[-1],end="")

Fixed submission:
O = input()
E = input()
for o,e in zip(O,E):
  print(o,e,end="",sep="")
if len(O)>len(E):
    print(O[-1],end="")

Buggy python submission (verdict: Runtime Error):
o = list(input())
e = list(input())
ans = []
for i in range(len(o)):
  ans.append(o[i])
  ans.append(e[i])
print("".join(ans))

Fixed submission:
O = input()
E = input()
for o,e in zip(O,E):
  print(o,e,end="",sep="")
if len(O)>len(E):
    print(O[-1],end="")

Buggy python submission (verdict: Runtime Error):
o = list(input())
e = list(input())
ans = []
for i in range(len(o)):
  ans.append(o[i])
  ans.append(e[i])
print("".join(ans))

Fixed submission:
O = input()
E = input()
for o,e in zip(O,E):
  print(o,e,end="",sep="")
if len(O)>len(E):
    print(O[-1],end="")
Buggy python submission (verdict: Runtime Error):
n = int(input())
import fractions
print(fractions.factorial(n)%(10**9+7))

Fixed submission:
n = int(input())
import math
print(math.factorial(n)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
x = import()

if x == 0:
    print(1)

else:
    print(0)

Fixed submission:
x = int(input())

if x == 0:
    print(1)

else:
    print(0)

Buggy python submission (verdict: Runtime Error):
x = int(import())

if x == 0:
    print(1)

else:
    print(0)

Fixed submission:
x = int(input())

if x == 0:
    print(1)

else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
An_input = input().split()
An = [int(s) for s in An_input]

#print(An)
A = An[0] + An[1]
#print(A)

cnt = 0
M = 10**9 + 7

for i in range(0, N-1):
    #print(i)
    for l in range(1, N-i):
        cnt += An[i] * An[i+l]
        #print(An[i], An[i+l])
        #print(cnt)

ans = cnt % M
print(ans)

Fixed submission:
N = int(input())
An_input = input().split()
An = [int(s) for s in An_input]

cnt = 0
k = 0
M = 10**9 + 7

for i in range(0, N-1):
    k += An[i]
    cnt += k * An[i+1]

ans = cnt % M
print(ans)
Buggy python submission (verdict: Runtime Error):
temp = input()
if temp >= 30:
    print("Yes")

else:
    print("No")

Fixed submission:
temp = int(input())
if temp >= 30:
    print("Yes")

else:
    print("No")
Buggy python submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

import resource,sys
resource.setrlimit(resource.RLIMIT_STACK,(2**29,-1))
sys.setrecursionlimit(10**6)

def dfs(u):
    global graph,vis
    vis.add(u)
    for i in graph[u]:
        if i not in vis:
            dfs(i)

n,m = ip()
graph = {i:[] for i in range(1,n+1)}
for i in range(m):
    a,b = ip()
    graph[a].append(b)
    graph[b].append(a)
for i in graph:
    graph[i] = list(set(graph[i]))
vis = set()
ans = -1
prev = 0
for i in range(1,n+1):
    if i not in vis:
        dfs(i)
        t = len(vis)
        ans = max(ans,t-prev)
        prev = t
print(ans)

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

import resource,sys
#resource.setrlimit(resource.RLIMIT_STACK,(2**29,-1))
sys.setrecursionlimit(10**6)

def dfs(u):
    global graph,vis
    vis.add(u)
    for i in graph[u]:
        if i not in vis:
            dfs(i)

n,m = ip()
graph = {i:[] for i in range(1,n+1)}
for i in range(m):
    a,b = ip()
    graph[a].append(b)
    graph[b].append(a)
for i in graph:
    graph[i] = list(set(graph[i]))
vis = set()
ans = -1
prev = 0
for i in range(1,n+1):
    if i not in vis:
        dfs(i)
        t = len(vis)
        ans = max(ans,t-prev)
        prev = t
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

h,w,m = ip()
y = [0]*h
x = [0]*w
dt = {}
for i in range(m):
    a,b = ip()
    y[a-1] += 1
    x[b-1] += 1
    dt[(a-1,b-1)] = 1
ans = 0
for i in range(h):
    for j in range(w):
        if dt.get((i,j),0):
            ans = max(ans,y[i]+x[j]-1)
        else:
            ans = max(ans,y[i]+x[j])
print(ans)


Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

h,w,m = ip()
y = [0]*h
x = [0]*w
dt = {}
for i in range(m):
    a,b = ip()
    y[a-1] += 1
    x[b-1] += 1
    dt[(a-1,b-1)] = 1
ans = 0
mx = max(x)
my = max(y)
xx = [i for i in range(w) if x[i] == mx]
yy = [i for i in range(h) if y[i] == my]
#print(x,y,xx,yy)
for i in xx:
    for j in yy:
        if dt.get((j,i),0):
            ans = max(ans,x[i]+y[j]-1)
        else:
            ans = max(ans,x[i]+y[j])
        if ans == mx+my:
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
s = input().strip()
if s.count('W') in [0,n]:
    print(0)
    exit()
ans = n
w,r = 0,s.count('R')
for i in range(n):
    if s[i] == 'W':
        w += 1
    elif s[i] == 'R':
        r -= 1
    ans = max(ans,min(w,r))
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
s = input().strip()
l,r = 0,n-1
ct = 0
if s.count('W') in [0,n]:
    print(ct)
    exit()
while l < r:
    while s[l] == 'R':
        if l >= r:
            break
        l += 1
    while s[r] == 'W':
        if l >= r:
            break
        r -= 1
    ct += 1
    l += 1
    r -= 1
print(min(ct,s.count('R'),s.count('W')))



Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
s = input().strip()
print(s[:s.count('R')].count('W'))
Buggy python submission (verdict: Time Limit Exceeded):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
if n < 3:
    print(max(x))
    exit()
x.sort(reverse=True)
k = n - 2
ans = x[0]
x.pop(0)
while k:
    t = x.pop(0)
    ans += t
    k -= 1
    if k == 0:
        break
    ans += t
    k -= 1
print(ans)

    


Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
if n < 3:
    print(max(x))
    exit()
x.sort(reverse=True)
k = n - 2
ans = x[0]
x.pop(0)
ans += 2*sum(x[:k//2])
if k%2:
    ans += x[k//2]
print(ans)
Buggy python submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

s = input().strip()
t = input().strip()
ans = 0
for i in range(n):
    if s[i] != t[i]:
        ans += 1
print(ans)
    


Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

s = input().strip()
t = input().strip()
n = len(s)
ans = 0
for i in range(n):
    if s[i] != t[i]:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
string s,t;
ll a[200500], b[200500], pa[200500], pbb[200500];

int main() {
	//freopen("input.txt","r",stdin);
 	//freopen("output.txt","w",stdout);
    int n,m,x,i;
	ll tests=1;
	while (tests--)
	{
		cin >> n >> m >> x;
		for (i = 0; i < n; i++)
		{
			cin >> a[i];
			pa[i+1] = pa[i] + a[i];
		}
		for (i = 0; i < m; i++)
		{
			cin >> b[i];
			pbb[i+1] = pbb[i] + b[i];
		}
		int ans = 0;
		for (i = 0; i <= n; i++)
		{
			if (pa[i] <= x)
			   ans = max(ans, i+(int)(upper_bound(pbb, pbb+m+1, x-pa[i])-pbb-1));
			else
				break;
		}
		cout << ans << endl;
	}
    return 0;
}

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

from bisect import bisect_right as bs
n,m,k = ip()
a = ip()
b = ip()
x = [0]*(n+1)
for i in range(n):
    x[i+1] = x[i]+a[i]
y = [0]*(m+1)
for i in range(m):
    y[i+1] = y[i]+b[i]
ans = 0
for i in range(n+1):
    if x[i] <= k:
        ans = max(ans,i+bs(y,k-x[i])-1)
    else:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
ele = 10**18
prod = 1
for i in x:
    prod *= i
    if prod == 0:
        print(0)
        exit()
if prod > ele:
    print(-1)
    exit()
print(prod)

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
ele = 10**18
prod = 1
if 0 in x:
    print(0)
    exit()
for i in x:
    prod *= i
    if prod > ele:
        print(-1)
        exit()
print(prod)
Buggy python submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

a,b = ip()
print(int(a*b//1))

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

a,b = input().split()
a = int(a)
b = list(b.split("."))
b = ''.join(b)
b = int(b)
print(a*b//100)

Buggy python submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
ele = 10**18
prod = 1
if 0 in x:
    print(0)
    exit()
for i in x:
    prod *= i
    if prod > ele:
        print(-1)
        exit()
print(prod)

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

a,b = input().split()
a = int(a)
b = list(b.split("."))
b = ''.join(b)
b = int(b)
print(a*b//100)