Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = input()
n = int(s)

m = str(int(s[0]) - 1) + (len(s) - 1) * "9" 
ans1 = 0
for i in range(len(m)):
    ans1 += int(m[i])

if s[-1] != "9":
    n1 = n - (int(s[-1]) + 1)
    s = str(n1)

ans2 = 0
for i in range(len(s)):
    ans2 += int(s[i])

print(max(ans1, ans2))


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

m = str(int(s[0]) - 1) + (len(s) - 1) * "9" 
ans1 = 0
for i in range(len(m)):
    ans1 += int(m[i])

if s[-1] != "9" and n >= 10:
    n1 = n - (int(s[-1]) + 1)
    s = str(n1)

ans2 = 0
for i in range(len(s)):
    ans2 += int(s[i])

print(max(ans1, ans2))

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

m = str(int(s[0]) - 1) + (len(s) - 1) * "9" 
ans1 = 0
for i in range(len(m)):
    ans1 += int(m[i])

if s[-1] != "9":
    n = n - (int(s[-1]) + 1)
    s = str(n)

ans2 = 0
for i in range(len(s)):
    ans2 += int(s[i])

print(max(ans1, ans2))

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

m = str(int(s[0]) - 1) + (len(s) - 1) * "9" 
ans1 = 0
for i in range(len(m)):
    ans1 += int(m[i])

if s[-1] != "9" and n >= 10:
    n1 = n - (int(s[-1]) + 1)
    s = str(n1)

ans2 = 0
for i in range(len(s)):
    ans2 += int(s[i])

print(max(ans1, ans2))

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

m = str(int(s[0]) - 1) + (len(s) - 1) * "9" 
ans1 = 0
for i in range(len(m)):
    ans1 += int(m[i])

if s[-1] != "9":
    n -= int(s[-1]) +1
    s = str(n)

ans2 = 0
for i in range(len(s)):
    ans2 += int(s[i])

print(max(ans1, ans2))


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

m = str(int(s[0]) - 1) + (len(s) - 1) * "9" 
ans1 = 0
for i in range(len(m)):
    ans1 += int(m[i])

if s[-1] != "9" and n >= 10:
    n1 = n - (int(s[-1]) + 1)
    s = str(n1)

ans2 = 0
for i in range(len(s)):
    ans2 += int(s[i])

print(max(ans1, ans2))

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

if s[-1] != "9":
    n1 = n - int(s[-1]) +1
    s1 = str(n1)

ans1 = 0
for i in range(len(s1)):
    ans1 += int(s[i])

m = str(int(s[0]) - 1) + (len(s) - 1) * "9" 
ans2 = 0
for i in range(len(m)):
    ans2 += int(m[i])

print(max(ans1, ans2))

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

m = str(int(s[0]) - 1) + (len(s) - 1) * "9" 
ans1 = 0
for i in range(len(m)):
    ans1 += int(m[i])

if s[-1] != "9" and n >= 10:
    n1 = n - (int(s[-1]) + 1)
    s = str(n1)

ans2 = 0
for i in range(len(s)):
    ans2 += int(s[i])

print(max(ans1, ans2))
Buggy python submission (verdict: Runtime Error):
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))

c = c1 + c2 + c3

if sum(c) % 3 == 0 and c[0] + c[4] + c[8] == c[1] + c[3] + c[8]:
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())
A = int(input())

if N % 500 <= A:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)


for i in range(N - 1):
    time = S[i] + C[i]
    for j in range(i+1, N-1):
        cnt = 0
        while time > S[j] + F[j] * cnt:
            cnt += 1

        time = S[j] + F[j] * cnt + C[j]
    
    print(time)

print(0)

Fixed submission:
N = int(input())

C = []; S = []; F = []
for i in range(N-1):
    c, s, f = map(int, input().split())
    C.append(c); S.append(s); F.append(f)

