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

Fixed submission:
import math

N, K = map(int, input().split())
K = min(41, K)
A = list(map(int, input().split()))
A.insert(0, 0)

def operation():
  global A, N
  B = [0] * (N+1)
  for i in range(1, N+1):
    left = max(1, math.ceil(i - A[i] - 0.5))
    right = min(N, math.floor(i + A[i] + 0.5))
    B[left] += 1
    if right+1 <= N:
      B[right+1] -= 1
  for i in range(1, N+1):
    B[i] += B[i-1]
  return B


operation()

#print(A)
#print(B)

for _ in range(K):
  A = operation()

print(*A[1:])

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

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N+1)

def operation():
  global A, B, N
  for i in range(1, N+1):
    left = math.ceil(i - A[i] - 0.5)
    right = math.floor(i + A[i] + 0.5)
    if left < 1:
      left = 1
    if right > N:
      right = N
    for j in range(left, right+1):
      B[j] += 1


operation()

#print(A)
#print(B)

for _ in range(K):
  for i in range(1, N+1):
    if A[i] != B[i]:
      A[i] = B[i]
    B[i] = 0
  operation()
  if A == B:
    ans = [N]* N
	print(ans)
    sys.exit()

print(A[1:])

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N+1)

def operation():
  global A, B, N
  for i in range(1, N+1):
     left = math.ceil(i - A[i] - 0.5)
    right = math.floor(i + A[i] + 0.5)
    if left < 1:
      left = 1
    if right > N:
      right = N
    for j in range(left, right+1):
      B[j] += 1


operation()

#print(A)
#print(B)

for _ in range(K):
  for i in range(1, N+1):
    A[i] = B[i]
    B[i] = 0
  operation()

print(A[1:])
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
T.rstrip()
 
if T[:-1] == S:
  print('Yes')
else:
  print('No')

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

if len(T)-len(S) == 1:
  print(Yes)
else:
  print(No)
Problem p02861 (python)

Fixed submission:
import itertools
 
N = int(input())
coord = [list(map(int, input().split())) for _ in range(N)]
dis = 0

for order in itertools.permutations(range(N)):
  for i in range(1, N):
    dis += ((coord[order[i]][0]-coord[order[i-1]][0])**2 + (coord[order[i]][1]-coord[order[i-1]][1])**2)**0.5
 
ave = dis / len(list(itertools.permutations(range(N))))
print(ave)

Buggy submission (verdict: Runtime Error):
import itertools
 
N = int(input)
coord = [list(map(int, input().split())) for _ in range(N)]
dis = 0

for order in itertools.permutation(range(N)):
  for i in range(1, N):
    dis += ((coord[order[i]][0]-coord[order[i-1]][0])**2 + (coord[order[i]][1]-coord[order[i-1]][1])**2)**0.5
 
Ave = dis / N
print(Ave)

Buggy submission (verdict: Runtime Error):
import itertools
 
N = int(input)
coord = [list(map(int, input().split())) for _ in range(N)]
dis = 0

for order in itertools.permutations(range(N)):
  for i in range(1, N):
    dis += ((coord[order[i]][0]-coord[order[i-1]][0])**2 + (coord[order[i]][1]-coord[order[i-1]][1])**2)**0.5
 
Ave = dis / N
print(Ave)

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input)
coords = [list(map(int, input().split())) for i in range(N)]
dis = 0
n = list(range(N))

for order in itertools.permutations(n):
  for i in range(1, N):
    dis += ((coords[order[i]][0]-coords[order[i-1]][0])**2 + (coords[order[i]][1]-coords[order[i-1]][1])**2)**0.5

ave = dis / N
print(ave)

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input)
coords = [list(map(int, input().split())) for i in range(N)]
dis = 0
n = list(range(N))

for order in itertools.permutations(n):
  for i in range(1, N):
    dis += ((coords[order[i]][0]-coords[order[i-1]][0])**2 + (coords[order[i]][1]-coords[order[i-1]][1])**2)**0.5

ave dis / N
print(ave)
Problem p03339 (python)

Fixed submission:
N = int(input())
S = list(input())
W = 0
E = S[1:].count('E')
Turn = []
Turn.append(E)

