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

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

#２整数の最大公約数を求める

def gcd2(x,y): 
    while y != 0:
        x , y = y , x % y 
    return x



#N 整数の最大公約数を求める
#A = [A[0],...,A[N]] とする

def gcd(A):
    ans = A[0]
    for i in range(1,N): #range(1,N)= 1,2,...,N-1
        ans = gcd2(ans, A[i])
    return ans
print(gcd(A))

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

#２整数の最大公約数を求める

def gcd(x,y): 
    while y != 0:
        x , y = y , x % y 
    return x



#N 整数の最大公約数を求める
#A = [A[0],...,A[N]] とする

def gcd(A):
    ans = A[0]
    for i in range(1,N) #range(1,N)= 1,2,...,N-1
        ans = gcd(ans, A[i])
    return ans
print(gcd(A))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

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

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

def judge(A):
    
    count = 0
    for i in range(N):
        if A[i] >= 1:
            count += 1
    if count == 1:
        return 1
    else: return 0
    

while judge(A) == 0:
    A.sort()

    for i in range(N):
        if i >=1:
            A[i] = A[i]%A[0]

for i in range(N):
    if A[i] >= 1:
        print(A[i])
Problem p02935 (python)

Fixed submission:
import heapq

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

heapq.heapify(v)

res = 0
for _ in range(N-1):
  a = heapq.heappop(v)
  b = heapq.heappop(v)
  res = (a+b)/2
  heapq.heappush(v, res)
    
print(res)

Buggy submission (verdict: Runtime Error):
import heapq

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

heapq.heapify(v)

res = 0
for _ in range(int(N/2)+1):
  a = heapq.heappop(v)
  b = heapq.heappop(v)
  res = (a+b)/2
  heapq.heappush(v, res)
    
print(res)
Problem p03775 (python)

Fixed submission:
N = int(input())
M = int(N**0.5)
l = []
if N <= 3:
  print(1)
else:
  for a in range(1, M+1):
    if N % a == 0:
      b = int(N/a)
    else:
      continue
    l.append(max(len(str(a)), len(str(b))))
  print(min(l))

Buggy submission (verdict: Runtime Error):
N = int(input())
M = int(N**0.5)
l = []
if N <= 3:
  print(1)
else:
  for a in range(1, M+1):
    if N % a == 0:
      b = int(N/a)
    else:
      continue
    l.append(max(len(str(a)), len(str(b))))
print(min(l))

Buggy submission (verdict: Runtime Error):
N = int(input())
M = int(N**0.5)
l = []
for a in range(1, M):
  if N % a == 0:
  	b = int(N/a)
  else:
    continue
  l.append(max(len(str(a)), len(str(b))))
print(min(l))
Problem p03805 (python)

Fixed submission:
import itertools

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

for i in range(M): #隣接行列
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)

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

for i in range(N):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

def dfs(v, used):
    if not False in used:
        return 1

    ans = 0
    for i in range(N):
        if not adj_matrix[v][i]:
            continue
        if used[i]:
            continue
        used[i] = True
        ans += dfs(i, used)
        used[i] = False        
    return ans

used = [False] * N
used[0] = True
print(dfs(0, used))

Buggy submission (verdict: Runtime Error):
import itertools

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

# 隣接行列を作る
for i in range(N):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:  # 始点は1でないといけないから
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)

Buggy submission (verdict: Runtime Error):
import itertools

N, M = map(int, input().split())
adj_matrix = [[0]*N for i in range(N)]

# 隣接行列を作る
for i in range(N):
  a, b = map(int, input().split())
  adj_matrix[a-1][b-1] = 1
  adj_matrix[b-1][a-1] = 1
  
cnt = 0

for each in itertools.permutations(range(N)):
  if each[0] != 0:  # 始点は1でないといけないから
    break
  factor = 1
  for i in range(N-1):
    factor *= adj_matrix[each[i]][each[i+1]]
  cnt += factor

print(cnt)
Problem p02725 (python)

Fixed submission:
k=int(input().split(" ")[0])
a = sorted(map(lambda x: int(x), input().split("\n")[0].split(" ")))
dfs=[k-a[len(a)-1]+a[0]]
for i in range(len(a) - 1):
    dfs.append(a[i+1]-a[i])
print(sum(dfs)-max(dfs))

Buggy submission (verdict: Runtime Error):
k=input().split(" ")[0]
a = list(map(lambda x: int(x), input().split("\n")[1].split(" ")))
df = max(a) - min(a)
print(min(df, k - df))
Problem p02689 (python)