for i in range(N):
    t = 0
    for j in range(i, N-1):
        if t <= S[j]:
            t = S[j]
        elif t % F[j] == 0:
            pass
        elif t % F[j] !=0:
            t += F[j] - (t%F[j])
        t += C[j]
    print(t)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

b = list(set(a))
m = len(b)

ans = 0
for i in range(m):
    c = a.count(b[i])
    if b[i] > c: ans += c
    if b[i] < c: ans += c - b[i]

print(ans) 


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

b = [0 for _ in range(n+1)]

ans = 0
for i in range(n):
    if a[i] > n:
        ans += 1
    else:
        b[a[i]] += 1 

for i in range(n+1):
    if b[i] > i: ans += b[i] - i
    if b[i] < i: ans += b[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

b = list(set(a))
m = len(b)

ans = 0
for i in range(m):
    c = a.count(b[i])
    if b[i] > c: ans += c
    if b[i] < c: ans += c - b[i]

print(ans) 


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

b = [0 for _ in range(n+1)]

ans = 0
for i in range(n):
    if a[i] > n:
        ans += 1
    else:
        b[a[i]] += 1 

for i in range(n+1):
    if b[i] > i: ans += b[i] - i
    if b[i] < i: ans += b[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

dic = {}
for num in a:
    if num not in dic.keys():
        dic[num] = 0
    dic[num] += 1

dic = sorted(dic.items(), key=lambda x:x[1])

ans = 0

for i in range(len(dic)- k):
    ans += dic[i][1]

print(ans)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))

b = [0] * n
for i in range(n):
    b[a[i] - 1] += 1

b.sort(reverse=True)

ans = 0

for i in range(k):
    ans +=b[i] 

if n - ans <= 0:
    print(0)
