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

Fixed submission:
import math
import sys
ans = 9223372036854775807
n = int(input())
a = list(range(1,math.ceil(math.sqrt(n))+1))
for i in a:
    s = n/i
    if s==int(s):
        ans = min(i+s-2,ans)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
ans = math.inf
n = int(input())
a = list(range(1,math.ceil(math.sqrt(n))+1))
for i in a:
    s = n/i
    if s==int(s):
        ans = min(i+s-2,ans)
print(int(ans))
Problem p02754 (python)

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

result = 0
result += N // (A + B) * A
result += min(N % (A + B), A)
print(result)

Buggy submission (verdict: Runtime Error):
if A == 0:
  print(0)
elif B == 0:
  print(N)
else:
  ans = 0
  div = N //( A + B ) # A > 0
  ans = div * A
  ans += min( N % (A + B) , A)
  # mod = N % ( A + B )


  # if mod > A :
  #   ans += A
  # else :
  #   ans += mod
  
  print(ans)
Problem p02723 (python)

Fixed submission:
s = input()
if s[2] == s[3] and s[4] == s[5]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
if s[3] == s[4] and s[5] == s[6]:
    print('Yes')
else:
    print('No')
Problem p02990 (python)

Fixed submission:
# k-1Ci-1 * n-k+1Ci
mod = 10**9+7
n, k = map(int, input().split())
ans = n-k+1
print(ans)
for i in range(1, k):
    ans = ans*(k-i)*(n-k-i+1)//(i*(i+1))
    print(ans % mod)

Buggy submission (verdict: Runtime Error):
mod = 10**9+7
n, k = map(int, input().split())
ans = n-k+1
print(ans)
for i in range(1, k):
    ans = int(ans*(k-i)*(n-k-i+1)/(i*(i+1)))
    print(ans % mod)
Problem p03013 (python)

Fixed submission:
import sys
input = sys.stdin.readline


def fib(n):
    '''f(n)=f(n-1)+f(n-2)'''
    a, b = 0, 1
    for _ in range(n-1):
        a, b = b, a+b
    return b


n, m = map(int, input().split())
mod = 10**9+7
a = [int(input()) for _ in range(m)]
if not a:
    ans = fib(n+1) % mod
else:
    ans = fib(a[0])*fib(n-a[m-1]) % mod
    for i in range(m-1):
        if a[i+1]-a[i] == 1:
            ans = 0
            break
        ans = ans * fib(a[i+1]-a[i]-1) % mod

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def fib(n):
    '''f(n)=f(n-1)+f(n-2)'''
    a, b = 0, 1
    for _ in range(n-1):
        a, b = b, a+b
    return b


n, m = map(int, input().split())
mod = 10**9+7
a = [int(input()) for _ in range(m)]
ans = fib(a[0])*fib(n-a[m-1]) % mod
for i in range(m-1):
    if a[i+1]-a[i] == 1:
        ans = 0
        break
    ans = ans * fib(a[i+1]-a[i]-1) % mod

print(ans)

Buggy submission (verdict: Runtime Error):
def fib(n):
    '''f(n)=f(n-1)+f(n-2)'''
    a, b = 0, 1
    for _ in range(n-1):
        a, b = b, a+b
    return b


n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
ans = fib(a[0])*fib(n-a[m-1])
for i in range(m-1):
    if a[i+1]-a[i] == 1:
        ans = 0
        break
    ans = ans * fib(a[i+1]-a[i]-1) % (10**9+7)

print(ans)
Problem p03307 (python)

Fixed submission:
n = int(input())

if (n % 2) == 0:
  print(n)
else:
  print(n * 2)

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

value = []
for part in input().split():
  value.append(int(part))

print(max(value) - min(value))
Problem p02711 (python)

Fixed submission:
s = input()
print('Yes' if s[0] =='7' or s[1] =='7' or s[2] =='7' else 'No')

Buggy submission (verdict: Runtime Error):
s = str(input())
print('Yes' if s[0] ='7' or s[1] ='7' or s[2] ='7' else 'No')

Buggy submission (verdict: Runtime Error):
s = input()
print('Yes' if s[0] ='7' or s[1] ='7' or s[2] ='7' else 'No')
Problem p02880 (python)

