Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02571 (python)

Fixed submission:
def matcher(s1,s2):
    match=0
    for i in range(len(s1)):
        if(s1[i]!=s2[i]):
            match+=1
            
    return match

#print(matcher("eforces","atcoder"))

s = input()
st = input()
mx=10**5

rangeforloop= len(s)+1 - len(st)
 
for i in range(rangeforloop):
    mx=min(mx,matcher(s[i:len(st)+i], st))
    
     
print(mx)

Buggy submission (verdict: Runtime Error):
from math import min
s = input()
st = input()
mx=10**5

rangeforloop= len(s)+1 - len(st)
 
for i in range(rangeforloop):
    mx=min(mx,matcher(s[i:len(st)+i], st))
    
     
print(mx)

Buggy submission (verdict: Runtime Error):
s = input()
st = input()
mx=10**5

rangeforloop= len(s)+1 - len(st)
 
for i in range(rangeforloop):
    mx=min(mx,matcher(s[i:len(st)+i], st))
    
     
print(mx)

Buggy submission (verdict: Runtime Error):
s = input()
st = input()
mx=10**9

rangeforloop= len(s)+1 - len(st)
 
for i in range(rangeforloop):
    mx=min(mx,matcher(s[i:len(st)+i], st))
    
     
print(mx)

Buggy submission (verdict: Runtime Error):
s = input()
st = input()
mx=10**9

rangeforloop= len(s)+1 - len(st)
 
for i in range(rangeforloop):
    mx=min(mx,matcher(s[i:len(st)+i], st))
    
     
print(mx)

Buggy submission (verdict: Runtime Error):
s = input()
st = input()
mx=10**9

rangeforloop= len(s)+1 - len(st)
 
for i in range(rangeforloop):
    mx=min(mx,matcher(s[i:len(st+i)], st))
    
     
print(mx)
Problem p02729 (python)

Fixed submission:
n,m=map(int,input().split())
if(n+m>=2 and n>=0 and n<=100 and m<=100 and m>=0):
    ans=int(round(n*(n-1)/2)+(m*(m-1)/2))
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
if(n+m>=2):
  if(n==1 or n==0):
    print(m*(m-1)/2)
  else if(m==1 or m==0):
    print(n*(n-1)/2)
    
  else:
    print((n*(n-1)/2)+(m*(m-1)/2))
Problem p02577 (python)

Fixed submission:
N=int(input())

if N%9==0:
  print("Yes")

else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())

if(N%9==) print("Yes")
else print("No")
Problem p02596 (python)

Fixed submission:
import sys
input = sys.stdin.readline
import math
import time
import numpy as np

k = int(input())

if k %2 ==0 or k%5==0:
    print(-1)
else:
    if k %7 == 0:
        l = k*9//7
    else:
        l = k*9
    q = 10%l
    for i in range(1,1000000):
        if q ==1:
            print(i)
            break
        else:
            q = (q*10)%l
            pass

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import math
import time
import numpy as np

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

k = int(input())


a = prime_factorize(k)

def nana(n):
    for i in range(1,100000):
        na = int("7"*i)
        if na % n ==0:
            return i

if k %2 == 0:
    print(-1)
else:
    t = []
    for e in a:
        t.append(nana(e))
    print(np.gcd.reduce(t))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import math
import time
import numpy as np

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

k = int(input())

a = prime_factorize(k)

def nana(n):
    for i in range(1,100000):
        na = int("7"*i)
        if na % n ==0:
            return i

t = []
for e in a:
    t.append(nana(e))
print(np.gcd.reduce(t))
Problem p02695 (python)

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

from itertools import combinations_with_replacement as CwR



n, m, q = map(int, input().split())
Lis = [[int(e) for e in input().split()] for _ in range(q)]

Tables = list(CwR(range(1,m+1),n))
Sum_cor = []
for Table in Tables:
    d_sum = 0
    for l in Lis:
        if Table[l[1]-1]-Table[l[0]-1] == l[2]:
            d_sum+=l[3]
    Sum_cor.append(d_sum)

