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: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split( )))
c=a[0]
for i in range(1,n-1):
	if i%2!=0:
		c=c-a[i]
	else:
		c=c+a[i]
ans=[]
ans.append(abs(c+a[-1]))
x1=abs((c+a[-1])//2)
t=x1
for i in range(n-1):
	t=abs(t-a[i])
	ans.append(2*t)
print(*ans)

Submission status: Accepted

Solution code:
N = int(input())
*A, = map(int, input().split())
X = [0]*N
X_total = sum(A)
A_odd = sum([A[i % N] for i in range(1, N, 2)])
A_even = sum([A[i % N] for i in range(2, N+1, 2)])
for i in range(N):
    X[i] = X_total - 2*(A_odd if i % 2 == 0 else A_even)
    if i % 2 == 0: A_odd += A[i] - A[(i+1) % N]
    else: A_even += A[i] - A[(i+1) % N]
print(*X)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

#def xcheck(n):
#	
#    m = int(n**.5)
#    return 1 if abs(m*m - n) < 1e-6 else 0
#	if(1):
#		#兵法数なら
#		return 1
#	return 0

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

ans =[0] * n

###
#print(hoge)

sum = 0
for i in range(n):
#	print(i)
#	print(hoge[i])
	if(i%2 == 0):
		sum+=hoge[i]
	else:
		sum-=hoge[i]
#print(sum)
#ans[0]=sum//2
ans[0]=sum

#print(ans)

for i in range(1,n):
	ans[i]=(hoge[(i-1)] - ans[i-1]//2)*2
#	print((hoge[(i-1)] - ans[i-1]//2)*2)
#	print(i)



#print(ans)

tout=""

tout+=str(ans[0])
#print(tout)

for i in range(1,n):
	tout+=" "
	tout+=str(ans[i])

print(tout)





#	listx[i][j] = hoge[j]
#print(hoge[0])
#print(hoge[2])

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    al = [int(i) for i in input().split()]
    a = n // 2
    s = sum(al)
    ans = [0] * n
    for j in range(a):
        s -= 2 * al[(0 - (1 + 2 * (j + 1)) + n) % n]
    ans[n - 1] = s
    for i in range(n - 2, -1, -1):
        ans[i] = 2 * al[i] - ans[i + 1]
    print(" ".join([str(i) for i in ans]))

if __name__=="__main__":
    solve()

Submission status: Accepted

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

#SA = []
#for i in range(N):
#    SA.append(A[i], i)
#SA.sort(reverse=True)

# A[i] = ans[i]/2 + ans[i+1]/2
ans = [0] * N

# A[i] = ans[i]/2 + ans[i+1]/2
# ans[i] =  2A[i] - ans[i+1]
# A[i+1] = ans[i+1]/2 + ans[i+2]/2
# ans[i+1] =  2A[i+1] - ans[i+2]
for i in range(N):
    if i%2 == 0:
        tmp = -1
    else:
        tmp = 1
    tmp *= A[i] * 2
    ans[0] -= tmp
ans[0] //= 2

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

print(' '.join(map(str, ans)))
#for i in range(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
u = []
a = 0
for j, i in enumerate(l):
    a += i*((-1)**j)
u.append(a)
mae = a
for j, i in enumerate(l):
    usi = int((i - mae/2) * 2)
    u.append(usi)
    mae = usi
print(*u[:-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = [0] * n
ans[0] = sum(a) - sum(a[1::2])*2

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

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

Submission status: Accepted

Solution code:
N=int(input())
listA=list(map(int,input().split()))
list1=[(-1)**(i+1)*listA[i] for i in range(N-1)]
SUM=sum(list1)
ans=listA[N-1]-SUM
listANS=[ans]
for i in range(N-1):
  ans=2*listA[i]-ans
  listANS+=[ans]
listANS=[str(i) for i in listANS]  
listANS=' '.join(listANS)
print(listANS)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(len(A)):
    B.append(A[i]*2)
B_2 = []
for i in range(len(B)):
    if i%2 != 0:
        B_2.append(B[i])
    else:
        pass


C = []
C.append(sum(A) - sum(B_2)) 

for i in range(len(A)-1):
    C.append(B[i]-C[i])
for i in range(len(C)):
    C[i] = str(C[i])

answer = ' '.join(C)
print(answer)

Submission status: Accepted

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

ans = [0]*n
sum_ = sum(lista)/2

tmp = 0
for i in range(0,n-1,2):
    tmp+=lista[i]
ans[-1] = int(sum_-tmp)*2
#print(ans)

for i in range(n-1):
    ans[n-2-i] = int(lista[n-2-i]*2 - ans[n-1- i])

for i in range(n):
    print(ans[i]," ",end="")

Submission status: Accepted

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

ans = [] * (N)
temp = (A[1] - A[0])*2
for i in range(N)[2:]:
    temp = A[i]*2 - temp
a = int(temp/2)
ans.append(str(a))

temp = a
for i in range(N-1):
    temp = A[i]*2 - temp
    ans.append(str(temp))

print(' '.join(ans))

Submission status: Accepted

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

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

d = B[0]/2 + B[N-1]/2 - A[N-1]
if d==0:
	print(*list(map(int, B)))
else:
	B[0] -= d
	for i in range(N-1):
		l = A[i]-B[i]/2
		B[i+1] = l*2
	print(*list(map(int, B)))

Submission status: Accepted

Solution code:
num_mount = int(input())

dam = [int(s) for s in input().split(' ')]

even = [i for index, i in enumerate(dam) if index % 2 == 0]
odds = [i for index, i in enumerate(dam) if index % 2 == 1]

sum_even = sum(even)
sum_odds = sum(odds)

mount = [sum_even - sum_odds]

dam.append(dam[0])
for i in range(0, num_mount-1):
    mount.append(2 * dam[i] - mount[i])

mount_str = map(str, mount)
print(' '.join(mount_str))

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))


N = int(input())
A = LI()

mountains = [-1 for i in range(N)]
last = sum(A)//2
for i in range(0,N-1,2):
    last -= A[i]

mountains[-1] = last

for i in reversed(range(N-1)):
    mountains[i] = A[i] - mountains[i+1]

for i in range(N):
    print(mountains[i]*2,end=" ")
print("")

Submission status: Accepted

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

for i in range(1, N):
  if i % 2 == 0:
    tmp = tmp + A[i]
  else:
    tmp = tmp - A[i]
X = [tmp]*N
for i in range(0, N-1):
  X[i+1] = (A[i] - X[i] // 2) * 2
print(" ".join(list(map(str, X))))

Submission status: Accepted

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

X = [0]*N

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

for i in range(N-2,-1,-1):
    X[i]=2*A[i]-X[i+1]
    
sX=["a"]*N
for i in range(N):
    sX[i]=str(X[i])

print(" ".join(sX))

Submission status: Accepted

Solution code:
from collections import defaultdict
import numpy as np
from scipy.sparse import bsr_matrix
from scipy.sparse.linalg import spsolve
def inpl(): return list(map(int, input().split()))

N = int(input())
A = np.array(inpl(), dtype=np.int64) * 2

data = np.ones(2*N, dtype=np.int64)
R = np.array([i//2 + i%2 for i in range(-1, 2*N-1)], dtype=np.int64)
C = np.array([N-1, 0] + [i//2 + i%2 for i in range(2*N-2)], dtype=np.int64)
X = bsr_matrix((data, (R, C)), shape=(N, N), dtype=np.uint64)

ans = spsolve(X, A)

print(*[int(ans[i]) for i in range(-1, N-1)], sep = " ")

Submission status: Accepted

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

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

print(int(ans*2), end=' ')
for i in range(n-1):
    ans = a[i] - ans
    print(int(ans*2), end=' ')

Submission status: Accepted

Solution code:
n=int(input())
a = [int(i) for i in input().split()]
s=0
for i in range(n):
  if i%2==0:
    s+=a[i]
  else:
    s-=a[i]
print(s,end=" ")
s=s//2
for i in range(0,n-1):
  s=(a[i]-s)*2
  print(s,end=" ")
  s=s//2

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
m = [0]
for i in range(1,n):
  m.append(2*d[i-1] - m[i-1])
diff = 2*d[n-1] - m[n-1]
M = [diff//2]
for i in range(1,n):
  M.append(2*d[i-1] - M[i-1])
ans = list(map(str,M))
print(' '.join(ans))

Submission status: Accepted

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

k = 0
for i in range(1,N):
    k = A[i] - k

ans = (A[0] - k) // 2
ans_l = [None]*N

ans_l[1] = str(ans*2)
for i in range(1,N):
    ans = A[i] - ans
    if i==N-1:
        ans_l[0] = str(ans*2)
    else:
        ans_l[i+1] = str(ans*2)
print(" ".join(ans_l))

Submission status: Accepted

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

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

B[0] = num

for i in range(1, N):
    B[i] = 2 * (A[i] - (B[i - 1] // 2))
B.reverse()
B = list(map(str, B))
print(' '.join(B))

Submission status: Accepted

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

x = 0
rains = [x]
for a in A:
    x = a - x
    rains.append(x)

diff = (rains[-1] - rains[0]) // 2
result = []
for i, x in enumerate(rains[:-1]):
    if i % 2 == 0:
        result.append(str((x + diff) * 2))
    else:
        result.append(str((x - diff) * 2))

print(' '.join(result))

Submission status: Accepted

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

x = 0
for i,a in enumerate(A):
    if i%2==0:
        x += a
    else:
        x -= a
ans = [str(x)]
for i in range(1,N):
    x = 2*A[i-1] - x
    ans.append(str(x))

print(' '.join(ans))

Submission status: Accepted

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

ans = []

ans.append(
        int((sum(s) * 0.5 - sum(s[1::2]))*2)
        )
for i in range(n-1):
    ans.append(int((s[i]-ans[i]/2)*2))

print(*ans)

Submission status: Accepted

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

asum=sum(alist)
ans_list=[-1]*N

minus_even=sum(alist[1:N:2])
minus_odd=sum(alist[2:N:2])

for i in range(N//2):
  ans_list[2*i] = asum-2*minus_even
  ans_list[2*i+1] = asum-2*minus_odd
  
  minus_even += alist[(2*i+N)%N]-alist[(2*i+1)%N]
  minus_odd += alist[(2*i+N+1)%N]-alist[(2*i+2)%N]
  
ans_list[-1]=asum-2*minus_even
  
ans_list_str=map(str,ans_list)  
print(" ".join(ans_list_str))

Submission status: Accepted

Solution code:
N = int(input())

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

X = [0]*N

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

for j in range(0,N-1):
    X[j+1] = 2 * (A[j] - int(X[j]/2))

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

X = [0 for _ in range(N)]


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

Submission status: Accepted

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

def last_value(x):
    tmp2 = x
    for a in A:
        tmp = x
        x = a - tmp
    return x-tmp2

def bsearch(l,r):
    if l > r:
        return -1
    else:
        c = (l+r)//2
        last = last_value(c)
        if last < 0:
            return bsearch(l,c-1)
        elif last> 0:
            return bsearch(c+1,r)
        elif last == 0:
            return c
    
    
        
def solver(x):
    ans = [0] * N
    ans[0] = x*2
    for i,a in enumerate(A[:-1]):
        tmp = x
        x = a - tmp
        ans[i+1] = x * 2
    return ans


Left = 0
Right = min(A[0],A[N-1])

ans = solver(bsearch(Left,Right))

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

Submission status: Accepted

Solution code:
n = int(input())
a = tuple(map(int, input().split()))
m = [0] * n

for i in range(0, n, 2):
  m[0] += a[i]

for i in range(1, n, 2):
  m[0] -= a[i]

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

print(*m)

Submission status: Accepted

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

half_sum_water = sum(water) // 2

ans = []

m = n // 2
x0 = half_sum_water
for i in range(m):
    x0 = x0 - water[(1 + (i * 2)) % n]

print(x0 * 2,end = ' ')

x = x0
for i in range(n - 1):
    x = water[i] - x
    print(x * 2,end = ' ')

print()

Submission status: Accepted

Solution code:
n=int(input())
dam=[int(x) for x in input().split()]
yama=[0]*n
dam_sum=sum(dam)//2
diff=0
if n in (1,2):
    for j in range(n):
        diff=0
        for i in range(n):
            if i%2==0:
                continue
            diff+=dam[(i+j)%n]
        yama[j]=dam_sum - diff
        yama[j]*=2
else:
    diff_same=0
    for i in range(n):
            if i%2==0:
                continue
            diff_same+=dam[(i)%n]
    yama[0]=dam_sum - diff_same
    yama[0]*=2
    diff_odd=0
    for i in range(n):
            if i%2==0:
                continue
            diff_odd+=dam[(i+1)%n]
    yama[1]=dam_sum - diff_odd
    yama[1]*=2
    for j in range(2,n):
        if j%2==0:
            diff_same-=dam[(j-1)%n]
            diff_same+=dam[(j-2)%n]
            yama[j]=dam_sum - diff_same
        else:
            diff_odd-=dam[(j-1)%n]
            diff_odd+=dam[(j-2)%n]
            yama[j]=dam_sum - diff_odd
        yama[j]*=2
print(" ".join([str(x) for x in yama]))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
a0=sum(a)//2-sum(a[1::2])
ans=[a0*2]
for i in range(n-2):
    ans.append(a[i]*2-ans[-1])
ans.append((a[-1]-a0)*2)
print(*ans)

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A = list(map(int, input().split()))
lenA = len(A)

m0 = sum([A[i] for i in range(lenA) if i%2==0]) \
   - sum([A[i] for i in range(lenA) if i%2==1])

res = [0]*lenA
res[0] = m0

last = m0
i = 1
for a in A[:-1]:
    res[i] = 2*(a-last//2)
    last = res[i]
    i += 1

print(*res)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    mi = (0, -1)
    for i in range(N):
        mi = max(mi, (A[i-1] + A[i], i, A[i-1], A[i]))


    s = min(mi[2], mi[3])*2

    si = mi[1]
    while True:
        ans = [0] * N
        ans[si] = s
        a = A[:]
        a[si-1] -= s//2
        a[si] -= s//2
        for i in range(1, N):
            ans[(si+i)%N] = a[(si+i-1)%N] * 2
            a[(si+i) % N] -= a[(si+i-1) % N]
            a[(si+i-1) % N] = 0
        
        if a[(si+i) % N] == 0:
            break
        s += a[(si+i) % N]
        if s < 0:
            break

    return ' '.join(map(str, ans))


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

D = [0] * (N+1)
D[0] = 0

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    y = [0 for i in range(N)]
    y[0] = sum([A[i] if i%2 == 0 else (-1) * A[i] for i in range(N)])
    for i in range(0, N-1):
        y[i+1] = 2 * A[i] - y[i]
    result = [str(i) for i in y]
    print(' '.join(result))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = []
base = 0
for i in range(n):
    if i % 2 == 0:
        base += a[i]
    else:
        base -= a[i]
base //= 2

for i in range(n)[::-1]:
    base = a[i] - base
    ans.append(base)
ans = list(map(lambda x: str(x*2), ans))
ans = ans[::-1]
print(" ".join(ans))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    y = [-1 for i in range(N)]
    y[0] = sum([A[i] if i%2 == 0 else (-1) * A[i] for i in range(N)])
    for i in range(0, N-1):
        y[i+1] = 2 * A[i] - y[i]
    result = [str(i) for i in y]
    print(' '.join(result))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.extend(a)
ans = 0
k = 0
for i in range(n):
    ans += a[i]*(-1)**k
    k += 1
print(ans,end=" ")
for i in range(n-1):
    ans = 2*a[i]-ans 
    print(ans,end=" ")

Submission status: Accepted

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

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

X = []

X.append(X1by2)
for i in range(len(A)-1):
  X.append((A[i]-X[i]/2)*2)

print(" ".join(repr(int(e)) for e in X))

Submission status: Accepted

Solution code:
import numpy as np

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

a = np.array(list(a)).astype(np.float)
c = np.zeros(n)
c[0] = 1 / 2
c[-1] = 1 / 2


ans = np.round(np.real(np.fft.ifft(np.fft.fft(a) / np.fft.fft(c)))).astype(np.int)

print(*ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = tuple(map(int,input().split()))
#山1に降った雨の量を求める
m1 = 0
for i,v in enumerate(a):
    m1+= v*((-1)**(i%2))
ret = [m1]*n
for i in range(1,len(ret)):
    ret[i]=a[i-1]*2-ret[i-1]
ret = tuple(map(str,ret))
print(" ".join(ret))

Submission status: Accepted

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

total = sum(A)/2
total2 = sum(A[1::2])
for i in range(N//2):
    X[i*2] = int(total - total2)
    X[i*2+1] = int(A[i*2]-X[i*2])
    total -= A[i*2]
    total2 -= A[i*2+1]
X[-1] = int(A[-1] - X[0])

ans = ''
for i in range(N):
    ans += str(X[i]*2) + ' '

print(ans[:-1])

Submission status: Accepted

Solution code:
N = int(input()) # 数字を変数に格納
List = list(map(int,input().split())) # 複数の数字をリストに格納

x_0 = 0

for i in range(N):
    if (i % 2) == 0:
        x_0 += List[i]
    else:
        x_0 -= List[i]

result_x = []
result_x.append(x_0)

for j in range(N-1):
    result_x.append(int((List[j] - (result_x[j])/2) *2))

print(*result_x)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
a = 0
for i in range(N):
  a += A[i] * (-1) ** i
b = a
print(a, end = " ")

for i in range(0, N-2):
  b = 2 * A[i] - b
  print(b, end = " ")

print(2 * A[N-2] - b)

Submission status: Accepted

Solution code:
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
A = list(map(int, input().split()))
total1 = [0] * (N + 1)
total2 = [0] * (N + 1)

for i in range(1, N + 1):
	total1[i] += total1[i - 1] + A[i - 1] * ((-1) ** (i % 2))
	total2[i] += total2[i - 1] + A[i - 1] * ((-1) ** (i % 2 + 1))

for i in range(N):
	ans = total1[N] - total1[i] + total2[i] - total2[0]
	print(abs(ans), end=' ')

Submission status: Accepted

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

odd_sum = [0]
even_sum = [0]

for i in range(N):
    if i % 2 == 0:
        odd_sum.append(odd_sum[-1] + a_list[i])
        even_sum.append(even_sum[-1] - a_list[i])
    else:
        odd_sum.append(odd_sum[-1] - a_list[i])
        even_sum.append(even_sum[-1] + a_list[i])

ans = []
for i in range(N):
    a = a_list[i]

    if i % 2 == 0:
        a += (odd_sum[-1] - odd_sum[i + 1])
        a += even_sum[i]
    else:
        a += (even_sum[-1] - even_sum[i + 1])
        a += odd_sum[i]
    print(a)
    # if i == 0:
    #     break
    # flg = False
    # for j in range(i + 1, N + i):
    #     b = a_list[j % N]
    #     if flg:
    #         flg = False
    #         a += b
    #     else:
    #         flg = True
    #         a -= b
    # print(a)

Submission status: Accepted

Solution code:
n = int(input())
a = tuple(map(int,input().split()))
x = [0] * n
x1 = 0
for i in range(n):
  if i % 2 == 0:
    x1 += a[i]
  else:
    x1 -= a[i]
x[0] = x1
for i in range(1,n):
  x[i] = 2 * a[i-1] - x[i-1]
for i in range(n):
  x[i] = str(x[i])
print(' '.join(x))

Submission status: Accepted

Solution code:
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def ans(i):
    if i % 2 == 0:
        return s-sre[int((n-i-1)/2)]*2-slo[int(i/2)]*2
    return s-sro[int((n-i)/2)]*2-sle[int((i-1)/2)]*2


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

s = sum(a)
sle = [0]
sre = [0]
slo = [0]
sro = [0]
for i in range(n):
    if i % 2 == 0:
        slo.append(slo[-1]+a[i])
        sro.append(sro[-1]+a[-i-1])
    else:
        sle.append(sle[-1]+a[i])
        sre.append(sre[-1]+a[-i-1])
print(' '.join(map(str, [ans(i) for i in range(n)])))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
B1 = 0
for i,a in enumerate(A):
    if i%2 == 1:
        B1 -= a
    else:
        B1 += a
B1 = int(B1)//2
B = [B1]
for i, a in enumerate(A[:-1]):
    B.append(a-B[i])
B = [str(b*2) for b in B]
print(' '.join(B))

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
ans = [a[i] if (i % 2 == 0) else -1 * a[i] for i in range(n)]
b = []
ans0 = sum([a[i] if (i % 2 == 0) else -1 * a[i] for i in range(n)])
b.append(str(ans0))
temp = int(ans0 // 2)
for i in range(0, n-1):
    k = a[i] - temp
    b.append(str(k*2))
    temp = k
print(' '.join(b))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input())
    A_list = list(map(int, input().split()))

    sum_x = sum(A_list)//2
    x1 = sum_x
    for i in range(2, N, 2):
        x1 -= A_list[i-1]

    x_list = [-1] * N
    x_list[0] = x1
    for i in range(N-1):
        x_list[i+1] = A_list[i] - x_list[i]

    answer = ' '.join([str(2*x) for x in x_list])
    print(answer)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# いっこ入力
n =int(input())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b =[0]
# if b1 were 0
b.append(2*a[0])
for i in range(2,n):
    b.append(2*a[i-1]-b[i-1])
suma=0
sumb=0
for i in range(n):
    suma += a[i]
    sumb += b[i]
#print(b)
a1 = sumb - suma
for i in range(n):
    if i % 2 ==0:
        b[i] -= a1
    else:
        b[i] += a1
#print(b)
for i in range(n):
    print(b[i],end=" ")
print("")

Submission status: Accepted

Solution code:
import math


N = int(input())
As = list(map(int, input().split(" ")))
Asdouble = list(map(lambda x:x * 2,As))
AsdoubleRev = Asdouble[::-1]
temp = AsdoubleRev[1] - AsdoubleRev[0]
for a,b in zip(AsdoubleRev[1:-2],AsdoubleRev[2:-1]):
    temp = b -temp
M1 =Asdouble[0] - temp
M1 //=2

ans = [M1]
temp = M1
for a in Asdouble[:-1]:
    temp = a - temp
    ans.append(temp)
ans = list(map(str,ans))
print(" ".join(ans))

Submission status: Accepted

Solution code:
size = int(input())
waters = list(map(int, input().split()))

# 奇数の場合のみ、たとえば size = 5 なら、
# m1 = d1 - d2 + d3 - d4 + d5 のように求められる

# 各山に振った水量を、mとする
m = [0]*size
m[0] = str(sum(waters[::2]) - sum(waters[1::2]))

for i in range(1, size):
    m[i] = str(2 * (waters[i-1]) - int(m[i - 1]))


print(" ".join(m))

Submission status: Accepted

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

M1=sum(A)-sum(A[1::2])*2

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

Submission status: Accepted

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


s = 0
for i in a:
    s = 2*i - s
x = s//2

ans = []
ans.append(str(x))
for i in range(len(a)-1):
    x = 2*a[i]-x
    ans.append(str(x))
print(' '.join(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

ans = [str(0) for _ in range(n)]

odd_total = sum(a[:-2:2])
even_total = sum(a[1::2])
ans[0] = str(a[-1] + odd_total - even_total)
for i in range(n - 1):
    ans[i + 1] = str(2 * a[i] - int(ans[i]))

print(' '.join(ans))

Submission status: Accepted

Solution code:
import sys
import math
#from pprint import pprint
import numpy as np
def myinput_int():
    return list(map(int, input().split()))


N = myinput_int()

a = myinput_int()

a = np.array(a)

goukei = np.sum(a[::2]) - np.sum(a[1::2])
x = int(goukei/2)

now_val = x
text = str(now_val*2)
for i in range(1, a.shape[0]) :
    now_val = a[i-1]-now_val    
    text += ' ' + str(now_val*2)

print(text)

Submission status: Accepted

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

ans = [0]*(n+1)
#for i in range(0, a[0]*2+1, 2):
#    ans[0] = i
while True:
    for j in range(n):
        ans[j+1] = (a[j] - ans[j]//2) *2
    if ans[0] == ans[n]:
        print(' '.join(map(str, ans[0:len(ans)-1])))
        exit(0)
    else:
        ans[0] += ans[n]//2

Submission status: Accepted

Solution code:

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

a_sum = sum(a)//2
a_odd = 0

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

a_back = a_sum-a_odd
print(2*a_back)

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = []
sum_A = sum(A)
tmp_sum = 0
for i in range(1,len(A)-1,2):
    tmp_sum += 2*A[i]
ans.append(sum_A - tmp_sum)
ans.append((A[0] - (ans[0]//2))*2)
tmp = ans[1]
for i in range(1,N-1):
    tmp = 2*A[i] - tmp
    ans.append(tmp)
print(' '.join([str(n) for n in ans]))

Submission status: Accepted

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

res = []
s = 0
for i in range(n):
    s += a[i] * [-1, 1][i % 2 ==0]
res.append(s)

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

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int, input().split()))
x=[0 for i in range(n)]
sum=0
for i in range(n):
    if i%2==0:
        sum=sum+a[i]
    else:
        sum=sum-a[i]

x[0]=sum//2

for i in range(1, n):
    x[i]=a[i-1]-x[i-1]

x=map(lambda t:t*2, x)
x=map(str, x)

ans=" ".join(x)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
temp = A[0]
for x in range(1, N):
  if x % 2 == 1:
    temp -= A[x]
  else:
    temp += A[x]
res = [temp]
show = str(res[0])

for i in range(0, N - 1):
  res.append((A[i] - res[i] // 2) * 2)
  show += " " + str(res[i + 1])
print(show)

Submission status: Accepted

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

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

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

print(*yamas, sep=' ')

Submission status: Accepted

Solution code:
N=int(input())
A=[int(_) for _ in input().split()]
X=[]
x=0
for j in range(N):
    if (j%N)%2==0:
        x+=A[j]
    else:
        x-=A[j]
X.append(x)
for i in range(1,N):
    x=2*A[i-1]-X[i-1]
    X.append(x)
print(' '.join(map(str, X)))

Submission status: Accepted

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
ans = [0 for i in range(n)]
ans[-1] = A[-1]
for i in range((n-1)//2):
    ans[-1] = ans[-1] - A[2*i] + A[2*i+1]
for i in range(n-2, -1, -1):
    ans[i] = 2*A[i] - ans[i+1]
for i in ans:
    print(i, end=" ")

Submission status: Accepted

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

R1 = sum(A_list) - 2 * sum(A_list[i] for i in range(1,N,2))

Ri_list = [0] * N

Ri_list[0] = R1

for i in range(1,N):
    # print(A_list[i-1])
    Ri_list[i] = A_list[i-1] * 2 - Ri_list[i-1]

for item in Ri_list:
    print(item, end=' ')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
t = sum(a)
x = [0]*n
x[0] = t - 2*sum(a[1::2])

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