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

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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

lcm=C*D//gcd(C,D)
con1=B//C - (A-1)//C
con2=B//D - (A-1)//D
con3=B//lcm - (A-1)//lcm

print(B-(A-1)-(con1+con2-con3))

Buggy submission (verdict: Runtime Error):
import numpy as np
A,B,C,D = map(int, input().split())
ndcage = np.arange(A,B+1)

cmlist = np.nonzero(ndcage % C)[0]
dmlist = np.nonzero(ndcage % D)[0]

count=0
for i in cmlist:
    if i in dmlist:
        count+=1
print(count)
Problem p03101 (python)

Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())
print((H-h)*(W-w))

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

N, M, C = map(int, input().split())
M=[int(x) for x in input().split()]
nlist=[]

for i in range(N):
    nlist.append([int(x) for x in input().split()])

nlist=np.array(nlist)
M= np.array(M)
ans=(nlist*M+C).sum(axis=1)
print((ans>0).sum())
Problem p03238 (python)

Fixed submission:
a = int(input())
if a==1:
  print("Hello World")
else:
  A = int(input())
  B = int(input())
  print(A+B)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
cage,cage2=[],[]
for i in range(N):
  c, t = map(int, input().split())
  if t<=T:
      cage.append(c)
if cage is None:
  print("TLE")
else:
  print(min(cage))

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
cage,cage2=[],[]
for i in range(N):
  c, t = map(int, input().split())
  if t<=T:
	cage.append(c)
if cage is None:
  print("TLE")
else:
  print(min(cage))

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
cage,cage2=[],[]
for i in range(N):
  c, t = map(int, input().split())
  if t<=T:
	cage.append(c)
if cage==None:
  print("TLE")
else:
  print(min(cage))
Problem p03239 (python)

Fixed submission:
N, T = map(int, input().split())
cage,cage2=[],[]
for i in range(N):
  c, t = map(int, input().split())
  if t<=T:
      cage.append(c)
if len(cage)==0:
  print("TLE")
else:
  print(min(cage))

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
cage,cage2=[],[]
for i in range(N):
  c, t = map(int, input().split())
  if t<=T:
      cage.append(c)
if cage==None:
  print("TLE")
else:
  print(min(cage))

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
cage,cage2=[],[]
for i in range(N):
  c, t = map(int, input().split())
  if t<=T:
	cage.append(c)
if cage==None:
  print("TLE")
else:
  print(min(cage))

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
cage,cage2=[],[]
for i in range(N):
  c, t = map(int, input().split())
  if t<=T:
	cage.append(c)
if cage==None:
  print("TLE")
else:
  print(soted(cage)[0])

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
cage,cage2=[],[]
for i in range(N):
  c, t = map(int, input().split())
  if t<=T:
	cage.append(c)
    cage2.append(n)
if cage==None:
  print("TLE")
else:
  print(soted(cage)[0])

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
cage,cage2=[],[]
for n,i in enumerate(N):
  c, t = map(int, input().split())
  if t<=T:
	cage.append(c)
    cage2.append(n)
if cage==None:
  print("TLE")
