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

Fixed submission:
W, H, x, y = map(int, input().split())
jufuku = 0
if W / 2 == x and H / 2 == y:
    jufuku = 1
print(W * H / 2, jufuku)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
jufuku = 0
if x == 0 and y == 0:
    if y / x == H / W:
        naname = W * H / 2
        jufuku = 1
        kiri = naname
else:
    # 縦
    tate = min((W - x) * H, x * H)
    # 横
    yoko = min(W * (H - y), W * y)
    if tate == yoko:
        jufuku = 1
    kiri = max(tate, yoko)
print(kiri, jufuku)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
jufuku = 0
if (x == 0 and y == 0) or y / x == H / W:
    naname = W * H / 2
    jufuku = 1
    kiri = naname
else:
    # 縦
    tate = min((W - x) * H, x * H)
    # 横
    yoko = min(W * (H - y), W * y)
    if tate == yoko:
        jufuku = 1
    kiri = max(tate, yoko)
print(kiri, jufuku)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
jufuku = 0
if y / x == H / W:
    naname = W * H / 2
    jufuku = 1
    kiri = naname
else:
    # 縦
    tate = min((W - x) * H, x * H)
    # 横
    yoko = min(W * (H - y), W * y)
    if tate == yoko:
        jufuku = 1
    kiri = max(tate, yoko)
print(kiri, jufuku)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(float, input().split())
jufuku = 0
if W % x == 0 and H % y == 0:
    kiri = W * H / 2
    jufuku = 1
else:
    # 縦
    tate = min((W - x) * H, x * H)
    # 横
    yoko = min(W * (H - y), W * y)
    if tate == yoko:
        jufuku = 1
    else:
        kiri = max(tate, yoko)
print(kiri, jufuku)
Problem p03076 (python)

Fixed submission:
import math
ae = [int(input()) for _ in range(5)]
if all([a%10==0 for a in ae]):
    min_ae = 0
else:
    min_ae = 9
num = 0
for a in ae:
    s = str(a)
    if s[-1] == "0":
        pass
    else:
        min_ae = min(int(s[-1]), min_ae)
    if min_ae==int(s[-1]):
        num = a
ae.remove(num)
ceil_ae = [math.ceil(a/10)*10 for a in ae]
print(num + sum(ceil_ae))

Buggy submission (verdict: Runtime Error):
import math
ae = [int(input()) for _ in range(5)]
min_ae = 9
num = 0
for a in ae:
    s = str(a)
    if s[-1] == "0":
        pass
    else:
        min_ae = min(int(s[-1]), min_ae)
    if min_ae==int(s[-1]):
        num = a
ae.remove(num)
ceil_ae = [math.ceil(a/10)*10 for a in ae]
print(num + sum(ceil_ae))
Problem p03087 (python)

Fixed submission:
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(Q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])

Buggy submission (verdict: Runtime Error):
import re

rexp = re.compile("AC")

N, Q = map(int, input().split())
S = input()
ruiseki_S = [""]
for i in range(N):
    ruiseki_S.append(ruiseki_S[i] + S[i])
for i in range(Q):
    l, r = map(int, input().split())
    a = ruiseki_S[r].replace(ruiseki_S[l - 1], "", 1)
    print(len(rexp.findall(a)))
Problem p03125 (python)

Fixed submission:
a, b = map(int, input().split())
if b % a == 0:
    print(a+b)
else:
    print(b-a)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a_list = list(map(int, input().split()))
num = a_list[0]

for i in range(n):
    num = math.gcd(num, a_list[i])
print(num)
Problem p03211 (python)

Fixed submission:
s = input()
print(min(abs(int(s[i:i+3]) - 753) for i in range(len(s) - 2)))

Buggy submission (verdict: Runtime Error):
n = int(input())
sft = 753
list = []
while n > 0:
    list.append(i%10)
    i //= 10 # 必須
list.reverse()
ans = 1000
for i in range(len(list)-2):
    tmp = 100*list[i] + 10*list[i+1] + list[i+2]
    sft - tmp if sft - tmp < ans else ans
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
sft = 753
list = []
while n > 0:
    list.append(i%10)
    i //= 10 # 必須
list.reverse()
ans = 1000
for i in range(len(list)+2):
    tmp = 100*list[i] + 10*list[i+1] + list[i+2]
    sft - tmp if sft - tmp < ans else ans
