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

Fixed submission:
a,b = map(int, input().split())
r=[a+b, a-b, a*b]
print(max(r))

Buggy submission (verdict: Runtime Error):
n = int(input())
sl = []
for _ in range(n):
    sl.append(input())
rl=[]
ll=[]
rslt=0
for i in range(n):
    r=sorted(sl[i])
    if r in rl: ll[rl.index(r)]+=1; rslt+=ll[rl.index(r)]
    else: rl.append(r); ll.append(0)
print(rslt)
Problem p02947 (python)

Fixed submission:
n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(rslt)

Buggy submission (verdict: Runtime Error):
n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d
        d+=1
    else:
        d[s]=1
print(rslt)
Problem p02952 (python)

Fixed submission:
n=input()
l=len(n)
s=0
if l>1:
    if l%2==1:
        s+=int(n[1:])+1+(int(n[0])-1)*(10**(l-1))
        l-=1
    for i in range(int(l/2)):
        s+=9*10**(i*2)
    print(s)
else:
    print(int(n))

Buggy submission (verdict: Runtime Error):
n=input()
l=len(n)
s=0
if l%2==1:
    s+=int(n[1:])+1+(int(n[0])-1)*(10**(l-1))
    l-=1
for i in range(int(l/2)):
    s+=9*10**(i*2)
print(s)
Problem p02953 (python)

Fixed submission:
n=int(input())
hl=list(map(int, input().split()))
m=0
for h in hl:
    if m <= h: m = h
    elif m == h+1: continue
    else: print("No"); break
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input()))
p,a=True,0
for h in H:
  if h>a:
    a=h-1
  elif a>h:
    p=False
    break
print("Yes" if p else "No")
Problem p02971 (python)

Fixed submission:
N=int(input())
l=[]
l.append(int(input()))
l.append(int(input()))
m1=max(l)
m2=min(l)
for _ in range(N-2):
  l.append(int(input()))
  if l[-1] >= m1:
    m2 = m1
    m1 = l[-1]
  elif l[-1] > m2:
    m2 = l[-1]
for i in range(N):
  if l[i] == m1:
    print(m2)
  else:
    print(m1)

Buggy submission (verdict: Runtime Error):
N=int(input())
l=[]
l.append(int(input()))
l.append(int(input()))
m1=max(l)
mx=min(l)
for _ in range(N-2):
  l.append(int(input()))
  if l[-1] >= m1:
    m2 = m1
    m1 = l[-1]
  elif l[-1] > m2:
    m2 = l[-1]
for i in range(N):
  if l[i] == m1:
    print(m2)
  else:
    print(m1)
Problem p02982 (python)

Fixed submission:
import math
 
N,D=map(int,input().split())
X=[]
for _ in range(N):
  X.append(list(map(int, input().split())))
count=0
for i in range(N-1):
  for j in range(i+1,N):
    a=0
    for k in range(D):
      a+=(X[i][k]-X[j][k])**2
    if math.sqrt(a).is_integer():
      count+=1
print(count)

Buggy submission (verdict: Runtime Error):
import math

N,D=map(int,input().split())
X=[]
for _ in range(N):
  X.append(list(map(int, input().split())))
count=0
for i in range(N-1):
  for j in range(i+1,N):
    a=0
    for k in range(D):
      a+=(X[i][k]-X[j][k])**2
    if math.sqrt(a).is_integer():
      coutn+=1
print(count)
Problem p02993 (python)

Fixed submission:
S=input()
p = 'a'
for s in S:
  if p == s:
    p = 'a'
    break
  else:
    p = s
print("Bad" if p == 'a' else "Good")

Buggy submission (verdict: Runtime Error):
S=input()
p = a
for s in S:
  if p == s:
    p = a
    break
  else:
    p = s
print("Bad" if p == a else "Good")
Problem p03076 (python)

Fixed submission:
import math
ans=0
A=[int(input()) for i in range(5)]
a=10
p=0
for i in range(5):
  if a>(A[i]%10) and A[i]%10!=0:
    p=i
    a=A[i]%10
for i in range(5):
  if i==p:
    ans+=A[i]
  else:
    ans+=10*(math.ceil(A[i]/10))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
ans=0
A=[int(input()) for i in range(5)]
a=0
for i in range(5):
  if (A[i]%10)>a:
    p=i
    a=A[i]
for i in range(5):
  if i==p:
    ans+=A[i]
  else:
    ans+=10*(math.ceil(A[i]/10))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
