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

Fixed submission:
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools, random
from collections import deque
from heapq import heappush, heappop
sys.setrecursionlimit(10 ** 7)
ans = 0
tmp = 0
inf = 10 ** 20
INF = float("INF")
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
ddn9 = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

h, w, n = wi()
c = mip(n)

d = collections.defaultdict(int)

for i in range(n):
    for dx, dy in ddn9:
        nx = c[i][1] + dx;
        ny = c[i][0] + dy
        if 0 < nx < w - 1 and 0 < ny < h - 1:
            d[str(ny) + "+" + str(nx)] += 1#前のままだと，28+1,2+81とかがが被る

ansli = [0] * 10
for i in d:
    ansli[d[i]] += 1

ansli[0] = (h - 2) * (w - 2) - sum(ansli)
for i in ansli:
    print(i)

Buggy submission (verdict: Runtime Error):
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools, random
from collections import deque
from heapq import heappush, heappop
sys.setrecursionlimit(10 ** 7)
ans = 0
tmp = 0
inf = 10 ** 20
INF = float("INF")
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
ddn9 = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

h, w, n = wi()
c = mip(n)

d = collections.defaultdict(int)

for i in range(n):
    for dx, dy in ddn9:
        nx = c[i][1] + dx;
        ny = c[i][0] + dy
        if 0 < nx < w - 1 and 0 < ny < h - 1:
            d[str(ny) + str(nx)] += 1

ansli = [0] * 10
for i in d:
    ansli[d[i]] += 1

ansli[0] = (h - 2) * (w - 2) - sum(ansli)
for i in ansli:
    print(i)
Problem p03998 (python)

Fixed submission:
A, B, C = [input() for _ in range(3)]

x = A[0]
cnt_a = 0
cnt_b = 0
cnt_c = 0
for _ in range(len(A)+len(B)+len(C)):
    if x == "a":
        if cnt_a < len(A):
            x = A[cnt_a]
            cnt_a += 1
        else:
            print("A")
            break
    elif x == "b":
        if cnt_b < len(B):
            x = B[cnt_b]
            cnt_b += 1
        else:
            print("B")
            break
    else:
        if cnt_c < len(C):
            x = C[cnt_c]
            cnt_c += 1
        else:
            print("C")
            break

Buggy submission (verdict: Runtime Error):
SA = list(str(input())) 
SB = list(str(input())) 
SC = list(str(input())) 
list=[SA,SB,SC]
a=0
list[0].pop(0)
while True:
    a=ord(list[a][0])-97
    list[a].pop(0)
    if len(list[0])==0 or len(list[1])==0 or len(list[2])==0:
        break
print(chr(a+65))
Problem p02713 (python)

Fixed submission:
import fractions as fr
k = int(input())
ans = (k+1)*k//2
tttt = [[0]*(k+1) for _ in range(k+1)]
for i in range(1, k+1):
  for j in range(1, k+1):
    if i == j:
      continue
    else:
      if tttt[i][j] != 0:
        g = tttt[i][j]
        ans += 3*g
      else:
        g = fr.gcd(i,j)
        tttt[i][j] = g
        tttt[j][i] = g
        ans += 3*g
for i in range(1, k-1):
  for j in range(i+1, k):
    for l in range(j+1, k+1):
      temp = tttt[i][j]
      temp2 = tttt[temp][l]
      ans+= 6*temp2
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions as fr
k = int(input())
ans = (k+1)*k//2
tttt = [[0]*(k+1) for _ in range(k+1)]
for i in range(1, k+1):
  for j in range(1, k+1):
    if i == j:
      continue
    else:
      if tttt[i][j] != 0:
        g = tttt[i][j]
        ans += 3*g
      else:
        g = fr.gcd(i,j)
        tttt[i][j] = g
        tttt[j][i] = g
        ans += 3*g
for i in range(1, k-1):
  for j in range(i+1, k):
    for l in range(j+1, k+1):
      temp = tttt[i][j]
      temp2 = tttt[temp][l]
      ans+= 6*tee
print(ans)
Problem p02717 (python)

Fixed submission:
a, b, c = input().split()
lis = [c, a, b]
print(" ".join(lis))

Buggy submission (verdict: Runtime Error):
x, y, z = map(int, input().split())
lis = [x, y, z]
print("".join(lis))

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
lis = [c, a, b]
print(" ".join(lis))
Problem p02718 (python)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
a.sort(reverse = True)
k = s/(4*m)
if a[m-1] < k:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
a.sort(reversed = True)
k = s/(4*m)
if a[m-1] < k:
  print("No")
