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

Fixed submission:
import math

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

if (N==0 or N==1) and (M==0 or M==1):
  print(0)
elif (N==0 or N==1) and (M!=0 and M!=1):
  print(int(math.factorial(M)/math.factorial(M-2)/math.factorial(2)))
elif (M==0 or M==1) and (N!=0 and N!=1):
  print(int(math.factorial(N)/math.factorial(N-2)/math.factorial(2)))
else:
  print(int(math.factorial(N)/math.factorial(N-2)/math.factorial(2)+math.factorial(M)/math.factorial(M-2)/math.factorial(2)))

Buggy submission (verdict: Runtime Error):
import math

N,M=map(int,input().split())
if N==1 and M==1:
  print(0)
elif N==1 and M!=1:
  print(int(math.factorial(M)/math.factorial(M-2)/math.factorial(2)))
elif M==1 and N!=1:
  print(int(math.factorial(N)/math.factorial(N-2)/math.factorial(2)))
else:
  print(int(math.factorial(N)/math.factorial(N-2)/math.factorial(2)+math.factorial(M)/math.factorial(M-2)/math.factorial(2)))

Buggy submission (verdict: Runtime Error):
import math

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

print(int(math.factorial(N)/math.factorial(N-2)/math.factorial(2)+math.factorial(M)/math.factorial(M-2)/math.factorial(2)))
Problem p02729 (python)

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

Buggy submission (verdict: Runtime Error):
import sys
N=int(sys.stdin.readline())
L=list(map(int,sys.stdin.readline().split()))
count=[0]*N
C=list(set(L))
x=0
d=[0]*len(C)
e=[0]*N
for i in range(len(C)):
  d[i] = int((L.count(C[i]))*(L.count(C[i])-1)/2)
  x += d[i]  
for K in range(N):
  e[K] = L.count(L[K])-1
  print(x-e[K])
Problem p03775 (python)

Fixed submission:
def p(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
def P(L):
  P = 1
  for c in range(len(L)):
    P = P*L[c]
  return P  
N = int(input())
A = p(N)
F = []
for i in range(2**(len(A))):
  B = []
  C = []
  for j in range(len(A)):
    if(i>>j&1):
      B.append(A[j])
    else:
      C.append(A[j])
  F.append(max(len(str(P(B))),len(str(P(C)))))
  
print(min(F))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(int(N**0.5)):
  if N%(i+1) == 0:
    A.append(i)
print(len(str(int(N/A[-1]))))
Problem p02659 (python)

Fixed submission:
a, b = input().split()
a=int(a)
b = int(b.replace('.',''))
c = a*b
c = c//100
print(c)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
a=int(a)
b = int(b*100)
c = a*b
c = c//100
print(c)
Problem p02682 (python)

Fixed submission:
a, b, c, k = [int(e) for e in input().split()]

count=0

if k <= a:
    count +=k
elif k <= a+b:
    count +=a
else:
    count = 2*a + b - k

print(count)

Buggy submission (verdict: Runtime Error):
a, b, c, k = [int(e) for e in input().split()]

import numpy as np

all = np.zeros(a+b+c)
all[:a] +=1
all[-c:] -=1

print(int(sum(all[:k])))

Buggy submission (verdict: Runtime Error):
a, b, c, k = [int(e) for e in input().split()]

import numpy as np

all = np.zeros(a+b+c)
all[:a] +=1
all[-c:] -=1

print(int(sum(all[:a+b])))

Buggy submission (verdict: Runtime Error):
a, b, c, k = [int(e) for e in input().split()]

import numpy as np

all = np.zeros(k)
all[:a] +=1
all[a+b:] -=1

print(sum(all))
Problem p02695 (python)

Fixed submission:
n, m, q = [int(e) for e in input().split()]

import itertools as it
abcd=list()
for i in range(q):
    abcd.append([int(e) for e in input().split()])


all = it.combinations_with_replacement(range(1,m+1),n)

count=list()
num=0
for i in all:
    for j in abcd:
        if i[j[1]-1]-i[j[0]-1] == j[2]:
            num += j[3]
        else:
            pass
    count.append(num)
    num=0

print(max(count))

Buggy submission (verdict: Runtime Error):
n, m, q = [int(e) for e in input().split()]

import itertools as it
abcd=list()
for i in range(q):
    abcd.append([int(e) for e in input().split()])


all = it.combinations(range(1,m+1),n)

count=list()
num=0
for i in all:
    for j in abcd:
        if i[j[1]-1]-i[j[0]-1] == j[2]:
            num += j[3]
        else:
            pass
    count.append(num)
    num=0



print(max(count))
Problem p02623 (python)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])

    
ans, j = 0, 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()))

