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

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

dic = {}
for i in range(n):
    if a[i] in dic:
        dic[a[i]].append(i)
    else:
        dic[a[i]] = [i]

zero = [-1 for i in range(n)]
for key, value in dic.items():
    num = len(value)
    for i in range(num-1):
        zero[value[i]] = value[i+1] - value[i] + 1
    zero[value[-1]] = n - value[-1] + value[0] + 1

lst = [zero]
while lst[-1][0] <+ n*k - 1:
    before = lst[-1]
    after = []
    for i in range(n):
        after.append(before[i] + before[(before[i]+i)%n])
    lst.append(after)
lst.pop()

i = 0
while lst != []:
    lsti = lst.pop()
    while True:
        if i + lsti[i%n] <= n*k - 1:
            i = i + lsti[i%n]
        else:
            break

i = i % n
nokori = a[i:]
lst = []
dic = {}
ko = 0
for i in range(len(nokori)):
    if nokori[i] not in dic:
        lst.append(nokori[i])
        dic[nokori[i]] = ko
        ko += 1
    else:
        lst = lst[:dic[nokori[i]]]
        dic = {}
        for j in range(len(lst)):
            dic[lst[j]] = j
        ko = len(lst)
print(*lst)

Buggy submission (verdict: Runtime Error):
from collections import deque

n, k = map(int, input().split())
a = list(map(int, input().split()))

kotae = deque([])
lst = []
d = deque(a)
shugo = []
pattern = 0
while True:
    for kazu in d:
        if kazu in kotae:
            ind = kotae.index(kazu)
            for _ in range(len(kotae) - ind):
                kotae.pop()
        else:
            kotae.append(kazu)
    kotae_lst = list(kotae)
    if kotae_lst in shugo:
        break
    else:
        shugo.append(kotae_lst)
        lst.append(kotae_lst)
        pattern += 1

doko = k % pattern
ans = lst[doko-1]
if ans != []:
    print(' '.join(map(str, ans)))
Problem p02998 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
edges = [[] for i in range(2*10**5)]
for i in range(n):
    xi, yi = map(int, input().split())
    xi -= 1
    yi = yi - 1 + 10**5
    edges[xi].append(yi)
    edges[yi].append(xi)

already = set([])
def dfs(x, y, node):
    if node in already:
        return x, y
    if node < 10**5:
        x += 1
    else:
        y += 1
    already.add(node)
    for next_node in edges[node]:
        x, y = dfs(x, y, next_node)
    return x, y

num = 0
for i in range(10**5):
    x, y = dfs(0, 0, i)
    num += x * y
print(num-n)

Buggy submission (verdict: Runtime Error):
n = int(input())
edges = [[] for i in range(2*10**5)]
for i in range(n):
    xi, yi = map(int, input().split())
    xi -= 1
    yi = yi - 1 + 10**5
    edges[xi].append(yi)
    edges[yi].append(xi)

already = set([])
def dfs(x, y, node):
    if node in already:
        return x, y
    if node < 10**5:
        x += 1
    else:
        y += 1
    already.add(node)
    for next_node in edges[node]:
        x, y = dfs(x, y, next_node)
    return x, y

num = 0
for i in range(10**5):
    x, y = dfs(0, 0, i)
    num += x * y
print(num-n)
Problem p03038 (python)

Fixed submission:
import numpy as np

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

b = [0] * M
c = [0] * M
for i in range(M):
    b[i], c[i] = map(int, input().split())

lst = np.array([c, b]).T.tolist()
lst.sort(reverse=True)
c = np.array(lst).T.tolist()[0]
b = np.array(lst).T.tolist()[1]

k = 0
judge = 0
for i in range(M):
    if k+b[i]-1 < N:
        if A[k+b[i]-1] < c[i]:
            A[k:k+b[i]] = [c[i]] * b[i]
            k += b[i]
        else:
            for j in range(b[i]):
                if k < N:
                    if A[k] < c[i]:
                        A[k] = c[i]
                        k += 1
                    else:
                        judge = 1
                        break
            if judge == 1:
                break
    elif k < N:
        for j in range(b[i]):
            if k < N:
                if A[k] < c[i]:
                    A[k] = c[i]
                    k += 1
                else:
                    judge = 1
                    break
        if judge == 1:
            break
    else:
        break

print(sum(A))

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

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

b = [0] * M
c = [0] * M
for i in range(M):
    b[i], c[i] = map(int, input().split())

lst = np.array([c, b]).T.tolist()
lst.sort(reverse=True)
c = np.array(lst).T.tolist()[0]
b = np.array(lst).T.tolist()[1]

