Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
if n%2==1:
    print(*a[::-2],*a[1::2])
if n%2==0:
    print(*a[::-2],*a[0::2])



Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if n%2==1:
    print(*(a[::-2]+a[1::2]))
if n%2==0:
    print(*(a[::-2]+a[0::2]))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
if n%2==1:
    print(*a[::-2],*a[1::2])
if n%2==0:
    print(*a[::-2],*a[0::2])



Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if n%2==1:
    print(*(a[::-2]+a[1::2]))
if n%2==0:
    print(*(a[::-2]+a[0::2]))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]
if n%2==0:
    for i in range(n):
        if i%2==0:b.append(a[i])
        if i%2==1:b.insert(0,a[i])
if n%2==1:
    for i in range(n):
        if i%2==1:b.append(a[i])
        if i%2==0:b.insert(0,a[i])


print(*b)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if n%2==1:
    print(*(a[::-2]+a[1::2]))
if n%2==0:
    print(*(a[::-2]+a[0::2]))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    if i%2==0:b.append(a[i])
    if i%2==1:b.insert(0,a[i])

if n%2==1:b.reverse()
print(*b)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if n%2==1:
    print(*(a[::-2]+a[1::2]))
if n%2==0:
    print(*(a[::-2]+a[0::2]))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(a[i])
    b.reverse()
print(*b)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if n%2==1:
    print(*(a[::-2]+a[1::2]))
if n%2==0:
    print(*(a[::-2]+a[0::2]))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
s = input()

tmp = []
cnt = 1
s += '-'
for i in range(n):
    if s[i] == s[i + 1]:
        cnt += 1
    else:
        tmp.append(cnt)
        cnt = 1

for i in range(k):
    if len(tmp) == 1:
        break
    elif len(tmp) == 2:
        tmp = [tmp[0] + tmp[1]]
    else:
        tmp = [tmp[0] + tmp[1] + tmp[2]] + tmp[3:]
# print(tmp)

if len(tmp) == 1:
    print(tmp[0] - 1)
else:
    total = 0
    for j in tmp:
        if j > 1:
            total += j - 1
    print(total)


Fixed submission:
from collections import deque


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

tmp = deque()
cnt = 1
s += '-'
for i in range(n):
    if s[i] == s[i + 1]:
        cnt += 1
    else:
        tmp.append(cnt)
        cnt = 1

for i in range(k):
    if len(tmp) == 1:
        break
    elif len(tmp) == 2:
        tmp = [tmp[0] + tmp[1]]
    else:
        hoge = tmp[0] + tmp[1] + tmp[2]
        tmp.popleft()
        tmp.popleft()
        tmp.popleft()
        tmp.appendleft(hoge)

if len(tmp) == 1:
    print(tmp[0] - 1)
else:
    total = 0
    for j in tmp:
        if j > 1:
            total += j - 1
    print(total)
Buggy python submission (verdict: Runtime Error):
from functools import reduce


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

numerator = reduce(lambda a, b: a * b, A)
denominator = 0
for i in range(n):
    denominator += reduce(lambda a, b: a * b, A[:i] + A[i+1:])
print(1.0)


Fixed submission:
from functools import reduce


n = int(input())
A = list(map(int, input().split()))
if n == 1:
    print(A[0])
else:
    numerator = reduce(lambda a, b: a * b, A)
    denominator = 0
    for i in range(n):
        denominator += reduce(lambda a, b: a * b, A[:i] + A[i+1:])
    print(1.0 * numerator / denominator)

Buggy python submission (verdict: Runtime Error):
from functools import reduce


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

numerator = reduce(lambda a, b: a * b, A)
denominator = 0
for i in range(n):
    denominator += reduce(lambda a, b: a * b, A[:i] + A[i+1:])
print(1.0 * numerator / denominator)


Fixed submission:
from functools import reduce


n = int(input())
A = list(map(int, input().split()))
if n == 1:
    print(A[0])
else:
    numerator = reduce(lambda a, b: a * b, A)
    denominator = 0
    for i in range(n):
        denominator += reduce(lambda a, b: a * b, A[:i] + A[i+1:])
    print(1.0 * numerator / denominator)

Buggy python submission (verdict: Runtime Error):
from functools import reduce


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

a = reduce(lambda a, b: a * b, A)
total = 0
for i in range(n):
    total += reduce(lambda a, b: a * b, A[:i] + A[i+1:])
print(1.0 * a / total)

Fixed submission:
from functools import reduce


n = int(input())
A = list(map(int, input().split()))
if n == 1:
    print(A[0])