a, b = [0], [0]
for i in range(N):
a.append(a[i] + A[i])
for i in range(M):
b.append(b[i] + B[i])

ans, j = 0, 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)
Problem p02699 (python)

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

S,W = map(int, input().split())

if W >= S :
    print("unsafe")
else:
    print("safe")

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

import sys

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

if C - B <= 0:
    print("yes")
    sys.exit()
elif A - D <= 0:
    print("No")
    sys.exit()

aoki = C - B
taka = A - D

for i in range(1000):
    aoki -= B
    if aoki <= 0:
        print("Yes")
        break
    
    taka -= D
    if taka <= 0:
        print("No")
        break
Problem p02712 (python)

Fixed submission:

N = int(input())

total = 0

for i in range(N):

    if (i+1) % 15 == 0:
        pass
    elif (i+1) % 3 == 0:
        pass
    elif (i+1) % 5 == 0:
        pass
    else:
        total += (i+1)
        
print(total)

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

#入力
n = int(input())

#要素数の確認
def element_check(before,after,matirx):
    diff = after - before
    if diff == 1:
        a = np.delete(matirx,-1)
        return a
    if diff == 2:
        a = np.delete(matirx,-1)
        b = np.delete(a,-1)
        return b

#3の倍数をFに変更
def multiples_3(matrix):
    #列ベクトルを削除(3列目)
    m_de = np.delete(fizzbuzz_list, [2, 3], axis=1)
    #Fの列ベクトルを作成
    f_list = np.zeros(j,dtype = object).reshape(-1, 1)
    f_list.fill("F")
    #結合
    result = np.concatenate([m_de, f_list], 1)
    return result

