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

Fixed submission:
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #ここにコード
    #input
    N, M, K = map(int, input().split())

    #output
    mod = 998244353

    n_ = 4*10**5 + 5
    fun = [1]*(n_+1)
    for i in range(1,n_+1):
        fun[i] = fun[i-1]*i%mod
    rev = [1]*(n_+1)
    rev[n_] = pow(fun[n_],mod-2,mod)
    for i in range(n_-1,0,-1):
        rev[i] = rev[i+1]*(i+1)%mod
    def cmb(n,r):
        if n <= 0 or r < 0 or r > n: return 0
        return fun[n]*rev[r]%mod*rev[n-r]%mod

    answer = 0
    for i in range(K+1):
        answer += M*pow(M-1, N-(i+1), mod)*cmb(N-1, i) % mod

    answer %= mod

    if N == 1:
        print(M)
        exit()

    print(answer)
    

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #ここにコード
    #input
    N, M, K = map(int, input().split())

    #output
    mod = 998244353

    n_ = 4*10**5 + 5
    fun = [1]*(n_+1)
    for i in range(1,n_+1):
        fun[i] = fun[i-1]*i%mod
    rev = [1]*(n_+1)
    rev[n_] = pow(fun[n_],mod-2,mod)
    for i in range(n_-1,0,-1):
        rev[i] = rev[i+1]*(i+1)%mod
    def cmb(n,r):
        if n <= 0 or r < 0 or r > n: return 0
        return fun[n]*rev[r]%mod*rev[n-r]%mod

    answer = 0
    for i in range(K+1):
        answer += M*pow(M-1, N-(i+1), mod)*cmb(N-1, i) % mod

    answer %= mod

    if N == 1:
        answer = M
    else:
        continue

    print(answer)
    

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

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

#output
answer = "NG"
for i in range(A, B+1):
    if i % K == 0:
        answer = "OK"
    else:
        continue

print(answer)

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

#output
answer = "NG"
for i in range(A, B+1):
    if i % K == 0:
        answer = "OK"
    else:
        continue

print(answer)
Problem p02711 (python)

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

#output
if "7" in str(N):
    print("Yes")
else:
    print("No")

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

#output
if "7" in str(N):
    print("Yes")
else:
    print("No")
Problem p02793 (python)

Fixed submission:
import sys
input = sys.stdin.readline
 
#input
N = int(input())
A = list(map(int, input().split()))
 
#output
import fractions, functools
 
def lcm_base(x, y):
    return (x*y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)
 
lcm = lcm_list(A)
 
answer = 0
for i in range(N):
    answer += lcm//A[i]
 
print(answer % (10**9 + 7))

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

#input
N = int(input())
A = [int(input()) for _ in range(N)]

#output
import fractions, functools
import numpy as np

mod = 10**9 + 7

def lcm_base(x, y):
    return (x*y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

#lcm = A[0]
#for i in range(1, N):
#    lcm = lcm * A[i]//fractions.gcd(lcm, A[i])

answer = 0
for i in range(N):
    answer += lcm//A[i] % mod

print(answer % mod)

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

#output
import fractions
import  functools
import numpy as np

mod = 10**9 + 7

gcd = functools.reduce(fractions.gcd, A)

def lcm_base(x, y):
    return (x*y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

lcm =  lcm_list(A)

answer = 0
for i in range(N):
    answer += lcm//A[i]

print(answer % mod)
Problem p02862 (python)

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

#input
X, Y = map(int, input().split())

#output
import math

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if (X + Y) % 3 == 0:
    k = (-X + 2*Y) //3
    l = (2*X -Y) //3
    if k < 0 or l <0:
        answer = 0
    else:
        answer = cmb(k+l, l) % (10**9 + 7)
else:
    answer = 0

print(answer)

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

#input
X, Y = map(int, input().split())

#output
import math

if (X + Y) % 3 == 0:
    k = (-X + 2*Y) //3
    l = (2*X -Y) //3
    answer = math.factorial(k+l)//(math.factorial(k)*math.factorial(l)) % (10**9 + 7)
else:
    answer = 0

print(answer)
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()))

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

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

#output
sum1 = sum(B)
sum2 = 0 
for i in range(N-1):
    if A[i] + 1 == A[i+1]:
        sum2 += C[(A[i]-1)]
print(sum1 + sum2)
Problem p02935 (python)

Fixed submission:
N = int(input())

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

v = sorted(v, reverse = False)

