TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
l, r = [int(i) for i in input().split()]

base = 2019
l_mod = l % base
r_mod = r % base

print(l_mod * (l_mod + 1))


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))


Verdicts: Runtime Error

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

Submission attempts (in order):
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))

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)):
  ans.append(2*(t[i-1]-(ans[i-1]//2)))

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
List = []
List.append(sum(a[0::2])-sum(a[1::2]))
for i in range(n-1):
	List.append(2 * a[i]-List[i])
print(List)

n = int(input())
a = list(map(int,input().split()))
List = []
List.append(sum(a[0::2])-sum(a[1::2]))
for i in range(n-1):
	List.append(2 * a[i]-List[i])
print(' '.join(map(str,List)))

Verdicts: Wrong Answer

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

Submission attempts (in order):
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)

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]
a_tot=0
for j in range(n//2):
  a_tot+=a_cycle[2*j+1]
b[0]=total-2*a_tot
for i in range(1,n):
  b[i]=2*a[i-1]-b[i-1]
print(*b)

Verdicts: Wrong Answer

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

Submission attempts (in order):
N = int(input())
waters = list(map(int, input().split()))
ans = []
x = sum(waters) - sum([waters[i] for i in range(1, N-1, 2)])*2
ans.append(x)
for i in range(N-1):
    ans.append(waters[i] * 2 - x)
    x = ans[-1]
print(ans)

N = int(input())
waters = list(map(int, input().split()))
ans = []
x = sum(waters) - sum([waters[i] for i in range(1, N-1, 2)])*2
ans.append(x)
for i in range(N-1):
    ans.append(waters[i] * 2 - x)
    x = ans[-1]
output = [str(num) for num in ans]
print(' '.join(output))

Verdicts: Wrong Answer

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

Submission attempts (in order):
#coding utf-8
N=int(input())
A=list(map(int,input().split())) 
x = [0 for i in range(N)]
S =sum(A)
x[0]=S
for i in range(1,N,2):
  x[0]-=2*A[i]

for i in range(1,N):
  x[i]=2*A[i-1]-x[i-1]
print(S)
ans= map(str,x)
print(' '.join(ans))

#coding utf-8
N=int(input())
A=list(map(int,input().split())) 
x = [0 for i in range(N)]
S =sum(A)
x[0]=S
for i in range(1,N,2):
  x[0]-=2*A[i]

for i in range(1,N):
  x[i]=2*A[i-1]-x[i-1]
ans= map(str,x)
print(' '.join(ans))

Verdicts: Wrong Answer

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

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

for i in range(0, min(2 * A[0], 2 * A[1]) + 1, 2):
    ans = [0] * N
    ans[0] = i
    odd = False
    for j in range(1, N):
        ans[j] = 2 * A[j - 1] - ans[j - 1] // 2
        if ans[j] % 2 == 1:
            odd = True
            break
    if not odd:
        print(' '.join(map(str, ans)))


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

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

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


Verdicts: Wrong Answer

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

Submission attempts (in order):
import numpy as np
n = int(input())
A = [int(i) * 2 for i in input().split()]

L1 = [[0] * n for _ in range(n)]
for i in range(n):
    if i + 1 <= n-1:
        L1[i][i] = 1
        L1[i][i+1] = 1
    else:
        L1[i][i] = 1
        L1[i][0] = 1
        
L1 = np.linalg.inv(L1)
L2 = np.array(A)

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

x1 = sum(A)
for i in range(n):
    if i % 2 == 0:
        x1 -= A[i]
ans = [x1]
for i in range(n-1):
    tmp = 2 * A[i] - ans[i]
    ans.append(tmp)
print(" ".join([str(int(n)) for n in ans]))

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

x1 = sum(A)
for i in range(n):
    if i % 2 != 0:
        x1 -= 2 * A[i]
ans = [x1]
for i in range(n-1):
    tmp = 2 * A[i] - ans[i]
    ans.append(tmp)

print(" ".join([str(int(n)) for n in ans]))

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
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)

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

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)

Verdicts: Wrong Answer

Wrong Answer

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

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

L=[i 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]-ans[i-1]
  
print(ans)

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)


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+i]-a

ans[0]=a//2

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

print(*ans)


Verdicts: Runtime Error

Wrong Answer

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

Submission attempts (in order):
from sys import exit

