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):
N = int(input())
A = map(lambda x: 2 * int(x), input().split())

all_mount = sum(A) // 2
A_1 = all_mount
for i in range(1, N, 2):
  A_1 -= A[i]
  
mounts = [A_1]
for i in range(N-1):
  mounts.append(A[i] - mounts[i])
  
print(" ".join(mounts))

N = int(input())
A = list(map(lambda x: 2 * int(x), input().split()))

all_mount = sum(A) // 2
A_1 = all_mount
for i in range(1, N, 2):
  A_1 -= A[i]
  
mounts = [A_1]
for i in range(N-1):
  mounts.append(A[i] - mounts[i])
  
print(" ".join(map(str, mounts)))

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


N = int(input())
l_a = list(map(int,input().split()))
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)


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 = [int(x) for x in input().split()]
r = [0]*(N+1)
for i in range(N):
  r[i+1] = A[i]-r[i]
x = r[N]
r[1::2] = r[1::,2]-x
r[0::2] = r[1::,2]+x
r = list(map(str,r))
print(" ".join(r))


import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
r = np.array([0]*(N+1))
for i in range(N):
  r[i+1] = A[i]-r[i]
x = r[N]
#print(r)
r[1::2] = r[1::2]*2-x
r[0::2] = r[0::2]*2+x
r = r[:N]
r = list(map(str,r))
print(" ".join(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):
import sympy

N = input()
Y = list(map(int,input().split(' ')))

symbols = []
for i in range(N):
    symbols.append(sympy.Symbol('x' + str(i)))

equation = []
for i in range(N):
    i1 = i
    i2 = i + 1 
    if i2 >= N:
        i2 = 0
    equation.append(0.5*symbols[i1] + 0.5*symbols[i2] - Y[i])

for i in range(N):
    print(str(int(sympy.solve(equation)[symbols[i]])) + " " , end="")
print()

import sympy

N = 3
Y = list(map(int,input().split(' ')))


symbols = []
for i in range(N):
    symbols.append(sympy.Symbol('x' + str(i)))

equation = []
for i in range(N):
    i1 = i
    i2 = i + 1 
    if i2 >= N:
        i2 = 0
    equation.append(0.5*symbols[i1] + 0.5*symbols[i2] - Y[i])

for i in range(N):
    print(str(int(sympy.solve(equation)[symbols[i]])) + " " , end="")
print()

import sympy

N = int(input())
Y = list(map(int,input().split(' ')))


symbols = []
for i in range(N):
    symbols.append(sympy.Symbol('x' + str(i)))

equation = []
for i in range(N):
    i1 = i
    i2 = i + 1 
    if i2 >= N:
        i2 = 0
    equation.append(0.5*symbols[i1] + 0.5*symbols[i2] - Y[i])

for i in range(N):
    print(str(int(sympy.solve(equation)[symbols[i]])) + " " , end="")
print()

# -*- coding: utf-8 -*-
 
N = int(input())
A = list(map(int, input().split()))
s = sum(A)
r = [s - 2 * sum(A[1::2])]

for i in range(N-1):
    r.append(2 * A[i] - r[i])
    
r = map(str, r)
print(" ".join(r))

'''
5
3 8 7 5 5
'''

Verdicts: Runtime Error

Runtime Error

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, = map(int, input().split())
A = np.array(A, dtype='int64')
C = np.diag([1 for _ in range(N)]) + np.diag([1 for _ in range(N-1)], k=1)
C[-1, 0] = 1
X = np.linalg.solve(C, A)
X = list(map(int, X))
print(*X)

N = int(input())
*A, = map(int, input().split())
X = [0]*N
total = sum(A)
X[0] = total - 2*sum([a for a in A[1::2]])
for i in range(1, N):
    X[i] = 2*A[i-1] - X[i-1]
print(*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):
N = int(input())
A = list(map(int, input().split()))

s = sum(A)
c = 0
for i in range(2, N, 2):
    c += A[i]

ans = [s - 2 * c]

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

print(*ans)


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

s = sum(A)
c = 0
for i in range(2, N, 2):
    c += A[i]

a = [s - 2 * c]

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

ans = [a[-1]]
ans.extend(a[:-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):

L, R = map(int, input().split())
# 2019 = 3*673
p = 673
if R-L>=p:
    print(0)
else:
    ans = 2019
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans = min((i*j)%2019, ans)
    print(ans)

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

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()))
X =[0]*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
print(X[0])
for i in range(1,N):
  X[i]=A[i]-X[i-1]
  print(X[i])
  

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