print(max(Sum_cor))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

from itertools import combinations_with_replacement as CwR



n, m, q = map(int, input().split())
Lis = [[int(e) for e in input().split()] for _ in range(q)]

Tables = list(CwR(range(1,M+1),N))
Sum_cor = []
for Table in Tables:
    d_sum = 0
    for l in Lis:
        if Table[l[1]-1]-Table[l[0]-1] == l[2]:
            d_sum+=l[3]
    Sum_cor.append(d_sum)


print(max(Sum_cor))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
import time


def make_table(n, m):
    Table = np.random.randint(1,m+1)
    return Table

t0 = time.time()
n, m, q = map(int, input().split())
Lis = [[int(e) for e in input().split()] for _ in range(q)]

Sum_cor = []
for i in range(10000000000):
    Table = make_table(n,m)
    Table.sort()
    d_sum = 0
    for l in Lis:
        if Table[l[1]-1]-Table[l[0]-1] == l[2]:
            d_sum+=l[3]
    Sum_cor.append(d_sum)
    t1 = time.time()
    if t1-t0 >1.88:
        print(max(Sum_cor))
        break

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
import time


def make_table(n, m):
    Table = np.random.randint(1,m+1)
    return Table

t0 = time.time()
n, m, q = map(int, input().split())
Lis = [[int(e) for e in input().split()] for _ in range(q)]

Sum_cor = []
for i in range(10000000000):
    if m >=6:
        Table = make_table(n,m)
    else:
        Table = make_table(n,m)
    Table.sort()
    d_sum = 0
    for l in Lis:
        if Table[l[1]-1]-Table[l[0]-1] == l[2]:
            d_sum+=l[3]
    Sum_cor.append(d_sum)
    t1 = time.time()
    if t1-t0 >1.9:
        print(max(Sum_cor))
        print(i)
        break

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
import time


def make_table(n, m):
    Table = np.random.randint(1,m+1)
    return Table

t0 = time.time()
n, m, q = map(int, input().split())
Lis = [[int(e) for e in input().split()] for _ in range(q)]

Sum_cor = []
for i in range(10000000000):
    if m >=6:
        Table = make_table(n,m)
    else:
        Table = make_table(n,m)
    Table.sort()
    d_sum = 0
    for l in Lis:
        if Table[l[1]-1]-Table[l[0]-1] == l[2]:
            d_sum+=l[3]
    Sum_cor.append(d_sum)
    t1 = time.time()
    if t1-t0 >1.9:
        print(max(Sum_cor))
        print(i)
        break
Problem p02707 (python)

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

n = int(input())
A = [int(a) for a in input().split()]

sub_list = [0] *n

for a in A:
  sub_list[a-1] +=1