else:
  print("Yes")
Problem p02719 (python)

Fixed submission:
n, k = map(int, input().split())
if n == k:
  print(0)
  exit()
l = n%k
print(min(l, k-l))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
if n == k:
  print(0)
  exit()
l = k%n
print(min(l, k-l))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
if n == k:
  print(0)
  exit()
if n > k:
  k, n = n, k
l = k%n
print(min(l, n-l))
Problem p02727 (python)

Fixed submission:
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
pp = p[:x]
qq = q[:y]
if x+y <= c:
  rr = r[:(x+y)]
else:
  rr = r
ppqqrr = pp + qq + rr
ppqqrr.sort(reverse = True)
print(sum(ppqqrr[:x+y]))

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
pp = p[:x]
qq = q[:y]
if x+y <= c:
  rr = r[:(x+y)]
else:
  rr = r
ppqq = pp + qq
ppqq.sort()
for i in range(len(ppqq)):
  if ppqq[i] < rr[0]:
    ppqq[i] = rr[0]
    del rr[0]
print(sum(ppqq))

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
pp = p[:x]
qq = q[:y]
rr = r[:(x+y)]
ppqq = pp + qq
ppqq.sort()
for i in range(len(ppqq)):
  if ppqq[i] < rr[0]:
    ppqq[i] = rr[0]
    del rr[0]
print(sum(ppqq))
Problem p02854 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
k = 0
f = 0
for i in range(n):
  k += a[i]
  if k >= s//2:
    f = i
    break
k = max(k, s - k)
k2 = k - a[f]
k2 = max(k2, s - k2)
print(min(2*k - s, 2*k2 - s))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
k = 0
f
for i in range(n):
  k += a[i]
  if k >= a//2:
    f = i
    break
print(2*k - s)
Problem p02855 (python)

Fixed submission:
h, w, k = map(int, input().split())
l = []
ans = []
for i in range(h):
  lll = [0 for x in range(w)]
  ans.append(lll)
for i in range(h):
  ll = list(input())
  l.append(ll)
res = 0
fl = False
for i in range(h):
  res2 = 0
  if not "#" in l[i]:
    if i == 0:
      fl = True
      
    else:
      ans[i] = ans [i-1]
      
  else:
    res += 1
    for j in range(w):
      if l[i][j] == "#":
        res2 += 1
        if res2 >= 2:
          res += 1
        ans[i][j] = res     
      else:
        ans[i][j] = res
if fl:
  ffff = 1
  for i in range(h):
    if "#" in l[i]:
      ffff = i
      break
  for i in reversed(range(1, ffff+1)):
    ans[i-1] = ans[i]
for i in range(h):
  print(' '.join(map(str, ans[i])))

Buggy submission (verdict: Runtime Error):
h, w, k = map(int, input().split())
l = []
ans = []
for i in range(h):
  lll = [0 for x in range(w)]
  ans.append(lll)
for i in range(h):
  ll = list(input())
  l.append(ll)
res = 0
for i in range(h):
  res2 = 0
  res += 1
  if not "#" in l[i]:
    if i == 0:
      fl = True
    else:
      ans[i] = ans [i-1]
      break
  for j in range(w):
    if l[i][j] == "#":
      res2 += 1
      if res2 >= 2:
        res += 1
      ans[i][j] = res     
    else:
      ans[i][j] = res
if fl:
  for i in range(h):
    for j in range(w):
      ans[i][j] -= 1/2
  ans[0] = ans[1]
  for i in range(h):
    for j in range(w):
      ans[i][j] = int(ans[i][j])
for i in range(h):
  print(' '.join(map(str, ans[i])))
Problem p02866 (python)

Fixed submission:
import collections
n = int(input())
d = list(map(int, input().split()))
fl = False
if d[0] != 0:
  fl = True
  print(0)
else:
  del d[0]
  c = collections.Counter(d)
  ll = len(c)
  ans = 1
  for i in range(1, ll+1):
    if c[i] == 0:
      print(0)
      fl = True
      break
    else:
      if i != 1:
        ans *= c[i-1]**c[i]

if not fl:
  print(ans%998244353)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
d = list(map(int, input().split()))
if d[0] != 0:
  print(0)
else:
  del d[0]
  c = collections.Counter(d)
  ll = len(c)
  ans = 1
  fl = False
  for i in range(1, ll+1):
    if c[i] == 0:
      print(0)
      fl = True
      break
    else:
      if i != 1:
        ans *= c[i-1]**c[i]

if not fl:
  print(ans%998244353)
Problem p02889 (python)

