Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#C
from collections import Counter
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
first = sorted(set(a))[-1]
if len(a) == 1 or sorted(set(a))[0] == sorted(set(a))[-1]:
    pass
else:
    second = sorted(set(a))[-2]
for i in a:
    if i != first:
        print(first)
    else:
        print(second)


Fixed submission:
#C
from collections import Counter
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
b = a.copy()
b.sort()
b.reverse()
fi = b[0]
se = b[1]
for i in a:
    if i == fi:
        print(se)
    else:
        print(fi)

Buggy python submission (verdict: Runtime Error):
#C
from collections import Counter
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
first = sorted(set(a))[-1]
if sorted(set(a))[0] == sorted(set(a))[-1]:
    pass
else:
    second = sorted(set(a))[-2]
for i in a:
    if i != first:
        print(first)
    else:
        print(second)


Fixed submission:
#C
from collections import Counter
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
b = a.copy()
b.sort()
b.reverse()
fi = b[0]
se = b[1]
for i in a:
    if i == fi:
        print(se)
    else:
        print(fi)
Buggy python submission (verdict: Runtime Error):
#A
n, a, b = map(int, input().split())
print(min(n*a,b))A

Fixed submission:
#A
n, a, b = map(int, input().split())
print(min(n*a,b))
Buggy python submission (verdict: Time Limit Exceeded):
#C
l, r = map(int, input().split())
ans=2018
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        if i * j % 2019 < ans:
            ans = i * j % 2019
print(ans)

Fixed submission:
#C
import sys
l, r = map(int, input().split())
ans=2018
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        if i * j % 2019 < ans:
            ans = i * j % 2019
        if ans == 0:
            print(0)
            sys.exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