ans=0
A=[int(input()) for i in range(5)]
a=10
for i in range(5):
  if a>A[i]:
    p=i
    a=A[i]
for i in range(5):
  if i==p:
    ans+=A[i]
  else:
    ans+=10*(math.ceil(A[i]/10))
print(ans)
Problem p03106 (python)

Fixed submission:
A,B,K=map(int,input().split())
k=0
n=min(A,B)
while 1:
  if A%n==0 and B%n==0:
    k+=1
  if K==k:
    break
  n-=1
print (n)

Buggy submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
n=1
while K>1:
  n+=1
  if A%n==0 and B%==0:
    K-=1
print(n)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
for i in range(1,range(max(a,b)+1)):
  if a%i==0 and b%i==0:
    k-=1
    if k==0:
      break
print(i)
Problem p03110 (python)

Fixed submission:
btc=380000
N=int(input())
ans=0
for i in range(N):
  x,u=input().split()
  if u=='JPY':
    ans+=float(x)
  else:
    ans+=float(x)*btc
print(ans)

Buggy submission (verdict: Runtime Error):
btc=380000
N=int(input())
ans=0
for i in range(N):
  x,u=input().split()
  if u=='JPY':
    ans+=int(x)
  else:
    ans+=int(x)*btc
print(ans)
Problem p03111 (python)

Fixed submission:
N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
R=[0]*N
ans=10**9
def myadd(i):
    if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1
for i in range(4**N-1):
    myadd(0)
    if 1 in R and 2 in R and 3 in R:
        tmp=-30
        t1,t2,t3=0,0,0
        for j in range(N):
            if R[j]==0:
                continue
            if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
            tmp+=10
        tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3)
        ans=min(tmp,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
R=[0]*N
ans=10**9
def myadd(i):
    if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1
for i in range(N**4):
    myadd(0)
    if 1 in R and 2 in R and 3 in R:
        tmp=-6
        t1,t2,t3=0,0,0
        for j in range(N):
            if R[j]==0:
                continue
            if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
            tmp+=2
        tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3)
        ans=min(tmp,ans)
print(ans)
Problem p03112 (python)

Fixed submission:
from bisect import bisect_left

A,B,Q=map(int,input().split())
S=[int(input()) for i in range(A)]
T=[int(input()) for i in range(B)]
for i in range(Q):
    x=int(input())
    si=bisect_left(S,x)
    ti=bisect_left(T,x)
    if 0<si<A and 0<ti<B:
        sl,sr=abs(x-S[si-1]),abs(x-S[si])
        tl,tr=abs(x-T[ti-1]),abs(x-T[ti])
        print(min(max(sr,tr),max(sl,tl),sl+tr+min(sl,tr),sr+tl+min(sr,tl)))
    elif si==0 and ti==0:
        sr=abs(x-S[si])
        tr=abs(x-T[ti])
        print(max(sr,tr))
    elif si==A and ti==B:
        sl=abs(x-S[si-1])
        tl=abs(x-T[ti-1])
        print(max(sl,tl))
    elif si==0 and ti==B:
        sr=abs(x-S[si])
        tl=abs(x-T[ti-1])
        print(sr+tl+min(sr,tl))
    elif si==A and ti==0:
        sl=abs(x-S[si-1])
        tr=abs(x-T[ti])
        print(sl+tr+min(sl,tr))
    elif si==0:
        sr=abs(x-S[si])
        tl,tr=abs(x-T[ti-1]),abs(x-T[ti])
        print(min(max(sr,tr),sr+tl+min(sr,tl)))
    elif si==A:
        sl=abs(x-S[si-1])
        tl,tr=abs(x-T[ti-1]),abs(x-T[ti])
        print(min(max(sl,tl),sl+tr+min(sl,tr)))
    elif ti==0:
        sl,sr=abs(x-S[si-1]),abs(x-S[si])
        tr=abs(x-T[ti])
        print(min(max(sr,tr),sl+tr+min(sl,tr)))
    elif ti==B:
        sl,sr=abs(x-S[si-1]),abs(x-S[si])
        tl=abs(x-T[ti-1])
        print(min(max(sl,tl),sr+tl+min(sr,tl)))

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left