else:
  print(soted(cage)[0]
Problem p03254 (python)

Fixed submission:
N, x = map(int, input().split())
A = list(map(int, input().split()))
 
x_tmp = x
for i, Ai in enumerate(sorted(A)):
    x_tmp -= Ai
    if x_tmp == 0:
        ans = i + 1
        break
    elif x_tmp < 0:
        ans = i
        break
    else: continue
else: ans = i
 
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
x = int(input())
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
cage = sorted(cage)
ans=0

for i in range(N):
    n = cage[i]
    if x>=n:
        x = x - n
        ans += 1
    else:
        break

if cage[0]>x:
    ans=0
if x != 0:
    ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
x = int(input())
y=x
cage = list(map(int,input().split()))
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = y
    ans += 1
if x>0:
    ans = ans - 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
x = int(input())
y=x
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = y
    ans += 1
if x>0:
    ans = ans - 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
x = int(input())
y=x
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = y
    ans += 1
if x>0:
    ans = ans - 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
x = int(input())
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = "no"
    ans += 1
if x>0:
    ans = ans - 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
x = int(input())
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = "no"
    ans += 1
if x>0:
    ans = ans - 1
print(ans)
print(x,cage)
Problem p02993 (python)

Fixed submission:

S=input()

if S[0:1]==S[1:2] or S[1:2]==S[2:3] or S[3:4]==S[2:3]:
    print("Bad")
else:
    print("Good")

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


for i in range(len(S)):
    A=S[i:i+1]
    print(A)

if S[0:1]==S[1:2]:
    print("Bad")
elif S[1:2]==S[2:3]:
    print("Bad")
elif S[3:4]==S[2:3]:
    print("Bad")
else:
    print("Good")

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


for i in range(len(S)):
    A=S[i:i+1]
    print(A)

if S[0:1]==S[1:2]:
    print("Bad")
elif S[1:2]==S[2:3]:
    print("Bad")
elif S[3:4]==S[2:3]:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
for i in range(len(S)):
    A=S[i:i+1]
    print(A)

if S[0:1]==S[1:2]:
    print("Bad")
elif S[1:2]==S[2:3]:
    print("Bad")
elif S[3:4]==S[2:3]:
    print("Bad")
else:
    print("Good")
Problem p02999 (python)

Fixed submission:
alfa=input()

X=alfa[0]
A=alfa[2]

if X<A:
    print("0")
else:
    print("10")

Buggy submission (verdict: Runtime Error):
ini=input().split()
ini=[int(i) for i in ini]
N=ini[0]
K=ini[1]
a=input().split()
a=[int(i) for i in a]


count=0
ans=0
x=0
lena=len(a)

for i in range(lena):
    for j in range(N-i):
        #print(i,j,a[i+j])
        x += a[i+j]
#        print(i,j,x,count)
        if x >= K:
#            print("aaa",i,j,x,count,ans)
            count = N-j-i
            x=0
            break
        if j==N-i-1:
            x=0
#    print(i,j,ans)
    ans+=count
    count=0
print(ans)

Buggy submission (verdict: Runtime Error):
alfa=input().split()
N=int(alfa[0])
X=int(alfa[1])
#L=[int(input().split()) for i in range(N)]
L=input().split()

#print(N,X,L)
D=0
count=1
for i in range(N):
    D+=int(L[i])
    if D>X:
        print(count)
        break
    else:
        count+=1

if D<X:
    print(count)

Buggy submission (verdict: Runtime Error):
alfa=input().split()
N=int(alfa[0])
X=int(alfa[1])
#L=[int(input().split()) for i in range(N)]
L=input().split()


print(N,X,L)
D=0
count=1
for i in range(N):
    D+=int(L[i])
    if D>X:
        print(count,D,X,i,L[i])
        break
    else:
        count+=1

Buggy submission (verdict: Runtime Error):
alfa=input()
N=int(alfa[0])
X=int(alfa[2])
#L=[int(input().split()) for i in range(N)]
L=input().split()


print(N,X,L)
D=0
count=0
for i in range(N):
    count+=1
    D+=int(L[i])
    if D>X:
        print(count)
        break
Problem p03000 (python)

Fixed submission:
alfa=input().split()
N=int(alfa[0])
X=int(alfa[1])
#L=[int(input().split()) for i in range(N)]
L=input().split()

#print(N,X,L)
D=0
count=1
for i in range(N):
    D+=int(L[i])
    if D>X:
        print(count)
        break
    else:
        count+=1

if D<=X:
    print(count)

Buggy submission (verdict: Runtime Error):
alfa=input()
N=int(alfa[0])
X=int(alfa[2])
#L=[int(input().split()) for i in range(N)]
L=input().split()


#print(N,X,L)
D=0
count=1
for i in range(N-1):
    D+=int(L[i])
    if D>X:
        print(count)
        break
    else:
        count+=1

Buggy submission (verdict: Runtime Error):
alfa=input()
N=int(alfa[0])
X=int(alfa[2])
#L=[int(input().split()) for i in range(N)]
L=input().split()


#print(N,X,L)
D=0
count=1
for i in range(N):
    D+=int(L[i])
    if D>X:
        print(count)
        break
    else:
        count+=1

Buggy submission (verdict: Runtime Error):
alfa=input()
N=int(alfa[0])
X=int(alfa[2])
#L=[int(input().split()) for i in range(N)]
L=input().split()


print(N,X,L)
D=0
count=0
for i in range(N):
    count+=1
    D+=int(L[i])
    if D>X:
        print(count)
        break

Buggy submission (verdict: Runtime Error):
alfa=input()
N=int(alfa[0])
X=int(alfa[2])
#L=[int(input().split()) for i in range(N)]
L=input().split()


print(N,X,L)
D=0
count=0
for i in range(N):
    count+=1
    D+=int(L[i])
    if D>X:
        print(count)
        break

Buggy submission (verdict: Runtime Error):
alfa=int(input())
L=[int(input()) for i in range(N)]

N=alfa[0]
X=alfa[2]

print(N,X,L)
D=0
count=0
for i in range(N):
    count+=1
    D+=L[i]
    if D>X:
        print(count)
        break

Buggy submission (verdict: Runtime Error):
N=int(input())
X=int(input())
L=[int(input()) for i in range(N)]

print(N,X,L)
D=0
count=0
for i in range(N):
    count+=1
    D+=L[i]
    if D>X:
        print(count)
        break
Problem p03001 (python)

Fixed submission:
a=input().split()
a=[int(i) for i in a]

W=a[0]
H=a[1]
x=a[2]
y=a[3]

max=round(W*H*0.5,9)
print(max)

if x==W/2 and y==H/2:
    print("1")
else:
    print("0")

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

W=x[0]
H=x[1]
x=x[2]
y=x[3]

max=W*H*0.5

if x==W/2 and y==H/2:
    print("1")
else:
    print("0")
Problem p03047 (python)

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

ans = n - k + 1

print(ans)

Buggy submission (verdict: Runtime Error):
r,g,b,n = map(int,input().split())

i,j,k = 0,0,0

ans = 0

while True:
	temp = i * r
	j,k = 0,0
	if(temp > n):
		break
	while True:
		temp = i * r + j * g
		k = 0
		if(temp > n):
			break
		while True:
			temp = i * r + j * g + k * b
			#print(temp)
			if(temp > n): break
			if (temp == n):
				ans += 1
			k += 1
		j+= 1
	i += 1

print(ans)
Problem p03067 (python)

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

if(a > b):
	temp = a
	a = b
	b = temp

if (c > a and c < b):
	print("Yes")
else:
	print("No")

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

ans = 0

for i in range(len(s)-1):
	if(s[i] == "#" and s[i+1] == "."):
		if(i == 0):
			s[i] = "."
		elif(i > 0 and s[i-1] != "#"):
			s[i] = "."
		else:
			s[i+1] = "#"
		ans += 1

print(ans)
Problem p03069 (python)

Fixed submission:
n = input()
s = list(input())
 
ans = len(s)

sharp = 0
dot = 0
for string in s:
	if(string == "#"):
		sharp += 1
	else:
		dot += 1 

left_sharp = 0
right_dot = dot

for i in range(len(s)):
	temp_ans = left_sharp + right_dot
	ans = min(ans,temp_ans)
	if(s[i] == "."):
		right_dot -= 1
	else:
		left_sharp += 1

ans = min(ans, len(s) - dot) 

print(ans)

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

sb = s.copy()

ans = 0

for i in range(len(s)-1):
	if(s[i] == "#" and s[i+1] == "."):
		if(i == 0):
			s[i] = "."
		elif(i > 0 and s[i-1] != "#"):
			s[i] = "."
		else:
			s[i+1] = "#"
		ans += 1

ansb = 0
for i in range(len(sb)-1):
	if(i == 0 and sb[i] != "."):
		sb[i] = "."
		ansb += 1
	elif(sb[i] == "#" and sb[i+1] == "."):
		if(i > 0 and sb[i-1] != "#"):
			sb[i] = "."
		else:
			sb[i+1] = "#"
		ansb += 1

#print(s)
#print(sb)


#print(ans)
#print(ansb)

ans = min(ans, ansb)

print(ans)

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

ans = 0

for i in range(len(s)-1):
	if(s[i] == "#" and s[i+1] == "."):
		if(i == 0):
			s[i] = "."
		else if(i > 0 and s[i-1] != "#"):
			s[i] = "."
		else:
			s[i+1] = "#"
		ans += 1

print(ans)
Problem p03043 (python)

Fixed submission:
import numpy as np
 
N, K = map(int, input().split())
 
def get_x(n, K):
    if n >= K:
        return 0
    else:
        x_raw = np.log2(K) - np.log2(n)
        return np.ceil(x_raw)

def get_prob(n, K):
    x = get_x(n, K)
    if x == 0:
        return 1
    else:
        return (1/2)**x
    
ans = np.mean([get_prob(n, K) for n in range(1, N+1)], dtype=np.float64)
 
print('{0:.12f}'.format(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
 
N, K = map(int, input().split())
 
def get_x(n, K):
    if n >= K:
        return 0
    else:
      	x_raw = (np.log(K) - np.log(n))/np.log(2)
        # x_raw = np.log2(K) - np.log2(n)
        return np.ceil(x_raw)

def get_prob(n, K):
    x = get_x(n, K)
    if x == 0:
        return 1
    else:
        return (1/2)**x
    
ans = np.mean([get_prob(n, K) for n in range(1, N+1)])
 
print(ans)
Problem p03050 (python)

Fixed submission:
from collections import Counter
from itertools import product

N = int(input())

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

# 素因数分解で約数を計算する
primes = prime_decomposition(N)

# 素因数の種類と個数を数え上げる
counter = Counter(primes)
values = [[k**i for i in range(v+1)] for k, v in counter.items()]
p = product(*values)

# 全ての種類の素数×個数を計算して、約数の組み合わせを格納する
divisors = []
for v in p:
    div = 1
    for w in v:
        div *= w
    divisors.append(div)

# 条件にあう約数を選別してmを求め、答えに加算する
ans = 0
for i in divisors:
    j = N / i
    if (i > j + 1) & (i >= 1) & (j >= 1):
        ans += i - 1
print(ans)

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

import math
from collections import defaultdict
from itertools import product
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return 'prime number'
    else:
        factor.append(n)
        return factor

fac = trial_division(N)
dic = defaultdict(int)
for n in fac:
    if n != 1:
        dic[n] += 1

a = []
for k, v in dic.items():
    a.append([k**j for j in range(v+1)])

tmp = list(product(*a))

ans = 0
for t in tmp:
    b = 1
    for j in t:
        b *= j
    if b >= 2:
        xx, yy = divmod(N, b-1)
        if xx == yy:
            ans += b - 1

print(ans)

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

import math
from collections import defaultdict
from itertools import product
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return 'prime number'
    else:
        factor.append(n)
        return factor

fac = trial_division(N)
dic = defaultdict(int)
for n in fac:
    if n != 1:
        dic[n] += 1

a = []
for k, v in dic.items():
    a.append([k**j for j in range(v+1)])

tmp = list(product(*a))

ans = 0
for t in tmp:
    b = 1
    for j in t:
        b *= j
    if b >= 2:
        xx, yy = divmod(N, b-1)
        if xx == yy:
            ans += b - 1

print(ans)
Problem p03069 (python)

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

ans =  S.count(".")
l = [0, ans]
for i in range(N):
    if S[i] == "#":
        l[0] += 1
    else:
         l[1] -= 1
    
    if ans > sum(l):
        ans = sum(l)
print(ans)

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

N = int(input())
S = input()

ans = [np.zeros(N), np.zeros(N)]

for i in range(N):
    if S[i] == "#":
        ans[0][i:] += 1
    else:
        ans[1][:i+1] += 1

print(min(ans[0][N-1], ans[1][0], np.min(ans[0][1:]+ans[1][:N-1])))

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

ans1 = 1e7
ans2 = 1e7
ans3 = 1e7
f = False
for i in range(N-1):
    if S[i:i+2] == "#.":
        ans1 = S[i+1:].count(".")
        f = True
        break

for i in range(N-1):
    j = N - i
    if S[j-2:j] == "#.":
        ans2= S[:j-1].count("#")
        f = True
        break
        
for k in range(j-1):
    if S[j-2-k] == ".":
        ans3 = S[:j-1-k].count("#") + S[j-1:].count(".")
        break
    
print(min(ans1, ans2, ans3) if f else 0)
Problem p03074 (python)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
S = input()

l = [[], []]
ans = []
k = [int(s) for s in S]
if k[0] == 0:
    l[1].append(0)
v0 = 1 if k[0] == 0 else 0
v1 = 1 if k[0] == 1 else 0
for i in range(1, N):
    if (k[i]==0) & (k[i-1]==0):
        v0 += 1
    elif (k[i]==1) & (k[i-1]==0):
        l[0].append(v0)
        v0 = 0
        v1 += 1
    elif (k[i]==0) & (k[i-1]==1):
        l[1].append(v1)
        v0 += 1
        v1 = 0 
    else:
        v1 += 1
        
for i, v in enumerate([v0, v1]):
    if v > 0:
        l[i].append(v)
        
if k[0] == 0:
    l[1].append(0)

if len(l[0]) <= K:
    print(N)

else:
    l[0].extend(np.repeat(0,K+1))
    l[1].extend(np.repeat(0,K+1))
    a = sum(l[0][:K]) + sum(l[1][:K+1])
    ans.append(a)
    for i in range(1, len(l[0])-K-1):
        a -= l[0][i-1] + l[1][i-1]
        a += l[0][i+K-1] + l[1][i+K]
        ans.append(a)
    print(max(ans))

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

N, K = map(int, input().split())
S = input()

l = [list(np.repeat(0, K)), list(np.repeat(0, K))]
ans = []
k = [int(s) for s in S]
v0 = 1 if k[0] == 0 else 0
v1 = 1 if k[0] == 1 else 0
for i in range(1, N):
    if (k[i]==0) & (k[i-1]==0):
        v0 += 1
    elif (k[i]==1) & (k[i-1]==0):
        l[0].append(v0)
        v0 = 0
        v1 += 1
    elif (k[i]==0) & (k[i-1]==1):
        l[1].append(v1)
        v1 = 0
        v0 += 1
        
        
        a = sum(l[0][-K:]+l[1][-K-1:])
        ans.append(a)
        
    elif (k[i]==1) & (k[i-1]==1):
        v1 += 1
        
for i, v in enumerate([v0, v1]):
    if v > 0:
        l[i].append(v)

if (v0==0) & (v1>0):
    a = sum(l[0][-K:]+l[1][-K-1:])
    ans.append(a)
    
print(max(ans))
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
S = input()

acl = [0]*(N+1)

for i in range(N):
    acl[i+1] = acl[i] + (1 if S[i:i+2] == "AC" else 0)

for _ in range(Q):
    l, r = map(int, input().split())
    print(acl[r-1] - acl[l-1])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i:i+2]=='AC' else 0)
for i in range(N):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy submission (verdict: Runtime Error):
import re
import sys
s = sys.stdin.readlines()
N, Q = map(int, s[0].split())
S = s[1]
for i in s[2:]:
    lr.append(tuple(map(int, i.split())))
    
for i in lr:
    print(len(re.findall("AC", S[i[0]-1:i[1]])))
Problem p03142 (python)

Fixed submission:
from collections import deque

n, m = map(int, input().split())

up = [[] for _ in range(n)] # [[]]*nした後にappendするのはNG
down = [[] for _ in range(n)]
used = [0]*n # これならOK
res = [0]*n
cnt = 0

for _ in range(n+m-1):
    p, c = map(int, input().split())
    up[c-1].append(p)
    down[p-1].append(c)

for i in range(n):
    if up[i] == []:
        root = i+1
        res[root-1] = 0
        used[root-1] = 1
        cnt += 1
        break

ptank = deque([root])
ctank = deque([root])
clist = list()

def is_p_used(i):
    for j in up[i-1]:
        if used[j-1]==0:
            return False
    return True

def find_c(p):
    for i in down[p-1]:
        if (is_p_used(i)) & (used[i-1]==0):
            res[i-1] = p
            ctank.append(i)
            clist.append(i)

while cnt < n:
    ptank = ctank
    ctank = deque()
    while len(ptank) != 0:
        find_c(ptank.popleft())
    cnt += len(ctank)
    for i in clist:
        used[i-1] = 1
    clist = list()
    

for i in range(n):
    print(res[i])

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

n, m = map(int, input().split())

up = [[] for _ in range(n)] # [[]]*nした後にappendするのはNG
down = [[] for _ in range(n)]
used = [0]*n # これならOK
res = [0]*n
cnt = 0

for _ in range(n+m-1):
    p, c = map(int, input().split())
    up[c-1].append(p)
    down[p-1].append(c)

for i in range(n):
    if up[i] == []:
        root = i+1
        res[root-1] = 0
        used[root-1] = 1
        cnt += 1
        break

ptank = deque([root])
ctank = deque([root])

def find_c(p):
    for i in down[p-1]:
        if all([used[j-1]==1 for j in up[i-1]]) & (used[i-1]==0):
            res[i-1] = p
            ctank.append(i)

while cnt < n:
    ptank = ctank.copy()
    while len(ctank) != 0:
        used[ctank.popleft()-1] = 1
    while len(ptank) != 0:
        find_c(ptank.popleft())
    cnt += len(ctank)
    

for i in range(n):
    print(res[i])
Problem p03212 (python)

Fixed submission:
n = int(input())
def dfs(s):
  if int(s) > n:
    return 0
  ret = 1 if all([s.count(c) > 0 for c in '753']) else 0
  for c in '753':
    ret += dfs(s+c)
  return ret
print(dfs('0'))

Buggy submission (verdict: Runtime Error):
n = int(input())
def dfs(s):
  if int(s) > n:
    return 0
  ret = 1 if all([s.count(c) > 0 for c in '753']) else 0
  for c in '753':
    ret += dfs(s+c)
  return ret
print(ret('0'))

Buggy submission (verdict: Runtime Error):
n = int(input())
def dfs(s):
  if int(s) > n:
    return 0
  ret = 1 if all([s.count(c) for c in '753']) else 0
  for c in '753':
    ret += dfs(s+c)
  return ret
print(ret('0'))

Buggy submission (verdict: Runtime Error):
s = set(['7', '5', '3'])
print(sum((1 for i in range(1, n+1) if set(str(i)) == s)))
Problem p03213 (python)

Fixed submission:
n = int(input())
e = [0] * (n+1)

# 素因数分解する  
for i in range(2, n+1):
    cur = i
    for j in range(2, i+1):
        # ひたすら割り算を繰り返す
        # 2で割り続ければ、4で割ろうとした時には2で割れない数になっている
        # 自動的に素因数分解ができる
        while cur % j == 0:
            e[j] += 1
            cur //= j

def num(m):
    return len([i for i in e if i >= m-1])

print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) \
      + num(5) * (num(5) - 1) * (num(3) - 2) // 2)

Buggy submission (verdict: Runtime Error):
n = int(input())
e = [0] * (n-1)

# 素因数分解する  
for i in range(2, n+1):
    cur = i
    for j in range(2, i+1):
        # ひたすら割り算を繰り返す
        # 2で割り続ければ、4で割ろうとした時には2で割れない数になっている
        # 自動的に素因数分解ができる
        while cur % j == 0:
            e[j] += 1
            cur //= j

def num(m):
    return len([i for i in e if i >= m-1])

print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) \
      + num(5) * (num(5) - 1) * (num(3) - 2) // 2)

Buggy submission (verdict: Runtime Error):
n = int(input())
e = [0] * (n-1)

# 素因数分解する  
for i in range(2, n+1):
    cur = i
    for j in range(2, i+1):
        # ひたすら割り算を繰り返す
        # 2で割り続ければ、4で割ろうとした時には2で割れない数になっている
        # 自動的に素因数分解ができる
        while cur % j == 0:
            e[j] += 1
            cur //= j

def num(m):
    return len([i for i in e if i >= m-1])

print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1)
      + num(5) * (num(5) - 1) * (num(3) - 2) // 2)