Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

n = int(input())
s = list(str(input()))

num_list = []
r, g, b = 0, 0, 0
for i in range(n-1, -1, -1):
    if s[i] == "R":
        r += 1
    elif s[i] == "G":
        g += 1
    elif s[i] == "B":
        b += 1
    num_list.append([r, g, b])

num_list.reverse()

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        rest_str = "B"
        dev = [s[i], s[j]]
        dev.sort()
        if ["B", "G"] == dev:
            rest_num = 0
            rest_str = "R"
        elif ["B", "R"] == dev:
            rest_num = 1
            rest_str = "G"
        elif ["G", "R"] == dev:
            rest_num = 2
            rest_str = "B"

        ans += num_list[j+1][rest_num]
        if j+j-i < n:
            if s[j+j-i] == rest_str:
                ans -= 1

print(ans)


Fixed submission:
#!/usr/bin/env python3

n = int(input())
s = list(str(input()))

num_list = []
r, g, b = 0, 0, 0
for i in range(n-1, -1, -1):
    if s[i] == "R":
        r += 1
    elif s[i] == "G":
        g += 1
    elif s[i] == "B":
        b += 1
    num_list.append([r, g, b])

num_list.reverse()

ans = 0
for i in range(n-2):
    if s[i] == "R":
        ans += num_list[i+1][1] * num_list[i+1][2]  # G , B
        for j in range(0, (n-i-1)//2):
            a, b, c = i, j+i+1, j+j+i+2
            # print(a, b, c)
            if {s[b], s[c]} == {"G", "B"}:
                ans -= 1
    if s[i] == "G":
        ans += num_list[i+1][0] * num_list[i+1][2]  # R, B
        for j in range(0, (n-i-1)//2):
            a, b, c = i, j+i+1, j+j+i+2
            # print(a, b, c)
            if {s[b], s[c]} == {"R", "B"}:
                ans -= 1
    if s[i] == "B":
        ans += num_list[i+1][0] * num_list[i+1][1]  # R, G
        for j in range(0, (n-i-1)//2):
            a, b, c = i, j+i+1, j+j+i+2
            # print(a, b, c)
            if {s[b], s[c]} == {"R", "G"}:
                ans -= 1
# print(num_list)
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

a = int(input())
a, b = map(int, input().split())
a = list(str(input()))


Fixed submission:
#!/usr/bin/env python3

a, b, c = map(int, input().split())
print("{} {} {}".format(c, a, b))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

a = int(input())
a, b = map(int, input().split())
a = list(str(input()))


Fixed submission:
#!/usr/bin/env python3

a, b, c = map(int, input().split())
print("{} {} {}".format(c, a, b))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

a = int(input())
a, b = map(int, input().split())
a = list(str(input()))


Fixed submission:
#!/usr/bin/env python3

a, b, c = map(int, input().split())
print("{} {} {}".format(c, a, b))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

a = int(input())
a, b = map(int, input().split())
a = list(str(input()))


Fixed submission:
#!/usr/bin/env python3

import numpy as np
N, M = map(int, input().split())
A = list(map(int, input().split()))

A = np.array(A)

num = np.sum(A >= np.sum(A)/(4*M))

if num >= M:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import collections

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

c = collections.Counter(A)
values = c.keys()
counts = c.values()


ans = 0
for i in range(len(values)):
    tmp = counts[i]
    ans += (tmp * (tmp-1))//2

for i in range(N):
    num = A[i]
    index = values.index(num)
    print(ans - counts[index] + 1)


Fixed submission:
#!/usr/bin/env python3

import collections

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

c = collections.Counter(A)
values = c.keys()
counts = c.values()

subs = {}
a_sum = 0
for v, c in zip(values, counts):
    subs[v] = c
    a_sum += (c * (c-1)) // 2

for i in range(N):
    print(a_sum - subs[A[i]] + 1)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import collections

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

c = collections.Counter(A)
values, counts = c.keys(), c.values()

ans = 0
for i in range(len(values)):
    tmp = counts[i]
    ans += (tmp * (tmp-1))//2

for i in range(N):
    num = A[i]
    index = values.index(num)
    print(ans - counts[index] + 1)


Fixed submission:
#!/usr/bin/env python3

import collections

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

c = collections.Counter(A)
values = c.keys()
counts = c.values()

subs = {}
a_sum = 0
for v, c in zip(values, counts):
    subs[v] = c
    a_sum += (c * (c-1)) // 2

for i in range(N):
    print(a_sum - subs[A[i]] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import collections

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

c = collections.Counter(A)
values, counts = zip(*c.most_common())

ans = 0
for i in range(len(values)):
    tmp = counts[i]
    ans += (tmp * (tmp-1))//2

for i in range(N):
    num = A[i]
    index = values.index(num)
    print(ans - counts[index] + 1)


Fixed submission:
#!/usr/bin/env python3

import collections

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

c = collections.Counter(A)
values = c.keys()
counts = c.values()

subs = {}
a_sum = 0
for v, c in zip(values, counts):
    subs[v] = c
    a_sum += (c * (c-1)) // 2

for i in range(N):
    print(a_sum - subs[A[i]] + 1)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import numpy as np

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

unique_array = np.unique(A, return_counts=True)

ans = 0
for i in range(len(unique_array[0])):
    tmp = unique_array[1][i]
    ans += (tmp * (tmp-1))//2


for i in range(N):
    num = A[i]
    index = np.where(unique_array[0] == num)[0]
    print(ans - unique_array[1][index][0] + 1)


Fixed submission:
#!/usr/bin/env python3

import collections

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

c = collections.Counter(A)
values = c.keys()
counts = c.values()

subs = {}
a_sum = 0
for v, c in zip(values, counts):
    subs[v] = c
    a_sum += (c * (c-1)) // 2

for i in range(N):
    print(a_sum - subs[A[i]] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
# B
N, A, B = map(int, input().split())

def main():
    countb = 0
    count = 0
    while(1):
        for i in range(A):
            count+=1
            countb+=1
            if count >=N:
                return countb
        for i in range(B):
            count+=1
            if count >=N:
                return countb
a = main()

print(a)

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

num = N // (A+B) * A
amari = N % (A+B)
num += min(amari, A)

print(num)
Buggy python submission (verdict: Runtime Error):
# C
import numpy as np
N = int(input())
X = np.array(list(map(int, input().split())))

P_floor = math.floor(np.sum(X)/N)
P_ceil = math.ceil(np.sum(X)/N)

ans = min(np.sum((X-P_floor)**2), np.sum((X-P_ceil)**2))

print(ans)

Fixed submission:
import numpy as np
import math
N = int(input())
X = np.array(list(map(int, input().split())))

P_floor = math.floor(np.sum(X)/N)
P_ceil = math.ceil(np.sum(X)/N)

ans = min(np.sum((X-P_floor)**2), np.sum((X-P_ceil)**2))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# D
import numpy as np

N, K = list(map(int, input().split()))
p = np.array(list(map(int, input().split())))

ans = 0
for i in range(0, N-K+1):
    ans_tmp = np.sum(p[i:i+K])
    ans = max(ans, ans_tmp)

ans = (ans+K)/2

print(ans)

Fixed submission:
# D

N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

ans = sum(p[0:K])
ans_tmp = ans
for i in range(K, N):
#    print(p)
#    print(-p[i-K] + p[K])
    ans_tmp = ans_tmp - p[i-K] + p[i]
#    print(ans_tmp)
    ans = max(ans, ans_tmp)

ans = (ans+K)/2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# D
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

# for i in range(N):
#     p[i] = (1+p[i])/2

ans = 0
# ans_index = 0
for i in range(0, N-K+1):
    ans_tmp = sum(p[i:i+K])
    ans = max(ans, ans_tmp)
#         ans_index = i

ans = (ans+K)/2

print(ans)

Fixed submission:
# D

N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

ans = sum(p[0:K])
ans_tmp = ans
for i in range(K, N):
#    print(p)
#    print(-p[i-K] + p[K])
    ans_tmp = ans_tmp - p[i-K] + p[i]
#    print(ans_tmp)
    ans = max(ans, ans_tmp)

ans = (ans+K)/2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# D
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

for i in range(N):
    p[i] = (1+p[i])/2

ans = 0
for i in range(0, N-K+1):
    ans_tmp = sum(p[i:i+K])
    ans = max(ans, ans_tmp)
    
print(ans)


Fixed submission:
# D

N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

ans = sum(p[0:K])
ans_tmp = ans
for i in range(K, N):
#    print(p)
#    print(-p[i-K] + p[K])
    ans_tmp = ans_tmp - p[i-K] + p[i]
#    print(ans_tmp)
    ans = max(ans, ans_tmp)

ans = (ans+K)/2

print(ans)
Buggy python submission (verdict: Runtime Error):
# D
def touhi(a,r,n):
    return a*(pow(r, n) - 1)//(r-1)
  
H = int(input()) 
n = math.floor(math.log2(H))+1
print(touhi(a=1, r=2, n=n))

Fixed submission:
import math
def touhi(a,r,n):
    return a*(pow(r, n) - 1)//(r-1)
H = int(input()) 
n = math.floor(math.log2(H))+1
print(touhi(a=1, r=2, n=n))
Buggy python submission (verdict: Runtime Error):
# E
import fractions
N = int(input()) 
A = list(map(int, input().split()))

def main():
    value = A[0]
    for i in range(1, N):
        value = value * A[i] // fractions.gcd(value, A[i])

    z = 10**9+7
    ans = 0
    for i in A:
        ans += (value//i) % z

    print(ans % z)

if __name__=="__main__":
    main()

Fixed submission:
N = int(input()) 

ans=0
d = [10*[0] for _ in range(10)]

for i in range(1, N+1):
    s = str(i)
    if s[0]=="0" or s[-1]=="0":
        continue
    d[int(s[0])][int(s[-1])]+=1
    
for i in range(10):
    for j in range(10):
        ans+=d[i][j]*d[j][i]
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

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

flag = [0 for _ in range(n)]
wa_num_list = [0 for _ in range(n)]

for i in range(m):
    p, s = list(map(str, input().split()))
    p = int(p)
    if flag[p-1] == 0:
        if s == "WA":
            wa_num_list[p-1] += 1
        else:
            flag[p-1] = 1

pen = 0
for i in range(m):
    if flag[i] == 1:
        pen += wa_num_list[i]

print(sum(flag), pen)


Fixed submission:
#!/usr/bin/env python3

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

flag = [0 for _ in range(n)]
wa_num_list = [0 for _ in range(n)]

for i in range(m):
    p, s = list(map(str, input().split()))
    p = int(p)
    if flag[p-1] == 0:
        if s == "WA":
            wa_num_list[p-1] += 1
        else:
            flag[p-1] = 1

pen = 0
for i in range(n):
    if flag[i] == 1:
        pen += wa_num_list[i]

print(sum(flag), pen)
Buggy python submission (verdict: Runtime Error):
# D
def perm(N, k):
    a = 1
    for i in range(int(k)):
        a*=N
        N-=1
        return a
from math import factorial
# from math import perm

tmp = list(map(int, input().split()))
X = tmp[0]
Y = tmp[1]

x = (2*Y-X)/3
y = (2*X-Y)/3

if not x.is_integer():
    print(0)
elif not y.is_integer():
    print(0)
else:
    if x>y:
        denominator = perm(x+y, x)%(10**9+7)
        numerator = factorial(y)%(10**9+7)
        tmp = denominator//numerator
        print(int(tmp))
    else:
        denominator = perm(x+y, y)%(10**9+7)
        numerator = factorial(x)%(10**9+7)
        tmp = denominator//numerator
        print(int(tmp))

Fixed submission:
#!/usr/bin/env python3

import math

mod = 10**9+7

x, y = list(map(int, input().split()))

# dp = [[0]*(y+1) for _ in range(x+1)]
# dp[0][0] = 1
# for x_tmp in range(1, x+1):
#     for y_tmp in range(1, y+1):
#         print(x_tmp, y_tmp)

#         if x_tmp-2 >= 0 and y_tmp-1 >= 0:
#             dp[x_tmp][y_tmp] += dp[x_tmp-2][y_tmp-1] % mod
#         if x_tmp-1 >= 0 and y_tmp-2 >= 0:
#             dp[x_tmp][y_tmp] += dp[x_tmp-1][y_tmp-2] % mod

# print(dp[-1][-1] % mod)


def comb(n, r):
    X = Y = 1
    if r < 0 or n < r:
        return 0
    if r == 0:
        return 1
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % mod
        X = X*(n-i+1) % mod
    Y = pow(Y, mod-2, mod)
    return X*Y


if (x+y) % 3 != 0:
    print(0)
    exit()

num = min(x, y)-(x+y)//3
if num < 0:
    print(0)
    exit()

# print((x+y)//3, num)
print(comb((x+y)//3, num) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import bisect

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

a.sort()
for i in range(m):
    value = a.pop()
    value //= 2
    insert_index = bisect.bisect_left(a, value)

    a.insert(insert_index, value)
print(sum(a))


Fixed submission:
#!/usr/bin/env python3
import heapq
# import bisect

n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(a)
for i in range(m):
    value = heapq.heappop(a)
    value = (value+1)//2
    heapq.heappush(a, value)

# print(a)
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import bisect

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

a.sort()
for i in range(m):
    value = a.pop()
    value //= 2
    insert_index = bisect.bisect_left(a, value)

    a.insert(insert_index, value)
print(sum(a))


Fixed submission:
#!/usr/bin/env python3
import heapq
# import bisect

n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(a)
for i in range(m):
    value = heapq.heappop(a)
    value = (value+1)//2
    heapq.heappush(a, value)

# print(a)
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
# D
N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(M):
    A[A.index(max(A))] //=2
    
print(sum(A))

Fixed submission:
#!/usr/bin/env python3
import heapq
# import bisect

n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(a)
for i in range(m):
    value = heapq.heappop(a)
    value = (value+1)//2
    heapq.heappush(a, value)

# print(a)
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
# D
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)

for i in range(M):
    A[0] = A[0]//2
    
    if N!=1:
        for i in range(N-1):
            if A[i+1]>A[i]:
                tmp = A[i+1]
                A[i+1] = A[i]
                A[i] = tmp
            else:
                break
print(sum(A))

Fixed submission:
#!/usr/bin/env python3
import heapq
# import bisect

n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(a)
for i in range(m):
    value = heapq.heappop(a)
    value = (value+1)//2
    heapq.heappush(a, value)

# print(a)
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
# D
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

for i in range(M):
    A[-1] = A[-1]//2
    A.sort()
print(sum(A))

Fixed submission:
#!/usr/bin/env python3
import heapq
# import bisect

n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(a)
for i in range(m):
    value = heapq.heappop(a)
    value = (value+1)//2
    heapq.heappush(a, value)

# print(a)
print(-sum(a))
Buggy python submission (verdict: Runtime Error):

A = [0]*(len(B)+1)

A[0] = B[0]
for i in range(len(B)):
    if A[i]>=B[i]:
        A[i]=B[i]
    A[i+1]=B[i]
print(sum(A))

Fixed submission:
N = int(input())
B = list(map(int, input().split()))
A = [0]*(len(B)+1)

A[0] = B[0]
for i in range(len(B)):
    if A[i]>=B[i]:
        A[i]=B[i]
    A[i+1]=B[i]
print(sum(A))
Buggy python submission (verdict: Runtime Error):
v = list(map(int, input().split()))
v.sort()

while(len(v)!=2):
    v += [(v.pop(0)+v.pop(0))/2]
    v.sort()
print(sum(v)/2)

Fixed submission:
# C
N = int(input())
v = list(map(int, input().split()))
v.sort()

while(len(v)!=2):
    v += [(v.pop(0)+v.pop(0))/2]
    v.sort()
print(sum(v)/2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
    S_tmp = str(input())
    S_tmp = list(S_tmp)
    S_tmp.sort()
    S.append("".join(S_tmp))

count=0
for i in range(len(S) - 1):
    for j in range(i+1, len(S)):
        if S[i]==S[j]:
            count+=1
print(count)

Fixed submission:
import math

N = int(input())
S = []
for i in range(N):
    S_tmp = str(input())
    S_tmp = list(S_tmp)
    S_tmp.sort()
    S.append("".join(S_tmp))
S.sort()

count=0
x = 0
tmp = S[0]
count_all = []
for i in S[1:]:
    if tmp==i:
        count+=1
    else:
        if count>0:
            x += math.factorial(count+1)//(math.factorial(count+1-2) * math.factorial(2))
        count = 0
    tmp = i
if count>0:
    x += math.factorial(count+1)//(math.factorial(count+1-2) * math.factorial(2))
        
    tmp = i
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
    S_tmp = str(input())
    S_tmp = list(S_tmp)
    S_tmp.sort()
    S.append(S_tmp)

count=0
for i in range(len(S) - 1):
    for j in range(i+1, len(S)):
        if S[i]==S[j]:
            count+=1
print(count)

Fixed submission:
import math

N = int(input())
S = []
for i in range(N):
    S_tmp = str(input())
    S_tmp = list(S_tmp)
    S_tmp.sort()
    S.append("".join(S_tmp))
S.sort()

count=0
x = 0
tmp = S[0]
count_all = []
for i in S[1:]:
    if tmp==i:
        count+=1
    else:
        if count>0:
            x += math.factorial(count+1)//(math.factorial(count+1-2) * math.factorial(2))
        count = 0
    tmp = i
if count>0:
    x += math.factorial(count+1)//(math.factorial(count+1-2) * math.factorial(2))
        
    tmp = i
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
        if z==1:
            break
    
print(minimum)

Fixed submission:
L, R = map(int, input().split())

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
    if z==1:
        break
    
print(minimum)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
        if z==1:
            break
    
print(minimum)

Fixed submission:
L, R = map(int, input().split())

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
    if z==1:
        break
    
print(minimum)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
L, R = map(int, input().split())

minimum=2019
for i in range(L, R):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            continue
    if minimum==0:
        continue
print(minimum)


Fixed submission:
L, R = map(int, input().split())

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
    if z==1:
        break
    
print(minimum)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
L, R = map(int, input().split())

minimum=2019
for i in range(L, R):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
    if minimum==0:
        continue
print(minimum)

Fixed submission:
L, R = map(int, input().split())

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
    if z==1:
        break
    
print(minimum)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

minimum=2019
for i in range(L, R):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp

print(minimum)

Fixed submission:
L, R = map(int, input().split())

minimum=2019
z=0
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if minimum>tmp:
            minimum = tmp
        if minimum==0:
            z=1
            break
    if z==1:
        break
    
print(minimum)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
# 整数の入力
N = int(input())
A = [int(input()) for _ in range(N)]

sum_water = sum(A)
A = A[1:] + A[0:N-2]
for i in range(N):
    tmp=sum_water
    for j in range((N-1)//2):
        tmp-=A[i+j*2]*2
    print(tmp, end="")
    print(" ", end="")

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

sum_water = sum(A)

tmp=sum_water
for j in range((N-1)//2):
    tmp-=A[j*2+1]*2
print(tmp, end="")
print(" ", end="")

for i in A[:-1]:
    tmp = 2*i - tmp
    print(tmp, end="")
    print(" ", end="")

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

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

sum_water = sum(A)
A = A[1:] + A[0:N-2]
for i in range(N):
    tmp=sum_water
    for j in range((N-1)//2):
        tmp-=A[i+j*2]*2
    print(tmp, end="")
    print(" ", end="")
# for i in range(len(X)-1):
#     print(X[i], end="")
#     print(" ", end="")
# print(X[-1])

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

sum_water = sum(A)

tmp=sum_water
for j in range((N-1)//2):
    tmp-=A[j*2+1]*2
print(tmp, end="")
print(" ", end="")

for i in A[:-1]:
    tmp = 2*i - tmp
    print(tmp, end="")
    print(" ", end="")

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

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

sum_water = sum(A)
A = A[1:] + A[0:N-2]
X = []
for i in range(N):
    tmp=sum_water
    for j in range((N-1)//2):
        tmp-=A[i+j*2]*2
    X.append(tmp)
for i in range(len(X)-1):
    print(X[i], end="")
    print(" ", end="")
print(X[-1])

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

sum_water = sum(A)

tmp=sum_water
for j in range((N-1)//2):
    tmp-=A[j*2+1]*2
print(tmp, end="")
print(" ", end="")

for i in A[:-1]:
    tmp = 2*i - tmp
    print(tmp, end="")
    print(" ", end="")

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

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

sum_water = sum(A)
A = A[1:] + A[0:3]
X = []
for i in range(N):
    tmp=sum_water
    for j in range((N-1)//2):
        tmp-=A[i+j*2]*2
    X.append(tmp)
for i in range(len(X)-1):
    print(X[i], end="")
    print(" ", end="")
print(X[-1])

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

sum_water = sum(A)

tmp=sum_water
for j in range((N-1)//2):
    tmp-=A[j*2+1]*2
print(tmp, end="")
print(" ", end="")

for i in A[:-1]:
    tmp = 2*i - tmp
    print(tmp, end="")
    print(" ", end="")