A,B,Q=map(int,input().split())
S=[int(input()) for i in range(A)]
T=[int(input()) for i in range(B)]
for i in range(Q):
    x=int(input())
    si=bisect_left(S,x)
    ti=bisect_left(T,x)
    if 0<si<A and 0<ti<B:
        sl,sr=abs(x-S[si-1]),abs(x-S[si])
        tl,tr=abs(x-T[ti-1]),abs(x-T[ti])
        print(min(max(sr,tr),max(sl,tl),sl+tr+min(sl,tr),sr+tl+min(sr,tl)))
    elif si==0 and ti==0:
        sr=abs(x-S[si])
        tr=abs(x-T[ti])
        print(sr,tr)
    elif si==A and ti==B:
        sl=abs(x-S[si-1]),abs(x-S[si])
        tl=abs(x-T[ti-1]),abs(x-T[ti])
        print(max(sl,tl))
    elif si==0 and ti==B:
        sr=abs(x-S[si])
        tl=abs(x-T[ti-1])
        print(sr+tl+min(sr,tl))
    elif si==A and ti==0:
        sl=abs(x-S[si-1])
        tr=abs(x-T[ti])
        print(sl+tr+min(sl,tr))
    elif si==0:
        sr=abs(x-S[si])
        tl,tr=abs(x-T[ti-1]),abs(x-T[ti])
        print(min(max(sr,tr),sr+tl+min(sr,tl)))
    elif si==A:
        sl=abs(x-S[si-1])
        tl,tr=abs(x-T[ti-1]),abs(x-T[ti])
        print(min(max(sl,tl),sl+tr+min(sl,tr)))
    elif ti==0:
        sl,sr=abs(x-S[si-1]),abs(x-S[si])
        tr=abs(x-T[ti])
        print(min(max(sr,tr),sl+tr+min(sl,tr)))
    elif ti==B:
        sl,sr=abs(x-S[si-1]),abs(x-S[si])
        tl=abs(x-T[ti-1])
        print(min(max(sl,tl),sr+tl+min(sr,tl)))
Problem p03206 (python)

Fixed submission:
D=int(input())
s="Christmas"
e=" Eve"
if D==25:
  print(s)
  exit()
s+=e
if D==24:
  print(s)
  exit()
s+=e
if D==23:
  print(s)
  exit()
if D==22:
  print(s+e)

Buggy submission (verdict: Runtime Error):
D=int(input())
s="Christmas"
e=" Eve"
if D==25:
  print(s)
  exit()
s+=e
if D==24:
  print(s)
  exit()
s+=e
if D==23:
  print(s)
  exit()
if D==22:
  priint(s+e)
Problem p03274 (python)

Fixed submission:
N,K=map(int,input().split())
X=list(map(int,input().split()))
p=True
for i in range(N):
    if X[i]<0:
        continue
    elif X[i]==0:
        K-=1
        if i<K:
            mX=[0]+[-x for x in X[:i]][::-1]
        else:
            mX=[0]+[-x for x in X[i-K:i]][::-1]
        pX=[0]+X[i+1:i+1+K]
        p=False
        break
    else:
        if i<K:
            mX=[0]+[-x for x in X[:i]][::-1]
        else:
            mX=[0]+[-x for x in X[i-K:i]][::-1]
        pX=[0]+X[i:i+K]
        p=False
        break
if p:
    mX=[0]+[-x for x in X[::-1]]
    pX=[0]
ans=10**9
l=K-(len(pX)-1)
n=len(mX)
for i in range(len(pX)-1,-1,-1):
    if l<n:
        ans=min(ans,pX[i]+mX[l]*2,pX[i]*2+mX[l])
    else:
        break
    l+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
X=list(map(int,input().split()))
for i in range(N):
    if X[i]<0:
        continue
    elif X[i]==0:
        K-=1
        if i<K:
            mX=[0]+[-x for x in X[:i]][::-1]
        else:
            mX=[0]+[-x for x in X[i-K:i]][::-1]
        pX=[0]+X[i+1:i+1+K]
        break
    else:
        if i<K:
            mX=[0]+[-x for x in X[:i]][::-1]
        else:
            mX=[0]+[-x for x in X[i-K:i]][::-1]
        pX=[0]+X[i:i+K]
        break
ans=10**9
l=K-(len(pX)-1)
n=len(mX)
for i in range(len(pX)-1,-1,-1):
    if l<n:
        ans=min(ans,pX[i]+mX[l]*2,pX[i]*2+mX[l])
    else:
        break
    l+=1
print(ans)
Problem p02641 (python)

Fixed submission:

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


if n <= 0:
    print(x)
