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

Fixed submission:
# ABC138D

import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000000)

def dfs(adj,v,p,px,x,ct):
    x+=px[v]
    for nv in adj[v]:
        if nv==p:
            continue
        else:
            dfs(adj,nv,v,px,x,ct)
    ct[v]+=x

def main():
    N,Q=map(int,input().split())
    adj=[[] for i in range(N)]
    for i in range(N-1):
        a,b=map(int,input().split())
        adj[a-1]+=[b-1]
        adj[b-1]+=[a-1]
    px=[0]*N
    for i in range(Q):
        p,x=map(int,input().split())
        px[p-1]+=x
        
    ct=[0]*N
    dfs(adj,0,-1,px,0,ct)
    
    
    print(ct[0], end="")
    for i in range(1,N):
        print(" {}".format(ct[i]),end="")
    print("")
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
# ABC138D

import sys
sys.setrecursionlimit(1000000000000)
def dfs(kol,adj,v,p):
    for nv in adj[v]:
        if nv==p:
            continue
        else:
            dfs(kol,adj,nv,v)
    kol[v]+=[v]
    if p!=-1:
        kol[p]+=kol[v]
N,Q=map(int,input().split())
adj=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    adj[a-1]+=[b-1]
    adj[b-1]+=[a-1]
    
ct=[0]*N
kol=[[] for i in range(N)]

dfs(kol,adj,0,-1)

for i in range(Q):
    p,x=map(int,input().split())
    for j in kol[p-1]:
        ct[j]+=x

print(ct[0], end="")
for i in range(1,N):
    print(" {}".format(ct[i]),end="")
print("")

Buggy submission (verdict: Runtime Error):
# ABC138D
def dfs(kol,adj,v,p):
    for nv in adj[v]:
        if nv==p:
            continue
        else:
            dfs(kol,adj,nv,v)
    kol[v]+=[v]
    if p!=-1:
        kol[p]+=kol[v]
N,Q=map(int,input().split())
adj=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    adj[a-1]+=[b-1]
    adj[b-1]+=[a-1]
    
ct=[0]*N
kol=[[] for i in range(N)]

dfs(kol,adj,0,-1)

for i in range(Q):
    p,x=map(int,input().split())
    for j in kol[p-1]:
        ct[j]+=x

print(ct[0], end="")
for i in range(1,N):
    print(" {}".format(ct[i]),end="")
print("")
Problem p02960 (python)

Fixed submission:
#

import sys
input=sys.stdin.readline

def main():
    MOD=10**9+7
    S=input().strip("\n")
    q=[]
    g=0
    S=S[::-1]
    m13=(1,10,9,12,3,4)
    for i in range(len(S)):
        if S[i] == "?":
            q.append(m13[i%6])
        else:
            x=int(S[i])
            g+=x*m13[i%6]
            g%=13
    if len(q)==0:
        if g==5:
            print(1)
        else:
            print(0)
        exit()
    N=len(q)
    q=[0]+q
    dp=[[0]*13 for i in range(N+1)]
    for j in range(10):
        dp[1][(j*q[1])%13]=1
    for i in range(2,N+1):
        for j in range(13):
            for k in range(10):
                x=(j-k*q[i])%13
                dp[i][j]+=dp[i-1][x]
                dp[i][j]%=MOD
    print(dp[N][(5-g)%13])
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
#

import sys
input=sys.stdin.readline

def main():
    MOD=10**9+7
    S=input().strip("\n")
    q=[]
    g=0
    S=S[::-1]
    m13=(1,10,9,12,3,4)
    for i in range(len(S)):
        if S[i] == "?":
            q.append(m13[i%6])
        else:
            x=int(S[i])
            g+=x*m13[i%6]
            g%=13
    N=len(q)
    q=[0]+q
    dp=[[0]*13 for i in range(N+1)]
    for j in range(10):
        dp[1][(j*q[1])%13]=1
    for i in range(2,N+1):
        for j in range(13):
            for k in range(10):
                x=(j-k*q[i])%13
                dp[i][j]+=dp[i-1][x]
                dp[i][j]%=MOD
    print(dp[N][(5-g)%13])
    
