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

Fixed submission:
sx, sy, tx, ty = map(int, input().split())

W = abs(sx-tx)
H = abs(sy-ty)
ans = ""

for i in range(W):
    ans += "R"
for i in range(H+1):
    ans += "U"
for i in range(W+1):
    ans += "L"
for i in range(H+1):
    ans += "D"
ans += "R"

for i in range(H):
    ans += "U"
for i in range(W+1):
    ans += "R"
for i in range(H+1):
    ans += "D"
for i in range(W+1):
    ans += "L"
ans += "U"

print(ans)

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

ans = 0
A_test = sorted(list(set(A)))

if N % 2 == 1:
    judge = [i for i in range(0,N,2)]
    if (A_test == judge) and (A.count(0) == 1):
        ans = 2**(N//2)
else:
    judge = [i for i in range(1,N,2)]
    if A_test == judge:
        ans = 2**(N//2)

ans = ans % (10**9 + 7)
print(ans)
Problem p03846 (python)

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

ans = 0
A_test = sorted(list(set(A)))

if N % 2 == 1:
    judge = [i for i in range(0,N,2)]
    if (A_test == judge) and (A.count(0) == 1):
        ans = 2**(N//2)
else:
    judge = [i for i in range(1,N,2)]
    if A_test == judge:
        ans = 2**(N//2)

ans = ans % (10**9 + 7)
print(ans)

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

ans = 0
A_test = sorted(list(set(A)))

if N % 2 == 1:
    judge = [i for i in range(0,N,2)]
    if A_test == judge:
        ans = 2**(N//2)
else:
    judge = [i for i in range(1,N,2)]
    if A_test == judge:
        ans = 2**(N//2)]

ans = ans % (10**9 + 7)
print(ans)

Buggy submission (verdict: Runtime Error):
#Beginner 050 C

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

if L % 2 == 0:
    lst = [2*i+1 for i in range(L//2)]
    if set(lst) == set(A):
        print(2**(L//2))
    else:
        pront(0)
        quit()
else:
    lst = [2*i for i in range(L//2+1)]
    if set(lst) == set(A):
        print(2**(L//2+1))
    else:
        pront(0)
        quit()
Problem p03998 (python)

Fixed submission:
Sa = list(input())
Sb = list(input())
Sc = list(input())

turn = Sa.pop(0)

for i in range(len(Sa)+len(Sb)+len(Sc)):
    if turn == "a":
        if len(Sa) != 0:
            turn = Sa.pop(0)
        else:
            print("A")
            quit()
    elif turn == "b":
        if len(Sb) != 0:
            turn = Sb.pop(0)
        else:
            print("B")
            quit()
    elif turn == "c":
        if len(Sc) != 0:
            turn = Sc.pop(0)
        else:
            print("C")
            quit()

Buggy submission (verdict: Runtime Error):
Sa = str(input())
Sb = str(input())
Sc = str(input())

turn = Sa.pop(0)

while Sa <> [] or Sb <> [] or Sc <> []:
    if turn == "a":
        turn += Sa.pop(0)
    elif turn == "b":
        turn += Sb.pop(0)
    elif turn == "c":
        turn += Sc.pop(0)

if Sa == []:
    print("A")
elif Sb == []:
    print("B")
else:
    print("C")
Problem p04031 (python)

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

R = []

for i in range(min(A), max(A)):
    cost = 0
    for j in range(len(A)):
        cost += (i - A[j])**2
    R.append(cost)

if R == []:
    print(0)
else:
    print(min(R))

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

R = []

for i in range(min(A), max(A)):
    cost = 0
    for j in range(len(A)):
        cost += (i - A[j])**2
    R.append(cost)

print(min(R))
Problem p04032 (python)

Fixed submission:
s = str(input())


if len(s) > 2:
    for i in range(len(s)-2):
        if s[i] == s[i+1] or s[i] == s[i+2]:
            res1 = str(i+1)
            res2 = str(i+3)
            print(res1 + " " + res2)
            quit()
        else:
            continue
else:
    if s[0] == s[1]:
        print("1 2")
        quit()

print("-1 -1")

Buggy submission (verdict: Runtime Error):
s = str(inpout())

for i in range(len(s)):
    if s[i] == s[i+1]:
        res1 = str(i)
        res2 = str(i+1)
        print(res1 + " " + res2)
        break
    elif s[i] == s[i+2]:
        res1 = i
        res2 = i+2
        print(res1 + " " + res2)
        break
    else:
        continue

print("-1 -1")
Problem p04044 (python)

Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]

SS = sorted(S)
ans = ""

for i in range(N):
    ans += SS[i]

print(ans)

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = [input() for i in range(L)]

SS = sorted(S)
ans = ""

for i in range(L):
    ans += SS[i]

print(ans)
Problem p04045 (python)

Fixed submission:
N, K = map(int, input().split())
dislike = list(map(str, input().split()))
num = ["0","1","2","3","4","5","6","7","8","9"]
can_use = set(num) - set(dislike)

while not set(list(str(N))) <= can_use:
    N += 1

print(N)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
num = ["0","1","2","3","4","5","6","7","8","9"]
dis = input().split()
can_use = sorted(list(set(num)-set(dis)))

sN = str(N)
L = len(sN)
ans = ""

for i in range(1,L):
    if sN[i] in can_use:
        ans += sN[i]
    else:
        ans += min(can_use)

if sN[0] in can_use:
    ans += sN[0]
else:
    if can_use[0] == "0":
        ans = can_use[1] + ans
    else:
        ans = can_use[0] + ans

if int(ans) < N:
    if can_use[0] != "0":
        ans = ans + can_use[1]
    else:
        ans = ans + can_use[0]

print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
num = ["0","1","2","3","4","5","6","7","8","9"]
dis = input().split()
can_use = sorted(list(set(num)-set(dis)))

sN = str(N)
L = len(sN)
ans = ""

if sN[0] in can_use:
    ans += sN[0]
else:
    if can_use[0] == "0":
        ans += can_use[1]
    else:
        ans += can_use[0]

for i in range(1,L):
    if sN[i] in can_use:
        ans += sN[i]
    else:
        ans += min(can_use)

if int(ans) < N:
    if can_use[0] != "0":
        ans = ans + can_use[1]
    else:
        ans = ans + can_use[0]

print(ans)
Problem p02641 (python)

Fixed submission:
X,N=map(int,input().split())
P=list(map(int,input().split()))
m=100
ans=0
lis=list(range(101,-1,-1))
for k in lis:
    for l in range(N):
        if k==P[l]:
            lis[101-k]=0
for i in lis:
    if abs(i-X)<=m:
        m=abs(i-X)
        ans=i
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
count=0
for i in range(N):
    for j in range(N):
        if A[i]%A[j]==0:
            count+=1
            if count==2:
                break
    if count==1:
        B[i]=1
    else:
        B[i]=0
    count=0
print(sum(B))
Problem p02683 (python)

Fixed submission:
import numpy as np
import itertools
n,m,x=map(int,input().split())
a=[]
b=[0]*m
skill=np.array([b])
ans=[]
money=0
for _ in range(n):
    a.append(list(map(int,input().split())))
for i in range(1,n+1):
    for j in itertools.combinations(range(1,n+1),i):
        for k in range(len(j)):
            money+=a[j[k]-1][0]
            skill+=np.array([a[j[k]-1][1:m+1]])
        if all([i>=x for i in skill[0]]):
            ans.append(money)
        money=0
        skill=np.array([b])
if len(ans)==0:
    print(-1)
else:
    print(min(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
import itertools
n,m,x=map(int,input().split())
a=[]
b=[0]*m
skill=np.array([b])
ans=[]
money=0
for _ in range(n):
    a.append(list(map(int,input().split())))
for i in range(1,n+1):
    for j in itertools.combinations_with_replacement(range(1,n+1),i):
        for k in range(len(j)):
            money+=a[j[k]-1][0]
            skill+=np.array([a[j[k]-1][1:m+1]])
        if all([i>=x for i in skill[0]]):
            ans.append(money)
        money=0
        skill=np.array([b])
print(min(ans))
Problem p02713 (python)

Fixed submission:
a=int(input())
import math
print(sum(math.gcd(math.gcd(i,j),k)for i in range(1,a+1) for j in range(1,a+1) for k in range(1,a+1)))

Buggy submission (verdict: Runtime Error):
a=int(input())
import math
print(sum(gcd(gcd(i,j),k)for i in range(1,a+1) for j in range(1,a+1) for k in range(1,a+1)))
Problem p02760 (python)

Fixed submission:
a=[]
b=[]
for _ in range(3):
    a.append(list(map(int,input().split())))
N=int(input())
for _ in range(N):
    b.append(int(input()))
for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i]==a[k][j]:
                a[k][j]=0
if (a[0][0]==0 and a[0][1]==0 and a[0][2]==0)or(a[1][0]==0 and a[1][1]==0 and a[1][2]==0) or (a[2][0]==0 and a[2][1]==0 and a[2][2]==0) or (a[0][0]==0 and a[1][0]==0 and a[2][0]==0) or (a[0][1]==0 and a[1][1]==0 and a[2][1]==0) or (a[0][2]==0 and a[1][2]==0 and a[2][2]==0) or (a[0][0]==0 and a[1][1]==0 and a[2][2]==0) or (a[0][2]==0 and a[1][1]==0 and a[2][0]==0):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a=[]
b=[]
for _ in range(3):
    a.append(list(map(int,input().split())))
for _ in range(int(input())):
    b.append(int(input()))
for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i]==a[k][j]:
                a[k][j]=0
if (a[0][0]==0 and a[0][1]==0 and a[0][2]==0)or(a[1][0]==0 and a[1][1]==0 and a[1][2]==0) or (a[2][0]==0 and a[2][1]==0 and a[2][2]==0) or (a[0][0]==0 and a[1][0]==0 and a[2][0]==0) or (a[0][1]==0 and a[1][1]==0 and a[2][1]==0) or (a[0][2]==0 and a[1][2]==0 and a[2][2]==0) or (a[0][0]==0 and a[1][1]==0 and a[2][2]==0) or (a[0][2]==0 and a[1][1]==0 and a[2][0]==0):
    print("Yes")
else:
    print("No")
Problem p02767 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
ans=[]
b=0
if N==1:
    print(0)
else:
    for i in range(min(a),max(a)+1):
        for k in range(N):
            b+=(a[k]-i)**2
        ans.append(b)
        b=0
    print(min(ans))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
ans=[]
b=0
if N==1:
    print(0)
else:
    for i in range(min(a),max(a)):
        for k in range(N):
            b+=(a[k]-i)**2
        ans.append(b)
        b=0
    print(min(ans))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
ans=[]
b=0
for i in range(min(a),max(a)):
    for k in range(N):
        b+=(a[k]-i)**2
    ans.append(b)
    b=0
print(min(ans))
Problem p02802 (python)

Fixed submission:
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[P[j]-1]!=-1 and S[j]=="WA":
        task[P[j]-1]+=1
    elif task[P[j]-1]!=-1 and S[j]=="AC":
        ans+=1
        pen+=task[P[j]-1]
        task[P[j]-1]=-1
print(ans,pen)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[A[M]-1]!=-1 and S[j]=="WA":
        pen+=1
    elif task[A[M]-1]!=-1 and S[j]=="AC":
        ans+=1
        task[A[M]]=-1
        break
print(ans,pen)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[A[M]]!=-1 and S[j]=="WA":
        pen+=1
    elif task[A[M]]!=-1 and S[j]=="AC":
        ans+=1
        task[A[M]]=-1
        break
print(ans,pen)
Problem p02885 (python)

Fixed submission:
A, B = map(int,input().split())
if A>2*B:
    print(A-2*B)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if A>2*B:
    print(A-2*B)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N=int(input())
d = list(map(int, input().split()))
total=0
for n in range(N):
    for j in range(n+1,N):
        total+=d[n]*d[j]
total
Problem p02886 (python)

Fixed submission:
N=int(input())
d = list(map(int, input().split()))
total=0
for n in range(N-1):
    for j in range(n+1,N):
        total+=d[n]*d[j]
print(total)

Buggy submission (verdict: Runtime Error):
N=int(input())
d=[]
total=0
for i in range(N):
    d.append(int(input()))
for n in range(N):
    for j in range(n+1,N):
        total+=d[n]*d[j]
total
Problem p02923 (python)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
count=0
ans=[]
for i in range(1,N):
    if H[i-1]>=H[i]:
        count+=1
        if i==N-1:
            ans.append(count)
    else:
        ans.append(count)
        count=0

if N==1:
    print(0)
else:
    print(max(ans))

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
count=0
ans=[]
for i in range(1,N):
    if H[i-1]>=H[i]:
        count+=1
        if i==N-1:
            ans.append(count)
    else:
        ans.append(count)
        count=0
print(max(ans))
Problem p02983 (python)

Fixed submission:
from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
if R-L>=2018:
    print(0)
else:
    for i in combinations(range(L,R+1),2):
        if ans>=i[0]*i[1]%2019:
            ans=i[0]*i[1]%2019
    print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
for i in combinations(range(L,R+1),2):
    if L!=0 and R!=0:
        if ans>=i[0]*i[1]%2019:
            ans=i[0]*i[1]%2019
    else:
        ans=0
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
for i in combinations(range(L,R+1),2):
    if ans>=i[0]*i[1]%2019:
        ans=i[0]*i[1]%2019
    elif L==0 or R==0:
        ans=0
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
for i in combinations(range(L,R+1),2):
    if ans>=i[0]*i[1]%2019:
        ans=i[0]*i[1]%2019
print(ans)
Problem p03076 (python)

Fixed submission:
A=[int(input()) for i in range(5)]
ans=0
for i in range(5):
    if A[i]%10==0:
        ans+=A[i]
        A[i]=0
B=[str(i) for i in A]
C=[B[i][-1] for i in range(5)]
C=[int(C[i]) for i in range(5)]
D=[None]*5
for i in range(5):
    D[i]=int(B[i])-int(C[i])
E=list([n for n in(sorted(C,reverse=True)) if n>0])
for i in range(len(E)-1):
    ans+=10
try:
    ans=ans+E[-1]+int(sum(D))
except(IndexError):
    ans=ans+int(sum(D))
print(ans)

Buggy submission (verdict: Runtime Error):
A=[int(input()) for i in range(5)]
ans=0
for i in range(5):
    if A[i]%10==0:
        ans+=A[i]
        A[i]=0
B=[str(i) for i in A]
C=[B[i][-1] for i in range(5)]
C=[int(C[i]) for i in range(5)]
D=[None]*5
for i in range(5):
    D[i]=int(B[i])-int(C[i])
try:
    E=list([n for n in(sorted(C,reverse=True)) if n>0])
finally:
    pass
for i in range(len(E)-1):
    ans+=10
ans=ans+E[-1]+int(sum(D))
print(ans)

Buggy submission (verdict: Runtime Error):
A=[int(input()) for i in range(5)]
ans=0
for i in range(5):
    if A[i]%10==0:
        ans+=A[i]
        A[i]=0
B=[str(i) for i in A]
C=[B[i][-1] for i in range(5)]
C=[int(C[i]) for i in range(5)]
D=[None]*5
for i in range(5):
    D[i]=int(B[i])-int(C[i])
E=list([n for n in(sorted(C,reverse=True)) if n>0])
for i in range(len(E)-1):
    ans+=10
ans=ans+E[-1]+int(sum(D))
print(ans)

Buggy submission (verdict: Runtime Error):
A=[int(input()) for i in range(5)]
ans=0
for i in range(5):
    if A[i]%10==0:
        ans+=A[i]
        A[i]=0
B=[str(i) for i in A]
C=[B[i][-1] for i in range(5)]
C=[int(C[i]) for i in range(5)]
D=[None]*5
for i in range(5):
    D[i]=int(B[i])-int(C[i])
E=list([n for n in(sorted(C,reverse=True)) if n>0])
for i in range(len(E)-1):
    ans+=10
ans=ans+E[-1]+int(sum(D))
print(ans)
Problem p03238 (python)

Fixed submission:
N=int(input())
if N==1:
    print("Hello World")
else:
    A=int(input())
    B=int(input())
    print(A+B)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N==1:
    print("Hello World")
else:
    A,B=tuple(map(int,input().split()))
    print(A+B)
Problem p02639 (python)

Fixed submission:
x = list(map(int,input().split()))
print(x.index(0)+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
count = N
for i in range(N):
	for j in range(N):
		if a[i]%a[j] ==0 and i!= j:
			count = count -1
			break
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
count = 0
flag = 0
for i in range(N):
	for j in range(N):
		if a[i]%a[j] ==0 and i!= j:
			flag = 1
			break
	if(flag == 0):
		count = count +1
	flag = 0
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
count = 0
flag = 0
for i in range(N):
	for j in range(N):
		if a[i]%a[j] ==0 and i!= j:
			flag = 1
	if(flag == 0):
		count = count +1
	flag = 0
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
count = 0
flag = 0
for i in range(N):
	for j in range(N):
		if a[i]%a[j] ==0 and i!= j:
			flag = 1
	if(flag == 0):
		count = count +1
	flag = 0
print(count)
Problem p02641 (python)

Fixed submission:
x,n = map(int,input().split())
if n == 0:
	print(x)
else:
	p = list(map(int,input().split()))
	t = abs(min(p)-x)+1
	u = min(p)-1
	for i in range(min(x-1,min(p)-1),max(x+1,max(p)+2)):
		if not( i in p ):
			if abs(i-x)<t:
				t = abs(i-x)
				u = i
			elif  abs(i-x)==t:
				if i < u:
					u = i
	print(u)

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
p = list(map(int,input().split()))
t = abs(min(p)-x)+1
u = min(p)-1
for i in range(min(x-1,min(p)-1),max(x+1,max(p)+2)):
	if not( i in p ):
		if abs(i-x)<t:
			t = abs(i-x)
			u = i
		elif  abs(i-x)==t:
			if i < u:
				u = i
print(u)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
import sys
N,Q = map(int,input().split())
graph = [[] for _ in range(N)]
#グラフをリストで表現
for _ in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)#リストの番号で頂点を表示するため-1
    graph[b-1].append(a-1)
point = [0]*N
for _ in range(Q):
    a,b = map(int,input().split())
    point[a-1] += b#根にあたる部分にだけコストをプラス


#再帰定義
def dfs(now, prev = -1):#prev,now,nextの三段階を扱う
    for next in graph[now]:#今見ている頂点に連結されているものを見る
        if next == prev:#親だったら飛ばす
            continue
        point[next] += point[now]#子の得点をプラス
        dfs(next,now)#nextが親だけになると自分を呼ぶ前に飛ばされて終わる

dfs(0)#根頂点を指定してスタート
print(*point)

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
graph = [[] for _ in range(N)]
#グラフをリストで表現
for _ in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)#リストの番号で頂点を表示するため-1
    graph[b-1].append(a-1)
point = [0]*N
for _ in range(Q):
    a,b = map(int,input().split())
    point[a-1] += b#根にあたる部分にだけコストをプラス


#再帰定義
def dfs(now, prev = -1):#prev,now,nextの三段階を扱う
    for next in graph[now]:#今見ている頂点に連結されているものを見る
        if next == prev:#親だったら飛ばす
            continue
        point[next] += point[now]#子の得点をプラス
        dfs(next,now)#nextが親だけになると自分を呼ぶ前に飛ばされて終わる

dfs(0)#根頂点を指定してスタート
print(*point)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
p = [int(i) for i in input().split()]
if n == 0:
    print(x)
else:
    under = over = x
    for num in range(x - min(p) + 2):
        if not (x - num in p):
            under = x - num
            break
    for num in range(max(p) - x + 2):
        if not (x + num in p):
            over = x + num
            break
    if x - under <= over - x:
        print(under)
    else:
        print(over)

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

x, n = map(int, input().split())
p = list(map(int, input().split()))
for d in range(x+1): #0に達した時点で0を出力して終了するので、大きい側は気にしなくてよい
    for d in [-1, 1]:
        a = x + i*s
        if not a in p:
            print(a)
            exit()
Problem p02675 (python)

Fixed submission:
n = int(input())%10
if n in [2, 4, 5, 7, 9]:
    print('hon')
elif n in [0, 1, 6, 8]:
    print('pon')
else:
    print('bon')

Buggy submission (verdict: Runtime Error):
from math import cos, radians, sqrt

a, b, h, m = map(int, input().split())
angle = radians(h*30 + m / 2- m*6)
print(sqrt(a**2 + b**2 - 2*a*b*cos(angle)))
Problem p02761 (python)

Fixed submission:
from sys import exit
N, M = map(int, input().split())
line = []
for i in range(M):
  line.append([int(i) for i in input().split()])
for i in range(10 ** N):
  i_keta = [i // 100, (i % 100) // 10, i % 10]
  correct = True
  for test in line:
    s = test[0]
    c = test[1]
    if s == 1:
      if N >= 2:
        if i_keta[3 - N] == 0 or i_keta[3 - N] != c:
          correct = False
          break
      elif i_keta[2] != c:
        correct = False
        break
    else:
      if i_keta[s - N + 2] != c:
        correct = False
        break
  if correct:
    if N >= 2 and i_keta[3 - N] != 0:
      print(i)
      exit()
    elif N == 1:
      print(i)
      exit()
print(-1)

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
line = []
for i in range(M):
  line.append([int(i) for i in input().split()])
for i in range(10 ** N):
  i_keta = [i // 100, (i % 100) // 10, i % 10]
  correct = True
  for test in line:
    s = test[0]
    c = test[1]
    if s == 1:
      if N >= 2:
        if i_keta[3 - N] == 0 or i_keta[3 - N] != c:
          correct = False
          break
      elif i_keta[2] != c:
        correct = False
        break
    else:
      if i_keta[s - N + 2] != c:
        correct = False
        break
  if correct:
    if N >= 2 and i_keta[3 - N] != 0:
      print(i)
      sys.exit(1)
    elif N == 1:
      print(i)
      sys.exit(1)
print(-1)
Problem p02996 (python)

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

n = int(input())
task = []
time_total = [-1 for i in range(n)]
for i in range(n):
    task.append([int(i) for i in input().split()])
task_sorted = sorted(task, key = lambda x:x[1])
time_total[0] = task_sorted[0][0]
for i in range(n - 1):
    time_total[i + 1] = time_total[i] + task_sorted[i + 1][0]
for i in range(n):
    if time_total[i] > task_sorted[i][1]:
        print("No")
        sys.exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
from sys import exit
input = sys.stdin.readline

n = int(input())
task = []
time_total = [-1 for i in range(n)]
for i in range(n):
    task.append([int(i) for i in input().split()])
task_sorted = sorted(task, key = lambda x:x[1])
time_total[0] = task_sorted[0][0]
for i in range(n - 1):
    time_total[i + 1] = time_total[i] + task_sorted[i + 1][0]
for i in range(n):
    if time_total[i] > task_sorted[i][1]:
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
from sys import
input = sys.stdin.readline

n = int(input())
task = []
time_total = [-1 for i in range(n)]
for i in range(n):
    task.append([int(i) for i in input().split()])
task_sorted = sorted(task, key = lambda x:x[1])
time_total[0] = task_sorted[0][0]
for i in range(n - 1):
    time_total[i + 1] = time_total[i] + task_sorted[i + 1][0]
for i in range(n):
    if time_total[i] > task_sorted[i][1]:
        print("No")
        exit()
print("Yes")
Problem p02630 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
C = [0] * 100001
s = 0
for i in A:
    C[i] += 1
    s += i

K = int(input())

for i in range(K):
    f, t = map(int, input().split())
    C[t] += C[f]
    s += t * C[f]
    s -= f * C[f]
    C[f] = 0
    print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
C = [0] * 10001
s = 0
for i in A:
    C[i] += 1
    s += i

K = int(input())

for i in range(K):
    f, t = map(int, input().split())
    if f == t:
        continue
    C[t] += C[f]
    s += t * C[f]
    s -= f * C[f]
    C[f] = 0
    print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
C = [0] * 10001
s = 0
for i in A:
    C[i] += 1
    s += i

K = int(input())

for i in range(K):
    f, t = map(int, input().split())
    C[t] += C[f]
    s += t * C[f]
    s -= f * C[f]
    C[f] = 0
    print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
A =[0] * 10001
s = 0
for i in map(int, input().split()):
    A[i] += 1
    s += i

K = int(input())

for i in range(K):
    f, t = map(int, input().split())
    A[t] += A[f]
    s += t * A[f]
    s -= f * A[f]
    A[f] = 0
    print(s)