Fixed submission:
from collections import defaultdict

d = defaultdict(list)

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

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

for i in range(M):
    a, b = list(map(int, input().split()))
    d[a-1].append(b-1)
    d[b-1].append(a-1)

ans = 0
for i in range(N):
    ng = 0

    if(i not in d):
        ans += 1
        continue

    for j in d[i]:
        if(H[i] <= H[j]): ng = 1
    if(ng != 1):
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):

d = defaultdict(list)

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

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

for i in range(M):
    a, b = list(map(int, input().split()))
    d[a-1].append(b-1)
    d[b-1].append(a-1)

ans = 0
for i in range(N):
    ng = 0

    if(i not in d):
        ans += 1
        continue

    for j in d[i]:
        if(H[i] <= H[j]): ng = 1
    if(ng != 1):
        ans += 1

print(ans)
Problem p02781 (python)

Fixed submission:
from sys import stdin
from functools import lru_cache

@lru_cache(None)
def solver(N, K):
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    m, r = divmod(N,10)
    ans = 0
    if K >= 1:
        ans += solver(m, K-1) * r
        ans += solver(m-1, K-1) * (9-r)
    ans += solver(m, K)
    return ans


n = int(input())
k = int(input())
print(solver(n,k))

Buggy submission (verdict: Runtime Error):
from sys import stdin
from functools import lru_cache

@lru_cache(None)
def solver(N, K):
    """N以下で0でないものがちょうどK個。0を含める"""
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    # divmod : 商と余りを両方取れる
    m, r = divmod(N,10)
    ans = 0
        # 1の位が nonzero
        ans += solver(m, K-1) * r
        ans += solver(m-1, K-1) * (9-r)
    ans += solver(m, K)
    return ans


n = int(input())
k = int(input())
print(solver(n,k)
Problem p02753 (python)

Fixed submission:
def S(): return input().rstrip()

def main():
    s = S()

    if 'A' in s and 'B' in s:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
ef S(): return input().rstrip()

def main():
    s = S()

    if 'A' in s and 'B' in s:
        print('Yes')
    else:
        print('No')

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

Fixed submission:
import numpy as np
import itertools


N, M, Q = map(int, input().split(" "))

vals = []
for i in range(Q):
    vals.append(list(map(int, input().split(" "))))
    
maxv = 0
cand = list(itertools.combinations_with_replacement(range(1, M+1), N))
for c in cand:
    sumv = 0
    for v in vals:
        if (c[v[1]-1] - c[v[0]-1]) == v[2]:
            sumv += v[3]
    if maxv < sumv:
        maxv = sumv
print(maxv)

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


N, M, Q = map(int, input().split(" "))

vals = []
for i in range(Q):
    vals.append([list(map(int, input().split(" ")))])
    
maxv = 0
cand = list(itertools.combinations_with_replacement(range(1, M+1), N))
for c in cand:
    sumv = 0
    for v in vals:
        if (c[v[1]-1] - c[v[0]-1]) == v[2]:
            sumv += v[3]
    if maxv < sumv:
        maxv = sumv
print(maxv)
Problem p02693 (python)

Fixed submission:
# -*- coding: utf-8 -*-
K=int(input())
A,B=map(int,input().split())
i=1
ans=0
while B>=K*i:
    if A<=K*i:
        ans=1
        break
    i=i+1
if ans==1:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from itertools import itertools_with_replacement
N,M,Q=map(int,input().split())
abcd=[]
for _ in range(Q):
    abcd.append(tuple(map(int,input().split())))
Abase=[]
for a in range(1,M+1):
    Abase=Abase+[a]
A=set(itertools.combinations_with_replacement(Abase,N))
ans=0
for i in A:
    temp=0
    for j in abcd:
        if i[j[1]-1]-i[j[0]-1]==j[2]:
            temp=temp+j[3]
    if temp>=ans:
        ans=temp
print(ans)
Problem p02695 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import itertools
N,M,Q=map(int,input().split())
abcd=[]
for _ in range(Q):
    abcd.append(tuple(map(int,input().split())))
Abase=[]
for a in range(1,M+1):
    Abase=Abase+[a]
A=set(itertools.combinations_with_replacement(Abase,N))
ans=0
for i in A:
    temp=0
    for j in abcd:
        if i[j[1]-1]-i[j[0]-1]==j[2]:
            temp=temp+j[3]
    if temp>=ans:
        ans=temp
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from itertools import itertools.combinations_with_replacement
N,M,Q=map(int,input().split())
abcd=[]
for _ in range(Q):
    abcd.append(tuple(map(int,input().split())))
Abase=[]
for a in range(1,M+1):
    Abase=Abase+[a]
A=set(itertools.combinations_with_replacement(Abase,N))
ans=0
for i in A:
    temp=0
    for j in abcd:
        if i[j[1]-1]-i[j[0]-1]==j[2]:
            temp=temp+j[3]
    if temp>=ans:
        ans=temp
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from itertools import itertools_with_replacement
N,M,Q=map(int,input().split())
abcd=[]
for _ in range(Q):
    abcd.append(tuple(map(int,input().split())))
Abase=[]
for a in range(1,M+1):
    Abase=Abase+[a]
A=set(itertools.combinations_with_replacement(Abase,N))
ans=0
for i in A:
    temp=0
    for j in abcd:
        if i[j[1]-1]-i[j[0]-1]==j[2]:
            temp=temp+j[3]
    if temp>=ans:
        ans=temp
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from itertools import itertools_with_replacement
N,M,Q=map(int,input().split())
abcd=[]
for _ in range(Q):
    abcd.append(tuple(map(int,input().split())))
Abase=[]
for a in range(1,M+1):
    Abase=Abase+[a]
A=set(itertools.combinations_with_replacement(Abase,N))
ans=0
for i in A:
    temp=0
    for j in abcd:
        if i[j[1]-1]-i[j[0]-1]==j[2]:
            temp=temp+j[3]
    if temp>=ans:
        ans=temp
print(ans)
Problem p02829 (python)

Fixed submission:
# -*- coding:utf-8 -*-
A=int(input())
B=int(input())
if A+B==3:
    print(3)
elif A+B==4:
    print(2)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
A=int(input())
B=int(input())
if A+B==3:
    print(3)
elif A+B=4:
    print(2)
else:
    print(1)
Problem p02881 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)
    return divisors

