Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

l = input().split()
N = int(l[0])
A = int(l[1])
B = int(l[2])

HP = [int(input()) for i in range(N)]


count = 0
check = 0
while(True):
	HP.sort()
	print(HP)

	for i in range(N):
		if i == N-1:
			HP[i] = HP[i] - A
			count = count + 1
		else:
			HP[i] = HP[i] - B

	for i in range(N):
		if HP[N-1] < 0 and HP[N-2] < 0:
			check = 1

	if check == 1:
		break

print("Count: " + str(count))

Fixed submission:
# -*- coding:utf-8 -*-

N = int(input())
s = [int(input()) for i in range(N)]
s.sort()

sum = 0
for i in range(N):
	sum = sum + s[i]

check = 0
if sum % 10 != 0:
	print(sum)
else:
	for i in range(N):
		if s[i] % 10 != 0:
			print(sum - s[i])
			break
		else:
			check = check + 1

if check == N:
	print(0)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
count = 0

for m in range(1, a+1):5 5
  for d in range(1, b+1):
    if (m-d == 0):
      count += 1

print(count)

Fixed submission:
a, b = map(int, input().split())
if a <= b:
  print(a)
else:
  print(a-1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
T = []
A = []
for _ in xrange(N):
    t, a = map(int, raw_input().split())
    T.append(t)
    A.append(a)

ans = T[0] + A[0]
tmpT = T[0]
tmpA = A[0]
for i in xrange(1, N):
    if T[i] >= T[i-1] and A[i] >= A[i-1] and T[i] + A[i] >= ans:
        ans = T[i] + A[i]
        tmpT = T[i]
        tmpA = A[i]
    else:
        add = T[i] + A[i]
        j = ans / add + 1
        while True:
            tmpAns = add * j
            tt = T[i] * j
            aa = A[i] * j
            if tt >= tmpT and aa >= tmpA:
                ans = tmpAns
                tmpT =tt
                tmpA = aa
                break
            j += 1
print ans

Fixed submission:
N = int(input())
T = []
A = []
for _ in range(N):
    Ti, Ai = map(int, input().split())
    T.append(Ti)
    A.append(Ai)

tmp_t = T[0]
tmp_a = A[0]
ans = tmp_t + tmp_a
for i in range(1, N):
    n_t = tmp_t // T[i] if tmp_t % T[i] == 0 else tmp_t // T[i] + 1
    n_a = tmp_a // A[i] if tmp_a % A[i] == 0 else tmp_a // A[i] + 1
    n = max(n_t, n_a)
    tmp_t = T[i] * n
    tmp_a = A[i] * n
    ans = tmp_t + tmp_a

print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq
N, L = map(int, raw_input().split())
hq = []
for _ in xrange(N:
    s = raw_input()
    heapq.heappush(hq, s)
ans = ''
while len(hq) > 0:
    ans += heapq.heappop(hq)
print ans

Fixed submission:
import heapq
N, L = map(int, raw_input().split())
hq = []
for _ in xrange(N):
    s = raw_input()
    heapq.heappush(hq, s)
ans = ''
while len(hq) > 0:
    ans += heapq.heappop(hq)
print ans
Buggy python submission (verdict: Runtime Error):
N, K = raw_input().split()
D = raw_input().split()
candi = [str(i) for i in xrange(10)]
for d in D:
    candi.remove(d)

def decide(i):
    if i >= len(N):
        return ''
    for c in candi:
        if N[i] == c:
            return c + decide(i+1)
        elif N[i] < c:
            return c + candi[0] * (len(N) - i - 1)
    else:
        return (candi[0] if candi[0] != 0 else candi[1]) + decide(i)

print decide(0)

Fixed submission:
N, K = raw_input().split()
D = raw_input().split()
candi = [str(i) for i in xrange(10)]
for d in D:
    candi.remove(d)

def decide(i):
    if i >= len(N):
        return ''
    for c in candi:
        if N[i] == c:
            return c + decide(i+1)
        elif N[i] < c:
            return c + candi[0] * (len(N) - i - 1)

if candi[-1] * len(N) >= N:
    print decide(0)
else:
    print (candi[0] if candi[0] != '0' else candi[1]) + candi[0] * len(N)
Buggy python submission (verdict: Runtime Error):
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)

k = input()
k = int(k)

print(max(a * 2 * k + b + c, a + b * 2 * k + c, a + b + c * 2 * k))


Fixed submission:
a, b = input().split()
a = int(a)
b = int(b)
if a <= b:
  print(a)
else:
  print(a-1)
Buggy python submission (verdict: Runtime Error):
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)