else:
    print(n - ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
t = ["A", "K", "I", "H", "A", "B", "A", "R", "A"]


if s[-1] != "A":
    s = s + ["A"]
for i in range(len(t)):
    if t[i] != s[i] and t[i] != "A":
        break
    if t[i] != s[i] and t[i] == "A":
        s.insert(i, "A")

if s == t:
    print("YES")
else:
    print("NO")

Fixed submission:
s = list(input())
t = ["A", "K", "I", "H", "A", "B", "A", "R", "A"]


if s[-1] != "A":
    s = s + ["A"]
for i in range(len(t)):
    if len(s) <= i: break
    if t[i] != s[i] and t[i] != "A":
        break
    if t[i] != s[i] and t[i] == "A":
        s.insert(i, "A")

if s == t:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
s = list(input())
t = ["A", "K", "I", "H", "A", "B", "A", "R", "A"]

if s == t:
    print("YES")
    exit()

if len(s) >= len(t):
    print("NO")
    exit()
    
if s[-1] != "A":
    s = s + ["A"]
for i in range(len(t)):
    if t[i] != s[i] and t[i] == "A":
        s.insert(i, "A")
        print(s)
if s == t:
    print("YES")
else:
    print("NO")

Fixed submission:
s = list(input())
t = ["A", "K", "I", "H", "A", "B", "A", "R", "A"]


if s[-1] != "A":
    s = s + ["A"]
for i in range(len(t)):
    if len(s) <= i: break
    if t[i] != s[i] and t[i] != "A":
        break
    if t[i] != s[i] and t[i] == "A":
        s.insert(i, "A")

if s == t:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
s = list(input())
t = ["A", "K", "I", "H", "A", "B", "A", "R", "A"]

if s[-1] != "A":
    s = s + ["A"]
for i in range(len(t)):
    if t[i] != s[i] and t[i] == "A":
        s.insert(i, "A")

if s == t:
    print("YES")
else:
    print("NO")

Fixed submission:
s = list(input())
t = ["A", "K", "I", "H", "A", "B", "A", "R", "A"]


if s[-1] != "A":
    s = s + ["A"]
for i in range(len(t)):
    if len(s) <= i: break
    if t[i] != s[i] and t[i] != "A":
        break
    if t[i] != s[i] and t[i] == "A":
        s.insert(i, "A")

if s == t:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
a, b, c, d, e, f = map(int, input().split())

w = {0}
s = {0}

for i in range(f+1):
    for j in range(f+1):
        x = 100 * (a * i + b * j)
        if x <= f:
            w.add(x)

for i in range(f+1):
    for j in range(f+1):
        y = c * i + d * j
        if y <= f:
            s.add(y)

s_list = list(s)
s_list.sort()
w_list = list(w)
w_list.sort()


c_ans = 0
s_ans = 0
w_ans = 0

for i in range(1, len(w_list)):
    for j in range(1, len(s_list)):
        z = int(100 * s_list[j] / (s_list[j] + w_list[i]))
        sum = w_list[i] + s_list[j]
        if z <= int(100 * e / (e + 100)) and z > c_ans and sum <= f:
            c_ans = z
            w_ans = w_list[i]
            s_ans = s_list[j]

print(str(w_ans + s_ans) + " " + str(s_ans))

Fixed submission:
N = int(input())
A = int(input())

print(N ** 2 -A)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

dic = {}
for i in range(n):
    m = int(input())
    if m not in dic.keys():
        dic[m] = 0
    dic[m] += 1

dic_list = list(dic.values())
ans = 0
for i in range(len(dic_list)):
    if dic_list[i] % 2 == 1:
        ans += 1

print(ans)


Fixed submission:
import collections

n = int(input())
a = list()

for i in range(n):
    a.append(int(input()))

dic = collections.Counter(a)
    
dic_list = list(dic.values())
ans = 0
for i in range(len(dic_list)):
    if dic_list[i] % 2 == 1:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

PS = [[Q * 4, 0.25], [H * 2, 0.5], [S, 1], [D / 2, 2]]

PS.sort(key=lambda x: x[0])

# print(PS)

R = N
ans = 0
for i in range (4):
    if R == 0:
        break
    elif R >= PS[i][1]:
        ans += PS[i][0] * PS[i][1] * (R // PS[i][1])
        R = R % PS[i][1]
    # print("ans :", ans)

print(int(ans))

Fixed submission:
Q, H, S, D = map(int, input().split())
N = int(input())

PS = [[Q * 8, 0.25], [H * 4, 0.5], [S * 2, 1], [D, 2]]

PS.sort(key=lambda x: x[0])


R = N
ans = 0
for i in range (4):
    if R == 0:
        break
    elif R >= PS[i][1]:
        ans += int(PS[i][0] * PS[i][1] // 2 * (R // PS[i][1]))
        R = R % PS[i][1]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = [int(x) for x in input().split()]

d = {}
for i in range(N):
    if A[i] not in d:
        d[A[i]] = 0
    d[A[i]] += 1


ans = 0
for k in d:
    if d[k] >= 4:
        ans = max(ans, k ** 2)
    
    if d[k] >= 2:
        for l in d:
            if k == l: continue
            elif d[l] >= 2:
                ans = max(ans, k * l)

print(ans) 

Fixed submission:
N = int(input())

A = [int(x) for x in input().split()]

d = {}
for i in range(N):
    if A[i] not in d:
        d[A[i]] = 0
    d[A[i]] += 1


ans = {0}
s1 = [k for k, v in d.items() if v >= 4]
if len(s1) > 0:
    s1.sort()
    ans.add(s1[-1] ** 2)

s2 = [k for k, v in d.items() if v >= 2]
if len(s2) >= 2:
    s2.sort()
    ans.add(s2[-1] * s2[-2])

print(max(ans))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
if max(a) < k:
    print("IMPOSSIBLE")
    exit()

for i in range(n-1):
    if k == a[i]:
        print("POSSIBLE")
        break
    if k % (a[i+1] - a[i]) == 0:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))

a = [0] + a
a.sort()
if max(a) < k:
    print("IMPOSSIBLE")
    exit()

for i in range(len(a) - 1):
    if k == a[i]:
        print("POSSIBLE")
        break
    if a[i+1] - a[i] == 0: continue 
    if k % (a[i+1] - a[i]) == 0:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

even_is_negative = 0
odd_is_nagative = 0

for i in range(n):
    if i % 2 == 0 and a[i] < 0:
        even_is_negative += 1
    elif i % 2 == 1 and a[i] < 0:
        odd_is_nagative += 1

# print(even_is_negative)
# print(odd_is_nagative)

sum = a[0]
change = 0

if even_is_negative >= odd_is_nagative:
    for i in range(1, n):
        if i % 2 == 1 and sum + a[i] <= 0:
            change += abs(sum + a[i]) + 1
            sum = 1
            # print("a " + str(sum))
        elif i % 2 == 0 and sum + a[i] >= 0:
            change += sum + abs(a[i]) + 1
            sum = -1
            # print("b " + str(sum))
        else:
            sum += a[i]
            # print("c " + str(sum))

if even_is_negative < odd_is_nagative:
    for i in range(1, n):
        if i % 2 == 1 and sum + a[i] >= 0:
            change += sum + abs(a[i]) + 1
            sum = -1
            # print("a " + str(sum) + str(change))
        elif i % 2 == 0 and sum + a[i] <= 0:
            change += abs(sum + a[i]) + 1
            sum = 1
            # print("b " + str(sum)+ str(change))
        else:
            sum += a[i]
            # print("c " + str(sum)+ str(change))

if sum == 0:
    print(change + 1)
else:
    print(change)
             

Fixed submission:
s = input().split()
a = ""

for i in range(len(s)):
    str = s[i][0]
    a += str.upper()

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

si, sj = 0, 0


while si < m:
    ni, nj = si, sj
    rest = m ** 2
    for i in range(m):
        nj = sj
        for j in range(m):
            # print(ni, nj, i, j)
            if a[ni][nj] != b[i][j]:
                break
            nj +=1
            rest -= 1
        ni += 1
    if rest == 0:
        print("Yes")
        exit()
    sj += 1
    if sj > n - m:
        si += 1
        sj = 0

print("No")
    

Fixed submission:
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]