import numpy as np
N = int(input())
A = list(map(int,input().split()))
X =[0]*N
sum_=0
for i in range(N):
  if i%2==0:
    sum_=sum_+A[i]
  else:
    sum_=sum_-A[i]
X[0]=int(sum_/2)
for i in range(1,N):
  X[i]=A[i-1]-X[i-1]
X = list(np.array(X)*2)
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())
a = list(map(int, input().split( )))

a_sum = sum(a)
a_sum //= 2

a_sum_0 = sum(a[1::2])

ans = []
a0 = a_sum -a_sum_0
print(a_sum,a_sum_0,a0)
ans.append(2*a0)
a[0] -= a0
for i in range(n-1):
    ans.append(2*a[i])
    a[i+1] -= a[i]
    
print(*ans)

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

a_sum = sum(a)
a_sum //= 2

a_sum_0 = sum(a[1::2])

ans = []
a0 = a_sum -a_sum_0
ans.append(2*a0)
a[0] -= a0
for i in range(n-1):
    ans.append(2*a[i])
    a[i+1] -= a[i]
    
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 = list(map(int, input().split()))

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

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

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

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

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

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

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

  tmp = ans
  print(ans, end = "")
  if i != N - 1:
    print(" ", end = "")
  else:
    print()

Verdicts: Wrong Answer

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()))
all_rain = sum(l)
ans = []

for i in range(n):
    now = (i+2)%n
    others = 0
    while now%n != (i+1)%n:
        others += l[(now-1)%n]
        now = (now+2)%n
    ans.append(all_rain-others*2)

print(ans)

n = int(input())
l = list(map(int, input().split()))
ans = []

cnt =1
rain_others = 0
while cnt != n:
    rain_others += l[cnt] * 2
    cnt += 2
ans.append(sum(l)-rain_others)

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

print(" ".join(list(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):
def nCk(_n,_k):
  if _k==0:
    return 1
  else:
    if _n<0 or _k<0 or _n-_k<0:
      return 0
    else:
      return (fact[_n]//(fact[_k]*fact[_n-_k]))%m

fact=[1]*2005
for i in range(1,2001):
  fact[i]=fact[i-1]*i

n,k=map(int,input().split())
m=10**9+7
ans=cnt=0
for _k in range(1,k+1):
  ans=(nCk(n-k+_k,_k)-cnt)*nCk(k-1,_k-1) if _k>1 else n-k+_k 
  cnt+=ans
  cnt%=m
  ans%=m
  print(ans)


l,r=map(int,input().split())
m,ans=2019,2018
r=min(r,l+2019*2)
for i in range(l,r+1):
  for j in range(i+1,r+1):
    i%=m
    j%=m
    ans=min(ans,(i*j)%m)
print(ans)


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

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

print(*ans)


Verdicts: Runtime Error

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())
As = list(map(int, input().split()))

A_all = sum(As)//2

ans = []
for i in range(N):
    cnt = 0
    for j in range(N//2):
        index = i+2*j
        cnt += As[index%N]
    ans.append((A_all-cnt)*2)
 
a = ""
for i in range(1,N+1):
    a += str(ans[i%N])+" "
print(a)

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

Asum = sum(As)
sum_eve = 0 
sum_odd = 0 

for i,a in enumerate(As+[As[0]]):
    if i % 2 == 0:
        sum_eve += a
    if i % 2 == 1:
        sum_odd += a 
# print(sum_eve)   
# print(sum_odd)
ans = [0] * N
ans[0] = sum_eve-Asum//2
ans[1] = sum_odd-Asum//2

n = N//2
for i in range(2,N):
    i_d = i-2  
    i_a = (i+2*n)%N 
    # print(i)
    ans[i] = ans[i-2] - As[i_d] + As[i_a]

ans = [2*a for a in ans]

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):
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)
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=" ")

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)


