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

Fixed submission:
def main():
    n, m = map(int, input().split())
    g = [[] for _ in range(n)]
    for _ in range(m):
        u, v = map(lambda x: int(x) - 1, input().split())
        g[u].append(v)
        g[v].append(u)

    vis = [False] * n
    ans = dfs(0, g, vis, 0)

    print(ans)


def dfs(v, g, vis, count):
    vis[v] = True

    if all(vis):
        return count + 1

    for i in g[v]:
        if vis[i]:
            continue
        count = dfs(i, g, vis, count)
        vis[i] = False

    return count


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    _, __ = map(int, input().split())
    ___ = [[] for _ in range(_)]
    for _ in range(__):
        ____, _____ = map(lambda ______: int(_____) - 1, input().split())
        ___[____].append(_____)
        ___[_____].append(____)

    _______ = [False] * _
    ________ = ___________(0, ___, _______, 0)

    print(________)


def ___________(_____, ___, _______, _________):
    _______[_____] = True
    if all(_______):
        return _________ + 1

    for __________ in ___[_____]:
        if _______[__________]:
            continue
        _________ = ___________(__________, ___, _______, _________)
        _______[__________] = False

    return _________


if __name__ == '__main__':
    main()
Problem p02580 (python)

Fixed submission:
from bisect import bisect_left, bisect_right

def exists(ite, x):
	return bool(bisect_right(ite, x) - bisect_left(ite, x))

H, W, M = map(int,input().split())
targets = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

cnth = [0] * H
cntw = [0] * W
wlist = [[] for i in range(H)]

for i in range(M):
	hi, wi = targets[i]
	cnth[hi] += 1
	cntw[wi] += 1
	wlist[hi].append(wi)

maxhi = []
maxwi = []
maxh = max(cnth)
maxw = max(cntw)

for i in range(H):
	wlist[i].sort()
	if cnth[i] == maxh:
		maxhi.append(i)
for i in range(W):
	if cntw[i] == maxw:
		maxwi.append(i)

for i in range(len(maxhi)):
	for j in range(len(maxwi)):
		if not exists(wlist[maxhi[i]], maxwi[j]):
			print(maxh + maxw)
			exit()
print(maxh + maxw - 1)

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

H, W, M = map(int,input().split())
targets = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

cnth = [0] * H
cntw = [0] * W
wlist = [[] for i in range(H)]

for i in range(M):
	hi, wi = targets[i]
	cnth[hi] += 1
	cntw[wi] += 1
	wlist[hi].append(wi)

maxhi = []
maxwi = []
maxh = max(cnth)
maxw = max(cntw)

for i in range(H):
	wlist[i].sort()
	if cnth[i] == maxh:
		maxhi.append(i)
for i in range(W):
	if cntw[i] == maxw:
		maxwi.append(i)

for i in range(len(maxhi)):
	for j in range(len(maxwi)):
		if bisect_right(wlist[maxhi[i]], maxwi[j]) - bisect_left(wlist[maxhi[i]], maxwi[j]) == :
			print(maxh + maxw)
			exit()
print(maxh + maxw - 1)
Problem p02594 (python)

Fixed submission:
#

import sys
input=sys.stdin.readline

def main():
    X=int(input())
    if X>=30:
        print("Yes")
    else:
        print("No")
    
    
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
#

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

def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    sumA=sum(A)
    K_i=[int(A[i]/sumA*(K+N)-1) for i in range(N)]
    dA=[A[i]/(K_i[i]+1) for i in range(N)]
    res=K-sum(K_i)
    b=[]
    for i in range(N):
        b.append([dA[i],i])
    b.sort(reverse=True)
    now=0
    for i in range(res):
        K_i[b[now][1]]+=1
        dA[b[now][1]]=A[b[now][1]]/(K_i[b[now][1]]+1)
        if dA[b[now][1]]<b[now+1][0]:
            now+=1
    
    maxi=dA.index(max(dA))
    print(ceil(A[maxi]/(K_i[maxi]+1)))
    
    
    
if __name__=="__main__":
    main()
Problem p02596 (python)

Fixed submission:
#

import sys
input=sys.stdin.readline