si, sj = 0, 0
c = 0
while si <= n - m:
    ni, nj = si, sj
    rest = m ** 2
    for i in range(m):
        nj = sj
        for j in range(m):
            # print(ni, nj, i, j)
            if a[ni][nj] != b[i][j]:
                break
            nj +=1
            rest -= 1
        ni += 1
        # print()
    if rest == 0:
        print("Yes")
        exit()
    sj += 1
    if sj > n - m:
        si += 1
        sj = 0

print("No")

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

for nj in range(0, n - m):
    for ni in range(0, n - m):
        for i in range(m):
            for j in range(m):
                if a[nj][ni] == b[m-1][m-1]:
                    print("Yes")
                    exit()
                if a[nj][ni] != b[j][i]:
                    break
                nj += 1
            ni += 1

print("No")
    

Fixed submission:
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]

si, sj = 0, 0
c = 0
while si <= n - m:
    ni, nj = si, sj
    rest = m ** 2
    for i in range(m):
        nj = sj
        for j in range(m):
            # print(ni, nj, i, j)
            if a[ni][nj] != b[i][j]:
                break
            nj +=1
            rest -= 1
        ni += 1
        # print()
    if rest == 0:
        print("Yes")
        exit()
    sj += 1
    if sj > n - m:
        si += 1
        sj = 0

print("No")
Buggy python submission (verdict: Runtime Error):
K, S = map(int, input().split())


ans = 0
for x in range(K+1):
    for y in range(K+1):
       z = S - x - y
       if z >= 0 and z <= K:
           ans += 1

print(ans)

Fixed submission:
s = input()

print(s.replace(",", " "))

Buggy python submission (verdict: Runtime Error):
K, S = map(int, input().split())

