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

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
 
N,u,v = map(int,input().split())
edges = [list(map(int,input().split())) for _ in range(N-1)]
E = [[] for _ in range(N+1)]
for a,b in edges:
    E[a].append(b)
    E[b].append(a)
 
depth = [[-1,-1] for _ in range(N+1)] 
depth[v][0] = 0
depth[u][1] = 0

def dfs1(E,v):
    vv = E[v]
    for vvv in vv:
        if depth[vvv][0] == -1:
            depth[vvv][0] = depth[v][0] + 1
            dfs1(E,vvv)
 
def dfs2(E,v):
    vv = E[v]
    for vvv in vv:
        if depth[vvv][1] == -1:
            depth[vvv][1] = depth[v][1] + 1
            dfs2(E,vvv)
dfs1(E,v)
dfs2(E,u)
depth = sorted(depth, reverse=True)
idx = 0
while True:
    if depth[idx][0] - depth[idx][1] >= 1:
        print(depth[idx][0]-1)
        exit()
    else:
        idx += 1

Buggy submission (verdict: Runtime Error):
n,u,v=map(int, input().split())
ab=[list(map(int, input().split())) for _ in range(n-1)]
graph = [[] for _ in range(n+1)]
for vs in ab:
    graph[vs[0]].append(vs[1])
    graph[vs[1]].append(vs[0])

depth=[[-1,-1] for _ in range(n+1)]
depth[v][0]=0
depth[v][1]=0

def dfs1(graph,v):
    vv=graph[v]
    for vvv in vv:
        if depth[vvv][0]==-1:
            depth[vvv][0]=depth[v][0]+1
            dfs1(graph,vvv)

def dfs2(graph,v):
    vv=graph[v]
    for vvv in vv:
        if depth[vvv][1]==-1:
            depth[vvv][1]=depth[v][1]+1
            dfs2(graph,vvv)

dfs1(graph,v)
dfs2(graph,u)
depth=sorted(depth,reverse=True)

for i in range(10**6):
    if depth[i][0]-depth[i][1]>=1:
        print(depth[i][0]-1)
        break

Buggy submission (verdict: Runtime Error):
n,u,v=map(int, input().split())
ab=[list(map(int, input().split())) for _ in range(n-1)]
graph = [[] for _ in range(n+1)]
for vs in ab:
    graph[vs[0]].append(vs[1])
    graph[vs[1]].append(vs[0])

depth=[[-1,-1] for _ in range(n+1)]
depth[v][0]=0
depth[v][1]=0

def dfs1(graph,v):
    vv=graph[v]
    for vvv in vv:
        if depth[vvv][0]==-1:
            depth[vvv][0]=depth[v][0]+1
            dfs1(graph,vvv)

def dfs2(graph,v):
    vv=graph[v]
    for vvv in vv:
        if depth[vvv][1]==-1:
            depth[vvv][1]=depth[v][1]+1
            dfs2(graph,vvv)

dfs1(graph,v)
dfs2(graph,u)
depth=sorted(depth,reverse=True)

for i in range(10**5):
    if depth[i][0]-depth[i][1]>=1:
        print(depth[i][0]-1)
        break
Problem p02862 (python)

Fixed submission:
x,y=map(int,input().split())
mod=10**9+7

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def mod_combinations_count(n, r, mod):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

if (x+y)%3!=0:
    print(0)
else:
    n=(x+y)//3
    m=(-x+2*y)//3
    if n<0 or m<0 or n<m:
        print(0)
        exit()
    else:
        print(mod_combinations_count(n,m,mod)%mod)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
mod=10**9+7

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def mod_combinations_cont(n, r, mod):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

if (x+y)%3!=0:
    print(0)
else:
    n=(x+y)//3
    m=(-x+2*y)/3
    if n<0 or m<0:
        print(0)
        exit()
    else:
        print(mod_combinations_cont(n,m,mod)%mod)
Problem p02879 (python)

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

print(a*b if 1<=a<=9 and 1<=b<=9 else -1)

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

print(a*b if 1<=a<=9 and 1<=b<=9 else -1)

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

print('Yes' if 1<=a<=9 and 1<=b<=9 else 'No')
Problem p02897 (python)