if __name__=="__main__":
    main()
Problem p02973 (python)

Fixed submission:
# ABC134E

import sys
input=sys.stdin.readline

def bisectR(ite,x):
    st=-1
    en=len(ite)
    while(en-st>1):
        mid=(en+st)//2
        if ite[mid]<x:
            en=mid
        else:
            st=mid
    return en

def main():
    N=int(input())
    A=[int(input()) for i in range(N)]
    
    lbds=[A[0]]
    for i in range(1,N):
        if lbds[-1]>=A[i]:
            lbds+=[A[i]]
        else:
            x=bisectR(lbds,A[i])
            lbds[x]=A[i]
    print(len(lbds))
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
# ABC134E

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    A=[int(input()) for i in range(N)]
    
    cho=[0]*(10**9+1)
    cho[A[0]]+=1
    maxset=set([A[0]])
    
    for i in range(1,N):
        remset=set()
        for m in maxset:
            if A[i]>m:
                remset.add(m)
            if A[i]==m:
                cho[m]+=1
        if len(remset)>0:
            maxset.remove(max(remset))
            maxset.add(A[i])
        else:
            maxset.add(A[i])
            
    print(max(len(maxset),max(cho)))
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
# ABC134E

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    A=[int(input()) for i in range(N)]
    
    cho=[0]*(10**5+1)
    cho[A[0]]+=1
    maxset=set([A[0]])
    
    for i in range(1,N):
        remset=set()
        for m in maxset:
            if A[i]>m:
                remset.add(m)
            if A[i]==m:
                cho[m]+=1
        if len(remset)>0:
            maxset.remove(max(remset))
            maxset.add(A[i])
        else:
            maxset.add(A[i])
            
    print(max(len(maxset),max(cho)))
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
# ABC134E

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    A=[int(input()) for i in range(N)]
    
    cho=[0]*(10**5+1)
    cho[A[0]]+=1
    maxset=set([A[0]])
    
    for i in range(1,N):
        remset=set()
        for m in maxset:
            if A[i]>m:
                remset.add(m)
            if A[i]==m:
                cho[m]+=1
        if len(remset)>0:
            maxset.remove(max(remset))
            maxset.add(A[i])
        else:
            maxset.add(A[i])
            
    print(maxset)
    print(max(len(maxset),cho))
    
if __name__=="__main__":
    main()
Problem p03062 (python)

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

fu=0
for i in range(N):
  if A[i]<0:
    fu+=1
if fu % 2 == 0:
  print(sum(Aabs))
else:
  print(sum(Aabs)-2*min(Aabs))

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

fu=0
for i in range(N):
  if A[i]<0:
    fu+=1
if fu % 2 == 0:
  print(sum(Aabs))
else:
  print(sum(Aabs)-2*min(Aabs))

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

fu=0
for i in range(N):
  if A[i]<0:
    fu+=1
if fu % 2 == 0:
  print(sum(Aabs))
else:
  print(sum(Aabs)-2*min(Aabs))
Problem p03076 (python)

Fixed submission:
#

import sys
from math import ceil
input=sys.stdin.readline

def main():
    t=[int(input()) for i in range(5)]
    tp10=[t[i]%10 for i in range(5) if t[i]%10!=0]
    ans=0
    for i in range(5):
        ans+=ceil(t[i]/10)*10
    if len(tp10)>0:
      	print(ans-10+min(tp10))
    else:
      	print(ans)
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
#

import sys
from math import ceil
input=sys.stdin.readline

def main():
    t=[int(input()) for i in range(5)]
    tp10=[t[i]%10 for i in range(5) if t[i]%10!=0]
    ans=0
    for i in range(5):
        ans+=ceil(t[i]/10)*10
    print(ans-10+min(tp10))
    
if __name__=="__main__":
    main()
Problem p03161 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n

