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(input())
a=list(map(int, input().split()))
r=[0]*n

# 平滑化
for i in range(n):
    a1,a2,a3=a[i-1], a[i], a[(i+1)%n]
    if a2 > a1:
        r[(i+1)%n]+=(a2-a1)*2
        a[i]-=(a2-a1)
        a[(i+1)%n]-=(a2-a1)
    if a2 > a3:
        r[i]+=(a2-a3)*2
        a[i]-=(a2-a3)
        a[i-1]-=(a2-a3)

b=max(a)
print(" ".join(list(map(lambda x: str(x+b), r))))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
M=[0]*n
M[0]=sum(a[i]*(-1)**i for i in range(n))
for i in range(1,n):
    M[i]=2*a[i-1]-M[i-1]
print(M)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def func(dam_num, dam_volumes):
    water_amount = sum(dam_volumes)
    mountains_rain = [0]*dam_num
    mountains_rain[0] = water_amount
    
    # 最初の山の降水量を計算
    for i in range(dam_num//2):
        mountains_rain[0] -= 2*dam_volumes[2*(i+1)-1]

    # 漸化式　mountains_rain[i+1] = 2*dam_volumes[i] - mountains_rain[i]
    for i in range(dam_num-1):
        mountains_rain[i+1] = 2*dam_volumes[i] - mountains_rain[i]

    print(mountains_rain)
    exit()


def main():
    n = int(input())
    a = [int(i) for i in input().split()] 

    func(n,a)
    
# main関数呼び出し
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def rain_volume(A, N):
    X = [0]*N
    X[0] = sum(A)
    for i, a in enumerate(A):
        if i%2 != 0:
            X[0] -= 2*a
    for i, a in enumerate(A):
        if i != 0:
            X[i] = 2*A[i] - X[i-1]
    return X

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

    print(' '.join(map(str, rain_volume(A, N))))

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
Rain = np.array(list(map(int,input().split())))
Rain = np.reshape(Rain,(N,1))

n1 = np.ones(N)
n2 = np.ones(N-1)
print('u')
"""
a = np.diag(n1)
b = np.diag(n2,k=1)
c = a+b
c[N-1][0] = 1
d = 0.5 * c

ans = np.linalg.solve(d,Rain)
for i in ans:
    print(int(i[0]),end=' ')
"""

Submission status: Wrong Answer

Solution code:
N=int(input())
a_list=[int(x) for x in input().split()]

from numpy.linalg import solve
left=[]
for i in range(N):
    tmp=[0]*N
    tmp[i]=1
    if i==N-1:
        tmp[0]=1
    else:
        tmp[i+1]=1
    left.append(tmp)
right=[2*x for x in a_list]
print(solve(left, right))

Submission status: Wrong Answer

Solution code:
N = int(input())
x = [0] * N
y = [0] * N

for i, A in enumerate(input().split()):
  x[i] = int(A)
  
for i in range(N):
  for j in range(N):
    index = (i + j) % N
    y[i] += ((-1) ** j) *  x[index]
    print("y[{}]:{}".format(i, y[i]))
    
str_y = map(str, y)
output = " ".join(str_y)
print(output)

Submission status: Wrong Answer

Solution code:
N = int(input())
x = [0] * N
y = [0] * N

for i, A in enumerate(input().split()):
  x[i] = int(A)
  
for i in range(N):
  for j in range(i, i+N):
    index = j % N
    y[i] += ((-1) ** index) *  x[index]
    
str_y = map(str, y)
output = " ".join(str_y)
print(output)

Submission status: Wrong Answer

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

ans = []

sumA = sum(A)
sum_even = 2*sum(A[1 : int((N+3)/2) : 2])
ans_i = sumA - sum_even
ans.append(ans_i)

for i in range(N-2):
	ans_i = 2*A[i] - ans_i
	ans.append(ans_i)

ans.append(2*A[-1] - ans[0])

ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)

Submission status: Wrong Answer

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

ans = []

sumA = sum(A)

for i in range(int(len(A)/2)):
	ans_1 = sumA - 2*sum(A[2*i+1 : int((N+3)/2) : 2])
	ans_2 = 2*A[2*i] - ans_1
	ans.append(ans_1)
	ans.append(ans_2)
	sumA -= (ans_1+ans_2)
