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

Fixed submission:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
from math import factorial
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

MOD = 10**9+7
def comb(n, r):
    return factorial(n)  // (factorial(n - r) * factorial(r)) % MOD
    
N,K = Is()
for i in range(1,K+1):
#    print(i,K-1,i-1,N-K+1,i)
    if N-K+1 < i:
        print(0)
    else:
        print((comb(K-1,i-1) * comb(N-K+1,i)) % MOD)

Buggy submission (verdict: Runtime Error):
import sys,collections,math,random;sys.setrecursionlimit(10**7)
from math import factorial
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

MOD = 10**9+7
def comb(n, r):
    return factorial(n)  // (factorial(n - r) * factorial(r)) % MOD
    
N,K = Is()
for i in range(1,K+1):
#    print(K-1,i-1,N-K+1,i)
#    print(comb(K-1,i),comb(i+2,N-K-i))
    print((comb(K-1,i-1) * comb(N-K+1,i)) % MOD)
Problem p03332 (python)

Fixed submission:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 998244353 #出力の制限
N = 3*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,A,B,K = Is()
ans = 0
for x in range(N+1):
    y = (K-A*x)/B
    if 0 <= y <= N and y.is_integer():
        ans += cmb(N,x,mod)*cmb(N,int(y),mod) % mod
print(ans % mod)

Buggy submission (verdict: Runtime Error):
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

MOD = 998244353

def comb(n, r):
    if n == 0 or r == 0: return 1
    return ( comb(n, r-1) % MOD) * (n-r+1) / r
    
N,A,B,K = Is()
ans = 0
for x in range(N+1):
    if (K-A*x)/B >= 0 and (K-A*x)/B == int((K-A*x)/B):
        ans += comb(N,x)*comb(N,(K-A*x)/B) % MOD
print(int(ans))
Problem p03631 (python)

Fixed submission:
n = input()
s = []
for i in range(len(n)):
    s.append(n[len(n)-1-i])
if(n=="".join(s)):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
class edge():
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

N = int(input())
tree = [[] for i in range(N)]

for i in range(N-1):
    a,b,c = list(map(int,input().split()))
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))
Q,K = list(map(int,input().split()))
K = K - 1
dmax = 10**14 + 1
depth = [dmax for _ in range(N+1)]
depth[K] = 0

def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to == p:
            continue
        DFS(e.to, v, d + e.cost)
DFS(K,-1,0)

for _ in range(Q):
    x,y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])

Buggy submission (verdict: Runtime Error):

class edge():
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

N = int(input())
tree = [[] for i in range(N)]

for i in range(N-1):
    a,b,c = list(map(int,input().split()))
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))
Q,K = list(map(int,input().split()))
K = K - 1

depth = [-1] * N

def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to == p:
            continue
        DFS(e.to, v, d + e.cost)
DFS(K,-1,0)

for _ in range(Q):
    x,y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])

Buggy submission (verdict: Runtime Error):
class edge():
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

N = int(input())
tree = [[] for i in range(N)]

for i in range(N-1):
    a,b,c = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))
Q, K = list(map(int, input().split()))
K = K - 1

depth = [0]*N
def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to==p :
            continue
        DFS(e.to, v, d + e.cost)
DFS(K,-1,0)

for q in range(Q):
    x,y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])

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

class edge:
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

tree = [[] for i in range(N)]

for i in range(N-1):
    a,b,c = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))

Q, K = list(map(int, input().split()))
K = K - 1
depth = [0]*N

def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to==p :
            continue
        DFS(e.to, v, d + e.cost)

DFS(K,-1,0)

for q in range(Q):
    x,y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])
Problem p02577 (python)

Fixed submission:
N =input()
array = list(map(int, N))

if sum(array) % 9 == 0:
  print("Yes")
else:
  print("No")

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

while True:
  i += N % 10
  i = i % 9
  N = int(N/10)
  if N < 10:
    i += N
    break

if i % 9 == 0:
  print("Yes")
else:
  print("No")

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

while True:
  i += N % 10
  i = i % 9
  N = int(N/10)
  if N == 0:
    break

if i % 9 == 0:
  print("Yes")
else:
  print("No")

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

while True:
  i += int(N % 10)
  N = int(N/10)
  if N == 0:
    break