dp[0]=0
for i in range(1,n):
    for j in range(1,min(k+1,i+1)):
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
    
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n

dp[0]=0
for i in range(1,n):
    for j in range(1,max(k+1,n)):
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
    
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n

dp[0]=0
for i in range(1,n):
    for j in range(1,k+1):
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
    
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n

dp[0]=0
for i in range(1,n):
    for j in range(1,k+1):
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
    
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n

dp[0]=0
for i in range(1,n):
    for j in range(min(0,i-k),i):
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]))
    
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[1000]*n

dp[0]=0
for i in range(1,n):
    for j in range(i-k,i):
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]))
    
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[1000]*n

dp[0]=0
for i in range(1,n):
    for j in range(i-k,i):
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]))
    
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n

dp[0]=0
for i in range(1,n):
    for j in range(i-k,i):
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]))
    
print(dp[n-1])
Problem p03163 (python)

Fixed submission:
N,W=map(int,input().split())
wv=[[0,0]]+[list(map(int,input().split())) for _ in range(N)]

dp=[[0 for i in range(W+1)] for j in range(N+1)]

for i in range(1,N+1):
    for j in range(W+1):
        dp[i][j]=dp[i-1][j]
        if j - wv[i][0] >= 0:
            dp[i][j]=max(dp[i][j],dp[i-1][j-wv[i][0]]+wv[i][1])

            
print(max(dp[N]))

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

N, W = map(int, input().split())
w = np.empty(N)
v = np.empty(N)
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = np.zeros(W + 1, dtype = np.int64)
dp[w[0]] = v[0]

for i in range(1, N):
	dp[w[i]:] = np.maximum(dp[w[i]:], dp[:W - w[i] + 1] + v[i])

print(dp.max())

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

dp = [0] * (W + 1)
dp[w[0]] = v[1]

for i in range(1, N):
	for j in range(W, -1, -1):
		if j - w[i] >= 0 and dp[j - w[i]] + v[i] > dp[j]:
			dp[j] = max(dp[j], dp[j - w[i]] + v[i])
print(max(dp))

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

dp = [0] * (W + 1)
dp[w[0]] = v[1]

for i in range(1, N):
	for j in range(W, -1, -1):
		if j - w[i] >= 0 and dp[j - w[i]] + v[i] > dp[j]:
			dp[j] = max(dp[j], dp[j - w[i]] + v[i])
print(max(dp))
Problem p03230 (python)

Fixed submission:
# https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_d

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    m=0
    k=0
    for i in range(int(((8*N+1)**0.5-1)/2)+1):
        if i*(i+1)==2*N:
            m=i
            k=i+1
            break
    if m==0:
        print("No")
        exit()
    elif N==1:
        print("Yes")
        print(2)
        print(1,1)
        print(1,1)
    else:
        ml=[[] for i in range(k)]
        for i in range(1,k+1):
            ml[i-1].append(str(i))
            ml[i-2].append(str(i))
        for i in range(k+1,N+1):
            ml[(i-k-1)%k].append(str(i))
            l=(i-k-1)//k
            ml[(i-k-1+2+l)%k].append(str(i))
        print("Yes")
        print(k)
        for i in range(k):
            print(m, " ".join(ml[i]))
    
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_d

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    m=0
    k=0
    for i in range(2*N+1):
        if i*(i+1)==2*N:
            m=i
            k=i+1
            break
    if m==0 or N==1:
        print("No")
        exit()
    else:
        ml=[[] for i in range(k)]
        for i in range(1,k+1):
            ml[i-1].append(str(i))
            ml[i-2].append(str(i))
        for i in range(k+1,N+1):
            ml[i-k-1].append(str(i))
            l=(i-k-1)//k
            ml[(i-k-1+2+l)%k].append(str(i))
        print("Yes")
        print(k)
        for i in range(k):
            print(m, " ".join(ml[i]))
    
    
if __name__=="__main__":
    main()
Problem p03471 (python)

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

x=-1
y=-1
z=-1
bp=0

