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

Fixed submission:
#個数が無制限のナップザックの問題(ただし、上限に注意)です(どの魔法を順番に選べば良いなどの制約がないのでナップザックDPを選択しました。)。
#dpの配列にはi番目の要素にモンスターの体力をi減らすために必要な最小の魔力を保存します。
#この配列は個数制限がないことに注意してinfではない要素のみを順に更新していけば良いです。
#また、最終的にモンスターの体力を最小の魔力で0以下にすれば良いので、モンスターの体力をh以上減らせる最小の魔力を求めれば良いです。

h,n=map(int,input().split())
a,b=[],[]
for i in range(n):
    a_sub,b_sub=map(int,input().split())
    a.append(a_sub)
    b.append(b_sub)
inf=10000000000000
ma=max(a)#ダメージの最大値

dp=[inf]*(h+1+ma)#与えるダメージの最大値を考慮したDP
dp[0]=0#初期値

for i in range(h+1+ma):# 与えるダメージ合計：0ーH+1+maまで
    if dp[i] == inf:#更新してきて、ダメージiになる組み合わせが存在しない場合は飛ばす
        continue
    for j in range(n):    #N個の魔法を試す
        ni = i + a[j] #今の状態から新しく与えた場合のダメージ合計
        if ni<h+ma:#オーバーキルの範囲を超えるなら、無視
            dp[ni] = min(dp[ni], dp[i] + b[j])        #ダメージniを与えるのにより小さい魔力で実現できる場合は更新
print(min(dp[h:]))

Buggy submission (verdict: Runtime Error):
#個数が無制限のナップザックの問題(ただし、上限に注意)です(どの魔法を順番に選べば良いなどの制約がないのでナップザックDPを選択しました。)。
#dpの配列にはi番目の要素にモンスターの体力をi減らすために必要な最小の魔力を保存します。
#この配列は個数制限がないことに注意してinfではない要素のみを順に更新していけば良いです。
#また、最終的にモンスターの体力を最小の魔力で0以下にすれば良いので、モンスターの体力をh以上減らせる最小の魔力を求めれば良いです。

h,n=map(int,input().split())
a,b=[],[]
for i in range(n):
    a_sub,b_sub=map(int,input().split())
    a.append(a_sub)
    b.append(b_sub)
inf=10000000000000
ma=max(a)#ダメージの最大値

dp=[inf]*(h+ma)#与えるダメージの最大値を考慮したDP
dp[0]=0#初期値

for i in range(h+1+ma):# 与えるダメージ合計：0ーH+1+maまで
    if dp[i] == inf:#更新してきて、ダメージiになる組み合わせが存在しない場合は飛ばす
        continue
    for j in range(n):    #N個の魔法を試す
        ni = i + a[j] #今の状態から新しく与えた場合のダメージ合計
        if ni<h+ma:#オーバーキルの範囲を超えるなら、無視
            dp[ni] = min(dp[ni], dp[i] + b[j])        #ダメージniを与えるのにより小さい魔力で実現できる場合は更新
print(min(dp[h:]))
Problem p02911 (python)

Fixed submission:
N,K,Q=map(int,input().split())
A=[int(input()) for i in range(Q)]
A_point=[0]*N

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

for aa in A_point:
  if K-(Q-aa)<=0:
    print("No")
  else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N,K,Q=map(int,input().split())
A=[int(input()) for i in range(Q)]
A_point=[K]*N
#全体の試合数Q-
for a in A:
  A_point[a]-=1
for aa in A_point:
  if aa<=0:
    print("NO")
  else:
    print("Yes")
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(500*500)
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[] for _ in range(N+1)]
 
for edge in edges:
  A[edge[0]].append([edge[1],edge[2]])
  A[edge[1]].append([edge[0],edge[2]])
  
depth = [-1] * (N+1)
depth[1] = 0
 
def dfs(A,s):
  for v in A[s]:
    if depth[v[0]] == -1:
      depth[v[0]] = depth[s] + v[1]
      dfs(A,v[0])    
dfs(A,1)
for d in depth[1:]:
  if d % 2 == 0:
    print(0)
  else:
    print(1)

Buggy submission (verdict: Runtime Error):
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[] for _ in range(N)]

for edge in edges:#edge0=u,edge1=v,edge2=w
  u=edge[0]
  v=edge[1]
  w=edge[2]
  A[u-1].append([v-1,w])
  A[v-1].append([u-1,w])