ans.append(sumA)

ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
L=list(map(int,input().split()))
ans=[0 for i in range(n)]

L=[i*2 for i in L]


m=n//2
a=L[m]

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

ans[0]=a//2

for i in range(1,n):
  ans[i]=L[i-1]-ans[i-1]

print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
L=list(map(int,input().split()))
ans=[0 for i in range(n)]

L=[i*2 for i in L]


m=n//2
a=L[m]

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

ans[0]=a//2

for i in range(1,n):
  ans[i]=L[i-1]-ans[i-1]

print(L)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

sum_odd = sum([v for v in A[1::2]])
x0 = sum(A)-2*sum_odd
ans = [x0]

x = x0
for a in A:
    nex = 2*a-x
    ans.append(nex)
    x = nex
print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
for i in range(0,2*min( a[0],a[N-1] ),2):
    s=[i/2]
    answer=[]        
    for n in range(N):
        s.append(a[n]-s[n])
        answer.append(int(2*s[n]))
    if s[N-1]+i/2==a[N-1]:
        print(*answer)
        exit(0)

Submission status: Wrong Answer

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

sum1=0
sum2=0
for i in range(a):
  sum1=sum1+N[i]
  if i%2==1:
      sum2=sum2+N[i]

sum1=int(sum1/2)

M=[0]*a
M[0]=sum1-sum2

for i in range(a-1):
 M[i+1]=N[i]-M[i]

b=''
for i in range(a-1):
 b=b+str(M[i])+' '

b=b+str(M[a-1])

print(b)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

x1=sum([pow(-1, k)*A[k] for k in range(N)])/2
for i in range(1, N):
  #x=x+[sum([pow(-1, k-i)*A[k] for k in range(i, N)])-pow(-1, i)*x[0]]
  print(sum([pow(-1, k-i)*A[k] for k in range(i, N)])-pow(-1, i)*x1, end=' ')

Submission status: Wrong Answer

Solution code:
N=int(input())
temp=input().split()
A=[int(temp[i]) for i in range(N)]
A=[A[-1]]+A[:-1]

for i in range(N):
  print(sum(A[i:i+2])/2, end=' ')

Submission status: Wrong Answer

Solution code:
N=int(input())
temp=input().split()
A=[int(temp[i]) for i in range(N)]
A=[A[-1]]+A[:-1]
result=[]
for i in range(N):
  result.append(sum(A[i:i+2])/2)
  
print(result)

Submission status: Wrong Answer

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

result=[]
for i in range(N):
  result.append(sum(A[i:i+2])/2)
  
print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
total=0
b=[0]*n
a_cycle=a*2

for i in range(n):
  total+=a[i]