#C
import math
a, b, c, d = map(int, input().split())
bb = b - (b // c) - (b // d) + (b // (c * d / math.gcd(c, d)))
aa = a - (a // c) - (a // d) + (a // (c * d / math.gcd(c, d)))

print((bb-aa))

Fixed submission:
#C
import math
a, b, c, d = map(int, input().split())

def gcd(x, y):
    if x < y:
        x, y = y, x
    while y != 0:
        x, y = y, x % y
    return x

s = b - a + 1
cc = b // c - (a - 1) // c
dd = b // d - (a - 1) // d
cd = c * d // gcd(c, d)
cd = b // cd - (a - 1) // cd
s -= cc + dd - cd
print(s)

Buggy python submission (verdict: Runtime Error):
#C
import math
a, b, c, d = map(int, input().split())

def gcd(x, y):
    if x < y:
        x, y = y, x
    while a % b != 0:
        a, b = b, a % b

a-=1
cd=c*d//math.gcd(c,d)
ans = b - (b // c) - (b // d) + (b // cd)
ans -= a - (a // c) - (a // d) + (a // cd)

print(ans)

Fixed submission:
#C
import math
a, b, c, d = map(int, input().split())

def gcd(x, y):
    if x < y:
        x, y = y, x
    while y != 0:
        x, y = y, x % y
    return x

s = b - a + 1
cc = b // c - (a - 1) // c
dd = b // d - (a - 1) // d
cd = c * d // gcd(c, d)
cd = b // cd - (a - 1) // cd
s -= cc + dd - cd
print(s)

Buggy python submission (verdict: Runtime Error):
#C
import math
a, b, c, d = map(int, input().split())
a-=1
cd=c*d//math.gcd(c,d)
ans = b - (b // c) - (b // d) + (b // cd)
ans -= a - (a // c) - (a // d) + (a // cd)

print(ans)

Fixed submission:
#C
import math
a, b, c, d = map(int, input().split())

def gcd(x, y):
    if x < y:
        x, y = y, x
    while y != 0:
        x, y = y, x % y
    return x

s = b - a + 1
cc = b // c - (a - 1) // c
dd = b // d - (a - 1) // d
cd = c * d // gcd(c, d)
cd = b // cd - (a - 1) // cd
s -= cc + dd - cd
print(s)

Buggy python submission (verdict: Runtime Error):
C
import math
a, b, c, d = map(int, input().split())
a-=1
cd=c*d//math.gcd(c,d)
ans = b - (b // c) - (b // d) + (b // cd)
ans -= a - (a // c) - (a // d) + (a // cd)

print(ans)

Fixed submission:
#C
import math
a, b, c, d = map(int, input().split())

def gcd(x, y):
    if x < y:
        x, y = y, x
    while y != 0:
        x, y = y, x % y
    return x

s = b - a + 1
cc = b // c - (a - 1) // c
dd = b // d - (a - 1) // d
cd = c * d // gcd(c, d)
cd = b // cd - (a - 1) // cd
s -= cc + dd - cd
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
#C
a, b, c, d = map(int, input().split())
count=0
for i in range(a, b + 1):
    if i % c!=0 and i % d!=0:
        count += 1
print(count)

Fixed submission:
#C
import math
a, b, c, d = map(int, input().split())

def gcd(x, y):
    if x < y:
        x, y = y, x
    while y != 0:
        x, y = y, x % y
    return x

s = b - a + 1
cc = b // c - (a - 1) // c
dd = b // d - (a - 1) // d
cd = c * d // gcd(c, d)
cd = b // cd - (a - 1) // cd
s -= cc + dd - cd
print(s)
Buggy python submission (verdict: Runtime Error):
#B
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
count=1
for i in range(n+1):
    d = d + l[i]
    if d > x:
        break
    count+=1
print(count)

Fixed submission:
#B
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = [0] * (n + 1)
d[0]=0
count = 0
for i in range(n):
    d[i + 1] = d[i] + l[i]
for i in d:
    if i <= x:
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
#B
import math
n = int(input())
w = list(map(int, input().split()))
min=math.inf
for t in range(1,n):
    a = sum(w[:t])
    b = sum(w[t:])
    # print(a, b)
    if min > abs(a - b):
        min = abs(a - b)
print(min)

Fixed submission:
#B
import math
n = int(input())
w = list(map(int, input().split()))
min=float('inf')
for t in range(1,n):
    a = sum(w[:t])
    b = sum(w[t:])
    # print(a, b)
    if min > abs(a - b):
        min = abs(a - b)
print(min)
Buggy python submission (verdict: Runtime Error):
#C
n, m = map(int, input().split())
k = [] * m
s = [] * m
p = [] * m
for i in range(m):
    ks = list(map(int, input().split()))
    k.append(ks[0])
    s.append(ks[1:])
p = list(map(int, input().split()))

# print(k, s, p)
for i in range(2 ** n):
    on = True
    for j in range(m):
        light = 0
        for k in s[j]:
            tmp = i >> k & 2
            light = (light + tmp) % 2
        if light != p[j]:
            on = False
            break
    ans += int(on)
print(ans)

Fixed submission:
# C
n, m = map(int, input().split())
k =[0]*m
s = [0]*m
for i in range(m):
    lst=input().split()
    k[i] = int(lst[0])
    s[i] = [int(x) - 1 for x in lst[1:]]
p = [int(x) for x in input().split()]
# print(s, p)
ans=0
for i in range(2 ** n):
    all_on = True
    for j in range(m):
        light = 0
        for k in s[j]:
            tmp = i >> k & 1
            #iをkだけ左にシフトし1とのANDをとる
            #>>iのk番目が1の時１を返す
            light = (light + tmp) % 2
            # print(tmp,light)
        if light != p[j]:
            all_on = False
            # print(light,p[j])
            break
    ans += int(all_on)
print(ans)

Buggy python submission (verdict: Runtime Error):
#C
n, m = map(int, input().split())
k = [] * m
s = [] * m
p = [] * m
for i in range(m):
    ks = list(map(int, input().split()))
    k.append(ks[0])
    s.append(ks[1:])
p = list(map(int, input().split()))

print(k, s, p)
for i in range(2 ** n):
    on = Ture
    for j in range(m):
        light = 0
        for k in s[j]:
            tmp = i >> k & 2
            light = (light + tmp) % 2
        if light != p[j]:
            on = False
            break
    ans += int(on)
print(ans)

Fixed submission:
# C
n, m = map(int, input().split())
k =[0]*m
s = [0]*m
for i in range(m):
    lst=input().split()
    k[i] = int(lst[0])
    s[i] = [int(x) - 1 for x in lst[1:]]
p = [int(x) for x in input().split()]
# print(s, p)
ans=0
for i in range(2 ** n):
    all_on = True
    for j in range(m):
        light = 0
        for k in s[j]:
            tmp = i >> k & 1
            #iをkだけ左にシフトし1とのANDをとる
            #>>iのk番目が1の時１を返す
            light = (light + tmp) % 2
            # print(tmp,light)
        if light != p[j]:
            all_on = False
            # print(light,p[j])
            break
    ans += int(all_on)
print(ans)
Buggy python submission (verdict: Runtime Error):
10 3
3 6
5 7
6 9

Fixed submission:
#C
n, m = map(int, input().split())
l = []
r = []
for i in range(m):
    lin = list(map(int, input().split()))
    l.append(lin[0])
    r.append(lin[1])
lma = max(l)
rmi = min(r)
if lma > rmi:
    print(0)
else:
    print(rmi - lma + 1)
Buggy python submission (verdict: Runtime Error):
#D
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = c = []
for _ in range(m):
    tmp = list(map(int, input().split()))
    b.append(tmp[0])
    c.append(tmp[1])
a.sort
for i in range(m):
    a += [c[i]] * b[i]
a=sorted(a,reverse=True)
a = a[n:]
print(sum(a))

Fixed submission:
#D
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
d = []
for i in range(m):
    b, c = map(int, input().split())
    d.append([b, c])
#print(d)
d = sorted(d, key=lambda x: x[1], reverse=True)
#print(d)
k = 0
for i in range(n):
    if d[k][0] == 0:#追加できなくなる
        k += 1
        if k == len(d):  #配列末
            break
    if a[i] >= d[k][1]:  #a>=cなのでこれ以上置き換わっても意味がない
        break
    a[i] = d[k][1]  #cに置き換わった
    d[k][0] -= 1  #dの追加出来る数を１減らす
print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
#D
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
c = []
for _ in range(m):
    tmp = list(map(int, input().split()))
    b.append(tmp[0])
    c.append(tmp[1])
#print(b,c)
a.sort()
for i in range(m):
    a += [c[i]] * b[i]
    #print(i,a)
    a=sorted(a,reverse=True)
    a = a[:n]
    #print(i,a)
print(sum(a))

Fixed submission:
#D
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
d = []
for i in range(m):
    b, c = map(int, input().split())
    d.append([b, c])
#print(d)
d = sorted(d, key=lambda x: x[1], reverse=True)
#print(d)
k = 0
for i in range(n):
    if d[k][0] == 0:#追加できなくなる
        k += 1
        if k == len(d):  #配列末
            break
    if a[i] >= d[k][1]:  #a>=cなのでこれ以上置き換わっても意味がない
        break
    a[i] = d[k][1]  #cに置き換わった
    d[k][0] -= 1  #dの追加出来る数を１減らす
print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
#C
def f(x):
    return int(x) - 1

n, q = map(int, input().split())
s = input()
l = [0] * q
r = [0] * q
for i in range(q):
    l[i], r[i] = map(f, input().split())
for i in range(q):
    count=0
    for j in range(l[i], r[i]):
        if r[i] == n:
            pass
        if s[j] == "A" and s[j + 1] == "C":
            count+=1
    print(count)

Fixed submission:
#C
def f(x):
    return int(x) - 1

n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i:i + 2] == "AC" else 0)
# print(t)
for i in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])
Buggy python submission (verdict: Runtime Error):
# C MP消費を抑えるにはABCとの差が小さけれは良い
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]
INF = 10**9


def dfs(now, a, b, c):
    if now == n:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    # 方法１　１つ飛ばす
    way1 = dfs(now + 1, a, b, c)
    # 方法２　合成魔法(MP10)
    way2 = dfs(now + 1, a + l[now], b, c)+10
    way3 = dfs(now + 1, a, b + l[now], c)+10
    way4 = dfs(now + 1, a, b, c + l[now])+10
    return min(way1, way2, way3, way4)


print(dfs(0, 0, 0, 0))
# C MP消費を抑えるにはABCとの差が小さけれは良い
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]
INF = 10**9


def dfs(now, a, b, c):
    if now == n:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    # 方法１　１つ飛ばす
    way1 = dfs(now + 1, a, b, c)
    # 方法２　合成魔法(MP10)
    way2 = dfs(now + 1, a + l[now], b, c)+10
    way3 = dfs(now + 1, a, b + l[now], c)+10
    way4 = dfs(now + 1, a, b, c + l[now])+10
    return min(way1, way2, way3, way4)


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


Fixed submission:
# C MP消費を抑えるにはABCとの差が小さけれは良い
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]
INF = 10**9


def dfs(now, a, b, c):
    if now == n:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    # 方法１　１つ飛ばす
    way1 = dfs(now + 1, a, b, c)
    # 方法２　合成魔法(MP10)
    way2 = dfs(now + 1, a + l[now], b, c)+10
    way3 = dfs(now + 1, a, b + l[now], c)+10
    way4 = dfs(now + 1, a, b, c + l[now])+10
    return min(way1, way2, way3, way4)


print(dfs(0, 0, 0, 0))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a%2==1 and b%2==1 and c%2==1:
  print('Yes')
else:
  print('No')

Fixed submission:
a,b=map(int,input().split())
if a%2==0 or b%2==0:
  print('No')
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a%2==1 and b%2==1 and c%2==1:
  print('Yes')
else:
  print('No')


Fixed submission:
a,b=map(int,input().split())
if a%2==0 or b%2==0:
  print('No')
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if (a%2==1 and b%2==1 and c%2==1):
  print('Yes')
else:
  print('No')

Fixed submission:
a,b=map(int,input().split())
if a%2==0 or b%2==0:
  print('No')
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if(a%2==0 and b%2==0 and c%2==0):
  print('Yes')
else:
  print('No')

Fixed submission:
a,b=map(int,input().split())
if a%2==0 or b%2==0:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
num = list(map(int, input().split()))
time = num[0] / num[2]
if time <= num[1]:
  print("Yes")
  else:
    print("No")



Fixed submission:

def resolve():
    num = list(map(int, input().split()))
    time = num[0] / num[2]
    if time <= num[1]:
        print("Yes")
    else:
        print("No")
resolve()

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

time = list[0] / list [2]

if time <= list[1]:
  print("Yes")
 else:
  print("No)

Fixed submission:

def resolve():
    num = list(map(int, input().split()))
    time = num[0] / num[2]
    if time <= num[1]:
        print("Yes")
    else:
        print("No")
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == "__main__":
	a, b, c, k = map(int, input().strip().split(' '))
	s = 0
	for i in range(k):
		if a > 0:
			s += 1
			a -= 1
		elif b > 0:
			b -= 1
		elif c > 0:
			s -= 1
			c -= 1
	print(s)

Fixed submission:
if __name__ == "__main__":
	a, b, c, k = map(int, input().strip().split(' '))
	s, i = 0, 0
	if k <= a:
		s = k
	elif k > a:
		s = a
		k -= a
		if k > b:
			k -= b
			s -= k
	print(s)

Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == "__main__":
	a, b, c, k = map(int, input().strip().split(' '))
	s = 0
	for i in range(k):
		if a > 0:
			s += 1
			a -= 1
		elif b > 0:
			b -= 1
		elif c > 0:
			s -= 1
			c -= 1
	print(s)

Fixed submission:
if __name__ == "__main__":
	a, b, c, k = map(int, input().strip().split(' '))
	s, i = 0, 0
	if k <= a:
		s = k
	elif k > a:
		s = a
		k -= a
		if k > b:
			k -= b
			s -= k
	print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
x = int(input())

a = -1
judge = True
while(judge):
    a += 1
    if(a**5 <= x):
        b = 0
        while(a**5 - b**5 <= x):
            if (a**5 - b**5 == x):
                judge = False
                print(a, b)
                sys.exit(0)
                break
            b -= 1
            # print('1', a, b)
    if(a**5 - (a-1)**5 < x):
        b = 0
        while(a**5 - b**5 >= x):
            if (a**5 - b**5 == x):
                judge = False
                print(a, b)
                sys.exit(0)
                break
            b += 1
            # print('2', a, b)
    # print(a)
    # a += 1
print(a, b)


Fixed submission:
import sys
import bisect
import numpy as np

x = int(input())
bs = [i for i in range(-100, 200)]
bspow = list(map(lambda x: x**5, bs))
# print(bspow)

for a in range(200):
    b_calc = a**5 - x
    index = bisect.bisect_left(bspow, b_calc)
    if(bspow[index] == b_calc):
        print(a, bs[index])
        sys.exit(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
height = list(map(int, input().split()))
ans = 0
m_height = max(height)
for i in range(n):
    for j in range(i+height[i], min(n, i+height[i] + 2 * m_height)):
        if(j-i == height[j] + height[i]):
            ans += 1
print(ans)


Fixed submission:
from collections import defaultdict

n = int(input())
height = list(map(int, input().split()))
ans = 0

d = defaultdict(int)

for i in range(n):
    x = i+height[i]
    d[x] += 1

for i in range(n):
    x = i-height[i]
    ans += d[x]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
height = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i+height[i]-1, n):
        if(j-i == height[j] + height[i]):
            ans += 1
print(ans)


Fixed submission:
from collections import defaultdict

n = int(input())
height = list(map(int, input().split()))
ans = 0

d = defaultdict(int)

for i in range(n):
    x = i+height[i]
    d[x] += 1

for i in range(n):
    x = i-height[i]
    ans += d[x]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
height = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i+1, n):
        if(j-i == height[j] + height[i]):
            ans += 1
print(ans)


Fixed submission:
from collections import defaultdict

n = int(input())
height = list(map(int, input().split()))
ans = 0

d = defaultdict(int)

for i in range(n):
    x = i+height[i]
    d[x] += 1

for i in range(n):
    x = i-height[i]
    ans += d[x]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
for i in range(len(s)):
    for j in range(i+4, len(s)+1):
        # print(int(s[i:j]))
        if(int(s[i:j]) % 2019 == 0):
            ans += 1
print(ans)


Fixed submission:
s = input()
ans = 0
tmp = 0
mods = [0]*2019
mods[0] = 1
order = 1
for i in reversed(s):
    tmp += int(i) * order
    mods[tmp % 2019] += 1
    order *= 10
    order %= 2019
ans = sum(n*(n-1)//2 for n in mods)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
l = list(map(int,input().split()))
ans = 0
for i in range n:
  if(l[i]>=k):
    ans += 1
print(ans)

Fixed submission:
n,k = map(int,input().split())
l = list(map(int,input().split()))
ans = 0
for i in range (n):
    if(l[i]>=k):
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

def pf(n):
    ans=[1]
    i=2
    while(n!=1):
        if (n%i==0):
            while(n%i==0):
                n=n/i
            ans.append(i)
        i+=1
    return ans

a,b = map(int,input().split())
pfa=pf(a)
pfb=pf(b)
ans=0
for i in pfa:
    if(i in pfb):
        ans+=1
print(ans)


Fixed submission:
import math

def pf(n):
    ans=[1]
    i=2
    if(n%i==0):
        while(n%2==0):
            n = n/i
        ans.append(i)
    i+=1
    while(i<math.sqrt(n) and n!=1):
        if (n%i==0):
            while(n%i==0):
                n=n/i
            ans.append(i)
        i+=2
    if(n!=1):
        ans.append(n)
    return set(ans)

a,b = map(int,input().split())
pfa=pf(a)
a=0
for i in pfa:
    if(b%i==0):
        a+=1
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
import math

def pf(n):
    ans=[1]
    i=2
    while(n!=1):
        if (n%i==0):
            while(n%i==0):
                n=n/i
            ans.append(i)
        i+=1
    return ans

a,b = map(int,input().split())
pfa=pf(a)
ans=0
for i in range (len(pfa)):
    if(b%pfa[i]==0):
        ans+=1
print(ans)


Fixed submission:
import math

def pf(n):
    ans=[1]
    i=2
    if(n%i==0):
        while(n%2==0):
            n = n/i
        ans.append(i)
    i+=1
    while(i<math.sqrt(n) and n!=1):
        if (n%i==0):
            while(n%i==0):
                n=n/i
            ans.append(i)
        i+=2
    if(n!=1):
        ans.append(n)
    return set(ans)

a,b = map(int,input().split())
pfa=pf(a)
a=0
for i in pfa:
    if(b%i==0):
        a+=1
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [int(input()) for i in range(n)]

for i in range(n):
    a=l[i]
    l.remove(a)
    #print(a,l)
    print(max(l))
    l.insert(i,a)


Fixed submission:
n = int(input())
l = [int(input()) for i in range(n)]
l_sorted = sorted(l)

for i in range(n):
    if l[i] == l_sorted[-1]:
        print(l_sorted[-2])
    else:
        print(l_sorted[-1])
Buggy python submission (verdict: Runtime Error):
#coding: utf-8
import numpy as np
n = int(input())
water = list(map(int,input().split()))

A = np.identity(n)
A += np.eye(n, k=1)
A[n-1][0] = 1

ans = np.linalg.solve(0.5*A,water)
print(" ".join(list(map(lambda x:str(int(x)),ans))))


Fixed submission:
#coding: utf-8
n = int(input())
water = list(map(int,input().split()))

sum_water = sum(water)
r_1 = sum_water
for i in range(1,int((n-1)/2+1)):
    r_1 -= water[2*i-1]*2
    #print(water[2*i])

ans = [r_1]
for i in range(n-1):
    ans.append(water[i]*2-ans[-1])
    #print(ans)

print(" ".join(map(lambda x:str(int(x)),ans)))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import statistics
import collections
n=int(input())
all_str=list(map(int,input().split()))
i=0
o_str=[]   # 0, ,2,
e_str=[]   #  ,1, ,3,
while(2*i+1<n):
  o_str.append(all_str[2*i])
  e_str.append(all_str[2*i+1])
  i+=1
o_mode=statistics.mode(o_str)
e_mode=statistics.mode(e_str)
if(o_mode!=e_mode):
  alt=len(all_str)-o_str.count(o_mode)-e_str.count(e_mode)
else:
  alt=min(o_str.count(o_mode),e_str.count(e_mode))
print(alt)

Fixed submission:
# coding: utf-8
import collections
n=int(input())
all_str=list(map(int,input().split()))
i=0
j=0
o_str=[]   # 0, ,2,
e_str=[]   #  ,1, ,3,
while(2*i<n):
  o_str.append(all_str[2*i])
  i+=1
while(2*j+1<n):
  e_str.append(all_str[2*j+1])
  j+=1

o_c=collections.Counter(o_str)
e_c=collections.Counter(e_str)
o_mode=o_c.most_common()[0][0]
e_mode=e_c.most_common()[0][0]
o_mode_n=o_str.count(o_mode)
e_mode_n=e_str.count(e_mode)
if(o_mode==e_mode):
  if(len(o_c)==1 and len(e_c)==1):
    if(o_mode_n>e_mode_n):
      e_mode_n=0
      
    else:
      
      o_mode_n=0
      
  else:
    if(len(o_c)==1):
      o_c_sec=0
      e_c_sec=e_c.most_common()[1][1]
    elif(len(e_c)==1):
      e_c_sec=0
      o_c_sec=o_c.most_common()[1][1]
    else:
      o_c_sec=o_c.most_common()[1][1]
      e_c_sec=e_c.most_common()[1][1]
    if(o_c_sec>e_c_sec):
      o_mode_n=o_c.most_common()[1][1]
    else:
      e_mode_n=e_c.most_common()[1][1]
alt=len(all_str)-o_mode_n-e_mode_n
print(alt)
Buggy python submission (verdict: Runtime Error):

#入力

N,M = map(int,input().split())

graph = [ ]
for _ in range(N+1):
    graph.append([])

for _ in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

visited = []
for _ in range(N+1):
    visited.append(False)


def dfs(dep,cur):
    global N,visited,graph

    if dep == N:
        ans += 1
        return 1

        ans = 0

    for dist in graph[cur]:
        if visited[dist] == False:
            visited[dist] = True
            ans += dfs(dep + 1,dist)
            visited[dist] = False
    return ans

 visited[1] = True
 dfs(1,1)
 print(ans)


Fixed submission:

#入力

N,M = map(int,input().split())

graph = [ ]
for _ in range(N+1):
    graph.append([])

for _ in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

visited = []
for _ in range(N+1):
    visited.append(False)


def dfs(dep,cur):
    global N,visited,graph

    if dep == N:
        return 1

    ans = 0

    for dist in graph[cur]:
        if visited[dist] == False:
            visited[dist] = True
            ans += dfs(dep + 1,dist)
            visited[dist] = False
    return ans

visited[1] = True
print(dfs(1,1))
Buggy python submission (verdict: Runtime Error):
import math as m

n = int(input())
q = int(m.sqrt(n))

for i in range(q,1,-1):
    if n%i == 0:
        k = i
        l = n/i
        break

print(int(k+l-2))



Fixed submission:
import math as m

n = int(input())
q = int(m.sqrt(n))

for i in range(q,0,-1):
    if n%i == 0:
        k = i
        l = int(n/i)
        break

print(int(k+l-2))