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

Fixed submission:
N = int(input())
count = 0
for i in range(N+1):
  if i % 3 != 0 and i % 5 != 0:
    count += i
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
count = 0
for i in range(N+1):
  if i % 3 != 0 and i % 5 != 0:
  print(i)
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
def f(N):
  if N % 5 == 0 and N % 3 == 0:
    return f(N-1)
  elif N % 5 == 0:
    return f(N-1)
  elif N % 3 == 0:
    return f(N-1)
  elif N == 1:
    return 1
  else:
    return f(N-1)+N
print(f(N))
Problem p02754 (python)

Fixed submission:
a = list(map(int,input().split()))
N = a[0]
blue = a[1]
red = a[2]
ans = 0
A = blue + red
X = N // A
Y = N % A
if Y <= blue:
    ans = blue * X + Y
else:
    ans = blue * X + blue
print(ans)

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

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

t1 = np.ones(A,dtype=np.int64)
t2 = np.zeros(B,dtype=np.int64)
t = np.hstack((t1, t2))

L = len(t)

Q = N // L
R = N % L
ANS = Q*(np.sum(t))+np.sum(t[0:R])
print(ANS)
Problem p03265 (python)

Fixed submission:
A = list(map(int, input().split()))
L = len(A)
ans = [0, 0, 0, 0]
dx = A[2] - A[0]
dy = A[3] - A[1]
if(dx>=0 and dy>=0):
    dx = abs(dx)
    dy = abs(dy)
    x3 = A[2] - dy
    y3 = A[3] + dx
    x4 = x3 - dx
    y4 = y3 - dy
elif(dx>0 and dy<0):
    dx = abs(dx)
    dy = abs(dy)
    x3 = A[2] + dy
    y3 = A[3] + dx
    x4 = x3 - dx
    y4 = y3 + dy
elif(dx<=0 and dy<=0):
    dx = abs(dx)
    dy = abs(dy)
    x3 = A[2] + dy
    y3 = A[3] - dx
    x4 = x3 + dx
    y4 = y3 + dy
elif(dx<0 and dy>0):
    dx = abs(dx)
    dy = abs(dy)
    x3 = A[2] - dy
    y3 = A[3] - dx
    x4 = x3 + dx
    y4 = y3 - dy

ans[0] = str(x3)
ans[1] = str(y3)
ans[2] = str(x4)
ans[3] = str(y4)
ans = ' '.join(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split()))
L = len(A)
ans = [0, 0, 0, 0]
dx = A[2] - A[0]
dy = A[3] - A[1]
if(dx>0 and dy>=0):
    dx = abs(dx)
    dy = abs(dy)
    x3 = A[2] - dy
    y3 = A[3] + dx
    x4 = x3 - dx
    y4 = y3 - dy
elif(dx>=0 and dy<0):
    dx = abs(dx)
    dy = abs(dy)
    x3 = A[2] + dy
    y3 = A[3] + dx
    x4 = x3 - dx
    y4 = y3 + dy
elif(dx<=0 and dy<0):
    dx = abs(dx)
    dy = abs(dy)
    x3 = A[2] + dy
    y3 = A[3] - dx
    x4 = x3 + dx
    y4 = y3 + dy
elif(dx<0 and dy>=0):
    dx = abs(dx)
    dy = abs(dy)
    x3 = A[2] - dy
    y3 = A[3] - dx
    x4 = x3 + dx
    y4 = y3 - dy

ans[0] = str(x3)
ans[1] = str(y3)
ans[2] = str(x4)
ans[3] = str(y4)
ans = ' '.join(ans)
print(ans)
Problem p03307 (python)

Fixed submission:
a = int(input())
ans = 0
if a % 2 == 0:
    ans = a
else:
    ans = a * 2

print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
ans = 0
if a % 2 == 0:
    ans = a
elif a[i] == "-":
    ans = a * 2

print(ans)
Problem p02552 (python)

Fixed submission:
x = input()
x = int(x)
if x == 1:
    print("0")
else:
    print("1")

Buggy submission (verdict: Runtime Error):
x = int(input())
if x = 1:
  print("0")