print(ans)
Problem p03238 (python)

Fixed submission:
import sys

N = int(input())

if N == 1:
    print("Hello World")
    sys.exit()
AB = [int(input()) for _ in range(2)]
print(sum(AB))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
result ='Hello World' if n == 1 else a+b
print(result)
Problem p03243 (python)

Fixed submission:
n = input()
if n[0] == n[1] == n[2]:
    ans = n
elif n[1] > n[0] or (n[1] == n[0] and n[2] > n[0]):
    ans = str(int(n[0])+1)*3
elif n[1] <= n[0] or n[2] < n[0]:
    ans = n[0]*3
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(900):
    x = list(n)
    if x[0]==x[1]==x[2]:
        print(n)
        break 
    n+=1
Problem p03244 (python)

Fixed submission:
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
v_odd = v[0::2]
v_even = v[1::2]
ans = 0
c_odd = Counter(v_odd)
c_even = Counter(v_even)
v_o, c_o = zip(*c_odd.most_common())
v_e, c_e = zip(*c_even.most_common())
if len(c_o) == 1:
    odd1 = 0
else:
    odd1 = c_o[1]
if len(c_e) == 1:
    even1 = 0
else:
    even1 = c_e[1]
if not v_o[0] == v_e[0]:
    print(sum(c_o) - c_o[0] + sum(c_e) - c_e[0])
else:
    ans = min(sum(c_o) - c_o[0] + sum(c_e) - even1, sum(c_o) - odd1 + sum(c_e) - c_e[0])
    print(ans)

Buggy submission (verdict: Runtime Error):
from statistics import mode

n = int(input())
v = list(map(int, input.split()))
a = v[::1]
b = v[1::1]
slash = mode(a)
back_slash = mode(b)
a = [i for i in a if i != slash]
b = [j for j in b if j != back_slash]
print(len(a) + len(b))

Buggy submission (verdict: Runtime Error):
from statistics import mode

n = int(input())
v = list(map(int, input.split()))
a = v[::1]
b = v[1::1]
slash = mode(a)
back_slash = mode(b)
a = [i for i in a if i == slash]
b = [j for j in b if j == back_slash]
print(len(a) + len(b))
Problem p03262 (python)

Fixed submission:
from fractions import gcd


def liner_search(n, l):
    for i in range(len(l)):
        if n < l[i]:
            return i
    return len(l)


N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))
x.insert(liner_search(X, x), X)
sabun = [None] * N
for i in range(1, len(x)):
    sabun[i - 1] = x[i] - x[i - 1]
res = gcd(0, sabun[0])
for i in range(1, len(sabun)):
    res = gcd(res, sabun[i])
print(res)

Buggy submission (verdict: Runtime Error):
from fractions import gcd


def liner_search(n, l):
    for i in range(len(l)):
        if n < l[i]:
            return i
    return len(l)


N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))
x.insert(liner_search(X, x), X)
sabun = [None] * N
for i in range(1, len(x)):
    sabun[i - 1] = x[i] - x[i - 1]
res = gcd(sabun[0], sabun[1])
for i in range(1, len(sabun)):
    res = gcd(res, sabun[i])
print(res)

Buggy submission (verdict: Runtime Error):
def liner_search(n, l):
    for i in range(len(l)):
        if n <= l[i]:
            return i


N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))
x.insert(liner_search(X, x), X)
sabun = [None] * N
for i in range(1, len(x)):
    sabun[i - 1] = x[i] - x[i - 1]
print(sorted(sabun)[0])
Problem p03282 (python)

Fixed submission:
def searchInf(s, k):
    l = k if len(s) >= k else len(s)
    for i in range(l):
        if s[i] == "1":
            continue
        else:
            print(s[i])
            return 0
    print(1)
    return 0


S = list(input())
K = int(input())
searchInf(S, K)

Buggy submission (verdict: Runtime Error):
S = list(input())
K = int(input())
if not S[0] == "1":
    print(S[0])
else:
    print(S[1])
Problem p03377 (python)

Fixed submission:
a, b, x = map(int, input().split())
if a <= x <= a+b:
    ans = "YES"
else:
    ans = "NO"
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input())
if a <= x <= a+b:
    ans = "YES"
else:
    ans = "NO"
print(ans)
Problem p02660 (python)