sum = v[0] / pow(2, N-1)
for i in range(1, N):
    sum += v[i]/pow(2, (N-i))

print(sum)

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

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

v = sorted(v, reverse = False)

sum = v[0] / 2**(N-1)
for i in range(1, N):
    sum += v[i]/2**(N-i)

pprint(sum)
Problem p02948 (python)

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

jobs = {}
for _ in range(N):
    A, B = map(int, input().split())
    if A > M :
        continue
    if A in jobs:
        jobs[A].append(B)
    else:
        jobs[A] = [B]

#output
import heapq

#点数配列の用意
point = 0
hq = []
#M-i日目(1 <= i <= M)に働ける仕事の中で、Bが最大のものを選ぶ
for A in range(1, M+1):
    if A in jobs:
        for B in jobs[A]:
            heapq.heappush(hq, -B)
    else:
        if len(hq) == 0:
            continue
    point += -heapq.heappop(hq)

print(point)

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

for _ in range(N):
    s.append(input())

for i in range(N):
    s[i] = [*s[i]]
    s[i] = sorted(s[i])

counter = 0
for i in range(N):
    for j in range((i+1), N):
        if s[i] == s[j]:
            counter += 1

print(counter)
Problem p03326 (python)

Fixed submission:
#input
N, M = map(int, input().split())
x = []
y = []
z = []
for i in range(N):
    x_temp, y_temp, z_temp = map(int, input().split())
    x.append(x_temp)
    y.append(y_temp)
    z.append(z_temp)

#output
#+++
a1 = [p+q+r for p, q, r in zip(x, y, z)]
a1.sort(reverse = True)
b1 = sum(a1[:M])

#++-
a2 = [p+q-r for p, q, r in zip(x, y, z)]
a2.sort(reverse = True)
b2 = sum(a2[:M])

#+-+
a3 = [p-q+r for p, q, r in zip(x, y, z)]
a3.sort(reverse = True)
b3 = sum(a3[:M])

#-++
a4 = [-p+q+r for p, q, r in zip(x, y, z)]
a4.sort(reverse = True)
b4 = sum(a4[:M])

#+--
a5 = [p-q-r for p, q, r in zip(x, y, z)]
a5.sort(reverse = True)
b5 = sum(a5[:M])

#-+-
a6 = [-p+q-r for p, q, r in zip(x, y, z)]
a6.sort(reverse = True)
b6 = sum(a6[:M])

#--+
a7 = [-p-q+r for p, q, r in zip(x, y, z)]
a7.sort(reverse = True)
b7 = sum(a7[:M])

#---
a8 = [-p-q-r for p, q, r in zip(x, y, z)]
a8.sort(reverse = True)
b8 = sum(a8[:M])

print(max(b1, b2, b3, b4, b5, b6, b7, b8))

Buggy submission (verdict: Runtime Error):
#input
N, M = map(int, input().split())
x = []
y = []
z = []
for i in range(N):
    x_temp, y_temp, z_temp = map(int, input().split())
    x.append(x_temp)
    y.append(y_temp)
    z.append(z_temp)

#output
#+++
a1 = [p+q+r for p, q, r in zip(x, y, z)]
a1.sort(reverse = True)
b1 = np.sum(a1[:M])

#++-
a2 = [p+q-r for p, q, r in zip(x, y, z)]
a2.sort(reverse = True)
b2 = np.sum(a2[:M])

#+-+
a3 = [p-q+r for p, q, r in zip(x, y, z)]
a3.sort(reverse = True)
b3 = np.sum(a3[:M])

#-++
a4 = [-p+q+r for p, q, r in zip(x, y, z)]
a4.sort(reverse = True)
b4 = np.sum(a4[:M])

#+--
a5 = [p-q-r for p, q, r in zip(x, y, z)]
a5.sort(reverse = True)
b5 = np.sum(a5[:M])

#-+-
a6 = [-p+q-r for p, q, r in zip(x, y, z)]
a6.sort(reverse = True)
b6 = np.sum(a6[:M])

#--+
a7 = [-p-q+r for p, q, r in zip(x, y, z)]
a7.sort(reverse = True)
b7 = np.sum(a7[:M])

#---
a8 = [-p-q-r for p, q, r in zip(x, y, z)]
a8.sort(reverse = True)
b8 = np.sum(a8[:M])

print(max(b1, b2, b3, b4, b5, b6, b7, b8))