ans=make_divisors(N)

temp=ans[0]+ans[1]-2

for i in range(len(ans)):
    if i%2!=0:
        continue
    if temp>ans[i]+ans[i+1]-2:
        temp=ans[i]+ans[i+1]-2
print(temp)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

ans=make_divisors(N)

temp=ans[0]+ans[1]-2

for i in range(len(ans)):
    if i%2!=0:
        continue
    if temp>ans[i]+ans[i+1]-2:
        temp=ans[i]+ans[i+1]-2
print(temp)
Problem p02987 (python)

Fixed submission:
# -*- coding: utf-8 -*-
S=input()
if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2] :
  print("Yes")
elif S[0]==S[2] and S[1]==S[3] and S[0]!=S[1] :
  print("Yes")
elif S[0]==S[3] and S[1]==S[2] and S[0]!=S[1] :
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
S=input()
if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2] :
  print("Yes")
elif S[0]==S[2] and S[1]==S[4] and S[0]!=S[1] :
  print("Yes")
elif S[0]==S[3] and S[1]==S[2] and S[0]!=S[1] :
  print("Yes")
else:
  print("No")
Problem p02990 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N,K=map(int,input().split())
import math
for i in range(1,K+1):
    ans1=(math.factorial(K-1)//math.factorial(i-1)//math.factorial(K-i))%1000000007
    if N-K-i+1<0:
        print(0)
        continue
    ans2=(math.factorial(N-K+1)//math.factorial(N-K-i+1)//math.factorial(i))%1000000007
    ans=(ans1*ans2)%1000000007
    print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N,K=map(int,input().split())
import math
for i in range(1,K+1):
    ans1=(math.factorial(K-1)//math.factorial(i-1)//math.factorial(K-i))%1000000007
    ans2=(math.factorial(N-K-i+1+i)//math.factorial(N-K-i+1)//math.factorial(i))%1000000007
    ans=(ans1*ans2)%1000000007
    print(ans)
Problem p03011 (python)

Fixed submission:
# -*- coding: utf-8 -*-
p,q,r=map(int,input().split())
print(min(p+q,q+r,r+p))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
p,q,r=map(int,input().split())
ptint(min(p+q,q+r,r+p))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
p,q,r=map(int,input().split())
ptint(min(p+q,q+r,r+p)
Problem p03041 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n,k=map(int,input().split(" "))
s=input()
s=s[:k-1]+s[k-1].lower()+s[k:]
print(s)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n,k=map(int,input().split(" "))
s=input()
s=s[:k-1]+s[k-1].lower()+s[k]
print(s)
Problem p03075 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a=[]
ans="Yay!"
for _ in range(6):
  a.append(int(input()))
for i in range(5):
  for j in range(i+1,5):
    if abs(a[i]-a[j])>a[5]:
      ans=":("
      break
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a=[]
ans="Yay!"
for _ in range(6):
  a.append(int(input()))
for i in range(5):
  for j in range(i+1,5):
    if abs(a(i)-a(j))>a(5):
      ans=":("
      break
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a=[]
ans="Yay!"
for _ in range(6):
  a.append(int(input()))
for i in range(5):
  for j in range(i+1,5):
    if abs(a.append(i)-a.append(j))>a.append(5):
      ans=":("
      break
print(ans)
Problem p03835 (python)

Fixed submission:
# -*- coding: utf-8 -*-
K,S=map(int,input().split())
count=0
for i in range(K+1):
  for j in range(K+1):
    k=S-i-j
    if 0<=k<=K:
      count=count+1
print(count)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
K,S=map(int,input().split())
count=0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      if i+j+k=S:
        count=count+1
print(count)
Problem p02711 (python)

Fixed submission:
N = input()
if N[0] == "7":
    print("Yes")
elif N[1] == "7":
    print("Yes")
elif N[2] == "7":
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
if N[0] == "7":
    print("Yes")
elif N[1] == "7":
    print("Yes")
elif N[2] == "7":
    print("Yes")
else:
    print("No")
Problem p02753 (python)

Fixed submission:
S = input()
if S == "AAA":
    print("No")
elif S == "BBB":
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
list = input().split(" ")
N = int(list[0])
A = int(list[1])
B = int(list[2])

num1 = N // (A + B)
num2 = N % (A + B)
if num2 <= A:
    print(num1 * A + num2)
else:
    print(num1 * A + A)
Problem p02785 (python)

Fixed submission:
list = input().split(" ")
N = int(list[0])
K = int(list[1])
list_hp = input().split(" ")
list_hp = [int(i) for i in list_hp]
list_hp = sorted(list_hp)

if K < N:
    sum = 0
    for i in range(N-K):
        sum = sum + list_hp[i]
    print(sum)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
list = input().split(" ")
N = int(list[0])
K = int(list[1])
list_hp = input().split(" ")
list_hp = [int(i) for i in list_hp]
list_hp = sorted(list_hp)

if K < N:
    for i in range(1,K+1):
        list_hp.pop(-i)
    print(sum(list_hp))
    
else:
    print(0)
Problem p02831 (python)

Fixed submission:
import fractions
A,B = map(int,input().split(" "))
print(int((A * B) / fractions.gcd(A, B)))

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split(" "))
print(int((A * B) / math.gcd(A, B)))

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split(" "))
print((A * B) // math.gcd(A, B))

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split(" "))
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split(" "))
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split(" "))
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split(" "))
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A,B))
Problem p02847 (python)