Fixed submission:
n = int(input())
if n < 11 or n == 12 or n == 14 or n == 15 or n == 16 or n == 18 or n == 20 or n == 21 or n == 24 or n == 25  or n == 27  or n == 28   or n == 30  or n == 32  or n == 35  or n == 36  or n == 40  or n == 42   or n == 45  or n == 48  or n == 49   or n == 54   or n == 56 or n == 63    or n == 64   or n == 72   or n == 81  :
  print('Yes')
  exit()
print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
if n < 11 or n == 12 or n == 14 or n == 15 or n == 16 or n == 18 or n == 20 or n == 24 or n == 25  or n == 27  or n == 28   or n == 30  or n == 32  or n == 35  or n == 36  or n == 40  or n == 42   or n == 45  or n == 48  or n == 49   or n == 54   or n == 56   or n == 64   or n == 72   or n == 81  :
  print('Yes')
  eixt()
print('No')
Problem p02990 (python)

Fixed submission:
n, k = map(int, input().split())
import math
mod = (10**9) +7
def kai(x):
  if x == 0:
    return 1
  elif x < 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  if n - k  + 1 >= i:
    result = (kai(k-1)*kai(n-k+1))//(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))
    result2 = result % mod
    print(result2)
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
import math
mod = (10**9) +7
def kai(x):
  if x == 0:
    return 1
  elif x < 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  if n - k  + 1 >= i:
    result = (kai(k-1)*kai(n-k+1))/(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))
    result2 = result % mod
    print(result2)
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
import math
def kai(x):
  if x == 0:
    return 1
  elif x < 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  if n - k  + 1 >= i:
    result = (kai(k-1)*kai(n-k+1))/(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))
    result2 = result % ((10**9) +7)
    print(int(result2//1))
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
import math
def kai(x):
  if x == 0:
    return 1
  elif x < 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  if n - k  + 1 >= i:
    print(int((((kai(k-1)*kai(n-k+1)/(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))) % ((10**9) +7)))//1))
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
import math
def kai(x):
  if x == 0:
    return 1
  elif x < 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  if n - k  + 1 >= i:
    print(int(((kai(k-1)*kai(n-k+1)/(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))) % (10**9 +7))//1))
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
import math
def kai(x):
  if x == 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  if n - k  + 1 >= i:
    print(int(((kai(k-1)*kai(n-k+1)/(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))) % (10**9 +7))//1))
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
import math
def kai(x):
  if x == 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  print(int(((kai(k-1)*kai(n-k+1)/(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))) % (10**9 +7))//1))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
import math
def kai(x):
  if x == 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  print((kai(k-1)*kai(n-k+1)/(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))) % (10**9 +7))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
import math
def kai(x):
  if x == 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  print((kai(k-1)*kai(n-k+1)/(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))) % (10**9 +7))
Problem p03073 (python)

Fixed submission:
N = input()
S = [int(c) for c in N]

A = [0] * (len(S)+4)
B = [0] * (len(S)+4)

for i in range((len(S)//2)+1):
  A[i*2+1] = 1
  B[i*2] = 1
  
ca =0
cb =0
for i in range(len(S)):
  ca += abs(S[i]-A[i])
  cb += abs(S[i]-B[i])
print(min(ca, cb))

Buggy submission (verdict: Runtime Error):
N = input()
S = [int(c) for c in N]

A = [0] * (len(S)+1)
B = [0] * (len(S)+1)

for i in range((len(S)//2)+1):
  A[i*2+1] = 1
  B[i*2] = 1
  
  
ca =0
cb =0
for i in range(len(S)):
  ca += abs(S[i]-A[i])
  cb += abs(S[i]-B[i])
print(min(ca, cb))
Problem p03075 (python)

Fixed submission:
A=[0]*5
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())
K = int(input())
 
for i in range(4):
  for j in range(i+1,5):
    if abs(A[i]-A[j]) > K:
      print(':(')
      exit()
print('Yay!')

Buggy submission (verdict: Runtime Error):
A[0]*5
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())
K = int(input())

for i in range(4):
  for j in range(i+1,5):
    if abs(A[i]-A[j]) > K:
      print(':(')
      exit()
print('Yay!')
Problem p03207 (python)

Fixed submission:
N = int(input())
P = []
for i in range(N):
  P.append(int(input()))
print(sum(P) - max(P) // 2)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = []
for i in range(N):
  P.append(int(input())
print(sum(P) - max(P) / 2)
Problem p03315 (python)

Fixed submission:
S = [c for c in input()]
print(2 * S.count('+') -4)

Buggy submission (verdict: Runtime Error):
S = [c for c in int()]
print(2 * S.count('+') -4)
Problem p03327 (python)

Fixed submission:
N = int(input())
if N<1000:
  print('ABC')
  exit()
print('ABD')

Buggy submission (verdict: Runtime Error):
N = int(input())
if N<1000:
  print('ABC' + N.zfill(3))
  exit()
print('ABD' + (N-999).zfill(3))
Problem p03631 (python)

Fixed submission:
N = input()
if N[0] == N[2]:
  print('Yes')
  exit()
print('No')

Buggy submission (verdict: Runtime Error):
print('Yes' if input()[0] == input()[2] else 'No')
Problem p03834 (python)

Fixed submission:
s = input()
for i in range(len(s)):
  print(s[i] if i != 5 and i != 13 else ' ' , end ='')

Buggy submission (verdict: Runtime Error):
s = input()
s[5] = ' '
s[13] = ' '
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
s[5] = ' '
s[13] = ' '
print(s)
Problem p03017 (python)

Fixed submission:
n,a,b,c,d = map(int,input().split())
s = input().rstrip()
renzoku_iwa = [0 for i in range(n)]
renzoku_blank = [0 for i in range(n)]
old1 = ""
old2 = ""
for i,tmp in enumerate(s):
	if old1 == tmp:
		if old1 == "." and old2 == ".":
			renzoku_blank[i] = 1
		elif old1 == "#":
			renzoku_iwa[i] = 1
	old2 = old1
	old1 = tmp

if sum(renzoku_iwa[a-1:c]) == 0 and sum(renzoku_iwa[b-1:d]) == 0:
	if c < d:
		print("Yes")
	else:
		if sum(renzoku_blank[b:min(d+1,len(renzoku_blank))])>=1:
			print("Yes")
		else:
			print("No")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d = map(int,input().split())
s = input().rstrip()
renzoku_iwa = [0 for i in range(n)]
renzoku_blank = [0 for i in range(n)]
old1 = ""
old2 = ""
for i,tmp in enumerate(s):
	if old1 == tmp:
		if old1 == "." and old2 == ".":
			renzoku_blank[i] = 1
		elif old1 == "#":
			renzoku_iwa[i] = 1
	old2 = old1
	old1 = tmp

if sum(renzoku_iwa[a-1:c]) == 0 and sum(renzoku_iwa[b-1:d]) == 0:
	if c < d:
		print("Yes")
	else:
		if sum(renzoku_blank[b:d])>=1:
			1/0
			print("Yes")
		else:
			print("No")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d = map(int,input().split())
s = input().rstrip()
renzoku_iwa = [0 for i in range(n)]
renzoku_blank = [0 for i in range(n)]
old1 = ""
old2 = ""
for i,tmp in enumerate(s):
	if old1 == tmp:
		if old1 == "." and old2 == ".":
			renzoku_blank[i] = 1
		elif old1 == "#":
			renzoku_iwa[i] = 1
	old2 = old1
	old1 = tmp

if sum(renzoku_iwa[a-1:c]) == 0 and sum(renzoku_iwa[b-1:d]) == 0:
	if c < d:
		print("Yes")
	else:
		1/0
		if sum(renzoku_blank[b:d])>=1:
			print("Yes")
		else:
			print("No")
else:
	print("No")
print(renzoku_iwa)
print(renzoku_blank)
Problem p03018 (python)

Fixed submission:
s = input().rstrip()

concurrent_BC_cnt = 0
old1 = ""
cnt = 0
for tmp in (reversed(s)):
	if tmp == "A":
		if old1 == "B":
			cnt += concurrent_BC_cnt
		else:
			concurrent_BC_cnt = 0
			old1 = "A"
		# if "A" not update old1
	else:
		if tmp == "B" and old1 == "C":
			concurrent_BC_cnt += 1
		elif tmp == "C" and old1 == "B":
			pass
		else:
			concurrent_BC_cnt = 0
			
		old1=tmp
	
print(cnt)

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

concurrent_BC_cnt = 0
old1 = ""
cnt = 0
for tmp in (reversed(s)):
	if tmp == "A"
		if old1 == "B":
			cnt += concurrent_BC_cnt
		else:
			concurrent_BC_cnt = 0
			old1 = "A"
		# if "A" not update old1
	else:
		if tmp == "B" and old1 == "C":
			concurrent_BC_cnt += 1
		elif tmp == "C" and old1 == "B":
			pass
		else:
			concurrent_BC_cnt = 0
			
		old1=tmp
	
print(cnt)
Problem p03104 (python)

Fixed submission:
import math

def get_nearest_bin(x):
	if x <= 1:
		return x
	y = x
	i=0
	while y !=0:
		y = y >> 1
		i += 1
	return (x >> (i-1) ) << (i-1)

def func(x):
	if x <= 3:
		return {0:0,1:1,2:3,3:0}[x]
	
	nearest_bin = get_nearest_bin(x)

	if ((x-nearest_bin + 1) %2) == 0:
		ans = 0
	else:
		ans = nearest_bin

	return ans ^ func(x - nearest_bin)


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

if A == B:
	print(A)

elif A == 0:
	print(func(B))
else:
	print(func(A-1)^func(B))

Buggy submission (verdict: Runtime Error):
import math

def get_nearest_bin(x):
	if x <= 1:
		return x
	y = x
	i=0
	while y !=0:
		y = y >> 1
		i += 1
	return (x >> (i-1) ) << (i-1)

def func(x):
	if x <= 3:
		return {0:0,1:1,2:3,3:0}[x]
	
	nearest_bin = get_nearest_bin(x)

	if ((x-nearest_bin + 1) %2) == 0:
		ans = 0
	else:
		ans = nearest_bin

	return nearest_bin ^ func(x - nearest_bin)


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

if A == B:
	print(A)
else:
	print(func(A-1)^func(B))

Buggy submission (verdict: Runtime Error):
import math

def func(x):
	if x <= 3:
		return {0:0,1:1,2:3,3:0}[x]
	
	nearest_bin = 2 ** int(math.log2(x))

	if ((x-nearest_bin + 1) %2) == 0:
		ans = 0
	else:
		ans = nearest_bin

	return nearest_bin ^ func(x - nearest_bin)


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

if A == B:
	print(A)
else:
	print(func(A-1)^func(B))
Problem p03107 (python)

Fixed submission:
in_s = input().rstrip()
lst = list(in_s)
cur=0
while True:
    if cur+1 >= len(lst):
        break
    if lst[cur]!=lst[cur+1]:
        del lst[cur+1]
        del lst[cur]
        cur = max(0,cur-1)
    else:
        cur+=1
 
print(len(in_s) - len(lst))

Buggy submission (verdict: Runtime Error):
in_s = input().rstrip()
lst = list(in_s)
cur=0
while True:
    if cur >= len(lst):
        break
    if lst[cur]!=lst[cur+1]:
        del lst[cur+1]
        del lst[cur]
        cur = max(0,cur-1)
    else:
        cur+=1

print(len(in_s) - len(lst))

Buggy submission (verdict: Runtime Error):
in_s = input().rstrip()
lst = list(in_s)
cur=0
while True:
    if cur +1 == len(lst):
        break
    if lst[cur]!=lst[cur+1]:
        del lst[cur+1]
        del lst[cur]
        cur = max(0,cur-1)
    else:
        cur+=1

print(len(in_s) - len(lst))
Problem p03186 (python)

Fixed submission:
a,b,c = [int(s) for s in input().split(" ")]
ret = min(a+b+1,c) + b
print(ret)

Buggy submission (verdict: Runtime Error):
  a,b,c = [int(s) for s in input().split(" ")]
  ret = min(a+b+1,c) + b
  print(ret)
Problem p03705 (python)

Fixed submission:
N,A,B=map(lambda x:int(x) , raw_input().split(' '))

if N==0:
	print 0
elif N==1:
	if A==B:
		print 1
	else:
		print 0
elif A>B:
	print 0
else:
	print (B-A)*(N-2)+1

Buggy submission (verdict: Runtime Error):
N,A,B=map(lambda x:int(x) , raw_input().split(' '))
if A>B or N<2:
	print 0
elif A==B:
	print 1
else:
	li= range(0,B-A+2)[::-1]
        print li
	print sum(li[:N-2])
Problem p03075 (python)

Fixed submission:
distances = [int(input()) for _ in range(5)]
K = int(input())
 
if distances[-1] - distances[0] > K:
  print(":(")
else:
  print("Yay!")

Buggy submission (verdict: Runtime Error):
distances = [int(input()) in _ for range(5)]
K = int(input())

if distances[-1] - distances[0] > K:
  print(":(")
else:
  print("Yay!")
Problem p03631 (python)

Fixed submission:
N = input()
if (N == N[::-1]):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = input()
if (N = N[::-1]):
    print('Yes')
else:
    print('No')
Problem p02711 (python)

Fixed submission:
s=input()

for e in s:
  if e=="7":
    print("Yes")
    break
else:
  print("No")

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

for e in s:
  if e="7":
    print("Yes")
    break
else:
  print("No")
Problem p02793 (python)

Fixed submission:

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

# from math import gcd # Python versions 3.5 and above
from functools import reduce # Python version 3.x


def computeGCD(x, y):
    while (y):
        x, y = y, x % y
    
    return x

def lcm(a, b):
    return (a * b) // computeGCD(a, b)

# def lcm(denominators):
#     return reduce(lambda a,b: a*b // gcd(a,b), denominators)

res = reduce(lcm, A, 1)
# res = lcm(A)
print(sum(res // A[i] for i in range(N)) % (10 ** 9 + 7))

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

from math import gcd # Python versions 3.5 and above
from functools import reduce # Python version 3.x


def lcm(a, b):
    return (a * b) // gcd(a, b)

# def lcm(denominators):
#     return reduce(lambda a,b: a*b // gcd(a,b), denominators)

res = reduce(lcm, A, 1)
# res = lcm(A)
print(sum(res // A[i] for i in range(N)) % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):

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

from math import gcd # Python versions 3.5 and above
from functools import reduce # Python version 3.x

def lcm(denominators):
    return reduce(lambda a,b: a*b // gcd(a,b), denominators)

res = lcm(A)
print(sum(res // A[i] for i in range(N)) % (10 ** 9 + 7))
Problem p02912 (python)

Fixed submission:
import heapq

N, M = map(int, input().split())
A = [-i for i in map(int, input().split())]
heapq.heapify(A)
for i in range(M):
  tmp = -((-heapq.heappop(A))//2)
  heapq.heappush(A, tmp)

print(-sum(A))

Buggy submission (verdict: Runtime Error):
import heapq

N, M = map(int, input().split())
A = [-i for i in map(int, input().split())]
heapq.heapify(A)
for i in range(M):
  tmp = -((-heapq.heappop(A))//2)
  heapq.heappush(A, tmp)

print(-sum(A))

Buggy submission (verdict: Runtime Error):
import heapq
N, M = map(int, input().split())
A = [-i for i in map(int, input().split())]
heapq.heapify(A)
for _ in xrange(M):
    cur = -(-heapq.heappop(A) // 2)
    heapq.heappush(A, cur)
print(-sum(A))

Buggy submission (verdict: Runtime Error):
import heapq
N, M = map(int, input().split())
A = map(int, input().split())
A = [-x for x in A]
heapq.heapify(A)
for _ in xrange(M):
    cur = -(-heapq.heappop(A) // 2)
    heapq.heappush(A, cur)
print(-sum(A))
Problem p03108 (python)

Fixed submission:
N, M = [int(x) for x in input().split(' ')]
edges = []
for _ in range(M):
    edges.append([int(x)-1 for x in input().split(' ')])
res = [str(N * (N-1) // 2)]
init = N * (N-1) // 2
f = list(range(N))
cnt = [1] * N
def find(x):
    if x != f[x]:
        f[x] = find(f[x])
    return f[x]
for i in range(M-1, 0, -1):
    a, b = edges[i]
    fx, fy = find(a), find(b)
    if fx == fy:
        res.append(str(init))
    else:
        
        pre = cnt[fx] * (cnt[fx] - 1) // 2 + cnt[fy] * (cnt[fy] - 1) // 2
        if cnt[fx] < cnt[fy]:
            f[fx] = fy
            cnt[fy] += cnt[fx]
            init = init - cnt[fy] * (cnt[fy]-1) // 2 + pre
        else:
            f[fy] = fx
            cnt[fx] += cnt[fy]
            init = init - cnt[fx] * (cnt[fx] - 1) // 2 + pre
        res.append(str(init))
print('\n'.join(res[::-1]))

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split(' ')]
edges = []
for _ in range(M):
    edges.append([int(x) - 1 for x in input().split(' ')])
res = [str(N * (N-1) // 2)]
init = N * (N-1) // 2
f = list(range(N))
cnt = [1] * N
def find(x):
    if x != f[x]:
        f[x] = find(f[x])
    return f[x]
for i in range(M-1, 0, -1):
    a, b = edges[i]
    fx, fy = find(a), find(b)
    if fx == fy:
        res.append(str(init))
    else:
        f[fy] = fx
        pre = cnt[fx] * (cnt[fx] - 1) // 2 + cnt[fy] * (cnt[fy] - 1) // 2
        cnt[fx] += cnt[fy]
        # print(a, b, f, cnt)
        init = init - cnt[fx] * (cnt[fx]-1) // 2 + pre
        res.append(str(init))
print('\n'.join(res[::-1]))

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in raw_input().split(' ')]
edges = []
for _ in range(M):
    edges.append([int(x) - 1 for x in raw_input().split(' ')])
res = [str(N * (N-1) / 2)]
init = N * (N-1) / 2
f = range(N)
cnt = [1] * N
def find(x):
    if x != f[x]:
        f[x] = find(f[x])
    return f[x]
for i in range(M-1, 0, -1):
    a, b = edges[i]
    fx, fy = find(a), find(b)
    if fx == fy:
        res.append(str(init))
    else:
        f[fy] = fx
        pre = cnt[fx] * (cnt[fx] - 1) / 2 + cnt[fy] * (cnt[fy] - 1) / 2
        cnt[fx] += cnt[fy]
        # print(a, b, f, cnt)
        init = init - cnt[fx] * (cnt[fx]-1) / 2 + pre
        res.append(str(init))
print('\n'.join(res[::-1]))
Problem p02777 (python)

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

Buggy submission (verdict: Runtime Error):
s,t= input().split()
a,b=map(int,input().split())
u=input()
if u==s:
  a-=1
else:
  t-=1
print(a,b)
Problem p02835 (python)

Fixed submission:
a,b,c,=(int(x) for x in input().split())
 
if a+b+c<=21:
  print("win")
  
else:
  print("bust")

Buggy submission (verdict: Runtime Error):
a,b,c,=(int(x) for x in input().split())

if a+b+c<=21:
  print(win)
  
else:
  print(bust)
Problem p02771 (python)

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

Buggy submission (verdict: Runtime Error):
*l = map(int, input().split())
if len(set(l)) == 2:
    print('Yes')
else:
    print('No')
Problem p02753 (python)

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

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

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

Buggy submission (verdict: Runtime Error):
S = input()
if S[0] == S[1] and s[1] == S[2]:
  print("No")
else:
  print("Yes)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = str(input())
 
if a>=3200:
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
a = map(int, input())
s = map(str, input())

if a>=3200:
  print(s)
else:
  print('red')
Problem p02729 (python)

Fixed submission:
import math


def combinations_count(n, r):
    try:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    except ValueError:
        return 0
    

li = list(map(int, input().split()))
n = li[0]
m = li[1]

print(combinations_count(m, 2)+combinations_count(n, 2))

Buggy submission (verdict: Runtime Error):
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

li = list(map(int, input().split()))
n = li[0]
m = li[1]

print(combinations_count(m, 2)+combinations_count(n, 2))
Problem p02711 (python)

Fixed submission:
a = input()
if a[0] == '7' or a[1] == '7' or a[2] == '7' :
  print("Yes")
else :
  print("No")

Buggy submission (verdict: Runtime Error):
a = input()
if a[1] == '7' or a[2] == '7' or a[3] == '7' :
  print("Yes")
else :
  print("No")

Buggy submission (verdict: Runtime Error):
a = int(input())
if a[1] == 7 or a[2] == 7 or a[3] == 7 :
  print(Yes)
else :
  print(No)
Problem p02729 (python)

Fixed submission:
n,m=(int(x) for x in input().split())

n_dot = n*(n-1)/2
m_dot = m*(m-1)/2

answer = int(n_dot+ m_dot)
print(answer)

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

n_dot = n*(n-1)/2
m_dot = m*(m-1)/2

answer = int(n_dot+ m_dot)
print(answer)

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

n_dot = n*(n-1)/2
m_dot = m*(m-1)/2

answer = n_dot+ m_dot
print(answer)