Fixed submission:
n=int(input())
print(((n+1)//2)/n)

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

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

def rle(string):
    tmp = string[0]
    cnt = 1
    ans = []
    for i in range(1, len(string)):
        if tmp == string[i]:
            cnt += 1
        else:
            ans.append(tmp)
            ans.append(cnt)
            tmp = string[i]
            cnt = 1
    ans.append(tmp)
    ans.append(cnt)
    return ans

rle_s=list(rle(s))
# print(rle_s)
ans=[0]*n
sum_cnt=0

for i in range(0,len(rle_s),4):
    r_num=int(rle_s[i+1])
    l_num=int(rle_s[i+3])
    odd_num=r_num//2+(l_num+1)//2
    even_num=r_num+l_num-odd_num

    ans[sum_cnt+r_num-1]=even_num
    ans[sum_cnt+r_num]=odd_num

    sum_cnt+=(r_num+l_num)
    # print(r_num, l_num, odd_num, even_num, sum_cnt)

print(*ans)

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

def rle(string):
    tmp = string[0]
    cnt = 1
    ans = ''
    for i in range(1, len(string)):
        if tmp == string[i]:
            cnt += 1
        else:
            ans += tmp+str(cnt)
            tmp = string[i]
            cnt = 1
    ans += (tmp+str(cnt))
    return ans


rle_s=list(rle(s))

ans=[0]*n
sum_cnt=0

for i in range(0,len(rle_s),4):
    r_num=int(rle_s[i+1])
    l_num=int(rle_s[i+3])
    odd_num=r_num//2+(l_num+1)//2
    even_num=r_num+l_num-odd_num

    ans[sum_cnt+r_num-1]=even_num
    ans[sum_cnt+r_num]=odd_num

    sum_cnt+=(r_num+l_num)
    # print(r_num, l_num, odd_num, even_num, sum_cnt)

print(*ans)

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

def rle(s):
    tmp, cnt, ans = s[0], 1, ''
    for i in range(1, len(s)):
        if tmp == s[i]:
            cnt += 1
        else:
            ans += tmp+str(cnt)
            tmp = s[i]
            cnt = 1
    ans += tmp+str(cnt)
    return ans

rle_s=list(rle(s))
ans=[0]*n
sum_cnt=0
for i in range(0,len(rle_s),4):
    r_num=int(rle_s[i+1])
    l_num=int(rle_s[i+3])
    odd_num=(r_num+l_num+1)//2
    even_num=r_num+l_num-odd_num

    if r_num%2==0:
        ans[sum_cnt+r_num-1]=even_num
        ans[sum_cnt+r_num]=odd_num
    else:
        ans[sum_cnt+r_num-1]=odd_num
        ans[sum_cnt+r_num]=even_num

    sum_cnt+=r_num+l_num
    # print(r_num,l_num,odd_num,even_num)

print(*ans)
Problem p02990 (python)

Fixed submission:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

for i in range(1,k+1):
    if n-k+1<i:
        print(0)
    else:
        ans = combinations_count(k-1,i-1)*combinations_count(n-k+1, i)
        print(int(ans%(10**9+7)))

Buggy submission (verdict: Runtime Error):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())
for i in range(1,k+1):
    ans = combinations_count(k-1,i-1)*combinations_count(n-k+1, i)
    print(int(ans%(10**9+7)))

Buggy submission (verdict: Runtime Error):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())
for i in range(1,k+1):
    ans = combinations_count(k-1,i-1)*combinations_count(n-k+1, i)
    print(int(ans%(10**9+7)))
Problem p03041 (python)

Fixed submission:
n,k=map(int,input().split())
s=input()
ss=s[k-1]

print(s[:(k-1)]+ss.lower()+s[k:])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
ss=s[k]

print(s[:k]+ss.lower()+s[k+1:])
Problem p03108 (python)

Fixed submission:
import sys
# sys.setrecursionlimit(10**7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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

uf = UnionFind(n)
tmp_ans = n*(n-1)//2
ans = []
for i in range(m):
    ans.append(tmp_ans)
    a=ab[m-1-i][0]
    b=ab[m-1-i][1]
    a-=1
    b-=1
    if not uf.is_same(a,b):
        tmp_ans-=uf.size(a)*uf.size(b)
    uf.union(a,b)