print(total)
for i in range(n):
  a_tot=0
  for j in range(n//2):
  	a_tot+=a_cycle[i+2*j+1]
  b[i]=total-2*a_tot
print(*b)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(map(int,input().split()))
m = [0]*n
m[0]= d[-1]+d[0]-d[1]
m[n-1]= d[n-1]+d[n-2]-d[0]
for i in range(1,n-1):
  m[i]= d[i]+d[i-1]-d[i+1]
  
for i in range(n):  
  print(m[i], end=" ")

Submission status: Wrong Answer

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

A=[A[-1]]+A

for i in range(N):
  print((A[i]+A[i+1])/2)

Submission status: Wrong Answer

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

total = sum(A)//2
ans = []
for i in range(len(A)):
  calc = 0
  for j in range(i, i+(len(A)-1)//2+1, 2):
    j = j%len(A)
    calc += A[j]
  ans += [(total-calc)*2]

ans += [ans[0]]
ans = ans[1:]
result = [str(a) for a in ans]
print(' '.join(result))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n = 0
v = []
s = []
# s[0]が2*qの時に1周してs[n]を返す関数
def f(q):
	global s
	s = [0] * (n+1)
	# 0の持分
	s[0] = 2 * q
	for j in range(1, n+1):
		s[j] = 2 * (v[j-1] - s[j-1]//2)
	return s[n], s[0]


def bin(i, j):
	if i+1 >= j:
		f(i)
		return s
	mid = (i+j) // 2
	res, expect = f(mid)
	if res == expect:
		return s
	elif res < expect:
		return bin(i, mid)
	else:
		return bin(mid, j)

def main():
	global n, v
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	w = []
	N = min(v[0], v[1])
	w = bin(0, N+1)
	for i in range(n):
		print("{} ".format(w[i]), end='')
	print("")

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	s = sum(v)
	t = sum(v[1::2])
	x = [0] * n
	print(s, t)
	x[0] = s - 2 * t
	for i in range(1, n):
		x[i] = 2 * v[i-1] - x[i-1]
	for i in range(n):
		print("{} ".format(x[i]), end='')
	print("")


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n = 0
v = []
s = []
# s[0]が2*qの時に1周してs[n]を返す関数
def f(q):
	global s
	s = [0] * (n+1)
	# 0の持分
	s[0] = 2 * q
	for j in range(1, n+1):
		s[j] = 2 * (v[j-1] - s[j-1]//2)
	return s[n], s[0]


def bin(i, j):
	if i+1 >= j:
		f(i)
		return s
	mid = (i+j) // 2
	res, expect = f(mid)
	if res < expect:
		return bin(i, mid)
	else:
		return bin(mid, j)

def main():
	global n, v
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	w = []
	N = min(v[0], v[1])
	w = bin(0, N+1)
	for i in range(n):
		print("{} ".format(w[i]), end='')
	print("")

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
def calc_double(n):
    return n * 2
N=int(input())
DAM = list(map(int, input().split()))
result=[0]*N
YAMASUM = []
for val in DAM:
    YAMASUM.append(calc_double(val))
for a in range(0,YAMASUM[0]+1):
    result[0]=a
    for i in range(1,N):
        result[i]=YAMASUM[i-1]-result[i-1]
        if(result[i]<0):
            break
    if(result[0]+result[N-1]==YAMASUM[N-1]):
        break
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
rain = []
S = sum(A)
sub = sum(A[0:N - 1:2])
rain.append(S - sub * 2)
while len(rain) != N:
    rain.append(A[len(rain) - 1] * 2 - rain[-1])
for _ in rain:
    print(_)

Submission status: Wrong Answer

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input133d.txt')

#+++++

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

sum = 0
for s in a:
    sum += s

asum = 0
for i in range(n):
    if i % 2 == 1:
        asum += a[i]

x1 = sum - 2 * asum

ret = []
ret.append(x1)

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

print(ret)

Submission status: Wrong Answer

Solution code:
from numpy.linalg import solve

n = int(input())
right = list(map(lambda x: x * 2 ,list(map(int,input().split(" ")))))

left = []
tmp = []
for i in range(n):
    for i in range(n):
        tmp.append(0)
    left.append(tmp)
    tmp = []
#print(left)
for i in range(n):
    left[i][(n-i-1)%n] = 1
    left[i][(n-i-2)%n] = 1
    #print(left)

ans = solve(left,right)
ans = list(map(str,list(map(int,ans))))
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
w = list(map(int,input().split()))
ans = []
for i in range(n-1):
  r = int(w[i]/2) + int(w[i+1]/2)
  ans.append(r)
rn = int(w[0]/2) + int(w[n-1]/2)
ans.append(rn)
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
b = 0
for i in range(N):
  if i%2 == 0:
    b += A[i]
  else:
    b -= A[i]
print(b)

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

Submission status: Wrong Answer

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

# X1の拘束条件
# A1 * 2 && last
X1_up = min(A[0], A[-1]) * 2
Xlast_up = min(A[-1], A[-2]) * 2


ansx1 = -1
ansxlast = -1
is_found = False
for x1 in range(0,X1_up + 1, 2):
    for xlast in range(0, Xlast_up + 1, 2):
        if x1 == 2 * A[-1] - xlast:
            ansx1 = x1
            ansxlast = xlast
            is_found = True
            break
    if is_found:
        break


ans = []
ans.append(ansx1)
prev = ansx1
for index in range(len(A)-1):
    d = 2 * (A[index] - int(prev //2))
    ans.append(d)
    prev = d

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

Submission status: Wrong Answer

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

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

print(Y)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split()))) * 2
C = np.linalg.inv([[1 if i == j or i % N == (j + 1) % N else 0 for i in range(N)] for j in range(N)])
print(np.dot(C, A))

Submission status: Wrong Answer

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

water_sum = sum(A_array) 

now_water = water_sum - sum(A_array[1::2]) * 2
ans_array = []
print(now_water)
ans_array.append(str(now_water))
for i in range(N-1):
    now_water = A_array[i] * 2 - now_water
    ans_array.append(str(now_water))

print(" ".join(ans_array))

Submission status: Wrong Answer

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

res = []
for i in range(N):
    res_tmp = 0
    for j, a in enumerate(A[i:i+N]):
        res_tmp += a if j % 2 == 0 else -a
    res.append(res_tmp)
print(res)

Submission status: Wrong Answer

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

m=[0]*n

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

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a=[]
a=list(map(int, input().split()))
m=[0]*n
for i in range(a[0]):
  mn=0
  for j in range(n-1):
    if j==0:
      m[n-1]=i*2
      m[j]=(a[j]-m[n-1]/2)*2
    else:
      m[j]=(a[j]-m[j-1]/2)*2
      if m[j]<0:
        continue

  if m[n-2]/2+m[n-1]/2 == a[n-1]:
    print(int(m[n-1]),sep=" ",end=" ")
    for i in range(n-1):
      print(int(m[i]),sep=" ",end=" ")


    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a=[]
a=list(map(int, input().split()))
m=[0]*n
for i in range(a[0]):
  mn=0
  for j in range(n-1):
    if j==0:
      m[n-1]=i*2
      m[j]=(a[j]-m[n-1]/2)*2
    else:
      m[j]=(a[j]-m[j-1]/2)*2

  if m[n-2]/2+m[n-1]/2 ==a[n-1]:
    print(int(m[n-1]),sep=" ",end=" ")
    for i in range(n-1):
      print(int(m[i]),sep=" ",end=" ")


    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a=[]
a=list(map(int, input().split()))
m=[0]*n
for i in range(a[0]):
  mn=0
  for j in range(n-1):
    if j==0:
      m[n-1]=i*2
    m[j]=(a[j]-m[j-1]/2)*2
  if m[n-2]/2+m[n-1]/2 ==a[n-1]:
    for i in range(n):
      print(int(m[i]),sep=" ",end=" ")
    sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
result = [0]*n
result[0] = sum(a) - 2*sum(a[1:-1])
for i in range(n-1):
  result[i+1] = 2*a[i] - result[i]

print(*result)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
a = np.array(A)
l = int(((N**2)+1)/2)
b = []
for i in range(l):
    b.append([1,-1])
    print(b)
b = np.array(b).reshape(1,2*l)
c = (np.delete(b, 2*l-1, axis=None)).reshape(N,N)
d = c.reshape(N,N)
inv = 0.5*( np.triu(c) - ( np.tril(c) - np.eye(N) ) )
g = np.eye(N)
x = 2*(np.dot(inv,a))
ans = list(map(str, list(map(int, list(x)))))
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

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



a = np.array(A)
l = int(((N**2)+1)/2)

print(1)

# b = np.tile((1,-1),(1,l))
# c = (np.delete(b, 2*l-1, axis=None)).reshape(N,N)
# # print(c)
# d = c.reshape(N,N)

# inv = 0.5*( np.triu(c) - ( np.tril(c) - np.eye(N) ) )
# g = np.eye(N)
# print(inv)

# x = 2*(np.dot(inv,a))
# print(x)

# ans = list(map(str, list(map(int, list(x)))))
# print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

print(1)

# a = np.array(A)
# l = int(((N**2)+1)/2)
# b = np.tile((1,-1),(1,l))
# c = (np.delete(b, 2*l-1, axis=None)).reshape(N,N)
# print(c)
# d = c.reshape(N,N)

# inv = 0.5*( np.triu(c) - ( np.tril(c) - np.eye(N) ) )
# g = np.eye(N)
# print(inv)

# x = 2*(np.dot(inv,a))
# print(x)

# ans = list(map(str, list(map(int, list(x)))))
# print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.append(a[0])
r=[]
for i in range(n):
  r_pre =a[i]+a[i+1]
  r_i = r_pre/2
  r.append(r_i)
print(*r)

Submission status: Wrong Answer

Solution code:
def main03():
    data = int(input())
    data2 = input().split()
    num = []
    for i in range(data):
        num.append(int(data2[i]))
    are = 0
    for i in range(1,data,1):
        if i % 2 == 1:
            are = are + num[i]
        else:
            are = are - num[i]
    results = []
    results.append(0)
    for i in range(data):
        are = num[i] - are
        if i == (data-1):
            results[0] = are
        else:
            results.append(are)
    for i in range(data):
        print((results[i]*2), end='')
        print(" ", end='')
    print("")

if __name__ == "__main__":
    main03()

Submission status: Wrong Answer

Solution code:
def main03():
    data = int(input())
    data2 = input().split()
    num = []
    for i in range(data):
        num.append(int(data2[i]))
    are = 0
    for i in range(1,data,1):
        if i % 2 == 1:
            are = are + num[i]
        else:
            are = are - num[i]
    for i in range(data):
        are = num[i] - are
        print((are*2), end='')
        print(" ", end='')
    print("")

if __name__ == "__main__":
    main03()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
for i in range(a[0] + 1):
  ans = [i]
  ans.append(a[0] - i)
  for j in range(1, n):
    ans.append(a[j] - ans[j])
  if ans[0] == ans[n]:
    ans = [i * 2 for i in ans[0:n]]
    print(ans)
    break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = sum(a)

x1 = s - 2 * (sum(a[1::2]))  # 偶数番目のindexを取得
x = [x1]
for i in range(2, n + 1):
    x.append(2 * a[i - 2] - x[i - 2])

print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
# まずX_1を求める
x_1 = s
for i in range(1,n,2):
    x_1 -= 2*a[i]
ans = [x_1]
for i in range(1, n):
    ans.append(2*a[i-1]-ans[i-1])
print(ans)
print(" ".join(list(map(str, ans))))

Submission status: Wrong Answer

Solution code:
from numpy.linalg import solve
n=int(input())
a=list(map(int,input().split()))
c=[2*i for i in a]
print(c)
A=[[1 if i==j or i==(j+1)%n else 0 for i in range(n)] for j in range(n)]
x=solve(A,c)
print(" ".join(list(map(str,list(map(int,x))))))

Submission status: Wrong Answer

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

M_list.append(sum(A_list)-sum(A_list[::2])) 
print(M_list[0])

for i in range (N):
         M_list.append(2 * A_list[i] - M_list[i])


print(*M_list)

Submission status: Wrong Answer

Solution code:
import sys

def solve(N, A):
    def moutain(x):
        sum = 0
        for i in range(N):
            sum += A[(x+i)%N] * (-1) ** (i)
        return sum

    m = [int()] * N
    for i in range(N):
        m[i] = moutain(i)

    print(m)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    solve(N, A)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
n=int(sys.stdin.readline())
a=list(map(int,sys.stdin.readline().split()))

x=[sum(a)-2*sum(a[1::2])]
for i in range(n-1):
    s=2*a[0]-x[i]
    x.append(s)
s=map(str,x)
print(" ".join(s))

Submission status: Wrong Answer

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

xn = 0
for i in range(n-1):
    xn = xn + (-1) ** (i+1) * int(A[i])

xn = xn + A[n-1]

x = []
x1 = 2*A[n-1]-xn
x.append(x1)

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

Submission status: Wrong Answer

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

# size = 3
# items = list(map(int, "1000000000 1000000000 0".split()))
# size = 3
# items = list(map(int, "2 2 4".split()))

total = sum(items)
for y1 in reversed(range(0, total, 2)):
  # print(y1)
  tmp = [0] * size
  res = [0] * size
  np1 = y1
  flg = False
  for i, item in enumerate(items):
    # print("y1:{} np1:{} item:{}".format(y1, np1, item))
    res[i] = np1

    if np1 != -1 and np1 // 2 > item:
      # print("break:{}".format(item))
      break

    tmp[i] += np1 // 2
    tmp[(i + 1) % size] += np1 // 2

    np1 = int(item - tmp[(i + 1) % size]) * 2

  if tmp[0] == items[size - 1]:
    print(" ".join(map(str, res)))
    quit()

Submission status: Wrong Answer

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

Ns=[]
N1=0
for i in range(N):
  N1+=(A[i]*(-1)**(i-1))
Ns.append(N1)
for i in range (1,N):
  n=(A[i-1]-Ns[i-1]/2)*2
  Ns.append(n)
  
print(Ns)

Submission status: Wrong Answer

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

D = []

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

D = [0 for i in range(N)]
D[0] = x

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

ans = [str(i) for i in D]
print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
x=a[n-1]
for i in range(0,n-2,2):
	x += a[i] - a[i+1]
x /= 2
m = [x]
for t in range(n-1):
	m.append(a[t]-m[t])
m = [int(mountain * 2) for mountain in m]
print(m)

# m  = []
# m.append(a[0]+a[n-1])
# for i in range(1,n):
# 	m.append(a[i-1]+a[i])
# # print(' '.join(m))
# print(m)
# print(a)

Submission status: Wrong Answer

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

S = sum(A)
x1 = S - 2 * sum([A[i] for i in range(len(A)) if i % 2 == 1])
ansList = [x1]
print(x1)
for i in range(1, N):
    tmp = 2 * A[i-1] - ansList[-1]
    ansList.append(tmp)
ansList = [str(a) for a in ansList]
ans = ' '.join(ansList)
print(ans)

Submission status: Wrong Answer

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

S = sum(A)
x1 = S - 2 * sum([A[i] for i in range(len(A)) if i % 2 == 1])
ansList = [x1]
for i, a in enumerate(A[1:]):
    tmp = 2 * a - ansList[0]
    ansList.append(tmp)
ansList = [str(a) for a in ansList]
ans = ' '.join(ansList)
print(ans)

Submission status: Wrong Answer

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

minA = min(A)
idx_minA = A.index(minA)

A_new = A[idx_minA:] + A[:idx_minA]

x0_half_cands = [a for a in range(minA+1)]

for x0_half in x0_half_cands:
    x_values = [x0_half]
    has_missed = False
    for idx in range(N-1):
        a = A_new[idx]
        x_next = a - x_values[-1]
        if x_next < 0:
            has_missed = True
            break
        else:
            x_values.append(x_next)
    if (not has_missed) and (x_values[0] + x_values[-1] == A[N-1]):
        break

x_values = x_values[-idx_minA:] + x_values[:-idx_minA]
x_values = [str(2*x) for x in x_values]
print(' '.join(x_values))

Submission status: Wrong Answer

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

xlist=[1]*N

S=0
for a in A:
  S+=a

S1=0
for i in range(1,N-1):
  S1+=A[i]
  
xlist[0]=S-2*S1
for i in range(1,len(xlist)):
  xlist[i]=2*A[i-1]-xlist[i-1]
  
ans=" ".join(map(str, xlist))
print(ans)

Submission status: Wrong Answer

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

x0_half_cands = [a for a in range(A[0]+1)]

for x0_half in x0_half_cands:
    x_values = [x0_half]
    has_missed = False
    for idx in range(N):
        a = A[idx]
        x_next = a - x_values[-1]
        if x_next < 0:
            has_missed = True
            break
        else:
            x_values.append(x_next)
    if not has_missed:
        break
x_values = [str(2*x) for x in x_values]
print(' '.join(x_values))

Submission status: Wrong Answer

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

start = A.index(min(A))
B = [0]*N
flag = False

for j in range(5*10000):    
    B[start] = 2 * j
    for i in range(start,start+N):
        B[(i+1)%N] = 2*A[i%N] - B[i%N]
        if B[(i+1)%N] < 0:
            break
        if (i+1)%N == start and B[start] == 2*j:
            flag = True
    if flag == True:
        break
        
for k in range(N):
    print(B[k], end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
ans = A
for i in range(1, N):
    ans += (-1) ** i * np.concatenate([A[i:].copy(), A[:i].copy()])
ans = list(ans)
print(" ".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
ans = np.zeros((N), dtype=np.int)
tmp = np.zeros((N), dtype=np.int)
for i in range(N):
    if i == 0:
        tmp = A.copy()
    else:
        tmp = np.concatenate([A[i:].copy(), A[:i].copy()])
    print(tmp)
    ans += (-1) ** i * tmp
ans = list(ans)
print(" ".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
ans = np.zeros((N), dtype=np.int)
tmp = np.zeros((N), dtype=np.int)
for i in range(N):
    if i == 0:
        tmp = A.copy()
    else:
        tmp[:-i] = A[i:].copy()
        tmp[-i:] = A[:i].copy()
    print(tmp)
    ans += (-1) ** i * tmp
ans = list(ans)
print(" ".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())
_a = input().split()

a = []

x = []

for i in range(n):
  a.append(2*int(_a[i]))
  x.append(0)
  
for i in range(1, n):
  a[i] -= a[i-1]

x[n-1] = a[n-1] // 2

for i in range(n-2, -1, -1):
  print(i)
  if i%2==0:
    x[i] = a[i] - x[n-1]
  else:
    x[i] = a[i] + x[n-1]
    
ans = str(x[n-1]) + ' '
for i in range(n-1):
  ans += str(x[i]) + ' '
  

print(ans[:-1])

Submission status: Wrong Answer

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

x1 = sum(A) - 2 * sum([A[i] for i in range(1,N,2)])
x = [x1]

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

print(x)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

N = int(N)
flag = 0
x = np.zeros(N)
for i in range(2 * A[0] + 1):
    x[0] = 2 * A[0] - i
    for j in range(N - 1):
        x[j + 1] = 2 * A[j] - x[j]
        if x[j + 1] < 0:
            break
        if j == N - 2:
            flag = 1
    if flag == 1:
        print(x)
        break

Submission status: Wrong Answer

Solution code:
N = int(input())
l_a = list(map(int,input().split()))
print(l_a[1::2])
b_x = sum(l_a) - sum(l_a[1::2])*2
l_x =[b_x]
for s in range(N-1):
    x = l_a[s]*2 - b_x
    l_x.append(x)
    b_x = x
print(l_x)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
b=sum(a)//2
c=[0]*n
c[-1]=b-sum(a[1::2])
for i in range(n-1,0,-1):
  c[i-1]=a[i-1]-c[i]
print(" ".join([str(i*2) for i in c]))

Submission status: Wrong Answer

Solution code:
a=int(input())
b=list(map(int,input().split()))
c=sum(b)
e=0
f=0

for i in range(a):
  if i%2==0:
    e=e+2*b[i]
  else:
    f=f+2*b[i]
    
d=[]
for i in range(a):
  x=0
  if i%2==0:
    x=f
    if a!=3 and i==a-1:
      x=e-2*b[(i-1)%a]
  else:
    x=e-2*b[(i-1)%a]
  d.append(c-x)

for i in d:
  print(i,end=' ')

Submission status: Wrong Answer

Solution code:
a=int(input())
b=list(map(int,input().split()))
c=sum(b)
e=0
f=0

for i in range(a):
  if i%2==0:
    e=e+2*b[i]
  else:
    f=f+2*b[i]
    
d=[]
for i in range(a):
  x=0
  if a!=3 and i%2==0:
    x=f
    if i==a-1:
      x=e-2*b[(i-1)%a]
  else:
    x=e-2*b[(i-1)%a]
  d.append(c-x)

for i in d:
  print(i,end=' ')

Submission status: Wrong Answer

Solution code:
n=int(input())
ls=list(map(int,input().split()))
t=sum(ls)-2*sum(ls[1::2])
x=[t]
for i in ls:
    t=i*2-t
    x.append(t)
x.pop()
print(x)

Submission status: Wrong Answer

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


def find_mountain_rain_amount(N, A):
    for i in range(N):
        A[i] = A[i] * 2

    offset = 0
    for i in range(N):
        offset = A[i] - offset

    x = offset // 2

    cur = x
    ans = []
    for i in range(N):
        ans.append(cur)
        cur = A[i] - cur

    return ans


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = find_mountain_rain_amount(N, A)
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
num = int(input())
a = input().split()
b = list(map(int, a))
sum = sum(b)

X = [0]*num
X1 = 0
for i in range(num):
  if((2*i+1) >= num):
    break
  X1 = b[2*i+1] + X1
X[0] = sum - 2 * X1

for i in range(1,num):
  X[i] = b[i-1]*2 - X[i-1]
print(X)

Submission status: Wrong Answer

Solution code:
n =  map(int, raw_input().split())

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

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