for i in range(N+1):
    for j in range(N+1-i):
        if Y==9000*i+4000*j+1000*N:
            x=i
            y=j
            z=N-i-j
            bp=1
            break
    if bp==1:
        break
        
print("{} {} {}".format(x,y,z))

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

x=-1
y=-1
z=-1

bp=0
for i in range(N+1):
    for j in range(N+1-i):
        if Y==9000*i+4000*j+1000*N:
            x=i
            y=j
            z=N-i-j
            bp=1
            break
    if bp==1:
        break
        
print(f"{x} {y} {z}")

Buggy submission (verdict: Runtime Error):

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

x,y,z=-1,-1,-1
bp=0
for i in range(N+1):
    for j in range(N+1-i):
        if Y==9000*i+4000*j+1000*N:
            x=i
            y=j
            z=N-i-j
            bp=1
            break
    if bp==1:
        break
        
print(f"{x} {y} {z}")

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

x,y,z=-1,-1,-1
bp=0
for i in range(N+1):
    for j in range(N+1-i):
        if Y==9000*i+4000*j+1000*N:
            x=i
            y=j
            z=N-i-j
            bp=1
            break
    if bp==1:
        break
        
print(f"{x} {y} {z}")
Problem p03557 (python)

Fixed submission:
# ABC077C

import bisect

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

bC=[0 for i in range(N)]
for i in range(N):
    bC[i]=N-bisect.bisect(C,B[i])
    
bCS=[0]*(N+1)
for i in range(N):
    bCS[i+1] = bCS[i]+bC[i]
    
ans=0
for i in range(N):
    x=bisect.bisect(B,A[i])
    ans+=bCS[N]-bCS[x]
        
print(ans)

Buggy submission (verdict: Runtime Error):
# ABC077C

import bisect

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

bC=[0 for i in range(N)]
for i in range(N):
    bC[i]=N-bisect.bisect(C,B[i])
    
bCS=[0]*N+1
for i in range(N):
    bCS[i+1] = bCS[i]+bC[i]
    
ans=0
for i in range(N):
    x=bisect.bisect(B,A[i])
    ans+=bCS[N]-bCS[x]
        
print(ans)
Problem p03565 (python)

Fixed submission:
Sp = input()
T = input()

if len(T) > len(Sp):
	print("UNRESTORABLE")
	exit()
	
oklist = []
for i in range(len(Sp) - len(T), -1, -1):
	for j in range(len(T)):
		if Sp[i + j] != "?" and Sp[i + j] != T[j]:
			break
	else:
		okpre = ["a" if Sp[k] == "?" else Sp[k] for k in range(i)]
		oksuf = ["a" if Sp[k] == "?" else Sp[k] for k in range(i + len(T), len(Sp))] 
		oklist.append("".join(okpre) + T + "".join(oksuf))

if oklist:
	print(min(oklist))
else:
	print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
Sp = input()
T = input()

if len(T) > len(Sp):
	print("UNRESTORABLE")
	exit()
	
oklist = []
for i in range(len(Sp) - len(T), -1,Sp = input()
T = input()

if len(T) > len(Sp):
	print("UNRESTORABLE")
	exit()
	
oklist = []
for i in range(len(Sp) - len(T), -1, -1):
	for j in range(len(T)):
		if Sp[i + j] != "?" and Sp[i + j] != T[j]:
			break
	else:
		okpre = ["a" if Sp[k] == "?" else Sp[k] for k in range(i)]
		oksuf = ["a" if Sp[k] == "?" else Sp[k] for k in range(i + len(T), len(Sp))] 
		oklist.append("".join(okpre) + T + "".join(oksuf))

if oklist:
	print(min(oklist))
else:
	print("UNRESTORABLE") -1):
	for j in range(len(T)):
		if Sp[i + j] != "?" and Sp[i + j] != T[j]:
			break
	else:
		print(i)
		okpre = ["a" if Sp[k] == "?" else Sp[k] for k in range(i)]
		oksuf = ["a" if Sp[k] == "?" else Sp[k] for k in range(i + len(T), len(Sp))] 
		oklist.append("".join(okpre) + T + "".join(oksuf))

