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

Fixed submission:
s = input()
ans = 0
i = 0
j = len(s) - 1
while i <= j:
    if s[i] != s[j]:
        ans += 1
    i += 1
    j -= 1
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
 
ans = 0
for i in range(len(s)):
  for j in list(range(len(s)))[::-1]:
    if j < i:
      return ans
    else:
      if s[i] != s[j]:
        ans += 1

Buggy submission (verdict: Runtime Error):
s = input()

ans = 0
for i in range(len(s)):
  for j in list(range(len(s)))[::-1]:
    if j < i:
      return ans
    else:
      if s[i] != s[j]:
        ans += 1
Problem p02771 (python)

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

if A==B and B==C or A!=B and B!=C and C!=A:
    print('No')
else:
    print('Yes')

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

if A==B and B==C or A!=B and B!=C and C!=A:
    print('No')
else
    print('Yes')
Problem p02847 (python)

Fixed submission:
S=input()

if S=="SUN":
    print('7')
elif S=="MON":
    print('6')
elif S=="TUE":
    print('5')
elif S=="WED":
    print('4')
elif S=="THU":
    print('3')
elif S=="FRI":
    print('2')
elif S=="SAT":
    print('1')

Buggy submission (verdict: Runtime Error):
S=input()

if S=="SUN":
    print('7')
elif S=="MON":
    print('6')
elif S=="TUE":
    print('5')
elif S=="WED":
    print('4')
elif S=="THU":
    print('3')