N = int(input())

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


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

n = A[N - 1] + a

_x = n
ans = []
for i in range(N - 1):
    if i == 0:
        ans.append((A[N - 1] - _x / 2) * 2)
        _x = (A[N - 1] - _x / 2) * 2
    else:
        ans.append((A[i - 1] - _x / 2) * 2)
        _x = (A[i - 1] - _x / 2) * 2

ans.append(n)

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


from sys import exit

N = int(input())

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


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

n = A[N - 1] + a

_x = n
ans = []
for i in range(N - 1):
    if i == 0:
        ans.append(int((A[N - 1] - _x / 2) * 2))
        _x = (A[N - 1] - _x / 2) * 2
    else:
        ans.append(int((A[i - 1] - _x / 2) * 2))
        _x = (A[i - 1] - _x / 2) * 2

ans.append(n)

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


Verdicts: Wrong Answer

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

Submission attempts (in order):
N=int(input())
dums = list(map(int, input().split()))

M_1 = 0
for i,val in enumerate(dums):
    i+=1
    if i%2==1:
        M_1 += val
    else:
        M_1 -= val

out_dict = {i+1:0 for i in range(N)}
out_dict[1] = M_N

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

print(" ".join(list(map(str, out_dict.values()))))

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

M_1 = 0
for i,val in enumerate(dums):
    i+=1
    if i%2==1:
        M_1 += val
    else:
        M_1 -= val

out_dict = {i+1:0 for i in range(N)}
out_dict[1] = M_1

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

print(" ".join(list(map(str, out_dict.values()))))

Verdicts: Runtime Error

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

Submission attempts (in order):
import scipy.linalg as linalg

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

A = np.zeros(N**2).reshape(N, N)
for i in range(N):
    for j in range(N):
        if i == j or i+1 == j:
            A[i, j] = 1
        else:
            continue
A[N-1, 0] = 1
A = A / 2
A_inv = linalg.inv(A)

x = np.dot(A_inv, b)
print(*x)

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

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

ans.append(x1)

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

print(*ans)

Verdicts: Runtime Error

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

Submission attempts (in order):
import sys
input = sys.stdin.readline

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

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

print(X)


ANS=[X]

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

print(*ANS)


import sys
input = sys.stdin.readline

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

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

#print(X)


ANS=[X]

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

print(*ANS)


Verdicts: Wrong Answer

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

Submission attempts (in order):
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
argmn = np.argmin(A)
mn = A[argmn]
for m in range(mn+1):
  B = np.zeros(len(A))
  B[argmn] = m * 2
  for i in range(len(A)):
    idx = (i + argmn)%len(A)
    B[(idx+1)%len(A)]  += A[idx] * 2  - B[idx]
  B[argmn] -= m * 2
  if (B[argmn]+B[(argmn+1)%len(A)]==(A[argmn]*2)):
    print (" ".join(B.astype(np.int).astype(np.str)))
    exit()

N = int(input())
A = list(map(int, input().split()))
sm = sum(A)
x = sm-2*sum(A[1::2])
X = []
X.append(str(x))
for i in range(N-1):
   x = 2*A[i]-x
   X.append(str(x))
print (" ".join(X))

Verdicts: Time Limit Exceeded

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

Submission attempts (in order):
import sys
import numpy as np


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    a = [int(e) for e in input().split()]
    va = np.array(a)
    m = np.identity(n, dtype=int)
    for i in range(n):
        if i < n - 1:
            m[i][i + 1] = 1
        else:
            m[i][0] = 1
    vx = np.linalg.solve(m, va).astype(np.int) * 2
    print(*vx)


main()