else:
    p = list(map(int,input().split()))
    p.sort()
    p2 = [x for x in range(-200,200)]

    p_p2_diff = set(p)^set(p2)
    p_p2_diff_list = list(p_p2_diff)

    min_list = []
    for i in p_p2_diff_list:
        val = abs(x - i)
        min_list.append(val)

    print(p_p2_diff_list[min_list.index(min(min_list))])

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


if n <= 0:
    print(x)
else:
    p = list(map(int,input().split()))
    p.sort()
    p2 = [x for x in range(1,p[-1]+n)]

    p_p2_diff = set(p)^set(p2)
    p_p2_diff_list = list(p_p2_diff)

    min_list = []
    for i in p_p2_diff_list:
        val = abs(x - i)
        min_list.append(val)

    print(p_p2_diff_list[min_list.index(min(min_list))])

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


if n <= 0:
    print(x)
else:
    p = list(map(int,input().split()))
    p2 = [x for x in range(1,100+1)]

    p_p2_diff = set(p)^set(p2)
    p_p2_diff_list = list(p_p2_diff)

    min_list = []
    for i in range(len(p_p2_diff_list)):
        val = abs(x - p_p2_diff_list[i])
        min_list.append(val)

    print(p_p2_diff_list[min_list.index(min(min_list))])

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


if n <= 0:
    print(x)
else:
    p = list(map(int,input().split()))
    q = p
    q.sort()
    p2 = [x for x in range(1,q[-1]+n)]

    p_p2_diff = set(p)^set(p2)
    p_p2_diff_list = list(p_p2_diff)

    min_list = []
    for i in range(len(p_p2_diff_list)):
        val = abs(x - p_p2_diff_list[i])
        min_list.append(val)

    print(p_p2_diff_list[min_list.index(min(min_list))])

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

if n <= 0:
    print(x)
else:
    q = p
    q.sort()
    p2 = [x for x in range(1,q[-1]+n)]

    p_p2_diff = set(p)^set(p2)
    p_p2_diff_list = list(p_p2_diff)

    min_list = []
    for i in range(len(p_p2_diff_list)):
        val = abs(x - p_p2_diff_list[i])
        min_list.append(val)

    print(p_p2_diff_list[min_list.index(min(min_list))])

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

if n <= 0:
    print(x)
else:
    q = p
    q.sort()
    p2 = [x for x in range(1,q[-1]+n)]

    p_p2_diff = set(p)^set(p2)
    p_p2_diff_list = list(p_p2_diff)

    min_list = []
    for i in range(len(p_p2_diff_list)):
        val = abs(x - p_p2_diff_list[i])
        min_list.append(val)

    print(p_p2_diff_list[min_list.index(min(min_list))])
Problem p02576 (python)

Fixed submission:
n, x, t=map(int, input().split())

cnt=0

while n > x*cnt:
    cnt+=1

print(t*cnt)

Buggy submission (verdict: Runtime Error):
h, w=map(int, input().split())
ch, cw=map(int, input().split())
dh, dw=map(int, input().split())

grid=["0"]*(h+2)
grid[0]="0"*(w+2)
grid[h+1]="0"*(w+2)

for i in range(1, h+1):
    s=input()
    grid[i]= "0"+s+"0"

p=1
road=[[0] * (w+2) for i in range(h+2)]

for i in range(1, h+1):
    for j in range(1, w+1):
        if grid[i][j] == ".":
            for k in range(5):
                flag=0
                if flag == 0 and road[i][j]==0:
                    road[i][j]=p
                if grid[i][j+1] == "." and flag == 1 and road[i][j+1]==0:
                    road[i][j+1]=p
                    flag+=1

                if grid[i][j-1] == "." and flag == 2 and road[i][j-1]==0:
                    road[i][j-1]=p
                    flag+=1

                if grid[i+1][j] == "." and flag == 3 and road[i+1][j]==0:
                    road[i+1][j]=p
                    flag+=1

                if grid[i-1][j] == "." and flag == 4 and road[i-1][j]==0:
                    road[i-1][j]=p
                    flag+=1

    p+=1

print(road)
Problem p02603 (python)

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

money=1000

chart=[a[0]]

for kabuka in a:
    if kabuka==chart[-1]:
        continue
    else:
        chart.append(kabuka)

days=len(chart)
kabu=0

if days==1:
    print(money)
    exit()