for i in range(n):
  print(sub_list[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [0]*(n+1)
A[a] +=0   for a in input().split()

for e in A[1:]:
  print(e)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

def print_sub(A, m, c):
    A -= 1
    print(m - np.nonzero(A)[0].size)
    c +=1
    if c < m:
        print_sub(A, m, c)
    else:
        print("0")
        

n= int(input())
A = [int(a) for a in input().split()]
A = np.array(A)
c = 0
print_sub(A, n-1, c)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

def print_sub(A, m, c):
    A -= 1
    print(m -np.nonzero(A)[0].size)
    c +=1
    if c < m:
        return print_sub(A, m, c)
    else:
        return

n= int(input())
A = [int(a) for a in input().split()]
A = np.array(A)
c = 0
print_sub(A, n-1, c)

print("0")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

def print_sub(A, m, c):
    A = np.array(A)
    A -= 1
    print(m -np.nonzero(A)[0].size)
    c +=1
    if c < m:
        return print_sub(A, m, c)
    else:
        return

n= int(input())
A = [int(a) for a in input().split()]
c = 0
print_sub(A, n-1, c)

print("0")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

def print_sub(A, m, c):
    A = np.array(A)
    A -= 1
    print(m -len(np.nonzero(A)[0]))
    c +=1
    if c < m:
        return print_sub(A, m, c)
    else:
        return

n= int(input())
A = [int(a) for a in input().split()]
c = 0
print_sub(A, n-1, c)

print("0")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

def print_sub(A, Ones, m, c):
    A = np.array(A)
    A = A -Ones
    print(m -len(np.nonzero(A)[0]))
    c +=1
    if c < m:
        return print_sub(A, Ones, m, c)
    else:
        return

n= int(input())
A = [int(a) for a in input().split()]
Ones = np.array([1]*(n-1))
c = 0
print_sub(A, Ones, n-1, c)

print("0")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

def print_sub(A, Ones, m, c):
    A = np.array(A)
    A = A -Ones
    print(n-1 -len(np.nonzero(A)[0]))
    c +=1
    if c < m:
        return print_sub(A, Ones, m, c)
    else:
        pass

n= int(input())
A = [int(a) for a in input().split()]
Ones = np.array([1]*(n-1))
c = 0
print_sub(A, Ones, n-1, c)

print("0")
Problem p02987 (python)

Fixed submission:
S = [s for s in input()]

SS = sorted(S)

if SS[0] == SS[1] and SS[2] == SS[3] and SS[0] != SS[2]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
mod = 1e9 + 7
def comb(n, r):
    if n == 0 or r == 0:
        return 1
    elif n < r:
        return 0
    else:
        m = n - r
        u = max(m, r)
        mul_sum = 1
        for j in range(u):
            loc_sum = (m - j) / (j + 1)
            mul_sum = mul_sum * loc_sum
        asr = int(mul_sum % mod)
        return asr



n, k = map(int, input().split())
ans = 0
red = n - k


for i in range(k):
    b_c = comb(k-1, i)
    r_c = comb(red+1, i+1)
    mlt = int(b_c * r_c)
    ans = mlt % mod
    print(int(ans))
Problem p03013 (python)

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

A = [int(input().strip()) for _ in range(m)]

a0 = 1
if len(A) == 0:
  a1 = 1
else:
  a1 = 1 if A[0] !=1 else 0
mod = 1000000007

ANS=[0]*(n+1)
ANS[0]=a0
ANS[1]=a1
Next = A if a1 !=0 else A[1:]
next = 0
for i in range(2, n+1):
    if next <= len(Next)-1:
        if i == Next[next]:
            ANS[i] = 0
            next += 1
            continue
    ANS[i] = ANS[i-2] + ANS[i-1]

print(ANS[n]%mod)

Buggy submission (verdict: Runtime Error):
n, m  = map(int, input().split())

A = [int(input().strip()) for _ in range(m)]

a0 = 1
a1 = 1 if A[0] !=1 else 0
mod = 1000000007

ANS=[0]*(n+1)
ANS[0]=a0
ANS[1]=a1
Next = A if a1 !=0 else A[1:]
next = 0
for i in range(2, n+1):
    if next <= len(Next)-1:
        if i == Next[next]:
            ANS[i] = 0
            next += 1
            continue
    ANS[i] = ANS[i-2] + ANS[i-1]

print(ANS[n]%mod)

Buggy submission (verdict: Runtime Error):
n, m  = map(int, input().split())

A = [int(input()) for _ in range(m)]

a0 = 1
a1 = 1 if A[0] !=1 else 0
mod = 1e9+7

ANS=[0]*(n+1)
ANS[0]=a0
ANS[1]=a1
Next = A if a1 !=0 else A[1:]
next = 0
for i in range(2, n+1):
    if next <= len(Next)-1:
        if i == Next[next]:
            ANS[i] = 0
            next += 1
            continue
    ANS[i] = ANS[i-2] + ANS[i-1]

print(int(ANS[n]%mod))

Buggy submission (verdict: Runtime Error):
n, m  = map(int, input().split()) 

A = [int(a) for a in input().strip()]

a0 = 1 
a1 = 1 if A[0] !=1 else 0 

ANS=[0]*(n+1)
ANS[0]=a0
ANS[1]=a1
Next = A[1:] if a1 !=0 else A
next = 0
for i in range(2,n+1) :
  if i == Next[next]:
    A[i] = 0
    next += 1 
  else:
    A[i] = A[i-2] + A[i-1] 
  
print(A[n])
Problem p03041 (python)

Fixed submission:
n, k =map(int, input().split())
STR = input()
str = STR.lower()

if k == 1:
  sTR = str[0] + STR[1:]
elif k == n:
  sTR = STR[:n-1] + str[n-1]
else:
  sTR = STR[:k-1] + str[k-1] + STR[k:]

print(sTR)

Buggy submission (verdict: Runtime Error):
n, k =map(int, input().split())
STR = input()
str = STR.lower()

if k == 1:
  sTR = str[0] + STR[1:]
elif k == n:
  stR = STR[:n-2] + str[n-1]
else:
  sTR = STR[:k-2] + str[k-1] + STR[:k]

print(sTR)

Buggy submission (verdict: Runtime Error):
n, k =map(int, input().split())
s = input()

if k == 1:
  sTR = lower(s[0]) + s[1:]
else:
  sTR = s[:k-2] + lower(s[k-1]) + s[:k]

print(sTR)
Problem p03042 (python)

Fixed submission:
import bisect

lis = [1, 13]

str = input()
tp = int(str[:2])
bt = int(str[2:])

tplo = bisect.bisect_right(lis, tp)
btlo = bisect.bisect_right(lis, bt)

if tplo == 1:
    if btlo == 1:
        jd = 2
    else:
        jd = 1
else:
    if btlo == 1:
        jd = 0
    else:
        jd = 3

judge = ["YYMM", "MMYY", "AMBIGUOUS", "NA"]

print(judge[jd])

Buggy submission (verdict: Runtime Error):
import bisect

lis = [1, 12]

str = input()
tp = int(str[:2])
bt = int(str[2:])

tplo = bisect.bisect_right(lis, tp)
btlo = bisect.bisect_right(lis, bt)

if tp == 0:
    if bt == 1:
        jd = 3
    else:
        jd == 0
elif tp == 1:
    if bt == 1:
        jd == 2
    else:
        jd == 1
else:
    if bt == 1:
        jd == 0
    else:
        jd == 3

judge = ["YYMM", "MMYY", "AMBIGUOUS", "NA"]
print(judge[jd])

Buggy submission (verdict: Runtime Error):
import bisect

lis[1, 12]

str = input()
tp = int(str[:2])
bt = int(str[2:])

tplo = bisect.bisect_right(lis, tp)
btlo = bisect.bisect_right(lis, bt)

if tp == 0:
    if bt == 1:
        jd = 3
    else:
        jd == 0
elif tp == 1:
    if bt == 1:
        jd == 2
    else:
        jd == 1
else:
    if bt == 1:
        jd == 0
    else:
        jd == 3

judge = ["YYMM", "MMYY", "AMBIGUOUS", "NA"]
print(judge[jd])

Buggy submission (verdict: Runtime Error):
import bisect

lis[1, 12]

str = input()
tp = int(str[:2])
bt = int(str[2:])
if

tplo = bisect.bisect_right(lis, tp)
btlo = bisect.bisect_right(lis, bt)

if tp == 0:
    if bt == 1:
        jd = 3
    else:
        jd == 0
elif tp == 1:
    if bt == 1:
        jd == 2
    else:
        jd == 1
else:
    if bt == 1:
        jd == 0
    else:
        jd == 3

judge = ["YYMM", "MMYY", "AMBIGUOUS", "NA"]
print(judge[jd])
Problem p02693 (python)

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

flag = False

if a <= int(b / k) * k:
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
A, B = map(int, input().split())

c = A / K
b = c * K
flag = False

if b == B:
  flag = True
b += K
  if b <= B:
    flag = True

if flag == True:
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
A, B = map(int, input().split())

c = A / K
b = c * K
flag = False

if b == B:
  flag = True
while b <= B:
  b += K
  elif b <= B:
    flag = True

if flag == True:
  print("OK")
else:
  print("NG")
Problem p02570 (python)

Fixed submission:
D,T,S=map(int,input().split())
if D/S<=T:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
D,T,S=map(int,input().split)
if D/S<=T:
  print("Yes")
else:
  print("No")
Problem p02629 (python)

Fixed submission:
n = int(input())
a = 0
r = 26
count = 1
result = ""
moji = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
while a == 0:
    if r < n:
        n -= r
        r *= 26
        count += 1
    else:
        a = 1
zenbu = 26**count

def kaidan(zenbu,n):
    global moji
    for i in range(26):
        #print(i)
        if (zenbu/26)*i < n <= (zenbu/26)*(i+1):
            return(moji[i],i)

for l in range(count):
    kotae,s = kaidan(zenbu/(26**l),n)
    result += kotae
    n -= 26**(count-l-1)*s
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = 0
r = 26
count = 1
result = ""
moji = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
while a == 0:
    if r <= n:
        n -= r
        r *= 26
        count += 1
    else:
        a = 1
zenbu = 26**count

def kaidan(zenbu,n):
    global moji
    for i in range(26):
        #print(i)
        if (zenbu/26)*i < n <= (zenbu/26)*(i+1):
            return(moji[i],i)

for l in range(count):
    kotae,s = kaidan(zenbu/(26**l),n)
    result += kotae
    n -= 26**(count-l-1)*s
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = 0
r = 26
count = 1
result = ""
moji = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
while a == 0:
    if r <= n:
        n -= r
        r *= 26
        count += 1
    else:
        a = 1
zenbu = 26**count

def kaidan(zenbu,n):
    global moji
    for i in range(26):
        #print(i)
        if zenbu/26*i < n <= zenbu/26*(i+1):
            return(moji[i],i)

for l in range(count):
    kotae,s = kaidan(zenbu/(26**l),n)
    result += kotae
    n -= 26**(count-l-1)*s
print(result)
Problem p02689 (python)

Fixed submission:
N,M = map(int,input().split())
H = list(map(int,input().split()))
c = [0] * N
for i in range(M):
    A,B = map(int,input().split())
    if H[A -1] >= H[B -1]:
        c[B - 1] += 1
    if H[B - 1] >= H[A - 1]:
        c[A - 1] += 1
print(c.count(0))

Buggy submission (verdict: Runtime Error):
(N,M) = input().split()
N = int(N)
M = int(M)
h = list(map(int,input().split()))
y = [0] * N
for i in range (M):
    A,B = map(int,input().split())
    if h[A -1] >= h[B -1]:
        y[B -1] += 1
    if h[B -1] >= h[a -1]:
        y[A -1] += 1
print(y.count(0))

Buggy submission (verdict: Runtime Error):
(N,M) = input().split()
N = int(N)
M = int(M)
h = list(map(int,input().split()))
y = [0] * N
for i in range (M):
    A,B = map(int,input().split())
    if h[A -1] >= h[B -1]:
        y[B -1] += 1
    if h[B -1] >= h[a -1]:
        y[A -1] += 1
print(y.count(0))
Problem p02594 (python)

Fixed submission:
X = int(input())
if X >= 30:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
K = int(input())
m = 0
for i in range(K):
    m = (m * 10 + 7) % K
    if m == 0:
        print(i)
        break
    elif m == k-1:
        print(-1)
        break
Problem p02771 (python)

Fixed submission:
import sys
nums = input()
a = nums[0] 
b = nums[2]
c = nums[4]

if a == b:
    if b == c:
        print("No")
    else:
        print("Yes")
else:
    if b == c:
        print("Yes")
    elif a == c:
        print("Yes")
    else: 
        print("No")

Buggy submission (verdict: Runtime Error):
　import sys
nums = input()
print(nums)
a = nums[0] 
b = nums[2]
c = nums[4]

if a == b:
    if b == c:
        print("No")
    else:
        print("Yes")
else:
    if b == c:
        print("Yes")
    elif a == c:
        print("Yes")
    else: 
        print("No")
Problem p02622 (python)

Fixed submission:
s,t,count=input(),input(),0

for i in range(len(s)):
  if s[i]!=t[i]:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
s,t,count=input(),input(),0

for i in range(len(s)):
  if s[i]!=t[i]:
    count++
print(count)
Problem p02571 (python)

Fixed submission:
s = input()
t = input()

ans = len(s)

for i in range(len(s)):
  if i + len(t) - 1 >= len(s):break;
  dif=0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      dif += 1
  ans = min(ans, dif)
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

ans = len(s)

for i in range(len(s)):
  if i + len(t) - 1 >= len(s):break;
    dif=0
    for j in range(len(t)):
      if s[i+j] != t[j]:
        dif += 1
    ans = min(ans, dif)
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

ans = len(s)

for s_start in range(len(s)):
  if i + len(t) - 1 >= len(s):break;
    dif=0
    for j in range(len(t)):
      if s[i+j] != t[j]:
        dif += 1
    ans = min(ans, dif)
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t - input()

ans = len(s)

for s_start in range(len(s)):
  if i + len(t) - 1 >= len(s):break;
    dif=0
    for j in range(len(t)):
      if s[i+j] != t[j]:
        dif += 1
    ans = min(ans, dif)
print(ans)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = str(input())
if a > 3199:
    print(s)
else:
    print('red')

Buggy submission (verdict: Runtime Error):
a = int(input())
s = int(input())
if a > 3199:
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
a = int(input())
s = 'pink'
a > 3199 = s
a < 3200 = 'red'
Problem p02623 (python)

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

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


a_pre,b_pre=[0],[0]

for i in range(n):
	a_pre.append(a_pre[i]+a[i])

for i in range(m):
	b_pre.append(b_pre[i]+b[i])

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

	ans=max(ans,i+j)

print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
n,m,k = map(int, stdin.readline().rstrip().split())
a = list(map(int, stdin.readline().rstrip().split()))
b = list(map(int, stdin.readline().rstrip().split()))

A = [0]
B = [0]
ans,res = 0,0
for i in range(0, n):
    A.append(A[i]+a[i])
for i in range(0, m):
    B.append(B[i]+b[i])

def ans(A, B):
    for i in range(0, n + 1):
        j = 0
        while A[i] + B[j + 1] <= k:
            j += 1
            if j == len(B) - 1:
                break

        ans = max(ans, i + j)
    return ans

if A[1] > k and B[1] > k:
    print(0)
else:
    res = ans(A, B)
    print(res)

Buggy submission (verdict: Runtime Error):
from sys import stdin
n,m,k = map(int, stdin.readline().rstrip().split())
a = list(map(int, stdin.readline().rstrip().split()))
b = list(map(int, stdin.readline().rstrip().split()))

A = [0]
B = [0]
ans,res = 0,0
for i in range(0, n):
    A.append(A[i]+a[i])
for i in range(0, m):
    B.append(B[i]+b[i])

def ans(A, B):
    for i in range(0, n + 1):
        j = 0
        while A[i] + B[j + 1] <= k:
            j += 1
            if j == len(B) - 1:
                break

        ans = max(ans, i + j)
    return ans

if A[1] > k and B[1] > k:
    print(0)
else:
    res = ans(A, B)
    print(res)

Buggy submission (verdict: Runtime Error):
from sys import stdin
n,m,k = map(int, stdin.readline().rstrip().split())
a = list(map(int, stdin.readline().rstrip().split()))
b = list(map(int, stdin.readline().rstrip().split()))

A = [0]
B = [0]
ans = 0
for i in range(0, n):
    A.append(A[i]+a[i])
for i in range(0, m):
    B.append(B[i]+b[i])

for i in range(0,n):
    j = 0
    while A[i] + B[j+1] <= k:
        j += 1
    ans = max(ans, i + j)
print(ans)