Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import Counter
import math

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

even = V[0::2]
odd = V[1::2]
even_max_cnt = Counter(even).most_common()
odd_max_cnt = Counter(odd).most_common()

cost = math.inf
res_freq_even = None
res_freq_odd = None
for e in even_max_cnt:
    for o in odd_max_cnt:
        if e[0] == o[0]:
            continue
        cost = min(cost, e[1]+o[1])
        res_freq_even = e
        res_freq_odd = o

if even_max_cnt[0][1] == len(even) and \
        odd_max_cnt[0][1] == len(odd) and \
        even_max_cnt[0][0] == odd_max_cnt[0][0]:
    ans = len(even)
else:
    ans = (len(even) - even_max_cnt[0][1]) + (len(odd) - odd_max_cnt[0][1])

print(ans)


Fixed submission:
from collections import Counter

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

even = V[0::2]
odd = V[1::2]
even_max_cnt = Counter(even).most_common(2)
odd_max_cnt = Counter(odd).most_common(2)

if even_max_cnt[0][0] != odd_max_cnt[0][0]:
    ans = len(V) - even_max_cnt[0][1] - odd_max_cnt[0][1]
else:
    if len(even_max_cnt) == 1 or len(odd_max_cnt) == 1:
        ans = len(V) // 2
    else:
        ans = len(V) - max(even_max_cnt[0][1]+odd_max_cnt[1][1],
                           even_max_cnt[1][1]+odd_max_cnt[0][1])

print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
s = set()
for i, n in enumerate(range(A, B+1)):
    if i+1 <= K:
        s.add(n)
for i, n in enumerate(reversed(range(A, B+1))):
    if i+1 <= K:
        s.add(n)
for i in sorted(s):
    print(i)

Fixed submission:
S = input()
if 'a' in S and 'b' in S and 'c' in S:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())
s = set()
for i, n in enumerate(range(A, B+1)):
    if i+1 <= K:
        s.add(n)
for i, n in enumerate(reversed(range(A, B+1))):
    if i+1 <= K:
        s.add(n)
for i in sorted(s):
    print(i)

Fixed submission:
A, B, K = map(int, input().split())
s = set()
for i, n in enumerate(range(A, B+1)):
    if i+1 <= K:
        s.add(n)
    if i+1 > K:
        break
for i, n in enumerate(reversed(range(A, B+1))):
    if i+1 <= K:
        s.add(n)
    if i+1 > K:
        break
for i in sorted(s):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())
s = set()
for i, n in enumerate(range(A, B+1)):
    if i+1 <= K:
        s.add(n)
for i, n in enumerate(reversed(range(A, B+1))):
    if i+1 <= K:
        s.add(n)
for i in sorted(s):
    print(i)

Fixed submission:
A, B, K = map(int, input().split())
s = set()
for i, n in enumerate(range(A, B+1)):
    if i+1 <= K:
        s.add(n)
    if i+1 > K:
        break
for i, n in enumerate(reversed(range(A, B+1))):
    if i+1 <= K:
        s.add(n)
    if i+1 > K:
        break
for i in sorted(s):
    print(i)
Buggy python submission (verdict: Runtime Error):
N = input()
A = list(map(int, input().split()))

tmp = min(A)
ans = 0
while all(a % 2 == 0 for a in A):
    A = all(a/2 for a in A)
    ans += 1
print(ans)

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

tmp = min(A)
ans = 0
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
import numpy as np


def lcm(x, y):
    return (x * y) // np.gcd(x, y)


N = int(input())
T = [int(input()) for _ in range(N)]

ans = T[0]
for t in T[1:]:
    ans = lcm(ans, t)

print(ans)

Fixed submission:
from fractions import gcd


def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x


N = int(input())
T = [int(input()) for _ in range(N)]

ans = lcm(T)

print(ans)

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


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


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

ans = T[0]
for t in T[1:]:
    ans = lcm(ans, t)

print(ans)

Fixed submission:
from fractions import gcd


def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x


N = int(input())
T = [int(input()) for _ in range(N)]

ans = lcm(T)

print(ans)

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


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


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

ans = T[0]
for t in T[1:]:
    ans = lcm(ans, t)

print(ans)

Fixed submission:
from fractions import gcd