k = input()
k = int(k)

ans = 0

if max(a,b,c) = a:
  ans = ans + b + c
elif max(a, b, c) == b:
  ans = ans + a + c
elif max(a, b, c) == c:
  ans = ans + a + b

print(ans + max(a, b, c) * 2 * k)

Fixed submission:
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)

k = input()
k = int(k)

print(max(a * 2 ** k + b + c, a + b * 2 ** k + c, a + b + c * 2 ** k))
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
    if M==1 and N==1:
        print(1)
    elif M==1:
        print(N-2)
    elif N==1:
        print(M-2)
    else:
        print((N-2)*(M-2))


Fixed submission:
N,M = map(int, input().split())
if M==1 and N==1:
    print(1)
elif M==1:
    print(N-2)
elif N==1:
    print(M-2)
else:
    print((N-2)*(M-2))

Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
if M==1 and N==1:
    return 1
elif M==1:
    return N-2
elif N==1:
    return M-2
else:
    return (N-2)*(M-2)


Fixed submission:
N,M = map(int, input().split())
if M==1 and N==1:
    print(1)
elif M==1:
    print(N-2)
elif N==1:
    print(M-2)
else:
    print((N-2)*(M-2))

Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
    if M==1 and N==1:
        return 1
    elif M==1:
        return N-2
    elif N==1:
        return M-2
    else:
        return (N-2)*(M-2)

Fixed submission:
N,M = map(int, input().split())
if M==1 and N==1:
    print(1)
elif M==1:
    print(N-2)
elif N==1:
    print(M-2)
else:
    print((N-2)*(M-2))

Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
    if M==1 and N==1:
        return 1
    elif M==1:
        return N-2
    elif N==1:
        return M-2
    else:
        return (N-2)*(M-2)

Fixed submission:
N,M = map(int, input().split())
if M==1 and N==1:
    print(1)
elif M==1:
    print(N-2)
elif N==1:
    print(M-2)
else:
    print((N-2)*(M-2))
Buggy python submission (verdict: Runtime Error):
import sys

N,K = map(int, input().split())
res = 0
if K==0:
    print(N*N)
    sys.exit(0)
for i in range(N):
    i += 1
    if i-K<=0:
        continue
    amari = N % i
    amari = amari - K + 1
    re = N // i
    if amari <= 0:
        amari = 0
    res += re*(i-K) + amari
 print(res)

Fixed submission:
import sys

N,K = map(int, input().split())
res = 0
if K==0:
    print(N*N)
    sys.exit(0)
for i in range(N):
    i += 1
    if i-K<=0:
        continue
    amari = N % i
    amari = amari - K + 1
    re = N // i
    if amari <= 0:
        amari = 0
    res += re*(i-K) + amari
print(res)

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

N,K = map(int, input().split())
res = 0
if K==0:
    print(N*N)
    sys.exit(0)
for i in range(N):
    i += 1
    if i-K<=0:
        continue
    amari = N % i
    amari = amari - K + 1
    re = N//i
    if amari<=0:
        amari = 0
    res += re*(i-K) + amari
 print(res)

Fixed submission:
import sys

N,K = map(int, input().split())
res = 0
if K==0:
    print(N*N)
    sys.exit(0)
for i in range(N):
    i += 1
    if i-K<=0:
        continue
    amari = N % i
    amari = amari - K + 1
    re = N // i
    if amari <= 0:
        amari = 0
    res += re*(i-K) + amari
print(res)

Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
res = 0
if K==0:
    print(N*N)
    return
for i in range(N):
    i += 1
    if i-K<=0:
        continue
    amari = N % i
    amari = amari - K + 1
    re = N//i
    if amari<=0:
        amari = 0
    res += re*(i-K) + amari
 print(res)

Fixed submission:
import sys

N,K = map(int, input().split())
res = 0
if K==0:
    print(N*N)
    sys.exit(0)
for i in range(N):
    i += 1
    if i-K<=0:
        continue
    amari = N % i
    amari = amari - K + 1
    re = N // i
    if amari <= 0:
        amari = 0
    res += re*(i-K) + amari
print(res)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
s = 0
if a <= b:
    s = a
    if b <= c:
        s += b
    else:
        s += c