if x = 0:
  print("1")
Problem p02699 (python)

Fixed submission:
S,W = input().split()
if int(W) >= int(S):
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
if W >= S:
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
S =  int(input('How many sheep'))
W =  int(input('How many wolf'))
if W >= S:
    print('unsafe')
else:
    print('safe')
Problem p02987 (python)

Fixed submission:
# cook your dish here
s = input()
a=[0,0,0,0]
b=[1,1,1,1]
for i in range(4):
    for j in range(4):
        if(s[i]==s[j] and i != j):
            a[i]+=1 
if(a==b):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
# cook your dish here
s = input()
c = 0 
if(s[0]==s[1] and s[2]==s[3]):
    c=1 
elif(s[0]==s[2] and s[1]==a[3]):
    c=1 
elif(s[0]==s[3] and s[1]==s[2]):
    c=1 
if(c==1):
    print("Yes")
else:
    print("No")
Problem p02594 (python)

Fixed submission:
N = int(input().strip())
if(N >= 30):
  print("Yes")
elif(N<30):
  print("No")

Buggy submission (verdict: Runtime Error):
import math

#N行,距離D
N,D = map(int, input().split())

num_list = []
for i in range(N):
    num_list.append(list(map(int,input().split())))

count = 0
for p,q in num_list:
  d = math.sqrt(p**2 + q**2)
  if(d<=D):
    count += 1
    
print(count)
Problem p02676 (python)

Fixed submission:
K=int(input())
S=input()
s=list(S)

if len(s) <= K:
    print(S)