Fixed submission:
S = input()
Weeks = ["MON","TUE","WED","THU","FRI","SAT","SUN"]
ind = Weeks.index(S)
if S != "SUN":
    print(6-ind)
else:
    print(7)

Buggy submission (verdict: Runtime Error):
S = input()
Weeks = ["MON","TUE","WED","THU","FRI","SAT","SUN"]
ind = Weeks.index(S)
if S != "SUN"
    print(6-ind)
else:
    print(7)
Problem p02860 (python)

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

if N % 2 != 0:
    print("No")
else:
    for i in range(int(N/2)):
        if S[i] != S[i+int(N/2)]:
            print("No")
            exit()
    print("Yes")

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

if N % 2 != 0:
    print("No")
else:
    for i in range(int(N/2)):
        if S[i] != S[i+int(N/2)]:
            print("No")
            exit()
    print("Yes")
Problem p02695 (python)

Fixed submission:
n, m, q = map(int, input().split())

abcd = [list(map(int, input().split())) for _ in range(q)]
from itertools import combinations_with_replacement as cwr
AList = list(cwr(range(1, m+1), n))


maxPoint = 0
for A in AList:
  point = 0
  for abc in abcd:
    a = abc[0]
    b = abc[1]
    c = abc[2]
    d = abc[3]
    if A[b-1] - A[a-1] == c:
      point += d
  if point > maxPoint:
    maxPoint = point
print(maxPoint)

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

abcd = [list(map(int, input().split())) for _ in range(q)]
from itertools import combinations_with_replacement as cwr
A = list(cwr(range(1, m+1), n))


maxPoint = 0
for item in A:
  point = 0
  for i in range(len(abcd)):
    a = abcd[i][0]
    b = abcd[i][1]
    c = abcd[i][2]
    d = abcd[i][3]
    if item[b-1] - item[a-1] == item[c-1]:
      point += d
  if point > maxPoint:
    maxPoint = point