#列を計算(繰り上げ)
j = -(-n // 3)

#1からnまでの配列を作成
fizzbuzz_list = np.arange(1,n+1,dtype=object)
#要素数
before_size = fizzbuzz_list.size
#3*n行列に変更
fizzbuzz_list.resize((j,3))

#3の倍数をFに変更
fizzbuzz_list = multiples_3(fizzbuzz_list)

#5の倍数をBに変更
n_b_1 = np.arange(3,j,5)
n_b_2 = np.arange(1,j,5)

fizzbuzz_list[n_b_1,0] = "B"
fizzbuzz_list[n_b_2,1] = "B"

#15の倍数をFBに変更
n_fb = np.arange(4,j,5)
fizzbuzz_list[n_fb,2] = "FB"

#要素をチェック
result = element_check(before_size,fizzbuzz_list.ravel().size,fizzbuzz_list.ravel())

print(np.sum(result))

# np.where(fizzbuzz_list[:,2:3],fizzbuzz_list,"F")
Problem p02723 (python)

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

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

Fixed submission:
a, b = map(int, input().split())
if a <= b:
    print(str(a) * b)
else:
    print(a * str(b))

Buggy submission (verdict: Runtime Error):
a,b = list(input().split())
print(min(a*int(b), b*int(a))

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

x=''

for i in range(a):
  x += str(b)
  
y=''

for i in range(b):
  y += str(a)
  
print(min(x,y))
Problem p02829 (python)

Fixed submission:
print(6-int(input())-int(input()))

Buggy submission (verdict: Runtime Error):
a,b = list(map(int,input().split()))
print(6-a-b)

Buggy submission (verdict: Runtime Error):
a,b = list(map(int,input().split()))
print(6-a-b)

Buggy submission (verdict: Runtime Error):
N = int(input())
S,T = input().stlip

s=""

for i in range(N):
  s+=S[i]+T[i]
print(s)

Buggy submission (verdict: Runtime Error):
print(6-input()-input())
Problem p02835 (python)

Fixed submission:
A = sum(list(map(int, input().split())))
 
print("bust") if A >= 22 else print("win")

Buggy submission (verdict: Runtime Error):
A=sum(list(map(int,input().stlip()))
      
      if A <=21:
      	print('win')
      else:
      	print('bust')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().stlip())
if a+b+c<=21:
	print('win')
  else:
  	print('bust')
Problem p02836 (python)

Fixed submission:
S = input()
 
count=0
for i in range(len(S)//2):
  if S[i] != S[-i-1]:
    count+=1

print(count)

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


count=0
for i in range(len(S)//2):
  if(S[i] != S[-i-1]):
    count++

print(count)
Problem p02847 (python)

Fixed submission:
cal = {"SUN":0,"MON":1,"TUE":2,"WED":3,"THU":4,"FRI":5,"SAT":6,}

S=input()
print(7-cal[S])

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

ans = ''

for x in S
	num=(ord(x) + N)
  	if(num >90):
    	num=64+num%90
    ans += chr(num)
print(ans)

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

ans = ''

for x in S
	num=(ord(x) + N)
  	if(num >90):
    	num=64+num%90
    ans += chr(num)
print(ans)

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

ans = ""

for x in range(S)
	num=(ord(x) + N)
  	if(num >90):
    	num=64+num%90
    ans += chr(num)
print(ans)
Problem p02860 (python)

Fixed submission:
n=int(input())
s=input()

if n%2==0:
    c=n//2
    if s[c:] == s[:c]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

if n%2==0:
    c=n//2:
    if(s[c:] == s[:c]):
        print('yes')
    else:
        print('no')
else:
    print('no')
Problem p02879 (python)

Fixed submission:
A, B = map(int, input().split())
if 0 <= A <= 9 and 0 <= B <= 9:
    print(A*B)
else:
    print(-1)

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

if a*b<=81:
  print(a*b)
else:
	print(-1)

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

if a*b<=81:
  print(a*b)
else:
	print(-1)
Problem p02897 (python)

Fixed submission:
n=int(input())
x=0
for i in range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)

Buggy submission (verdict: Runtime Error):
N=int(input())
x=0
for i in range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)

Buggy submission (verdict: Runtime Error):
N=int(input())
x=0
for i range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)

Buggy submission (verdict: Runtime Error):
N=int(input())
x=0
 
for i range(1,n+1):
  
  if (i%2==1):
    x+=1
    
print(x/n)

Buggy submission (verdict: Runtime Error):
N=int(input())
x=0
 
for i range(1,n+1):
  if i%2==1:
    x+=1
    
print(x/n)

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

for i range (1,n+1):
  
  if i%2==1:
    x+=1
    
print(x/n)
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()))

m=0
for i in range(n-1):
  if a[i+1]==a[i]+1:
    m=m+c[a[i]-1]

print(sum(b)+m)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
b = [int(input()) for i in range(n)]
c = [int(input()) for i in range(n-1)]

ans = sum(b)
for i in range(1,n):
    if a[i]-1==a[i-1]:
        ans+=c[i-1]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
b = [int(input()) for i in range(n)]
c = [int(input()) for i in range(n)]

ans = sum(b)
for i in range(1,n):
    if a[i]-1==a[i-1]:
        ans+=c[i-1]
print(ans)
Problem p02933 (python)

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

if a >= 3200:
    print(s)