if i % 9 == 0:
  print("Yes")
else:
  print("No")

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

while True:
  i += N % 10
  N = int(N/10)
  if N == 0:
    break

if i % 9 == 0:
  print("Yes")
else:
  print("No")
Problem p02622 (python)

Fixed submission:
s = input()
t = input()

sl = list(s)
tl = list(t)

count = 0

for (a, b) in zip(sl, tl):
  if a!=b:
    count+=1
    
print(count)

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

sl = list(s)
tl = list(t)

count = 0

for (a, b) in zip(sl, tl):
  if a!=b:
    count++
    
print(count)

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

sl = list(s)
tl = list(t)

count = 0

for a, b in sl, tl:
  if a!=b:
    count++
    
print(count)
Problem p03104 (python)

Fixed submission:
def func(a):
    if(0 == a % 4):
        return(a)
    if(1 == a % 4):
        return(1)
    if(2 == a % 4):
        return(a + 1)
    if(3 == a % 4):
        return(0)

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

print(func(A - 1) ^ func(B))

Buggy submission (verdict: Runtime Error):
import math

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

datanum = B - A + 1
depth = int(math.ceil(math.log2(datanum)))
#print("datanum = {}, depth = {}".format(datanum, depth))
a = [[0] * (2 ** depth) for i in range(depth + 1)]
a[0][0:datanum] = range(A, B + 1)
#print("a = ")
#print(a)

cnt = int(2 ** depth)
for i in range(depth):
#    print("cnt = " + str(cnt))
    k = 0
    for j in range(0, cnt, 2):
#        print("[{}][{}] <- [{}][{}] ^ [{}][{}]".format(i + 1, k, i, j, i, j + 1))
        a[i + 1][k] = a[i][j] ^ a[i][j + 1]
        k = k + 1
    cnt = cnt // 2
ans = a[depth][0]

print(ans)
Problem p02759 (python)

Fixed submission:
x = int(input())