def main():
    K=int(input())
    rsum=0
    r=7
    for i in range(10**6+1):
        rsum=(rsum+r)%K
        r=(r*10)%K
        if rsum==0:
            print(i+1)
            exit()
    print(-1)
    
    
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
#

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

def main():
    K=int(input())
    if K%2==0:
        print(-1)
        exit()
    if K==5:
        print(-1)
    s=set()
    r=7%K
    rsum=r
    s.add(r)
    for i in range(10**6):
        if rsum==0:
            print(i+1)
            exit()
        r=(r*10)%K
        if r in s:Q
            break
        s.add(r)
        rsum=(rsum+r)%K
    print((i+1)*K/gcd(rsum,K))
    
    
    
if __name__=="__main__":
    main()
Problem p02659 (python)

Fixed submission:
a,b=input().split()
a=int(a)
b=list(b)
b=[int(b[0]),int(b[2]),int(b[3])]
c=(a*b[0]*100+a*b[1]*10+a*b[2])//100
print(c)

Buggy submission (verdict: Runtime Error):
a,b=input().split()
a=int(a)
b=list(b)
b=[int(b[0]),int(b[2]),int(b[3])]
c=a*b[0]+a*b[2]//10+a*b[3]//100
print(c)

Buggy submission (verdict: Runtime Error):
a,b=input().split()
a=int(a)
b=list(b)
b=[b[0],b[2],b[3]]
c=a*b[0]+a*b[2]//10+a*b[3]//100
print(c)

Buggy submission (verdict: Runtime Error):
a,b=map(input().split())
a=int(a)
b=list(b)
b=[b[0],b[2],b[3]]
c=a*b[0]+a*b[2]//10+a*b[3]//100
print(c)