ans.reverse()
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

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

par = [i for i in range(n+1)]
rank = [0]*(n+1)
size = [1]*(n+1)

def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

def same(x, y):
    return root(x) == root(y)

def unite(x, y):
    xx = root(x)
    yy = root(y)
    if xx == yy:
        return
    if rank[xx] < rank[yy]:
        par[xx] = yy
        size[yy] += size[xx]
    else:
        par[yy] = xx
        size[xx] += size[yy]
        if rank[xx] == rank[yy]:
            rank[yy] += 1

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

ans=[0]*m
ans[m-1]=n*(n-1)//2

for i in range(M-1, 0, -1):
    a = ab[i][0]
    b = ab[i][1]
    if root(a) != root(b):
        ans[i-1] = ans[i] - size[root(a)]*size[root(b)]
    else:
        ans[i-1] = ans[i]
    unite(a,b)

for ans_i in ans:
    print(ans_i)
Problem p03775 (python)

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

n = int(input())
ans=[1145141919]
for i in range(1,round(math.sqrt(n))+1):
    if n%i==0:
        tmp=max(len(str(i)), len(str(n//i)))
        ans.append(tmp)
print(min(ans))

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

n = int(input())
ans=[]
for i in range(1,round(math.sqrt(n))):
    if n%i==0:
        tmp=max(len(str(i)),len(str(n//i)))
        ans.append(tmp)
print(min(ans))
Problem p03805 (python)

Fixed submission:
n,m=map(int,input().split())
graph = [[] for _ in range(n)]
for i in range(m):
    a, b=map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

def dfs(v, seen):
    if all(seen):
        return 1
    ans=0
    for i in graph[v]:
        if seen[i]:
            continue
        seen[i]=True
        # print(seen)
        ans+=dfs(i, seen)
        seen[i]=False
    return ans

seen=[False]*n
seen[0]=True
print(dfs(0, seen))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
graph=[[]*n for _ in range(n)]
for _ in range(n):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

def dfs(v, seen):
    if all(seen):
        return 1
    ans=0
    for vv in graph[v]:
        if seen[vv]:
            continue
        seen[vv]=True
        ans+=dfs(vv, seen)
        seen[vv]=False
    return ans

seen=[False]*n
seen[0]=True
print(dfs(0, seen))
Problem p02624 (python)

Fixed submission:
#!/usr/bin/env python3
# input
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
ans = n * (n + 1) - 1  # 1とk 自信

i = 2
while i * i <= n:
    num = n // i
    min_i = i * i
    max_i = i * num
    ans += (num - i + 1) * (min_i + max_i)  # 自分自身
    ans -= min_i
    i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
def solve(n):
  ans = n * (n + 1) - 1  # 1とk 自信

  i = 2
  while i * i <= n:
      num = n // i
      min_i = i * i
      max_i = i * num
      ans += (num - i + 1) * (min_i + max_i)  # 自分自身
      ans -= min_i
      i += 1
  print(ans)
  return True

if __name__ = "__main__":
  n = int(input())
  solve(n)
Problem p02726 (python)

Fixed submission:
#!/usr/bin/env python3
n,x,y = map(int,input().split())
# 問題 nC2 の中から、最短距離がk になる頂点の組み合わせをそれぞれ求める
# n <= 2*10**3なのでnC2は回る。O(1)に行ける
if x > y: x,y = y,x
#x < y
ans = [0]*n#出力は 0　消す
for i in range(1,n):
    for j in range(i+1,n+1):# i < jとする
        # パターン 1 [x,y]の両方外
        if y <= i or j <= x:
            k = j-i
            ans[k] += 1
        # パターン2 片方が[i,j]の内側
        elif (x<=i and i <= y and y <= j):
            k = min(j-i,i-x+j-y+1)
            ans[k] += 1
        # 片方が内側 i,x,j,y
        elif (i<=x and x <= j and j<=y):
            k = min(j-i,y-j+1+x-i)
            ans[k] += 1
        elif i <=x and y <= j:
            k = x-i+1+j-y
            ans[k] += 1
        else:#両方[x,y]の内側 x,i,j,y
            k = min(j-i,1+i-x+y-j)
            ans[k] += 1
        #print(i,j,k)
for i in range(1,n):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n, x, y = map(int, input().split())
cnt = [0] * n
# 漸化式が建てられそうでめんどくさい場合は、片方を固定する
# 端点を固定する 1..n-2 から順に大きい頂点に向かって伸びていく
for i in range(n - 1):
    for j in range(i + 1, n):
        if i <= x - 1:
            if j <= x - 1:  # 1 idx
                cnt[j - i] += 1
            elif j <= y - 1:
                cnt[min(j - i, x + y - i - j - 1)] += 1
            else:
                cnt[x - y - i + j + 1] += 1
        elif x - 1 < x <= y - 1:
            if j <= y - 1:
                cnt[min(j - i, 1 + (i - x + 1) + (y - 1 - j))] += 1
            else:
                cnt[min(j - i), 1 + (i - x + 1) + (j - y + 1)] += 1
        else:
            cnt[j - i] += 1

for i in range(1, n):
    print(cnt[i])
Problem p02757 (python)

Fixed submission:
#!/usr/bin/env python3
n,p= map(int,input().split())
s = input()
ans = 0
if p == 2 or p == 5:#右端を固定すれば2,5で割り切れるならそれ以降は全部いけるのでn-iをたす
    for i in range(n):
        if int(s[-1-i]) % p == 0:
            ans += n-i
    print(ans)
    exit()
else:
  s = s[::-1]#反転させてしたからみる
  cnt = [0]*p # pで割った時のあまり
  cnt[0] = 1 # 0の時はなにも取らない時全体も入るので+1する
  modp = 0
  for i,c in enumerate(map(int,s)):#enumerateでiterator i , s[i]の値cを同時に取得
    modp = (c*pow(10,i,p) + modp)%p
    cnt[modp] += 1
  for i in range(p):
    ans += cnt[i]*(cnt[i]-1) //2
  print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
n,p= map(int,input().split())
s = input()
ans = 0
if p == 2 or p == 5:#右端を固定すれば2,5で割り切れるならそれ以降は全部いけるのでn-iをたす
    for i in range(n):
        if int(s[-1-i]) % p == 0:
            ans += n-i
    print(ans)
    exit()
else:
  s = s[::-1]#反転させてしたからみる
  cnt = [0]*p # pで割った時のあまり
  cnt[0] = 1 # 0の時はなにも取らない時全体も入るので+1する
  for i,c in enumerate(map(int,s)):#enumerateでiterator i , s[i]の値cを同時に取得
    k += (c*pow(10,i,p) + cnt[i-1])%p
    cnt[k] += 1
  for i in range(p):
    ans += cnt[i]*(cnt[i]-1) //2
  print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
n,p= map(int,input().split())
s = input()
ans = 0
if p == 2 or p == 5:#右端を固定すれば2,5で割り切れるならそれ以降は全部いけるのでn-iをたす
    for i in range(n):
        if int(s[-1-i]) % p == 0:
            ans += n-i
    print(ans)
    exit()
else:
  s = s[::-1]#反転させてしたからみる
  cnt = [0]*p # pで割った時のあまり
  cnt[0] = 1 # 0の時はなにも取らない時全体も入るので+1する
  for i,c in enumerate(map(int,s)):#enumerateでiterator i , s[i]の値cを同時に取得
    k = c*pow(10,i) + cnt[i-1]
    k = k % p
  for i in range(p):
    ans += cnt[i]*(cnt[i]-1) //2
  print(ans)
Problem p03038 (python)

Fixed submission:
#!/usr/bin/env python3
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = [0]*m
c = [0]*m
for i in range(m):
    b[i],c[i] = map(int,input().split())
c,b = zip(*sorted(zip(c,b)))#c でソートする
# 整数列a からmin からc にb枚まで帰る操作を繰り返した時のsumのmaxを求める
# C の大きい順から、Nを超えないまで並べていく
# もし、そのtotalがN を超える場合は、そのできた配列とaをソートしたものを比べて、
# aをソートしたものの方が大きいところがあれば修正する
# もしtotla がNを超えないなら、小さい順から置き換えたもののそのままでOK
# 実装としては、ソートしたaを前から順番にc[i]より大きいか比べていく
cb = 0
idx = 0
for i in range(n):
    if cb == m:break
    else:
        if a[i] < c[m-1-cb]:a[i] = c[m-1-cb]
        idx += 1
        if idx == b[m-1-cb]:
            idx = 0
            cb += 1
print(sum(a))

Buggy submission (verdict: Runtime Error):
# M回の操作終了後に N枚のカードに書かれた整数の合計の最大値を求めてください。
# で操作はB_j 枚以下の任意のカードをC_jに置き換えるという処理ができる。
# つまり、元のカードの値Aをソートして、小さいものから順にC_jの大きいもので並び替えれば良い
import sys
input=sys.stdin.readline
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b_c = [list(map(int,input().split())) for _ in range(m)]
b_c.sort(key = lambda x:x[1], reverse=True) # c でソートする
pos = 0
ans = sum(a)
for i in range(m): # 一応最後までb_c をループするようにして、c よりも元のカードが大きくなったらbreakする
  if a[pos + b_c[i][0] - 1] > b_c[i][1]:
    for j in range(b_c[i][0]): #　何番目までは入れ替えた方が特か判定
      if a[pos + j] > b_c[i][1] or pos + j >= n:
        break
      else:
        ans += b_c[i][1] - a[pos + j] # 置き換えによる増加量
    break
  else:
    for j in range(b_c[i][0]): #　
      ans += b_c[i][1] - a[pos + j]
    pos += b_c[i][0]
print(ans)
# 最初はエラー : b_c[i][0]をb_c[0]でやっていたから
# 次は値がおかしい。sortがb_cは逆順（大きいものから順に）にする必要がある
# そのためには, reverse=True を入れる
# しかし、これでも入力例2で異なる答え、入力例4でエラーが出る。
# posをたす位置がおかしかった
# ここで提出したが、まさかのRE 時間がかかりすぎ
# 一応O(N)で収まっているはずだが、定数倍の高速化が必要
#

Buggy submission (verdict: Runtime Error):
# M回の操作終了後に N枚のカードに書かれた整数の合計の最大値を求めてください。
# で操作はB_j 枚以下の任意のカードをC_jに置き換えるという処理ができる。
# つまり、元のカードの値Aをソートして、小さいものから順にC_jの大きいもので並び替えれば良い
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b_c = [list(map(int,input().split())) for _ in range(m)]
b_c.sort(key = lambda x:x[1], reverse=True) # c でソートする
pos = 0
ans = sum(a)
for i in range(m): # 一応最後までb_c をループするようにして、c よりも元のカードが大きくなったらbreakする
  if a[pos + b_c[i][0] - 1] > b_c[i][1]:
    for j in range(b_c[i][0]): #　何番目までは入れ替えた方が特か判定
      if a[pos + j] > b_c[i][1] or pos + j >= n:
        break
      else:
        ans += b_c[i][1] - a[pos + j] # 置き換えによる増加量
    break
  else:
    for j in range(b_c[i][0]): #　
      ans += b_c[i][1] - a[pos + j]
    pos += b_c[i][0]
print(ans)
# 最初はエラー : b_c[i][0]をb_c[0]でやっていたから
# 次は値がおかしい。sortがb_cは逆順（大きいものから順に）にする必要がある
# そのためには, reverse=True を入れる
# しかし、これでも入力例2で異なる答え、入力例4でエラーが出る。
Problem p03745 (python)

Fixed submission:
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
bit = 0
ans = 1
i = 0
while i < n-1:
    if a[i+1] == a[i]: pass
    if bit == 0:
        bit = a[i+1]-a[i]
        #ans += 1
    else:#bit が立っているなら符号が一致するかを見て一致しないならans +=  1
        if bit * (a[i+1]-a[i]) < 0:#符号不一致
            bit = 0 
            ans += 1 
    i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
if (a[1]-a[0]) < 0: flag = -1
else: flag = 1
ans = 1
i = 0
while True:
    if flag * (a[i+1]-a[i]) < 0:#増加
        ans += 1
        flag = -1 * flag
        i += 1
    i += 1
    if i == n-1:
        break
    elif i == n:
        ans += 1
        break
print(ans)
Problem p03805 (python)

Fixed submission:
#!/usr/bin/env python3
# input
from collections import deque
import itertools

n, m = map(int, input().split())
path = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    path[a].append(b)
    path[b].append(a)
# n-1 ! を全探索する
all_lis = itertools.permutations(range(1, n))  # 1(0)は出発点なので除く
# print(all_lis)

ans = 0
for i in all_lis:
    start = 0# これをfor の外においていて爆死。
    ok = 1
    for j in range(n - 1):
        if i[j] not in path[start]:
            ok = 0
            break
        else:
            start = i[j]
    if ok:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# input
from collections import deque
import itertools

n, m = map(int, input().split())
a, b = [0] * (n), [0] * (n)
path = [[] for _ in range(n)]
for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    path[a[i]].append(b[i])
    path[b[i]].append(a[i])
# n-1 ! を全探索する
all_lis = itertools.permutations(range(1, n))  # 1(0)は出発点なので除く
# print(all_lis)

ans = 0
for i in all_lis:
    start = 0
    ok = 1
    for j in range(n - 1):
        if i[j] not in path[start]:
            ok = 0
            break
        else:
            start = i[j]
    if ok:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# input
from collections import deque
import itertools

n, m = map(int, input().split())
a, b = [0] * (n), [0] * (n)
path = [[] for _ in range(n)]
for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    path[a[i]].append(b[i])
    path[b[i]].append(a[i])
# n-1 ! を全探索する
all_lis = itertools.permutations(range(1, n))  # 1(0)は出発点なので除く
# print(all_lis)

ans = 0
for i in all_lis:
    start = 0
    ok = 1
    for j in range(n - 1):
        if i[j] not in path[start]:
            ok = 0
            break
        else:
            start = i[j]
    if ok:
        ans += 1
print(ans)
Problem p02659 (python)

Fixed submission:
import math


def solve():
    A, B = input().split()
    print(int(A) * int(B[-4] + B[-2:]) // 100)



if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import math


def solve():
    A, B = input().split()
    A = int(A)
    B = math.floor(B*100)
    print(A*B//100)


if __name__ == '__main__':
    solve()
Problem p02552 (python)

Fixed submission:
x = int(input())

if x == 1:
  print(0)
elif x == 0:
  print(1)
else:
  pass

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

if x == 1:
  print(0)
elif X == 0:
  print(1)
Problem p02552 (python)

Fixed submission:
num = int(input())
if num == 1:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
def _print():
  a = int(input())
  print(1 if a == 0 else 0)

if __name__ = '__main__':
  _print()

Buggy submission (verdict: Runtime Error):
num = int(input())
if num == 1:
  print(0)
 else:
  print(1)

Buggy submission (verdict: Runtime Error):
num = int(input())
if num == 1:
  print(1)
 else:
  print(0)

Buggy submission (verdict: Runtime Error):
num = input()
if num == 1:
  print(1)
 else:
  print(0)
Problem p02759 (python)

Fixed submission:
import math
N = int(input())
print(math.ceil(N/2))

Buggy submission (verdict: Runtime Error):
import itertools
import sys

[a,b,c] = [int(x) for x in input().split()]
[d,e,f] = [int(x) for x in input().split()]
[g,h,i] = [int(x) for x in input().split()]
N = int(input())
num_list = []
for i in range(N):
  n = int(input())
  num_list.append(n)
set_list = [{a,b,c},{d,e,f},{g,h,i},{a,d,g},{b,e,h},{c,f,i},{a,e,i},{c,e,g}]
the_set = set(num_list) & set([a,b,c,d,e,f,g,h,i])
v = itertools.permutations(the_set,3)
for i in v:
  if set(i) in set_list:
    print('Yes')
    sys.exit()
print('No')
Problem p02933 (python)

Fixed submission:
num = int(input())
color = input()
if num >= 3200:
    print(color)
else:
    print('red')

Buggy submission (verdict: Runtime Error):
color = input()
num = int(input())
if num >= 3200:
    print(color)
else:
    print('red')

Buggy submission (verdict: Runtime Error):
color = input()
num = int(input())
if num >= 3200:
    print(s)
else:
    print('red')

Buggy submission (verdict: Runtime Error):
color = input()
num = int(input())
if num <= 3200:
    print(s)
else:
    print('red')
Problem p02552 (python)

Fixed submission:
x = int(input())
if x == 0:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
x = int(input)
if x == 0:
	print(1)
else:
  print(0)