a = np.diag(n1)
b = np.diag(n2,k=1)
print('u')



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


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)


a = np.diag(n1)
b = np.diag(n2,k=1)
c = a+b
print('u')



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)


a = np.diag(n1)
print('u')



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)
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)
print('u')

#    print(int(i[0]),end=' ')

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

All = sum(A)

lim = len(A)//2
Exc1 = sum([A[2*i+1] for i in range(lim)])

one = All - Exc1*2
ans = [one]
for i in range(1,N):
    print('{}'.format(ans[-1]),end=' ')
    ans.append(A[i-1]*2 - ans[-1])
print('{}'.format(ans[-1]))


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

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

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

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

for i in range(a[0]*2+1):
    b = [i]
    for j in range(1,n):
        c = a[j-1]*2-b[-1]
        if not (c<0):
            b.append(c)
        else:
            break
    if len(b)==n and (b[0]+b[-1] == a[-1]*2):
        print(b)
        exit(0)

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

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

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()))
S=sum(A)
B=[0]*N
B[0]=S-2*sum(A[1::2])
for i in range(n-1):
    B[i+1]=2*A[i]-B[i]
print(*B)

N=int(input())
A=list(map(int,input().split()))
S=sum(A)
B=[0]*N
B[0]=S-2*sum(A[1::2])
for i in range(N-1):
    B[i+1]=2*A[i]-B[i]

print(*B)

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()))
if A[0] == 0 or A[N-1] == 0:
  A_tmp = A[0]
  A_ = A[1:N]
  A_.append(A_tmp)
  A = A_
  flag = 1
else:
  flag = 0
if A[0]<A[N-1]:
  start = A[0]
else:
  start = A[N-1]
for i in range(2*start,1,-2):
  ans = [i]
  A_tmp = A[:]
  A_tmp[0] -= ans[0]//2
  A_tmp[N-1] -= ans[0]//2 
  for j in range(1,N):
    if A_tmp[j-1]<A_tmp[j]:
      ans.append(A_tmp[j-1]*2)
      A_tmp[j] -= ans[j]//2
      A_tmp[j-1] -= ans[j]//2
    else:
      ans.append(A_tmp[j]*2)
      A_tmp[j] -= ans[j]//2
      A_tmp[j-1] -= ans[j]//2
  if sum(A_tmp)==0:
    break
if flag == 1:
  tmp = [0]*N
  tmp[1:] = ans[:N-1]
  tmp[0] = ans[N-1]
  ans = tmp
print(ans)

N = int(input())
A = list(map(int,input().split()))
if A[0] == 0 or A[N-1] == 0:
  A_tmp = A[0]
  A_ = A[1:N]
  A_.append(A_tmp)
  A = A_
  flag = 1
else:
  flag = 0
if A[0]<A[N-1]:
  start = A[0]
else:
  start = A[N-1]
for i in range(2*start-2,1,-2):
  ans = [i]
  A_tmp = A[:]
  A_tmp[0] -= ans[0]//2
  A_tmp[N-1] -= ans[0]//2 
  for j in range(1,N):
    if A_tmp[j-1]<A_tmp[j]:
      ans.append(A_tmp[j-1]*2)
      A_tmp[j] -= ans[j]//2
      A_tmp[j-1] -= ans[j]//2
    else:
      ans.append(A_tmp[j]*2)
      A_tmp[j] -= ans[j]//2
      A_tmp[j-1] -= ans[j]//2
  if sum(A_tmp)==0:
    break
if flag == 1:
  tmp = [0]*N
  tmp[1:] = ans[:N-1]
  tmp[0] = ans[N-1]
  ans = tmp
ans = map(str,ans)
print(' '.join(ans))


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

Verdicts: Runtime Error

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 = [int(i) for i in input().split()]
x = [0]*n
for i in range(n):
  x[i] = sum(a)
  for j in range(0, i):
    if (j-i) % 2 == 0:
      x[i] -= 2*a[j]
  for j in range(i, n):
    if (j-i) % 2 == 1:
      x[i] -= 2*a[j]
print(x)

n = int(input())
a = [int(i) for i in input().split()]
x = [0]*n