ans = 0
for i in range(K+1):
    for j in range(K+1):
        for l in range(K+1):
            if i + j + l == S:
                ans += 1


print(ans)

Fixed submission:
s = input()

print(s.replace(",", " "))
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

ans = 0
for i in range(K+1):
    for j in range(K+1):
        for l in range(K+1):
            if i + j + l == S:
                ans += 1


print(ans)

Fixed submission:
K, S = map(int, input().split())


ans = 0
for x in range(K+1):
    for y in range(K+1):
       z = S - x - y
       if z >= 0 and z <= K:
           ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = []
m = 0
for i in range(1, n):
    if m >= n: break
    a.append(i)
    m += i

if m == n:
    print(*a)
else:
    a.remove(m-n)
    print(*a)

Fixed submission:
n = int(input())

a = []
m = 0
for i in range(n):
    if m >= n: break
    a.append(i+1)
    m += i+1
    
if m == n:
    print(*a)
else:
    a.remove(m-n)
    print(*a)

Buggy python submission (verdict: Runtime Error):
n = int(input())

a = []
m = 0
for i in range(1, n):
    if m >= n: break
    a.append(i)
    m += i

if m == n:
    print(*a)
else:
    a.pop(m-n)
    print(*a)


Fixed submission:
n = int(input())

a = []
m = 0
for i in range(n):
    if m >= n: break
    a.append(i+1)
    m += i+1
    
if m == n:
    print(*a)
else:
    a.remove(m-n)
    print(*a)

Buggy python submission (verdict: Runtime Error):
n = int(input())

if n == 1 or n == 2:
    print(n)
else:
    a = []
    m = 0
    for i in range(1, n):
        if m > n: break
        a.append(i)
        m += i


    b = []
    for i in range(len(a) ** 2):
        g = []
        for j in range(len(a)):
            if ((i >> j) & 1):
                g.append(a[j])
        if sum(g) == n:
            b.append([g[-1], g])

    b.sort()
    for item in b[0][1]:
        print(item)            



Fixed submission:
n = int(input())

a = []
m = 0
for i in range(n):
    if m >= n: break
    a.append(i+1)
    m += i+1
    
if m == n:
    print(*a)
else:
    a.remove(m-n)
    print(*a)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

dy = [0, 1]
dx = [1, 0]

stack = [[0 for _ in range(w)] for _ in range(h)]

def dfs(y, x):
    stack[y][x] = 1
    if x == w-1 and y == h-1:
        return
    for i in range(2):
        ny = y + dy[i]
        nx = x + dx[i] 
        if ny < 0 or ny >= h or nx < 0 or nx >= w:
            continue
        if a[ny][nx] == "#":
            dfs(ny, nx)
            break
    return

dfs(0, 0)
for i in range(h):
    for j in range(w):
        if a[i][j] == "#" and stack[i][j] == 0:
            print('Impossible')
                exit()
    print('Possible')

Fixed submission:
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

dy = [0, 1]
dx = [1, 0]

stack = [[0 for _ in range(w)] for _ in range(h)]

def dfs(y, x):
    stack[y][x] = 1
    if x == w-1 and y == h-1:
        return
    for i in range(2):
        ny = y + dy[i]
        nx = x + dx[i] 
        if ny < 0 or ny >= h or nx < 0 or nx >= w:
            continue
        if a[ny][nx] == "#":
            dfs(ny, nx)
            break
    return

dfs(0, 0)
for i in range(h):
    for j in range(w):
        if a[i][j] == "#" and stack[i][j] == 0:
            print('Impossible')
            exit()
print('Possible')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]

#print()
T = 0
A = 0
for i in range(n):
    t, a = p[i]
    if t >= T and a >= A:
        T, A = t, a
    else:
        c = 1
        while  t * c < T or a * c < A:
            c += 1
            # print(t * c, a * c)
        T, A = t * c, a * c
    # print(T, A)

print(T+A)  