for i in range(1, N):
  if S[i] == 'E':
    E -= 1
  if S[i-1] == 'W':
    W += 1
  Turn.append(E+W)

print(min(Turn))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
max = N - 1
for i in range(N-1):
  cnt = S[:i].count('W') + S[i+1:].count('E')
  if cnt < min:
    min = cnt
print(min)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
max = N - 1
for i in range(N):
  cnt = S[:i].count('W') + S[i+1:].count('E')
  if cnt < min:
    min = cnt
print(min)
Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]
dh = [-1, 0, 0, 1]
dw = [0, -1, 1, 0]
cnt = 0

for h in range(H):
  for w in range(W):
    # Check only black cell
    if s[h][w] == '.':
      continue
    for k in range(4):
      nh = h + dh[k]
      nw = w + dw[k]
      if nh < 0 or nw < 0 or H <= nh or W <= nw:
        continue
      # ok
      if s[nh][nw] == '#':
        break
    # failed
    else:
      cnt += 1

if cnt == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = [list(input()) i in range(H)]
dh = [-1, 0, 0, 1]
dw = [0, -1, 1, 0]
cnt = 0

for h in range(H):
  for w in range(W):
    # Check only black cell
    if s[h][w] == '.':
      continue
    for k in range(4):
      nh = h + dh[k]
      nw = w + dw[k]
      if nh < 0 or nw < 0 or H <= nh or W <= nw:
        continue
      # ok
      if s[nh][nw] == '#':
        break
    # failed
    else:
      cnt += 1

if cnt == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = [list(input()) i in range(H)]
dh = [-1, 0, 0, 1]
dw = [0, -1, 1, 0]

for h in range(H):
  for w in range(W):
    # Don't check white cell
    if s[h][w] == '.':
      continue
    # check neighbor cell
    for k in range(4):
      nh = h + dh[k]
      nw = w + dw[k]
      if nh < 0 or nw < 0 or H <= nh or W <= nw:
        continue
      # neighbor black is found => ok
      if s[nh][nw] == '#':
        break
    # There is independ black => failed
    else:
      print('No')
      break
  # ok
  else:
    continue
  # failed
  break
# ok
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = [list(input()) i in range(H)]
dh = [-1, 0, 0, 1]
dw = [0, -1, 1, 0]

for h in range(H):
  for w in range(W):
    # Don't check white cell
    if s[h][w] == '.':
      continue
    # check neighbor cell
    for k in range(4):
      nh = h + dh
      nw = w + dw
      if nh < 0 or nw < 0 or H <= nh or W <= nw:
        continue
      # neighbor black is found => ok
      if s[nh][nw] == '#':
        break
    # There is independ black => failed
    else:
      print('No')
      break
  # ok
  else:
    continue
  # failed
  break
# ok
else:
  print('Yes')
Problem p03680 (python)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
i = 0
cnt = 0

while cnt <= N:
  lgt = a[i]
  cnt += 1
  if lgt == 2:
    print(cnt)
    break
  i = lgt - 1
else:
  print(-1)

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

while cnt <= N:
  lgt = a[i]
  cnt += 1
  if lgt == 2:
    print(cnt)
    break
  i = lgt - 1
else:
  print(-1)
Problem p02642 (python)

Fixed submission:
import math

def main():
  N = int(input())
  A = list(map(int, input().split()))
  A.sort()
  MAX = A[-1]
  dp = [True] * MAX
  c = [0] * MAX
  ans = 0

  for a in A:
    i = a - 1
    c[i] += 1

    if((not dp[i]) and c[i] > 1):
      continue

    e = a * 2    
    while e <= MAX:
      dp[e-1] = False
      e += a
      
  for v in A:
    i = v - 1
    if dp[i] and c[i] == 1:
      ans += 1

  print(ans)

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
import math

def main():
  N = int(input())
  A = list(map(int, input().split()))
  MAX = A[-1]
  dp = [True] * MAX
  c = [0] * MAX
  ans = 0

  A.sort()

  for v in A:
    c[v - 1] += 1

    if(not dp[v - 1] and c[v - 1] > 1):
      continue

    e = v * 2    
    while e < MAX:
      dp[e-1] = False
      e += v
      
  for v in A:
    if dp[v - 1] and c[v - 1] == 1:
      ans += 1

  print(ans)