x[0] = sum(a)
for j in range(1, n, 2):
  x[0] -= 2*a[j]
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):
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)

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)

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

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

import sys

def solve(N, A):
    m = [int()] * (N)
    for i in range(N):
        m[0] += A[i] * (-1)**i

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

    m = map(str, m)
    print(' '.join(m))

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

if __name__ == "__main__":
    main()

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())
a = [ 2*int(i) for i in sys.stdin.readline().split()]
f = (sum(a) - 2* sum(a[1::2]))//2
ans = [f] + [0 for i in range(n-1)]
print(ans)
for i in range(n-1):
    ans[i+1] =  a[i] - ans[i]
print(" ".join(map(str, ans)))


import sys
n = int(input())
a = [ 2*int(i) for i in sys.stdin.readline().split()]
f = (sum(a) - 2* sum(a[1::2]))//2
ans = [f] + [0 for i in range(n-1)]
for i in range(n-1):
    ans[i+1] =  a[i] - ans[i]
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()))

s = sum(a)

x1 = s - 2 * (sum(a[1::2]))  
x = [x1]
for i in range(2, n + 1):
    x.append(2 * a[i - 2] - x[i - 2])

print(x)


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

s = sum(a)

x1 = s - 2 * (sum(a[1::2]))  
x = [x1]
for i in range(2, n + 1):
    x.append(2 * a[i - 2] - x[i - 2])

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
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N = int(readline())
A = np.array([int(x) for x in readline().rstrip().split()])
A_sum = A.sum()
A_sum //= 2
A_bi = 2 * A
ans = []
if N > 3:
    for i in range(N):
        if i < N - 3:
            ans.append(A_sum - (A[i+1] + A[i+3]))
        elif i == N - 3:
            ans.append(A_sum - (A[i+1] + A[0]))
        elif i == N - 2:
            ans.append(A_sum - (A[i+1] + A[1]))
        else:
            ans.append(A_sum - (A[0] + A[2]))
else:
    ans.append(A_sum - A[1])
    ans.append(A_sum - A[2])
    ans.append(A_sum - A[0])

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N = int(readline())
A = np.array([int(x) for x in readline().rstrip().split()])
A_sum = A.sum()
A_sum //= 2
ans = []
x1 = A_sum
j = 1
for i in range((N-1)//2):
    x1 -= A[j]
    j += 2
ans.append(2 * x1)
for k in range(1, N):
    x = A[k-1] - (ans[k-1] // 2)
    ans.append(2 * x)
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())
y=list(map(int,input().split()))
y=list(map(lambda x: x*2,y))
A=np.zeros((n,n),dtype='int')
for i in range(n-1):
  for j in range(i,i+2):
    A[i][j]=1
A[n-1][0],A[n-1][n-1]=1,1
b=np.linalg.solve(A,y)
print(*b)

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

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):
# input
N = int(input())
A = [int(i) for i in input().split()]

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

for i in range(N):
  x = 2*A[i] - x
  water.append(x)
  # print("new water: ", water)

# output
print(*water)

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

# main
water = []
for i in range(N - 1, -1, -1):
  if A[i] == 0 or A[i - 1] == 0:
    x = 0
  elif A[i] == 1 or A[i - 1] == 1:
    x = 1
  else:
    if A[i - 1] < A[i]:
      x = 2*(A[i - 1]//2)
    else:
      x = 2*(A[i]//2) 
  A[i] -= x
  A[i - 1] -= x
  water.append(2*x)
  
# output
for i in water[::-1]:
  print(i, end = " ")

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

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

for i in range(N - 1):
  x = 2*A[i] - x
  water.append(x)
  # print("new water: ", water)

# output
print(*water)

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()))
x = [0] * n
x[0] += a[0]
for i in range(1, n, 2):
  x[0] += - a[i] + a[i+1]

for i in range(1, n):
  x[i] = -x[i-1] + 2*a[i-1]
  
o = " ".join(x)
print(o)


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

for i in range(1, n):
  x[i] = -x[i-1] + 2*a[i-1]
  
o = " ".join(x)
print(o)


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

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


Verdicts: Runtime Error

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()))
s = sum(A)
A = A*2