k = 0
judge = 0
for i in range(M):
    if k < N:
        if A[k+b[i]-1] < c[i]:
            A[k:k+b[i]] = [c[i]] * b[i]
            k += b[i]
        else:
            for j in range(b[i]):
                if A[k] < c[i]:
                    A[k] = c[i]
                    k += 1
                else:
                    judge = 1
                    break
            if judge == 1:
                break

print(sum(A))

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

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

b = [0] * M
c = [0] * M
for i in range(M):
    b[i], c[i] = map(int, input().split())

lst = np.array([c, b]).T.tolist()
lst.sort(reverse=True)
c = np.array(lst).T.tolist()[0]
b = np.array(lst).T.tolist()[1]

k = 0
judge = 0
for i in range(M):
    for j in range(b[i]):
        if A[k] < c[i]:
            A[k] = c[i]
            k += 1
        else:
            judge = 1
            break
    if judge == 1:
        break

print(sum(A))
Problem p03127 (python)

Fixed submission:
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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

print(gcd(*a))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

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

print(gcd(*a))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

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

print(gcd(*a))
Problem p03822 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**5)

n = int(input())
dic = {}
for i in range(n+1):
    if i <= 1: continue
    ai = int(input())
    if ai in dic:
        dic[ai].append(i)
    else:
        dic[ai] = [i]

def dfs(nxt):
    lst = []
    if nxt in dic:
        while dic[nxt] != []:
            child = dic[nxt].pop()
            tempmax = dfs(child)
            lst.append(tempmax)
    else:
        return 0
    lst.sort(reverse=True)
    for i in range(len(lst)):
        lst[i] += i+1
    return max(lst)

ans = dfs(1)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**10)

n = int(input())
dic = {}
for i in range(n+1):
    if i <= 1: continue
    ai = int(input())
    if ai in dic:
        dic[ai].append(i)
    else:
        dic[ai] = [i]

def dfs(nxt):
    lst = []
    if nxt in dic:
        while dic[nxt] != []:
            child = dic[nxt].pop()
            tempmax = dfs(child)
            lst.append(tempmax)
    else:
        return 0
    lst.sort(reverse=True)
    for i in range(len(lst)):
        lst[i] += i+1
    return max(lst)

ans = dfs(1)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
dic = {}
for i in range(n+1):
    if i <= 1: continue
    ai = int(input())
    if ai in dic:
        dic[ai].append(i)
    else:
        dic[ai] = [i]

def dfs(nxt):
    lst = []
    if nxt in dic:
        while dic[nxt] != []:
            child = dic[nxt].pop()
            tempmax = dfs(child)
            lst.append(tempmax)
    else:
        return 0
    lst.sort(reverse=True)
    for i in range(len(lst)):
        lst[i] += i+1
    return max(lst)

ans = dfs(1)
print(ans)
Problem p02989 (python)

Fixed submission:
N = int(input())
d = sorted(list(map(int, input().split())))
print(d[int(N / 2)] - d[int(N / 2 - 1)])

Buggy submission (verdict: Runtime Error):
N = int(input())
d = sorted(list(map(int, input().split())))
print(d[N / 2] - d[N / 2 - 1])
Problem p02990 (python)

Fixed submission:
N, K = map(int, input().split())
MOD = 10 **9 + 7
C = [[0] * (N + 1) for i in range(N + 1)]
C[1][1] = 1
for i in range(2, N + 1):
    for j in range(1, i + 1):
        if j == 1:
            C[i][j] = C[i - 1][j] + 1
        elif j == i:
            C[i][j] = 1
        else:
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j]
print(N - K + 1)
for i in range(2, K + 1):
    ans = (C[N - K + 1][i] * C[K - 1][i - 1]) % MOD
    print(ans)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, K = map(int, input().split())
MOD = 10 **9 + 7
ans = 0
for i in range(1, K + 1):
    ans = (cmb(N - K + 1, i) * cmb(K - 1, i - 1)) % MOD
    print(ans)
Problem p03036 (python)

Fixed submission:
import sys
r, D, x2000 = map(int, sys.stdin.readline().split())
x2001 = r * x2000 - D
x2002 = r * x2001 - D
x2003 = r * x2002 - D
x2004 = r * x2003 - D
x2005 = r * x2004 - D
x2006 = r * x2005 - D
x2007 = r * x2006 - D
x2008 = r * x2007 - D
x2009 = r * x2008 - D
x2010 = r * x2009 - D
print(x2001)
print(x2002)
print(x2003)
print(x2004)
print(x2005)
print(x2006)
print(x2007)
print(x2008)
print(x2009)
print(x2010)

