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

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


def main():
    a, b = [decimal.Decimal(i) for i in input().split()]
    ans = a * b
    print(int(ans))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from decimal import Desimal
import sys
input = sys.stdin.readline


def main():
    a, b = [Desimal(i) for i in input().split()]
    a = int(a)
    b = int(float(b) * 100)
    ans = a * b // 100
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


def main():
    a, b = [float(i) * 100 for i in input().split()]
    print((a ** b) // 100)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


def main():
    a, b = [int(i * 100) for i in input().split()]
    print((a ** b) // 100)


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

Fixed submission:
def main():
    k = int(input())
    s = input()
    if len(s) > k:
        s = s[:k] + '...'

    print(s)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import itertools
    k = int(input())
    s = input()
    if len(s) > k:
        s = s[:k] + '...'
    print(s)

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

Fixed submission:
n, m, k = map(int, input().split())
MOD = 998244353

ans = 0
c = 1
for i in range(k + 1):
    ans = (ans + m * pow(m - 1, n - i - 1, MOD) * c) % MOD
    c = (c * (n - 1 - i) * pow(i + 1, MOD - 2, MOD)) % MOD
    # print(f"{ans = }, {c = }")

print(ans)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
MOD = 998244353

ans = 0
for i in range(k + 1):
    ans += (ans + m * pow(m - 1, m - i - 1, MOD)) % MOD
    c = (c * (n - 1 - i) * pow(i + 1, MOD - 2, MOD)) % MOD

print(ans)
Problem p02757 (python)

Fixed submission:

n, p = map(int, input().split())
s = list(map(int, list(input())))


cnt = [0] * p
cnt[0] = 1
rem = 0
sum = 0

if p == 2 or p == 5:
    for i in range(n):
        if s[i] % p == 0:
            sum += i + 1

else:
    for i in range(n):
        rem = (int(s[-i - 1]) * pow(10, i, p) + rem) % p
        sum += cnt[rem]
        cnt[rem] += 1

print(sum)

Buggy submission (verdict: Runtime Error):
from collections import deque

n, p = map(int, input().split())
s = deque(list(input()))

def is_prime(p, s):
    if s % p == 0:
        return 1
    else:
        return 0

def str_num(s):
    return int(''.join(s))
  
  
cnt = 0
tmp = deque()
while len(s) >= 2:
    tmp.appendleft(s.pop())

    for i in range(len(s)):
        cnt += is_prime(p, str_num(s))
        cnt += is_prime(p, str_num(tmp))
        tmp.appendleft(s.pop())
    cnt += is_prime(p, str_num(tmp))
    tmp.pop()
    tmp.popleft()
    s, tmp = tmp, s


if n == 1:
    cnt += is_prime(str_num(s))

print(cnt)
Problem p02831 (python)

Fixed submission:
import fractions as math
input_line = list(map(int,input().split(' ')))

ans = input_line[0] * input_line[1] // math.gcd(input_line[0], input_line[1])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
input_line = list(map(int,input().split(' ')))

ans = input_line[0] * input_line[1] // math.gcd(input_line[0], input_line[1])
print(ans)
Problem p02594 (python)

Fixed submission:
X = int(input())
if X < 30:
	print("No")
if X >= 30:
	print("Yes")

Buggy submission (verdict: Runtime Error):
X = input()
if X<=30:
	print("No")
else: x>=30
	print("Yes")
Problem p02693 (python)

Fixed submission:
K=int(input())
A,B=map(int,input().split())
ans="NG"

for i in range(1001):
  if A<=i*K and i*K<=B:
    ans="OK"
    break

print(ans)

Buggy submission (verdict: Runtime Error):
K,A,B = map(int,input().split())
if A <= B % K == 0 and A or B % K == 0:
	print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
K,A,B = map(int,input().split())
if A <=B % K == 0:
	print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
K,A,B = map(int,input().split())
if A <= B % K == 0 and A or B % K == 0:
	print("OK")
else:
  	print("NG")

Buggy submission (verdict: Runtime Error):
K,A,B = map(int,input().split())
if A <= B % K == 0:
	print("OK")
else:
  	print("NG")

Buggy submission (verdict: Runtime Error):
K,A,B = map(int,input().split())
if A and B % K == 0:
	print("OK")
else:
  	print("NG")

Buggy submission (verdict: Runtime Error):
K,A,B = map(int,input().split())
A <= B 
if A or B % K == 0:
	print("OK")
else:
  	print("NG")

Buggy submission (verdict: Runtime Error):
K,A,B = map(int,input().split())
if A <= B and A or B % K == 0:
	print("OK")
else:
  	print("NG")

Buggy submission (verdict: Runtime Error):
K,A,B = map(int,input().split())
if A <= K <= B and A or B % K == 0:
	print("OK")
else:
  	print("NG")

Buggy submission (verdict: Runtime Error):
K,A,B = map(int,input().split())
if A or B % K == 0:
	print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
if a or b % k ==0:
	print("OK")
else:
    print("NG"

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
if a or b % k ==0:
	print("OK")
    else:
      print("NG")

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
if a or b % k ==0:
	print("OK")
    else:
      print("NG")
Problem p02699 (python)

Fixed submission:
S,W=map(int, input().split())
 
if S>W:
	print("safe")
if S<W:
	print("unsafe")
if S==W:
	print("unsafe")

Buggy submission (verdict: Runtime Error):
S,W=map(int, input().split())
 
if S>W:
	print("safe")
if S<W:
	print("unsafe")
if S=W:
	print("unsafe")

Buggy submission (verdict: Runtime Error):
S=int(input())
W=10
 
if S>W:
	print("safe")
if S<W:
	print("unsafe")
if S=W:
	print("unsafe")

Buggy submission (verdict: Runtime Error):
S=int(input())
W=10

if S>W:
	print("safe")
if S<W:
	print("unsafe")

Buggy submission (verdict: Runtime Error):
S=input()
W=10
if S>W:
	print("safe")
if W>S:
	print("unsafe")
Problem p02711 (python)

Fixed submission:
s = input()
if "7" in s:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N =
if N % 7 == 0:
	print("Yes")
else:
  	print("No")

Buggy submission (verdict: Runtime Error):
N = map(int,input().split())
if N % 7 == 0:
	print("Yes")
else:
  	print("No")

Buggy submission (verdict: Runtime Error):
N = map(int,input().split())
if N % 3 ==0:
	print("Yes")
else:
  	print("No")

Buggy submission (verdict: Runtime Error):
N = map(int,input().split())
if N % 3:
	print("Yes")
else:
  	print("No")

Buggy submission (verdict: Runtime Error):
if N % 3:
	print("Yes")
else:
  	print("No")
Problem p02729 (python)

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

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
print(n*w(n*w-1) /2)

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
print(nw(nw-1) /2)
Problem p02623 (python)

Fixed submission:
import numpy as np
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
a=np.cumsum(A)
b=np.cumsum(B)
a=np.insert(a,0,0)
b=np.insert(b,0,0)
j=m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
while True:
    if len(a) and len(b):
        if a[0] < b[0] and k >= a[0]:
            k-=a[0]
            del a[0]
            ans+=1
        elif a[0] >= b[0] and k >= b[0]:
            k-=b[0]
            del b[0]
            ans+=1
        else:
            print(ans)
            exit()
    elif len(a)==0 and k >= b[0]:
        k-=b[0]
        del b[0]
        ans+=1
    elif len(b)==0 and a[0] <= k:
        k-=a[0]
        del a[0]
        ans+=1
    else:
        print(ans)
        exit()

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
ans=0
a=list(map(int,input().split()))
b=list(map(int,input().split()))

if sum(a)+sum(b) <= k:
    print(len(a)+len(b))
    exit()

while k >= a[0] or k >= b[0]:
    if len(a)==0:
        k-=b[0]
        ans+=1
        del b[0]
    elif len(b)==0:
        k-=a[0]
        ans+=1
        del a[0]
    elif a[0] < b[0]:
        k-=a[0]
        ans+=1
        del a[0]
    else:
        k-=b[0]
        ans+=1
        del b[0]
print(ans)
Problem p02699 (python)

Fixed submission:
s,w=map(int,input().split())
if s > w:
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
S,W=map(unt,input().split())
if S>W:
  print("safe")
else:
  print("unsafe")
Problem p02594 (python)

Fixed submission:
a = input()

if int(a) >= 30:
  print('Yes')
else:
  print('No')

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

Fixed submission:
import numpy as np
 
N, D = input().strip().split() #1行目のNを取得する
grid = []
for i in range(int(N)):
    array = list(map(int, input().strip().split()))
    grid.append(array)
grid = np.array(grid)
p = 0
for i in range(int(N)):
  if np.sqrt(grid[i,0]*grid[i,0] + grid[i,1]*grid[i,1]) <= int(D):
    p += 1
print(p)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
N, D = int(input().split()) #1行目のNを取得する
grid = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    grid.append(array)
p = 0
for i in range(N):
  if np.sqrt(grid[i,0]*grid[i,0] + grid[i,1], grid[i,1]) <= D:
    p += 1
print(p)

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

N, D = int(input().split()) #1行目のNを取得する
a,b=(int(x) for x in input().split())
p = 0
for i in range(len(a)):
  if np.sqrt(a[i]*a[i] + b[i]*b[i]):
    p += 1
print(p)

Buggy submission (verdict: Runtime Error):
x, y = input().split()
s = [input() for i in range(x)]
t = [input() for i in range(y)]
p = 0
for i in range(len(s)):
  if sqrt(s[i]*s[i] + t[i]*t[i]) > y:
    p += 1

print(p)
Problem p02707 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
x = [0]*(2*10**5+1)
for i in range(N-1):
    x[A[i]] += 1
for i in range(1,N+1):
    print(x[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
x = [0]*(2*10**5)
for i in range(N-1):
    x[A[i]] += 1
for i in range(1,N+1):
    print(x[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
x = [0]*(2*10**5)
for i in range(2, N):
  x[A[i]] += 1
for i in range(N):
  print(x[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
x = [0]**(2*10**5)
for i in range(N):
  x[A[i]] += 1

for i in range(N):
  print(x[i])

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

for i in range(N):
  print(A.count(i+1))
Problem p02933 (python)

Fixed submission:
n = int(input())
s = input()
if n < 3200:
  print("red")
else:
  print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
if s < 3200:
  print("red")
else:
  print(s)
Problem p02729 (python)

Fixed submission:
import math
N,M=map(int,input().split())

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

if N >= 2:
	A=nCr(N,2)
else:
	A=0
if M >= 2:
	B=nCr(M,2)
else:
	B=0
print(A+B)

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

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

print(nCr(N,2)+nCr(M,2))
Problem p02777 (python)

Fixed submission:
S,T=input().split(" ")
A,B=map(int,input().split(" "))
U=input()
if U==S:
    A=A-1
else:
    B=B-1
print(" ".join([str(A),str(B)]))

Buggy submission (verdict: Runtime Error):
S,T=input().split(" ")
A,B=map(int,input().split(" "))
U=input()
if U==S:
    A=A-1
else:
    B=B-1
print(" ".join([A,B]))
Problem p02935 (python)

Fixed submission:
N=int(input())
values=[int(thing) for thing in input().split(" ")]
values.sort()
ret=0
for i in values:
    if ret!=0:
        ret=(i+ret)*0.5
    else:
        ret=i
print(ret)

Buggy submission (verdict: Runtime Error):
N=int(input())
values=[int(input()) for i in range(N)]
values.sort()
ret=0
for i in values:
    ret=(i+ret)*0.5
print(ret)
Problem p03075 (python)

Fixed submission:
inputs=[int(input()) for i in range(6)]
k=inputs[-1]
T=False
for i in range(5):
  for j in range(5-i):
    if abs(inputs[5-j]-inputs[i-1])>k:
      print(":(")
      quit()

print("Yay!")

Buggy submission (verdict: Runtime Error):
inputs=[int(i) for i in input().split()]
k=inputs[-1]
for i in range(5):
  for j in range(5-i):
    if abs(inputs[j]-inputs[i])>k
    print(":(")
 	return

print("Yay!")
return

Buggy submission (verdict: Runtime Error):
inputs=[int(i) for i in input().split()]
k=inputs[-1]
for i in range(5):
  for j in range(5-i):
    if abs(j-i)>k
    print(":(")
 	return

print("Yay!")
return

Buggy submission (verdict: Runtime Error):
inputs=[int(i) for i in input().split()]
k=inputs[-1]
for i in range(5):
  for j in range(5-i):
    if abs(j-i)>k
    print(":(")
 		return

print("Yay!")
return
Problem p02693 (python)

Fixed submission:
import math

def main():
    K=int(input())
    (A,B)=[int(x) for x in input().strip().split()]
    if A % K == 0:
        print('OK')
    elif math.ceil(A/K)*K <= B:
        print('OK')
    else:
        print('NG')
 
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    K=int(input())
    (A,B)=[int(x) for x in input().split()]
    if A % K == 0:
        print('OK')
    elif math.ceil(A/K)*K <= B:
        print('OK')
    else:
        print('NG')
 
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
def main():
    K=int(input())
    (A,B)=[int(x) for x in input().split()]
    if A % K == 0:
        print('OK')
        exit(0)
    elif math.ceil(A/K)*K <= B:
        print('OK')
        exit(0)
    else:
        print('NG')
        exit(-1)

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

Fixed submission:
A,B = [int(x) for x in input().split(' ')]

def calc_xor0(num):
    if num % 2 ==  0:
        if num % 4 == 2:
            ans =  num + 1
        else:
            ans =  num
    else:
        if num % 4 == 1:
            ans =  1
        else:
            ans =  0 #3:0 5:1 
    return ans

def main():
    print(calc_xor0(A-1) ^ calc_xor0(B))    

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
A,B = [int(x) for x in input().split(' ')]

def calc_xor0(num):
    if num % 2 ==  0:
        if num % 4 == 2:
            ans =  num + 1
        else:
            ans =  num
    else:
        if num % 4 == 1:
            ans =  1
        else:
            ans =  0 #3:0 5:1 
    return ans

def main():
    print(calc_xor0(A-1) ^ calc_xor0(B))    

    if __name__ == "__main__":
    main()
Problem p02594 (python)

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

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

Fixed submission:
import datetime
import string
import re
import math

input = int(input())

if input >= 30:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import datetime
import string
import re
import math

input = Int(input())

if input >= 30:
    print("Yes")
else:
    print("No")

return
Problem p02597 (python)

Fixed submission:
import datetime
import string
import re
import math

N=int(input())
input = input()
str = []
for i in range(N):
    str.append(input[i])
str.reverse()

count = 0
begin = 0
end = len(str) - 1
while True:
    if begin < len(str):
        while str[begin] == 'W':
            begin += 1
            if begin == len(str):
                break

    if end >= 0:
        while str[end] == 'R':
            end -= 1
            if end == -1:
                break

    if begin < end:
        str[begin] = 'R'
        str[end] = 'W'
        begin += 1
        end -= 1
        count += 1
    elif begin >= len(str) and end > -1:
        if end != len(str) - 1:
            if str[end + 1] == 'R':
                str[end] = 'W'
                end -= 1
                count += 1
            else:
                end -= 1
        else:
            end -= 1
    elif begin < len(str) and end <= -1:
        if begin != 0:
            if str[begin - 1] == 'W':
                str[begin] = 'R'
                begin += 1
                count += 1
            else:
                begin += 1
        else:
            begin += 1
    else:
        print(count)
        break

Buggy submission (verdict: Runtime Error):
import datetime
import string
import re
import math

N=int(input())
input = input()
str = []
for i in range(N):
    str.append(input[i])

count = 0
begin = 0
end = len(str) - 1
while True:
    if begin < len(str):
        while str[begin] == 'W':
            begin += 1
            if begin == len(str):
                break

    if end >= 0:
        while str[end] == 'R':
            end -= 1
            if end == -1:
                break

    if begin < end:
        str[begin] = 'R'
        str[end] = 'W'
        begin += 1
        end -= 1
        count += 1
    elif begin == len(str) and end != -1:
        if str[end + 1] == 'R':
            str[end] = 'W'
            end -= 1
            count += 1
        else:
            end -= 1
    elif begin != len(str) and end == -1:
        if str[begin - 1] == 'W':
            str[begin] = 'R'
            begin += 1
            count += 1
        else:
            begin += 1
    else:
        print(count)
        break
Problem p02781 (python)

Fixed submission:
N=int(input())
K=int(input())

M = len(str(N)) # 桁数

def solve_1(n,m):
    ans = 0
    ans += 9*(m-1)
    x = n//(10**(m-1))
    ans += x
    return ans

def solve_2(n,m):
    ans=0
    if m<2:
        return ans
    elif m>2:
        ans+= (9**2)*int((m-2)*(m-1)/2) 

    x = n//(10**(m-1))
    ans+= (x-1)*(m-1)*9

    y=int(str(n)[1:])
    ans+=solve_1(y,len(str(y)))
    # ans+= int(str(n)[1])+9*(m-2)
    return ans

def solve_3(n,m):
    ans=0
    if m<3:
        return ans
    elif m>3:
        ans+=int((9**3)*(1/6)*(m-1)*(m-2)*(m-3))
    
    x = n//(10**(m-1))
    ans+=int((x-1)*(m-1)*(m-2)/2*81)
    
    y= int(str(n)[1:])

    ans+=solve_2(y,len(str(y)))
    return ans

if K==1:
    ans = solve_1(N,M)
if K==2:
    ans = solve_2(N,M)
if K==3:
    ans = solve_3(N,M)

print(ans)

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

M = len(str(N)) # 桁数

def solve_1(n,m):
    ans = 0
    ans += 9*(m-1)
    x = n//(10**(m-1))
    ans += x
    return ans

def solve_2(n,m):
    ans=0
    if m<1:
        return ans
    elif m>2:
        ans+= (9**2)*int((m-2)*(m-1)/2) 

    x = n//(10**(m-1))
    ans+= (x-1)*(m-1)*9
    ans+= int(str(n)[1])+9*(m-2)
    return ans

def solve_3(n,m):
    ans=0
    if m<2:
        return ans
    elif m>3:
        ans+=int((9**3)*(1/6)*(m-1)*(m-2)*(m-3))
    
    x = n//(10**(m-1))
    ans+=int((x-1)*(m-1)*(m-2)/2*81)
    ans+=solve_2(int(str(n)[1:]),m-1)
    return ans

if K==1:
    ans = solve_1(N,M)
if K==2:
    ans = solve_2(N,M)
if K==3:
    ans = solve_3(N,M)

print(ans)
Problem p03108 (python)

Fixed submission:

class UnionFindTree():
    # Union find tree
    # 2つの効率化　経路圧縮、ランク
    # つなげることはできるか分離することはできないので、木をつなげる方向に利用する
    # 
    def __init__(self, node_size):
        # node_num: 全体のノード数
        # parent: ノードがrootなら-1、親がいれば親の番号を入れる
        # size:
        # rank:  
        self.parent =[-1] * node_size 
        self.size = [1] * node_size
        self.rank = [1] * node_size
    
    def find_root(self,node):
        # node属する木のrootを探す
        # たどった経路に含まれるnodeの親をrootにつなぎ替える
        if self.parent[node] == -1:             # 自身がrootの場合
            root = node
        else:                                   # 自身がrootでない場合
            root = self.find_root(self.parent[node]) # 再帰的にrootを探す
            self.parent[node] = root            # たどった経路に含まれるnodeの親をrootにつなぎ替える(経路圧縮)
        return root

    def unite(self,node0, node1):
        # node0とnode1が含まれる木を結合する
        
        #node0 node1のrootを求める
        root0 = self.find_root(node0) 
        root1 = self.find_root(node1)

        if root0 != root1:
            # rankを比較しrankが小さい方の木を大きい方の木のrootにつなげる
            # rank is sameのときのみrankが増える
            rank0 = self.rank[root0]
            rank1 = self.rank[root1]

            if rank0 == rank1: # rank is same
                self.parent[root1] = root0
                self.size[root0] += self.size[root1]
                self.rank[root0] += 1
            elif rank0 > rank1:
                self.parent[root1] = root0
                self.size[root0] += self.size[root1]
            else:
                self.parent[root0] = root1
                self.size[root1] += self.size[root0]

            


N,M = map(int,input().split())
bridges = [list(map(int,input().split())) for i in range(M)]

UFT = UnionFindTree(N)

a = int(N*(N-1)/2) # 不便さ
ans = [a]

for i in range(1,M)[::-1]:
    island0_num, island1_num = bridges[i][0]-1, bridges[i][1]-1 
    root0 = UFT.find_root(island0_num)
    root1 = UFT.find_root(island1_num)
    if root0 != root1:
        size0 =  UFT.size[root0]
        size1 =  UFT.size[root1]
        UFT.unite(island0_num,island1_num)
        a -= size0 * size1
    ans.append(int(a))

[print(ans[i]) for i in range(M)[::-1]]

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())

bridges = [list(map(int,input().split())) for i in range(M)]

roots = np.array((range(0,N)))
a =int(N*(N-1)/2)
ans = [a]

for i in range(0,M)[::-1]:
    island0, island1 = bridges[i][0],bridges[i][1]

    if roots[island0-1] == roots[island1-1]:
        ans.append(int(a))
        continue

    num_island0 = roots.count(roots[island0-1])
    num_island1 = roots.count(roots[island1-1])
    num_island01 = num_island0 + num_island1
    if roots[island1-1] != island1: # merge
        min_i = min(roots[island0-1],roots[island1-1])
        max_i = max(roots[island0-1],roots[island1-1])
        roots = [min_i if root==max_i else root for root in roots]        
    else: # つなげる
        roots[island1-1] = roots[island0-1]
    
    a -= (num_island01*(num_island01-1) - num_island0*(num_island0-1) - num_island1 *(num_island1-1))/2
    ans.append(int(a))

[print(ans[i]) for i in range(M)[::-1]]
Problem p03075 (python)

Fixed submission:
import math
import sys

antenas = []
for i in range(5):
    antenas.append(int(input()))
k = int(input())

for f in antenas:
    for d in antenas:
        if abs(f-d) > k:
            print(":(")
            sys.exit(0)

print("Yay!")

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

antenas = []
for i in range(5):
    antenas.append(int(input()))
k = int(input())

for f in antenas:
    for d in antenas:
        if abs(f-d) > k:
            print(":(")
            sys.exit(-1)

print("Yay!")
Problem p03208 (python)

Fixed submission:
n, m = map(int, input().split(' '))
lst = [int(input()) for i in range(n)]
lst.sort()
print(min(lst[i+m-1]-lst[i] for i in range(n-m+1)))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split(' '))
lst = []
for i in range(n):
  lst.append(int(input()))
  lst.sort()
  minn = 999999999999
  for i in range(0, n-x+1):
    if lst[i+x]-lst[i] < minn:
      minn = lst[i+x] - lst[i]
  print(minn)
Problem p02736 (python)

Fixed submission:
N = int(input())
a = list(map(int, list(input())))
 
while N != 0:
	digit = 1
	while digit < N // 2:
		digit *= 2
 
	x = []
	for i in range(digit, N):
		x.append(abs(a[i - digit] - a[i]))
 
	a = x
	N -= digit
	if len(x) == 1:
		break
 
print(a[0])

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

while n != 0:
	x = 1
	while x < n // 2:
		x *= 2
	b = []
	for i in range(x, n):
		b.append(abs(a[i - x] - a[i]))
	a = b
	n -= digit
	if len(b) == 1:
		break
print(a[0])