print((x+1)//2)

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

print(n+1//2)
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())

if (a == 1 and b == 2) or (a == 2 and b == 1) :
  print(3)
elif (a == 2 and b == 3) or (a == 3 and b == 2) :
  print(1)
elif (a == 1 and b == 3) or (a == 3 and b == 1) :
  print(2)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if (a == 1 and b == 2) or (a == 2 and b == 1) :
  print(3)
elif (a == 2 and b == 3) or (a == 3 or b == 2) :
  print(1)
else:
  pritn(2)
Problem p02659 (python)

Fixed submission:
a,b=map(int,input().replace('.','').split())

print(int(a*b//100))

Buggy submission (verdict: Runtime Error):
import math
from collections import deque
a,b=map(float,input().split())
a=int(a)
A=a
lst=deque()
while a > 0:
    lst.append(a%10)
    a //= 10
lst.reverse()

c=lst.pop()
if len(lst)>=2:
  c+=10*lst.pop()
d=math.floor(c*b)

A-=c
A=int(A/100)
b=int(b*100)
print(A*b+d)
Problem p02597 (python)

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

W=0
R=C.count("R")
ans=R
for i in range(N):
    
    if C[i]=="R":
        R-=1
    else:
        W+=1
    if  ans>max(W,R):
        ans=max(W,R)
print(ans)

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

for i in range(N):
    if C[i]=="R":
        C=C[i:]
        break

if C[-1]=="R":
    for i in range(1,N):
        if C[-i]=="W":
            C=C[:-i+1]
            break    
    

print(min(C.count("R"),C.count("W")))

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

for i in range(N):
    if C[i]=="R":
        C=C[i:]
        break

for i in range(1,N):
    if C[-i]=="W":
        C=C[:-i+1]
        break    
    

print(min(C.count("R"),C.count("W")))

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

for i in range(N):
    if C[i]=="R":
        C=C[i:]
        break
for i in range(N):
    if C[-i]=="W":
        C=C[:-i+1]
        break    
    

print(min(C.count("R"),C.count("W")))
Problem p02623 (python)

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

Asum=[0]
Bsum=[0]

for i in range(N):
    Asum.append(Asum[-1]+A[i])
        
for i in range(M):
    Bsum.append(Bsum[-1]+B[i])
    
m=0
j=M

for i in range(len(Asum)):
    if Asum[i]>K:
        break
    while Asum[i]+Bsum[j]>K:
        j-=1
    if m<i+j:
        m=i+j
        
print(m)

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

Asum=[0]
Bsum=[0]

for i in range(N):
    Asum.append(Asum[-1]+A[i])
        
for i in range(M):
    Bsum.append(Bsum[-1]+B[i])
    
m=0
j=M

for i in range(len(Asum)):
    if Asum[i]>K:
        break
    elif Asum[i]+Bsum[j]<=K and m<i+j:
        m=i+j
    elif:
        j-=1
print(m)

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

Asum=[0]
Bsum=[0]

for i in range(N):
    Asum.append(Asum[-1]+A[i])
    if Asum[i]>K:
        break
        
for i in range(M):
    Bsum.append(Bsum[-1]+B[i])
    if Bsum[i]>K:
        break
    
m=0
for i in range(len(Asum)):
    for j in range(len(Bsum)):

    elif Asum[i]+Bsum[j]<=K and m<i+j:
        m=i+j
print(m)

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

Asum=[0]
Bsum=[0]

for i in range(N):
    Asum.append(Asum[-1]+A[i])
    if Asum[i]>K:
        break
        
for i in range(M):
    Bsum.append(Bsum[-1]+B[i])
    if Bsum[i]>K:
        break
    
m=0
for i in range(len(Asum)):
    for j in range(len(Bsum)):

        elif Asum[i]+Bsum[j]<=K and m<i+j:
            m=i+j
print(m)
Problem p02659 (python)

Fixed submission:
A, B=(input().split())
A=int(A)
C=int(B[0])*100+int(B[2])*10+int(B[3])
print(int(A*C//100))

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

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

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

def lte_k(x, len_list):
    counter = 0
    for item in len_list:
        counter += math.ceil(item / x) - 1
    return counter <= k

def binary_search():
    low = 0
    high = max(a)

    while low < high-1:
        mid = (low + high) // 2
        guess = lte_k(mid, a)
        if guess:
            high = mid
        else:
            low = mid
    return high

print(binary_search())
Problem p02659 (python)

Fixed submission:
A, B = input().split()
 
A = int(A)
B = float(B)
B = round((B*100))
 
print((A*B)//100)

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

A = int(A)
B = float(B)
B = (B*100).round()

print((A*B)//100)
Problem p02679 (python)

Fixed submission:
from math import gcd
from numpy import sign
mod = 1000000007
N = int(input())

d = {}
counter = 0

f = 0
l = 0

for _ in range(N):
    a, b = list(map(int, input().split()))
    if a == b == 0:
        counter += 1
    elif a==0:
        f += 1
    elif b==0:
        l += 1
    else:
        g = gcd(a, b)
        a, b =  a // g, b //g
        if b < 0:
            a, b = -a, -b
        if (a, b) not in d:
            d[(a, b)] =1
        else:
            d[(a, b)] +=1

answer = 1

group = set()
for (p, q), v in d.items():
    invp,invq=-q,p
    if invq<0:
        invp,invq=-invp,-invq
    if not (invp,invq) in group:
        group.add((p,q))

for (p, q) in group:
    invp,invq=-q,p
    if invq<0:
        invp,invq=-invp,-invq
    if (invp, invq) not in d:
        answer *= (2 ** d[(p, q)])
    else:
        answer *= ((2 ** d[(p, q)]) + (2 ** d[(invp, invq)]) - 1)
        
answer *= 2**f + 2**l - 1
    
print((answer + counter - 1) % mod)

Buggy submission (verdict: Runtime Error):
from math import gcd
from numpy import sign
mod = 1000000007
N = int(input())

if N == 1:
    print(1)
    
d = {}
counter = 0

f = 0
l = 0

for _ in range(N):
    a, b = list(map(int, input().split()))
    if a == b == 0:
        counter += 1
    elif a==0:
        f += 1
    elif b==0:
        l += 1
    else:
        g = gcd(a, b)
        a, b =  a // g, b //g
        if b < 0:
            a, b = -a, -b
        if (a, b) not in d:
            d[(a, b)] =1
        else:
            d[(a, b)] +=1

answer = 1


group = set()
for (p, q), v in d.items():
    invp,invq=-q,p
    if invq<0:
        invp,invq=-invp,-invq
    if not (invp,invq) in group:
        group.add((p,q))

for (p, q), v in group:
    invp, invq = (sign(p) * (-1) * q, abs(p))
    if (invp, invq) not in d:
        answer *= (2 ** d[(p, q)]) % mod
        answer = answer % mod
    else:
        answer *= ((2 ** d[(p, q)]) + (2 ** d[(invp, invq)]) - 1) % mod
        answer = answer % mod
        
answer *= 2**f + 2**l - 1
    
print((answer + counter - 1) % mod)

Buggy submission (verdict: Runtime Error):
from math import gcd
from numpy import sign
mod = 1000000007
N = int(input())

if N == 1:
    print(1)
    
d = {}

search_list = []

for _ in range(N):
    a, b = list(map(int, input().split()))
    if a == b == 0:
        if (0, 0) not in d:
            d[(0, 0)] = 1
        else:
            d[(0, 0)] += 1
    else:
        g = gcd(a, b)

        a, b =  a / g, b /g
        if b < 0:
            a, b = -a, -b
        if b == 0:
            a, b =  1, 0
        if (a, b) not in d:
            d[(a, b)] =1
        else:
            d[(a, b)] +=1

answer = 1



for k in list(d.keys()):
    if k not in done_list and k != (0, 0):
        pair_k = (sign(k[0]) * (-1) * k[1], abs(k[0]))
        if pair_k not in d:
            answer *= (2 ** d[k]) % mod
            answer = answer % mod
            done_list += [k]
        else:
            answer *= ((2 ** d[k]) + (2 ** d[pair_k]) - 1) % mod
            answer = answer % mod
            done_list += [k, pair_k]

if (0, 0) in d:
    answer += d[(0, 0)]
    
print((answer - 1) % mod)
Problem p02682 (python)

Fixed submission:
a, b, c, k = list(map(int, input().split()))
if k < a:
    print(k)
elif k < a+b:
    print(a)
else:
    print(a-(k-a-b))

Buggy submission (verdict: Runtime Error):
a, b, c, k = list(map(input().split()))
if k < a:
    return k
elif k < a+b:
    return a
else:
    return a - (k-a-b)
Problem p02572 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split(" ")]

from itertools import combinations

mod = 1000000007  # 丁度いい大きさの素数だけで意味は特にない。

s = 0
ans = 0
for n in A:
    s += n
    s %= mod

for i in range(N):
    s -= A[i]
    ans += A[i] * s
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input)
A = [int(x) for x in input().split(" ")]

from itertools import combinations

mod = 1000000007  # 丁度いい大きさの素数だけで意味は特にない。
s = 0
for c in combinations(A, 2):
    s += c[0] * c[1]

print(s % mod)
Problem p02577 (python)

Fixed submission:

strN = input()
s = 0
for c in strN:
  s += int(c)

if s % 9 == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):

strN = input()
s = 0
for c in strN:
  s += int(c)

  if s % 9 == 0:
    print("Yes")
    else:
      print("No")
Problem p02762 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [-1] * n
        # rank
        self.size = [1] * n

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        self.par[y]=x
        self.size[x]+=self.size[y]

import sys
input=sys.stdin.readline
n,m,k=map(int,input().split())
uf=UnionFind(n)
out=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
    out[a-1].append(b-1)
    out[b-1].append(a-1)

for i in range(k):
    c,d=map(int,input().split())
    if uf.check(c-1,d-1):
        out[c-1].append(d-1)
        out[d-1].append(c-1)

for i in range(n):
    ans=uf.size[uf.find(i)]-1-len(out[i])
    print(ans,end=' ')

Buggy submission (verdict: Runtime Error):
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [-1] * n
        # rank
        #self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        self.par[y]=x
        self.size[x]+=self.size[y]

import sys
input=sys.stdin.readline
n,m,k=map(int,input().split())
uf=UnionFind(n)
out=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
    out[a-1].append(b-1)
    out[b-1].append(a-1)

for i in range(k):
    c,d=map(int,input().split())
    if uf.check(c-1,d-1):
        out[c-1].append(d-1)
        out[d-1].append(c-1)

for i in range(n):
    ans=uf.size[uf.find(i)]-1-len(out[i])
    print(ans,end=' ')
Problem p02793 (python)

Fixed submission:
#E
n=int(input())
a=tuple(map(int,input().split()))
import fractions
lcm=a[0]
b_sum=0
for i in range(1,n):
    lcm=lcm*a[i]//fractions.gcd(lcm,a[i])

num=10**9+7
for i in range(n):
    b_sum+=(lcm//a[i])

print(b_sum%num)

Buggy submission (verdict: Runtime Error):
#E
n=int(input())
a=tuple(map(int,input().split()))
import fractions
lcm=a[0]
ans=1/a[0]
for i in range(1,n):
    lcm=lcm*a[i]//fractions.gcd(lcm,a[i])
    ans+=1/a[i]
num=10**9+7
print(int(ans*lcm)%num)
Problem p02831 (python)

Fixed submission:
a,b=map(int,input().split())
import fractions
 
gcd=fractions.gcd(a,b)#最大公約数
lcm=a*b//gcd#最小公倍数least common multiple
print(lcm)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
import fractions

gcd=fractions.gcd(a,b)#最大公約数
lcm=a*b//gcd#最小公倍数least common multiple
print(lmc)
Problem p02881 (python)

Fixed submission:
n=int(input())
l=list(range(2,int(n**0.5//1+1)))
ans=n-1
count=0
for i in l:
    if n%i==0:
        a=i+int(n/i)-2
        ans=min(ans,a)
        count+=1
print(ans if count>0 else n-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(range(2,n+1))
ans=10**9
for i in l:
    if n%i==0:
        a=i+int(n/i)-2
        ans=min(ans,a)
print(ans)
Problem p02933 (python)

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

Buggy submission (verdict: Runtime Error):
s,t=input(),input()
count=0
for i in range(3):
    if s[i]==t[i]:
        count+=1

print(count)
Problem p02951 (python)

Fixed submission:
A,B,C=map(int,input().split())
if (A-B)>=C:
    print(0)
else:
    ans=C-A+B
    print(ans)

Buggy submission (verdict: Runtime Error):
A,B,C=int(input()),int(input()),int(input())
if (A-B)>=C:
    print(0)
else:
    print(C-A+B)

Buggy submission (verdict: Runtime Error):
A,B,C=int(input()),int(input()),int(input())
if (A-B)>=C:
    print(0)
else:
    print(C-(A-B))

Buggy submission (verdict: Runtime Error):
A,B,C=int(input()),int(input()),int(input())
if (A-B)>=C:
    print('0')
else:
    print(C-(A-B))
Problem p03127 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
import fractions as ft


ans=a[0]
for i in a:
    ans=ft.gcd(ans,i)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
def solve():
    a=sorted(a)
    ans=a[0]#暫定最小

    if len(set(a))!=1:
        for _ in range(a[0]):
            for i in range(n):
                amari=a[i]%ans
                
                if amari>0:
                    if amari<ans:
                        ans=amari
            if ans==1:
                break
    print(ans)

solve()

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
ans=a[0]#暫定最小

amari=[ans]
if len(set(a))!=1:
    for _ in range(a[0]):
        for i in range(n):
            if a[i]%ans>0:
                amari+=[a[i]%ans]
            ans=min(amari)
    if ans==1:
        break
print(ans)
Problem p03315 (python)

Fixed submission:
s=input()
s=list(s)
sum1=0
for i in range(4):
    if s[i]=='+':
        sum1+=1
    else:
        sum1+=-1
print(sum1)

Buggy submission (verdict: Runtime Error):
s=input()
s=[*s]
sum1=0
for i in range(4):
    if s[i]=='+':
        sum1+=1
    else:
        sum1+=-1
print(sum1)
Problem p03724 (python)

Fixed submission:
from collections import defaultdict
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
cnt=defaultdict(lambda :0)

for i in range(m):
    for j in range(2):
        cnt[ab[i][j]]+=1

for i in cnt.values():
    if i%2!=0:
        print('NO')
        exit()
print('YES')

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
cnt=defaultdict(lambda :0)

for i in range(m):
    for j in range(2):
        cnt[ab[i][j]]+=1

for i in cnt.values():
    if i%2!=0:
        print('NO')
        exit()
print('YES')