for i in range(days):
    if i==0:
        if chart[0]<chart[1]:
            kabu=money//chart[0]
            money%=chart[0]

    elif i==days-1:
        money+=kabu*chart[i]
        kanu=0
    
    else:
        if chart[i-1]<chart[i] and chart[i]>chart[i+1]:
            money+=kabu*chart[i]
            kabu=0

        if chart[i-1]>chart[i] and chart[i]<chart[i+1]:
            kabu=money//chart[i]
            money%=chart[i]

print(money)

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

money=1000

chart=[a[0]]
flag=0

for i in range(n):
    if flag==0:
        if a[i]>chart[-1]:
            chart.append(a[i])
            flag=1

    else:
        if a[i]<chart[-1]:
            cnt=0
            M=0
            for j in range(i, n):
                if a[i]<a[j]:
                    cnt+=1
                    if M<a[j]:
                        M=a[j]
            
            if cnt==0:
                break
            elif cnt==1:
                chart.append(M)
                break
            else:
                flag=0

days=len(chart)

for day in range(days):
    if day%2==0:
        contact=money//chart[i]
        money-=contact*chart[i]
    
    else:
        money+=contact*chart[i]

print(money)

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

money=1000

chart=[a[0]]
flag=0

for i in range(n):
    if flag==0:
        if a[i]>chart[-1]:
            chart.append(a[i])
            flag=1

    else:
        if a[i]<chart[-1]:
            cnt=0
            M=0
            for j in range(i, n+1):
                if a[i]<a[j]:
                    cnt+=1
                    if M<a[j]:
                        M=a[j]
            
            if cnt==0:
                break
            elif cnt==1:
                chart.append(M)
                break
            else:
                flag=0

days=len(chart)

for day in range(days):
    if day%2==0:
        contact=money//chart[i]
        money-=contact*chart[i]
    
    else:
        money+=contact*chart[i]

print(money)
Problem p02614 (python)

Fixed submission:
h, w, k = map(int, input().split())
ans = 0
c = [input() for i in range(h)]
for i in range(1<<h):
    for j in range(1<<w):
        cnt = 0
        for l in range(h):
            for m in range(w):
                if c[l][m] == '#' and (i >> l) & 1 and (j >> m) & 1:
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
h, w, k=map(int, input(). split())
table=[0]*h

for i in range(h):
    table[i]=input()


cnt=0
ans=0

for i in range(2**h):
    for j in range(2*:w):
        cnt=0
        for k in range(h):
            for l in range(w):
                if ((i>>k)&1)==1 and ((j>>l)&1)==1 and table[k][l]=="#":
                    cnt+=1
        
        if cnt==k:
            ans+=1


print(ans)

Buggy submission (verdict: Runtime Error):
h, w, k=map(int, input(). split())
table=[0]*h

for i in range(h):
    table[i]=input()


cnt=0
ans=0

for i in range(2**h):
    for j in range(2*:w):
        cnt=0
        for k in range(h):
            for l in range(w):
                if ((i>>k)&1)==1 and ((j>>l)&1)==1 and table[k][l]=="#":
                    cnt+=1
        
        if cnt==k:
            ans+=1


print(ans)

Buggy submission (verdict: Runtime Error):
h, w, k=map(int, input(). split())
table=[[0] * w for i in range(h)]
trial=h+w
original=0

for i in range(h):
    s=input()
    for j in range(w):
        table[i][j]=s[j]
        if table[i][j]=="#":
            original+=1


copy=[[0] * w for i in range(h)]

ans=0
cnt=0
for i in range(2**trial):
    for j in range(h):
        for k in range(w):
            copy[j][k]=table[j][k]
    
    cnt=0
    for l in range(trial):
        if ((i>>l)&1)==1:
            if l<=h:
                for m in range(w):
                    if copy[l][m]=="#":
                        copy[l][m]="."
                        cnt+=1
            
            else:
                l-=h
                for m in range(h):
                    if copy[m][l]=="#":
                        copy[m][l]="."
                        cnt+=1
    
    if original-cnt==k:
        ans+=1

print(ans)
Problem p02630 (python)

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

S=sum(a)

table=[0]*(10**6)

for i in range(n):
    table[a[i]]+=1

for i in range(q):
    b, c=map(int, input().split())
    if table[b]!=0:
        cnt=table[b]
        table[c]+=cnt
        ans=S+(cnt*(c-b))

        print(ans)

        table[b]=0
        S=ans
    else:
        print(S)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
q=int(input())
results=[]

S=sum(a)

table=[0]*(10**6)

for i in range(n):
    table[a[i]]+=1

