Problem:


Score : 400 points

Problem Statement

There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an odd number.

Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).

When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).

One day, each of the mountains received a non-negative even number of liters of rain.

As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.

Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Constraints

All values in input are integers.

3 \leq N \leq 10^5-1

N is an odd number.

0 \leq A_i \leq 10^9

The situation represented by input can occur when each of the mountains receives a non-negative even number of liters of rain.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print N integers representing the number of liters of rain Mountain 1, Mountain 2, ..., Mountain N received, in this order.

Sample Input 1

3
2 2 4

Sample Output 1

4 0 4

If we assume Mountain 1, 2, and 3 received 4, 0, and 4 liters of rain, respectively, it is consistent with this input, as follows:

Dam 1 should have accumulated \frac{4}{2} + \frac{0}{2} = 2 liters of water.

Dam 2 should have accumulated \frac{0}{2} + \frac{4}{2} = 2 liters of water.

Dam 3 should have accumulated \frac{4}{2} + \frac{4}{2} = 4 liters of water.

Sample Input 2

5
3 8 7 5 5

Sample Output 2

2 4 12 2 8

Sample Input 3

3
1000000000 1000000000 0

Sample Output 3

0 2000000000 0



Sample input:
3
2 2 4


Sample output:
4 0 4

Submission status: Wrong Answer

Solution code:
n = int(raw_input())

x =  map(int, raw_input().split())

s = sum(x)

ans = []
for i in range(n):
  ans.append(s-int(2*x[i]))
first = ans.pop(0)
ans.insert(-1, first)
print ' '.join(map(str, ans))

Submission status: Wrong Answer

Solution code:
n = int(raw_input())

x =  map(int, raw_input().split())

s = sum(x)

ans = []
for i in range(n):
  ans.append(s-int(2*x[i]))
print ' '.join(map(str, ans))

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = sum([dams[x]*(-1)**x for x in range(n)])
out = str(ans)

ansList = [0 for x in range(n)]

ansList[0] = ans

for i in range(1, n):
  ans = -1 * ans + 2 * dams[i - 1]
  ansList[i] = ans
  
print(out)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

odd = sum([dams[x]*(-1)**x for x in range(n)])
even = sum([-1 * dams[x]*(-1)**x for x in range(n)])
out = str(odd)
origin = {
  0: odd,
  1: even
}

for i in range(1, n):
  ans = origin[i%2] + 2 * dams[i]
  out += " " + str(ans)
  
print(out)

Submission status: Wrong Answer

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

x = [0]*N

for i in range(N):
    if i % 2 == 0:
        x[0] += A[i-(i+1)]
    else:
        x[0] -= A[i-(i+1)]

for i in range(1,N):
    x[i] = int( 2 * ( A[i-1] - x[i-1] / 2 ) )

for i in range(N):
    print(str(x[i]), end="")
    if i != N-1:
        print(" ", end="")

Submission status: Wrong Answer

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

rain = [0] * N
for i in range(N):
    if (i > 0 or A[i - 1] != A[i]) :
        rain[i] += A[i] * 2

for i in range(0, N):
    if (i == 0):
        for i in range(1, N):
            rain[0] += rain[i] * ((-1) ** i)
        rain[0] = int(rain[0] / 2)
    else:
        temp = 0
        count = 2
        for j in range(i, N):
            temp += rain[j] * ((-1) ** count)
            count += 1
            
        temp += rain[0] * ((-1) ** (N - i))
        rain[i] = int(temp)
        

print(" ".join(map(str, rain)))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
X = [0] * N
sum_A = sum(A)
sum_subA = 0
for i in range(1, N, 2):
    sum_subA += 2 * A[i]
X[0] = sum_A - sum_subA
for i in range(1, N):
    X[i] = 2 * A[i - 1] - X[i-1]
print(X)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
X = []

x0 = sum(A)
for i in range(1,N-1,2):
    x0 = x0-2*A[i]
X.append(x0)

for i in range(N-1):
    X.append(2*A[i]-X[i])
    