Fixed submission:
n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]

#print()
T = 0
A = 0
for i in range(n):
    t, a = p[i]
    if t >= T and a >= A:
        T, A = t, a
    else:
        d1 = T // t
        d2 = A // a
        if T % t != 0: d1 += 1
        if A % a != 0: d2 += 1
        d = max(d1, d2)
        T, A = d * t, d * a
    #print(T, A)

print(T+A)
Buggy python submission (verdict: Runtime Error):
k = int(input())
ans = 0
if k % 7 == 0:
    L = (9 * k) / 7
else:
    L = 9 * k
if L % 2 == 0 or L % 5 == 0:
    print(-1)
else:
    a = 1 % L
    for i in range(L):
        if (a * 10) % L == 1:
            ans = i + 1
            print(ans)
            break
        a = (a * 10) % L
    

Fixed submission:
k = int(input())
ans = 0
if k % 7 == 0:
    L = int((9 * k) / 7)
else:
    L = 9 * k
if L % 2 == 0 or L % 5 == 0:
    print(-1)
else:
    a = 1 % L
    for i in range(L):
        if (a * 10) % L == 1:
            ans = i + 1
            print(ans)
            break
        a = (a * 10) % L
    if ans == 0:
        print(-1)

Buggy python submission (verdict: Runtime Error):
k = int(input())
ans = 0
if k % 7 == 0:
    L = (9 * k) / 7
else:
    L = 9 * k
if L % 2 == 0 or L % 5 == 0:
    print(-1)
else:
    a = 1 % L
    for i in range(L):
        if (a * 10) % L == 1:
            ans = i + 1
            print(ans)
            break
        a = (a * 10) % L
    if ans == 0:
        print(-1)

Fixed submission:
k = int(input())
ans = 0
if k % 7 == 0:
    L = int((9 * k) / 7)
else:
    L = 9 * k
if L % 2 == 0 or L % 5 == 0:
    print(-1)
else:
    a = 1 % L
    for i in range(L):
        if (a * 10) % L == 1:
            ans = i + 1
            print(ans)
            break
        a = (a * 10) % L
    if ans == 0:
        print(-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
m = str(n)
if m[-1] == m[-2] == m[-3] == "0":
    print(0)
else:
    print(1000 - int(m[-3]+m[-2]+m[-1]))

Fixed submission:
n = int(input())
for i in range(100):
    if i * 1000 >= n:
        print(i * 1000 - n)
        break

Buggy python submission (verdict: Runtime Error):
n = input()
m = str(n)
if m[-1] == m[-2] == m[-3] == "0":
    print(0)
else:
    print(1000 - int(m[-3]+m[-2]+m[-1]))

Fixed submission:
n = int(input())
for i in range(100):
    if i * 1000 >= n:
        print(i * 1000 - n)
        break
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
ans = 0
j = m
for i in range(n + 1):
    if a[0] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Fixed submission:
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
ans = 0
j = m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
t = 0
cnt = 0
for i in range(n + m):
    if a[0] <= b[0]:
        t += a[0]
        del a[0]
    else:
        t += b[0]
        del b[0]
    if t >= k:
        break
    else:
        cnt += 1
print(cnt)

Fixed submission:
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
ans = 0
j = m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = "abcdefghijklmnopqrstuvwxyz"
a = n
s = ""
if n <= 26:
    print(x[n-1])
else:
    while a > 26:
        s += x[(a % 26) - 1]
        if a // 26 < 26 and a % 26 == 0:
            a = a // 26 - 1
            break
        else:
            a = a // 26
    s += x[a % 26 - 1]
    print(s[::-1]

Fixed submission:
n = int(input())
x = "abcdefghijklmnopqrstuvwxyz"
a = n
s = ""
while a != 0:
    if a % 26 == 0:
        s += x[a % 26 - 1]
        a = a//26 - 1
    else:
        s += x[a % 26 - 1]
        a = a//26
print(s[::-1])