Buggy submission (verdict: Runtime Error):
a,b=input().split()
a0=a//(10**9)
a1=a-a0*10**9
b*=100
print((a0*b*10**9+a1*b)//100)
Problem p02679 (python)

Fixed submission:
from math import gcd
from bisect import bisect_left, bisect_right

MOD = 10 ** 9 + 7
pow2 = [1] * (2 * 10 ** 5 + 1)
for i in range(1, 2 * 10 ** 5 + 1):
	pow2[i] = (pow2[i - 1] * 2) % MOD

N = int(input())
zero = 0
iwasies = []
for i in range(N):
	A, B = map(int, input().split())
	if A == 0 and B == 0:
		zero += 1
	elif A == 0:
		iwasies.append((0, 1))
	elif B == 0:
		iwasies.append((1, 0))
	else:
		g = gcd(A, B)
		A //= g
		B //= g
		if A < 0:
			iwasies.append((-A, -B))
		else:
			iwasies.append((A, B))

numiwasi = len(iwasies)
iwasies.sort()
badpairs = set()
for i in range(numiwasi):
	A, B = iwasies[i]
	abcount = bisect_right(iwasies, (A, B)) - bisect_left(iwasies, (A, B))
	
	Ao, Bo = B, -A
	if Ao < 0:
		Ao, Bo = -Ao, -Bo
	
	aobocount = bisect_right(iwasies, (Ao, Bo)) - bisect_left(iwasies, (Ao, Bo))
	
	if aobocount > 0:
		if (A, B) < (Ao, Bo):
			badpairs.add(((A, B, abcount), (Ao, Bo, aobocount)))
		else:
			badpairs.add(((Ao, Bo, aobocount), (A, B, abcount)))

sociable = numiwasi
ans = 1

for bp in badpairs:
	count1 = bp[0][2]
	count2 = bp[1][2]
	sociable -= (count1 + count2)
	ans = (ans * (pow2[count1] + pow2[count2] - 1)) % MOD
ans = (ans * pow2[sociable]) % MOD

print((ans + zero - 1) % MOD)

Buggy submission (verdict: Runtime Error):
from math import gcd
from bisect import bisect_left, bisect_right

MOD = 10 ** 9 + 7
pow2 = [1] * (2 * 10 ** 5 + 1)
for i in range(1, 2 * 10 ** 5 + 1):
	pow2[i] = (pow2[i - 1] * 2) % MOD

N = int(input())

iwasies = []
for i in range(N):
	A, B = map(int, input().split())
	if A == 0 and B == 0:
		continue
	elif A == 0:
		iwasies.append((0, 1))
	elif B == 0:
		iwasies.append((1, 0))
	else:
		g = gcd(A, B)
		A //= g
		B //= g
		if A < 0:
			iwasies.append((-A, -B))
		else:
			iwasies.append((A, B))

iwasies.sort()
badpairs = set()
for i in range(N):
	A, B = iwasies[i]
	abcount = bisect_right(iwasies, (A, B)) - bisect_left(iwasies, (A, B))
	
	Ao, Bo = B, -A
	if Ao < 0:
		Ao, Bo = -Ao, -Bo
	
	aobocount = bisect_right(iwasies, (Ao, Bo)) - bisect_left(iwasies, (Ao, Bo))
	
	if aobocount > 0:
		if (A, B) < (Ao, Bo):
			badpairs.add(((A, B, abcount), (Ao, Bo, aobocount)))
		else:
			badpairs.add(((Ao, Bo, aobocount), (A, B, abcount)))

numiwasi = len(iwasies)
sociable = numiwasi
ans = 1

for bp in badpairs:
	count1 = bp[0][2]
	count2 = bp[1][2]
	sociable -= (count1 + count2)
	ans = (ans * (pow2[count1] + pow2[count2] - 1)) % MOD
ans = (ans * pow2[sociable]) % MOD

print(ans - 1)
Problem p02793 (python)

Fixed submission:
#

import sys
from fractions import gcd
input=sys.stdin.readline

def main():
    MOD=10**9+7
    N=int(input())
    A=list(map(int,input().split()))
    if N==1:
        print(1)
        exit()
    l=(A[0]*A[1])//gcd(A[0],A[1])
    for i in range(2,N):
        l=(l*A[i])//gcd(A[i],l-A[i])
    l%=MOD
    ans=0
    for i in range(N):
        ans+=l*pow(A[i],MOD-2,MOD)
        ans%=MOD
    print(ans)
    
    
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
#

import sys
input=sys.stdin.readline

MOD=10**9+7
            
def main():
    N=int(input())
    A=list(map(int,input().split()))
    if N==1:
        print(1)
        exit()
    kl=[0]*(10**6+1)
    for j in range(N):
        n=A[j]
        for i in range(2,int((n)**0.5)+1):
            if n%i==0:
                cnt=0
                while(n%i==0):
                    n/=i
                    cnt+=1
                if kl[i]<cnt:
                    kl[i]=cnt
        if n!=1:
            if kl[n]<1:
                kl[n]=1
                
    lcm=1
    for i in range(2,10**6+1):
        lcm*=i**kl[i]
        lcm%=MOD
    ans=0
    for i in range(N):
        ans+=lcm*pow(A[i],MOD-2,MOD)
        ans%=MOD
    print(ans)
    
    
    
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
#

import sys
input=sys.stdin.readline

MOD=10**9+7
            
def main():
    N=int(input())
    A=list(map(int,input().split()))
    if N==1:
        print(1)
        exit()
    kl={}
    for j in range(N):
        n=A[j]
        for i in range(2,int((n)**0.5)+1):
            if n%i==0:
                cnt=0
                while(n%i==0):
                    n/=i
                    cnt+=1
                if kl.get(i,"a")=="a" or kl[i]<cnt:
                    kl[i]=cnt
        if n!=1:
            if kl.get(n,"a")=="a" or kl[n]<cnt:
                kl[n]=cnt
                
    lcm=1
    for a,b in kl.items():
        lcm*=a**b
        lcm%=MOD
    ans=0
    for i in range(N):
        ans+=lcm*pow(A[i],MOD-2,MOD)
        ans%=MOD
    print(ans)
    
    
    
if __name__=="__main__":
    main()
Problem p02578 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
h = a[0]
ans = 0           
for i in range(1,n):
  if a[i] > h:
    h = a[i]
  else:
    ans += h - a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
max_a = max(a)
max_b = max(b)
ans = max_a - max_b
print(ans)
Problem p02594 (python)

Fixed submission:
n = int(input())
if(n >= 30):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
if(x >= 30):
  print('Yes')
else:
  print('No')
Problem p02622 (python)

Fixed submission:
s = input()
t = input()
a = [c for c in s]
b = [d for d in t]
ans = 0
for i in range(len(a)):
  if(a[i] != b[i]):
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
s = input()
a = [int(c) for c in s]
b = [int(d) for d in t]
ans = 0
for i in range(len(a)):
  if(a[i] != b[i]):
    ans += 1
print(ans)
Problem p02688 (python)

Fixed submission:
n , k = map(int,input().split())
ans = [0] * n
for i in range(k):
  d = int(input())
  for j in list(map(int,input().split())):
    ans[j-1] = 1
print(ans.count(0))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = []
ans = 0
rangecounter = 0
for i in range(k-1):
  d = int(input())
  rangecounter += d
  for j in range(d):
    s.append(input().split())
for i in range(1,rangecounter):
  if s.count(i) == 0:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = []
ans = 0
rangecounter = 0
for i in range(k-1):
  d = int(input())
  rangecounter += d
  for j in range(d):
    s.append(input().split())
for i in range(rangecounter):
  if s.count(i) == 0:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = []
ans = 0
for i in range(k-1):
  d = int(input())
  for j in range(d):
    s.append(input().split())
for i in range(1,k):
  if s.count(i) == 0:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = []
ans = 0
for i in range(k-1):
  d = int(input())
  for j in range(d):
    s.append(input().split())
for i in range(k-1):
  if s.count(i) == 0:
    ans += 1
print(ans)
Problem p02693 (python)

Fixed submission:
k = int(input())
a, b = map(int, input().split())
p = a % k
q = k - p
if (p == 0) or ((a + q) <= b):
    print('OK')
else:
    print('NG')

Buggy submission (verdict: Runtime Error):
k = int(input())
a,b = map(int,input().split())
for i in range(a,b):
  if i % k == 0:
    ans = 'OK'
    break
  else:
    ans = 'NG'
print(ans)

Buggy submission (verdict: Runtime Error):
k = int(input())
a,b = map(int,input().split())
for i in range(a,b):
  if i % k == 0:
    ans = 'OK'
  else:
    ans = 'No'
print(ans)

Buggy submission (verdict: Runtime Error):
k = int(input())
a,b = map(int,input().split())
for i in range(a,b):
  if i % k == 0:
    ans = 'OK'
    break
  else:
    ans = 'No'
print(ans)
Problem p02701 (python)

Fixed submission:
n = int(input())
ans = len(set([input() for _ in range(n)]))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input)
ans = len(set([input() for _ in range(n)]))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [input() for i in range(n-1)]
a = []
index = a.find(s[i])
for i in range(n-1):
	if index = -1:
         a.append(i)