else:
    s = b
    if a <= c:
        s += a
    else:
        s += b
print(s)

Fixed submission:
a = [int(x) for x in input().split()]
s = 0
if a[0] <= a[1]:
    s = a[0]
    if a[1] <= a[2]:
        s += a[1]
    else:
        s += a[2]
else:
    s = a[1]
    if a[0] <= a[2]:
        s += a[0]
    else:
        s += a[2]
print(s)

Buggy python submission (verdict: Runtime Error):
def main():
    a = int(input())
    b = int(input())
    c = int(input())
    s = 0
    if a <= b:
        s = a
        if b <= c:
            s += b
        else:
            s += c
    else:
        s = b
        if a <= c:
            s += a
        else:
            s += b
    print(s)

if __name__ == "__main__":
    main()

Fixed submission:
a = [int(x) for x in input().split()]
s = 0
if a[0] <= a[1]:
    s = a[0]
    if a[1] <= a[2]:
        s += a[1]
    else:
        s += a[2]
else:
    s = a[1]
    if a[0] <= a[2]:
        s += a[0]
    else:
        s += a[2]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
b = []

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.insert(0,a[i])

for i in range(n):
    if n%2!=0:
        i=n-i-1
    print(str(b[i]) + " ", end="")
print()

Fixed submission:
from collections import deque
n = int(input())
a = [int(x) for x in input().split()]
b = deque()

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

for i in range(n):
    if n%2!=0:
        i=n-i-1
    print(str(b[i]) + " ", end="")
print()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
b = []

for i in range(n):
    b.append(a[i])
    b.reverse()

for i in range(n):
    print(str(b[i]) + " ", end="")
print()


Fixed submission:
from collections import deque
n = int(input())
a = [int(x) for x in input().split()]
b = deque()

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

for i in range(n):
    if n%2!=0:
        i=n-i-1
    print(str(b[i]) + " ", end="")
print()
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = [int(i) for i in input().split()]
for i in range(n):
    tmp = list(x)
    tmp[i] *= -1
    tmp.sort()
    median = int(n/2)
    print(tmp[median])
    


Fixed submission:
ipt = [int(i) for i in input().split()]
a = ipt[0]
b = ipt[1]
x = ipt[2]

if a <= x and x <= a+b:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
ipt1 = [int(i) for i in input().split()]
a = [int(i) for i  in input().split()]
n = ipt1[0]
m = ipt1[1]
x = ipt1[2]
cost_0 = 0
cost_n = 0
for i in range(m):
    if a[i] < x:
        cost_0 += 1
    else:
        cost_n += 1

print(int(min(cost_0, cost_n)))


Fixed submission:
ipt = [int(i) for i in input().split()]
a = ipt[0]
b = ipt[1]
x = ipt[2]

if a <= x and x <= a+b:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
ipt1 = [int(i) for i in input().split()]
a = [int(i) for i  in input().split()]
n = ipt1[0]
m = ipt1[1]
x = ipt1[2]
cost_0 = 0
cost_n = 0
for i in range(m):
    if a[i] < x:
        cost_0 += 1
    else:
        cost_n += 1

print(min(cost_0, cost_n))


Fixed submission:
ipt = [int(i) for i in input().split()]
a = ipt[0]
b = ipt[1]
x = ipt[2]

if a <= x and x <= a+b:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

tmp = np.zeros(n)
tmp = list(x)
indexhold = np.argsort(tmp)
for i in range(n):
    for j in range(n):
        if i == indexhold[j] and j < n/2:
            print(tmp[indexhold[int(n/2)]])
        elif i == indexhold[j] and j >= n/2:
            print(tmp[indexhold[int(n/2) -1]])    


Fixed submission:
import numpy as np
n = int(input())
x = [int(i) for i in input().split()]

index_hold = np.argsort(x)
index_hold_rev = [0 for i in range(n)]
for i in range(n):
    index_hold_rev[index_hold[i]] = i
for i in range(n):
    if index_hold_rev[i] < n/2:
        print(x[index_hold[int(n/2)]])
    else:
        print(x[index_hold[int(n/2-1)]])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = [int(i) for i in input().split()]
for i in range(n):
    tmp = list(x)
    tmp[i] *= -1
    tmp.sort()
    median = int(n/2)
    print(tmp[median])
    


Fixed submission:
import numpy as np
n = int(input())
x = [int(i) for i in input().split()]