Buggy submission (verdict: Runtime Error):
import sys
r, D, x2000 = map(int, sys.stdin.readline().split())
x2001 = r * x2000 - D
x2002 = r * x2001 - D
x2003 = r * x2002 - D
x2004 = r * x2003 - D
x2005 = r * x2004 - D
x2006 = r * x2005 - D
x2007 = r * x2006 - D
x2008 = r * x2007 - D
x2009 = r * x2008 - D
x2010 = r * x2009 - D
print(x2001)
print(x2002)
print(x2003)
print(x2004)
print(x2005)
print(x2006)
print(x2007)
print(x2008)
print(x2009)
print(x20010)
Problem p03038 (python)

Fixed submission:
from collections import deque
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
CB = deque([])
for i in range(M):
    B, C = map(int, input().split())
    CB.append([C, B])
CB = sorted(CB, reverse=True)
flag = False
c = 0
I = 0
for i in CB:
    I += i[1]
    if flag:
        break
    while c < I:
        if c >= N:
            break
        if A[c] < i[0]:
            A[c] = i[0]
            c += 1
        else:
            c = I
            flag = True
print(sum(A))

Buggy submission (verdict: Runtime Error):
from collections import deque
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
CB = deque([])
for i in range(M):
    B, C = map(int, input().split())
    CB.append([C, B])
CB = sorted(CB, reverse=True)
flag = False
c = 0
I = 0
for i in CB:
    I += i[1]
    if flag:
        break
    while c < I:
        if A[c] < i[0]:
            A[c] = i[0]
            c += 1
        else:
            c = I
            flag = True

print(sum(A))

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, sys.stdin.readline().split())
A = sorted(list(map(int, sys.stdin.readline().split())))
BC = [list(map(int,sys.stdin.readline().split())) for i in range(M)]
for i in range(len(BC)):
	BC[i] = BC[i][::-1]
BC = sorted(BC, reverse=True)
c = 0
for j in BC:
    for k in range(c, c + j[1]):
        if A[k] < j[0]:
            A[k] = j[0]
    c = c + j[1]
print(sum(A))
Problem p03775 (python)

Fixed submission:
import numpy as np
 
N = int(input())
ans = len(str(N))
for i in range(2, int(np.sqrt(N)) + 2):
    if not N % i:
        a = max(len(str(i)), len(str(int(N / i))))
        ans = min(ans, a)
print(ans)

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

N = int(input())
ans = len(str(N))
for i in range(2, int(np.sqrt(N)) + 2):
    if not N % i:
        a = max(len(str(i)), len(str(int(N / i))))
        ans = min(ans, a)
print(a)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
ans = 10 ** 10
for i in range(2:int(np.sqrt(N)) + 2):
    if not N % i:
        a = max(len(str(i)), len(str(int(121 / 11))))
        ans = min(ans, a)
print(a)
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, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
    
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > 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()))
A.reverse()
B.reverse()

t = 0
cnt = 0
c1, c2 = A.pop(), B.pop()
while True:
    
    if t >= K or (t + c1 > K and t + c2 > K):
        break


    if (t + c1 <= K and t + c2 <= K):
        l1 = [c1]
        sum_1 = c1
        for a in A[-1]:
            if t + a <= K:
                l1.append(a)
                sum_1 += a
            else:
                break
        l2 = [c2]
        sum_2 = c2
        for b in B[-1]:
            if t + b <= K:
                l2.append(b)
                sum_2 += b
            else:
                break
        
        if sum_1 <= sum_2:
            t += sum_1
            cnt += len(l1)
            for i in range(len(l1)-1):
                A.pop()
            c1 = A.pop() if bool(A) else 100000000000
        else:
            t += sum_2
            cnt += len(l2)
            for i in range(len(l2)-1):
                B.pop()
            c2 = B.pop() if bool(B) else 100000000000

    elif t + c1 <= K:
        
        t += c1
        cnt += 1
        c1 = A.pop() if bool(A) else 100000000000
    else:
        if t + c2 <= K:
            t += c2
            cnt += 1
            c2 = B.pop() if bool(B) else 100000000000

print(cnt)
Problem p02729 (python)

Fixed submission:
import math

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

def comb(n, r):
    if n <= 1:
        return 0
    return perm(n, r)//math.factorial(r)

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

ans = comb(N,2) + comb(M,2)


print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

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

def comb(n, r):
    if n == 1:
        return 0
    return perm(n, r)//math.factorial(r)

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

ans = comb(N,2) + comb(M,2)


print(int(ans))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

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

ans = comb(N,2) + comb(M,2)


print(int(ans))
Problem p02754 (python)

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