print(len(s[i])
Problem p02711 (python)

Fixed submission:
a, b, c = input()  # 1234を整数(int)型ではなく、文字列(str)型で変数に格納する
if(a=="7" or b=="7" or c=="7"): print("Yes")
elif( a=="7" and b=="7"): print("Yes")
elif( c=="7" and b=="7"): print("Yes")
elif( c=="7" and a=="7"): print("Yes")
elif(a=="7" and b=="7" and c=="7"): print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
List = [int(input()) for i in range(n)]
if(List.index(7)) print('Yes'):
  else: print('No')
Problem p02773 (python)

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]

dic={}
for i in range(n):
    if s[i] not in dic:
        dic[s[i]]=1
    else:
        dic[s[i]]+=1

largest=max(dic.values())
ans=list()

for key in dic.keys():
    if dic[key]==largest:
        ans.append(key)

ans.sort()
for answers in ans:
    print(answers)

Buggy submission (verdict: Runtime Error):
n = int(input())
int i = 0
List = [input() for i in range(n)]
print(sorted(List))
Problem p02779 (python)

Fixed submission:
n = int(input())
a = set(map(int, input().split()))
ans = "YES"
if len(a) != n: #setは重複させないから。
  ans = "NO"
  
print(ans)

Buggy submission (verdict: Runtime Error):
n = int (input())
a = [input() for _ in range(n)]
if ( a(i) != a(i+1) ):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int (input())
a = [input() for _ in range(n)]
if ( a(i) != a(i+1) ):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int (input())
a = [input() for _ in range(n)]
if ( a(i) != a(i+1) ):
  print("Yes)
else:
  print("No")
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
ans = 6
print(ans-(a+b))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
ans = 6
print(ans-(a+b))
Problem p02836 (python)

Fixed submission:
s = input()
ans = 0
for i in range(0,len(s)):
  if s[i] != s[len(s)-i-1]:
    ans += 1
print(int(ans/2))

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
for i in range(0,len(s)):
  if s[i] != s[len(s)-i-1]
    ans += 1
print(ans)
Problem p02860 (python)

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

if n % 2 != 0: 
  print('No')
elif s[:int(n/2)] == s[int(n/2):]: 
  print('Yes')
else: 
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
t = n/2
for i in range(n-1):
  if s[:int(n/2)]==s[int(n/2):]:
	  ans = ('Yes')
  else:
	  ans = ('No')
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
t = n/2
for i in range(n-1):
  if s[:int(n/2)]==s[int(n/2):]:　#コロンで分断
	  ans = ('Yes')
  else:
	  ans = ('No')
print(ans)
Problem p02951 (python)

Fixed submission:
a,b,c = map(int,input().split())
if(b+c >= a):
  print(b+c-a)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if(b+c >= a):
print(b+c-a)
else:
  print(0)
Problem p02970 (python)

Fixed submission:
n, d = map(int, input().split())
print((2 * d + n) // (2 * d + 1))

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
  while((2 * (d + i) + 1) * 2 >= n):
print((2 * d + n) / (2 * d + 1))
Problem p02987 (python)

Fixed submission:
s = input()
ans ='Yes'
if(s[0] == s[1] and s[2] == s[3]):
  ans ='Yes'
elif(s[0] == s[3] and s[1] == s[2]):
  ans ='Yes'
elif(s[0] == s[2] and s[1] == s[3]):
  ans ='Yes'
else:
  ans ='No'

if(s[0] == s[1] and s[1] == s[2] and s[2] == s[3]):
  ans ='No'
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans =='Yes'
if(s[0] == s[1] and s[2] == s[3]):
  ans =='Yes'
elif(s[0] == s[3] and s[1] == s[2]):
  ans =='Yes'
elif(s[0] == s[2] and s[1] == s[3]):
  ans =='Yes'
else:
  ans =='No'

if(s[0] == s[1] and s[1] == s[2] and s[2] == s[3]):
  ans =='No'
print(ans)
Problem p03072 (python)

Fixed submission:
n = int(input())
H = list(map(int, input().split()))
ans = 0
t = 0

for i in range(n):
  t = max(t,H[i])
  if(t == H[i]):
    ans += 1
print(ans)

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

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

Buggy submission (verdict: Runtime Error):
n=input()
if(n%2==0):
print(n)
else:
  print(2＊n)
Problem p02624 (python)

Fixed submission:
# coding: utf-8
n_input = int(input())
ans = 0
for i in range(1, n_input + 1):
    n = n_input // i
    ans += n * (1 + n) * i // 2
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sympy
n = int(input())
ans = 0

for i in range(n):
    list = sympy.divisors(i + 1)
    ans = ans + (1 + i) * len(list)
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sympy
n = int(input())
ans = 0
for i in range(n):
    ans = ans + (1 + i) * sympy.divisor_count(i+1)
print(ans)
Problem p02766 (python)

Fixed submission:
# coding: utf-8
import math
n, k = map(int, input().split())
print(int(math.log(n, k)) + 1)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math
n, k = map(int, input().split())
if n % k
print(int(math.log(n, k)) + 1)
Problem p02835 (python)

Fixed submission:
# coding: utf-8
a = list(map(int, input().split()))
if sum(a) > 21:
    print("bust")
else:
    print("win")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
a = list(map(int, input().split()))
if sum(a) > 21:
    print("bust")
else:
    print(win)
Problem p03108 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
ans = [0] * M

parent = [-1] * (N + 1)
size = [1] * (N + 1)
combi = N * (N - 1) // 2
count = 0

def get_parent(a):
    global parent
    temp = parent[a]
    if temp == -1:
        return a
    else:
        temp = get_parent(temp)
        parent[a] = temp
        return temp

def union(a, b):
    global count, size
    parent_a = get_parent(a)
    parent_b = get_parent(b)

    if parent_a != parent_b:
        parent[parent_b] = parent_a
        count -= size[parent_a] * (size[parent_a] - 1) // 2
        count -= size[parent_b] * (size[parent_b] - 1) // 2
        size[parent_a] += size[parent_b]
        count += size[parent_a] * (size[parent_a] - 1) // 2

for i in range(M - 1, -1, -1):
    ans[i] = combi - count

    a, b = AB[i]
    union(a, b)

for temp in ans:
    print(temp)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
ans = [0] * M

parent = [-1] * (N + 1)
size = [1] * (N + 1)
combi = N * (N - 1) // 2
count = 0

def get_parent(a):
    global parent
    temp = parent[a]
    if temp == -1:
        return a
    else:
        temp = get_parent(temp)
        parent[a] = temp
        return temp

def union(a, b):
    global count, size
    parent_a = get_parent(a)
    parent_b = get_parent(b)

    if parent_a != parent_b:
        parent[parent_b] = parent_a
        count -= size[parent_a] * (size[parent_a] - 1) // 2
        count -= size[parent_b] * (size[parent_b] - 1) // 2
        size[parent_a] += size[parent_b]
        count += size[parent_a] * (size[parent_a] - 1) // 2

for i in range(M - 1, -1, -1):
    ans[i] = combi - count

    a, b = AB[i]
    union(a, b)

for temp in ans:
    print(temp)
Problem p03295 (python)

Fixed submission:
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]
ab.sort(key = lambda x : x[1])

ans = 0
last = -1
for abTemp in ab:
    if abTemp[0] < last:
        continue
    else:
        ans += 1
        last = abTemp[1]

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

N, M = map(int, input().split())
ab = (tuple(map(int, line.split())) for line in sys.stdin.readlines())
ab.sort(key = lambda x : x[1])

ans = 0
last = -1
for a, b in ab:
    if a < last:
        continue
    else:
        ans += 1
        last = b

print(ans)
Problem p02659 (python)

Fixed submission:
def main():
    a,b=map(float,input().split())
    a=int(a)
    print(int((b*100+0.1)//1)*a//100)
main()

Buggy submission (verdict: Runtime Error):
def main():
    a,b=map(float,input().split())
    a=int(a)
    print(b*100//1)*a//100)
main()

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
print((B*100)*A//100)
Problem p02773 (python)

Fixed submission:
N=int(input())
ans={}
cnt=0
for i in range(N):
  t=input()
  if not t in ans.keys():
    ans[t]=1
  else:
    ans[t]+=1
  if cnt<ans[t]:
    cnt=ans[t]
tmp =[]
for i in ans.keys():
  if ans[i]  == cnt:
    tmp.append(i)
tmp.sort()
for i in tmp:
  print(i)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans={}
cnt=0
for i in range():
  t=input()
  if not t in ans.keys():
    ans[i]==1
  else:
    ans[i]+=1
  if cnt<ans[i]:
    cnt=ans[i]
tmp =[]
for i in ans.keys():
  if ans[i]  == cnt:
    tmp.append(i)
for i in sort(tmp):
  print(i)
Problem p02793 (python)

Fixed submission:
import fractions 
N=int(input())
A=list(map(int,input().split()))
t=A[0]
for i in range(1,N):
  t=(t*A[i])//fractions.gcd(t,A[i])
ans=0
for i in range(N):
  ans+=t//A[i]
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
import fractions as math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
N=int(input())
A=list(map(int,input().split()))
tmp=lcm_list(A)
ans=0
for i in A:
  ans+=tmp/i
  ans%=(10**9+7)
print(int(ans))
Problem p03041 (python)

Fixed submission:
N,K=input().split()
S=list(input())
for i in range(len(S)):
    if i==int(K)-1:
        S[i]=S[i].lower()
print(''.join(S))

Buggy submission (verdict: Runtime Error):
N,K=input().split()
S=input()
S[K-1]=S[K-1].lower()
print(S)