index_hold = np.argsort(x)
index_hold_rev = [0 for i in range(n)]
for i in range(n):
    index_hold_rev[index_hold[i]] = i
for i in range(n):
    if index_hold_rev[i] < n/2:
        print(x[index_hold[int(n/2)]])
    else:
        print(x[index_hold[int(n/2-1)]])
Buggy python submission (verdict: Runtime Error):
n = int(input())
D = ([int(_) for _ in input().split()])
m = int(input())
T = ([int(_) for _ in input().split()])

d_cnt = [0 for _ in range(200000)]
t_cnt = [0 for _ in range(200000)]

for d in D:
	d_cnt[d] += 1

for t in T:
	t_cnt[t] += 1

for i in range(len(t_cnt)):
	if t_cnt[i] > d_cnt[i]:
		print("NO")
		exit(0)
print("YES")

Fixed submission:
n = int(input())
D = sorted([int(_) for _ in input().split()])
m = int(input())
T = sorted([int(_) for _ in input().split()])

i = 0
for t in T:
	while(D[i] < t):
		i += 1
	if D[i] == t:
		i += 1
	else:
		print("NO")
		exit(0)
print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
D = sorted([int(_) for _ in input().split()])
m = int(input())
T = sorted([int(_) for _ in input().split()])


for t in T:
	while(D[0] < t):
		D.pop(0)
	if D[0] == t:
		D.pop(0)
	else:
		print("NO")
		exit(0)
print("YES")

Fixed submission:
n = int(input())
D = sorted([int(_) for _ in input().split()])
m = int(input())
T = sorted([int(_) for _ in input().split()])

i = 0
for t in T:
	while(D[i] < t):
		i += 1
	if D[i] == t:
		i += 1
	else:
		print("NO")
		exit(0)
print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
D = [int(_) for _ in input().split()]
m = int(input())
T = [int(_) for _ in input().split()]

for t in T:
	if t in D:
		D.remove(t)
	else:
		print("NO")
		exit(0)
print("YES")

Fixed submission:
n = int(input())
D = sorted([int(_) for _ in input().split()])
m = int(input())
T = sorted([int(_) for _ in input().split()])

i = 0
for t in T:
	while(D[i] < t):
		i += 1
	if D[i] == t:
		i += 1
	else:
		print("NO")
		exit(0)
print("YES")
Buggy python submission (verdict: Runtime Error):
x, a, b = (int(i) for i in input().split())

if x+a-b > 1:
  print('delicious')
else if x+a-b == 0:
    print('safe')
else:
    print('dangerous')


Fixed submission:
x, a, b = (int(i) for i in input().split())

if b-a>x:
    print('dangerous')
elif b-a>0:
    print('safe')
else:
    print('delicious')
Buggy python submission (verdict: Runtime Error):
N = int(input())

a = [int(n) for n in input().split()].sort()

print(a[N-1] - a[0])

Fixed submission:
N = int(input())

a = [int(n) for n in input().split()]
a = sorted(a)
print(a[N-1] - a[0])
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(n) for n in input().split()]
a = sorted(a)

colors = [0,0,0,0,0,0,0,0]
free = 0

for i in a:
    if i < 400:
        colors[0] = 1
    elif i < 800:
        colors[1] = 1
    elif i < 1200:
        colors[2] = 1
    elif i < 1600:
        colors[3] = 1
    elif i < 2000:
        colors[4] = 1
    elif i < 2400:
        colors[5] = 1
    elif i < 2800:
        colors[6] = 1
    elif i < 3200:
        colors[7] = 1
    else:
        free += 1

print(str(sum(colors)) + " " + str(min(sum(colors) + free, 8)))
N = int(input())
a = [int(n) for n in input().split()]
a = sorted(a)

colors = [0,0,0,0,0,0,0,0]
free = 0

for i in a:
    if i < 400:
        colors[0] = 1
    elif i < 800:
        colors[1] = 1
    elif i < 1200:
        colors[2] = 1
    elif i < 1600:
        colors[3] = 1
    elif i < 2000:
        colors[4] = 1
    elif i < 2400:
        colors[5] = 1
    elif i < 2800:
        colors[6] = 1
    elif i < 3200:
        colors[7] = 1
    else:
        free += 1

print(str(sum(colors)) + " " + str(min(sum(colors) + free, 8)))


Fixed submission:
N = int(input())
a = [int(n) for n in input().split()]

colors = [0,0,0,0,0,0,0,0]
free = 0