ans = (N//(A+B))*A + min((N%(A+B)),A)

print(ans)

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

cnt_a = cnt_b = 0

for i in range(10*100):
    if cnt_a + cnt_b + A >= N: 
        # N - cnt_a - cnt_b はみ出た分
        ans = cnt_a + N - cnt_a - cnt_b

    else:
        cnt_a += A
        cnt_b += B

print(ans)

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

L = []

for i in range(10**100):
    L += A*["b",]
    L += B*["r",]
    if len(L) >= N:
        break

#print(L,L[:N])
cnt = 0
for l in L[:N]:
    if l == "b":
        cnt += 1

print(cnt)

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

L = []

for i in range(10*100):
    L += A*["b",]
    L += B*["r",]
    if len(L) >= N:
        break

#print(L,L[:N])
cnt = 0
for l in L[:N]:
    if l == "b":
        cnt += 1

print(cnt)
Problem p02771 (python)

Fixed submission:
L = map(int,input().split(" "))

if len(set(L)) == 2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split(" "))
A = map(int,input().split(" "))
 
import itertools
 
L = []
 
for x in itertools.combinations(A, 2):
    L.append(x[0]*x[1])
 
L.sort()
 
print(L[K-1])
Problem p03208 (python)

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


H = sorted([int(input()) for i in range(N)],reverse=True)


#print(H)

L = []

for k in range(N-K+1):
    #print(k,k+1,k+2,k+K)
    
    L.append(H[k]-H[k+K-1])

print(min(L))

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


H = sorted([int(input()) for i in range(N)],reverse=True)


#print(H)

L = []

for k in range(N-K+1):
    #print(k,k+1,k+2)
    
    L.append(H[k]-H[k+K])

print(min(L))

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


H = sorted([int(input()) for i in range(N)],reverse=True)


#print(H)

L = []

for k in range(N-K+1):
    #print(k,k+1,k+2)
    
    L.append(H[k]-H[k+2])

print(min(L))
Problem p02729 (python)

Fixed submission:
N,M = map(int,input().split())
from math import factorial

if N<= 1 and M <=1:
    print(0)

elif N >= 2 and M <=1:
    ans = factorial(N) / factorial(2) / factorial(N - 2)
    print(int(ans))
        
elif N <= 1 and M >= 2:
    ans =factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))    

else:
    ans = (factorial(N) / factorial(2) / factorial(N - 2))+factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
from math import factorial

if N<= 1 and M <=1:
    print(0)

elif N >= 2 and M == 1:
    ans = factorial(N) / factorial(2) / factorial(N - 2)
    print(int(ans))
        
elif N == 1 and M >= 2:
    ans =factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))    

else:
    ans = (factorial(N) / factorial(2) / factorial(N - 2))+factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
from math import factorial

if N==1 and M ==1:
    print(0)

elif N >= 2 and M == 1:
    ans = factorial(N) / factorial(2) / factorial(N - 2)
    print(int(ans))
        
elif N == 1 and M >= 2:
    ans =factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))    

else:
    ans = (factorial(N) / factorial(2) / factorial(N - 2))+factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))
Problem p02933 (python)

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

Buggy submission (verdict: Runtime Error):
a = int(ipnut())
s = str(input())
if a >= 3200:
    print(s)
else:
    print('red')
Problem p02693 (python)

Fixed submission:
k = int(input())
a,b = map(int, input().split())
for i in range(a, b+1):
  if i % k == 0:
    print('OK')
    exit()
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('Yes')
  	exit()
print('No')
Problem p02712 (python)

Fixed submission:
n = int(input())
print(sum([i for i in range(1, n+1) if i%5 != 0 and i%3 != 0]))

Buggy submission (verdict: Runtime Error):
n = int(input())
print(sum([i for i in range(1, n+1) if and i%5 != 0 and i%3 != 0]))
Problem p02624 (python)

Fixed submission:
N = int(input())
if N == 1:
    print(1)
elif N == 2:
    print(5)
elif N == 3:
    print(11)
