TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
def main():
    L, R = map(int, input().split())
    start = time.time()
    if R // 2019 > L // 2019:
        print(0)
        return
    retval = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            retval = min(retval, (i % 2019 * j % 2019) % 2019)
            if retval == 0:
                print(0)
                return
            
    print(retval)
    return
    
if __name__ == '__main__':
    main()

import sys
sys.setrecursionlimit(10 ** 6)

def main():
    L, R = map(int, sys.stdin.readline().rstrip().split())

    if (R // 2019) > (L // 2019):
        print(0)
        exit()

    L %= 2019
    R %= 2019
    ans = 2019
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j) % 2019)
    
    print(ans)


if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
L, R = map(int, input().split())

if R-L > 2018:
    print(0)
else:
    if (L//2019) < (R//2019):
        print(0)
    else:
        c = 2019
        for i in range(L, R):
            for j in range(i, R+1):
              c = min((i*j)%2019, c)
        print(c)

L, R = map(int, input().split())

if R-L > 2018:
    print(0)
else:
    if (L//2019) < (R//2019):
        print(0)
    else:
        c = 2019
        for i in range(L, R):
            for j in range(i+1, R+1):
              c = min((i*j)%2019, c)
        print(c)

Verdicts: Wrong Answer

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
l, r = map(int, input().split())

a = list(range(l, r+1))

if len(a)>2019:
    a = a[:2019]

print(a)

num = 0
ans = 2019

for i in range(len(a)):
    for j in range(len(a)):
        if a[i]<a[j]:
            num = (a[i]*a[j])%2019
            ans = min(ans, num)
            if ans == 0:
                print(0)
                exit(0)

print(ans)

l, r = map(int, input().split())

if r-l>2019:
    print(0)
    exit(0)
else:
    a = list(range(l, r+1))

num = 0
ans = 2019

for i in range(len(a)):
    for j in range(len(a)):
        if a[i]<a[j]:
            num = (a[i]*a[j])%2019
            ans = min(ans, num)
            if ans == 0:
                print(0)
                exit(0)

print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

[L,R] = inpl()
rL, rR = L%2019, R%2019

if R-L>= 2018 or rL > rR : ans = 0
else:
    ans = (rL*rR)%2019
print(ans)

from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

[L,R] = inpl()
rL, rR = L%2019, R%2019
temp = INF
ans = INF
if R-L>= 2018 or rL > rR : ans = 0
else:
    for i in range(rL, rR):
        for j in range(i+1, rR+1):
            temp = ( i*j ) %2019
            if temp < ans: ans = temp
        
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
L,R = (int(x) for x in input().split())
if (L-R)//2019:
  R -= (L-R)//2019*2019
ans = 2018
for i in range(L,R):
  for j in range(i+1,R+1):
    ans = min(ans,(i*j)%2019)
print(ans)

L,R = (int(x) for x in input().split())
if R-L > 2019*2:
  R -= ((R-L)//2019-1)*2019
print(L,R)
ans = 2019
for i in range(L,R):
  for j in range(i+1,R+1):
    ans = min(ans,(i*j)%2019)
print(ans)

L,R = (int(x) for x in input().split())
if R-L > 2019*2:
  R -= ((R-L)//2019-1)*2019
ans = 2019
for i in range(L,R):
  for j in range(i+1,R+1):
    ans = min(ans,(i*j)%2019)
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
L,R=map(int,input().split(' '))
l,r=L%2019,R%2019
D=R-L
d=r-l
if D<2019:
  if D==d:
    if 
    print( (l*(l+1))%2019 )
  else:
    print(0)
else:
  print(0)

import numpy as np
L,R=map(int,input().split(' '))
l,r=L%2019,R%2019
D=R-L
d=r-l
print(L,l,R,r)
if D<2019:
  if D==d:
    res=[]
    for i in range(L,R+1):
      for j in range(i+1,R+1):
        res.append((i*j)%2019)
    print(min(res))
  else:
    print(0)
else:
  print(0)

import numpy as np
L,R=map(int,input().split(' '))
l,r=L%2019,R%2019
D=R-L
d=r-l
if D<2019:
  if D==d:
    res=[]
    for i in range(l,r+1):
      for j in range(l,r+1):
        res.append(i*j)
    res=np.array(res)%2019
    print(min(res))
  else:
    print(0)
else:
  print(0)

import numpy as np
L,R=map(int,input().split(' '))
l,r=L%2019,R%2019
D=R-L
d=r-l
if D<2019:
  if D==d:
    res=[]
    for i in range(L,R+1):
      for j in range(i+1,R+1):
        res.append((i*j)%2019)
    print(min(res))
  else:
    print(0)
else:
  print(0)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
from collections import Counter
inp=list(map(int,input().split()))
l=inp[0]
r=inp[1]
c=Counter([])
arr=[]
for i in range(l,r+1):
  if c[i]==0:
    c[i]+=1
    arr.append(i)
    continue
  else:
    break
if c[0]!=0:
  print (0)
ans=99999999999
for i in range(len(arr)):
  for j in range(i+1,len(arr)):
    ans=min(ans,(i*j)%2019)
   	if ans==0:
      break
  if ans==0:
    break
print (ans)

from collections import Counter
inp=list(map(int,input().split()))
l=inp[0]
r=inp[1]
c=Counter([])
arr=[]
for i in range(l,r+1):
    if c[(i%2019)]==0:
        c[(i%2019)]+=1
        arr.append((i%2019))
        continue
    else:
        break
if c[0]!=0:
    print (0)
else:
    ans=99999999999
    for i in range(len(arr)):
        for j in range(i+1,len(arr)):
            ans=min(ans,(arr[i]*arr[j])%2019)
            if ans==0:
                break
        if ans==0:
            break
    print (ans)

Verdicts: Runtime Error

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
L , R = map(int,input().split())
if R - L >= 2019 or L == 0:
    print("0")
    exit()
min = 2020

for i in range(L , R):
    for j in range(i + 1 , R + 1):
        tmp_min = ( i * j) % 2019
        if tmp_min < min:
            min = tmp_min


L , R = map(int,input().split())
if R - L >= 2019 or L == 0:
    print("0")
    exit()
min = 2020

for i in range(L , R):
    for j in range(i + 1 , R + 1):
        tmp_min = ( i * j) % 2019
        if tmp_min < min:
            min = tmp_min
print(min)

Verdicts: Wrong Answer

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
L, R = map(int, input().split())


if L == 0 or R-L >= 2019:
    ans = 0
else:
    flag = True
    for i in range(L, R+1):
        if i % 2019 == 0:
            ans = 0
            flag = False
            break
    if flag:
        raise
        ans = (L*(L+1))%2019

print(ans)


L, R = map(int, input().split())

if L == 0 or R-L >= 2019:
    ans = 0
else:
    ans = 10**18
    for i in range(L, R):
        for j in range(i+1, R+1):
            tmp = (i*j)%2019
            ans = min(ans, tmp)
            if not ans:
                break
print(ans)


Verdicts: Runtime Error

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
from sys import exit, stderr, stdin
input = stdin.readline
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    L, R = [int(n) for n in input().split()]
    if (L//2019)<(R//2019):
        print(0)
    else:
        l = L%2019
        r = R%2019
        res = 2019**2
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                res = min(res,(i*j)%MOD)
        print(res)


if __name__ == "__main__":
    main()


from sys import exit, stderr, stdin
input = stdin.readline
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    L, R = [int(n) for n in input().split()]
    if (L//2019)<(R//2019):
        print(0)
    else:
        l = L%2019
        r = R%2019
        res = 2019**2
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                res = min(res,(i*j)%2019)
        print(res)


if __name__ == "__main__":
    main()


Verdicts: Runtime Error

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
from sys import stdin

l,r = [int(x) for x in stdin.readline().rstrip().split()]
m = 2020
le = r-l+1
for i in range(le-1):
    for j in range(i+1,le):
        if i*j%2019 == 0:
            print(0)
            exit()
        else:
            m = min(m,i*j%2019)
print(m)

from sys import stdin

l,r = [int(x) for x in stdin.readline().rstrip().split()]
m = 2020
if r - l > 2018:
    print(0)
    exit()
for i in range(l,r):
    for j in range(i+1,r+1):
        if i*j%2019 == 0:
            print(0)
            exit()
        else:
            m = min(m,i*j%2019)
print(m)

Verdicts: Wrong Answer

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
args = input().split()
l = int(args[0])
r = int(args[1])

ans = 0
if r - l < 2019:
    left = l % 2019
    if 2018 - left >= r - l:
        right = left + r - l
        ans = 2019
        for i in range(left, right + 1):
            for j in range(i + 1, right + 1):
                tmp = i * j % 2019
                if ans > tmp:
                    ans = tmp
                    print(str(i) + ", " + str(j))
                    
        
        
print(ans)

args = input().split()
l = int(args[0])
r = int(args[1])

ans = 0
if r - l < 2019:
    left = l % 2019
    if 2018 - left >= r - l:
        right = left + r - l
        ans = 2019
        for i in range(left, right + 1):
            for j in range(i + 1, right + 1):
                tmp = i * j % 2019
                if ans > tmp:
                    ans = tmp
                    
        
        
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
L,R = map(int,input().split())

ans = 2020

for i in range(L,R + 1):
  l = i % 2019
  r = (i + 1) % 2019
  if l * r < ans:
    ans = l * r
  if r = 0:
    ans = 0
    break
    
print(ans)

L,R = map(int,input().split())

ans = 2019 ** 2

if R - L >= 2018:
  ans = 0
  print(ans)
else: 
  for i in range(L,R):
    for j in range(L + 1,R + 1):
      mod = (i * j) % 2019 
      if mod < ans:
        ans = mod
      elif mod == 0:
        ans = 0
        break
  print(ans)



Verdicts: Runtime Error

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
L,R = [int(i) for i in input().split()]
 
length = min(2019, R-L)
 
m = (L * R) % 2019
for i in range(L-1, L+length) :
    for k in range(i,L+length) :
        # tmp = (i*k) % 2019

        # print(i,k)
 
        l = i % 2019
        r = k % 2019
        tmp = (l*r) % 2019
        if (tmp == 0) :
            m = 0
            break
        
        if (tmp < m) :
            m = tmp 
 
print(m)

L,R = [int(i) for i in input().split()]

length = min(2019,R-L)

R = L + length

ans = 9999999999999999
for i in range(L,R+1) :
    for j in range(i+1,R+1) :
        v = (i * j) % 2019
        if (v < ans) :
            ans = v

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
l,r=map(int,input().split())

min = 500000
print('r-l',r-l)

for i in range(0,r-l):
    for j in range(i+1,r-l-i+1):
        if ((l+i)*(l+j))%2019 < min:
            min=((l+i)*(l+j))%2019

print(min)

l,r = map(int,input().split())

mn = 4038

if (r - l) >= 2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            tmp = (i * j) % 2019
            if tmp < mn:
                mn = tmp
	print(mn)


l,r = map(int,input().split())

mn = 4038

if (r - l) >= 2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            tmp = (i * j) % 2019
            if tmp < mn:
                mn = tmp
    print(mn)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Submission attempts (in order):
L,R=map(int,input().split())
min=0
result=[]
num_range=R-L
print(num_range)
for i in range(num_range-1):
    for j in range(i+1,num_range):
        if (L+i)>=2019 and (L+j)>=2019:
            result.append((L+i-2019)*(L+j-2019))
        else: result.append(L*R)    
result.sort()
print(result[0])

L,R=map(int,input().split())
if R-L>=2018:
    print(0)
else:
    ans=2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans=min(ans,i*j%2019)
    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):
num = int(input())
a = input().split()
b = list(map(int, a))
sum = sum(b)

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

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

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

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

for i in range(1,num):
  X[i] = b[i-1]*2 - X[i-1]
print(" ".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):
N = int(input())
A = list(map(int, input().split()))
import numpy as np
left = []
a = []
for i in range(N):
  if (i == 0 or i == 1):
      a.append(0.5)
  else:
    a.append(0)
a = np.array(a)
for i in range(N):
  left.append(np.roll(a, i))
left = np.array(left)
print(left)
from numpy.linalg import solve
answer = solve(left, A)
answer = list(map(int, answer))
print(*answer)

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

X = []
X.append(sum(A)-2*sum(A[2*i+1] for i in range(N//2)))
for i in range(N-1):
  X.append(2*A[i]-X[-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):
#D
n = int(input())
A = list(map(int, input().split()))

sum_eve = sum(A[0::2])
sum_odd = sum(A[1::2])

x = [0] * n

x[0] = sum_eve - sum_odd

for num in range(1, n):
    x[num] = 2 * A[num-1] - x[num-1]
    
print(x)

#D
n = int(input())
A = list(map(int, input().split()))

sum_eve = sum(A[0::2])
sum_odd = sum(A[1::2])

x = [0] * n

x[0] = sum_eve - sum_odd

for num in range(1, n):
    x[num] = 2 * A[num-1] - x[num-1]
    
ans = " ".join(map(str,x))

pritn(ans)

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

sum_eve = sum(A[0::2])
sum_odd = sum(A[1::2])

x = [0] * n

x[0] = sum_eve - sum_odd

for num in range(1, n):
    x[num] = 2 * A[num-1] - x[num-1]
    
ans = " ".join(map(str,x))
print(ans)

Verdicts: Wrong Answer

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().strip().split()))
X = []
X = X.append(sum(A[0::2])-sum(A[1::2]))
for k in range (N-1):
  X = X.extend(2*A[k] - X[k])
print(X)

N = int(input())
A = list(map(int, input().strip().split()))
X = []
X.append(sum(A[0::2])-sum(A[1::2]))
for k in range (N-1):
  X.append(2*A[k] - X[k])
print(X)

N = int(input())
A = list(map(int, input().strip().split()))
X = []
X.append(sum(A[0::2])-sum(A[1::2]))
for k in range (N-1):
  X.append(2*A[k] - X[k])
print(*X, sep=" ")

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):
n = int(input())
_a = input().split()

a = []

x = []

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

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

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

print(ans[:-1])


n = int(input())
_a = input().split()

a = []

x = []

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

x[n] = a[n]

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


n = int(input())
_a = input().split()

a = []

x = []

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

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

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

print(ans[:-1])


Verdicts: Wrong Answer

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

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

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

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


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

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

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

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


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

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

print(*Y)

  
  
  


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

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

print(*Y)

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

import numpy as np

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

for i in Y:
print(i)

  
  
  

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

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

print(*Y)


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):
N = int(input())
water = [int(x) for x in input().split()]
rain = [0]*N
sum = 0

for i in water:
    sum += i

for k in range(2):  
    sa = 0
    numofloop = 0
    ite = k + 1
    if (ite >= N):
        ite -= N
    while (numofloop < (N - 1) / 2):
        sa += water[ite]
        ite += 2
        if (ite >= N):
            ite -= N
        numofloop += 1
    sa *= 2
    rain[k] = sum - sa


for j in range(1, 1+(N // 2)):
    sa = rain[0]
    sa -= water[2 * j-1]*2
    sa += water[2 * j - 2]*2
    rain[2 * j] = sum - sa
    if j * 2 == N - 1:
        break
    sa = rain[1]
    sa -= water[2 * j]*2
    sa += water[2 * j - 1]*2
    rain[(2*j)+1] = sum-sa


print(' '.join(map(str, rain)))
print(sum)



N = int(input())
water = [int(x) for x in input().split()]
rain = [0]*N
sum = 0

for i in water:
    sum += i


sa = 0
numofloop = 0
ite = 1
while (numofloop < (N - 1) / 2):
    sa += water[ite]
    ite += 2
    if (ite >= N):
        ite -= N
    numofloop += 1
sa *= 2
rain[0] = sum - sa

for k in range(1, N):
    rain[k] = 2*water[k-1]-rain[k-1]

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


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=sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int,input().split()))
    m = min(A)
    xi = A.index(m)
    for a in range(0, m*2+1, 2):
        B = A.copy()
        ans = [0]*N
        B[(xi-1)%N] -= a//2
        B[xi] -= a//2
        ans[xi] = a
        for i in range(xi+1, xi+N):
            x = B[(i-1)%N]*2
            if B[i%N]-x//2 < 0:
                break
            B[(i-1)%N] -= x//2
            B[i%N] -= x//2
            ans[i%N] += x
            if sum(B) == 0:
                print(ans)
                return

if __name__ == '__main__':
    main()


import sys
input=sys.stdin.readline

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

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):
# ABC133D - Rain Flows into Dams
def main():
    # X_0 = sum(A) - 2 * sum(A[1::2]), X_i = 2Ai - X_{i-1}
    N, *A = map(int, open(0).read().split())
    X = [0] * N
    cur = sum(A) - 2 * sum(A[1::2])
    X[0] = cur
    for i, a in enumerate(A[:-1], 1):
        X[i] = a * 2 - cur
        cur = X[i]
    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()

# ABC133D - Rain Flows into Dams
def main():
    # X_0 = sum(A) - 2 * sum(A[1::2]), X_i = 2Ai - X_{i-1}
    N, *A = map(int, open(0).read().split())
    X = [0] * N
    cur = sum(A) - 2 * sum(A[1::2])
    X[0] = cur
    for i, a in enumerate(A[:-1], 1):
        X[i] = a * 2 - cur
        cur = X[i]
    print(" ".join(map(str, X)))


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())
A=list(map(int, input().split()))
M=[0]*N
maxi=sum(A)

M[0]=maxi//4
tmp=10**9

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

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

M[0]= maxi-2*sum(A[1::2])
for i in range(1,N):
  M[i]= 2*(A[i-1]-M[i-1]//2)
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):
n=int(input())
A=list(map(int,input().split()))
odd=sum(A[::2])
even=sum(A[1::2])
rtemp=10**9+1
ltemp=-1
while rtemp-ltemp>1:
    mid=(rtemp+ltemp)//2
    if odd-even-mid<=mid:
        rtemp=mid 

    else:
        ltemp=mid

ans=rtemp
for i in range(n-1):
    print(ans*2)
    ans=A[i]-ans

n=int(input())
A=list(map(int,input().split()))
odd=sum(A[::2])
even=sum(A[1::2])
rtemp=10**9+1
ltemp=-1
while rtemp-ltemp>1:
    mid=(rtemp+ltemp)//2
    if odd-even-mid<=mid:
        rtemp=mid 

    else:
        ltemp=mid

ans=rtemp
D=[]
for i in range(n-1):
    D.append(ans*2)
    ans=A[i]-ans
    
D.append(ans)
print(*D)

n=int(input())
A=list(map(int,input().split()))
odd=sum(A[::2])
even=sum(A[1::2])
rtemp=10**9+1
ltemp=-1
while rtemp-ltemp>1:
    mid=(rtemp+ltemp)//2
    if odd-even-mid<=mid:
        rtemp=mid 

    else:
        ltemp=mid

ans=rtemp
D=[]
for i in range(n-1):
    D.append(ans*2)
    ans=A[i]-ans
    
D.append(ans*2)
print(*D)

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

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

n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
a2 = 0
for i in range(1, n, 2):
    a2 += a[i]

ans = [0] * n
ans[0] = sum_a - 2*a2
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):
mod = 2019
l,r = map(int,input().split())

if l==0 or r//mod - (l-1)//mod >= 1:
  print(0)
else:
  print(l*(l+1)%mod)

n = int(input())

lsA = list(map(int,input().split()))
tot = sum(lsA)

an = tot
for i in range(0,n-2,2):
  an -= 2*lsA[i]

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

print(" ".join(list(map(str,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
import sys
input = sys.stdin.readline
N = int(input())
A = [[int(i)] for i in input().split()]
A_np =np.array(A)


mat_1 =np.zeros((N,N),dtype=int)
for i in range(N):
    mat_1[i,i]=1
    mat_1[i,(i+1)%N]=1 
x =np.linalg.solve(mat_1,A_np)*2


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

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

mt_rain =[0]*N
mt_all =sum(A)
dam_even = sum(A[1::2]) 
mt_rain[0] = mt_all - 2*dam_even 


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

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):
l, r = map(int, input().split())
if r-l >= 2017:
	print (0)
	exit()
else:
	for i in range(l,r+1):
		for j in range(i+1,r+1):
			a = min(a,i*j%2019)
print (a)

n = int(input())
a = list(map(int, input().split()))
x1 = 0
x1 = sum(a)-sum(a[1::2])*2
x = []
x.append(x1)
for i in range(n-1):
	xx = a[i]*2 - x[-1]
	x.append(xx)
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):
from numpy import roll, array

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

b = roll(a, 1)

ans = (array(a) + array(b)) / 2
ans = list(ans)

N = [str(int(p)) for p in ans]

print(' '.join(N))


from numpy import roll, array

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

b = roll(a, 1)

ans = (array(a) + array(b)) / 2
ans = list(ans)

N = [str(p) for p in ans]

print(' '.join(N))

from numpy.linalg import inv
from numpy import zeros, dot

n = int(input())

x = input().split(' ')

a = [int(v) for v in x]

Z = zeros((n, n))

for i in range(n):
    Z[i, i:i + 1] = 0.5

Z[0, 1] = 0
Z[0, n - 1] = 0.5

N = dot(inv(Z), a).astype('int')

N = [str(p) for p in N]

print(' '.join(N))

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

ret_lst = []

S = sum(a)

a_even = a[1::2]

m1 = S - 2 * sum(a_even)
ret_lst.append(m1)

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

    ret_lst.append(next_m)

N = [str(n) for n in ret_lst]

print(' '.join(N))

Verdicts: Wrong Answer

Wrong Answer

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

x_0 = 0

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

result_x = []
result_x.append(x_0)

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

print(result_x)

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

x_0 = 0

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

result_x = []
result_x.append(x_0)

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

print(*result_x)

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

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

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 = sys.stdin.readline

def func(dam_num, dam_volumes):
    water_amount = sum(dam_volumes)
    mountains_rain = [0]*dam_num
    mountains_rain[0] = water_amount
    
    
    for i in range(dam_num//2):
        mountains_rain[0] -= 2*dam_volumes[2*(i+1)-1]

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

    print(mountains_rain)
    exit()


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

    func(n,a)
    

if __name__ == "__main__":
    main()

import sys
input = sys.stdin.readline

def func(dam_num, dam_volumes):
    water_amount = sum(dam_volumes)
    mountains_rain = [0]*dam_num
    mountains_rain[0] = water_amount

    
    for i in range(dam_num//2):
        mountains_rain[0] -= 2*dam_volumes[2*(i+1)-1]

    
    for i in range(dam_num-1):
        mountains_rain[i+1] = 2*dam_volumes[i] - mountains_rain[i]
    
    print(*mountains_rain)
    exit()


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

    func(n,a)
    

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):
n = int(input())

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

total = sum(l)

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

ans = [total]

for i in range(1,n):
    ans.append(2*l[i-1] - ans[i-1])
    ans = [str(i) for i in ans]
    
print(' '.join(ans))
    


n = int(input())

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

total = sum(l)

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

ans = [total]

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


n = int(input())

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

total = sum(l)

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

ans = [total]

for i in range(1,n):
    ans.append(2*l[i-1]-ans[i-1])
ans = [str(i) for i in ans]
    
print(' '.join(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 numpy.linalg import solve
N=int(input())
A=input().split()
for i in range(N):
    A[i]=2*int(A[i])
x=[None]*N
for i in range(N-1):
    x[i]=[0]*N
    x[i][i],x[i][i+1]=1,1
x[N-1]=[0]*N
x[N-1][0],x[N-1][N-1]=1,1
y=solve(x,A)
for i in range(N):
    print(int(y[i]),end=' ')


import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
A=list(map(int,input().split()))
y=0
for i in range(N-1):
    y=2*(A[i]-y//2)
l=[None]*N
l[0]=(2*A[-1]-y)//2
for i in range(1,N):
    l[i]=2*(A[i-1]-l[i-1]//2)
print(*l)

Verdicts: Time Limit Exceeded

Accepted