else:
    numerator = reduce(lambda a, b: a * b, A)
    denominator = 0
    for i in range(n):
        denominator += reduce(lambda a, b: a * b, A[:i] + A[i+1:])
    print(1.0 * numerator / denominator)
Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt = 0
for i in range(1, n + 1):
    if str(i) % 2 == 1:
        cnt += 1
print(cnt)


Fixed submission:
n = int(input())
cnt = 0
for i in range(1, n + 1):
    if len(str(i)) % 2 == 1:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
sorted_p = sorted(p)
cnt = 0
for a, b in p, sorted_p:
    if a != b:
        cnt += 1
if cnt > 2:
    print("NO")
else:
    print("YES")


Fixed submission:
n = int(input())
p = list(map(int, input().split()))
sorted_p = sorted(p)
cnt = 0
for a, b in zip(p, sorted_p):
    if a != b:
        cnt += 1
if cnt > 2:
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Runtime Error):
from collections import Counter


s = input()
c = Counter(s)
if len(c) == 2 and c.most_common(1)[1] == 2:
    print("Yes")
else:
    print("No")


Fixed submission:
from collections import Counter


s = input()
c = Counter(s)
if len(c) == 2 and c.most_common(1)[0][1] == 2:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from math import gcd


def lcm(a, b):
    return a * b // gcd(a, b)


def counter(n, a):
    return n // a


a, b, c, d = map(int, input().split())
l = lcm(c, d)
print(b - a + 1 - (counter(b, c) - counter(a - 1, c) +
                   counter(b, d) - counter(a - 1, d) -
                   (counter(b, l) - counter(a - 1, l))))


Fixed submission:
from fractions import gcd


def lcm(a, b):
    return a * b // gcd(a, b)


def counter(n, a):
    return n // a


a, b, c, d = map(int, input().split())
l = lcm(c, d)
print(b - a + 1 - (counter(b, c) - counter(a - 1, c) +
                   counter(b, d) - counter(a - 1, d) -
                   (counter(b, l) - counter(a - 1, l))))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
s[k - 1] = s[k - 1].lower()
print(s)


Fixed submission:
n, k = map(int, input().split())
s = input()
print(s[:k-1] + s[k - 1].lower() + s[k:])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
vs = list(map(int, input().split()))
cs = list(map(int, input().split()))

ret = - float('inf')
for i in range((2 ** n)):
    total_cost = 0
    total_value = 0
    j = 0
    while i > 0:
        if i & 1:
            total_cost += cs[j]
            total_value += vs[j]
        i >>= 1
        j += 1
    ret = max(ret, total_value - total_cost)
print(ret)


Fixed submission:
n = int(input())
vs = list(map(int, input().split()))
cs = list(map(int, input().split()))

# ret = - float('inf')
# for i in range((2 ** n)):
#     total_cost = 0
#     total_value = 0
#     j = 0
#     while i > 0:
#         if i & 1:
#             total_cost += cs[j]
#             total_value += vs[j]
#         i >>= 1
#         j += 1
#     ret = max(ret, total_value - total_cost)
# print(ret)

x = 0
y = 0
for i in range(n):
    if vs[i] > cs[i]:
        x += vs[i]
        y += cs[i]
print(x - y)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = map(int, input().split())
total = 1
max_value = h[0]
for i in range(1, n):
    if max_value <= h[i]:
        total += 1
    max_value = max(max_value, h[i])
print(total)


Fixed submission:
n = int(input())
h = list(map(int, input().split()))
total = 1
max_value = h[0]
for i in range(1, n):
    if max_value <= h[i]:
        total += 1
    max_value = max(max_value, h[i])
print(total)
Buggy python submission (verdict: Runtime Error):
a, b, c = input()
if a == b == c:
    print("Yes")
else:
    print("No")


Fixed submission:
a, b, c = input().split()
if a == b == c:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
b = input()
a = ''
for i in range(4):
    if b[i] == 'A':
        a += 'T'
    elif b[i] == 'T':
        a += 'A'
    elif b[i] == 'C':
        a += 'G'
    elif b[i] == 'G':
        a += 'C'
print(a)


Fixed submission:
b = input()
a = ''
for i in range(len(b)):
    if b[i] == 'A':
        a += 'T'
    elif b[i] == 'T':
        a += 'A'
    elif b[i] == 'C':
        a += 'G'
    elif b[i] == 'G':
        a += 'C'
print(a)
Buggy python submission (verdict: Runtime Error):
import sys

N = int(input())
b = map(int, input().split())
# 1 1 1 2 2 1 2 3 2