if __name__ == "__main__":
  main()
Problem p02768 (python)

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

def powmod(x, exp, mod):
    if(exp == 1):
        return x % mod

    if(exp % 2 == 1):
        return (x * powmod(x, exp - 1, mod)) % mod

    x = powmod(x, exp / 2, mod)

    return (x * x) % mod

# nCrを計算するが、nもrも巨大なためフェルマーの小定理を利用する
# x = nPr
# y = r!
# x / y ≡ x * y^-1
# p を法とした時、掛けるたびにmodをとった数同士の割り算はうまくいかない
# フェルマーの小定理から
# y^(p-1) ≡ 1
# y * y^(p-2) ≡ 1
# y^(p-2)がyの逆元と同じ振る舞いをするのでy^(p-2)を掛ける
def combination(n, r, mod):
    x = 1
    y = 1

    for i in range(r):
        x *= n - i # n * (n - 1) * (n - 2) * ... * (n - i + 1)
        x %= mod
        y *= i + 1 # r * (r - 1) * (r - 2) * ... * 2 * 1 を逆さまにかけていく
        y %= mod

    return x * powmod(y, mod - 2, mod) % mod


total = powmod(2, n, p) - 1 #1本も花を選ばないパターンは除外する
comb_a = combination(n, a, p)
comb_b = combination(n, b, p)


print((total - comb_a - comb_b) % p)

Buggy submission (verdict: Runtime Error):
n,a,b = list(map(int, input().split()))
m = (10 ** 9) + 7
dp = [-1] * (n+1)
total = 0

for i in range(0, n+1):
    if(i > 0):
        x = i * dp[i - 1]

        if(x <= m):
            dp[i] = x
        else:
            dp[i] = x % m
    else:
        dp[0] = 1

if n > 2:
    for i in range(1, n+1):
        if(i != a and i != b):
            total += int(dp[n] / (dp[i] * dp[n-i]))
    
print(total % m)

Buggy submission (verdict: Runtime Error):
n,a,b = list(map(int, input().split()))
m = (10 ** 9) + 7
dp = [-1] * (n+1)
total = 0

for i in range(0, n+1):
    if(i > 0):
        x = i * dp[i - 1]

        if(x <= m):
            dp[i] = x
        else:
            dp[i] = x % m
    else:
        dp[0] = 1

if n > 2:
    for i in range(1, n+1):
        if(i != a and i != b):
            total += int(dp[n] / (dp[i] * dp[n-i]))
            total = total % m
    
print(total)

Buggy submission (verdict: Runtime Error):
n,a,b = list(map(int, input().split()))
m = (10 ** 9) + 7
dp = [-1] * (n+1)
total = 0

for i in range(0, n+1):
    if(i > 0):
        x = i * dp[i - 1]

        if(x <= m):
            dp[i] = x
        else:
            dp[i] = x % m
    else:
        dp[0] = 1

if n > 2:
    for i in range(1, n+1):
        if(i != a and i != b):
            total += int(dp[n] / (dp[i] * dp[n-i]))


print(total)

Buggy submission (verdict: Runtime Error):
n,a,b = list(map(int, input().split()))
divisor = 10 ** 9 + 7

dp = [-1] * (n+1)
total = 0

for i in range(0, n+1):
    if(i > 0):
        dp[i] = (i * dp[i - 1]) % divisor
    else:
        dp[0] = 1

def factorial(n):
    return dp[n]

if n > 2:
    for i in range(1, n+1):
        if(i != a and i != b):
            total += dp[n] // (dp[i] * dp[n-i])

else:
    print(0)
    

print(total)
Problem p02813 (python)

Fixed submission:
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

patterns = list(itertools.permutations(list(range(1,N+1))))

pi = 0
qi = 0

for index, pattern in enumerate(patterns):
  if P == pattern:
    pi = index
  if Q == pattern:
    qi = index

print(abs(pi - qi))