Fixed submission:
N = int(input())
a = []
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

prime_factorize(N, a)
ans = 0
if len(a) > 1:
    before = a[0]
    kosuu = 1
    for i in range(1, len(a)):
        tmp = a[i]
        if tmp == before:
            kosuu += 1
        else:
            ini = 1
            while kosuu - ini >= 0:
                kosuu = kosuu - ini
                ini += 1
                ans += 1
            before = tmp
            kosuu = 1
        ini = 1
    while kosuu - ini >= 0:
        kosuu = kosuu - ini
        ini += 1
        ans += 1
if len(a) == 1:
    ans = 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = []
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

prime_factorize(N, a)
ans = 0
if len(a) >= 1:
    before = a[0]
    kosuu = 1
    for i in range(1, len(a)):
        tmp = a[i]
        if tmp == before:
            kosuu += 1
        else:
            ini = 1
            while kosuu - ini >= 0:
                kosuu = kosuu - ini
                ini += 1
                ans += 1
            before = tmp
            kosuu = 1
        ini = 1
    while kosuu - ini >= 0:
        kosuu = kosuu - ini
        ini += 1
        ans += 1


print(ans)
Problem p02690 (python)

Fixed submission:
X = int(input())
pin = 0
for i in range(-120, 120):
    if pin == 1:
        break
    for j in range(-120, 120):
        if pow(i, 5) - pow(j, 5) == X :
            pin =1
            print(i, j)
            break

Buggy submission (verdict: Runtime Error):
X = int(input())
i = 0
while True:
  tmp1 = pow(X + pow(i, 5), 1/5)
  if tmp1.is_integer():
    print(int(tmp1), i)
    break
  tmp2 = pow(X - pow(i, 5), 1/5)
  if tmp2.is_integer():
    print(int(tmp2), -i)
    break
  else:
    i += 1
Problem p02691 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 0
plus_lis = [A[i] + i for i in range(N)]
minus_lis = [k - A[k] for k in range(N)]

ans_lis = [0] * 10 ** 6
for x in plus_lis:
    if x < 10 ** 6:
        ans_lis[x-1] += 1
for y in minus_lis:
    if y > 0:
        ans += ans_lis[y-1]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 0
plus_lis = [A[i] + i for i in range(N)]
minus_lis = [k - A[k] for k in range(N)]
plus_lis.sort()
minus_lis.sort()

ans_lis = [0] * 10 ** 6
for x in plus_lis:
    if x < 10 ** 6:
        ans_lis[x-1] += 1
for y in minus_lis:
    if y > 0:
        ans += ans_lis[x-1]
print(ans)
Problem p02713 (python)

Fixed submission:
import math
K = int(input())
ans = 0
for a in range(1, K+1):
  for b in range(1, a+1):
    for c in range(1, b+1):
      if a != b and b != c and c != a:
        ans += math.gcd(math.gcd(a,b),c) * 6
      elif a == b and b == c:
        ans += math.gcd(math.gcd(a,b),c)
      else:
        ans += math.gcd(math.gcd(a,b),c) * 3
print(ans)

Buggy submission (verdict: Runtime Error):
import math
K = int(input())
ans = 0
for a in range(1, K+1):
  for b in range(1, a+1):
    for c in range(1, b+1):
      if a != b and b != c and c != a:
        ans += math.gcd(a,b,c) * 6
      elif a == b and b == c:
        ans += math.gcd(a,b,c)
      else:
        ans += math.gcd(a,b,c) * 3
print(ans)
Problem p02717 (python)

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

Buggy submission (verdict: Runtime Error):
import numpy as np
K = int(input())
lis = [1,2,3,4,5,6,7,8,9]
lis = np.array(lis)
  
if K < 10:
  print(K)
    
else:
  count = 9
  sub_count = 0
  while count < K:
    tmp = lis[sub_count]
    if tmp % 10 == 9:
      count += 2
      lis.append(tmp * 10  + 8)
      lis.append(tmp + 9)
      sub_count += 1
    elif  tmp % 10== 0:
      count += 2
      lis.append(tmp * 10 + 0)
      lis.append(tmp * 10 + 1)
      sub_count += 1
    else:
      count += 3
      for i in range(-1,2):
        lis.append(tmp * 10 + tmp % 10 + i)
      sub_count += 1
  print(lis[count-1])
Problem p02732 (python)