else:
    print("red")

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

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

s=0
for x in a:
    s+=1/x
ans=1/s

print(ans)

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

if(a>=3200):
    print(s)
else:
    print("red")
Problem p03242 (python)

Fixed submission:
s = input()
n = ""
for i in s:
  if i == "9":
    n+="1"
  else:
    n+="9"
print(n)

Buggy submission (verdict: Runtime Error):
s = input()
n = ""
for i in s:
  if i == "9":
    n+=1
  else:
    n+=9
print(n)
Problem p02729 (python)

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

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

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n , m = map(int , input().split())
print(cmb(n , 2) + cmb(m , 2))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

n , m = map(int , input().split())
print(comb(n , 2 , exact = True) + comb(m , 2 , exact = True))
Problem p02773 (python)

Fixed submission:
n = int(input())
s = list(input() for i in range(n))

import collections
A = collections.Counter(s)
 
B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)
 
for i in C:
    print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input() for i in range(n))

import collections
A = collections.Counter(S)
 
B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)
 
for i in C:
    print(i)
Problem p02689 (python)

Fixed submission:
n, m = map(int, input().split())
hlist = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

maxh = [0]*n
for a, b in ab:
  maxh[a-1] = max(maxh[a-1], hlist[b-1])
  maxh[b-1] = max(maxh[b-1], hlist[a-1])
ans = 0
for i in range(n):
  if maxh[i] < hlist[i]:
    ans += 1
print(ans)

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

n, m = map(int, input().split())
hlist = np.array(list(map(int, input().split()))).astype(np.int64)
ab = [list(map(int, input().split())) for _ in range(m)]
connect = np.zeros((n,n)).astype(np.int64)

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

n, m = map(int, input().split())
hlist = np.array(list(map(int, input().split()))).astype(np.int64)
ab = [list(map(int, input().split())) for _ in range(m)]
connect = np.zeros((n,n)).astype(np.int64)
for a, b in ab:
  connect[a-1, b-1] = 1
  connect[b-1, a-1] = 1
ans = 0
#for i in range(n):
#  if (connect[i] * hlist >= hlist[i]).sum() == 0:
#    ans += 1
#print(ans)

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

n, m = map(int, input().split())
hlist = np.array(list(map(int, input().split()))).astype(np.int64)
ab = [list(map(int, input().split())) for _ in range(m)]
connect = np.zeros((n,n)).astype(np.int64)
for a, b in ab:
  connect[a-1, b-1] = 1
  connect[b-1, a-1] = 1
ans = 0
for i in range(n):
  if (connect[i] * hlist >= hlist[i]).sum() == 0:
    ans += 1
print(ans)

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

n, m = map(int, input().split())
hlist = np.array(list(map(int, input().split()))).astype(np.int64)
ab = [list(map(int, input().split())) for _ in range(m)]

connect = np.zeros((n,n)).astype(np.int64)
for a, b in ab:
  connect[a-1, b-1] = connect[b-1, a-1] = 1
ans = 0
for i in range(n):
  if (connect[i] * hlist >= hlist[i]).sum() == 0:
    ans += 1
print(ans)

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

n, m = map(int, input().split())
hlist = np.array(list(map(int, input().split())))
ab = [list(map(int, input().split())) for _ in range(m)]

connect = np.zeros((n,n)).astype(np.int64)
for a, b in ab:
  connect[a-1, b-1] = connect[b-1, a-1] = 1
ans = 0
for i in range(n):
  if (connect[i] * hlist >= hlist[i]).sum() == 0:
    ans += 1
print(ans)

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

n, m = map(int, input().split())
hlist = np.array(list(map(int, input().split())))
ab = [list(map(int, input().split())) for _ in range(m)]

connect = np.zeros((n,n)).astype(int)
for a, b in ab:
  connect[a-1, b-1] = connect[b-1, a-1] = 1