else:
    print(S[0:K:]+"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=input()
s=list(S)

if len(s) =< K:
    print(S)
else:
    print(S[0:K:]+"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=input()
s=list(S)

if len(s) < K:
    print(S)
else:
    print(s[0:(K-1):]+"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())

if len(S) < K:
    print(S)
else:
    print(S[0:(SL-1):1],"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())

if (len(S)+1) <= K:
    print(S)
else:
    print(S[0:(SL-1):1],"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())

if (len(S)+1) <= K:
    print(S)
elif (len(S)+1) > K:
    print(S[0:(SL-1):1],"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())

LS=len(S)

if (LS+1) <= K:
    print(S)
elif (LS+1) > K:
    print(S[0:(SL-1):1],"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())

LS=len(S)+1

if LS <= K:
    print(S)
elif LS > K:
    print(S[0:(SL-1):1],"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())

LS==len(S)+1

if LS <= K:
    print(S)
elif LS > K:
    print(S[0:(SL-1):1],"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())

LS==len(S)

if LS <= K:
    print(S)
elif LS > K:
    print(S[0:(SL-1):1],"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())

LS=len(S)

if LS <= K:
    print(S)
elif LS > K:
    print(S[0:(SL-1):1],"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())

if len(S) < K:
    print(S)
elif len(S) > K:
    print(S[0:(SL-1):1],"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())

if len(S) =< K:
    print(S)
elif len(S) > K:
    print(S[0:(SL-1):1],"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())

SL==len(S)

if SL =< K:
    print(S)
elif SL > K:
    print(S[0:(SL-1):1],"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=input()

SL=len(S)

if SL =< K:
    print(S)
elif SL > K:
    print(S[0:(SL-1):1],"...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=list(input())

SL=len(S)

if SL =< K:
    print(S)
elif SL > K:
    print(S[0:(SL-1):1])
Problem p02693 (python)

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

yn=0
for i in range(A,B+1,1):
    if (i % K) == 0:
        print("OK")
        yn=1
        break
if yn==0:
    print("NG")

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

for i in range(A,B,1):
    if (i %= K) == 0:
        print("OK")
        break
print("NG")

Buggy submission (verdict: Runtime Error):
K=input()
A=input()
B=input()

for i in range(A,B,1):
    if (i %= K) == 0:
        print("OK")
    else:
        print("NG")

Buggy submission (verdict: Runtime Error):
K=input()
A=input()
B=input()

for i in range(A,B,1):
  if (i %= K) == 0:
    print("OK")

Buggy submission (verdict: Runtime Error):
K=input()
A=input()
B=input()

for i in range(A,B):
  if (i %= K) ==0:
    print("OK")

Buggy submission (verdict: Runtime Error):
K=input()
A=input()
B=input()

i %= K
for i in range(A,B): 
  if i==0:
    print("OK")

Buggy submission (verdict: Runtime Error):
K=input()
A=input()
B=input()

for i in range(A,B):
  i %= K
  if i==0:
    print("OK")

Buggy submission (verdict: Runtime Error):
K=input()
A=input()
B=input()

for i in range(A,B)
i %= K
if i==0:
  print("OK")
Problem p02711 (python)

Fixed submission:
N=int(input())

a=N//100
b=(N-(a*100))//10
c=(N-(a*100+b*10))

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

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

a==N//100
b==(N-(a*100))//10
c==(N-(a*100+b*10))

if (a == 7):
    print("Yes")
else:
    print("No")

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

a==N//100
b==(N-(a*100))//10
c==(N-(a*100+b*10))

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

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

a==N//100
b==(N-(a*100))//10
c==(N-(a*100+b*10))

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

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

a==N//100
b==(N-(a*100))//10
c==(b-(a*100))//1

if ((a = 7) or (b= 7) or (c=7)):
    print("Yes")

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

a==N//100
b==(N-(a*100))//10
c==(b-(a*100))//1

if ((a == 7) or (b== 7) or (c==7)):
    print("Yes")
Problem p02723 (python)

Fixed submission:
n=list(input())

if n[2]==n[3] and n[4]==n[5]:
    print("Yes")
else:
    print("No")

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

if n[3]==n[4] and n[5]==n[6]:
    print("Yes")
else:
    print("No")

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

if (n[3]==n[4]):
    pass
    if (n[5]==n[6]):
        print("Yes")
    else:
        print("No")

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

if (n[3]==n[4] and n[5]==n[6]):
    print("Yes")
else:
    print("No")

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

if (n[3]==n[4] and n[5]==n[6])
    print("Yes")
else:
    print("No")
Problem p02729 (python)

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

print((N*(N-1)//2)+(M*(M-1)//2))

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

print(N*(N-1)/2+M*(M-1)/2)
Problem p02570 (python)

Fixed submission:
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

D,T,S = map(int,sys.stdin.readline().split())

if D <= T * S:
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env pypy3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import math,sys

n = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split()))
#n = int(input())
#a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)
acc = a[0]
for i in range(n):
    acc = math.gcd(acc,a[i])
if acc != 1:
    print("not coprime")
    exit()

LIMIT=max(a)
minPrime = [0]*(LIMIT+1)
minPrime[1] = 1
def make():
    for i in range(2,LIMIT+1):
        if minPrime[i] == 0:
            minPrime[i] = i
            #print(i)
            for j in range(i+i,LIMIT+1,i):
                #print(i,j)
                if minPrime[j] == 0:
                    minPrime[j] = i
make()
def factrial(N):
     ret = []
     while minPrime[N] != N:
         ret.append(minPrime[N])
         N = N//minPrime[N]
     if N != 1:
         ret.append(N)
     return ret

judge = set([])

for e in a:
    asf = set(factrial(e))
    if judge & asf != set():
        print("setwise coprime")
        exit()
    #judge |= asf
    judge = judge | asf #too slow
print("pairwise coprime")
Problem p02629 (python)

Fixed submission:
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

N = int(sys.stdin.readline())


def Base_10_to_n(X, n):
    m = chr(X%n+ord("a"))
    if (X//n):
        return Base_10_to_n(X//n-1, n)+m
    return m

print(Base_10_to_n(N-1,26))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

N = int(sys.stdin.readline())


def Base_10_to_n(X, n):
    m = chr(X%n+ord("a"))
    if (X//n):
        return Base_10_to_n(X//n-1, n)+m
    return m

print(N)print(Base_10_to_n(N-1,26))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

N = int(sys.stdin.readline())
A = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
Q = int(sys.stdin.readline())
BC = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(Q)) # multi line with multi param
co = collections.Counter(A)
s = sum(A)

for b,c in BC:
    if b in co:
        n = co[b]
        del(co[b])
        co[c] += n
        s += (c-b)*n
    print(s)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

N = int(sys.stdin.readline())


def Base_10_to_n(X, n):
    m = chr(X%n+ord("a"))
    if (X//n):
        return Base_10_to_n(X//n-1, n)+m
    return m

print(N)print(Base_10_to_n(N-1,26))
Problem p02682 (python)

Fixed submission:
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(sys.stdin.readline() for _ in range(n)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

A,B,C,K = map(int,sys.stdin.readline().split())

#ALL = [1]*A+[0]*B+[-1]*C
#print(sum(ALL[:K]))
print(1*min(A,K)+0*min(B,max(K-A,0))-1*min(C,max(K-A-B,0)))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(sys.stdin.readline() for _ in range(n)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

A,B,C,K = map(int,sys.stdin.readline().split())

ALL = [1]*A+[0]*B+[-1]*C

print(sum(ALL[:K]))
Problem p02629 (python)

Fixed submission:
n = int(input())
ans = ''
check = 'abcdefghijklmnopqrstuvwxyz'
while n != 0:
    n -= 1
    ans += check[n%26]
    n //= 26
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
str_row = ['z','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']
result = []

while N > 26:
    r = N % 26
    result.append(str_row[r])
    N = int(N / 26)
    if N == 27:
        break

if N == 27:
    result.append('z')
else:
    result.append(str_row[N])

for i in result[::-1]:
    print(str(i), end='')

Buggy submission (verdict: Runtime Error):
N = int(input())
str_row = ['z','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']
result = []

while N > 26:
    r = N % 26
    result.append(str_row[r])
    N = int(N / 26)
result.append(str_row[N])

for i in result[::-1]:
    print(str(i), end='')
Problem p02682 (python)

Fixed submission:
A, B, C, K = map(int, input().split())
lst = []
sum = 0
if A <= K:
    sum += 1 * A
else:
    sum += 1 * K

k = K - (A + B)

if (C <= k) and (k > 0):
    sum += -1 * C
elif (C > k) and k > 0:
    sum += -1 * k

print(sum)

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())
lst = []
sum = 0
if A <= K:
    sum += 1 * A
else:
    sum += 1 * K

k = K - (A + B)

if (C <= k) and (k > 0):
    sum += -1 * C
elif (c > k) and (k > 0):
    sum += -1 * k

print(sum)
Problem p02777 (python)

Fixed submission:
S, T = [i for i in input().split()]
A, B = map(int, input().split())
U = input()
if U == S:
    A -= 1
elif U == T:
    B -= 1
print(str(A) + " " + str(B))

Buggy submission (verdict: Runtime Error):
S, T = [i for i in input().split()]
A, B = map(int, input().split())
U = input()
if U == S:
    A -= 1
elif U == T:
    B -= 1
print(f'{A} {B}')

Buggy submission (verdict: Runtime Error):
S, T = [i for i in input().split()]
A, B = map(int, input().split())
U = input()
if U == S:
    A -= 1
elif U == T:
    B -= 1
print(f'{A} {B}')

Buggy submission (verdict: Runtime Error):
S, T = [i for i in input().split()]
A, B = map(int, input().split())
U = input()
if U == S:
    A -= 1
elif U == T:
    B -= 1
print(f'{A} {B}')
Problem p02951 (python)

Fixed submission:
A, B , C = map(int, input().split())
x = A - B
if (x <= C):
  print(C - x)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
x = A - B
pritn(C - x)
Problem p02557 (python)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
brr=list(map(int,input().split()))[::-1]
start=end=-1
for i in range(n):
    if arr[i]==brr[i]:
        
        if start==-1:
            start=end=i
        else:
            end=i
if start==-1:


    print('Yes')
    print(*brr)
else:

    i=0
    while i<n and start<=end:
        if brr[i]!=arr[end] and arr[i]!=arr[end]:
            brr[i],brr[start]=brr[start],brr[i]
            start+=1
        i+=1
    if start>end:
        print('Yes')
        print(*brr)
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
brr=list(map(int,input().split()))[::-1]
start=end=-1
for i,val in range(n):
  if arr[i]==brr[i]:
    if start==-1:
      start=end=i
    else:
      end=i
if start==-1:
  print('Yes')
  print(*brr)
else:
  i=0
  while i<n and start<=end:
    if brr[i]!=arr[end] and arr[i]!=arr[end]:
      brr[i],brr[start]=brr[start],brr[i]
      start+=1
    i+=1
  if start>end:
    print('Yes')
  	print(*brr)
  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.insert(0,0)
b.insert(0,0)
j=1
while j<=m and b[j]+b[j-1]<=k:
  b[j]+=b[j-1]
  j+=1
  

j-=1
books=j
#print(books,b)

i=1
while i<n+1:
  a[i]+=a[i-1]
  while j>=0 and a[i]+b[j]>k:
    j-=1
  if(j!=-1) and a[i]+b[j]<=k:
    books=max(books,j+i)
    
    
    i+=1
    #print(books,b[:j+1],a[:i])
  else:
    break
print(books)

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

while i<n and limit>=a[i]:
   
    limit-=a[i]
    i+=1
    
limit2=k
while j<m and limit2>=b[j]:
  
   
    limit2-=b[j]
    j+=1

if(i>j)or(i==j and limit>=limit2):
    j=0
    while j<m and limit>=b[j]:
        j+=1
        limit-=b[j]
else:
    i=0
    while i<n and limit2>=a[i]:
        i+=1
        limit2-=a[i]
print(i+j)
Problem p02990 (python)

Fixed submission:
import math


def combi(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n, k = map(int, input().split())
div_num = 10 ** 9 + 7
for i in range(1, k + 1):
    if n - k + 1 >= i:
        print(combi(n - k + 1, i) * combi(k - 1, i - 1) % div_num)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
import math


def combi(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n, k = map(int, input().split())
div_num = 10 ** 9 + 7
for i in range(1, k + 1):
    print(combi(n - k + 1, i) * combi(k - 1, i - 1) % div_num)
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(m)]
a.sort()
bc.sort(reverse=True, key=lambda x: x[1])
last_idx = len(a) - 1
idx = 0
for e in bc:
    b, c = e
    for i in range(b):
        if i + idx > last_idx:
            break
        if a[i + idx] < c:
            a[i + idx] = c
    idx += b

print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(m)]
a.sort()
bc.sort(reverse=True, key=lambda x: x[1])
last_idx = len(a) - 1
idx = 0
for e in bc:
    b, c = e
    for i in range(b):
        if i + idx > last_idx:
            break
        if a[i + idx] < c:
            a[i + idx] = c
        else:
            break
    else:
        idx += b
        print(a)
        print(idx)
        continue
    break

print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(m)]
a.sort()
bc.sort(reverse=True, key=lambda x: x[1])
last_idx = len(a) - 1
idx = 0
for e in bc:
    b, c = e
    for i in range(b):
        if i + idx >= last_idx:
            break
        if a[i + idx] < c:
            a[i + idx] = c
        else:
            break
    else:
        idx += b
        print(a)
        print(idx)
        continue
    break

print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(m)]
a.sort()
bc.sort(reverse=True, key=lambda x: x[1])

idx = 0
for e in bc:
    b, c = e
    for i in range(b):
        if a[i + idx] < c:
            a[i + idx] = c
        else:
            break
    else:
        idx += b
        continue
    break

print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(m)]
a.sort()
bc.sort(reverse=True, key=lambda x: x[1])

idx = 0
for e in bc:
    b, c = e
    for i in range(b):
        if a[i + idx] < c:
            a[i + idx] = c
    idx += b

print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(m)]
a.sort()
bc.sort(reverse=True, key=lambda x: x[1])

idx = 0
for e in bc:
    b, c = e
    for i in range(b):
        if a[i + idx] < c:
            a[i + idx] = c
        else:
            break
    else:
        idx += b
        continue
    break

print(sum(a))