#A[i-1]に頂点iと隣接する頂点とその距離を格納

#depth[i-1]=頂点１から頂点iへの距離
#頂点1への距離は0
depth = [-1] * (N)
depth[0] = 0
#depth[i] = 1から頂点dまでの距離(=depth[d]) + 頂点dからiの距離(=X[1]))で更新可能

def dfs(A,d):
    for X in A[d]:#X[0]:頂点X　X[1]:頂点dから頂点Xの距離
        if depth[X[0]] == -1:#距離が-1ならまだ行っていない
            depth[X[0]] = depth[d] + X[1]
            dfs(A,X[0])#次の隣の頂点へ

dfs(A,0)#頂点0からスタート
for d in depth:
    if d % 2 == 0:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[] for _ in range(N)]

for edge in edges:#edge0=u,edge1=v,edge2=w
  u=edge[0]
  v=edge[1]
  w=edge[2]
  A[u-1].append([v-1,w])
  A[v-1].append([u-1,w])
#A[i-1]に頂点iと隣接する頂点とその距離を格納

#depth[i-1]=頂点１から頂点iへの距離
#頂点1への距離は0
depth = [-1] * (N)
depth[1] = 0
#depth[i] = 1から頂点dまでの距離(=depth[d]) + 頂点dからiの距離(=X[1]))で更新可能

def dfs(A,d):
    for X in A[d]:#X[0]:頂点X　X[1]:頂点dから頂点Xの距離
        if depth[X[0]] == -1:#距離が-1ならまだ行っていない
            depth[X[0]] = depth[d] + X[1]
            dfs(A,X[0])#次の隣の頂点へ

dfs(A,0)#頂点0からスタート
for d in depth:
    if d % 2 == 0:
        print(0)
    else:
        print(1)
Problem p03160 (python)

Fixed submission:
N=int(input())
h=list(map(int, input().split()))
dp=[0]*N
for i in range(N):
  if i==0:
    dp[i]=0
  elif i==1:
    dp[i]=abs(h[i]-h[i-1])
  else:
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える

for i in range(N):
    for j in range(W+1):#重さ0からWまでチェック
        if j-w[i]>=0:#入れてもOKな場合,容量と価値を足す
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])
        else:#何も入れずに先に進む
            dp[i+1][j]=dp[i][j]
print(max(set(dp[N])))
Problem p03163 (python)

Fixed submission:
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える

for i in range(N):
    for j in range(W+1):#重さ0からWまでチェック
        if j-w[i]>=0:#入れてもOKな場合,容量と価値を足す
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])
        else:#何も入れずに先に進む
            dp[i+1][j]=dp[i][j]
print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える

for i in range(N):
    for j in range(W+1):#重さ0からWまでチェック
        if j-w[i]>=0:#入れてもOKな場合,容量と価値を足す
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])
        else:#何も入れずに先に進む
            dp[i+1][j]=dp[i][j]
print(max(set(dp)))

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える

for i in range(N):
    for j in range(W+1):#重さ0からWまでチェック
        if j-w[i]>=0:#入れてもOKな場合,容量と価値を足す
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])
        else:#何も入れずに先に進む
            dp[i+1][j]=dp[i][j]