Buggy submission (verdict: Runtime Error):

def dfs(node, paths, visited, n):
  # 全て訪問済みだったら全部を訪問できる経路として1を返す
  if not False in visited:
    return 1

  count = 0

  for nn in paths[node]:
    # 既に訪問済みなら処理をしない
    if(visited[nn]):
      continue

    visited[nn] = True
    count += dfs(nn, paths, visited, n)
    visited[nn] = False

  return count

def main():
  N, M = list(map(int, input().split()))
  paths = [[] for i in range(N)]
  visited = [False] * N

  for i in range(M):
    a, b = list(map(int, input().split()))
    paths[a-1].append(b-1)
    paths[b-1].append(a-1)

  visited[0] = True
  print(dfs(0, paths, visited, N))


if __name__ == "__main__":
    main()
Problem p02993 (python)

Fixed submission:
s=str(input())
c=0
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        c+=1
if c:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[]
r=[]
for i in range(n):
    a,b=map(int,input().split())
    r.append(a)
    l.append(b)
m=max(l)
s=sum(r)
if s<m:
    print("Yes")
else:
    print("No")
Problem p02630 (python)

Fixed submission:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
q = int(input())
cnt_A = dict(Counter(A))
ans = sum(A)
for i in range(q):
    b, c = map(int, input().split())
    if b in cnt_A and cnt_A[b] > 0:
        count = cnt_A[b]
        cnt_A[b] = 0
        if c not in cnt_A:
            cnt_A[c] = count
        else:
            cnt_A[c] += count
        ans += ((c - b) * count)
    print(ans)

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

n = int(input())
A = list(map(int, input().split()))
q = int(input())
cnt_A = dict(Counter(A))
for i in range(q):
    ans = 0
    b, c = map(int, input().split())
    if cnt_A[b] > 0:
        m = cnt_A[b]
        cnt_A[b] = 0
        if c not in cnt_A:
            cnt_A[c] = m
        else:
            cnt_A[c] += m
    ans = sum([k * v for k, v in cnt_A.items()])
    print(ans)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
if n > 0:
    P = list(map(int, input().split()))
else:
    P = []

ans, dist = 0, 1000
for i in range(-200, 200):
    if i not in P:
        if abs(i - x) < dist:
            dist = abs(i - x)
            ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n > 0:
    P = list(map(int, input().split()))
    Q = sorted(
        [[i, abs(i - x)] for i in range(1, 101) if i not in P],
        key=lambda x:x[0])
    Q.sort(key=lambda x:x[1])
    print(Q[0][0])
else:
    print(x)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n > 0:
    P = list(map(int, input().split()))
    Q = sorted(
        [[i, abs(i - x)] for i in range(1, 101) if i not in P],
        key=lambda x:x[1])
    print(Q[0][0])
else:
    print(x)
Problem p02664 (python)

Fixed submission:
T = input()
print(T.replace("?", "D"))

Buggy submission (verdict: Runtime Error):
T = input()
n = T.count("?")

S = T.replace("?", "D")
count1 = S.count("D") + S.count("PD")

for i, v in enumerate(T):
    if v == "?":
        if i == 0:
            if T[i + 1] == "D":
                T = T.replace("?", "P", 1)
            else:
                T = T.replace("?", "D", 1)
        else:
            if T[i - 1] == "P":
                T = T.replace("?", "D", 1)
            else:
                T = T.replace("?", "P", 1)

count2 = T.count("D") + T.count("PD")

print(T if count1 < count2 else S)
Problem p02732 (python)

Fixed submission:
import math
import collections

n = int(input())
A = list(map(int, input().split()))

equal = 0
elements = collections.Counter(A)
equal = sum([v * (v - 1) // 2 for v in elements.values()])

for i in range(n):
    equal_i = elements[A[i]] - 1
    print(equal - equal_i)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
A = list(map(int, input().split()))

equal = 0
elements = set(A)
for e in elements:
    tmp = A.count(e)
    equal += math.factorial(tmp) // (2 * math.factorial(tmp - 2))

for i in range(n):
    A_tmp = A[: i] + A[i + 1: ]
    equal_i = A_tmp.count(A[i])
    print(equal - equal_i)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))