import sys
import numpy as np


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    a = [int(e) for e in input().split()]
    x = [0 for _ in range(n)]
    x[0] = sum(a) - (sum(a[1:n:2]) * 2)
    for i in range(2, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    x[1] = sum(a) - (sum(a[2:n:2]) * 2)
    for i in range(3, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    print(*x)


main()


Verdicts: Runtime Error

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

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

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

ans = [0] * N
ans[0] = a

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

print(*ans)

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

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

ans = [0] * N
ans[0] = a

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

print(*ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
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])

# 	m.append(a[i-1]+a[i])
# # print(' '.join(m))
# print(m)
# print(a)

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
data = [0]*n
one = 0
for i in range(n):
  if i%2 == 0:
    one += A[i]
  else:
    one -= A[i]
data[0] = one
for i in range(1,n):
  data[i] = (A[i-1]-data[i-1]//2)*2
print(*data)

Verdicts: Wrong Answer

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

Submission attempts (in order):
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)

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(" ".join(map(str,X)))

Verdicts: Wrong Answer

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

Submission attempts (in order):
# 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)

# coding: utf-8
import math

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

res = list()
res.append(A_sum - 2 * sum([A[(2*j+1)] for j in range(int((N-1)/2))]))

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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
ans = [0] * n
double_x = 0

for i, t in enumerate(a):
    double_x += (1 + -2 * (i % 2)) * t

ans[0] = double_x

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

print(ans)

n = int(input())
a = list(map(int,input().split()))
ans = [0] * n
double_x = 0

for i, t in enumerate(a):
    double_x += (1 + -2 * (i % 2)) * t

ans[0] = double_x

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

print(*ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
from array import array
N = int(input())
S = input()
a = ['A', 'B', 'X', 'Y']
L = []
for i in range(16):
    L.append(a[i//4]+a[i%4])
ans = N+1
for m in range(16):
    for n in range(16):
        i=L[m]
        j=L[n]
        dp = array('i', [k for k in range(N+1)])
        for k in range(2, N+1):
            if S[k-2]+S[k-1] in {i, j}:
                dp[k] = min(dp[k-2], dp[k-1])+1
            else:
                dp[k] = dp[k-1]+1
        ans = min(ans, dp[N])
print(ans)


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

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


Verdicts: Wrong Answer

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

Submission attempts (in order):
import numpy as np
N = int(input())
A = list(map(int, input().split()))

# solve "mat * x = b" about x
x, y = np.identity(N), np.identity(N)
y0 = y[0]
y = np.reshape(np.append(np.delete(y, 0, 0), y0), (N, N))
mat = (x + y) / 2

b = np.array(A)

for i in range(len(mat) - 1):
    for j in range(i + 1, len(mat)):
        coef = mat[j][i] / mat[i][i]
        mat[j] -= mat[i] * coef
        b[j] -= b[i] * coef

for i in range(len(mat) - 1, 0, -1):
    b[i] /= mat[i][i]
    mat[i] /= mat[i][i]
    for j in range(i):
        b[j] -= b[i] * mat[j][i]
        mat[j][i] = 0

b = [int(n) for n in b]
b[0] += 1
print(" ".join(map(str, b)))


N = int(input())
A = list(map(int, input().split()))
X = [0] * N

X[0] = sum(A) - 2 * (sum([A[i] for i in range(N) if i % 2 == 1]))

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

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


Verdicts: Runtime Error

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

Submission attempts (in order):
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
P = []
for i in range(N):
    if i == N - 1:
        P.append([0.5] + [0] * (N - 2) + [0.5])
    else:
        P.append([0] * i + [0.5, 0.5] + [0] * (N - 2 - i))
P = np.array(P)
for i in np.dot(np.linalg.inv(P), A):
    print(int(i)," ", end="")


N = int(input())
A = [int(i) for i in input().split()]
# dif = A1-A2+A3-A4 ...
dif = sum([A[i] * pow(-1, i) for i in range(N - 1)])
ans = [0] * N
ans[0] = A[-1] + dif
ans[-1] = A[-1] - dif
for i in range(1, N - 1):
    ans[i] = 2 * A[i - 1] - ans[i - 1]
print(*ans)


Verdicts: Time Limit Exceeded

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

Submission attempts (in order):
n = int(input())
a = [int(x) for x in input().split(' ')]
# a = [int(input()) for x in range (n)]

b = [0] * n
if(a[0] > a[-1]) : mi = a[-1]
else : mi = a[-0]


for x in range(mi*2, -1,-2) :
    # print(x)
    b[0] = x

    for i in range(1,n) :
        b[i] = 2 * a[i-1] - b[i-1]
        # print(b)
        if (b[i] < 0) : 
            break

    else :
        if (b[-1] + b[0] == 2 * a[-1]) :
            break


s = ""
for i in b :
    s = s + str(i) + " " 


print(s)

n = int(input())
a = [int(x) for x in input().split(' ')]
# a = [int(input()) for x in range (n)]

b = [0] * n
if(a[0] > a[-1]) : mi = a[-1]
else : mi = a[-0]


for x in range(0,mi*2+1,2) :
    # print(x)
    b[0] = x

    for i in range(1,n) :
        b[i] = 2 * a[i-1] - b[i-1]
        # print(b)
        if (b[i] < 0) : 
            break

    else :
        if (b[-1] + b[0] == 2 * a[-1]) :
            break


s = ""
for i in b :
    s = s + str(i) + " " 


print(s)

n = int(input())
a = [int(x) for x in input().split(' ')]

b = [0] * n
if(a[0] > a[-1]) : mi = a[-1]
else : mi = a[0]

aa = 0
for i in range(1, n, 2) :
    aa += a[i]
b[0] = sum(a) - 2 * aa

for i in range(1,n) :
    b[i] = 2 * a[i-1] - b[i-1]
print(str(b).strip("[]").replace(",",""))

Verdicts: Time Limit Exceeded

Time Limit Exceeded

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

Submission attempts (in order):
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)


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)


Verdicts: Wrong Answer

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

Submission attempts (in order):
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]+=(a2-a1)*2
        a[i]-=(a2-a1)
        a[i+1]-=(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))))