Fixed submission:
from scipy.sparse.csgraph import floyd_warshall

n, m, l = map(int, input().split())
inf = 10**12
d = [[inf for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(m):
    x,y,z = map(int,input().split())
    d[x-1][y-1] = z
    d[y-1][x-1] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
dd = floyd_warshall(d)
ddd = [[inf for i in range(n)] for i in range(n)]
for i in range(n):
  for j in range(n):
    if dd[i][j] <= l:
      ddd[i][j] = 1
dddd =floyd_warshall(ddd)
q = int(input())
for i in range(q):
  s, t = map(int, input().split())
  if dddd[s-1][t-1] == inf:
    print(-1)
  else:
    print(int(dddd[s-1][t-1]-1))

Buggy submission (verdict: Runtime Error):
n, m, l = map(int, input().split())
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
inf = 10**12
d = [[inf for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(m):
    x,y,z = map(int,input().split())
    d[x-1][y-1] = z
    d[y-1][x-1] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
dd = warshall_floyd(d)
ddd = [[inf for i in range(n)] for i in range(n)]
for i in range(n):
  for j in range(n):
    if dd[i][j] <= l:
      ddd[i][j] = 1
dddd = warshall_floyd(ddd)
q = int(input())
for i in range(q):
  s, t = map(int, input().split())
  if dddd[s][t] == inf:
    print(-1)
  else:
    print(dddd[s-1][t-1]-1)

Buggy submission (verdict: Runtime Error):
n, m, l = map(int, input().split())
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
inf = 10**12
d = [[inf for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(m):
    x,y,z = map(int,input().split())
    d[x-1][y-1] = z
    d[y-1][x-1] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
dd = warshall_floyd(d)
ddd = [[inf for i in range(n)] for i in range(n)]
for i in range(n):
  for j in range(n):
    if dd[i][j] <= l:
      ddd[i][j] = 1
dddd = warshall_floyd(ddd)
q = int(input())
for i in range(q):
  s, t = map(int, input().split())
  if dddd[s][t] == inf:
    print(-1)
  else
    print(dddd[s-1][t-1]-1)
Problem p02910 (python)

Fixed submission:
ans = True
S = input()
i = 0
while i < len(S):
  if S[i] == "L":
    ans = False
  i += 2
j = 1
while j < len(S):
  if S[j] == "R":
    ans = False
  j += 2
if ans:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
bool ans = True
S = input()
i = 0
while i < len(S):
  if S[i] == "L":
    ans = False
  i += 2
j = 1
while j < len(S):
  if S[j] == "R":
    ans = False
  j += 2
if ans:
  print("Yes")
else:
  print("No")
Problem p03076 (python)

Fixed submission:
import math
dish = [int(input()) for _ in range(5)]
sm = 9
smin = 0
for cnt, item in enumerate(dish):
  r = item % 10
  if 1 <= r <= 9:
    if sm > r:
      sm = r
      smin = cnt
ans = 0    
for cnt, item in enumerate(dish):
  if cnt == smin:
    ans += item
  else:
    r = item % 10
    if 1 <= r <= 9:
      ans += item + 10 - r
    else:
      ans += item
print(ans)

Buggy submission (verdict: Runtime Error):
import math
dish = [int(input()) for _ in range(5)]
sm = 9
smin = 0
for item in dish:
  r = item % 10
  if 1 <= r <= 10:
    if sm > r:
      sm = r
      smin = item
ans = 0    
for cnt, item in enumerate(dish):
  if cnt == smin:
    ans += item
  else:
    ans += math.ceil(item, -1)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
dish = [int(input()) for _ in range(5)]
sm = 9
for item in dish:
  r = item % 10
  if 1 <= r <= 10:
    sm = min(sm, r)
    smin = item
ans = 0    
for cnt, item in enumerate(dish):
  if cnt == smin:
    ans += item
  else:
    ans += math.ceil(item)
print(ans)
Problem p03088 (python)

Fixed submission:
N, MOD = int(input()), 10**9 + 7
memo = [{} for x in range(N + 1)]
def ok(last4):
  for i in range(4):
    t = list(last4)
    if i >= 1:
      t[i-1], t[i] = t[i], t[i-1]
    if ''.join(t).count('AGC') >= 1:
      return False
  return True

def dfs(cur, last3):
  if last3 in memo[cur]:
    return memo[cur][last3]
  if cur == N:
    return 1
  ret = 0
  for c in 'ACGT':
    if ok(last3 + c):
      ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
  memo[cur][last3] = ret
  return ret

print(dfs(0, 'TTT'))

Buggy submission (verdict: Runtime Error):
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for x in range(N + 1)]
def ok(sec4):
  for i in range(4):
    tem = sec4
    if i >= 1:
      tem[i - 1], tem[i] = tem[i], tem[i - 1]  
    if tem[:3] == "AGC" or tem[1:] == "AGC":
      return False
  return True
def dfs(cur, last3):
  if last3 in memo[cur]:
    return memo[cur][last3]
  if cur == N:
    return 1
  ret = 0
  for s in "AGCT":
    if ok(last3 + s):
      ret = ret + dfs(cur + 1, last3[1:] + s)
  memo[cur][last3] = ret
  return ret
print(dfs(0, "TTT") % MOD)
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):
H, W = map(int, input().split())
h, w = map(int, input().split())
print(H*W - (H - h)(W - w))
Problem p03103 (python)

Fixed submission:
N, M = map(int, input().split())
lis = []
for _ in range(N):
  a, b = map(int, input().split())
  lis.append((a, b))
def eval(data):
  return data[0]
lis.sort(key=eval)
total = 0
num = 0
mark = 0
for i in range(N):
  num = num + lis[i][1]
  total = total + lis[i][0]*lis[i][1]
  if num > M:
    mark = i
    total = total - lis[i][0]*lis[i][1]
    num = num - lis[i][1]
    break
total = total + (M - num)*lis[mark][0]
print(total)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
lis = []
for _ in range(N):
  a, b = map(int, input().split)
  for l in range(b):
    lis.append(a)
lis.sort()
total = 0
for i in range(M):
  total = total + lis[i]
print(total)
Problem p03109 (python)

Fixed submission:
Y, M, D = map(int, input().split("/"))
boo = False
if Y < 2019:
  boo = True
else:
  if Y == 2019 and M <= 4:
    boo = True
if boo:
  print("Heisei")
else:
  print("TBD")

Buggy submission (verdict: Runtime Error):
Y, M, D = map(int, input().split(/))
boo = False
if Y < 2019:
  boo = True
else:
  if Y == 2019 and M <= 4:
    boo = True
if boo:
  print("Heisei")
else:
  print("TBD")
Problem p03110 (python)

Fixed submission:
N = int(input())
total = 0
for _ in range(N):
  x, u = input().split()
  i = float(x)
  if u == "JPY":
    total += i
  else:
    total += i*380000
print(total)

Buggy submission (verdict: Runtime Error):
N = int(input())
total = 0
for _ in range(N):
  x, u = input().split()
  i = int(x)
  if u == "JPY":
    tptal += i
  else:
    total += i*380000
print(total)

Buggy submission (verdict: Runtime Error):
N = int(input())
total = 0
for _ in range(N):
  x, u = input().split()
  i = int(x)
  if u == "JPY":
    tptal += i
  else:
    total += i*380000.0
print(total)
Problem p03111 (python)

Fixed submission:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
inf = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    if min(a, b, c) > 0:
      return abs(a - A) + abs(b - B) + abs(c - C) - 30 
    else:
      return inf
  else:  
    ret0 = dfs(cur + 1, a, b, c) 
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
inf = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    if min(a, b, c) > 0:
      return abs(a - A) + abs(b - B) + abs(c - C) 
    else:
      return inf
  else:  
  ret0 = dfs(cur + 1, a, b, c) 
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
if cur == N:
  return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
Problem p03112 (python)

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
  res = INF
  for S in [s[b - 1], s[b]]:
    for T in [t[d - 1], t[d]]:
      d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
      res = min(res, d1, d2)
  print(res)

Buggy submission (verdict: Runtime Error):
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
　　x = int(input())
　　b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
　　res = INF
　　for S in [s[b - 1], s[b]]:
　　　　for T in [t[d - 1], t[d]]:
　　　　　　d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
　　　　　　res = min(res, d1, d2)
print(res)
Problem p02817 (python)

Fixed submission:
ST = input().split()
s = ""
s += ST[1]
s += ST[0]
print(s)

Buggy submission (verdict: Runtime Error):
ST = input().split()
s += ST[0]
s += ST[1]
Problem p02898 (python)

Fixed submission:
N, K = map(int, input().split())
H = list(map(int, input().split()))
c = 0
for h in H:
  if h>=K:
    c += 1
print(c)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = list(map(int, input().split()))
c = 0
for h in H:
  if h>=K:
    c += 1
primt(c)
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
c = 0
if S[0]==T[0]:
  c += 1
if S[1]==T[1]:
  c += 1
if S[2]==T[2]:
  c += 1
print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
c=0
f = True
for i in range(N):
  A.append(list(map(int, input().split())))
idx = [0 for i in range(N)]

a = 0

cc = 0

ccc = 0

btlf = [False for i in range(N)]#その周回ですでにバトルしたかどうかのフラグです
m = (N*(N-1))//2
n = 100000
for i in range(min(m,n)):#周回
  btlf = [False for i in range(N)]#リセット
  ccc = 0
  for j in range(N):
    #print(idx)
    if idx[j] != N-1:
      a = A[j][idx[j]]
      if a>j:
        if A[a-1][idx[a-1]]-1==j and btlf[a-1] == False and btlf[j] == False:
          idx[a-1]+=1
          btlf[a-1] = True
          idx[j]+=1
          btlf[j] = True
          cc+=1
          ccc+=1
  if cc == m:#idx == [N-1 for i in range(N)]:
    print(i+1)
    f = False
    break
  if ccc == 0:#対戦が一度もなければ打ち切ります
    break
if f:
  print(-1)
Problem p02926 (python)

Fixed submission:
import cmath
import math

N = int(input())
pc = []
for i in range(N):
  x, y = map(int, input().split())
  c = x + y*1j
  p = cmath.phase(c)
  pc.append([p, c])
pc = sorted(pc, key=lambda x: x[0])

ps = [pc[i][0] for i in range(N)]
cs = [pc[i][1] for i in range(N)]

def L(i, j, N):
  if i<j:
    return list(range(i, j))
  else:
    return list(range(0, j)) + list(range(i+1, N))

s = 0
m = 0

for start in range(N):
  for end in range(N):
    s = 0
    #print(start,end,N,L(start,end,N))
    for k in L(start,end,N):
      s += cs[k]
    m = max(m, abs(s))
s = 0
for k in range(N):
  s += cs[k]
  m = max(m, abs(s))
print(m)

Buggy submission (verdict: Runtime Error):
import cmath
import math

N = int(input())
pc = []
for i in range(N):
  x, y = map(int, input().split())
  c = x + y*1j
  p = cmath.phase(c)
  pc.append([p, c])
pc = sorted(pc)

ps = [pc[i][0] for i in range(N)]
cs = [pc[i][1] for i in range(N)]

def L(i, j, N):
  if i<j:
    return list(range(i, j))
  else:
    return list(range(0, j)) + list(range(i+1, N))

s = 0
m = 0

for start in range(N):
  for end in range(N):
    s = 0
    #print(start,end,N,L(start,end,N))
    for k in L(start,end,N):
      s += cs[k]
    m = max(m, abs(s))
s = 0
for k in range(N):
  s += cs[k]
  m = max(m, abs(s))
print(m)

Buggy submission (verdict: Runtime Error):
import cmath
import math

N = int(input())
pc = []
for i in range(N):
  x, y = map(int, input().split())
  c = x + y*1j
  p = cmath.phase(c)
  pc.append([p, c])
pc = sorted(pc)

ps = [pc[i][0] for i in range(N)]
cs = [pc[i][1] for i in range(N)]

def L(i, j, N):
  if i<j:
    return list(range(i, j))
  else:
    return list(range(0, i)) + list(range(j+1, N))

s = 0
m = 0

for i in range(N):
  for j in range(N):
    s = 0
    s = 0
    for k in L(i,j,N):
      s += cs[k]
    m = max(m, abs(s))

print(m)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
c=0
f = True
for i in range(N):
  A.append(list(map(int, input().split())))
idx = [0 for i in range(N)]

a = 0

btlf = [False for i in range(N)]#その周回ですでにバトルしたかどうかのフラグです

for i in range((N*(N-1))//2):#周回
  btlf = [False for i in range(N)]#リセット
  for j in range(N):
    #print(idx)
    if idx[j] != N-1:
      a = A[j][idx[j]]
      if A[a-1][idx[a-1]]-1==j and btlf[a-1] == False and btlf[j] == False:
        idx[a-1]+=1
        btlf[a-1] = True
        idx[j]+=1
        btlf[j] = True
        #c+=1#とりあえず試合数で実装して後から修正します
  if idx == [N-1 for i in range(N)]:
    print(i+1)
    f = False
    break
  if btlf == [False for i in range(N)]:#対戦が一度もなければ打ち切ります
    break
if f:
  print(-1)
Problem p02934 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
s = 0
for i in range(N):
  s += 1/A[i]
print(1/s)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())
s = 0
for i in range(N):
  s += 1/i
print(1/s)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())
c = 0.0
for i in range(N):
  c += (1 / A[i])
print(1/c)