Buggy submission (verdict: Runtime Error):
#input
N, M = map(int, input().split())
x = []
y = []
z = []
for i in range(N):
    x_temp, y_temp, z_temp = map(int, input().split())
    x.append(x_temp)
    y.append(y_temp)
    z.append(z_temp)

#output
#+++
a1 = [p+q+r for p, q, r in zip(x, y, z)]
a1 = sorted(a1, reverse = True)
b1 = np.sum(a1[:M])

#++-
a2 = [p+q-r for p, q, r in zip(x, y, z)]
a2 = sorted(a2, reverse = True)
b2 = np.sum(a2[:M])

#+-+
a3 = [p-q+r for p, q, r in zip(x, y, z)]
a3 = sorted(a3, reverse = True)
b3 = np.sum(a3[:M])

#-++
a4 = [-p+q+r for p, q, r in zip(x, y, z)]
a4 = sorted(a4, reverse = True)
b4 = np.sum(a4[:M])

#+--
a5 = [p-q-r for p, q, r in zip(x, y, z)]
a5 = sorted(a5, reverse = True)
b5 = np.sum(a5[:M])

#-+-
a6 = [-p+q-r for p, q, r in zip(x, y, z)]
a6 = sorted(a6, reverse = True)
b6 = np.sum(a6[:M])

#--+
a7 = [-p-q+r for p, q, r in zip(x, y, z)]
a7 = sorted(a7, reverse = True)
b7 = np.sum(a7[:M])

#---
a8 = [-p-q-r for p, q, r in zip(x, y, z)]
a8 = sorted(a8, reverse = True)
b8 = np.sum(a8[:M])

print(max(b1, b2, b3, b4, b5, b6, b7, b8))
Problem p02595 (python)

Fixed submission:
import math

N,D = map(int,input().split())
cnt = 0
for n in range(N):
    a,b = map(int,input().split())
    if math.sqrt(a**2 + b**2)-D<=0:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
import math

N,D = map(int,input().split())
cnt = 0
for n in range(N):
    a,b = map(int,input().split())
    if sqrt(a**2 + b**2)-D>=0:
        cnt+=1
print(cnt)
Problem p02594 (python)

Fixed submission:
X = int(input())
if X < 30:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
X = input()
if X < 30:
  print('No')
else:
  print('Yes')
Problem p02627 (python)

Fixed submission:
str = input()
if str.islower():
  print('a')
else:
  print('A')

Buggy submission (verdict: Runtime Error):
N = int(input())
eList = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
n = N
mod = N
numList = []
 
while n > 0:
  n, mod = divmod(n,26)
  if mod != 0:
    numList.insert(0, mod - 1)
  else:
    numList.insert(0, 25)
    n -= 1
for num in numList:
  ans += eList[num]
print(ans)
Problem p02629 (python)

Fixed submission:
N = int(input())
eList = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
n = N
mod = N
numList = []
 
while n > 0:
  n, mod = divmod(n,26)
  if mod != 0:
    numList.insert(0, mod - 1)
  else:
    numList.insert(0, 25)
    n -= 1
ans =''
for num in numList:
  ans += eList[num]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
eList = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
n = N
mod = N
numList = []
 
while n > 0:
  n, mod = divmod(n,26)
  if mod != 0:
    numList.insert(0, mod - 1)
  else:
    numList.insert(0, 25)
    n -= 1
for num in numList:
  ans += eList[num]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
eList = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
n = N
mod = N
numList = []

while n > 0:
  n, mod = divmod(n,26)
  if mod != 0:
    numList.insert(0, mod - 1)
  else:
    numList.insert(0, 25)
    n -= 1
for num in numList:
  if num != 0:
    ans += eList[num]
print(ans)
Problem p02859 (python)

Fixed submission:
print(int(input())**2)

Buggy submission (verdict: Runtime Error):
print(int(inpu())**2)
Problem p02951 (python)

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

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

Fixed submission:
t,d = map(int,input().split())
p_a = t//(2*d+1)
p_b = t%(2*d+1)
if p_b == 0:
  print(p_a)
else:
  print(p_a + 1)

Buggy submission (verdict: Runtime Error):
t,d = map(int,input().split())
p_a = t//(2d+1)
p_b = t%(2d+1)
if p_b == 0:
  print(p_a)
else:
  print(p_a + 1)
Problem p02989 (python)