n=int(input())
a=list(map(int, input().split()))
r=[0]*n

while max(a) != min(a):
    for i in range(n):
        a1,a2,a3=a[i-1], a[i], a[(i+1)%n]
        if a2 > a1:
            val=min(a3, a2-a1)
            r[(i+1)%n]+=val*2
            a[i]-=val
            a[(i+1)%n]-=val
        if a2 > a3:
            val=min(a1, a2-a3)
            r[i]+=val*2
            a[i]-=val
            a[i-1]-=val

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

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

Verdicts: Runtime Error

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

Submission attempts (in order):
N = int(input()) 
inputs = [int(i) for i in input().split()]

double_inputs = list(map(lambda x: x * 2, inputs))
for i in range(N):
    total = sum(inputs)
    for j in range((N - 1) // 2):
        total -= double_inputs[(i+1+2*j)%N]
    print(total)

N = int(input()) 
inputs = [int(i) for i in input().split()]

double_inputs = list(map(lambda x: x * 2, inputs))
ans = [0 for _ in range(N)]
for i in range(N):
    if i == 0:
        ans[i] = sum(inputs) - sum(double_inputs[1::2])
    elif i == N - 1:
        ans[i] = double_inputs[-1] - ans[0]
    else:
        ans[i] = double_inputs[i-1] - ans[i-1]

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


Verdicts: Time Limit Exceeded

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

Submission attempts (in order):
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)

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)

Verdicts: Wrong Answer

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

Submission attempts (in order):
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)


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)


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)


Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
import os, sys, re, math

N = int(input())
A = list(map(int, input().split(' ')))
ret = [0 for _ in range(len(A))]
tmp = [0 for _ in range(len(A))]

init = sum(A) - 2 * sum([A[i] for i in range(1,N,2)])
ret[0] = init
for i in range(N):
    if i == 0:
        tmp[i] += ret[i] // 2
        tmp[i-1] += ret[i] // 2
    else:
        d = A[i-1] - tmp[i-1]
        if d < 0:
            break
        else:
            tmp[i] += d
            ret[i] += d * 2

print(ret)


import os, sys, re, math

N = int(input())
A = list(map(int, input().split(' ')))
ret = [0 for _ in range(len(A))]
tmp = [0 for _ in range(len(A))]

init = sum(A) - 2 * sum([A[i] for i in range(1,N,2)])
ret[0] = init
for i in range(N):
    if i == 0:
        tmp[i] += ret[i] // 2
        tmp[i-1] += ret[i] // 2
    else:
        d = A[i-1] - tmp[i-1]
        if d < 0:
            break
        else:
            tmp[i] += d
            ret[i] += d * 2

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


Verdicts: Wrong Answer

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

Submission attempts (in order):
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)))

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))




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


for n in range(1,N,1):
  _ = 2 * A[n-1] - ans[n-1]
  ans.append(_)


print(ans)

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




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


for n in range(1,N,1):
  _ = 2 * A[n-1] - ans[n-1]
  ans.append(_)


print(*ans)

Verdicts: Wrong Answer

Accepted