print(X)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
rain_sum = sum(A) // 2
rain_other = 0
for i in range((N - 1) // 2):
    rain_other += A[(i + 1 + 2 * i) % N]
rain_before = (rain_sum - rain_other) * 2
print(rain_before, end = ' ')
for i in range(N - 1):
    rain_before = 2 * A[i] - rain_before
    print(rain_before, end = ' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
rain_sum = sum(A) // 2
rain_other = 0
for i in range((N - 1) // 2):
    rain_other += A[(i + 1 + 2 * i) % N]
rain_before = (rain_sum - rain_other) * 2
print(rain_before, end = ' ')
for i in range(N - 1):
    rain_before = A[i] - rain_before
    print(rain_before, end = ' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B1 = 0
B = []
for i in range(0,N):
    if i%2 == 0:
        B1 += A[i]
    else:
        B1 -= A[i]
B.append(B1)
XX = B1
for i in range (0,N-1) :
    X = 2*A[i]-XX
    B.append(X)
    XX = X
print(B)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B1 = 0
B = []
for i in range(0,N):
    if A[i]%2 == 1:
        B1 += A[i]
    else:
        B1 -= A[i]
B.append(B1)
XX = B1
for i in range (0,N-1) :
    X = 2*A[i]-XX
    B.append(X)
    XX = X
for i in range(0,N):
    print(B[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B1 = 0
B = []
for i in range(0,N):
    if A[i]%2 == 1:
        B1 += A[i]
    else:
        B1 -= A[i]
B.append(B1)
XX = B1
for i in range (0,N-1) :
    X = 2*A[i]-XX
    B.append(X)
    XX = X
print(B)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
X = [0]*N
sum = 0
sum_A = 0

# 合計を求める
for i in range(N-1):
    sum = sum + A[i]

# A2からAN-1の合計を求める
for i in range(1, N-2):
    sum_A = sum_A + A[i]

#X1を求める
X[0] = sum - 2*sum_A

#X1を使ってXk+1を求める
for i in range(1, N):
    X[i] = 2 * (A[i-1]-X[i-1]/2)

#出力
for i in range(N):
    print(int(X[i]), end=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
answer = [0] * N

totalRain = sum(A)

answer[0] = totalRain
print(answer[0])
for i in range(1,N-1,2):
    answer[0]-=A[i]*2
print(answer[0])


for i in range(N-1):
    if i+1 != N:
        answer[i+1] = (A[i]*2) - answer[i]

print(answer[0], end="")
for i in range(1, N):
    print("",answer[i], end="")
print("")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
answer = [0] * N

totalRain = sum(A)

answer[0] = totalRain
print(answer[0])
for i in range(1,N-1,2):
    answer[0]-=A[i]*2
print(answer[0])


for i in range(N-1):
    if i+1 != N:
        answer[i+1] = (A[i]*2) - answer[i]

print(answer[0], end="")
for i in range(1, N):
    print("",answer[i], end="")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
answer = [0] * N

totalRain = sum(A)

answer[0] = totalRain
for i in range(1,N-1):
    answer[0]-=A[i]*2


for i in range(1, N-1):
    if i+1 != N:
        answer[i+1] = (A[i]*2) - answer[i]

print(answer[0], end="")
for i in range(1, N):
    print("",answer[i], end="")

Submission status: Wrong Answer

Solution code:
# D - Rain Flows into Dams

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

X = [-1 for _ in range(N)]

def get_next(n, i):
	if n+i>=N: return n+i-N
	else: return n+i


for x0 in range(0, 2*min(A[0],A[1])+1, 2):
	X[0] = x0
	for n in range(0,N-1):
		X0 = X[n]
		A0 = A[n]
		X1 = (A0 - X0//2)*2

		X[n+1] = X1
		
		if X1<0:
			break

		
	if X[0] + X[N-1] == A[N-1]*2:
		break 

X = map(str, X)
print(" ".join(X))

Submission status: Wrong Answer

Solution code:
# D - Rain Flows into Dams

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

X = [-1 for _ in range(N)]

def get_next(n, i):
	if n+i>=N: return n+i-N
	else: return n+i


for x0 in range(0, 2*min(A[0],A[1])+1, 2):
	X[0] = x0
	for n in range(0,N-1):
		X0 = X[n]
		A0 = A[n]
		X1 = (A0 - X0//2)*2

		X[n+1] = X1
		
		if X1<0:
			break

		
	if X[0] + X[N-1] == A[N-1]*2:
		break 

print(X)

Submission status: Wrong Answer

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

Kosui = [0]*N

for i in range(N):
	Kosui[0] += A[i]*(-1)**i

for i in range(N-1):
	Kosui[i+1] = (A[i] - (Kosui[i]//2))*2

print(Kosui)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(n):
  b[i + 1] = a[i] - b[i]
x = b[-1] / 2
for i in range(n):
  if i & 1 == 1:
    b[i] -= x
  else:
    b[i] += x
  b[i] *= 2
print(" ".join(map(str, b[:-1])))

Submission status: Wrong Answer

Solution code:
import sys
n = int(sys.stdin.readline())
a = list(map(int,sys.stdin.readline().split()))
water = [0]*n
cur = min(a[0],a[-1])
water[0]=2*min(a[0],a[-1])
dams=cur
i = n-1
while(i!=0):
    need = a[i] - cur
    water[i] = need * 2
    cur = need
    i -= 1
v = cur+dams
# print('v',v,dams)
if v!=a[0]:
    water[0] = abs(water[0]-(2*cur))
    cur = water[0] // 2
    i = n - 1
    while (i != 0):
        need = a[i] - cur
        water[i] = need * 2
        cur = need
        i -= 1
print(*water)

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    Tentative = [0] * N
    for i in range(N-1):
        Tentative[i+1] += A[i] - Tentative[i]
        Tentative[i] *= 2
    Tentative[N-1] *= 2
    dam = (Tentative[0] + Tentative[N-1])//2
    diff = A[N-1] - dam
 
    if diff != 0:
        diffclock, diffanticlock = diff, diff
        for i in range(N//2):
            Tentative[i] += diffclock
            diffclock = 2 * (A[i] - (Tentative[i] + Tentative[i+1]) // 2)
            Tentative[N-1-i] += diffanticlock
            diffanticlock = 2 * (A[N-1-i] - (Tentative[N-1-i] + Tentative[N-2-i])//2)
        Tentative[N//2] += diffclock

    print(" ".join(map(str, Tentative)))
 
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

n=int(input())
ls=list(map(int,input().split()))
ms=[]

#最初の山の値を求める
for i in range(0,10**9,2):
    x=i
    for j in range(n):
        x=(ls[j]-x//2)*2
    if x==0:
        ms.append(i//2)
        break

for i in range(n-1):
    ms.append((ls[i]-ms[-1]//2)*2)
print(ms)

Submission status: Wrong Answer

Solution code:
import sys
n = int(sys.stdin.readline())
a = list(map(int,sys.stdin.readline().split()))
water = [0]*n
cur = min(a[0],a[-1])
water[0]=2*min(a[0],a[-1])
dams=cur
i = n-1
while(i!=0):
    need = a[i] - cur
    water[i] = need * 2
    cur = need
    i -= 1
v = cur+dams
if v!=a[0]:
    if v>a[0]:
        water[0]-=cur
        cur=water[0]//2
        i=n-1
    else:
        water[0]+= a[0]-(cur+dams)
        cur = water[0] // 2
        i = n - 1
    while (i != 0):
        need = a[i] - cur
        water[i] = need * 2
        cur = need
        i -= 1
print(*water)

Submission status: Wrong Answer

Solution code:
import sys
n = int(sys.stdin.readline())
a = list(map(int,sys.stdin.readline().split()))
water = [0]*n
cur = min(a[0],a[-1])
water[0]=2*min(a[0],a[-1])
dams=cur
i = n-1
while(i!=0):
    need = a[i] - cur
    water[i] = need * 2
    cur = need
    i -= 1
if cur+dams!=a[0]:
    water[0]-=cur
    cur=water[0]//2
    i=n-1
    while (i != 0):
        need = a[i] - cur
        water[i] = need * 2
        cur = need
        i -= 1
print(*water)

Submission status: Wrong Answer

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

x = [None] * N
x[0] = sum(A) - sum([a for a in A[2::2]])
for i in range(N-1):
    x[i+1] = 2 * A[i] - x[i]
print(" ".join(map(str, x)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
setA = set()
water = [0]*n
dams = [0]*n
cur = min(a[0],a[-1])
water[0]=2*min(a[0],a[-1])
dams[0]=cur
i = n-1
while(1):
    if i==0:
        if dams[0]+cur== a[0]:
            break
        else:
            water[0]=cur
            dams[0]=cur//2
            cur = dams[0]
            i=n-1
    else:
        need = a[i]-cur
        water[i]= need*2
        cur=need
        i-=1
print(*water)

Submission status: Wrong Answer

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

x = [None] * N
x[0] = 2 * (A[0] + A[-1]) - sum(A)
for i in range(N-1):
    x[i+1] = 2 * A[i] - x[i]
print(" ".join(map(str, x)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(n):
  b[i + 1] = a[i] - b[i]
for i in range(n):
  if i & 1 == 1:
    b[i] -= b[-1]
  else:
    b[i] += b[-1]
  b[i] *= 2
print(" ".join(map(str, b[:-1])))

Submission status: Wrong Answer

Solution code:
n = int(input())
dam = list(map(int,input().split()))
yama =[0]*n
sum_dam = sum(dam)
dam2 = dam[0]*2
for kari in range(0,dam2,2):
  yama[0] = kari
  for i in range(1,n):
    yama[i] = (dam[i-1] - (yama[i-1] // 2))*2
    if yama[i] < 0:
      break
  if sum(yama) == sum_dam:
    joined = " ".join(map(str, yama))
    print(joined)
    break

Submission status: Wrong Answer

Solution code:
n = int(input())
dam = list(map(int,input().split()))
yama =[0]*n
sum_dam = sum(dam)
for kari in range(0,sum_dam,2):
  yama[0] = kari
  for i in range(1,n):
    yama[i] = (dam[i-1] - (yama[i-1] // 2))*2
    if yama[i] < 0:
      break
  if sum(yama) == sum_dam:
    joined = " ".join(map(str, yama))
    print(joined)
    break

Submission status: Wrong Answer

Solution code:
n = int(input())
dam = list(map(int,input().split()))
yama =[0]*n
sum_dam = sum(dam)
for kari in range(0,sum_dam):
  yama[0] = kari
  for i in range(1,n):
    yama[i] = (dam[i-1] - (yama[i-1] // 2))*2
    if yama[i] < 0:
      break
  if sum(yama) == sum(dam):
    joined = " ".join(map(str, yama))
    print(joined)
    break

Submission status: Wrong Answer

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

#print(A[0], A[-1])
x1 = sum(A) - 2 * (sum(A) - int(A[0]) - int(A[-1]))

x = []
x.append(x1)
for i in range(N-1):
    x.append(2 * A[i] - x[i])

print(' '.join(map(str, x)))

Submission status: Wrong Answer

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

print(A[0], A[-1])
x1 = sum(A) - 2 * (sum(A) - int(A[0]) - int(A[-1]))

x = []
x.append(x1)
for i in range(N-1):
    x.append(2 * A[i] - x[i])

print(' '.join(map(str, x)))

Submission status: Wrong Answer

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

print(A[0], A[-1])
x1 = sum(A) - 2 * (sum(A) - int(A[0]) - int(A[-1]))

x = []
x.append(x1)
for i in range(N-1):
    x.append(2 * A[i] - x[i])

print(x)

Submission status: Wrong Answer

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

x1 = sum(A) - 2 * sum(A[1::2])
print(A[1::2])
print(x1, end=' ')
for i in range(N-1):
    x1 = 2 * A[i] - x1
    print(x1, end=' ')
print()

Submission status: Wrong Answer

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

x1 = sum(A) - 2 * sum(A[1::2])
print(A[1::2])
print(x1, end=' ')
for i in range(N-1):
    x1 = 2 * A[i] - x1
    print(x1, end=' ')

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = sum(A) - 2 * sum(A[i] for i in range(1, N, 2))
    ans = [x]
    for i in range(N - 1):
        x = 2 * A[i] - x
        ans.append(x)
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
# ABC133 D-Rain flows into dams

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

X = [0]*(N+1) # ふった雨の量を入れるリスト
S = sum(A)
X[0] = S - 2*(sum(A[1::2]))
X[N] = X[0]
for i in range(N):
    if i == 0:
        continue
    else:
        X[i] = 2*A[i-1] - X[i-1]
        
print(X[:N])

Submission status: Wrong Answer

Solution code:
import numpy as np
     
n = int(input())
a = np.array(list(map(int, input().split())))
mat = np.array([])
    
for i in range(n):
    zeros = np.zeros(n)
    zeros[i] = 1
    if i + 1 > n - 1:
        zeros[0] = 1
    else:
        zeros[i + 1] = 1
    mat = np.hstack((mat, zeros))

b = a * 2
mat = np.reshape(mat, (n, n))
     
x = np.linalg.solve(mat, b)
     
print(*(x.tolist()))

Submission status: Wrong Answer

Solution code:


n = int(input())
Dn = list(map(int, input().split()))#ダム


memo = 0 # M_n = M_0
for i in range(n):
    memo += Dn[i]*(-1 if i%2==0 else 1)

memo *= -1

print(memo)



M0_max = min(Dn[0], Dn[-1])*2 
Mn0 = 0

for i in range(0, M0_max+1, 2):
    
    valid = i == memo 
    
#    print(i, memo, valid)
#    print(Dn)
#    print()

    if valid:
        Mn0 = i
        break

Mn = [0]*n
Mn[0] = Mn0
for i in range(1,n):
    Mn[i] = 2*Dn[i-1]-Mn[i-1]

print(*Mn)

Submission status: Wrong Answer

Solution code:
# x_(n+1) = 2*a_n - x_n
def xn(ans,a,n):
  for i in range(n-1):
    ans[i+1]=2*a[i]-ans[i]
  return ans
  

n = int(input())
A = list(map(int,input().split()))
ans = [0]*n
ans[0] = sum(A)-2*sum(A[1:n:2])
for j in range(2*max(A)):
  ans = xn(ans,A,n)
  if sum(ans)==sum(A):
    print(" ".join(list(map(str,ans))))
    #print(ans)

Submission status: Wrong Answer

Solution code:
# x_(n+1) = 2*a_n - x_n
def xn(ans,a,n):
  for i in range(n-1):
    ans[i+1]=2*a[i]-ans[i]
  return ans
  

n = int(input())
A = list(map(int,input().split()))
ans = [0]*n
for j in range(2*max(A)):
  ans[0] = j
  ans = xn(ans,A,n)
  if sum(ans)==sum(A):
    print(" ".join(list(map(str,ans))))
    #print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A_s = list(map(int,input().split()))
X_s = []
X_s.append(sum(A_s)-2*sum(A_s[1::2]))
for i,a in enumerate(A_s):
  X_s.append(2*A_s[i]-X_s[i])
print(' '.join(map(str,X_s)))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())

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

y = np.zeros((n, 1), dtype=np.int)

for i, wa in enumerate(a):
    y[i][0] = wa
exit()
A = np.zeros((n, n), dtype=np.int)

exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
ax=max(a)
dx=a.index(ax)

for i in range(ax*2,-1,-2):
    ans=[0]*n
    ans[dx]=i
    t=[x for x in a]
    for j in range(n):
        p=(j+dx)%n
        t[p]-=ans[p]//2
        t[p-1]-=ans[p]//2
        if t[p-1]<0:
            break
        if p+1<n: ans[p+1]=t[p]*2

    t=set(t)
    if len(t)==1 and t.pop()==0:
        print(*ans)
        exit()

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = [int(i) for i in input().split()] 
a = np.array(a)
x = np.zeros(n)

x[0] = sum(a) - (2*(sum(a) - a[-2] - a[0]))

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

print(' '.join(map(str, map(int, x))))

Submission status: Wrong Answer

Solution code:
N = int(input())
b = list(map(int, input().split(" ")))

ans = [0 for i in range(N)]

t = sum(b[0:-1])
t -= b[-1] # e, a
t = t // 2 # b, c, d
for i in range(1, N-1, 2):
    ans[i] = t
    #print("t", t)
    for j in range(1, i, 2):
        ans[i] -= b[j]
        #print("bj", b[j])
    for j in range(i+1, N-2):
        ans[i] -= b[j]
        #print("bj", b[j])

# N: odd
for i in range(0, N-2, 2): # i= 0, 2, .., N-3 (N-3=even)
    ans[i] = b[i] - ans[i+1]
ans[-1] = b[-1] - ans[0]

ans = list(map(lambda x: str(x*2), ans))
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = [int(i) for i in input().split()] 
a = np.array(a)
x = np.zeros(n)

x[0] = sum(a) - (2*(sum(a) - a[-1] - a[0]))

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

print(' '.join(map(str, map(int, x))))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = [int(i) for i in input().split()] 
a = np.array(a)
x = np.zeros(n)

x[0] = sum(a) - (2*(sum(a) - a[-1]))

for i in range(n-1):
    x[i+1] = 2*a[i] - x[i]
    
print(' '.join(map(str, map(int, x))))

Submission status: Wrong Answer

Solution code:
### ABC133-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
A=IL()
l=0
r=A[-1]
m=(l+r)//2
sA=sum(A)
x0=0
while l+2<=r:
    x0=m
    xm=m
    sx=2*xm
    for i in range(n-1):
        xm=A[i]-xm
        sx+=2*xm
    if sA==sx:
        break
    elif sx<sA:
        l=m
        m=(l+r)//2
    else:
        r=m
        m=(l+r)//2
print(2*x0,end=" ")
xm=x0
for i in range(n-1):
    xm=A[i]-xm
    print(2*xm,end=" ")
print()

Submission status: Wrong Answer

Solution code:
### ABC133-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
A=IL()
l=0
r=A[-1]
m=(l+r)//2
sA=sum(A)
x0=0
print(l,m,r)
while l<r:
    x0=m
    xm=m
    sx=2*xm
    for i in range(n-1):
        xm=A[i]-xm
        sx+=2*xm
    if sA==sx:
        break
    elif sx<sA:
        l=m
        m=(l+r)//2
    else:
        r=m
        m=(l+r)//2
print(2*x0,end=" ")
xm=x0
for i in range(n-1):
    xm=A[i]-xm
    print(2*xm,end=" ")
print()

Submission status: Wrong Answer

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

s = 1

for i in range(N):
    s = A[i] - s
    # print('A[i]',A[i])
    # print(s)

x = s//2
B = [0]*N

for i in range(N):
    B[i] = x*2
    x = A[i] - x

print(*B)

Submission status: Wrong Answer

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

x = [0]*N
tmp = 0
for i in range(N):
    if i % 2 == 0:
        tmp += A[i]
    else:
        tmp -= A[i]
x[0] = tmp
for i in range(1, N):
    x[i] = int(2*(A[i-1]-x[i-1]/2))
print(x)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
A = [int(n) for n in A]
print(A)
S = sum(A)
print(S)
X1 = S
result = []
for i in range(1,N-1,2):
    X1 -= 2*A[i]

result.append(X1)

for i in range(N-1):
    result.append(2*A[i]-result[i])

print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
a = [0]*N
a[0] = sum(A) - 2*sum(map(lambda i,x: x if i%2==1 else 0, range(N), A))
for i in range(1, N):
    a[i] = 2*A[i-1]-a[i-1]
print(a)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

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

res = [0 for i in range(N)]

for i in range(N):
    res[i] = A_sum - 2 * sum([A[(i+(2*j+1)) % N] for j in range(int((N-1)/2))])

print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
t = [int(i) for i in input().split()] 

ans = []
a = 0

for i in range(len(t)):
  if i % 2 == 0:
    a += t[i]
  else:
    a -= t[i]

ans.append(a)

for i in range(1,len(t)):
  print(t[i-1],ans[i-1])
  ans.append(2*(t[i-1]-(ans[i-1]//2)))

map_result = map(str, ans)
print(" ".join(map_result))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
b = list(map(int, input().strip().split()))
s = sum(b)
x = np.zeros((n))

x[0] = s
k = 1
for i in range(int((n-1)/2)):
    x[0] -= 2*b[k%n]
    k += 2

for i in range(1,n):
    x[i] = 2 * b[i-1] - x[i-1]

s = str(x.astype(int))
s = s.replace(',','')
s = s.replace('[','')
s = s.replace(']','')
print(s)

Submission status: Wrong Answer

Solution code:
input()
a=[int(x) for x in input().split()]
b=sum(a)-2*sum(a[1::2])
print(sum(a))
print(sum(a[1::2]))
ans = [b]
for x in a:
    b = x*2-b
    ans.append(b)
print(*ans[:-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
x =0
for i,w in enumerate(a):
    x += (-1)*(i%2)*w
ans = [x]
for i,t in enumerate(a[:-1]):
    ans.append(int(((ans[i]/2)-t)*(-2)))
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    a=LIST()
    a=[0]+a
    lis=[x for i,x in enumerate(a) if i%2==0 ]
    p=sum(lis)
    #print(p)
    #print(sum(a)-2*p)
    ans=[sum(a)-2*p]

    for i in range(1,n):
        ans.append(int(2*(a[i]-ans[i-1]/2)))

    print(ans)


if  __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    a=LIST()
    a=[0]+a
    lis=[x for i,x in enumerate(a) if i%2==0 ]
    p=sum(lis)
    #print(p)
    #print(sum(a)-2*p)
    ans=[sum(a)-2*p]

    for i in range(1,n):
        print(i)
        ans.append(int(2*(a[i]-ans[i-1]/2)))

    print(ans)


if  __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
s = sum(A)
ans = [0 for i in range(N)]
ans[0] = s
for i in range(N//2):
    ans[0] -= 2*A[2*i-1]
for i in range(1,N):
    ans[i] = 2*A[i-1] - ans[i-1]
tmp = str(ans[0])
for i in range(1,N):
    tmp += " " + str(ans[i])
print(tmp)

Submission status: Wrong Answer

Solution code:
from sys import stdin

if __name__ == '__main__':

    N = int(stdin.readline())
    A = [int(x) for x in stdin.readline().rstrip().split()]
    tmp = A[:]
    del tmp[N-1]
    del tmp[0]

    X = list()
    X.append(sum(A) - sum(tmp) * 2)

    for i in range(N):
        if i == 0:
            continue

        X.append(2 * A[i-1]-X[i-1])

    print(' '.join([str(x) for x in X]))

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A = [int(i) for i in input().split()]
A = np.array(A)
sumA=sum(A)
indexA = np.arange(0,N,2)
firstx = sum(A[indexA]) - sumA//2
xlist = [firstx]
for i in range(1,N):
  xlist.append(A[i-1]-xlist[i-1])
  
ans = np.array(xlist)*2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))
A_all = sum(As)//2
As *= 3

if N == 3:
    bs = [(A_all-a)*2 for a in As]
    print("{} {} {}".format(bs[1],bs[2],bs[0]))
else:
    window = sum(As[0:N-1:2])
    bs = [0]*(N)
    now = window
    bs[0] = now
    prev = 0
    for i in range(1,N+1):
        l = 2*i
        r = 2*i + N//2
        bs[(2*i+(N-1))%N] = now-As[prev]+As[r]
        now = bs[(2*i+N-1)%N]
        prev = l

    ans = [(A_all-b)*2 for b in bs]
    print(" ".join([str(a) for a in ans]))

Submission status: Wrong Answer

Solution code:
N=input()
A=input().split()
#print(A)

ans = []

for i in range(0,int(2*A[0]),2):
    #print()
    #print(i)
    tmp=i
    tmp2=i
    ans.append(tmp)

    for j in range(0,int(N)):
        tmp=(int(A[j])*2-tmp)
        if tmp%2:
            ans = [] 
            break

        ans.append(tmp)
        #print(tmp)

    
    if(tmp2==tmp):
        for i in range(len(ans)):
            if i == len(ans)-1:
                print()
                import sys
                sys.exit(0)

            print(ans[i], end=" ")
        
        #print("correct")

    else:
        ans = []

Submission status: Wrong Answer

Solution code:
A=[]
b=[]
N=input()
A=input().split()
#print(A)

ans = []

for i in range(0,int(2*A[0]),2):
    #print()
    #print(i)
    tmp=i
    tmp2=i
    ans.append(tmp)

    for j in range(0,int(N)):
        tmp=(int(A[j])*2-tmp)
        ans.append(tmp)
        #print(tmp)

    
    if(tmp2==tmp):
        for i in range(len(ans)):
            if i == len(ans)-1:
                print()
                import sys
                sys.exit(0)

            print(ans[i], end=" ")
        
        #print("correct")

    else:
        ans = []

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(i) for i in input().split()]

l = -2
r = 10 ** 9 + 2

def f(m):
    C = A[:]
    C[0] -= m // 2
    C[-1] -= m // 2
    for i in range(n - 1):
        C[i + 1] -= C[i]
        C[i] = 0
        if C[i + 1] < 0:
            return i % 2 == 1
    if C[-1] == 0:
        return True
    return False
    
while abs(r - l) > 2:
    m = (l + r) // 2
    if m % 2 == 1:
        m -= 1
    if f(m):
        r = m
    else:
        l = m

C = A[:]
C[0] -= r // 2
C[-1] -= r // 2
ans = [r]
for i in range(n - 1):
    ans.append(2 * C[i])
    C[i + 1] -= C[i]

print(*ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = input().split()
A = np.array([int(i) for i in a])

S = np.sum(A)
x = []
x.append(S - 2 * np.sum(A[1::2]))
for i in range(0, n - 1):
    x.append(2 * A[i] - x[i])
print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mina = min(a)
minaindex = a.index(min(a))
if minaindex + 2 <= n:
    ansstartmax = a[minaindex] + a[minaindex+1]
    start = minaindex+1
else:
    ansstartmax = a[minaindex] + a[minaindex-1]
    start = minaindex-1

ans = [0]* (n+1)

for i in range(ansstartmax//2+1):
    ans[start] = i*2
    for j in range(start+1, n+1):
        ans[j] = (a[j-1] - 0.5*ans[j-1])*2
    
    for j in reversed(range(start)):
        ans[j] = (a[j] - 0.5*ans[j+1])*2

    
    if ans[0] == ans[-1]:
        print(*ans[:-1])
        break

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
a = input().split(" ")
A = np.array([[int(a[0])]])

for i in range(1,N):
    A = np.append(A,[[int(a[i])]],axis=0)

k = np.zeros(N)
k[0] = 1/2
k[1] = 1/2
K = np.array([k])
for i in range(1,N):
    k = np.zeros(N)
    if i == N-1:
        k[0] = 1/2
        k[i] = 1/2
    else:
        k[i] = 1/2
        k[i+1] = 1/2
    K = np.append(K,[k],axis=0)

Q = np.dot(K.T,A)
t = np.linalg.inv(np.dot(K.T,K))
m = np.dot(t,Q)
a = str(int(m[0][0]))
for i in range(1,N):
    a += " "+str(int(m[i][0]))
print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

suma = sum(a)

anslist = []
anslist.append(suma - 2 * sum(a[1:]))
for i in range(1, n):
    anslist.append(2 * a[i - 1] - anslist[i - 1])

for ans in anslist:
    print(ans)

Submission status: Wrong Answer

Solution code:
def mul(inp):
    return int(inp * 2)


if __name__ == '__main__':
    n = int(input())
    a = list(map(mul, map(int, input().split())))
    res = [0] * n
    for x in range(0, n):
        res[x] = a[x]
        count = 1
        for i in range(x + 1, n + x):
            mod_i = i % n
            count += 1
            if count % 2 == 0:
                res[x] = res[x] - a[mod_i]
            else:
                res[x] = res[x] + a[mod_i]
        res[x] = int(res[x] / 2)
    print(res)