if oklist:
	print(min(oklist))
else:
	print("UNRESTORABLE")
Problem p03752 (python)

Fixed submission:
# https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b

from itertools import combinations

N,K=map(int,input().split())
a=list(map(int,input().split()))

minc=10**12
ai=[i for i in range(N)]
for i in combinations(ai,K):
    ac=a[:]
    cost=0
    i=list(i)
    for j in range(1,K):
        costt=max(max(ac[:i[j]])-ac[i[j]]+1,0)
        ac[i[j]]+=costt
        cost+=costt
    minc=min(cost,minc)
print(minc)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b

from itertools import combinations

N,K=map(int,input().split())
a=list(map(int,input().split()))

minc=10**12
ai=[i for i in range(N)]
for i in combinations(ai,K):
    ac=a[:]
    cost=0
    i=list(i)
    for j in range(1,K):
        costt=max(max(ac[:i[j]])-ac[i[j]]+1,0)
        ac[i[j]]+=costt
        costa+=costt
    minc=min(cost,minc)
print(minc)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b

from itertools import combinations

N,K=map(int,input().split())
a=list(map(int,input().split()))

upend=N-1
for i in range(N):
    if a[i]>a[i+1]:
        upend=i
        break
minc=10**12
for i in combinations(a[upend+1:],K):
    cost=0
    l=[a[j] for j in range(upend+1)]+list(i)
    for j in range(1,K):
        costt=max(l[j-1]-l[j]+1,0)
        l[j]+=costt
        cost+=costt
    minc=min(cost,minc)

print(minc)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b

from itertools import combinations

N,K=map(int,input().split())
a=list(map(int,input().split()))

minc=10**12
for i in combinations(a,K):
    cost=0
    for j in range(1,K):
        costt=max(i[j-1]-i[j]+1,0)
        i[j]+=costt
        cost+=costt
    minc=min(cost,minc)

print(minc)
Problem p02607 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
  if((i+1) % 2 == 1 and a[i] % 2 == 1):
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n+1):
  if((i+1) % 2 == 1 and a[i] % 2 == 1):
    ans += 1
print(ans)
Problem p02608 (python)

Fixed submission:
n = int(input())

ans = 0
ans1 = [0] * 10050
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      ans = i**2 + j**2 +k**2 + i*j + j*k + k*i
      if(ans < 10050):
        ans1[ans] += 1
for i in range(n):
  print(ans1[i+1])

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

ans = 0
ans1 = [0] * 10000
for i in range(1,100):
  for j in range(1,100):
    for k in range(1,100):
      ans = i**2 + j**2 +k**2 + i*j + j*k + k*i
      if(ans < 10000):
        ans1[ans] += 1
for i in range(n):
  print(ans1[i+1])

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

ans = 0
ans1 = [0] * n
for i in range(1,100):
  for j in range(1,100):
    for k in range(1,100):
      ans = i**2 + j**2 +k**2 + i*j + j*k + k*i
      if(l+1 < 10000):
        ans1[l] += 1
for i in range(n):
  print(ans1[i])

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

ans = 0
ans1 = [0] * n
for i in range(1,100):
  for j in range(1,100):
    for k in range(1,100):
      ans = i**2 + j**2 +k**2 + i*j + j*k + k*i
      for l in range(100):
        if(l+1 < 10000):
          ans1[l] += 1
for i in range(n):
  print(ans1[i])

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

ans = 0
ans1 = [0] * n
for i in range(1,n):
  for j in range(1,n):
      ans = i**2 + j**2 +k**2 + i*j + j*k + k*i
      for l in range(6,n-1):
        if(l+1 == ans):
          ans1[l] += 1
for i in range(n):
  print(ans1[i])
Problem p02621 (python)

Fixed submission:
a = int(input())
print(a**3 + a**2 + a)