elif S=="FRI":
    print('2
elif S=="SAT":
    print('1')
Problem p02912 (python)

Fixed submission:
N,M,=input().split()  #複数数値入力　「A B」みたいなスペース空いた入力のとき

N=int(N)
M=int(M)

A=list(map(int, input().split()))

a=[]
for n in range(N):
    a.append(int(A[n]) * (-1))

import heapq
import math

heapq.heapify(a)
for m in range(M):
    heapq.heappush(a,math.ceil(heapq.heappop(a)/2))   
    
print(sum(a)*(-1))

Buggy submission (verdict: Runtime Error):
N,M,*A=input().split()  

N=int(N)
M=int(M)
a=[]
for n in range(N):
    a.append(int(A[n]) * (-1))

import heapq
import math

heapq.heapify(a)
for m in range(M):
    heapq.heappush(a,math.ceil(heapq.heappop(a)/2))   
    
print(sum(a)*(-1))

Buggy submission (verdict: Runtime Error):
N=int(N)
M=int(M)
a=[]
for n in range(N):
    a.append(int(A[n]) * (-1))

import heapq
import math

heapq.heapify(a)
for m in range(M):
    heapq.heappush(a,math.ceil(heapq.heappop(a)/2))   
    
print(sum(a)*(-1))
Problem p02935 (python)

Fixed submission:
import math
import heapq

N=int(input())
V=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

heapq.heapify(V)
a=heapq.heappop(V)
b=0
for i in range(len(V)):
    b=heapq.heappop(V)
    a=(a+b)/2

print(a)

Buggy submission (verdict: Runtime Error):
import math
import heapq

N=int(input[0])
V=list(map(int, input[1].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

heapq.heapify(V)
a=heapq.heappop(V)
b=0
for i in range(len(V)):
    b=heapq.heappop(V)
    a=(a+b)/2

print(a)
Problem p03077 (python)

Fixed submission:
import math
import heapq
import sys
from collections import Counter
import numpy as np
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

#N,K=map(int, input[0].split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input[1].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
#s = [input() for i in range(3)]

N=int(input())
n=[]
n.append(int(input()))
n.append(int(input()))
n.append(int(input()))
n.append(int(input()))
n.append(int(input()))

print(4+math.ceil(N/min(n)))

Buggy submission (verdict: Runtime Error):

N=int(input())
n=[]
n.append(int(input())
n.append(int(input())
n.append(int(input())
n.append(int(input())
n.append(int(input())

print(5+N//min(n))
Problem p03307 (python)

Fixed submission:
import math
import fractions
import heapq
import sys
import re
from collections import Counter
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

#N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

N=int(input())
print((2*N)//fractions.gcd(2,N))

Buggy submission (verdict: Runtime Error):
import math
import heapq
import sys
import re
from collections import Counter
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

#N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

N=int(input())
print((2*N)//math.gcd(2,N))

Buggy submission (verdict: Runtime Error):
import math
import heapq
import sys
import re
from collections import Counter
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

#N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

N=int(input())
print((2*N)//math.gcd(2,N))

Buggy submission (verdict: Runtime Error):
import math
import heapq
import sys
import re
from collections import Counter
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

#N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき


N=int(input())

print((2*N)//math.gcd(2,N))

Buggy submission (verdict: Runtime Error):
import math
import heapq
import sys
import re
from collections import Counter
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

#N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

N=int(input())

print(lcm(2,N))
Problem p03803 (python)

Fixed submission:
import math

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

if A==1:
    A=14
if B==1:
    B=14
    
if A>B:
    print('Alice')
elif A<B:
    print('Bob')
else:
    print('Draw')

Buggy submission (verdict: Runtime Error):
import math

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

if A==1:
    A=14
if B==1:
    B=14
    
if A>B:
    print('Alice')
elif A<B:
    if b=='H':
        print('Bob')
    else:
        print('Draw')
Problem p02754 (python)

Fixed submission:
inp = input().split()
inp = [int(i) for i in inp]
N, A, B = inp
ans = (N//(A+B))*A
rem = N%(A+B)
ans += min(rem, A)
print(ans)

Buggy submission (verdict: Runtime Error):
N A B = tuple(input().split())
print((N // (A + B)) * A + N % (A + B))
Problem p03242 (python)

Fixed submission:
N=int(input())
n=list(map(int,str(N)))
for i in range(3):
    if n[i]==1:
        n[i]=9
    elif n[i]==9:
        n[i]=1
print(n[0]*100+n[1]*10+n[2])

Buggy submission (verdict: Runtime Error):
N,x=map(int,input().split())
l=list(map(int,input().split()))
ans=0
l.sort()

for n in range(N):
    if n!=N-1:
        if l[n]<x:
            x-=l[n]
            ans+=1
        elif l[n]==x:
            x-=l[n]
            ans+=1
            break
        else:
            break
    else:
        if l[n]==x:
            x-=l[n]
            ans+=1
        else:
            break

print(ans)
Problem p02753 (python)

Fixed submission:
a=input()
p1=a[-1]
p2=a[0]
p3=a[1]
 
if p1==p2==p3:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a=input()
p1=a[0]
p2=a[1]
p3=a[3]
 
if p1==p2==p3:
 print("No")
else:
 print("Yes")

Buggy submission (verdict: Runtime Error):
a=input()
p1=a[0]
p2=a[1]
p3=a[3]
 
if p1==p2==p3:
	print("No")
else:
	print("Yes")

Buggy submission (verdict: Runtime Error):
a=input()
p1=a[0]
p2=a[1]
p3=a[3]

if p1==p2==p3:
  print("No")
else:
  print("Yes")
Problem p02754 (python)

Fixed submission:
# coding:utf-8


from math import floor

import numpy as np

strInput = input()
N, A, B = np.array(strInput.split(' ')).astype(int)
numGroup = floor(N / (A + B))
numExtendBall = N % (A + B)
if numExtendBall >= A:
    numExtendBlueBall = A
else:
    numExtendBlueBall = numExtendBall
print(numGroup * A + numExtendBlueBall)

Buggy submission (verdict: Runtime Error):
# coding:utf-8


from math import ceil

import numpy as np

strInput = input()
N, A, B = np.array(strInput.split(' ')).astype(int)
numGroup = floor(N / (A + B))
numExtendBall = N % (A + B)
if numExtendBall >= A:
    numExtendBlueBall = A
else:
    numExtendBlueBall = numExtendBall
print(numGroup * A + numExtendBlueBall)

Buggy submission (verdict: Runtime Error):
# coding:utf-8


import numpy as np

strInput = input()
N, A, B = np.array(strInput.split(' ')).astype(int)
lsStrBall = []
while True:
    lsStrBall += ['b'] * A
    lsStrBall += ['r'] * B
    if len(lsStrBall) >= N:
        break

arrStrBall = np.array(lsStrBall)
print((arrStrBall[:N] == 'b').sum())
Problem p02753 (python)

Fixed submission:
n = input()
s = list(n)
if len(set(s)) == 1:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
n = list(map(input().split()))
if len(set(n)) == 1:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
n = list(map(input().split()))
if len(set(n)) == 2:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
n = list(map(input().split()))
if len(set(n)) == 3:
    print("No")
else:
    print("Yes")
Problem p02759 (python)

Fixed submission:
n = int(input())
if n % 2 == 1:
  print(int((n+1) / 2))
  exit(0)
print(int(n/2))

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 1:
  print (n-1) /2
print(n/2)
Problem p02771 (python)

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

Buggy submission (verdict: Runtime Error):
n = list(map(int, input().split()))
if n[0] == n[1]:
    if n[0] == n[2]:
    print("Yes")
print("No")

Buggy submission (verdict: Runtime Error):
n = list(map(int, input().split()))
if n[0] !== n[1]:
    print("Yes")
    exit(0)
if n[0] !== n[2]:
    print("Yes")
    exit(0)
print("No")

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

Fixed submission:
s,t = input().split()
sa,tb = map(int,input().split())
u = input()
if u == s:
    sa -= 1
else:
    tb -= 1
print(sa,tb)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
sa,tb = map(int,input())
u = input()
if u == s:
    sa -= 1
else:
    tb -= 1
print(sa,tb)
Problem p02948 (python)

Fixed submission:
import heapq

n,m=map(int,input().split())
L=[[] for _ in range(m)]
for _ in range(n):
        a,b=map(int,input().split())
        if a<=m:
                L[a-1].append(-b)
h=[]
heapq.heapify(h)

ans=0
for i in range(m):
        for j in L[i]:
                heapq.heappush(h,j)
        if len(h)==0:
                continue
        ans+=heapq.heappop(h)*(-1)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[['0']*10 for _ in range(n)]
for i in range(n):
        a=str(input())
        for j in range(10):
                l[i][j]=a[j]
        l[i].sort()
l.sort()

c=0
d=[]
for j in range(n-1):
        if l[j]==l[j+1] and j==n-2:
                c+=2
                d.append(c)
        elif l[j]==l[j+1]:
                c+=1
        else:
                c+=1
                d.append(c)
                c=0
aa=0
for k in range(len(d)):
        aa+=d[k]*(d[k]-1)//2
print(aa)
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
a=[-1]
for i in range(m):
    s=int(input())
    a.append(s)  
a.append(n+1)
if 1 in a:
    a=a[1:]
if n-1 in a:
    a=a[:-1]
b=[]
for i in range(len(a)-1):
    b.append(a[i+1]-a[i]-2)
l=[1,1,2]
for i in range(3,n+1):
    l.append(l[i-2]+l[i-1])
ans=1
#print(a,b,l)
for i in range(len(b)):
    if b[i]<0:
        print(0)
        break
    else:
        ans*=l[b[i]]%1000000007
else:
    print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
import sys
imput=sys.stdin.readline
n,m=map(int,input().split())
l=[0]*m
for i in range(m):
    l[i]=int(input())
#print(l)
dp=[0]*(n+1)
dp[0]=1
if l[0]!=1:
    dp[1]=1
for i in range(2,n+1):
    if i in l:
        dp[i]=0
    else:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%1000000007)

Buggy submission (verdict: Runtime Error):
import sys
imput=sys.stdin.readline
n,m=map(int,input().split())
l=[0]*m
for i in range(m):
    l[i]=int(input())
#print(l)
dp=[0]*(n+1)
dp[0]=1
if l[0]!=1:
    dp[1]=1
for i in range(2,n+1):
    if i in l:
        dp[i]=0
    else:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%1000000007)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[]
for _ in range(m):
    l.append(int(input()))
#print(l)
dp=[0]*(n+1)
dp[0]=1
if l[0]!=1:dp[1]=1
for i in range(2,n+1):
    if i in l:
        dp[i]=0
    else:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%1000000007)
Problem p03053 (python)

Fixed submission:
from collections import deque
h,w=map(int,input().split())
p=[list("#"*(w+2))]+[list("#"+input()+"#") for i in range(h)]+[list("#"*(w+2))]
q=deque([])
for i in range(1,h+1):
	for j in range(1,w+1):
		if p[i][j]=='#':
			p[i][j]=0
			q.append([i,j])
d=[(1,0),(-1,0),(0,1),(0,-1)]
while q:
	x,y=q.popleft()
	for dx,dy in d:
		if p[x+dx][y+dy]==".":
			p[x+dx][y+dy]=p[x][y]+1
			q.append([x+dx,y+dy])
ans=0
for i in range(1,h+1):
	for j in range(1,w+1):
		ans=max(ans,p[i][j])
print(ans)

Buggy submission (verdict: Runtime Error):
import copy
h,w=map(int,input().split())
a=[list("."*(w+2))]+[list("."+input()+".") for i in range(h)]+[list("."*(w+2))]
b=copy.deepcopy(a) 
#print(a,b)
for k in range(h+w-2):
    for i in range(1,h+1):
        for j in range(1,w+1):
            if a[i][j]=='#':
                b[i-1][j]='#'
                b[i+1][j]='#'
                b[i][j-1]='#'
                b[i][j+1]='#'
    #print(a,b)
    if a==b:
        break
    else:
        a=copy.deepcopy(b) 
print(k-1)
Problem p02753 (python)

Fixed submission:
args = input()
if 'A' in args:
  if 'B' in args:
    print('Yes')
    exit()
print('No')

Buggy submission (verdict: Runtime Error):
  args = input()
  print(args)
  if 'A' in args:
    if 'B' in args:
      print('Yes')
      exit()
  print('No')

Buggy submission (verdict: Runtime Error):
args = input()
if 'A' not in args:
  print('No')
  return
if 'B' not in args:
  print('No')
  return
print('yes')
Problem p02773 (python)

Fixed submission:
n = int(input())
d = {}
for i in range(n):
    s = input()
    d[s] = d[s]+1 if (s in d) else 1
d_sorted = sorted(d.items(), key=lambda x:x[1], reverse=True)
m = d_sorted[0][1]
result = []
for i in d_sorted:
    if i[1]!=m:
        break
    result.append(i[0])
print(*sorted(result), sep='\n')

Buggy submission (verdict: Runtime Error):
n = int(input())
d = {}
for i in range(n):
    s = input()
    d[s] = d[s]+1 if (s in d) else 1
d_sorted = sorted(d.items(), key=lambda x:x[1], reverse=True)
m = d_sorted[0][1]
result = []
for i in range(n):
    if d_sorted[i][1]!=m:
        break
    result.append(d_sorted[i][0])
print(*sorted(result), sep='\n')

Buggy submission (verdict: Runtime Error):
n = int(input())
d = {}
for i in range(n):
    s = input()
    d[s] = d[s]+1 if (s in d) else 1
d_sorted = sorted(d.items(), key=lambda x:x[1], reverse=True)
m = d_sorted[0][1]
for i in range(n):
    if d_sorted[i][1]!=m:
        break
    print(d_sorted[i][0])
Problem p02753 (python)

Fixed submission:
x = set(input())
print('No' if len(x)==1 else 'Yes')

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if a==0:
    print(0)
else :
    x = n/(a+b)
    y =n%(a+b)
    print(x*a+y)
Problem p02759 (python)

Fixed submission:
import math
n = int(input())
print(math.ceil(n/2))

Buggy submission (verdict: Runtime Error):
n = int(input())
print(n\\2)
Problem p02771 (python)

Fixed submission:
List= list(map(int,input().split()))
List=set(List)
if len(List)==2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
for i in range(a):
    if i%2==0:
        if i%3 !=0 or i%5 !=0:
            print('DENIED')
print('APPROVED')

Buggy submission (verdict: Runtime Error):
List= list(int,input().split())
List=set(List)
if len(List)==2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
List= sorted(list(int,input().split()))
if len(List)==2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
List= sorted(int,input().split())
if len(List)==2:
    print('Yes')
else:
    print('No')
Problem p03207 (python)

Fixed submission:
n = int(input())
p = [int(input()) for i in range(n)]
print(sum(p)-max(p)//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = [int(input()).for i in range(n)]
print(sam(p)-p[-1]/2)
Problem p03315 (python)

Fixed submission:
n = input()
s = n.count('+') - n.count('-')
print(s)

Buggy submission (verdict: Runtime Error):
n = input()
s = n.count(+) - n.count(-)
print(s)
Problem p03834 (python)

Fixed submission:
a,b,c=input().split(",")
print(a,b,c)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(b,a)
Problem p02753 (python)

Fixed submission:
S = input()
if S[0] == S[1] == S[2] :
  print("No")
else :
  print("Yes")

Buggy submission (verdict: Runtime Error):
S = input()
S_list = [S]
if S_list[1] == S_list[2] == S_list[3] :
  print("No")
else :
  print("Yes")

Buggy submission (verdict: Runtime Error):
S = input()
S_list = [S]
if S_list[1] = S_list[2] = S_list[3] :
  print("No")
else :
  print("Yes")
Problem p02897 (python)

Fixed submission:
N = int(input())
a = 0
for i in range(1,N+1) :
  if i%2 == 1 :
    a += 1
print(a/N)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = 0
for i in range(1,N+1) :
  if i%2 = 1 :
    a += 1
print(a/N)
Problem p03072 (python)

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

cnt = 0
for i in range(len(H)):
    if (max(H[0:i+1]) == H[i]):
        cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
num = 1
num1 = 0
N = input()
H = list(map(int, input().split())
for i in range(1,N) :
  if H[i] >= H[i-1] :
    num += 1
  else :
    num1 += 1
print(a)

Buggy submission (verdict: Runtime Error):
num = 1
num1 = 0
N = int(input())
H = list(map(int, input.split())
for i in range(1,N):
  if H[i] >= H[i-1]:
    num += 1
  else :
    num1 += 1
print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input.split())
a = 1
f = 0
for i in range(1 , N):
  if H[i] > H[i-1] :
         a += 1
  else :
         f += 1
print(a)

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

Fixed submission:
N = int(input())
monster = list(map(int, input().split()))
def gcd(a, b):
	if b > 0 :
		return gcd(b, a % b)
	else:
		return a
if len(monster) == 1 :
	print(monster[0])
else:
	mon = gcd(monster[0], monster[1])
	if len(monster) != 2 :
		for i in range(2, N) :
			mon = gcd(mon, monster[i])
print(mon)

Buggy submission (verdict: Runtime Error):
N = int(input())
monsters = list(map(int, input().split()))
def gcd(a, b):
	if b > 0 :
      return gcd(b , a % b)
    else :
      return x
if len(monster) == 1 :
	print(monster[0])
else :
    mon = gcd(monster[0], monster[1])
    if len(monster) >= 2
    for i in range(2 , N) :
      mon = gcd(mon, monster[i])
print(mon)
Problem p03327 (python)

Fixed submission:
N=int(input())
if N <= 999 :
  print("ABC")
else :
  print("ABD")

Buggy submission (verdict: Runtime Error):
N=int(input())
if N < 1000 :
  print(f"ABC{N}")
else :
  n = N - 999
  print(f"ABD{n})
Problem p02753 (python)

Fixed submission:
if len(set(input())) == 2:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
if set(input()) == 2:
	print('yes')
else
	print('No')
Problem p03108 (python)

Fixed submission:
n,m = map(int,input().split())
ab = [[int(i) for i in input().split()]for j in range(m)][1:]
ans = [0]*(m-1)+[int(n*(n-1)/2)]
l = [i for i in range(1,n+1)]
s = {i:1 for i in range(1,n+1)}
 
def serch_l(num):
  if l[num]==num+1:
    return l[num]
  else:
    leader = serch_l(l[num]-1)
    l[num]=leader
    return leader
    
for k,i in enumerate(ab[::-1]):
  k = m-1-k
  l_a,l_b = serch_l(i[0]-1),serch_l(i[1]-1)
  if l_a==l_b:
    ans[k-1]=ans[k]
  else:
    
    s_a,s_b = s[l_a],s[l_b]
    
    if s_a > s_b:
      (s_a,s_b) = (s_b,s_a)
      (l_a,l_b) = (l_b,l_a)
    c = s_a*s_b
    s[l_b]+=s_a
    s[l_a]=0
    l[l_a-1]=l_b
    ans[k-1]=ans[k]-c
for i in ans:
  print(i)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
ab = [[int(i) for i in input().split()]for j in range(m)][1:]
ans = [0]*(m-1)+[int(n*(n-1)/2)]
l = [i for i in range(1,n+1)]
s = {i:1 for i in range(1,n+1)}

def serch_l(num):
  if l[num]==num+1:
    return l[num]
  else:
    leader = serch_l(l[num]-1)
    l[num]=leader
    return leader
    

for k,i in enumerate(ab[::-1]):
  k = m-1-k
  
  if l[i[0]-1] == l[i[1]-1]:
    ans[k-1]=ans[k]
  else:
    l_a,l_b = serch_l(i[0]-1),serch_l(i[1]-1)
    s_a,s_b = s[l_a],s[l_b]
    
    if s_a > s_b:
      (s_a,s_b) = (s_b,s_a)
    c = s_a*s_b
    s[l_b]+=s_a
    s[l_a]=0
    l[l_a-1]=l_b
    ans[k-1]=ans[k]-c
for i in ans:
  print(i)
Problem p02754 (python)

Fixed submission:
N,A,B = map(int,input().split())
syou = N//(A+B)
amari = N%(A+B)
ans = A*syou + min(A,amari)
print(ans)

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
string = ''
for i in range(N//(A+B)+A+B):
  string += 'b'*A
  string += 'r'*B
  if len(string) >= N:
    break
str2 = string[0:N]
cnt = str2.count('b')
print(cnt)

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
string = ''
for i in range(10**100):
  string += 'b'*A
  string += 'r'*B
  if len(string) >= N:
    break
str2 = string[0:N]
cnt = str2.count('b')
print(cnt)
Problem p02880 (python)

Fixed submission:
N = int(input())
message = 'No'
for i in range(1,10):
  if N%i==0 and N/i<10 :
    message = 'Yes'
    break
print(message)

Buggy submission (verdict: Runtime Error):
N = map(int, input())
message = 'No'
for i in range(1,10):
  if N % i == 0 and N/i < 10 :
    message = 'Yes'
    break
print(message)
Problem p02881 (python)

Fixed submission:
N = int(input())
import math 
yakusuu_list = []
for i in range (int(math.sqrt(N)),0,-1):
  if N % i == 0:
    yakusuu = i
    break
print(i+ N//i -2)

Buggy submission (verdict: Runtime Error):
N = int(input())
yakusuu_list = []
for i in range (1,N+1):
  if N % i == 0:
    yakusuu_list.append([i,N/i])
kyori_list =[]
for a in yakusuu_list:
  [i,j] = a
  kyori_list.append(i+j-2)
print(min(kyori_list)

Buggy submission (verdict: Runtime Error):
N = int(input())
yakusuu_list
for i in range (1,N+1):
  if N % i == 0:
    yakusuu_list.append([i,N/i])
kyori_list =[]
for a in yakusuu_list:
  [i,j] = a
  kyori_list.append(i+j-2)
print(min(kyori_list)
Problem p02753 (python)

Fixed submission:
s = input()
if s == 'AAA' or s == 'BBB':
    print('No')
else:
    print('Yes')

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

ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem,A)
print(ans)
Problem p02916 (python)

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

sat = sum(B)
for i in range(N-1):
    if A[i]+1==A[i+1]:
        sat += C[A[i]-1]
print(sat)

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

sat = sum(B)
for i in range(N-1):
    if A[i]+1==A[i+1]:
        sat += C[A[i-1]]
print(sat)
Problem p03307 (python)

Fixed submission:
N = int(input())
if N%2==0:
  print(N)
else:
  print(N*2)

Buggy submission (verdict: Runtime Error):

def fact(n):
  if 1<n:
    return n + fact(n-1)
  else:
    return n


N = int(input())
A = list(map(int,input().split()))
b = int(round(float((sum(A)-fact(N)))/N))
if b<0:
    b -= 1

ans = 0

for i in range(N):
    ans += abs(A[i]-(b+i+1))

print(ans)