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

Fixed submission:
# input() は 'python3' で正常に動く
N = int(input())
S = input()
 
str_list = list(S)
str_trsf = []
 
for item in str_list:
    str_trsf.extend(chr(N - (ord('Z') - ord(item) + 1) + ord('A')) if ord(item) + N > ord('Z') else chr(ord(item) + N))

print(''.join(str_trsf))

Buggy submission (verdict: Runtime Error):
# input() は 'python3' で正常に動く
N = int(input())
S = input()

str_list = list(S)
str_trsf = []

for item in str_list:
    str_trsf.extend(chr(N - (ord('Z') - ord(item)) + ord('A') if ord(item) + N > ord('Z') else chr(ord(item) + N)))

print(''.join(str_trsf))
Problem p02760 (python)

Fixed submission:
l=[]
for i in range(3):
  l.append(list(map(int,input().split())))
n=int(input())
l1=[]
for i in range(n):
  l1.append(int(input()))
for i in range(len(l)):
    for j in range(len(l)):
        if(l[i][j] in l1):
            l[i][j]=0
f=0
if((l[0][0]==0 and l[0][1]==0 and l[0][2]==0) or (l[1][0]==0 and l[1][1]==0 and l[1][2]==0) or (l[2][0]==0 and l[2][1]==0 and l[2][2]==0)):
    f=1
elif((l[0][0]==0 and l[1][0]==0 and l[2][0]==0) or (l[0][1]==0 and l[1][1]==0 and l[2][1]==0) or (l[0][2]==0 and l[1][2]==0 and l[2][2]==0)):
    f=1
elif((l[0][0]==0 and l[1][1]==0 and l[2][2]==0) or (l[0][2]==0 and l[1][1]==0 and l[2][0]==0)):
    f=1
if(f==1):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
l=[]
for i in range(3):
  l.append(list(map(int,input().split())))