C = list(itertools.combinations(A, 2))
C = list(c for c in C if c[0] == c[1])
equal = len(C)

for i in range(n):
    A_tmp = A[: i] + A[i + 1: ]
    equal_i = A_tmp.count(A[i])
    print(equal - equal_i)
Problem p02756 (python)

Fixed submission:
s = input()
q = int(input())
count = 0
top = ""
end = ""
ans = s
for i in range(q):
    tmp = input()
    if tmp[0] == "1":
        count += 1
    else:
        _, f, c = map(str, tmp.split())
        if count % 2 == 0:
            if f == "1":
                top = c + top
            else:
                end = end + c
        else:
            if f == "1":
                end = end + c
            else:
                top = c + top

ans = top + ans + end
ans = ans[::-1] if count % 2 == 1 else ans
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())
count = 0
top = ""
end = ""
ans = s
for i in range(q):
    tmp = input()
        count += 1
    else:
        _, f, c = map(str, tmp.split())
        if (count % 2 == 0 and f == "1") or (count % 2 == 1 and f == "2"):
            top = c + top
        else:
            end = end + c

ans = top + ans + end
ans = ans[::-1] if count % 2 == 1 else ans
print(ans)
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]
ans = -1
for i in range(10 ** n):
    tmp = str(i)
    if len(tmp) == n:
        flg = True
        for l in lst:
            if tmp[l[0] - 1] != str(l[1]):
                flg = False
                break
        if flg == True:
            ans = i
            break
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]

ans = -1
for i in range(10 ** (n - 1) - 1, 10 ** n):
    tmp = str(i)
    flg = False
    for l in lst:
        if tmp[l[0] - 1] == str(l[1]):
            flg = True
            break
    if flg == True:
        ans = i
        break

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import os
f = open("input.txt", "r")
sys.stdin = f

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

for i in range(m):
    for j in range(m):
        if i != j and lst[i][0] == lst[j][0] and lst[i][1] != lst[j][1]:
            print(-1)
            exit()

ans = "0" * n
for l in lst:
    if l[0] == 1 and l[1] == 0:
        print(-1)
        exit()
    ans = ans[: l[0] - 1] + str(l[1]) + ans[l[0]: ]

if ans[0] == "0":
    ans = "1" + ans[1: ]

print(ans)
Problem p02802 (python)

Fixed submission:
n, m = map(int, input().split())
WA = [0] * n
AC = [0] * n

for i in range(m):
    p, s = map(str, input().split())
    p = int(p) - 1
    if s == "AC":
        AC[p] = 1
    elif s == "WA" and AC[p] == 0:
        WA[p] += 1

for i in range(n):
    WA[i] = 0 if AC[i] == 0 else WA[i]

print(sum(AC), sum(WA))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
WA = [0] * n
AC = [0] * n

for i in range(m):
    p, s = map(str, input().split())
    p = int(p) - 1
    if s == "AC":
        AC[p] = 1
    elif s == "WA" and AC[p] == 0:
        WA[p] += 1

WA = [WA[i] for i in range(m) if AC[i] >= 1]

print(sum(AC), sum(WA))
Problem p02995 (python)

Fixed submission:
import fractions

a, b, c, d = map(int, input().split())

a -= 1
lcm = (c * d) // fractions.gcd(c, d)