for i in a:
    if i < 400:
        colors[0] = 1
    elif i < 800:
        colors[1] = 1
    elif i < 1200:
        colors[2] = 1
    elif i < 1600:
        colors[3] = 1
    elif i < 2000:
        colors[4] = 1
    elif i < 2400:
        colors[5] = 1
    elif i < 2800:
        colors[6] = 1
    elif i < 3200:
        colors[7] = 1
    else:
        free += 1

s = sum(colors)

print(str(max(s, 1)) + " " + str(s + free))
Buggy python submission (verdict: Time Limit Exceeded):
import math

def calc(H, T, a, b):
    cnt = 0
    for h in H:
        cnt += math.ceil((h - b * T) / (a - b))
    if cnt <= T:
        return False
    else:
        return True

tmp = [int(n) for n in input().split()]
a = tmp[1]
b = tmp[2]
H = []

for i in range(tmp[0]):
    H.append(int(input()))
H = list(sorted(H))[::-1]
T = 1
while calc(H, T, a, b):
    T = T + 1

print(T)


Fixed submission:
import math

def calc(H, T, a, b):
    cnt = 0
    for h in H:
        if (h -b*T) >= 0:
            cnt += math.ceil((h - b * T) / (a - b))
    if cnt <= T:
        return True
    else:
        return False

tmp = [int(n) for n in input().split()]
a = tmp[1]
b = tmp[2]
H = []

H = sorted([int(input()) for i in range(tmp[0])])[::-1]
minT = 0
maxT = math.ceil(H[0] / b)
T = int((maxT + minT) / 2)

while True:
    T = math.ceil((maxT + minT) / 2)
    if calc(H, T, a, b):
        maxT = T
    else:
        minT = T
    if maxT - minT <= 1:
        break
print(maxT)

Buggy python submission (verdict: Runtime Error):
I'm Yata Ryuichi.

Fixed submission:
import math

def calc(H, T, a, b):
    cnt = 0
    for h in H:
        if (h -b*T) >= 0:
            cnt += math.ceil((h - b * T) / (a - b))
    if cnt <= T:
        return True
    else:
        return False

tmp = [int(n) for n in input().split()]
a = tmp[1]
b = tmp[2]
H = []

H = sorted([int(input()) for i in range(tmp[0])])[::-1]
minT = 0
maxT = math.ceil(H[0] / b)
T = int((maxT + minT) / 2)

while True:
    T = math.ceil((maxT + minT) / 2)
    if calc(H, T, a, b):
        maxT = T
    else:
        minT = T
    if maxT - minT <= 1:
        break
print(maxT)

Buggy python submission (verdict: Time Limit Exceeded):
tmp = [int(n) for n in input().split()]
a = tmp[1]
b = tmp[2]
H = []
for i in range(tmp[0]):
    H.append(int(input()))

cnt = 0
while True:
    H = list(sorted(H))[::-1]
    flg = 0
    cnt += 1
    H[0] = H[0] - a
    for i in range(len(H)):
        if i == 0:
            if H[0] > 0:
                flg = 1
            continue
        H[i] = H[i] - b
        if H[i] > 0:
            flg = 1
    if flg == 0:
        break

print(cnt)


Fixed submission:
import math

def calc(H, T, a, b):
    cnt = 0
    for h in H:
        if (h -b*T) >= 0:
            cnt += math.ceil((h - b * T) / (a - b))
    if cnt <= T:
        return True
    else:
        return False

tmp = [int(n) for n in input().split()]
a = tmp[1]
b = tmp[2]
H = []

H = sorted([int(input()) for i in range(tmp[0])])[::-1]
minT = 0
maxT = math.ceil(H[0] / b)
T = int((maxT + minT) / 2)

while True:
    T = math.ceil((maxT + minT) / 2)
    if calc(H, T, a, b):
        maxT = T
    else:
        minT = T
    if maxT - minT <= 1:
        break
print(maxT)
Buggy python submission (verdict: Runtime Error):
def calc(n):
    i=1
    sm = 0
    st = set()
    if n<=2:
        st.add(n)
        return st
    while sm<=n:
        st.add(i)
        sm += i
        i+=1
    st = st - calc(sm-n)
    return st

n = int(input())

c = calc(n)

for cc in c:
    print(cc)

Fixed submission:
import sys