def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x


N = int(input())
T = [int(input()) for _ in range(N)]

ans = lcm(T)

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

ans = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == 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 0 <= z <= K:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = str(input())
str_list = ['dream', 'dreamer', 'erase', 'eraser']
dp = [0] * 10000

for i in range(len(S)):
    for s in str_list:
        if S[i:i+len(s)] == s:
            dp[i+len(s)] = 1

if dp[len(S)] == 1:
    print('YES')
else:
    print('NO')

Fixed submission:
# 確認

S = str(input())
words = ['dream', 'dreamer', 'erase', 'eraser']
dp = [0] * 100010

dp[0] = 1
for i in range(len(S)):
    if not dp[i]:
        continue
    for w in words:
        if S[i:i+len(w)] == w:
            dp[i+len(w)] = 1

if dp[len(S)] == 1:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
str_list = ['dream', 'dreamer', 'erase', 'eraser']
dp = [0] * 10000

for i in range(len(S)):
    for s in str_list:
        if S[i:i+len(s)] == s:
            dp[i+len(s)] = 1

if dp[len(S)] == 1:
    print('YES')
else:
    print('NO')

Fixed submission:
# 確認

S = str(input())
words = ['dream', 'dreamer', 'erase', 'eraser']
dp = [0] * 100010

dp[0] = 1
for i in range(len(S)):
    if not dp[i]:
        continue
    for w in words:
        if S[i:i+len(w)] == w:
            dp[i+len(w)] = 1

if dp[len(S)] == 1:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
str_list = ['dream', 'dreamer', 'erase', 'eraser']
dp = [0] * 100000

for i in range(len(S)):
    for s in str_list:
        if S[i:i+len(s)] == s:
            dp[i+len(s)] = 1

if dp[len(S)] == 1:
    print('YES')
else:
    print('NO')

Fixed submission:
# 確認

S = str(input())
words = ['dream', 'dreamer', 'erase', 'eraser']
dp = [0] * 100010

dp[0] = 1
for i in range(len(S)):
    if not dp[i]:
        continue
    for w in words:
        if S[i:i+len(w)] == w:
            dp[i+len(w)] = 1

if dp[len(S)] == 1:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
s=int(input("羊:"))
w=int(input("狼:"))
if s>w:
    print("safe")
else:
    print("unsafe")

Fixed submission:
s,w = map(int, input().split())
 
if s > w:
    print('safe')
else:
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S=int(input("羊:"))
W=int(input("狼:"))
if S>W:
    print("safe")
else:
    print("unsafe")

Fixed submission:
s,w = map(int, input().split())
 
if s > w:
    print('safe')
else:
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S=int(input())
W=int(input())
if S>W:
    print("safe")
else:
    print("unsafe")

Fixed submission:
s,w = map(int, input().split())
 
if s > w:
    print('safe')
else:
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S=int(input("羊:"))
W=int(input("狼:"))
if S>W:
    print("safe")
else:
    print("unsafe")

Fixed submission:
s,w = map(int, input().split())
 
if s > w:
    print('safe')
else:
    print('unsafe')
Buggy python submission (verdict: Runtime Error):
a=int(input("a="))
b=int(input("b="))
c=int(input("c="))
if a==b==c:
    print("No")
if a!=b!=c:
    print("No")
else :
    print("Yes")

Fixed submission:
a,b,c=[int(x) for x in input().split()]
if a==b and b==c :
    print("No")
elif a!=b and b!=c and a!=c:
    print("No") 
else :
    print("Yes")
Buggy python submission (verdict: Runtime Error):
x=input()
print(x+(int)(pow(x,2)+(int)(pow(x,3)))

Fixed submission:
x=(int)(input())
y=x+(int)(pow(x,2))+(int)(pow(x,3))
print("{}".format(y))
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,raw_input().split())
a=map(int,raw_input().split())
b=map(int,raw_input().split())
cnt1=0
cnt2=0
a1=[0]
b1=[0]
for i in range(n):
    a1.append(a1[-1]+a[i])