Buggy submission (verdict: Runtime Error):
n = int(input())
print(a^3 + a^2 + a)
Problem p02630 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
num = [0] * 100010
b = [0] * q
c = [0] * q
for i in range(q):
    b[i], c[i] = map(int, input().split())

for i in a:
    num[i] += 1

s = sum(a)

for i in range(q):
  s+=(c[i]-b[i])*num[b[i]]
  num[c[i]] += num[b[i]]
  num[b[i]] = 0
  print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
num = [0] * 100010
b = [0] * q
c = [0] * q
for i in range(q):
    b[i], c[i] = map(int, input().split())

for i in a:
    num[i] += 1

s = sum(a)

for i in range(q):
    s += (c[i]　-　b[i])　*　num[b[i]]
    num[c[i]] += num[b[i]]
    num[b[i]] = 0
    print(s)
Problem p02658 (python)

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

for i in A:
    ans *= i
    if ans > 10 ** 18:
        print(-1)
        exit()

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in a:
  if(a[i] == 0):
    print(0)
     exit
  else:
    ans += a[0]
    for i in range(1,n):
      ans *= a[i]
      if(ans > 10**18):
        ans *= a[i]
        print(-1)
        exit
      else:
        print(sum(a))
Problem p02675 (python)

Fixed submission:
n = input()
a = [int(c) for c in n]
if(a[-1] == 3):
    print('bon')
elif(a[-1] == 0):
  print('pon')
elif(a[-1] == 1):
  print('pon')
elif(a[-1] == 6):
  print('pon')
elif(a[-1] == 8):
  print('pon')
elif(a[-1] == 2):
  print('hon')
elif(a[-1] == 4):
  print('hon')
elif(a[-1] == 5):
  print('hon')
elif(a[-1] == 7):
  print('hon')
elif(a[-1] == 9):
  print('hon')

Buggy submission (verdict: Runtime Error):
n = input()
a = [int(c) for c in n]
if(a[len(n)] == 3):
    print('bon')
elif(a[len(n)] == 0 or 1 or 6 or 8):
    print('pon')
else:
    print('hon')
Problem p02690 (python)

Fixed submission:
x = int(input())
for i in range(-500,500):
  for j in range(-500,500):
    a = pow(i,5)
    b = pow(j,5)
    if(x == a - b):
      print(i,j)
      exit(0)

Buggy submission (verdict: Runtime Error):
x = int(input())
i = 0
while x-i % i != 0:
  i+= 1
a += i
b += x - i
print(a,b)
Problem p02696 (python)

Fixed submission:
import math
a, b, n = map(int, input().split())
x = min(b-1, n)
print(math.floor(a*x/b)-a*math.floor(x/b))

Buggy submission (verdict: Runtime Error):
a,b,n = map(int, input().split())
for i in range(b-1):
  tmp = (a*i) // b - a*(i // b)
  ans = 0
  ans = max(tmp,ans)
print(ans)
Problem p02708 (python)

Fixed submission:
mod = 10**9+7
n, k = map(int, input().split())

ans = 0

for i in range(k, n+1):
    ans += i*(n-i+1)+1

print(ans%mod+1)

Buggy submission (verdict: Runtime Error):
mod = 10**9+7
n, k = map(int, input().split())

ans = 0

for i in range(k, n+1):
    ans += i*(n-i+1)
    ans %= MOD

print(ans)
Problem p02714 (python)

Fixed submission:
n = int(input())
s = input()

kumikazu = s.count('R')*s.count('B')*s.count('G')

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j-i
        if k >= n:
          break
        if (s[i] != s[j]) and (s[i] != s[k]) and (s[j] != s[k]):
                kumikazu -= 1
print(kumikazu)

Buggy submission (verdict: Runtime Error):

n = int(input())
s = input()

kumikazu = s.count('R')*s.count('B')*s.count('G')

for i in range(n-2):
    for j in range(i+1,n-1):
        k = 2*j-i
        if k >= n:
          if (s[i] != s[j]) and (s[i] != s[k]) and (s[j] != s[k]):
            kumikazu -= 1