Fixed submission:
import numpy as np
from sys import stdin
input = stdin.readline
N = int(input())
A = list(map(int, input().split()))
number = np.zeros(N, dtype = int)
total = 0

dic = {}
a = sorted(A)
now_key = a[0]
value = 1
dic[now_key] = 1
for i in range(1,N):
  if a[i] == now_key:
    value += 1
  else:
    dic[now_key] = value
    if value >= 2:
      total += value * (value-1) // 2
    now_key = a[i]
    value = 1
dic[now_key] = value
if value >= 2:
  total += value * (value-1)//2
for j in A:
  print(total - dic[j] + 1)

Buggy submission (verdict: Runtime Error):
import numpy as np
from sys import stdin
input = stdin.readline
N = int(input())
A = list(map(str, input().split()))
A = np.array(A)
number = np.zeros(N, dtype = int)
for i in range(N):
  number[i] = A.count(str(i + 1))
total = 0
for k in range(N):
  tmp = number[k]
  total += tmp * (tmp-1) // 2
for j in range(N):
  print(total - number[A[j]-1] + 1)

Buggy submission (verdict: Runtime Error):
import numpy as np
from sys import stdin
input = stdin.readline
N = int(input())
A = list(map(str, input().split()))
A = np.array(A)
number = np.zeros(N, dtype = int)
for i in range(N):
  number[i] = A.count(str(i + 1)
total = 0
for k in range(N):
  tmp = number[k]
  total += tmp * (tmp-1) // 2
for j in range(N):
  print(total - number[A[j]-1] + 1)

Buggy submission (verdict: Runtime Error):
import numpy as np
from sys import stdin
input = stdin.readline
N = int(input())
A = list(map(str, input().split()))
A = np.array(A)
number = np.zeros(N, dtype = int)
for i in range(N):
  number[i] = A.count('i + 1')
total = 0
for k in range(N):
  tmp = number[k]
  total += tmp * (tmp-1) // 2
for j in range(N):
  print(total - number[A[j]-1] + 1)

Buggy submission (verdict: Runtime Error):
import numpy as np
from sys import stdin
input = stdin.readline
N = int(input())
A = list(map(int, input().split()))
A = np.array(A)
number = np.zeros(N, dtype = int)
for i in range(N):
  number[i] = A.count(i + 1)
total = 0
for k in range(N):
  tmp = number[k]
  total += tmp * (tmp-1) // 2
for j in range(N):
  print(total - number[A[j]-1] + 1)

Buggy submission (verdict: Runtime Error):
impot numpy as np
N = int(input())
A = list(map(int, input().split()))
A = np.array(A)
number = np.zeros(N, dtype = int)
for i in range(N):
  number[A[i]-1] += 1
total = 0
for k in range(N):
  total += number[k] * (number[k]-1) // 2
for j in range(N):
  print(total - number[A[j]-1] + 1)
Problem p02748 (python)

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mi = 10**6
for i in range(M):
  x, y, c = map(int, input().split())
  tmp = a[x-1] + b[y-1] - c
  if mi > tmp:
    mi = tmp
a.sort()
b.sort()
tmp = a[0] + b[0]
if mi > tmp:
  mi = tmp
print(mi)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mi = 10**6
for i in range(M):
  x, y, c = map(int, input().split())
  tmp = A[x-1] + B[y-1] - c
  if mi > tmp:
    mi = tmp
A.sort()
B.sort()
tmp = A[0] + B[0]
if mi > tmp:
  mi = tmp
print(mi)
Problem p02786 (python)

Fixed submission:
H = int(input())
def re(a):
  if a == 1:
    return 1
  return 2 * re(a//2) + 1
print(re(H))

Buggy submission (verdict: Runtime Error):
H = int(input())
total = 1
while H > 1:
  H = H // 2
  if H != 0:
    total += 1
number = 0
for i in range(tatal):
  number += 2 ** i
print(number)

Buggy submission (verdict: Runtime Error):
H = int(input())
total = 1
while H != 1:
  H = H // 2
  total += 1
for i in range(tatal):
  number += 2 ** i
print(number)
Problem p02787 (python)

Fixed submission:
#初見じゃ無理だった。DPを使う
#標準入力
import math
H, N = map(int, input().split())
AB = []
max_A = 0
for i in range(N):
    ab = list(map(int, input().split()))
    if max_A < ab[0] :
        max_A = ab[0]
    AB.append(ab)

 #DP
DP = [0] * (H + max_A)
for i in range(1, H + max_A ): #DP[i] の最小値を求めていく
    tmp_mini = 10 ** 8
    for j in range(N):
        if i - AB[j][0] >= 0:
            tmp = DP[i - AB[j][0]] + AB[j][1]
            if tmp_mini > tmp:
                tmp_mini = tmp
    DP[i] = tmp_mini
print(min(DP[H: H + max_A]))

Buggy submission (verdict: Runtime Error):
#初見じゃ無理だった。DPを使う
#標準入力
import numpy as np
H, N = map(int, input().split())
AB = []
max_A = 0
for i in range(N):
    ab = list(map(int, input().split()))
    if max_A < ab[0] :
        max_A = ab[0]
    AB.append(ab)

 #DP
DP = [0] * (H + max_A)
for i in range(1, H + max_A ): #DP[i] の最小値を求めていく
    tmp_mini = 10 ** 8
    for j in range(N):
        if i - AB[j][0] >= 0:
            tmp = DP[i - AB[j][0]] + AB[j][1]
            if tmp_mini > tmp:
                tmp_mini = tmp
    DP[i] = tmp_mini
print(min(DP[H: H + max_A]))
Problem p02791 (python)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
count = 1
tmp_min = P[0]
for i in range(1, N):
  if P[i] <= tmp_min:
    count += 1
    tmp_min = P[i]
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
count = 1
for i in range(1, N):
  if P[i] <= min(P[0,i]):
    count += 1
print(count)
Problem p02801 (python)

Fixed submission:
C = input()
k = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(len(k)):
  if C == k[i]:
    print(k[i+1])

Buggy submission (verdict: Runtime Error):
from intertools import chain
from collections import deque
H, W = map(int,input().split())
S = [list(map(str,input().split())) for _ in range(H)]
dhw = [[0,1],[0,-1],[1,0],[-1,0]]

ans = 0
for h in range(H):
  for w in range(W):
    d = deque([h,w])
    maze = [[-1] * W for _ in range(H)]
    if S[h][w] == '#':
      continue
    maze[h][w] = 0
    while d:
      ht , hw = d.popleft()
      for dh, dw in dhw:
        nh = ht + dh
        nw = wt + dw
        if 0 <= nh < H and 0 <= nw < W:
          if maze[nh][nw] == -1 and S[nh][nw] == '.':
            d.append([nh,nw])
            maze[nh][nw] = maze[ht][wt] + 1
    ans = max(ans,max(chain(*maze))
print(ans)

Buggy submission (verdict: Runtime Error):
C = input()
k = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
for i in range(len(k)):
  if C == k[i]:
    print(k[i+1])

Buggy submission (verdict: Runtime Error):
C = input()
k = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,g]
for i in range(len(k)):
  if C == k[i]:
    print(k[i+1])
Problem p02802 (python)

Fixed submission:
N,M = map(int,input().split())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
  a,b = input().split()
  if lis[int(a)-1] < 0:
    pass
  elif b == 'AC':
    WA += lis[int(a)-1]
    AC += 1
    lis[int(a)-1] = -1
  else:
    lis[int(a)-1] += 1
print(AC, WA)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
  a,b = map(input().split())
  if lis[int(a)-1] < 0:
    pass
  elif b == 'AC':
    WA += lis[int(a)-1]
    AC += 1
    lis[int(a)-1] = -1
  else:
    lis[int(a)-1] += 1
print(AC, WA)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
  a,b = map(input().split())
  if lis[int(a)-1] < 0:
    pass
  elif b == 'AC'
    WA += lis[int(a)-1]
    AC += 1
    lis[int(a)-1] = -1
  else:
    lis[int(a)-1] += 1
print(AC, WA)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
AC = 0
WA = 0
lis_ac = []
dic_wa ={}
if M == 0:
  print(0,0)
else:
  A = [list(input().split()) for i in range(M)]
  for i in range(M):
    if A[i][0] not in lis_ac:
      if A[i][1] == 'AC':
        lis_ac.append(A[i][0])
        WA += dic_wa[A[i][0]]
      elif A[i][0] in dic_wa.keys():
        dic_wa[A[i][0]] += 1
      else:
        dic_wa[A[i][0]] = 1
  print(len(lis_ac), WA)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
AC = 0
WA = 0
lis_ac = []
dic_wa ={}
if M == 0:
  print(0,0)
else:
  for i in range(M):
    A = list(input().split())
    if A[0] not in lis_ac:
      if A[1] == 'AC':
        lis_ac.append(A[0])
        WA += dic_wa[A[0]]
      elif A[0] in dic_wa.keys():
        dic_wa[A[0]] += 1
      else:
        dic_wa[A[0]] = 1
  print(len(lis_ac), WA)
Problem p02813 (python)

Fixed submission:
import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lis1 = [i for i in range(1,N+1)]
lis2 = [i for i in range(1,N+1)]
def number(a, lis):
  total_order = 1
  for i in range(N):
    tmp_order = lis.index(a[i])
    lis.remove(a[i])
    total_order += tmp_order * math.factorial(len(lis))
  return total_order
print(abs(number(P, lis1) - number(Q, lis2)))

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lis1 = [i for i in range(1,N+1)]
lis2 = [i for i in range(1,N+1)]
def number(a, lis):
  total_order = 1
  for i in range(N):
    tmp_order = lis.index(a[i])
    lis.remove(a[i])
    total_order += tmp_order * math.factorial(len(lis))
  return total_order
print(abs(number(P, lis1) - number(Q, lis2)))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lis1 = [i for i in range(1,N+1)]
lis2 = [i for i in range(1,N+1)]
def number(a, lis):
  total_order = 1
  for i in range(N):
    tmp_order = lis.index(a[i])
    lis.pop(a[i])
    total_order += tmp_order * math.factorial(len(lis))
  return total_order
print(abs(number(P, lis1) - number(Q, lis2)))
Problem p02850 (python)

Fixed submission:
#グラフ構造DFSを使う
import sys
sys.setrecursionlimit(500000)
N = int(input())
ans = [-1] * (N-1)
g = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    g[a-1].append((b-1, i))
    g[b-1].append((a-1, i))

def bfs(v, c, p):
    n_c = 1
    for i in range(len(g[v])):
        to = g[v][i][0]
        ID = g[v][i][1]
        if to == p:
            continue
        if n_c == c:
            n_c += 1
        ans[ID] = n_c
        bfs(to, n_c, v)
        n_c += 1

bfs(0, 0, -1)
print(max(ans))
for i in range(N-1):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
#グラフ構造DFSを使う
N = int(input())
ans = [-1] * (N-1)
g = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    g[a-1].append((b-1, i))
    g[b-1].append((a-1, i))

def bfs(v, c, p):
    n_c = 1
    for i in range(len(g[v])):
        to = g[v][i][0]
        ID = g[v][i][1]
        if to == p:
            continue
        if n_c == c:
            n_c += 1
        ans[ID] = n_c
        bfs(to, n_c, v)
        n_c += 1

bfs(0, 0, -1)
print(max(ans))
for i in range(N-1):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
#標準入力からKを求めるまで
N = int(input())
node = [0] * N
AB = []
for i in range(N-1):
    ab = list(map(int, input().split()))
    node[ab[0] - 1] += 1
    node[ab[1] - 1] += 1
    AB.append(ab)
K = max(node)
print(K)

#各辺の色を求めていく
color = [[ i for i in range(1, K + 1)] for i in range(N)]
for i in range(N-1):
    now = list(set(color[AB[i][0]-1]) & set(color[AB[i][1] - 1]))
    tmp = now[0]
    color[AB[i][0]-1].remove(tmp)
    color[AB[i][1]-1].remove(tmp)
    print(tmp)

Buggy submission (verdict: Runtime Error):
#標準入力からKを求めるまで
N = int(input())
node = [0] * N
AB = []
for i in range(N-1):
    ab = list(map(int, input().split()))
    node[ab[0] - 1] += 1
    node[ab[1] - 1] += 1
    AB.append(ab)
K = max(node)
print(K)

#各辺の色を求めていく
color = [[ i for i in range(1, K + 1)] for i in range(N)]
for i in range(N-1):
    now = list(set(color[AB[i][0]-1]) & set(color[AB[i][1] - 1]))
    tmp = now[0]
    color[AB[i][0]-1].remove(tmp)
    color[AB[i][1]-1].remove(tmp)
    print(tmp)