print(max(set(dp))
Problem p03545 (python)

Fixed submission:
#1+2+2+2=7
K=input()
keta=len(K)
#print(K,keta)

for i in range(1<<(keta-1)):#探索数
  ANS=K[0]
  for j in range(keta-1):#調査桁数
    if (i>>j) &1 == 1:#bitがある、つまりプラスが入る場合
      ANS+="+"
    else:
      ANS+="-"
    ANS+=K[j+1]
#  print(ANS)
  if eval(ANS)==7:
    print(ANS+"=7")
    break

Buggy submission (verdict: Runtime Error):
#1+2+2+2=7
K=input()
keta=len(K)
#print(K,keta)

for i in range(1<<(keta-1)):#探索数
  ANS=K[0]
  for j in range(keta-1):#調査桁数
    if (i>>j) &1 == 1:#bitがある、つまりプラスが入る場合
      ANS+="+"
    ANS+=K[j+1]
#  print(ANS)
  if eval(ANS)==7:
    print(ANS+"=7")
    break
Problem p02600 (python)

Fixed submission:
X=int(input())
if X<=599:
    print(8)
elif X<=799:
    print(7)
elif X<=999:
    print(6)
elif X<=1199:
    print(5)
elif X<=1399:
    print(4)
elif X<=1599:
    print(3)
elif X<=1799:
    print(2)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
N=int(input())
souba=list(map(int,input().split()))
urikaiba=list()
money=1000
num=0
for i in range(1,N-1):
    if (souba[i]-souba[i-1])*(souba[i+1]-souba[i])<=0 and ((souba[i]-souba[i-1])!=0 or (souba[i+1]-souba[i])!=0) and (souba[i]-souba[i-1])!=0:
        urikaiba.append(souba[i])
urikaiba.insert(0,souba[0])
urikaiba.append(souba[N-1])
for i in range(len(urikaiba)-1):
    if urikaiba[i+1]-urikaiba[i]>0:
        num=money//urikaiba[i]
        money=money-num*urikaiba[i]
    elif urikaiba[i+1]-urikaiba[i]<0:
        money=money+num*souba[i]
        num=0
if num==0:
    print(money)
else:
    print(money+num*souba[N-1])
Problem p02606 (python)

Fixed submission:
a = list(map(int,input().split()))
answer=int(a[1]/a[2])-int(a[0]/a[2])
if a[0]%a[2]==0:
    answer=answer+1
print(answer)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
for i in range(1,n+1):
    nn=int(math.sqrt(i))
    min=int((nn+1)/math.sqrt(3))
    min1=int((nn+1)/math.sqrt(2))
    count=0
    for x in range(1,min+1):
        for y in range(x,min1+1):
            for z in range(y,nn+1):
                #print(x*x+y*y+z*z+x*y+y*z+z*x)
                if (x*x+y*y+z*z+x*y+y*z+z*x)==i:
                    if x==y and y==z and z==x:
                        count=count+1
                    elif x!=y and y!=z and z!=x:
                        count=count+6
                    else:
                        count=count+3
    print(count)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
for i in range(1,n+1):
    nn=int(math.sqrt(i))
    min=int((nn+1)/3)
    min1=int((nn+1)/2)
    count=0
    for x in range(1,min+1):
        for y in range(x,min1+1):
            for z in range(y,nn+1):
                #print(x*x+y*y+z*z+x*y+y*z+z*x)
                if (x*x+y*y+z*z+x*y+y*z+z*x)==i:
                    if x==y and y==z and z==x:
                        count=count+1
                    elif x!=y and y!=z and z!=x:
                        count=count+6
                    else:
                        count=count+3
    print(count)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
for i in range(1,n+1):
    nn=int(math.sqrt(i))
    min=int((nn+1)/3)
    min1=int((nn+1)/2)
    count=0
    for x in range(1,min+1):
        for y in range(x,min1+1):
            for z in range(y,nn+1):
                #print(x*x+y*y+z*z+x*y+y*z+z*x)
                if (x*x+y*y+z*z+x*y+y*z+z*x)==i:
                    if x==y and y==z and z==y:
                        count=count+1
                    elif x!=y and y!=z and z!=y:
                        count=count+6
                    else:
                        count=count+3
    print(count)
Problem p02628 (python)

Fixed submission:
nn,kk=map(int,input().split())
num_value = list(map(int, input().split())) 
num_value.sort()
gokei=0
for i in range(kk):
   gokei=gokei+num_value[i]
print(gokei)

Buggy submission (verdict: Runtime Error):
nn,kk=map(int,input.split())
num_value = list(map(int, input().split())) 
num_value.sort()
gokei=0
for i in range(kk):
   gokei=gokei+num_value[i]
print(gokei)

Buggy submission (verdict: Runtime Error):
nn=int(input())
kk=int(input())
num_value = list(map(int, input().split())) 
num_value.sort()
gokei=0
for i in range(kk):
   gokei=gokei+num_value[i]
print(gokei)

Buggy submission (verdict: Runtime Error):
nn=int(input())
kk=int(input())
num_value = list(map(int, input().split())) 
num_value.sort()
goukei=0
for i in range(kk):
   goukei=gokei+num_value[i]
print(goukei)

Buggy submission (verdict: Runtime Error):
nn=int(input())
kk=int(input())
num_value = list(map(int, input().split())) 
num_value.sort()
goukei=0
for i in range(kk):
    for k in range(nn-i):
        if num_value[i]>num_value[k]:
            num_value[i],num_value[k]=num_value[k],num_value[i]
goukei=goukei+num_value[i]
print(goukei)

Buggy submission (verdict: Runtime Error):
nn=int(input())
kk=int(input())
num_value = list(map(int, input().split())) 
num_value.sort()
goukei=0
for i in range(kk):
    goukei=goukei+num_value[kk]
print(goukei)

Buggy submission (verdict: Runtime Error):
nn=int(input())
kk=int(input())
num_value = list(map(int, input().split())) 
num_value.sort()
goukei=0
for i in range(kk):
    goukei=goukei+num_value[kk]
print(goukei)
Problem p02603 (python)

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

kabu=0
money=1000
x=x-1
lastday=0
for i in range(len(A)):
    if A[x-i]>A[x-i-1]:
        lastday=x-i
        break
    
for i in range(lastday):
    if A[i]<A[i+1]:
        buy=money//A[i]
        money-=A[i]*buy
        kabu+=buy
    elif A[i]>A[i+1]:
        money+=A[i]*kabu
        kabu=0

money+=A[lastday]*kabu
print(money)

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

kabu=0
money=1000
x=x-1
for i in range(len(A)):
    if A[x-i]>A[x-i-1]:
        lastday=x-i
        break
    
for i in range(lastday):
    if A[i]<A[i+1]:#翌日の方が高い⇒購入
        buy=money//A[i]
        money-=A[i]*buy
        kabu+=buy
    elif A[i]>A[i+1]:#前日の方が低い⇒売却
        money+=A[i]*kabu
        kabu=0

money+=A[lastday]*kabu
print(money)
Problem p02823 (python)

Fixed submission:
def main3():
    N, A, B = map(int, input().split())
    
    d = B - A
    if d % 2 == 0:
        print(d // 2)
    else:
        print(min(((d + 1) // 2 + N - B ), ((d + 1) // 2 + A - 1)))
         
if __name__ == "__main__":
    main3()

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

    d = B - A - 1
    if d % 2 ==  0:
        print(min(B - 1, N - A))
    else:
        print((d + 1)//2)

if __name__ == "__main__":
    main()
Problem p02842 (python)

Fixed submission:
def main():
    n = int(input())

    x = int(n/1.08)
    if int(x * 1.08) == n:
        print(x)
    elif int((x + 1) * 1.08) == n:
        print(x + 1)
    elif int((x - 1) * 1.08) == n:
        print(x - 1)
    else:
        print(":(")

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main2():
    n = int(input())
    x = int(math.ceil(n / 1.08))
    
    if int(x*1.08) == n:
        print(x)
    else:
        print(":(")

if __name__ == "__main__":
    main2()

Buggy submission (verdict: Runtime Error):
def main2():
    n = int(input())
    x = int(math.ceil(n / 1.08))
    
    if x == n:
        print(x)
    else:
        print(":(")

if __name__ == "__main__":
    main2()
Problem p03001 (python)

Fixed submission:
def main():
    W, H, x, y = map(int, input().split())
    pat = 0

    if x == W/2 and y == H/2:
        pat = 1

    print((W*H)/2.0, pat)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    W, H, x, y = map(int, input().split())

    if x == W/2 and y == H/2:
        pat = 1

    print(W*H/2.0, pat)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    W, H, x, y = map(int, input().split())

    area = 0
    pat = 0

    if (x == 0 and y == 0) or (x == 0 and y == H) or (x == W and Y == 0) or (x == W and y == H):
        area = W*H/2.0
        
    else:
        area_H = 0
        area_V = 0

        area_H = min(H - y, y) * W
        area_V = min(x, W - x) * H

        if area_H == area_V:
            pat = 1

        area = max(area_H, area_V)
        
    print(area, pat)

if __name__ == "__main__":
    main()
Problem p03076 (python)

Fixed submission:
def main():
    menu = [ input() for a in range(5)]
    time = 0
    for i in range(len(menu)):
        if int(menu[i]) % 10 == 0:
            time += int(menu[i])
            menu[i] = "0"
    if len(menu) > 0:
        for i in range(menu.count("0")):
            menu.remove("0")
    if len(menu) > 0:
        menu.sort(key = (lambda x: 10 - int(x[-1])))

        for i in range(len(menu) - 1):
            time += int(menu[i]) + 10 - int(menu[i][-1])
        time += int(menu[-1])
    print(time)
main()

Buggy submission (verdict: Runtime Error):
def main():
    menu = [ input() for a in range(5)]
    time = 0
    for i in range(len(menu)):
        if int(menu[i]) % 10 == 0:
            time += int(menu[i])
            menu[i] = "0"
    if len(menu) > 0:
        for i in range(menu.count("0")):
            menu.remove("0")

        menu.sort(key = (lambda x: 10 - int(x[-1])))

        for i in range(len(menu) - 1):
            time += int(menu[i]) + 10 - int(menu[i][-1])
        time += int(menu[-1])
    print(time)
main()
Problem p03126 (python)

Fixed submission:
def main():
    N, M = map(int, input().split())
    answer = [[0]*M for n in range(N)]
    for i in range(N):
        K, *A = map(int, input().split())
        for a in A:
            answer[i][a-1] = 1
    count = 0
    for j in range(M):
        same = 0
        for i in range(N):
            same += answer[i][j]
        if same == N:
            count += 1
    print(count)
main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    answer = [[0]*M for n in range(N)]
    for i in range(N):
        K, *A = map(int, input().split())
        for a in A:
            answer[i][a] = 1
    count = 0
    for j in range(M):
        same = 0
        for i in range(N):
            same += answer[i][j]
        if same == N:
            count += 1
    print(count)
main()
Problem p03196 (python)

Fixed submission:
import math
def prime_factorize(P):
    prime = list()
    for i in range(2, int(math.sqrt(P)) + 1):
        if P % i == 0:
            c = 0
            while P % i == 0:
                P //= i
                c += 1
            
            prime.append([i, c])
        else:
            continue

    if P != 1:
        prime.append([P, 1])

    return prime

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

    prime = prime_factorize(P)
    ans = 1
    for p in prime:
        n, c = p
        if c >= N:
            ans *= (n ** (c // N))

    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def prime_factorize(P):
    prime = list()
    for i in range(2, P + 1):
        if i**2 <= P:
            if P % i == 0:
                c = 0
                while P % i == 0:
                    P //= i
                    c += 1
                prime.append([i, c])
            else:
                continue
        else:
            break
 
    if P != 1:
        prime.append([P, 1])
 
    return prime
 
def main2():
    N, P = map(int, input().split())
 
    prime = prime_factorize(P)
 
    print(prime)
    ans = 1
    for p in prime:
        n, c = p
        ans *= (n ** (c // N)) 
 
    print(ans)
 
if __name__ == "__main__":
    main2()
def prime_factorize(P):
    prime = list()
    for i in range(2, P + 1):
        if i**2 <= P:
            if P % i == 0:
                c = 0
                while P % i == 0:
                    P //= i
                    c += 1
                prime.append([i, c])
            else:
                continue
        else:
            break

    if P != 1:
        prime.append([P, 1])

    return prime

def main2():
    N, P = map(int, input().split())

    prime = prime_factorize(P)
    ans = 1
    for p in prime:
        n, c = p
        ans *= (n ** (c // N)) 

    print(ans)

if __name__ == "__main__":
    main2()
Problem p03231 (python)

Fixed submission:
import math
def main4():
    N, M = map(int, input().split())
    S = input()
    T = input()

    L = (N * M) // math.gcd(N, M)

    pair = dict()

    for i in range(1, N + 1):
        idx = (i - 1) * (L // N) + 1
        pair[idx] = S[i - 1]

    for i in range(1, M + 1):
        idx = (i - 1) * (L // M) + 1

        if idx in pair.keys():
            if pair[idx] != T[i - 1]:
                print(-1)
                exit()

    print(L)

if __name__ == "__main__":
    main4()

Buggy submission (verdict: Runtime Error):
import math
def main5():
    N, M = map(int, input().split())
    S = input()
    T = input()

    G = math.gcd(N, M)
    L = (N * M) // G

    for i in range(G):
        if S[i * N // G] != T[i * M // G]:
            print(-1)
            exit()

    print(L)

if __name__ == "__main__":
    main4()
Problem p03486 (python)

Fixed submission:
def main():
    s = list(input())
    t = list(input())
    s = sorted(s)
    t = sorted(t)
    t = t[::-1]
    
    if "".join(s) < "".join(t):
        print("Yes")
    else:
        print("No")
main()

Buggy submission (verdict: Runtime Error):
def main():
    s = list(input())
    t = list(input())
    s = sorted(s)
    t = sorted(t)
    ind = 0
    for i in range(len(s)):
        if s[i] == t[i]:
            ind = i
    shrt = False
    for i in range(ind, len(t)):
        if s[0] < t[i]:
            shrt = True
            break
    if shrt :
        print("Yes")
    else:
        print("No")
main()
Problem p03607 (python)

Fixed submission:
def main():
    N = int(input())
    A = [int(input()) for a in range(N)]
    S = set()

    for i in range(N):
        if A[i] in S:
            S.remove(A[i])
        else:
            S.add(A[i])
    print(len(S))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = [int(input()) for a in range(N)]
    L = [0 for i in range(10**4)]

    for i in range(N):
        if L[A[i]-1] == 0:
            L[A[i]-1] = 1
        elif L[A[i]-1] == 1:
            L[A[i]-1] = 0

    print(sum(L))
if __name__ == "__main__":
    main()
Problem p03838 (python)

Fixed submission:
def main():
    x, y = map(int, input().split())

    if x == y:
        print(0)

    elif abs(x) == abs(y):
        print(1)

    elif x < y:
        if x >= 0 and y >= 0:
            print(y - x)

        elif x >= 0 and y <= 0:
            pass

        elif x <= 0 and y >= 0:
            if y == 0:
                print(abs(x))
            else:
                if abs(y) > abs(x):
                    print(abs(y) - abs(x) + 1)
                else:
                    print(abs(x) - abs(y) + 1)

        elif x <= 0 and y <= 0:
            print(abs(x) - abs(y))

    elif x > y:
        if x <= 0 and y <= 0:
            c1 = abs(y) - x + 1
            c2 = abs(y) - abs(x) + 2
            print(min(c1, c2))

        elif x <= 0 and y >= 0:
            pass

        elif x >= 0 and y <= 0:
            print(max(abs(x), abs(y)) - min(abs(x), abs(y)) + 1)
            
        elif x >= 0 and y >= 0:
            print(x - y + 2)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main2():
    x, y = map(int, input().split())

    delta = abs(abs(x) - abs(y))

    c1 = delta + 0 + 0
    c2 = delta + 0 + 1
    c3 = delta + 1 + 0
    c4 = delta + 1 + 1

    print(min(c1, c2, c3, c4))

if __name__ == "__main__":
    main()
Problem p02741 (python)

Fixed submission:
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(A[k-1])

Buggy submission (verdict: Runtime Error):
j = int(input())
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[k-1])
Problem p03280 (python)

Fixed submission:
A, B = [ int(i) for i in input().split()]
print(A*B - A - B + 1)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
for i in S:
    if i != '1':
        print(i)
        break
    K -= 1
    if K == 0:
        print(1)
        break
Problem p03605 (python)

Fixed submission:
N = input()
if '9' in N:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
from itertools import permutations
N, M, R = [int(i) for i in input().split()]
r = [int(i) - 1 for i in input().split()]
V = N
# Define infinity as the large enough value. This value will be
# used for vertices not connected to each other
INF  = 10000000
 
graph = [[INF for i in range(N)] for j in range(N)]
 
for m in range(M):
    A, B, C  = [int(i) for i in input().split()]
    A = A - 1
    B = B - 1
    graph[A][B] = C
    graph[B][A] = C
 
# Solves all pair shortest path via Floyd Warshall Algrorithm
def floydWarshall(graph):
    dist = graph
    for k in range(V):
 
        # pick all vertices as source one by one
        for i in range(V):
 
            # Pick all vertices as destination for the
            # above picked source
            for j in range(V):
 
                # If vertex k is on the shortest path from 
                # i to j, then update the value of dist[i][j]
                dist[i][j] = min(dist[i][j] ,
                                  dist[i][k]+ dist[k][j]
                                )
    return(dist)
 
new_graph = floydWarshall(graph)
smallest_dist = INF
for sub_permute in permutations(r):
    tmp = 0
    for i in range(R-1):
        tmp += new_graph[sub_permute[i]][sub_permute[i+1]]
    smallest_dist = min(smallest_dist, tmp)
print(smallest_dist)