# b = map(int, '1 1 1 2 2 1 2 3 2'.split())
# N = len(b)

steps = []
for i in range(N):
    cands = []
    for j in range(N - i):
        if (j + 1) == b[j]:
            cands.append(j)
    if len(cands) == 0:
        print(-1)
        sys.exit()
    else:
        j = cands[-1]
        steps.append(j + 1)
        b = b[:j] + b[j+1:]
for s in steps[::-1]:
    print(s)


Fixed submission:
import sys

N = int(input())
b = list(map(int, input().split()))
# 1 1 1 2 2 1 2 3 2


# b = map(int, '1 1 1 2 2 1 2 3 2'.split())
# N = len(b)

steps = []
for i in range(N):
    cands = []
    for j in range(N - i):
        if (j + 1) == b[j]:
            cands.append(j)
    if len(cands) == 0:
        print(-1)
        sys.exit()
    else:
        j = cands[-1]
        steps.append(j + 1)
        b = b[:j] + b[j+1:]
for s in steps[::-1]:
    print(s)
Buggy python submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]


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 float('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 + [cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))


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


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 float('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))
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict


n, m = map(int, input().split())
d = defaultdict(int)
for i in range(n):
    tmp = list(map(int, input().split()))
    for a in tmp[1:]:
        d[a] += 1
cnt = 0
for value in range(d.values()):
    if value == n:
        cnt += 1
print(cnt)


Fixed submission:
from collections import defaultdict


n, m = map(int, input().split())
d = defaultdict(int)
for i in range(n):
    tmp = list(map(int, input().split()))
    for a in tmp[1:]:
        d[a] += 1
cnt = 0
for value in d.values():
    if value == n:
        cnt += 1
print(cnt)

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


n, m = map(int, input().split())
d = defaultdict(int)
for i in range(n):
    tmp = map(int, input().split())
    for a in tmp[1:]:
        d[a] += 1
cnt = 0
for value in range(d.values()):
    if value == n:
        cnt += 1
print(cnt)

Fixed submission:
from collections import defaultdict


n, m = map(int, input().split())
d = defaultdict(int)
for i in range(n):
    tmp = list(map(int, input().split()))
    for a in tmp[1:]:
        d[a] += 1
cnt = 0
for value in d.values():
    if value == n:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc113/tasks/abc113_b


def temp(T, x, A):
    return abs(A - (T - 0.006 * x))

N = int(input())
T, A = map(int, input().split())
H = map(int, input().split())

min_diff = temp(T, H[0], A)
answer = 0
for i in range(1, N):
    diff = temp(T, H[i], A)
    if diff < min_diff:
        answer = i
        min_diff = diff
print(answer)


Fixed submission:
# https://atcoder.jp/contests/abc113/tasks/abc113_b


def temp(T, x, A):
    return abs(A - (T - 0.006 * x))

N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

min_diff = temp(T, H[0], A)
answer = 0
for i in range(1, N):
    diff = temp(T, H[i], A)
    if diff < min_diff:
        answer = i
        min_diff = diff
print(answer + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys


n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int, input().split())))

for cx in range(0, 101):
    for cy in range(0, 101):
        for H in range(max(1, xyh[0][2] - 201),
                       max(2, xyh[0][2] + 201)):
            is_valid = True
            for i in range(n):
                x, y, h = xyh[i]
                if max(H - abs(x - cx) - abs(y - cy), 0) != h:
                    is_valid = False
                    break
            if is_valid is True:
                print('{} {} {}'.format(cx, cy, H))
                sys.exit()


Fixed submission:
import sys


n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int, input().split())))
    if xyh[-1][2] >= 1:
        G = xyh[-1]

for cx in range(0, 101):
    for cy in range(0, 101):
        hs = []
        x, y, h = G
        H = h + abs(x - cx) + abs(y - cy)
        H = max(H, 0)
        invalid = False
        for i in range(n):
            x, y, h = xyh[i]
            hh = H - abs(x - cx) - abs(y - cy)
            hh = max(hh, 0)
            if hh != h:
                invalid = True
                break
        if invalid is False:
            print("{} {} {}".format(cx, cy, H))
            sys.exit()
Buggy python submission (verdict: Runtime Error):
from collections import Counter


n = int(input())
vs = list(map(int, input().split()))
a = vs[::2]
b = vs[1::2]

ca = Counter(a)
cb = Counter(b)
if ca.most_common(1)[0][0] != cb.most_common(1)[0][0]:
    print(n - ca.most_common(1)[0][1] - cb.most_common(1)[0][1])