divisible_c = (b // c) - (a // c)
divisible_d = (b // d) - (a // d)
divisible_cd = (b // lcm) - (a // lcm)

print((b - a) - (divisible_c + divisible_d - divisible_cd))

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

a -= 1
lcm = (c * d) // math.gcd(c, d)

divisible_c = (b // c) - (a // c)
divisible_d = (b // d) - (a // d)
divisible_cd = (b // lcm) - (a // lcm)

print((b - a) - (divisible_c + divisible_d - divisible_cd))
Problem p03000 (python)

Fixed submission:
import numpy as np

n, x = map(int, input().split())
L = list(map(int, input().split()))

CS_L = np.cumsum(L).tolist()
ans = len([l for l in CS_L if l <= x])
print(ans + 1)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
L = list(map(int, input().split()))

d, i = 0, 0
while d < x:
    d += L[i]
    i += 1

print(i)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
L = list(map(int, input().split()))

d, i = 0, 0
while d <= x:
    d += L[i]
    i += 1

print(i)

Buggy submission (verdict: Runtime Error):
d, i = 0, 0
while d <= x:
    d += L[i]
    i += 1

print(i)
Problem p03625 (python)

Fixed submission:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))

C = Counter(A)
C = [[k, v] for k, v in C.items() if v >= 2]
C.sort(key=lambda x:x[0], reverse=True)

ans = 0
if len(C) >= 1:
    if C[0][1] >= 4:
        ans = C[0][0] * C[0][0]
    elif len(C) >= 2:
        ans = C[0][0] * C[1][0]

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))

C = Counter(A)
C = [[k, v] for k, v in C.items() if v >= 2]
C.sort(key=lambda x:x[0], reverse=True)

ans = 0
if len(C) >= 1:
    if C[0][1] >= 4:
        ans = C[0][0] * C[0][0]
    elif len(C) >= 2:
        ans = C[0][0] * C[1][0]

print(ans)
Problem p03695 (python)

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

rate = set()
free = 0
for a in A:
    if a < 3200:
        rate.add(a // 400)
    else:
        free += 1

if len(rate) == 0:
    color_min, color_max = 1, n
else:
    color_min, color_max = len(rate), len(rate) + free

print(color_min, color_max)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = map(int, input().split())
rate = [0] * 9
for a in A:
    rate[a // 400] += 1
color_min = 8 - rate[:-1].count(0)
color_max = color_min + (min(rate[-1], rate[:-1].count(0)) if rate[-1] > 0 else 0)
print(color_min, color_max)
Problem p02641 (python)

Fixed submission:
from bisect import bisect_left as bl
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    i = 0
    p.sort()
    a = bl(p, x)
    if a == n:
        print(x)
    elif p[a] != x:
        print(x)
    else:
        while(True):
            i += 1
            if p[bl(p, x-i)] != x-i:
                print(x-i)
                break
            else:
                a = bl(p, x+i)
                if a == n:
                    print(x+i)
                    break
                elif p[a] != x+i:
                    print(x+i)
                    break

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left as bl
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    i = 0
    p.sort()
    a = bl(p, x)
    if a == n:
        print(x)
    elif p[a] != x:
        print(x)
    else:
        while(True):
            i += 1
            if p[bl(p, x-i)] != x-i:
                print(x-i)
                break
            elif p[bl(p, x+i)] != x+i:
                print(x+i)
                break

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left as bl
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    i = 0
    p.sort()
    if p[bl(p, x)] != x:
        print(x)
    else:
        while(True):
            i += 1
            if p[bl(p, x-i)] != x-i:
                print(x-i)
                break
            elif p[bl(p, x+i)] != x+i:
                print(x+i)
                break
Problem p02717 (python)

Fixed submission:
a,b,c = map(int, input().split())
print(str(c)+' '+str(a)+' '+str(b))

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
print(f'{c} {a} {b}')

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
print(f'{c} {a} {b}')
Problem p02730 (python)

Fixed submission:
s = input()
def is_kaibun(s):
  for i in range(len(s)//2):
    if s[i] != s[-i-1]:
      return False
  return True
n = len(s)
s1 = s[:(n-1)//2]
s2 = s[(n+1)//2:]
if is_kaibun(s) & is_kaibun(s1) & is_kaibun(s2):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = input()
def is_kaibun(s):
  for i in range(len(s)//2):
    if s[i] != s[-i-1]:
      return False
  return True
n = len(s)
s1 = s[:(n-1)/2]
s2 = s[(n+1)/2:]
if is_kaibun(s) & is_kaibun(s1) & is_kaibun(s2):
  print('Yes')
else:
  print('No')
Problem p03478 (python)

Fixed submission:
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
  if a <= sum(list(map(int, list(str(i))))) <= b:
    ans += i
print(ans)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
for i in range(n+1):
  if a <= sum(list(map(int, list(str(i))))) <= b:
    ans += 1
print(ans)