for i in range(m):
    b1.append(b1[-1]+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

Fixed submission:
n,m,k=map(int,raw_input().split())
a=map(int,raw_input().split())
b=map(int,raw_input().split())
cnt1=0
cnt2=0
a1=[0]
b1=[0]
for i in range(n):
    a1.append(a1[-1]+a[i])
for i in range(m):
    b1.append(b1[-1]+b[i])
ans=0
j=m
for i in range(n+1):
    if a1[i]>k:
        break
    while b1[j]>k-a1[i]:
        j-=1
    ans=max(ans,i+j)
print ans

Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,raw_input().split())
a=map(int,raw_input().split())
b=map(int,raw_input().split())
cnt1=0
cnt2=0
a1=[0]
b1=[0]
for i in range(n):
    a1.append(a1[-1]+a[i])
for i in range(n):
    b1.append(b1[-1]+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

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

Fixed submission:
def main():
    a = int(input())
    print(a + a*a + a*a*a)
    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
print(a + a*a + a*a*a)

Fixed submission:
def main():
    a = int(input())
    print(a + a*a + a*a*a)
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
Q = int(input())
result = 0
for i in a:
    result += i
for j in range(Q):
    b,c = map(int,input().split())
    while b in a:
        a[a.index(b)] = c
        result += c-b
    print(result)



Fixed submission:
N = int(input())
a = list(map(int,input().split()))
Q = int(input())
cnt = [0]*1000001
result = 0
for i in a:
    cnt[i] += 1
    result += i
for j in range(Q):
    b,c = map(int,input().split())
    cnt[c] += cnt[b]
    n = cnt[b]
    cnt[b] = 0
    result += (c-b)*n
    print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
M = 1000001
cnt = [0]*M
ans = 0
for x in A:
    if cnt[x] != 0:
        cnt[x] = 2
    for i in range(x,M,x):
        cnt[i] += 1
for x in A:
    if cnt[x] == 1:
        ans += 1
print(ans)

    


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
M = 1000001
cnt = [0]*M
ans = 0
for x in A:
    if cnt[x] != 0:
        cnt[x] = 2
        continue
    for i in range(x,M,x):
        cnt[i] += 1
for x in A:
    if cnt[x] == 1:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy
N = int(input())
A = list(map(int,input().split()))
count = 0
for i,a in enumerate(A):
    flag = 0
    A2 = deepcopy(A)
    del A2[i]
    Aas = sorted(A2)
    if a not in A2:
        for b in Aas:
            if a % b  == 0:
                flag = 1
                break
            if a/b < 2:
                break
    else:
        flag = 1
    if flag == 0:
        count += 1
print(count)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
M = 1000001
cnt = [0]*M
ans = 0
for x in A:
    if cnt[x] != 0:
        cnt[x] = 2
        continue
    for i in range(x,M,x):
        cnt[i] += 1
for x in A:
    if cnt[x] == 1:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy
N = int(input())
A = list(map(int,input().split()))
count = 0
for i,a in enumerate(A):
    flag = 0
    for j,b in enumerate(A):
        if a % b  == 0 and i != j:
            flag = 1
            break
    if flag == 0:
        count += 1
print(count)




Fixed submission:
N = int(input())
A = list(map(int,input().split()))
M = 1000001
cnt = [0]*M
ans = 0
for x in A:
    if cnt[x] != 0:
        cnt[x] = 2
        continue
    for i in range(x,M,x):
        cnt[i] += 1
for x in A:
    if cnt[x] == 1:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy
N = int(input())
A = list(map(int,input().split()))
count = 0
for i,a in enumerate(A):
    flag = 0
    A2 = deepcopy(A)
    del A2[i]
    for j in A2:
        if a % j == 0:
            flag = 1
            break
    if flag == 0:
        count += 1
print(count)



Fixed submission:
N = int(input())
A = list(map(int,input().split()))
M = 1000001
cnt = [0]*M
ans = 0
for x in A:
    if cnt[x] != 0:
        cnt[x] = 2
        continue
    for i in range(x,M,x):
        cnt[i] += 1
for x in A:
    if cnt[x] == 1:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = list(map(int, input().split()))
result = 1
for value in s:
    result *= value
if result > pow (10,18):
    print(-1)
else:
    print(result)   


Fixed submission:
import sys
N = int(input())
s = list(map(int, input().split()))
if 0 in s:
    print(0)
    sys.exit()
result = 1
for value in s:
    result *= value
    if result > pow (10,18):
        print(-1)
        sys.exit()
print(result)
Buggy python submission (verdict: Runtime Error):
n = input()
ans=""
for i in range(len(n)):
    if n[i] == "D":
        ans = ans+"D"
    elif n[i] == "P":
        ans = ans+"P"
    elif n[i] == "?":
        if n[i-1]=="D" :
            if n[i+1]=="D"or"?":
                ans = ans+"P"
            else:
                ans = ans + "D"
        else:
            ans = ans + "D"
print(ans)

Fixed submission:
n = input()
ans=""
for i in range(len(n)):
    if n[i] == "D":
        ans = ans+"D"
    elif n[i] == "P":
        ans = ans+"P"
    elif n[i] == "?":
        ans = ans+"D"
print(ans)
Buggy python submission (verdict: Runtime Error):
n = input()
if n[-1] in "24579":
    print("hon")
elif n[-1] in "0168":
    print("pon")
else :
    pinnt("bon")

Fixed submission:
n = input()
if n[-1] in "24579":
    print("hon")
if n[-1] in "0168":
    print("pon")
if n[-1] in "3":
    print("bon")
Buggy python submission (verdict: Runtime Error):
import math

a,b,h,m = map(int, input().split())
start = 30*h
d = min(abs(start - 5.5 * m),360-abs(start - 5.5 * m))
if int(d)!=90 and int(d)!= 0:
    c = math.cos(math.radians(d))
    k = a**2+b**2-2*a*b*c
    ans = math.sqrt(k) 
    print(ans)
elif int(d) == 0:
    print(abs(a-b))
    print(c)
elif int(d) ==90:
    k= a**2+b**2
    ans = math.sqrt(k)
    print(ans)


Fixed submission:
a,b,h,m = map(int, input().split())
import math
a_x = a * math.cos(math.radians(30*h + 0.5*m))
a_y = a * math.sin(math.radians(30*h + 0.5*m))
b_x = b * math.cos(math.radians(6*m))
b_y = b * math.sin(math.radians(6*m))

ans = math.sqrt(abs(a_x - b_x)**2 + abs(a_y - b_y)**2)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m  = map(int,input().split())
z = list(map(int,input().split()))


ok = [1]
if m == 1:
    print(z[0]-n)
    exit()

for i in range(1,z[1]-z[0]):
    ans = True
    for j in range(len(z)-1):
        if abs(z[j]-m)%i != 0:
            ans = False
            break
    if ans :
        ok.append(i)
print(ok[-1])


Fixed submission:
from fractions import gcd

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



ans = abs(z[0] - x)
for i in range(1, n):
    ans = gcd(ans, abs(x - z[i]))
print(ans)

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


ok = [1]
if m == 1:
    print(z[0]-n)
    exit()

for i in range(1,z[1]-z[0]):
    ans = True
    for j in range(len(z)):
        if abs(z[j]-m)%i != 0:
            ans = False
    if ans :
        ok.append(i)
print(ok[-1])


Fixed submission:
from fractions import gcd

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



ans = abs(z[0] - x)
for i in range(1, n):
    ans = gcd(ans, abs(x - z[i]))
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a,b,c=0,0,0
for i in range(n):
    t,x,y = map(int, input().split())
    sa = t-a
    if sa<abs(x-b)+abs(y-c):
        print("No")
        exit()
    else:
        tw = sa-abs(x-b)-abs(y-c)
        if tw%2!=0:
            print("No")
            exit()
    a,b,c=x,y,z
print("Yes")


Fixed submission:
n = int(input())
a,b,c=0,0,0
for i in range(n):
    t,x,y = map(int, input().split())
    sa = t-a
    if sa<abs(x-b)+abs(y-c):
        print("No")
        exit()
    else:
        tw = sa-abs(x-b)-abs(y-c)
        if tw%2!=0:
            print("No")
            exit()
    a,b,c=t,x,y
print("Yes")
Buggy python submission (verdict: Runtime Error):
x,y = map(int, input().split())

if 2*x <= y and y <= 4*x:
  if y % 2 == 0:
    print('Yes')
  else:
    print('No')
else:
  print('No')


Fixed submission:
a,b,c,d,e = map(int, input().split())
print(15-a-b-c-d-e)
Buggy python submission (verdict: Runtime Error):
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
else:
    print(x)

smaller = 0
for i in range(x):
    if x - i in p:
        pass
    else:
        smaller = x-i
        break

bigger = 2*x
for j in range(x):
    if x + j in p:
        pass
    else:
        bigger = x + j
        break

ans = smaller if x - smaller <= bigger - x else bigger
#print(bigger)
print(ans)

Fixed submission:
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
    smaller = 0
    for i in range(x):
        if x - i in p:
            pass
        else:
            smaller = x-i
            break

    bigger = 2*x
    for j in range(x):
        if x + j in p:
            pass
        else:
            bigger = x + j
            break

    ans = smaller if x - smaller <= bigger - x else bigger
    #print(bigger)
    print(ans)
else:
    print(x)

Buggy python submission (verdict: Runtime Error):
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))