ans = 0
for i in range(n):
  if (connect[i] * hlist >= hlist[i]).sum() == 0:
    ans += 1
print(ans)
Problem p02834 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**6)

N, u, v = map(int, input().split())
tree = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)
#print(tree)

def calc_dist(dlist, n, dist, nnode):
  for c in tree[n]:
    if c == nnode:
      continue
    dlist[c] = dist
    calc_dist(dlist, c, dist+1, n)
    
u_dist_list = [0] * N
calc_dist(u_dist_list, u-1, 1, -1)
#print(u_dist_list)

v_dist_list = [0] * N
calc_dist(v_dist_list, v-1, 1, -1)
#print(v_dist_list)

ans = 0
for i in range(N):
  if (v_dist_list[i] - u_dist_list[i]) > 0 and v_dist_list[i] > ans:
    ans = v_dist_list[i] - 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
N, u, v = map(int, input().split())
tree = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)
#print(tree)

def calc_dist(dlist, n, dist, nnode):
  for c in tree[n]:
    if c == nnode:
      continue
    dlist[c] = dist
    calc_dist(dlist, c, dist+1, n)
    
u_dist_list = [0] * N
calc_dist(u_dist_list, u-1, 1, -1)
#print(u_dist_list)

v_dist_list = [0] * N
calc_dist(v_dist_list, v-1, 1, -1)
#print(v_dist_list)

ans = 0
for i in range(N):
  if (v_dist_list[i] - u_dist_list[i]) > 0 and v_dist_list[i] > ans:
    ans = v_dist_list[i] - 1
    
print(ans)
Problem p02693 (python)

Fixed submission:
k = int(input())
a, b = map(int, input().split())
 