Fixed submission:
n = int(input())
d = sorted(list(map(int,input().split())))
if d[n//2 ] == d[n//2 -1]:
    print("0")
else:
    print(d[n//2] - d[n//2 -1])

Buggy submission (verdict: Runtime Error):
n = int(input())
d = sorted(list(map(int,input().split())))
print(d)
print(d[0])
print(d[n//2 + 2])
print(d[n//2 + 1])
if d[n//2 + 1] == d[n//2 +2]:
    print("0")
else:
    print(d[n//2] - d[n//2 -1])
Problem p03036 (python)

Fixed submission:
r,d,x = map(int,input().split())
ansl =[x]
for i in range(10):
  ans = r*ansl[i] - d
  print(ans)
  ansl.append(ans)

Buggy submission (verdict: Runtime Error):
r,d,x = map(int,input().split())
ansl =[x]
for i in range(10):
  ans = r*ansl[i] - d
  print(ans)
Problem p03041 (python)

Fixed submission:
n,k = map(int,input().split())
s = list(input())
s[k-1] = s[k-1].lower()
s ="".join(s)
print(s)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().splt())
s = list(input())
s[k-1] = s[k-1].lower()
s ="".join(s)
print(s)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = input()
s[k-1] = s[k-1].lower()
print(s)
Problem p03242 (python)

Fixed submission:
s = input()
s =s.replace("1","a").replace("9","1").replace("a","9")
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
for i in range(3):
  if s[i] =="1":
    s[i] = "9"
  else:
    s[i] = "1"
print(s)
Problem p03803 (python)

Fixed submission:
a,b = map(int,input().split())
print("Alice" if (a>b and b!=1) or (a==1 and b!=1) else "Bob" if (a<b and a!=1) or(a!=1 and b==1) else "Draw")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
print("Alice" if (a>b and b!=1) or (a==1 and b!=1) else "Bob" (if a<b and a!=1) or(a!=1 and b==1) else "Draw")
Problem p03041 (python)

Fixed submission:
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# import os
# fin = open('in_2.txt', 'r')
# sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str

    # write code
    A = list(S)
    A[K-1] = A[K-1].lower()
    print(''.join(A))

Buggy submission (verdict: Runtime Error):
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
import os
fin = open('in_2.txt', 'r')
sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str

    # write code
    A = list(S)
    A[K-1] = A[K-1].lower()
    print(''.join(A))
Problem p03075 (python)

Fixed submission:
a = []
for i in range(5):
    a.append(int(input()))

k = int(input())
if a[4] - a[0] > k:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
a = []
for i in range(5):
    a.append(int(input()))

k = int(input())
if a[5] - a[0] > k:
    print(":(")
else:
    print("Yay!")
Problem p03108 (python)

Fixed submission:
from sys import stdin
class UnionFind:
    def __init__(self, n):
        # par[x]: x が根のときは x を含むグループのサイズ (の -1 倍)、そうでないときは親ノード
        self.par = [-1 for i in range(n + 1)]

    # 親ノードの検索
    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    # 併合
    # x と y を同じグループにする, 計算量はならし O(α(n))
    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x

    # x と y が同じグループにいるか, 計算量はならし O(α(n))
    def issame(self, x, y):
        return self.root(x) == self.root(y)

    # size(x): x を含むグループの所属メンバー数
    def size(self, x):
        return -self.par[self.root(x)]


if __name__ == '__main__':
    N, M = list(map(int, input().split()))
    # print(Town.par)
    Island = UnionFind(N)
    A = [None]*M
    B = [None]*M
    cntlist = [0]*M
    cnt = N*(N-1)//2
    for i in range(M):
        A[i],B[i] = map(int,stdin.readline().rstrip('\n').split())
    # print(A,B)
    for i in range(M-1,0,-1):
        if Island.root(A[i]) == Island.root(B[i]):
            cntlist[i] = cnt
            continue
        else:
            cnt -= (Island.size(A[i]))*(Island.size(B[i]))
            Island.union(A[i],B[i])
        # for i in range(N+1):
        #     print(Island.size(i),end=',')
        # print()
        # print(cnt)
            cntlist[i] = cnt

    # print(Island.par)
    for i in range(1,M):
        print(cntlist[i])
    print(N*(N-1)//2)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

# BEGIN CUT HERE
class UnionFind():
    def __init__(self,n):
        self.data = [-1] * n
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.data[x] < self.data[y]:
            x, y = y, x  # swap
        self.data[x] += self.data[y]
        self.data[y] = x
    
    def find(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.find(self.data[x])
        return self.data[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return self.data[self.find(x)]
        
# END CUT HERE

def ABC120_D():
    n, m = mi()
    a = [0] * m
    b = [0] * m
    for i in range(m):
        a[i], b[i] = mi()
        
    uf = UnionFind(n)
    ans = [0] * (m + 1)
    ans[m] = n * (n - 1) // 2

    for i in range(m - 1, -1, -1):
        a[i] -= 1
        b[i] -= 1
        ans[i] = ans[i + 1]
        if uf.same(a[i], b[i]):
            continue
        
        x = uf.size(a[i])
        y = uf.size(b[i])
        ans[i] -= x * y
        
        uf.unite(a[i],b[i])
    
    for i in range(1, m + 1):
        print(ans[i])



if __name__ == '__main__':
    ABC120_D()
Problem p03127 (python)

Fixed submission:
N = int(input())
import math
#ユークリッド互除法の関数の定義
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
x = list(map(int,input().split()))

if N==1:
    print(x[0])
else:
    element = gcd(x[0], x[1])
    if N==2:print(element)
    else:
        for i in range(2,N):
            element=gcd(element,x[i])
        print(element)

# print(gcd_list(numbers))

Buggy submission (verdict: Runtime Error):
N = int(input())
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
numbers = list(map(int,input().split()))

print(gcd_list(numbers))
Problem p03286 (python)

Fixed submission:
N = int(input())
minus_bit = ''
if N == 0:
    minus_bit = '00'
while N != 0:
    mod = N % 4
    if mod == 0:
        minus_bit = minus_bit + '00'
        N = N//4
    elif mod == 1:
        minus_bit = minus_bit + '10'
        N = (N-1)//4
    elif mod == 2:
        minus_bit = minus_bit + '01'
        N = (N+2)//4
    else:
        minus_bit = minus_bit + '11'
        N = (N+1)//4

if minus_bit[-1] == '0':
    minus_bit = minus_bit[:-1]
print(minus_bit[::-1])

Buggy submission (verdict: Runtime Error):
  N = int(input())
  minus_bit = ''
  if N == 0:
      minus_bit = '00'
  while N != 0:
      mod = N % 4
      if mod == 0:
          minus_bit = minus_bit + '00'
          N = N//4
      elif mod == 1:
          minus_bit = minus_bit + '10'
          N = (N-1)//4
      elif mod == 2:
          minus_bit = minus_bit + '01'
          N = (N+2)//4
      else:
          minus_bit = minus_bit + '11'
          N = (N+1)//4

  if minus_bit[-1] == '0':
      minus_bit = minus_bit[:-1]
  print(minus_bit[::-1])
Problem p03329 (python)

Fixed submission:
import math
N = int(input())

dp = [10**7 for i in range(100010)]
dp[0] = 0

for i in range(1,N+1):
    dp[i] = min(dp[i-1]+1,min([dp[i-pow(6,j)]+1 for j in range(int(math.log(i,6)+1))]),min([dp[i-pow(9,j)]+1 for j in range(int(math.log(i+10**(-10),9))+1)]))

print(dp[N])

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

dp = [10**7 for i in range(100000)]
dp[0] = 0

for i in range(1,N+1):
    dp[i] = min(dp[i-1]+1,min([dp[i-pow(6,j)]+1 for j in range(int(math.log(i,6)+1))]),min([dp[i-pow(9,j)]+1 for j in range(int(math.log(i,9))+1)]))

print(dp[N])
Problem p02597 (python)

Fixed submission:
n=int(input())
from collections import deque
q =deque(input())

ans = 0
while q:
    while q and q[0] == 'R' and q:
        q.popleft()
    while q and q[-1] == 'W' and q:
        q.pop()
    if not q:break
    ans += 1
    q.popleft()
    q.pop()
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
from collections import deque
q =deque(input())

ans = 0
while q:
    while q[0] == 'R':
        q.popleft()
    while q[-1] == 'W':
        q.pop()
    ans += 1
    q.popleft()
    q.pop()
print(ans)
Problem p02629 (python)

Fixed submission:
n=int(input())

ans = ''
while n:
    tmp = (n-1)%26
    ans += chr(ord('a')+tmp)
    n-=1
    n//=26
print(ans[::-1])

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

ans = ''
while n:
    tmp = (n-1)%26
    ans += chr(ord('a')+tmp)
    n//=26
print(ans[::-1])n=int(input())

ans = ''
while n:
    tmp = (n-1)%26
    ans += chr(ord('a')+tmp)
    n//=26
print(ans[::-1])