ans = []
for i in range(2):
    ans.append(str(s - sum(A[i+1:N+i-1:2])*2 ))
for i in range(2,N):
    ans.append(str(int(ans[i-2])+(A[i-11]-A[N+i-2])*2))

ans = ' '.join(ans)
print(ans)

N = int(input())
A = list(map(int, input().split()))
s = sum(A)
A = A*2

ans = []
for i in range(2):
    ans.append(str(s - sum(A[i+1:N+i-1:2])*2 ))
for i in range(2,N):
    ans.append(str(int(ans[i-2])+(A[i-1]-A[N+i-2])*2))

ans = ' '.join(ans)
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 numpy as np

N = int(input())
B = [int(i)*2 for i in input().split()]

a = [[0]*N for i in range(N)]

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

a[-1][0] += 1
a[-1][-1] += 1

A = np.array(a, dtype=np.int)
b = np.array(B, dtype=np.int)

x = np.linalg.solve(A, b)

for i in x:
    print(int(i), end=" ")

import sys
import numpy as np

input = sys.stdin.readline
N = int(input())
B = [int(i)*2 for i in input().split()]


A = np.identity(N)
for i in range(N-1):
    #A[i][i] += 1
    A[i][i+1] += 1

A[-1][0] += 1
#A[-1][-1] += 1
#A = np.array(a)
b = np.array(B)

x = np.linalg.solve(A, b)

for i in x:
  print(int(i), end=" ")

import numpy as np

N = int(input())
B = [int(i)*2 for i in input().split()]

a = [[0]*N for i in range(N)]

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

a[-1][0] += 1
a[-1][-1] += 1

A = np.array(a)
b = np.array(B)

x = np.linalg.solve(A, b)

for i in x:
    print(int(i), end=" ")

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.linalg import spsolve

N = int(input())
b = np.array(input().split()).astype(int)

rows = np.concatenate([np.arange(N), np.arange(N)])
cols = np.concatenate([np.arange(N), np.arange(1,N+1) % N])

A = csr_matrix(([1] * (2*N), (rows, cols)), (N,N))

x = (spsolve(A, b) * 2).astype(int)

print(*x)

Verdicts: Time Limit Exceeded

Runtime Error

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
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

N = I()
A = LI()
ans = [0]*N
dis = [0]*N
dis[0] = (A[1]-A[0])*2
for i in range(N-1):
    dis[i+1] = dis[i]+2*(A[-N+2*i+3]-A[-N+2*i+2])
#print(dis)

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

print(ans)

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

N = I()
A = LI()
ans = [0]*N
dis = [0]*N
dis[0] = (A[1]-A[0])*2
for i in range(N-1):
    dis[i+1] = dis[i]+2*(A[-N+2*i+3]-A[-N+2*i+2])
#print(dis)

basic = (sum(A) - sum(dis))//N
ans[0] = basic
for i in range(1,N):
    ans[2*i-N] = basic + dis[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 sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    L, R = input_nums()
    MOD = 2019
    a = L%MOD
    b = R%MOD
    if a < b and R - L < 2019:
        print((a*(a+1))%MOD)
    else:
        print(0)

if __name__ == '__main__':
    main()

import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1,d2,d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    n = II()
    aa = MII()
    total = sum(aa)
    x1 = total - 2*sum(aa[1::2])
    ans = [x1]
    for i in range(0, n-1):
        ans.append(2*aa[i]-ans[-1])
    print(*ans)


if __name__ == '__main__':
    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())
x = list(map(int, input().split()))
y = [0] * N

odd = sum([n for i, n in enumerate(shifted_x) if i % 2 == 1])
even = sum([n for i, n in enumerate(shifted_x) if i % 2 == 0])
y[0] = even - odd

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


str_y = map(str, y)
output = " ".join(str_y)
print(output)

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)

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)

N = int(input())
x = list(map(int, input().split()))
y = [0] * N

odd = sum([n for i, n in enumerate(x) if i % 2 == 1])
even = sum([n for i, n in enumerate(x) if i % 2 == 0])
y[0] = even - odd

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


str_y = map(str, y)
output = " ".join(str_y)
print(output)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted