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

Fixed submission:
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_, e = I()
hs = Is()

obs = sorted([(i, h) for i, h in enumerate(hs, 1)], key=lambda x:x[1], reverse=True)
seen = D(bool)

roads = D(set)
for _ in range(e):
  a, b = I()
  roads[a].add(b)
  roads[b].add(a)
  
ans = 0
for ob in obs:
  if not seen[ob[0]]:
    if all(ob[1] > hs[r-1] for r in roads[ob[0]]):
      ans += 1
    seen[ob[0]] = True
    for r in roads[ob[0]]:
      seen[r] = True
      
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_, e = I()
hs = Is()

obs = sorted([(i, h) for i, h in enumerate(hs, 1)], key=lambda x:x[1], reverse=True)
seen = D(bool)

roads = D(set)
for _ in range(e):
  a, b = I()
  roads[a].add(b)
  roads[b].add(a)
  
ans = 0
for ob in obs:
  if not seen[ob[0]]:
    if all(ob[1] > hs[r] for r in roads[ob[0]]):
      ans += 1
    seen[ob[0]] = True
    for r in roads[ob[0]]:
      seen[r] = True
      
print(ans)
Problem p02948 (python)

Fixed submission:
from collections import defaultdict
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * N]

    ab = defaultdict(list)
    for a, b in AB:
        ab[a].append(b)

    ans = 0
    reward = []
    for i in range(1, M + 1):
        if ab[i]:
            for n in ab[i]:
                heappush(reward, n * -1)
        if reward:
            ans += heappop(reward) * -1
    print(ans)

input = lambda: stdin.readline()
main()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * N]

    ab = defaultdict(list)
    for a, b in AB:
        ab[a].append(b * -1)

    ans = 0
    flag = 1
    for i in range(1, M + 1):
        if flag:
            reward = heapify(ab[1])
            flag = 0
        if ab[i]:
            for n in ab[i]:
                heappush(reward, n * -1)
            ans += heappop(reward) * -1
    print(ans)

input = lambda: stdin.readline()
main()
Problem p03137 (python)

Fixed submission:
from sys import stdin

def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))

    if N >= M:
        print(0)
        return

    X.sort()
    n1 = [(i + 1, X[i+1] - X[i]) for i in range(M - 1)]
    n1.sort(reverse=1, key=lambda x: x[1])
    n2 = n1[:N-1]
    n2.sort()

    ans, i = 0, 0
    for j, _ in n2:
        ans += X[i:j][-1] - X[i:j][0]
        i = j
    ans += X[i:][-1] - X[i:][0]
    print(ans)

input = lambda: stdin.readline()
main()

Buggy submission (verdict: Runtime Error):
from sys import stdin

def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))

    if N >= M:
        print(0)
        return

    X.sort()
    n = [(i + 1, X[i+1] - X[i]) for i in range(M - 1)]
    n.sort(reverse=1, key=lambda x: x[1])
    ans, s1 = 0, 0
    for i in range(N - 1):
        s2 = n[i][0]
        ans += X[s1:s2][-1] - X[s1:s2][0]
        s1 = s2
    ans += X[s1:][-1] - X[s1:][0]
    print(ans)

input = lambda: stdin.readline()
main()
Problem p03705 (python)

Fixed submission:
def main():
    N, A, B = map(int, input().split())

    if A > B or (N == 1 and A != B):
        ans = 0
    elif N == 1:
        ans = 1
    else:
        ans = (N - 2) * (B - A) + 1
    print(ans)

main()

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

    num = tuple(range(A, B+1))
    n = len(num)
    cmb = n ** (N - 2)
    ans = (cmb + 1) // 2
    print(int(ans))

main()

Buggy submission (verdict: Runtime Error):
import itertools

def main():
    N, A, B = map(int, input().split())

    num = tuple(range(A, B+1))
    val = []
    for n in itertools.combinations_with_replacement(num, N):
        if n[0] == A and n[-1] == B:
            val.append(sum(n))

    ans = len(set(val))
    print(ans)

main()
Problem p03724 (python)

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

    i = 0
    AB = [0 for i in range(N)]
    while i < M:
        a, b = map(int, input().split())
        AB[a-1] += 1
        AB[b-1] += 1
        i += 1

    for i in AB:
        if i % 2 > 0:
            print('NO')
            break
    else:
        print('YES')

main()

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

    i = 0
    AB = []
    while i < M:
        AB.append(tuple(map(int, input().split())))
        i += 1

    edge = [0 for i in range(M)]
    for i in AB:
        j = i[0] - 1
        end = i[1] - 1
        while j < end:
            edge[j] += 1
            j += 1

    for i in edge:
        if i % 2 > 0:
            print('NO')
            break
    else:
        print('YES')

main()
Problem p03785 (python)

Fixed submission:
def main():
    N, C, K = map(int, input().split())
    i = 0
    T = []
    while i < N:
        T.append(int(input()))
        i += 1
    T.sort()
    T.reverse()

    c = 1
    i = 1
    bus = 1
    time = T[0]
    while i < N:
        if time - T[i] > K or c == C:
            bus += 1
            c = 1
            time = T[i]
        elif time - T[i] <= K:
            c += 1
        i += 1

    print(str(bus))

main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    i = 1
    j = N - 1
    x = sum(A)
    while j > 0:
        if (x - A[j]) * 2 >= A[j]:
            i += 1
        else:
            break
        x -= A[j]
        j -= 1
    print(str(i))

main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    A.reverse()

    i = 1
    j = 1
    while j < N:
        if A[j - 1] / 2 <= sum(A[j:]):
            i += 1
        else:
            break
        j += 1
    print(str(i))

main()
Problem p03805 (python)

Fixed submission:
import itertools

def path(n):
    l = len(n)
    i = 0
    while i < l - 1:
        a = n[i]
        b = n[i + 1]

        if a < b:
            c = (a, b)
        else:
            c = (b, a)

        for m in C:
            if m == c:
                break
        else:
            return False
        i += 1
    return True

N, M = map(int, input().split())
C = []
i = 0
while i < M:
    C += [tuple(map(int, input().split()))]
    i += 1

i = 0
l = range(1, N + 1)
for n in itertools.permutations(l, N):
    if n[0] != 1:
        break
    if path(n) == True:
        i += 1
print(str(i))

Buggy submission (verdict: Runtime Error):
import itertools

def path(n):
    l = len(n)
    i = 0
    while i < l - 1:
        a = n[i]
        b = n[i + 1]

        if a < b:
            c = (a, b)
        else:
            c = (b, a)

        for m in C:
            if m == c:
                break
        else:
            return False
        i += 1
    return True

N, M = map(int, input().split())
C = []
i = 0
while i < N:
    C += [tuple(map(int, input().split()))]
    i += 1

i = 0
l = range(1, N + 1)
for n in itertools.permutations(l, N):
    if n[0] != 1:
        break
    if path(n) == True:
        i += 1
print(str(i))

Buggy submission (verdict: Runtime Error):
import itertools

def path(n):
    l = len(n)
    i = 0
    while i < l - 1:
        a = n[i]
        b = n[i + 1]

        if a < b:
            c = (a, b)
        else:
            c = (b, a)

        for m in C:
            if m == c:
                break
        else:
            return False
        i += 1
    return True

N, M = map(int, input().split())
C = []
i = 0
while i < N:
    C += [tuple(map(int, input().split()))]
    i += 1

i = 0
l = range(1, N + 1)
for n in itertools.permutations(l, N):
    print(n)
    if n[0] != 1:
        break
    if path(n) == True:
        i += 1
print(str(i))

Buggy submission (verdict: Runtime Error):
import itertools

def path(n):
    l = len(n)
    i = 0
    while i < l - 1:
        a = n[i]
        b = n[i + 1]

        if a < b:
            c = (a, b)
        else:
            c = (b, a)

        for m in C:
            if m == c:
                break
        else:
            return False
        i += 1
    return True

N, M = map(int, input().split())
C = []
i = 0
while i < N:
    C += [tuple(map(int, input().split()))]
    i += 1

i = 0
l = range(1, N + 1)
for n in itertools.permutations(l, N):
    if n[0] != 1:
        break
    if path(n) == True:
        i += 1
print(i)
Problem p02754 (python)

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

q, x = divmod(N, A+B)
#q = N//(A+B)
#x = N % (A+B)
ans = q*A+int(min(x,A))
#print(type(ans))
print(ans)

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

q, x = divmod(N, A+B)
#q = N//(A+B)
#x = N % (A+B)
ans = q*A+int(min(x,A))
#print(type(ans))
print(ans
Problem p02847 (python)

Fixed submission:
S = input()

A = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

if S == A[0]:
    ans = 7
elif S == A[1]:
    ans = 6
elif S == A[2]:
    ans = 5
elif S == A[3]:
    ans = 4
elif S == A[4]:
    ans = 3
elif S == A[5]:
    ans = 2
elif S == A[6]:
    ans = 1

print(ans)

Buggy submission (verdict: Runtime Error):
#
a, b, x = map(int, input().split())

#Binary Search
high = 10**9 + 1
low  = 0
n = 0
while high - low > 0:
    mid = (high + low)//2
    if a * mid + b * len(str(mid)) <= x:
        low = mid
    else:
        high = mid

print(low)
Problem p02880 (python)

Fixed submission:
n = int(input())

A = []
for i in range (10):
    for j in range(10):
        A.append(i*j)

if A.count(n) != 0:
    print("Yes")
else:
    print("No")

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

A = ()
for i in range (10):
    for j in range(10):
        A.append(i*j)

if A.count(n) != 0:
    print("Yes")
else:
    print("No")
Problem p03327 (python)

Fixed submission:
n = int(input())
if n < 1000:
	print('ABC')
else:
	print('ABD')

Buggy submission (verdict: Runtime Error):
n=int(input())
if (n < 1000)
	print("ABC")
else
	print("ABD")

Buggy submission (verdict: Runtime Error):
n=int(intput())
if n < 1000:
	print('ABC')
else:
	print('ABD')

Buggy submission (verdict: Runtime Error):
n=int(intput())
if n < 1000:
	print("ABC")
else:
	print("ABD")

Buggy submission (verdict: Runtime Error):
n=int(intput())
if (n < 1000)
	print("ABC")
else
	print("ABD")

Buggy submission (verdict: Runtime Error):
n=intput()
if (n < 1000)
	print("ABC")
else
	print("ABD")
Problem p02550 (python)

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

y=x
A=[]
A.append(y)
cnt=1
su=x

for i in range(m):
    y=(y**2)%m
    cnt+=1
    if y in A:
        break
    else:
        A.append(y)
        su+=y

c=A.index(y) #周期のはじめ
d=cnt-(c+1)  #周期のはじめから次の周期のはじめで個数を求める

e=sum(A[:c]) 
#周期に入るまえまでを足しておく


f=sum(A[c:c+(n-c)%d])
    #周期からはみでた最後の部分

g=su-e#1周期分
h=g*((n-c)//d)#かけざん

print(e+h+f)

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

y=x
A=[]
A.append(y)
cnt=1
su=x

for i in range(n):
    y=(y**2)%m
    cnt+=1
    if y in A:
        break
    else:
        A.append(y)
        su+=y

if len(A)==n:
    print(su)

else:



    c=A.index(y) #周期のはじめ
    d=cnt-(c+1)  #周期のはじめから次の周期のはじめで個数を求める

    e=sum(A[:c]) 
    #周期に入るまえまでを足しておく

    f=0
    for w in range((n-c)%d):
        f+=A[c:][w]
        #周期からはみでた最後の部分

    g=su-e#1周期分
    h=g*((n-c)//d)#かけざん

    print(e+h+f)

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

y=x
A=[]
A.append(y)
cnt=1
su=x

for i in range(n):
    y=(y**2)%m
    cnt+=1
    if y in A:
        break
    else:
        A.append(y)
        su+=y

if len(A)==N:
    print(su)

else:



    c=A.index(y) #周期のはじめ
    d=cnt-(c+1)  #周期のはじめから次の周期のはじめで個数を求める

    e=sum(A[:c]) 
    #周期に入るまえまでを足しておく

    f=0
    for w in range((n-c)%d):
        f+=A[c:][w]
        #周期からはみでた最後の部分

    g=su-e#1周期分
    h=g*((n-c)//d)#かけざん

    print(e+h+f)
Problem p03631 (python)

Fixed submission:
# その13
# A - Palindromic Number

N = str(input())

if N[0] == N[2]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# その13
# A - Palindromic Number

N = int(input())

if N[0] == N[2]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# その13
# A - Palindromic Number

N = int(input())

if N[0] = N[2]:
    print('Yes')
else:
    print('No')
Problem p02547 (python)

Fixed submission:
#B
n = int(input())
count=0
mcount=0
for i in range(n):
    a,b = list(map(int, input().split()))
    if a==b:
        count+=1
        if mcount<count:
            mcount = count
            if mcount==3:
                break
    else:
        count=0
if mcount==3:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#B
n = int(input())
count=0
mcount=0
for i in range(n):
    a,b = list(map(int, input().split()))
    if a==b:
        count+=1
        if mcount<count:
            mcount = count
            if mcount=3:
                break
    else:
        count=0
if mcount=3:
    print("Yes")
else:
    print("No")
Problem p02596 (python)

Fixed submission:
N=int(input())
num = 7
i=1
a=[]
prir1=1
while i<=N:
    xx=num%N
    if xx==0:
        print(i)
        prir1=0
        break
    num=10*xx+7
    i+=1
if prir1:
    print(-1)

Buggy submission (verdict: Runtime Error):
N=int(input())
num=0
if (N%2==0)or(N%5==0):
    print(-1)
else:
    for i in range(1,N):
        num+=i*7
        if num%N==0:
            break
    print(i)
Problem p02572 (python)

Fixed submission:
MOD = 10 ** 9 + 7

n=int(input())
alst=list(map(int,input().split()))

total=sum(alst)
sum=0

# for i in range(n-1):
#   for j in range(i+1,n):
#     sum=pow(sum+alst[i]*alst[j],1,MOD)

# print(sum)

for a in alst:
  sum = sum+a * (total - a)
  sum %= MOD

sum *= pow(2, MOD - 2, MOD)
sum %= MOD
print(sum)

Buggy submission (verdict: Runtime Error):
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=np.cumsum(alst,dtype='list')

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)
Problem p02572 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
total = 0
sub = 0
for i in a:
    total += i
    sub += i * i
print((((total * total) - sub) // 2) % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
for i in range (N):
    A = (int(input())
MASS = 0
for i in range (N - 1):
    T = 0
    for j in range (i + 1, N):
        T += (A[j] % NUM)
    MASS += ((A[i]%NUM) * (T%NUM))%NUM
print(MASS % NUM)

Buggy submission (verdict: Runtime Error):
N = int(input())
NUM = 1000000007
A = [int(input()) for _ in range(N)]
MASS = 0
for i in range (N):
    I = A[i] % NUM
    I = (I * (N - 1)) % NUM
    MASS += I
print(MASS % NUM)

Buggy submission (verdict: Runtime Error):
N = int(input())
NUM = 1000000007
A = [list(map(int, input().split())) for _ in range(N)]
MASS = 0
for i in range (N):
    I = A[i] % NUM
    I = (I * (N - 1)) % NUM
    MASS += I
print(MASS % NUM)
Problem p02595 (python)

Fixed submission:
import math
n, d = list(map(int, input().split()))
count = 0
for _ in range(n):
  x, y = list(map(int, input().split()))
  if math.sqrt(x**2 + y**2) <= d:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N, D = list(map(int, input().split()))
count = 0
for i in range(N):
  x, y = list(map(int, input().split()))
  if (x**2 + y**2) <= d**2:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
D = int(input())
count = 0
for i in range (N):
    x = int(input())
    y = int(input())
    if((D * D) >= ((x * x) + (y * y))):
        ++count
print(count)

Buggy submission (verdict: Runtime Error):
N = input()
D = input()
count = 0
for i in range (N):
    x = input()
    y = input()
    if((D * D) >= ((x * x) + (y * y))):
        ++count
print(count)
Problem p02596 (python)

Fixed submission:
K = int(input())

t = 7
for i in range(K):
    if t % K == 0:
        print(i + 1)
        break
    t = (t * 10 + 7) % K
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
K = int(input())
if(K % 2 == 0) or (K % 5 == 0):
    print(-1)
N = 7
for i in range(K):
    if　N % K == 0:
        print(i + 1)
        break
    N = ((N * 10) + 7) % K

Buggy submission (verdict: Runtime Error):
K = int(input())
if(K % 2 == 0 or K % 5 == 0):
    print(-1)
N = 7
for i in range(K):
    if　N % K == 0:
        print(i + 1)
        break
    N = ((N * 10) + 7) % K

Buggy submission (verdict: Runtime Error):
K = int(input())
if(K % 2 == 0 or K % 5 == 0):
    print(-1)
N = 7
for i in range(K):
    if　N % K == 0:
        print(i + 1)
        break
    else:
        N = ((N * 10) + 7) % K

Buggy submission (verdict: Runtime Error):
K = int(input())
if(K % 2 == 0 | K % 5 == 0):
    print(-1)
N = 7
for i in range(K):
    if　N % K == 0:
        print(i + 1)
        break
    else:
        N = ((N * 10) + 7) % K

Buggy submission (verdict: Runtime Error):
K = int(input())
if(K % 2 == 0 | K % 5 == 0):
    print(-1)
N = 7
for i in range(K):
    if　N % 7 == 0:
        print(i + 1)
        break
    else:
        N = ((N * 10) + 7) % K

Buggy submission (verdict: Runtime Error):
import sys
K = int(input())
N = 0
for i in range 2000000:
    if((K // (N + (10**i)*7)) == 0):
        print(i + 1)
        sys.exit()
    else:
        N = (N + (10**i)*7)
print(-1)
Problem p02547 (python)

Fixed submission:
n = int(input())
d = [list(map(int, input().split()))for _ in range(n)]

cnt = 0
for i, (p, q) in enumerate(d):
    if p == q:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        break
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
d = [list(map(int, input().split()))for _ in range(n)]
​
cnt = 0
for i, (p, q) in enumerate(d):
    if p == q:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:        
        print("Yes")
        break
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
d = [list(map(int, input().split()))for _ in range(n)]
​
cnt = 0
for i, (p, q) in enumerate(d):
    if p == q:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:        
        print("Yes")
        break
else:
    print("No")
5

Buggy submission (verdict: Runtime Error):
n = int(input())
d = [list(map(int, input().split()))for _ in range(n)]

flg = False
for i, (p, q) in enumerate(d):
    if p == q:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:        
        print("Yes")
        break
else:
    print("No")
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_sum = [0]
b_sum = [0]
for i in range(n):
    a_sum.append(a_sum[i] + a[i])
for i in range(m):
    b_sum.append(b_sum[i] + b[i])
    
ans, j = 0, m
for i in range(n + 1):
    if a_sum[i] > k:
        break
    while b_sum[j] > k - a_sum[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

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

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

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

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

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

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

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

cnt = 0
sum_ = k
idx_a = 0
idx_b = 0
while sum_ > 0:
    if a[idx_a] == 0 and b[idx_b] != 0:
        while sum_ > 0:
            sum_ = sum_ - b[idx_b]
            idx_b += 1
            cnt += 1
    elif b[idx_b] == 0 and a[idx_a]!= 0:
        while sum_ > 0:
            sum_ = sum_ - a[idx_a]
            idx_a += 1        
            cnt += 1
    else:
        while sum_ > 0:
            if a[idx_a] > b[idx_b]:
                sum_ = sum_ - b[idx_b]
                b[idx_b] = 0
                idx_b += 1
                cnt += 1
#             elif a[idx_a] < b[idx_b]:
            else:
                sum_ = sum_ - a[idx_a]
                a[idx_a] = 0
                idx_a += 1
                cnt += 1
print(cnt - 1)
Problem p02629 (python)

Fixed submission:
n = int(input())

def calc(m, res):
        q, mod = divmod(m, 26)
        if (mod == 0):
            q = q - 1
            mod = 26
            res = chr(ord("a") + (mod - 1)) + res
        else:
            res = chr(ord("a") + (mod - 1)) + res
        if (q > 0):
            calc(q, res)
        else:
            print(res)
        return
    
calc(n, "")

Buggy submission (verdict: Runtime Error):
arr = ["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"]
n = int(input())

def calc(sho, res):
    q, mod = divmod(sho, 26)
    res = arr[mod - 1] + res
    if (mod == 0):
        print(res)
    else:
        res = arr[q - 1] + res
        print(res)
    return
    
calc(n, "")

Buggy submission (verdict: Runtime Error):
def calc(sho, res):
    q, mod = divmod(sho, 26)
    res = arr[mod - 1] + res
    if(q >= 26):
        calc(q, res)
    else:
        if (q == 0):
            print(res)
        elif(mod == 0):
            print(res)
        else:
            res = arr[q - 1] + res
            print(res)
    return 

calc(n, "")
Problem p02633 (python)

Fixed submission:
import math
from fractions import Fraction

x = int(input())


k = 0
while True:
    k += 1
    s = x * k
    if s % 360 == 0:
        break
print(k)

Buggy submission (verdict: Runtime Error):

x = int(input())
rad = (math.pi / 180) * x

cos = 0
sin = 0
k = 0
while True:
    cos += (math.cos(rad * k))
    sin += (math.sin(rad * k))
    k += 1
    if int(cos) ==0 and int(sin) == 0:
        break
if k == 359:
    k = 360
print(k)
Problem p02682 (python)

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

x = k - a
if x <= 0:
    print(k)
else:
    y = x - b
    if y <= 0:
        print(a)
    else: 
        print(a + ((k - (a + b)) * (-1)))

Buggy submission (verdict: Runtime Error):
2000000000 0 0 2000000000