else:
    print(min(
        n - ca.most_common(1)[0][1] - cb.most_common(2)[1][1],
        n - ca.most_common(2)[1][1] - cb.most_common(1)[0][1]
    ))


Fixed submission:
from collections import Counter


n = int(input())
vs = list(map(int, input().split()))
a = vs[::2]
b = vs[1::2]

ca = Counter(a)
cb = Counter(b)
ca[0] = 0
cb[0] = 0
if ca.most_common(1)[0][0] != cb.most_common(1)[0][0]:
    print(n - ca.most_common(1)[0][1] - cb.most_common(1)[0][1])
else:
    print(min(
        n - ca.most_common(1)[0][1] - cb.most_common(2)[1][1],
        n - ca.most_common(2)[1][1] - cb.most_common(1)[0][1]
    ))
    # if len(set(vs)) == 1:
    #     print(n // 2)
    # else:
    #     print(min(
    #         n - ca.most_common(1)[0][1] - cb.most_common(2)[1][1],
    #         n - ca.most_common(2)[1][1] - cb.most_common(1)[0][1]
    #     ))
Buggy python submission (verdict: Runtime Error):

import bisect


n, x = map(int, input().split())
a = list(sorted(map(int, input().split())))
if x == sum(x):
    print(n)
else:
    acc = [0 for i in range(n)]
    acc[0] = a[0]
    for i in range(1, n):
        acc[i] += a[i - 1] + a[i]
    index = bisect.bisect_right(acc, x)
    if index == n:
        print(index - 1)


Fixed submission:
n, x = map(int, input().split())
a = list(sorted(map(int, input().split())))
if x == sum(a):
    print(n)
else:
    acc = 0
    for i in range(n):
        acc += a[i]
        if acc > x:
            break
    if i == n:
        print(n - 1)
    else:
        print(i)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
i = 0
while i < len(s) and s[i] == '1':
    i += 1
if k < i:
    print(1)
else:
    print(s[i])



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

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


Fixed submission:
s = input()
k = int(input())
if len(set(s)) == 1 and s[0] == '1':
    print(1)
else:
    i = 0
    while i < len(s) and s[i] == '1':
        i += 1
    if k <= i:
        print(1)
    else:
        print(s[i])
Buggy python submission (verdict: Runtime Error):
N = int(input())
As = map(int, input().split())
max_diff = - float('inf')
for i in range(N):
    for j in range(i + 1, N):
        max_diff = max(max_diff, abs(As[i] - As[j]))
print(max_diff)


Fixed submission:
N = int(input())
a = sorted(map(int, input().split()))
print(a[-1] - a[0])
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
sorted_x = sorted(x)