def calc(n):
    i = 1
    sm = 0
    st = set()
    if n <= 2:
        st.add(n)
        return st
    while sm < n:
        st.add(i)
        sm += i
        i += 1
    st = st - calc(sm - n)
    return st


sys.setrecursionlimit(10000000)
n = int(input())

c = calc(n)

for cc in c:
    print(cc)

Buggy python submission (verdict: Runtime Error):
def calc(n):
    i=1
    sm = 0
    st = set()
    if n<=2:
        st.add(n)
        return st
    while sm<=n:
        st.add(i)
        sm += i
        i+=1
    st = st - calc(sm-n)
    return st

n = int(input())

c = calc(n)

for cc in c:
    print(cc)

Fixed submission:
import sys


def calc(n):
    i = 1
    sm = 0
    st = set()
    if n <= 2:
        st.add(n)
        return st
    while sm < n:
        st.add(i)
        sm += i
        i += 1
    st = st - calc(sm - n)
    return st


sys.setrecursionlimit(10000000)
n = int(input())

c = calc(n)

for cc in c:
    print(cc)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math
from decimal import Decimal

N = int(input())

votes = []

for _ in range(N):
    votes.append([Decimal(n) for n in input().split()])

befa = 1
befb = 1

for a, b in votes:
    kakeru = Decimal(max(math.ceil(befa / a), math.ceil(befb / b)))
    befa = a * kakeru
    befb = b * kakeru

print(int(befa)+int(befb))

Fixed submission:
# coding: utf-8

colors = input().split()

bef = 0
count = 0
colors.sort()

for c in colors:
    if bef == 0:
        count += 1
        bef = c
    else:
        if c > bef:
            count += 1
            bef = c

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

N = int(input())

votes = []

for _ in range(N):
    votes.append([int(n) for n in input().split()])

# an = votes[0][0]
# bn = votes[0][1]
#
# for a, b in votes:
#     if a == b :
#         an = bn = max(an, bn)
#     elif a < b:
#         az = a
#         while(a)
#     elif a > b:

sum = 0
befa = 0
befb = 0

for a, b in votes:
    a_m = a
    b_m = b
    while(a < befa or b < befb):
        a += a_m
        b += b_m
    t = a + b;
    i = 1
    while(t * i < sum):
        i += 1
    sum = t * i
    befa = a
    befb = b

print(sum)



Fixed submission:
# coding: utf-8
import math
from decimal import Decimal

N = int(input())

votes = []

for _ in range(N):
    votes.append([Decimal(n) for n in input().split()])

befa = 1
befb = 1

for a, b in votes:
    kakeru = Decimal(max(math.ceil(befa / a), math.ceil(befb / b)))
    befa = a * kakeru
    befb = b * kakeru

print(int(befa)+int(befb))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
n =[]
for i in range(a,b+1):
    n.append(i)
nf=n[:k]
nb=n[len(n)-k:]
n=nf+nb
n=list(set(n))
n.sort()
for i in n:
    print(i)

Fixed submission:
a,b,k=map(int,input().split())
n =[]
for i in range(a,a+k if k<(b-a) else b+1):
    n.append(i)
for i in range(b-k+1 if k<(b-a) else b+1,b+1):
    if(i not in n):
        n.append(i)
for i in n:
    print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
n = list(range(a,b+1))
nf=n[:k]
nb=n[len(n)-k:]
n=list(set(nf+nb))
n.sort()
for i in n:
    print(i)

Fixed submission:
a,b,k=map(int,input().split())
n =[]
for i in range(a,a+k if k<(b-a) else b+1):
    n.append(i)
for i in range(b-k+1 if k<(b-a) else b+1,b+1):
    if(i not in n):
        n.append(i)
for i in n:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
a.append(0)
for i in range(n):
    m=0
    b = list(a)
    del b[i+1]
    for j in range(n):
        m += abs(b[j]-b[j+1])
    print(m)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
a.append(0)
cost = 0
for i in range(n+1):
    cost += abs(a[i]-a[i+1])
for i in range(1,n+1):
    print(cost-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1]))+abs(a[i-1]-a[i+1]))
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
max = 0
s = 10**int(math.log(n,10)) - 1
for i in range(s,n+1):
    num = sum(list(map(int,list(str(i)))))
    max = num if num > max else max
print(max)


Fixed submission:
import math
n = int(input())
s = 10**(int(math.log(n,10))+1) - 1
while s>n:
    s -= 10**int(math.log(n,10))
print(sum(list(map(int,list(str(s))))))