if ((a // k) + 1) * k <= b or a % k == 0:
  print("OK")
else:
  print("NG")

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

Fixed submission:
s = input()

print(2 * min(s.count("0"), s.count("1")))

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

ans = 0
i = 1
while len(s[i:]) >= 1:
  before = s[i-1]
  tmp = s[i]
  if before != tmp:
    s = s[:i-1] + s[i+1:]
    ans += 2
    i -= 1
  else:
    i += 1

print(ans)
Problem p02623 (python)

Fixed submission:

import sys

for a0 in range(1):
    n,m,x = input().strip().split(' ')
    n,m,x = [int(n),int(m),int(x)]
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    a.reverse()
    b.reverse()
    total = 0
    atmp = []
    for i in range(n):
        val = a.pop()
        if total + val > x:
            break
        total += val 
        atmp.append(val)

    max_count = len(atmp)
    cur_count = max_count
    while m:
        if total + b[-1] <= x:
            total += b.pop() 
            m -= 1
            cur_count += 1
            if cur_count > max_count:
                max_count = cur_count
            continue
        if not len(atmp):
            break
        aval = atmp.pop()
        total -= aval
        cur_count -= 1
    print (max_count)

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

dp = [[-1 for i in range(n+2)] for j in range(m+2)]
def find(i, j, sum):
    if sum >= k:
        return 0
    if i < len(a) and j < len(b) and dp[i][j] != -1:
        return dp[i][j]
    dp[i][j] = 0
    if j < len(b) and sum + b [j] <= k :
        dp[i][j] = 1 + find(i , j+1, sum+b[j])
    if i < len(a) and sum + a[i] <= k :
        dp[i][j] = max(dp[i][j], 1 + find(i+1, j, sum+a[i]))
    return dp[i][j]

print(find(0, 0, 0))
Problem p03012 (python)

Fixed submission:
N=int(input())
W=list(map(int,input().split()))
total=sum(W)
diff=total
for i in range(N):
    if abs(diff-2*W[i]) < diff:
        diff = diff-2*W[i]
    else:
        break
print(abs(diff))

Buggy submission (verdict: Runtime Error):
N=int(input())
W=map(int,input())
total=sum(W)
diff=total
for w in W:
    if abs(diff-2*w) < diff:
        diff = diff-2*w
    else:
        break
print(diff)

Buggy submission (verdict: Runtime Error):
N=int(input())
W=map(int,input())
total=sum(W)
diff=total
for w in W:
	if abs(diff-2*w) < diff:
   		diff = diff-2*w
    else:
    	break
print(diff)
Problem p03805 (python)

Fixed submission:
N, M = map(int, input().split())  #頂点, 辺
g = [[] for _ in range(N)]  #iはjと繋がっている
for _ in range(M):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

#1度通った頂点をTrueにする
is_checked = [False] * N

import sys
sys.setrecursionlimit(10 ** 8)
def dfs(i):
    cnt = 0
    is_checked[i] = True
    if not(False in is_checked):
        return 1
    else:
        for j in g[i]:
            if not(is_checked[j]):
                cnt += dfs(j)
                is_checked[j] = False
        return cnt
            
ans = dfs(0)
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())  #頂点, 辺
g = [[] for _ in range(M)]  #iはjと繋がっている
for i in range(M):
    u, v = map(int, input().split())
    if u > v:
        u, v = v, u
    g[u-1].append(v-1)
    g[v-1].append(u-1)

is_checked = [False] * N

def dfs(i):
    cnt = 0
    is_checked[i] = True
    for j in g[i]:
        if not(is_checked[j]):
            dfs(j)
        if not(False in is_checked):
            cnt += 1
    return cnt
            
ans = dfs(0)
print(ans)
Problem p02754 (python)

Fixed submission:

class abc_158:
    
    def __init__(self):
        pass
    
    def A(self):
        S=input()
        if "BA" in S or "AB" in S:print("Yes")
        else:print("No")
    
    def B(self):
        NAB=list(map(int,input().split()))
        
        if NAB[0]<=NAB[1]:ans=NAB[0]
        elif NAB[0]<=NAB[1]+NAB[2]:ans=NAB[1]
        else:
            tail = NAB[0]%(NAB[1]+NAB[2]) if NAB[0]%(NAB[1]+NAB[2])<NAB[1] else NAB[1]
            ans=(int(NAB[0]/(NAB[1]+NAB[2]))*NAB[1])+tail
            
        print(int(ans))
            
    def C(self):
        AB=list(map(int,input().split()))
        ans=-1
        
        #A<B<100
        for i in range(1,1001):
            if AB[0]==int(i*0.08) and AB[1]==int(i*0.1):
                ans=i
                break
            else:continue
        print(ans)
            
    def D(self):
        pass
        
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_158()
    obj.B()

Buggy submission (verdict: Runtime Error):
    
    def __init__(self):
        pass
    
    def A(self):
        S=input()
        if "BA" in S or "AB" in S:print("Yes")
        else:print("No")
    
    def B(self):
        NAB=list(map(int,input().split()))
        
        if NAB[0]<=NAB[1]:ans=NAB[0]
        elif NAB[0]<=NAB[1]+NAB[2]:ans=NAB[1]
        else:
            tail = NAB[0]%(NAB[1]+NAB[2]) if NAB[0]%(NAB[1]+NAB[2])<NAB[1] else NAB[1]
            ans=(int(NAB[0]/(NAB[1]+NAB[2]))*NAB[1])+tail
            
        print(int(ans))
            
    def C(self):
        AB=list(map(int,input().split()))
        ans=-1
        
        #A<B<100
        for i in range(1,1001):
            if AB[0]==int(i*0.08) and AB[1]==int(i*0.1):
                ans=i
                break
            else:continue
        print(ans)
            
    def D(self):
        pass
        
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_158()
    obj.B()
Problem p02624 (python)

Fixed submission:
N = int(input())

ans = int(sum([j * (N//j)*(N//j+1)/2 for j in range(1,N+1)]))

print(ans)

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

ans = sum([j * (N//j)*(N//j+1)/2 for j in range(N)])

print(ans)