n=int(input())
l1=[]
for i in range(n):
  l1.append(int(input())
for i in range(len(l)):
    for j in range(len(l)):
        if(l[i][j] in l1):
            l[i][j]=0
f=0
if((l[0][0]==0 and l[0][1]==0 and l[0][2]==0) or (l[1][0]==0 and l[1][1]==0 and l[1][2]==0) or (l[2][0]==0 and l[2][1]==0 and l[2][2]==0))
    f=1
elif((l[0][0]==0 and l[1][0]==0 and l[2][0]==0) or (l[0][1]==0 and l[1][1]==0 and l[2][1]==0) or (l[0][2]==0 and l[1][2]==0 and l[2][2]==0))
    f=1
elif((l[0][0]==0 and l[1][1]==0 and l[2][2]==0) or (l[0][2]==0 and l[1][1]==0 and l[2][0]==0)):
    f=1
if(f==1):
    print("Yes")
else:
    print("No")
Problem p03160 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
dp=[float('inf') for i in range(n+1)]
dp[0]=0
for i in range(len(dp)):
    for j in range(i+1,i+3):
        if(j<len(l)):
      	    dp[j]=min(dp[j],dp[i]+abs(l[j]-l[i]))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
dp=[float('inf') for i in range(n+1)]
dp[0]=0
for i in range(len(dp)):
	for j in range(i+1,i+3):
    	if(j<len(l)):
      		dp[j]=min(dp[j],dp[i]+abs(l[j]-l[i]))
print(dp[n])

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
dp=[float('inf') for i in range(n+1)]
dp[0]=0
for i in range(len(dp)):
	for j in range(i+1,i+3):
    	if(j<len(l)):
      		dp[j]=min(dp[j],dp[i]+abs(l[j]-l[i]))
print(dp[n])
Problem p02768 (python)

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9 + 7


def neko(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    k = min(n - k, k)
    ans = 1
    inv = [1] * (k + 1)
    if k >= 1:
        ans *= (n - k + 1) % mod
    for i in range(2, k + 1):
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        ans = ans * (n - k + i) * inv[i] % mod
    return ans


print((pow(2, n, mod) - 1 - neko(n, a) - neko(n, b)) % mod)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
mod = 10**9 + 7
ans = 0
MAX = 500000000
fac = [1, 1] + [0] * MAX
finv = [1, 1] + [0] * MAX
inv = [0, 1] + [0] * MAX
for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = -inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def neko(n, r):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod


if n % 2:
    for i in range((n + 1) // 2):
        ans += neko(n, i) * 2 % mod
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))
else:
    for i in range(n // 2):
        ans += neko(n, i) * 2 % mod
    ans += neko(n, n // 2)
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
mod = 10**9 + 7
ans = 0
MAX = 500000
fac = [1, 1] + [0] * MAX
finv = [1, 1] + [0] * MAX
inv = [0, 1] + [0] * MAX
for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = -inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def neko(n, r):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod


if n % 2:
    for i in range((n + 1) // 2):
        ans += neko(n, i) * 2 % mod
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))
else:
    for i in range(n // 2):
        ans += neko(n, i) * 2 % mod
    ans += neko(n, n // 2)
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
mod = 10**9 + 7
ans = 0
MAX = 500000000
fac = [1, 1] + [0] * MAX
finv = [1, 1] + [0] * MAX
inv = [0, 1] + [0] * MAX
for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = -inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def neko(n, r):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod


if n % 2:
    for i in range((n + 1) // 2):
        ans += neko(n, i) * 2 % mod
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))
else:
    for i in range(n // 2):
        ans += neko(n, i) * 2 % mod
    ans += neko(n, n // 2)
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))
Problem p02865 (python)

Fixed submission:
n=int(input())
if n%2==0:
    print(n//2-1)
else:
    print((n-1)//2)

Buggy submission (verdict: Runtime Error):
print((int(input()+1)//2-1)
Problem p02900 (python)

Fixed submission:
import fractions
a, b = map(int, input().split())
n = fractions.gcd(a, b)
k = int(n**0.5)
cnt = 1
for i in range(2, k + 1):
    if n == 1:
        break
    elif n % i == 0:
        while n % i == 0:
            n //= i
        cnt += 1
if n != 1:
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
n = math.gcd(a, b)
k = int(n**0.5)
cnt = 1
for i in range(2, k + 1):
    if n == 1:
        break
    elif n % i == 0:
        while n % i == 0:
            n //= i
        cnt += 1
if n != 1:
    cnt += 1
print(cnt)
Problem p02923 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
x=[]
c=0
if n==1:print(0)
else:
    for i in range(n-1):
        if h[i]>=h[i+1]:
            c+=1
            x.append(c)
        else:
            c=0
            x.append(c)
    print(max(x))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
x=[]
c=0
for i in range(n-1):
    if h[i]>=h[i+1]:
        c+=1
        x.append(c)
    else:
        c=0
        x.append(c)
print(max(x))
Problem p02995 (python)

Fixed submission:
import fractions
a,b,c,d=map(int,input().split())
x=c*d//fractions.gcd(c,d)
print(b-~-a-(b//c-~-a//c)-(b//d-~-a//d)+b//x-~-a//x)

Buggy submission (verdict: Runtime Error):
import math

a,b,c,d=map(int,input().split())
x=c*d//math.gcd(c,d)
print(b-~-a-(b//c-~-a//c)-(b//d-~-a//d)+b//x-~-a//x)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
x=c*d//math.gcd(c,d)
print(b-~-a-(b//c-~-a//c)-(b//d-~-a//d)+b//x-~-a//x)
Problem p03086 (python)

Fixed submission:
s=input()
x=[]
c=0
for i in range(len(s)):
    if s[i]in['A','C','G','T']:
        c+=1
        x.append(c)
    else:
        c=0
        x.append(c)
print(max(x))

Buggy submission (verdict: Runtime Error):
s=input()
x=[]
c=0
for i in range(len(s)):
    if s[i]in['A','C','G','T']:
        c+=1
    else:
        x.append(c)
        c=0
print(max(x))
Problem p03219 (python)

Fixed submission:
x,y=map(int,input().split());print(x+y//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
x=[]
for i in range(n):
    x.append(abs(a-(t-h[i]*0.006)))
print(x.index(min(x))+1)
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())
i = 0
if s.count('1') == len(s):
    print(1)
else:
    while s[i] == '1':
        i += 1
    print([1, s[i]][i < k])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
i = 0
while s[i] == '1':
    i += 1
print([1, s[i]][i < k])
Problem p03455 (python)

Fixed submission:
print('EOvdedn'[eval(input().replace(' ','*'))%2::2])

Buggy submission (verdict: Runtime Error):
print('EOvdedn'[int(input())*int(input())%2::2])
Problem p03779 (python)

Fixed submission:
x = int(input())
ans = i = 0
while i < x:
    ans += 1
    i += ans
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
print([2, 1][m > 1])
Problem p02783 (python)

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

if h%a != 0:
    print(h//a + 1)
else:
    print(h//a)

Buggy submission (verdict: Runtime Error):
h, a = map(int, input())

print(h//a + h%a)
Problem p02786 (python)

Fixed submission:
H = int(input())

h = H
attack = []
division = 0
while h >= 1:
    h /= 2
    attack.append(2**division)
    division += 1
print(sum(attack))

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

split_num = math.floor(math.log2(h)) + 1
attack_num = sum([2**s for s in range(1, split_num+1)])

print(attack_num)
Problem p02787 (python)

Fixed submission:
H, N = map(int, input().split())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    
#import numpy as np
#dp = np.zeros([N+1, H+1])
#dp[0, 1:] = np.inf
dp = [[0]*(H+1) for _ in range(N+1)]
for j in range(1, H+1):
	dp[0][j] = float('inf')

for i in range(0, N):
    for j in range(1, H+1):        
        dp[i+1][j] = min(dp[i][j], dp[i+1][max(0, j-A[i])] + B[i])
        
print(int(dp[-1][-1]))

Buggy submission (verdict: Runtime Error):
H, N = map(int, input().split())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    
import numpy as np

dp = np.zeros([N+1, H+1])
dp[0, 1:] = np.inf

for i in range(0, N):
    for j in range(1, H+1):        
        dp[i+1][j] = min(dp[i][j], dp[i+1][max(0, j-A[i])] + B[i])
        
print(int(dp[-1][-1]))
Problem p02838 (python)

Fixed submission:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

max_digits = 60
MOD = 10**9 + 7

ans = 0
for i in range(max_digits):
    one_num = np.count_nonzero((a >> i) & 1)
    radix_mod = 2**i % MOD
    ans += (radix_mod * one_num * (n - one_num)) % MOD
print(ans%MOD)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

max_digist = 60
MOD = 10**9 + 7

ans = 0
for i in range(max_digits):
    one_num = np.count_nonzero((a >> i) & 1)
    radix_mod = 2**i % MOD
    ans += (radix_mod * one_num * (n - one_num)) % MOD
print(ans%MOD)
Problem p02887 (python)

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

ans = 0
pre_s = ''
for s in S:
    if s == pre_s:
        continue
    else:
        pre_s = s
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
ans = 0
pre_s = ''
for s in S:
    if s == pre_s:
        continue
    else:
        pre_s = s
        ans += 1
print(ans)
Problem p02900 (python)

Fixed submission:
def prime_factorize(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
 
a, b = map(int, input().split())
print(len(set(prime_factorize(a)) & set(prime_factorize(b))) + 1)

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

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

g = gcd(a, b)

common = []
for i in range(1, int(g**0.5)+1):
    if g%i == 0:
        common.append(i)
        common.append(g//i)
    
import math
def Eratosthenes(n):
    if n < 2:
        return [1]
    prime = [1, 2]
    limit = math.ceil(n**0.5)
    data = list(range(3, n+1, 2))
    p = -1
    while p < limit:
        p = data[0]
        prime.append(p)
        data = [d for d in data if d%p != 0]
    return prime + data

prime = Eratosthenes(max(common))

print(len(set(common) & set(prime)))

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

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

g = gcd(a, b)

common = []
for i in range(1, int(g**0.5)+1):
    if g%i == 0:
        common.append(i)
        common.append(g//i)
    
def Eratosthenes(n):
    if n < 2:
        return [1]
    prime = [1, 2]
    limit = math.ceil(n**0.5)
    data = list(range(3, n+1, 2))
    p = -1
    while p < limit:
        p = data[0]
        prime.append(p)
        data = [d for d in data if d%p != 0]
    return prime + data

prime = Eratosthenes(max(common))

print(len(set(common) & set(prime)))

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

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

g = gcd(a, b)

common = []
for i in range(1, int(g**0.5)+1):
    if g%i == 0:
        common.append(i)
        common.append(g//i)

import math
def Eratosthenes(n):
    if n < 2:
        return None
    prime = [2]
    limit = math.ceil(n**0.5)
    data = list(range(3, n+1, 2))
    p = -1
    while p < limit:
        p = data[0]
        prime.append(p)
        data = [d for d in data if d%p != 0]
    return prime + data

prime = Eratosthenes(max(common))

print(1 + len(set(common) & set(prime)))
Problem p02946 (python)

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

print(*list(range(x-k+1, x)) + list(range(x, x+k)))

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

print(*list(range(x-k+1, x)) + list(range(x, x+k)))
Problem p02995 (python)

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

a, b, c, d = map(int, input().split())
g = gcd(c, d)
l = int(c*d/g)

print((b - a + 1) - ((b//c - (a-1)//c) + (b//d - (a-1)//d) - (b//l - (a-1)//l)))

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
print(
  len(set(list(range(A, B+1)))
      - set(list(range(C, B+1, C)))
      - set(list(range(D, B+1, D))))
)
Problem p03078 (python)

Fixed submission:
import heapq

x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

# A+B+Cが大きい順になるようにリストに入れていく
ABC = []

# heapqに任意の値が入っているか確認する
from collections import defaultdict
d = defaultdict(int)

que = []

def HeapPush(a, b, c):
    if d[(a, b, c)] == 0:
        heapq.heappush(que, ((A[a] + B[b] + C[c])*-1, a, b, c))  # -1を掛ける
        d[(a, b, c)] += 1


HeapPush(0, 0, 0)

while len(ABC) < k:
    
    abc, a, b, c = heapq.heappop(que)
    ABC.append(abc*-1)  # -1を掛け直す
    
    if a + 1 < x:
        HeapPush(a+1, b, c)
    if b + 1 < y:
        HeapPush(a, b+1, c)
    if c + 1 < z:
        HeapPush(a, b, c+1)
   

for abc in ABC:
    print(abc)

Buggy submission (verdict: Runtime Error):
import heapq
from collections import defaultdict

# 3種類のケーキを美味しい順にソートする
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)


# heapqで管理
que = []
heapq.heapify(que)
# 最も美味しい組み合わせは、
heapq.heappush(que, ((A[0] + B[0] + C[0])*-1, (0, 0, 0)))

# 使用した組み合わせ
used = defaultdict(int)
used[(0, 0, 0)] = 1

ans = []
while len(ans) < k:
    total, comb = heapq.heappop(que)
    ans.append(total*-1)
    a, b, c = comb
    # その次に美味しい組み合わせは、以下のいずれか
    for p, q, r in [[a+1, b, c], [a, b+1, c], [a, b, c+1]]:
        if used[(p, q, r)] == 0:
            heapq.heappush(que, ((A[p] + B[q] + C[r])*-1, (p, q, r)))
            used[(p, q, r)] = 1

for i in range(k):
    print(ans[i])
Problem p03106 (python)

Fixed submission:
a, b, k = map(int, input().split())
 
def get_divisors(n):
    return [i for i in range(1, n//2+1) if n%i == 0] + [n]

print(sorted(set(get_divisors(a)) & set(get_divisors(b)), reverse=True)[k-1])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
 
d1 = [i for i in range(1, a//2+2) if a%i == 0]
d2 = [i for i in range(1, b//2+2) if b%i == 0]
print(sorted(set(d1) & set(d2))[k-1])

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

d1 = [i for i in range(1, a//2+2) if a%i == 0]
d2 = [i for i in range(1, b//2+2) if a%i == 0]
print(sorted(set(d1) & set(d2))[k-1])
Problem p03162 (python)

Fixed submission:
N = int(input())
act = [list(map(int, input().split())) for _ in range(N)]

import numpy as np
act = np.array(act)
act = np.concatenate([[[0]*3], act])  # 0日目は0にする

# DPテーブル
dp = np.zeros([N+1, 3], dtype='int')

for i in range(1, N+1):  # 1日目からN日目までの幸福度を順番に計算する
    for j in range(3):  # i日目は海か山か家を選択する
        for k in range(3):  # i日目にjの活動をする場合、i-1日目はj以外の活動
            if k == j:
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k] + act[i][j])
            
print(np.max(dp[-1]))

Buggy submission (verdict: Runtime Error):
N = int(input())
act = [list(map(int, input().split())) for _ in range(N)]
 
import numpy as np
act = np.array(act)
act = np.concatenate([[[0]*3], act])  # 0日目は0にする
 
# DPテーブル
dp = np.zeros([N+1, 3], dtype='int')
 
for i in range(1, N+1):  # 1日目からN日目までの幸福度を順番に計算する
    for j in range(3):  # i日目は海か山か家を選択する
        for k in range(3):  # i日目にjの活動をする場合、i-1日目はj以外の活動
            if k == j:
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k] + act[i][j])
            
print(np.max(dp[-1]))
Problem p03260 (python)

Fixed submission:
a, b = map(int, input().split())
for c in range(1, 4):
    if a*b*c%2 == 1:
        print('Yes')
        break
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
for c in range(1, 4):
  if a*b*c%2 == 1:
    print('Yes')
	break
else:
  print('No')
Problem p03289 (python)

Fixed submission:
S = input()
cnt = S[2:-1].count('C')
 
for s in S[1:]:
    if s.isupper() and s != 'C':
        print('WA')
        break
else:
    if S[0] == 'A' and cnt == 1:
        print('AC')
    else:
        print('WA')

Buggy submission (verdict: Runtime Error):
S = input()
cnt = S[2:-1].count('C')

if s in S[1:]:
    if s.isupper() and s != 'C':
        print('WA')
        break
else:
    if S[0] == 'A' and cnt == 1:
        print('AC')
    else:
        print('WA')
Problem p03386 (python)

Fixed submission:
a,b,k=map(int,input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):print(i)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
x = list(range(a, b+1))
C = sorted(list(set(x[:k] + x[-k:])))
for c in C:
    print(c)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
x = list(range(a, b+1))
C = list(set(x[:k] + x[-k:]))
C.sort()
for c in C:
    print(c)
Problem p03407 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a + b >= c:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a, b, c = mapt(int, input().split())
if a + b >= c:
    print('Yes')
else:
    print('No')
Problem p03457 (python)

Fixed submission:
n = int(input())
t=x=y=0
ans = 'Yes'
for _ in range(n):
    nt, nx, ny = map(int, input().split())
    dis = abs(nx - x) + abs(ny - y)
    time = nt - t
    if dis <= time and dis%2 == time%2:
        t = nt
        x, y = nx, ny
        continue
    else:
        ans = 'No'
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
time = []
point = []
for _ in range(n):
    time_point = list(map(int, input().split()))
    time.append(time_point[0])
    point.append(time_point[1:])

point_dict = dict(zip(time, point))
direction = [[1, 0], [-1, 0], [0, 1], [0, -1]]
moved = [[] for _ in range(time[-1] + 1)]

def dfs(t, x, y, dx, dy):
    nx = x + dx
    ny = y + dy
    if [nx, ny] in moved[t]:
        return 0
    moved[t].append([nx, ny])
    if [nx, ny] != point_dict.get(t, [nx, ny]):
        return 0
    if t == time[-1]:
        return 1
    else:
        return dfs(t+1, nx, ny, *direction[0]) + dfs(t+1, nx, ny, *direction[1]) + dfs(t+1, nx, ny, *direction[2]) + dfs(t+1, nx, ny, *direction[3])
        
for i in range(4):
    if dfs(1, 0, 0, *direction[i]) >= 1:
        print('Yes')
        break
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
time = []
point = []
for _ in range(n):
    time_point = list(map(int, input().split()))
    time.append(time_point[0])
    point.append(time_point[1:])

direction = [[1, 0], [-1, 0], [0, 1], [0, -1]]
moved = [[] for _ in range(time[-1] + 1)]

def dfs(t, x, y, dx, dy):
    nx = x + dx
    ny = y + dy
    if [nx, ny] in moved[t]:
        return 0
    moved[t].append([nx, ny])
    if [nx, ny] != point_dict.get(t, [nx, ny]):
        return 0
    if t == time[-1]:
        return 1
    else:
        return dfs(t+1, nx, ny, *direction[0]) + dfs(t+1, nx, ny, *direction[1]) + dfs(t+1, nx, ny, *direction[2]) + dfs(t+1, nx, ny, *direction[3])
        
for i in range(4):
    if dfs(1, 0, 0, *direction[i]) >= 1:
        print('Yes')
        break
else:
    print('No')
Problem p03479 (python)

Fixed submission:
x, y = map(int, input().split())

nx = x*2
if nx > y:
    print(1)
else:
    i = 2
    while nx*2 <= y:
        nx = nx*2
        i += 1
    print(i)

Buggy submission (verdict: Runtime Error):
nx = x*2
if nx > y:
    print(1)
else:
    i = 2
    while nx*2 <= y:
        nx = nx*2
        i += 1
    print(i)
Problem p03575 (python)

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

from collections import defaultdict
d = defaultdict(list)
B = []
for _ in range(m):
    a1, a2 = list(map(int, input().split()))
    B.append([a1, a2])
    d[a1].append(a2)
    d[a2].append(a1)
    
def dfs(a, conn):
    memo[a] = 1
    for c in conn:
        if memo[c] == 0:
            dfs(c, d[c])
            
cnt = 0
for b in B:
    a1, a2 = b
    memo = [0]*(n+1)
    conn = set(d[a1]) - set([a2])
    dfs(a1, conn)
    if memo.count(1) != n:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
## import numpy as np
from collections import defaultdict

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

AB = []
G = defaultdict(list)
for _ in range(m):
    a, b = map(int, input().split())
    AB.append([a, b])
    G[a].append(b)
    G[b].append(a)

ans = 0
for a, b in AB:
    memo = [0]*(n+1)
    memo[a] = 1
    que = [c for c in G[a] if c != b]
    while que:
        c = que.pop()
        memo[c] = 1
        for nc in G[c]:
            if memo[nc] == 0:
                que.append(nc)
    if np.count_nonzero(memo) != n:
        ans += 1
print(ans)
Problem p03730 (python)

Fixed submission:
a, b, c = map(int, input().split())
for i in range(1, b+1):
  if a*i%b == c:
    print('YES')
    break
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
for i in range(i, b+1):
  if a*i%b == c:
    print('YES')
    break
else:
  print('NO')
Problem p04030 (python)

Fixed submission:
inputs = list(map(str, input()))
 
output = ''
for i in inputs:
    if i == 'B':
        output = output[:-1]
    elif i == '1':
        output += '1'
    else:
          output += '0'
print(output)

Buggy submission (verdict: Runtime Error):
inputs = list(map(str, input()))

output = ''
for i in inputs:
	if output == 'B':
    	output = output[:-1]
	elif output == '1':
		output += '1'
    else:
      	output += '0'
print(output)