print(maxPoint)

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

abcd = [list(map(int, input.split())) for _ in range(q)]
from itertools import combinations_with_replacement as cwr
A = list(cwr(range(1, m+1), n))


maxPoint = 0
for item in A:
  point = 0
  for i in range(len(abcd))
  a = abcd[i][0]
  b = abcd[i][1]
  c = abcd[i][2]
  d = abcd[i][3]
  if item[b-1] - item[a-1] == item[c-1]:
    point += d
  if point > maxPoint:
    maxPoint = point
print(maxPoint)
Problem p02711 (python)

Fixed submission:
n=input()
ans=0
for i in range(3):
    if int(n[i]) == 7:
        ans=1
print("Yes" if ans == 1 else "No")

Buggy submission (verdict: Runtime Error):
=input()
ans=0
for i in range(3):
    if int(n[i]) == 7:
        ans=1
print("YES" if ans == 1 else "NO")
Problem p02759 (python)

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N = ir()
    print(N//2+N%2)
resolve()

Buggy submission (verdict: Runtime Error):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M, K = lr()
    fri = [[] for _ in range(N)]
    for i in range(M):
        a, b = lr()
        fri[a-1].append(b-1)
        fri[b-1].append(a-1)
    blo = [[] for _ in range(N)]
    for i in range(K):
        c, d = lr()
        blo[c-1].append(d-1)
        blo[d-1].append(c-1)

    can = [[] for _ in range(N)]
    for i in range(N):
        vis = [False for _ in range(N)]
        s = [i]
        while len(s) > 0:
            v = s.pop()
            vis[v] = True
            for j in fri[v]:
                if vis[j]:
                    continue
                s.append(j)
                if j not in fri[i] and j not in blo[i] and j not in can[i]:
                    can[i].append(j)
    ans = []
    for i in range(N):
        ans.append(len(can[i]))
    print(*ans, sep=' ')
resolve()
Problem p02933 (python)

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

Buggy submission (verdict: Runtime Error):
a=int(input())
s=string(input())
if (a>=3200) :
 print(s)
else :
 print("red")
Problem p02819 (python)

Fixed submission:
# C
X = int(input())
import math

import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

for i in range(X, 10**9):
    if (is_prime(i)):
        print(i)
        break

Buggy submission (verdict: Runtime Error):
# C
X = int(input())
import math

def isPrime(n):
    if n % 2 == 0:
        return False
  
    m = math.floor(math.sqrt(n))
    for p in prime_numbers:
        if n % p == 0:
            return False
        if p > m:
        # 素数がnの平方根を超えたら終了
            break
    return True

for i in range(X, 10**9):
    if (is_prime(i)):
        print(i)
        break
Problem p02881 (python)

Fixed submission:
# C
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ans = N - 1
lst = make_divisors(N)
if (len(lst) % 2 == 0):
    for i in range(0, len(lst), 2):
        num = lst[i] + lst[i+1] - 2
        ans = min(ans,num)
else:
    for i in range(0, len(lst)-1, 2):
        num = lst[i] + lst[i+1] - 2
        ans = min(ans,num)
    ans = min(ans,2*lst[-1] - 2)
print(ans)

Buggy submission (verdict: Runtime Error):
# C
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ans = N - 1
lst = make_divisors(N)
for i in range(0, len(lst), 2):
    num = lst[i] + lst[i+1] - 2
    ans = min(ans,num)

print(ans)
Problem p02891 (python)

Fixed submission:
S = input()
K = int(input())
lst = []

cnt = 1
ans = 0
if (len(S) != 1):
  for i in range(len(S)-1):
    if (S[i] == S[i+1]):
      cnt += 1
      if (i == len(S)-2):
        lst.append(cnt)
    else:
      lst.append(cnt)
      cnt = 1
      
  if (len(lst) == 1):
    ans = len(S)*K // 2
  else:
    for i in lst:
      ans += i // 2
    ans *= K
    
    if (S[0] == S[-1] and lst[0] % 2 != 0 and lst[-1] % 2 != 0):
      ans += K-1
else:
  ans = K // 2
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
lst = []

cnt = 1
for i in range(len(S)-1):
  if (S[i] == S[i+1]):
    cnt += 1
    if (i == len(S)-2):
      lst.append(cnt)
  else:
    lst.append(cnt)
    cnt = 1
if (S[0] == S[-1]):
  lst[-1] += 1

ans = 0
for i in lst:
  ans += i // 2
print(ans*K)