for i in range(q):
    b, c=map(int, input().split())
    if table[b]!=0:
        cnt=table[b]
        table[c]+=cnt
        ans=S+(cnt*(c-b))
        results.append(ans)
        table[b]=0
        S=ans
    else:
        results.appned(S)

for result in results:
    print(result)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
q=int(input())
results=[]

S=sum(a)

table=[0]*(10**5)

for i in range(n):
    table[a[i]]+=1

for i in range(q):
    b, c=map(int, input().split())
    if table[b]!=0:
        cnt=table[b]
        table[c]+=cnt
        ans=S+(cnt*(c-b))
        results.append(ans)
        table[b]=0
        S=ans
    else:
        results.append(S)

for result in results:
    print(result)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
q=int(input())
results=[]

S=sum(a)

table=[0]*(10**5)

for i in range(n):
    table[a[i]]+=1

for i in range(q):
    b, c=map(int, input().split())
    if table[b]!=0:
        cnt=table[b]
        table[c]+=cnt
        ans=S+(cnt*(c-b))
        results.append(ans)
        table[b]=0
        S=ans
    else:
        results.appned(S)

for result in results:
    print(result)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
q=int(input())

S=sum(a)

table=[0]*(10**5)

for i in range(n):
    table[a[i]]+=1

for i in range(q):
    b, c=map(int, input().split())
    if table[b]!=0:
        cnt=table[b]
        table[c]+=cnt
        ans=S+(cnt*(c-b))
        print(ans)
        table[b]=0
        S=ans
    else:
        print(S)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
q=int(input())

S=sum(a)

table=[0]*(10**5)

for i in range(n):
    table[a[i]]+=1

for i in range(q):
    b, c=map(int, input().split())
    if table[b]!=0:
        cnt=table[b]
        table[c]+=cnt
        ans=S+(cnt*(c-b))
        print(ans)
        table[b]=0
        S=ans
    else:
        print(S)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
q=int(input())

S=sum(a)

table=[0]*(10**5)

for i in range(n):
    table[i]+=1

for i in range(q):
    b, c=map(int, input().split())

    cnt=table[b]
    table[c]+=cnt
    ans=S+(cnt*(c-b))
    print(ans)
    table[b]=0
    S=ans
Problem p02718 (python)

Fixed submission:
N, M = map(int, input(). split())
A = list(map(int, input().split()))
A.sort()
S = sum(A)
         
if 1/(4*M) <= A[N-M]/S :
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input(). split())
A = list(map(int, input().split())
A.sort()
S = sum(A)
         
if 1/(4*M) <= A[N-M]/S :
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input(). split())
A = list(map(int, input().split())
A.sort()
S = sum(A)
         
if 1/(4M) <= A[N-M]/S :
	print("YES")
else:
	print("NO")
Problem p02719 (python)

Fixed submission:
N, K=map(int, input().split())
min=min(N%K, abs((N%K)-K))
print(min)

Buggy submission (verdict: Runtime Error):
N,K =int(input().split())
print(min(N%K, abs((N%K)-K)))

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

while N-K >= 0:
	num1 = N-K
	N = N-K
    
num2 = abs(num1-K)
if num1 < num2:
  print(num1)
else:
  print(num2)
Problem p02730 (python)

Fixed submission:
S=input()
N=len(S)
cnt=0
cnt1=0
cnt2=0
for i in range (N):
    if S[i]==S[N-1-i]:
        cnt+=1

if cnt==N:
    for j in range((N-1)//2):
        if  S[j]==S[(N-1)//2 -1-j]:
            cnt1+=1
    if cnt1==(N-1)//2:
        for k in range((N-1)//2):
            if S[(N+3)//2 -1+k]==S[N-1-k]:
                cnt2+=1
    else:
        print("No")
        exit()
    if cnt2==(N-1)//2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S=input()
N=len(S)
cnt=0
cnt1=0
cnt2=0
for i in range (N):
    if S[i]==S[N-1-i]:
        cnt+=1
 
if cnt==N:
    for j in range((N-1)//2):
        if  S[j]==S[(N-1)//2 -1-j]:
            cnt1+=1
    if cnt1==(N-1)//2:
        for k in range((N-1)//2):
            if S[(N+3)//2 -1+k]==S[N-1-k]:
                cnt2+=1
    else:
        print("No")
		exit()
    if cnt2==(N-1)//2:
        print("Yes")
    else:
        print("No")
else:
    print("No")