if sorted_x[n // 2] == sorted_x[n // 2 - 1]:
    print(' '.join([sorted_x[n // 2] * n]))
else:
    ret = []
    for i in range(n):
        if x[i] >= sorted_x[n // 2]:
            ret.append(sorted_x[n // 2])
        else:
            ret.append(sorted_x[n // 2 - 1])
    print(' '.join(ret))


Fixed submission:
n = int(input())
x = list(map(int, input().split()))
sorted_x = sorted(x)

if sorted_x[n // 2] == sorted_x[n // 2 - 1]:
    ret = [sorted_x[n // 2]] * n
else:
    ret = []
    for i in range(n):
        if x[i] >= sorted_x[n // 2]:
            ret.append(sorted_x[n // 2 - 1])
        else:
            ret.append(sorted_x[n // 2])
for i in ret:
    print(i)
Buggy python submission (verdict: Runtime Error):
a = list(sorted(map(int, input().split())))
if (a[2] - a[0]) % 2 == 0 and (a[2] - a[1]) % 2 == 0:
    print((a[2] - a[0]) // 2 + (a[2] - a[1]) // 2)
elif (a[2] - a[0]) % 2 == 1 and (a[2] - a[1]) % 2 == 1:
    print((a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 1)
else:
    if (a[2] - a[0]) % 2 == 1:
        a[0] += 3
        a[1] += 2
        a[2] += 1
    else:
        a[1] += 3
        a[0] += 2
        a[2] += 1
    a = sorted(a)
    if (a[2] - a[0]) % 2 == 0 and (a[2] - a[1]) % 2 == 0:
        print((a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 3)
    elif (a[2] - a[0]) % 2 == 1 and (a[2] - a[1]) % 2 == 1:
        print((a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 1 + 3)
    else:
        raise


Fixed submission:
a = list(sorted(map(int, input().split())))
if (a[2] - a[0]) % 2 == 0 and (a[2] - a[1]) % 2 == 0:
    print((a[2] - a[0]) // 2 + (a[2] - a[1]) // 2)
elif (a[2] - a[0]) % 2 == 1 and (a[2] - a[1]) % 2 == 1:
    print((a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 1)
else:
    if (a[2] - a[0]) % 2 == 1:
        a[0] += 2
        a[1] += 1
        a[2] += 1
    else:
        a[0] += 1
        a[1] += 2
        a[2] += 1
    a = sorted(a)
    if (a[2] - a[0]) % 2 == 0 and (a[2] - a[1]) % 2 == 0:
        print((a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 2)
    elif (a[2] - a[0]) % 2 == 1 and (a[2] - a[1]) % 2 == 1:
        print((a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 1 + 2)
    else:
        raise
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
print(min(a + c,
          a + d,
          b + c,
          b + d))


Fixed submission:
a, b, c, d = [int(input()) for _ in range(4)]
print(min(a + c,
          a + d,
          b + c,
          b + d))
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

n = int(input())
d = defaultdict()
for _ in range(n):
    s = input()
    d[s] += 1
m = int(input())
for _ in range(m):
    s = input()
    d[s] -= 1

answer = sorted([d[k] for k in d.keys()])[-1]
if answer < 0:
    answer = 0
print(answer)


Fixed submission:
from collections import defaultdict

n = int(input())
d = defaultdict(int)
for _ in range(n):
    s = input()
    d[s] += 1
m = int(input())
for _ in range(m):
    s = input()
    d[s] -= 1

answer = sorted([d[k] for k in d.keys()])[-1]
if answer < 0:
    answer = 0
print(answer)

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

n = int(input())
d = defaultdict()
for _ in range(n):
    s = input()
    d[s] += 1
m = int(input())
for _ in range(m):
    s = input()
    d[s] -= 1

print(sorted([d[k] for k in d.keys()])[-1])


Fixed submission:
from collections import defaultdict

n = int(input())
d = defaultdict(int)
for _ in range(n):
    s = input()
    d[s] += 1
m = int(input())
for _ in range(m):
    s = input()
    d[s] -= 1

answer = sorted([d[k] for k in d.keys()])[-1]
if answer < 0:
    answer = 0
print(answer)
Buggy python submission (verdict: Runtime Error):
n = input()
k = len(n)
c = int(n[0])
if n == c + '9' * (k - 1):
    print(int(n[0]) + 9 * (k - 1))
else:
    print(int(n[0]) + 9 * (k - 1) - 1)


Fixed submission:
n = input()
k = len(n)
c = n[0]
if n == c + '9' * (k - 1):
    print(int(n[0]) + 9 * (k - 1))
else:
    print(int(n[0]) + 9 * (k - 1) - 1)
Buggy python submission (verdict: Runtime Error):
import sys

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

for a in range(-1000, 1001):
    b_1 = m[0][0] - a
    b_2 = m[0][1] - a
    b_3 = m[0][2] - a
    if (m[1][0] - b_1 ==
        m[1][1] - b_2 ==
        m[1][2] - b_3) and \
        (m[2][0] - b_1 ==
         m[2][1] - b_2 ==
         m[2][2] - b_3):
        print('Yes')
        sys.exit()
print('No')


Fixed submission:
# https://atcoder.jp/contests/abc088/tasks/abc088_c

import sys

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

for a in range(-1000, 1001):
    b_1 = m[0][0] - a
    b_2 = m[0][1] - a
    b_3 = m[0][2] - a
    if (m[1][0] - b_1 ==
        m[1][1] - b_2 ==
        m[1][2] - b_3) and \
        (m[2][0] - b_1 ==
         m[2][1] - b_2 ==
         m[2][2] - b_3):
        print('Yes')
        sys.exit()
print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = sorted([int(input()) for _ in range(n)])
cnt = 1
for a, b in zip(cnt[1:], cnt):
    if a > b:
        cnt += 1
print(cnt)


Fixed submission:
N = int(input())
d = set([int(input()) for _ in range(N)])
print(len(d))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(set([int(input) for _ in range(n)]))
if k >= len(a):
    print(0)
else:
    print(k - len(a))

Fixed submission:
# https://atcoder.jp/contests/abc081/tasks/arc086_a

from collections import Counter

n, k = map(int, input().split())
a = list(sorted(map(int, input().split())))
c = Counter(a)
current_k = len(c)
xlst = c.most_common(current_k)[k:]

answer = 0
for x in xlst:
    answer += x[1]

print(answer)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input())
print(min(b, a * n))


Fixed submission:
n, a, b = map(int, input().split())
print(min(b, a * n))