else:
    ans = N*(N+1)-1
    for i in range(2,N//2+1):
        t = N//i
        ans += i*(t*(t+1)//2-1)
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 1:
    print(1)
elif N == 2:
    print(5)
elif N == 3:
    print(11)
else:
    ans = N*(N+1)-1
    for i in range(2,N//2):
        t = N//i
        ans += i*(t*(t+1)//2-1)
        
print(ans)
Problem p02629 (python)

Fixed submission:
N = int(input())

i=1
now=26
before = 0
while True:
    if N <= now:
        break
    i += 1
    before = now
    now += 26**i
    
#print(i)
M = N-before
alphabet = "abcdefghijklmnopqrstuvwxyz"
ans=""
for j in range(i):
    dig = int((M-1)//26**(i-j-1))
    #print(M, dig)
    ans = ans + alphabet[dig]
    M -= dig*26**(i-j-1)
    
print(ans)

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

i=1
now=26
before = 0
while True:
    if N <= now:
        break
    i += 1
    before = now
    now += 26**i
    
#print(i)
M = N-before
alphabet = "abcdefghijklmnopqrstuvwxyz"
ans=""
for j in range(i):
    dig = int(M//26**(i-j-1))
    #print(dig)
    if j==i-1:
        ans = ans + alphabet[dig-1]
    else:
        ans = ans + alphabet[dig]
        M -= dig*26**(i-j-1)
    
print(ans)
Problem p02771 (python)

Fixed submission:
a,b,c = input().split()
if a==b and c != b and c != a:
  print('Yes')
elif b==c and a != b and a != c:
  print('Yes')
elif c==a and b != a and b != c:
  print('Yes')
else: print('No')

Buggy submission (verdict: Runtime Error):
a,b,c = int(input()).split()
if a=b and c != b and c != a:
  print('Yes')
elif b=c and a != b and a != c:
  print('Yes')
elif c=a and b != a and b != c:
  print('Yes')
else: print('No')
Problem p03186 (python)

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

count = 0
if C - B < 0:
    count = C + B
elif C - B >=0:
    if C - B - A <=0:
        count = C + B
    elif C - B - A >0:
        count = A + 2*B  +1
    
print(count)

Buggy submission (verdict: Runtime Error):
A, B, C = (int(n) for n in input().split())

count = 0
if C - B < 0:
  count = C + B
elif C - B =>0:
  if C - B - A =<0:
    count = C + B
  elif C - B - A >0:
    count = A + 2*B + 1
    
print(count)
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, b = [0], [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])

ans, j = 0, m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > 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()))

if sum(a) + sum(b) <= k:
    print(n + m)
    exit()

lena = len(a)
lenb = len(b)

timecnt = 0
cnt = 0
while timecnt <= k:
    inda = len(a) - lena
    indb = len(b) - lenb
    if inda < 0 and indb < 0:
        break
    elif inda < 0 and indb >= 0:
        timecnt += b[indb]
        lenb -= 1
        cnt += 1
    elif inda >= 0 and indb < 0:
        timecnt += a[inda]
        lena -= 1
        cnt += 1
    elif a[inda] <= b[indb]:
        timecnt += a[inda]
        lena -= 1
        cnt += 1
    else:
        timecnt += b[indb]
        lenb -= 1
        cnt += 1

print(cnt - 1)
Problem p02754 (python)

Fixed submission:
n, a, b = map(int, input().split())
ans = n // (a + b) * a
rem = n % (a + b)
ans += min(a, rem)
print(ans)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
retsu = ""
while len(retsu) < n:
    retsu += "b"*a + "r"*b
print(retsu[:n].count("b"))
Problem p02771 (python)

Fixed submission:
a = list(map(int, input().split()))
if a[0] == a[1] and a[1] == a[2]:
  print("No")
elif a[0] != a[1] and a[1] != a[2] and a[0] != a[2]:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
n = list(map(int, input().split()))
if a[0] == a[1] and a[1] == a[2]:
  print("No")
elif a[0] != a[1] and a[1] != a[2] and a[0] != a[2]:
  print("No")
else:
  print("Yes")
Problem p02989 (python)

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
 
if n % 2 == 1:
  print(0)
  exit()

d = sorted(d)
print(d[int(n/2)] - d[int(n/2) - 1])

Buggy submission (verdict: Runtime Error):
import statistics
 
n = int(input())
d = list(map(int, input().split()))
 
if n % 2 == 1:
  print(0)
  exit()

d = sorted(d)
print(d[n/2] - d[(n/2) - 1])

Buggy submission (verdict: Runtime Error):
import statistics

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

if n % 2 == 1:
  print(0)
  exit()
cnt = 0
index = 0
for _, num in enumerate(d):
  item = [j for j in d if j >= num]
  if len(item) == (len(d) / 2):
    cnt = num
    index = _

d = list(set(sorted(d)))
ans = cnt - d[d.index(cnt) - 1]
print(ans)
Problem p03036 (python)

Fixed submission:
r, d, x = map(int, input().split())
for i in range(10):
  x = r*x-d
  print(x)

Buggy submission (verdict: Runtime Error):
r, d, x = map(int, input(),split())
for i in range(10):
  r = r*x-d
  print(r)