Buggy python submission (verdict: Time Limit Exceeded):
def sol():
    n=int(input())
    a=tuple(int(i) for i in input().split())
    chk=a.index(min(a))
    #for i in range(min(a[0],a[-1])*2,-1,-2):
    for i in range(a[chk]*2,-1,-2):
        ans=[0]*n
        ans[chk]=i
        f=1
        for k in range(1,n):
            j=(chk+k)%n
            t=(a[j-1]-ans[j-1]//2)*2
            if t>=0 and (t+ans[j-1])//2==a[j-1]:
                ans[j]=t
            else:
                f=0
                break
        #if f and ans[-1]//2+ans[-2]//2==a[-2] and ans[-1]//2+ans[0]//2==a[-1]:
        if f and ans[chk-1]//2+ans[chk-2]//2==a[chk-2] and ans[chk-1]//2+ans[chk]//2==a[chk-1]:
            print(*ans)
            exit()

if __name__=="__main__":
    sol()

Fixed submission:
# from https://atcoder.jp/contests/abc133/submissions/6272850
n=int(input())
a=[int(i) for i in input().split()]
c=[0]
s=sum(a)

for i in range(2*n):
    c.append(c[-1]+a[(i*2+1)%n])
ans=[0]*n
for i in range(n):
    ans[i*2%n]=s-2*(c[i+n//2]-c[i])
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
def sol():
    n=int(input())
    a=tuple(int(i) for i in input().split())
    chk=a.index(min(a))
    #for i in range(min(a[0],a[-1])*2,-1,-2):
    for i in range(a[chk]*2,-1,-2):
        ans=[0]*n
        ans[chk]=i
        f=1
        for k in range(1,n):
            j=(chk+k)%n
            t=(a[j-1]-ans[j-1]//2)*2
            if t>=0 and (t+ans[j-1])//2==a[j-1]:
                ans[j]=t
            else:
                f=0
                break
        #if f and ans[-1]//2+ans[-2]//2==a[-2] and ans[-1]//2+ans[0]//2==a[-1]:
        if f and ans[chk-1]//2+ans[chk-2]//2==a[chk-2] and ans[chk-1]//2+ans[chk]//2==a[chk-1]:
            print(*ans)
            exit()

if __name__=="__main__":
    sol()

Fixed submission:
# from https://atcoder.jp/contests/abc133/submissions/6272850
n=int(input())
a=[int(i) for i in input().split()]
c=[0]
s=sum(a)

for i in range(2*n):
    c.append(c[-1]+a[(i*2+1)%n])
ans=[0]*n
for i in range(n):
    ans[i*2%n]=s-2*(c[i+n//2]-c[i])
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
def sol():
    n=int(input())
    a=tuple(int(i) for i in input().split())
    ans=chk=0
    for i in range(min(a[0],a[-1])*2,-1,-2):
        ans=[0]*n
        ans[0]=i
        f=1
        for j in range(1,n):
            t=(a[j-1]-ans[j-1]//2)*2
            if t>=0 and (t+ans[j-1])//2==a[j-1]:
                ans[j]=t
            else:
                f=0
                break
        if f and ans[-1]//2+ans[-2]//2==a[-2] and ans[-1]//2+ans[0]//2==a[-1]:
            print(*ans)
            exit()

if __name__=="__main__":
    sol()

Fixed submission:
# from https://atcoder.jp/contests/abc133/submissions/6272850
n=int(input())
a=[int(i) for i in input().split()]
c=[0]
s=sum(a)

for i in range(2*n):
    c.append(c[-1]+a[(i*2+1)%n])
ans=[0]*n
for i in range(n):
    ans[i*2%n]=s-2*(c[i+n//2]-c[i])
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
def sol():
    n=int(input())
    a=tuple(int(i) for i in input().split())
    ans=chk=0
    for i in range(min(a[0],a[-1])*2,-1,-2):
        ans=[0]*n
        ans[0]=i
        f=1
        for j in range(1,n):
            t=(a[j-1]-ans[j-1]//2)*2
            if t>=0 and (t+ans[j-1])//2==a[j-1]:
                ans[j]=t
            else:
                f=0
                break
        if f and ans[-1]//2+ans[-2]//2==a[-2] and ans[-1]//2+ans[0]//2==a[-1]:
            print(*ans)

if __name__=="__main__":
    sol()

Fixed submission:
# from https://atcoder.jp/contests/abc133/submissions/6272850
n=int(input())
a=[int(i) for i in input().split()]
c=[0]
s=sum(a)

for i in range(2*n):
    c.append(c[-1]+a[(i*2+1)%n])
ans=[0]*n
for i in range(n):
    ans[i*2%n]=s-2*(c[i+n//2]-c[i])
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
def sol():
    n=int(input())
    a=[int(i) for i in input().split()]
    ans=chk=0
    for i in range(min(a[0],a[-1])*2,-1,-2):
        ans=[0]*n
        ans[0]=i
        f=1
        for j in range(1,n):
            t=(a[j-1]-ans[j-1]//2)*2
            if t>=0 and (t+ans[j-1])//2==a[j-1]:
                ans[j]=t
            else:
                f=0
                break
        if f and ans[-1]//2+ans[-2]//2==a[-2] and ans[-1]//2+ans[0]//2==a[-1]:
            print(*ans)

if __name__=="__main__":
    sol()


Fixed submission:
# from https://atcoder.jp/contests/abc133/submissions/6272850
n=int(input())
a=[int(i) for i in input().split()]
c=[0]
s=sum(a)

for i in range(2*n):
    c.append(c[-1]+a[(i*2+1)%n])
ans=[0]*n
for i in range(n):
    ans[i*2%n]=s-2*(c[i+n//2]-c[i])
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(i) for i in input().split()]
ans=chk=0
for i in range(a[-1]*2,-1,-2):
    ans=[0]*n
    ans[0]=i
    f=1
    for j in range(1,n):
        t=(a[j-1]-ans[j-1]//2)*2
        if t>=0 and (t+ans[j-1])//2==a[j-1]:
            ans[j]=t
        else:
            f=0
            break
    if f and ans[-1]//2+ans[-2]//2==a[-2] and ans[-1]//2+ans[0]//2==a[-1]:
        print(*ans)

Fixed submission:
# from https://atcoder.jp/contests/abc133/submissions/6272850
n=int(input())
a=[int(i) for i in input().split()]
c=[0]
s=sum(a)

for i in range(2*n):
    c.append(c[-1]+a[(i*2+1)%n])
ans=[0]*n
for i in range(n):
    ans[i*2%n]=s-2*(c[i+n//2]-c[i])
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(i) for i in input().split()]
ax=max(a)
dx=a.index(ax)

for i in range(ax*2,-1,-2):
    ans=[0]*n
    ans[dx]=i
    t=[x for x in a]
    for j in range(n):
        p=(dx+j)%n
        o=ans[p]//2
        t[p]-=o
        if j!=n-1:
            ans[(p+1)%n]=t[p]*2
        t[p-1]-=o
        if t[p]<0 or t[p-1]<0: break
    t=set(t)
    if len(t)==1 and 0==t.pop():
        print(*ans)
        exit()


Fixed submission:
# from https://atcoder.jp/contests/abc133/submissions/6272850
n=int(input())
a=[int(i) for i in input().split()]
c=[0]
s=sum(a)

for i in range(2*n):
    c.append(c[-1]+a[(i*2+1)%n])
ans=[0]*n
for i in range(n):
    ans[i*2%n]=s-2*(c[i+n//2]-c[i])
print(*ans)