smaller = 0
for i in range(x):
    if x - i in p:
        pass
    else:
        smaller = x-i
        break

bigger = 2*x
for j in range(x):
    if x + j in p:
        pass
    else:
        bigger = x + j
        break

ans = smaller if x - smaller <= bigger - x else bigger
#print(bigger)
print(ans)

Fixed submission:
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
    smaller = 0
    for i in range(x):
        if x - i in p:
            pass
        else:
            smaller = x-i
            break

    bigger = 2*x
    for j in range(x):
        if x + j in p:
            pass
        else:
            bigger = x + j
            break

    ans = smaller if x - smaller <= bigger - x else bigger
    #print(bigger)
    print(ans)
else:
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
print(ans if ans <= 10**18 else -1)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
if min(a) == 0:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            ans = 0
    print(ans if ans != 0 else -1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = [0]*(n+1)

b[0] = 1
for i in range(n):
    b[i+1] = 2*(b[i] - a[i])
#根から計算した深さごとの要素数の最大値

c = [0]*(n+1)
c[n] = a[n]
for j in range(n):
    c[n-1-j] = c[n-j] + a[n-1-j]
#葉から計算した最小値

#print(b)
#print(c)

d = [0]*(n+1)
flag = 0
for k in range(n+1):
    if b[k] < c[k]:
        d[k] = b[k]
        if d[k] <= 0:
            flag += 1
    else:
        d[k] = c[k]
        if d[k] <= 0:
            flag += 1

for l in range(n):
    flag += 1 if d[l+1] < d[l] - a[l] or 2*d[l] - a[l] < d[l+1] else 0
    flag += 1 if a[l] + (d[l+1]+1)//2 > d[l] or d[l] > d[l+1] + a[l] else 0

ans = sum(d) if flag == 0 else -1
ans = -1 if n == 0 and a[0] > 1 else ans
ans = -1 if a[n] != d[n] else ans
print(ans)
#print(d)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*(n+1)

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

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

d = [0]*(n+1)
flag = 0
for k in range(n+1):
    if b[k] < c[k]:
        d[k] = b[k]
        if d[k] <= 0:
            flag += 1
    else:
        d[k] = c[k]
        if d[k] <= 0:
            flag += 1

ans = sum(d) if flag == 0 else -1
ans = -1 if n == 0 and a[0] > 1 else ans
ans = -1 if a[n] != d[n] else ans
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int, input().split())
ans = 0

for i in range(n):
    tmp = (a*i+a)//b - (i+1)//b * a
    ans = max(ans, tmp)

print(ans)

Fixed submission:
a,b,n = map(int, input().split())
y = min(b-1, n)
ans = a*y//b - y//b * a

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
print(~-float(input())*2*math.pi)

Fixed submission:
print(int(input())*6.28)
Buggy python submission (verdict: Runtime Error):
import math
n,k = map(int, input().split())

ans = 0
for i in range(n-k+1):
    ans += math.factorial(n+1)/math.factorial(k+i)/math.factorial(n+1-k-i)

print(int(ans))

Fixed submission:
import math
n,k = map(int, input().split())
mod = 10**9 + 7
ans = 0

for i in range(k, n+2):
    max = (i*(n + n-i+1))//2
    min = (i*(i-1))//2
    ans += max - min + 1
    ans %= mod
    
print(ans)