Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, C = map(int, input().split())
STC = [[int(i) for i in input().split()] for i in range(N)]
STC.sort()

R = [[STC[0][1], STC[0][2]]]
for s, t, c in STC[1:]:
    for i in range(len(R)):
        R[i][0], R[i][1] = t_r, c_r
        if c == c_r and t_r <= s:
            R[i] = [t, c]
            break
        if c != c_r and t_r < s:
            R[i] = [t, c]
            break
    else:
        R.append([t, c])
        
print(len(R))

Fixed submission:
N, C = map(int, input().split())
STC = [[int(i) for i in input().split()] for i in range(N)]
STC.sort()

R = [[STC[0][1], STC[0][2]]]
for s, t, c in STC[1:]:
    for i in range(len(R)):
        t_r, c_r = R[i][0], R[i][1]
        if c == c_r and t_r <= s:
            R[i] = [t, c]
            break
        if c != c_r and t_r < s:
            R[i] = [t, c]
            break
    else:
        R.append([t, c])
        
print(len(R))

Buggy python submission (verdict: Runtime Error):
N, C = map(int, input().split())

A = [[] for i in range(C + 1)]
for i in range(N):
    s, t, c = map(int, input().split())
    A[c].extend(list(range(s - 1, t + 1)))
    
dp = [0] * (10 ** 5 + 1)
for a in A:
    if a == []:
        continue
    a.sort()
    dp[a[0]] += 1
    dp[a[-1] + 1] -= 1
    
for i in range(1, 10 ** 5 + 1):
    dp[i] += dp[i - 1]
    
print(max(dp))

Fixed submission:
N, C = map(int, input().split())
STC = [[int(i) for i in input().split()] for i in range(N)]
STC.sort()

R = [[STC[0][1], STC[0][2]]]
for s, t, c in STC[1:]:
    for i in range(len(R)):
        t_r, c_r = R[i][0], R[i][1]
        if c == c_r and t_r <= s:
            R[i] = [t, c]
            break
        if c != c_r and t_r < s:
            R[i] = [t, c]
            break
    else:
        R.append([t, c])
        
print(len(R))

Buggy python submission (verdict: Runtime Error):
N, C = map(int, input().split())

A = [[0] * (10 ** 5 + 1) for i in range(C + 1)]
for i in range(N):
    s, t, c = map(int, input().split())
    A[c][s] += 1
    A[c][t + 1] -= 1
    
for i in range(C + 1):
    for j in range(1, 10 ** 5 + 1):
        A[i][j] += A[i][j - 1]
        
for j in range(10 ** 5 + 1):
    for i in range(1, C + 1):
        A[i][j] += A[i - 1][j]
        
print(max(A[-1]))

Fixed submission:
N, C = map(int, input().split())
STC = [[int(i) for i in input().split()] for i in range(N)]
STC.sort()

R = [[STC[0][1], STC[0][2]]]
for s, t, c in STC[1:]:
    for i in range(len(R)):
        t_r, c_r = R[i][0], R[i][1]
        if c == c_r and t_r <= s:
            R[i] = [t, c]
            break
        if c != c_r and t_r < s:
            R[i] = [t, c]
            break
    else:
        R.append([t, c])
        
print(len(R))
Buggy python submission (verdict: Runtime Error):
A = input()

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return -1

B = []
for i in range(8):
    if int(A[0]) + f(i//4) * int(A[1]) + f(i//2) * int(A[2]) + f(i) * int(A[3]) == 7:
        if f(i//4) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i//2) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i) == 1:
            B.append('+')
        else:
            B.sppend('-')
        flag = 1
        break
        
if flag == 1:
    print('{}{}{}{}{}{}{}{}'.format(A[0], B[0], A[1], B[1], A[2], B[2], A[3], '=7'))

Fixed submission:
A = input()

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return -1

B = []
for i in range(8):
    if int(A[0]) + f(i//4) * int(A[1]) + f(i//2) * int(A[2]) + f(i) * int(A[3]) == 7:
        if f(i//4) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i//2) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i) == 1:
            B.append('+')
        else:
            B.append('-')
        flag = 1
        break
        
if flag == 1:
    print('{}{}{}{}{}{}{}{}'.format(A[0], B[0], A[1], B[1], A[2], B[2], A[3], '=7'))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])

cnt = 0
for i in range(N):
    x = bisect.bisect_right(B, A[i])
    for j in B[x:]:
        y = bisect.bisect_right(C, j)
        cnt += N - y
        
print(cnt)

Fixed submission:
import bisect

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

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])

cnt = 0
for i in range(N):
    x = bisect.bisect_right(B, A[i])
    for j in B[x:]:
        y = bisect.bisect_right(C, j)
        cnt += len(C[y:])
        
print(cnt)

Fixed submission:
import bisect

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

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
    
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
    
print(ans)

Fixed submission:
import bisect

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

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for a in A:
    B2 = [i for i in B if i > a]
    for b in B2:
        ans += len([j for j in C if j > b])
    
print(ans)

Fixed submission:
import bisect

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

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
    
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
n = len(S)
m = len(T)

ans = 'UNRESTORABLE'
for i in range(n - m + 1):
    for j in range(m):
        if S[i + j] != '?' and S[i + j] != T[j]:
            break
    else:
        S2 = S[: i] + T + S[i + m :]
ans = S2.replace('?', 'a')
        
print(ans)

Fixed submission:
S = input()
T = input()

ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    flag = 1
    for j in range(len(T)):
        if S[i+j] == T[j] or S[i+j] == '?':
            continue
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T):]
        ans = ans.replace('?', 'a')
    
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
 
ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    s = S[i:i+len(T)+1]
    flag = 1
    for j in range(len(T)):
        if s[j] == T[j] or s[j] == '?':
            pass
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T)]
        ans = ans.replace('?', 'a')
print(ans)

Fixed submission:
S = input()
T = input()

ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    flag = 1
    for j in range(len(T)):
        if S[i+j] == T[j] or S[i+j] == '?':
            continue
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T):]
        ans = ans.replace('?', 'a')
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = []
for i in range(N):
    a = int(input())
    if a not in A:
        A.append(a)
    else:
        A.remove(a)
        
print(len(A))

Fixed submission:
from collections import Counter
n = int(input())
A = Counter([int(input()) for i in range(n)]).most_common()
B = []

for i in range(len(A)):
    if A[i][1] % 2 == 1:
        B.append(A[i][1])
        
print(len(B))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n = int(input())
D = deque()
for i in range(n):
    x = int(input())
    if x in D:
        D.remove(x)
    else:
        D.append(x)
print(len(D))

Fixed submission:
from collections import Counter
n = int(input())
A = Counter([int(input()) for i in range(n)]).most_common()
B = []

for i in range(len(A)):
    if A[i][1] % 2 == 1:
        B.append(A[i][1])
        
print(len(B))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
D = []
for i in range(n):
    x = int(input())
    if x in D:
        D.remove(x)
    else:
        D.append(x)
print(len(D))

Fixed submission:
from collections import Counter
n = int(input())
A = Counter([int(input()) for i in range(n)]).most_common()
B = []

for i in range(len(A)):
    if A[i][1] % 2 == 1:
        B.append(A[i][1])
        
print(len(B))
Buggy python submission (verdict: Runtime Error):
import bisect
n, m = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(m)]
S = []
G = []

for ab in AB:
    if ab[0] == 1:
        S.append(ab[1])
    if ab[1] == n:
        G.append(ab[0])

S.sort()
G.sort()
        
ans = 'IMPOSSIBLE'
if len(S) != 0 and len(G) != 0:
    for s in S:
        idx = bisect.bisect_left(G, s)
        if s == G[idx]:
            ans = 'POSSIBLE'
print(ans)

Fixed submission:
n, m = map(int, input().split())
S = set()
G = set()

for i in range(m):
    s, g = map(int, input().split())
    if s == 1:
        G.add(g)
    if g == n:
        S.add(s)

if len(S&G) != 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
import bisect
n, m = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(m)]
S = []
G = []

for ab in AB:
    if ab[0] == 1:
        S.append(ab[1])
    if ab[1] == n:
        G.append(ab[0])

S.sort()
G.sort()
        
ans = 'IMPOSSIBLE'
if len(G) != 0:
    for s in S:
        idx = bisect.bisect_left(G, s)
        if s == G[idx]:
            ans = 'POSSIBLE'
print(ans)

Fixed submission:
n, m = map(int, input().split())
S = set()
G = set()

for i in range(m):
    s, g = map(int, input().split())
    if s == 1:
        G.add(g)
    if g == n:
        S.add(s)

if len(S&G) != 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
import bisect
n, m = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(m)]
S = []
G = []

for ab in AB:
    if ab[0] == 1:
        S.append(ab[1])
    if ab[1] == n:
        G.append(ab[0])
        
ans = 'IMPOSSIBLE'
if len(G) != 0:
    for s in S:
        idx = bisect.bisect_left(G, s)
        if s == G[idx]:
            ans = 'POSSIBLE'
print(ans)

Fixed submission:
n, m = map(int, input().split())
S = set()
G = set()

for i in range(m):
    s, g = map(int, input().split())
    if s == 1:
        G.add(g)
    if g == n:
        S.add(s)

if len(S&G) != 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(m)]
S = []
G = []

for ab in AB:
    if ab[0] == 1:
        S.append(ab)
    if ab[1] == n:
        G.append(ab)
        
ans = 'IMPOSSIBLE'
for s in S:
    for g in G:
        if s[1] == g[0]:
            ans = 'POSSIBLE'
print(ans)

Fixed submission:
n, m = map(int, input().split())
S = set()
G = set()

for i in range(m):
    s, g = map(int, input().split())
    if s == 1:
        G.add(g)
    if g == n:
        S.add(s)

if len(S&G) != 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(i) for i in input().split()]

tmp = 0
ans = 10 ** 10
for i in range(n - 1):
    tmp += A[i]
    ans = min(ans, abs(tmp -(sum(A) - tmp)))
print(ans)

Fixed submission:
n = int(input())
A = [int(i) for i in input().split()]
sumA = sum(A)

tmp = 0
ans = 10 ** 10
for i in range(n - 1):
    tmp += A[i]
    ans = min(ans, abs(tmp -(sumA - tmp)))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(i) for i in input().split()]
B = []
for i in range(n):
    B.append(A.pop(0))
    B.reverse()
print(' '.join(map(str, B)))

Fixed submission:
n = int(input())
A = [int(i) for i in input().split()]
odd = A[1::2]
even = A[0::2]

if len(A) % 2 == 0:
    odd.reverse()
    ans = odd + even
else:
    even.reverse()
    ans = even + odd
    
print(' '.join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n, m = map(int, input().split())
A = []
for i in range(m):
    x, y = map(int, input().split())
    A.append(x)
    A.append(y)
C = sorted(Counter(A).most_common())
for i in range(n):
    print(C[i][1])

Fixed submission:
n, m = map(int, input().split())
A = [0] * n

for i in range(m):
    x, y = map(int, input().split())
    A[x-1] += 1
    A[y-1] += 1

for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n, m = map(int, input().split())
A = []
for i in range(m):
    x, y = map(int, input().split())
    A.append(x)
    A.append(y)
C = sorted(Counter(A).most_common(), reverse = True, key = lambda x: x[1])
for i in range(n):
    print(C[i][1])

Fixed submission:
n, m = map(int, input().split())
A = [0] * n

for i in range(m):
    x, y = map(int, input().split())
    A[x-1] += 1
    A[y-1] += 1

for i in range(n):
    print(A[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [int(i) for i in input().split()]

if A[0] < A[1]:
    flag = 1
elif A[0] > A[1]:
    flag = -1
else:
    flag = 0
    
cnt = 1
x = A[1]
for i in range(2, n):
    if flag == 1:
        if x <= A[i]:
            pass
        else:
            cnt += 1
            flag = 0
    if flag == -1:
        if x < A[i]:
            cnt += 1
            flag = 0
        else:
            pass
    else:
        if x < A[i]:
            flag = 1
        elif x > A[i]:
            flag = -1
        else:
            flag = 0
    x = A[i]
    
print(cnt)

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

if n == 1:
    cnt = 1
else:
    if A[0] < A[1]:
        flag = 1
    elif A[0] > A[1]:
        flag = -1
    else:
        flag = 0
    
    cnt = 1
    x = A[1]
    for i in range(2, n):
        if flag == 1:
            if x <= A[i]:
                pass
            else:
                cnt += 1
                flag = 0
                
        elif flag == -1:
            if x < A[i]:
                cnt += 1
                flag = 0
            else:
                pass
            
        else:
            if x < A[i]:
                flag = 1
            elif x > A[i]:
                flag = -1
            else:
                flag = 0
        #print('x', x, 'A[i]', A[i], 'flag', flag, 'cnt', cnt)
        x = A[i]
    
print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [int(i) for i in input().split()]

if A[0] <= A[1]:
    flag = 1
else:
    flag = -1
cnt = 1
x = A[1]
for i in range(2, n):
    if flag == 1:
        if x <= A[i]:
            pass
        else:
            cnt += 1
            flag = 0
    if flag == -1:
        if x < A[i]:
            cnt += 1
            flag = 0
        else:
            pass
    else:
        if x < A[i]:
            flag = 1
        elif x > A[i]:
            flag = -1
        else:
            flag = 0
    x = A[i]
    
print(cnt)

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

if n == 1:
    cnt = 1
else:
    if A[0] < A[1]:
        flag = 1
    elif A[0] > A[1]:
        flag = -1
    else:
        flag = 0
    
    cnt = 1
    x = A[1]
    for i in range(2, n):
        if flag == 1:
            if x <= A[i]:
                pass
            else:
                cnt += 1
                flag = 0
                
        elif flag == -1:
            if x < A[i]:
                cnt += 1
                flag = 0
            else:
                pass
            
        else:
            if x < A[i]:
                flag = 1
            elif x > A[i]:
                flag = -1
            else:
                flag = 0
        #print('x', x, 'A[i]', A[i], 'flag', flag, 'cnt', cnt)
        x = A[i]
    
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = n
for a in range(1, n + 1):
    if n % a == 0:
        b = n // a
        tmp = max(len(str(a)), len(str(b)))
        ans = min(ans, tmp)
        if a > b:
            break
print(ans)

Fixed submission:
n = int(input())
ans = n
for a in range(int(n ** (0.5)), 0, -1):
    if n % a == 0:
        b = n // a
        tmp = max(len(str(a)), len(str(b)))
        ans = min(ans, tmp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s, c = map(int, input().split())

cnt = 0
while s >= 1 and c >= 2:
    s -= 1
    c -= 2
    cnt += 1
    
if c > 3:
    cnt += c // 4
    
print(cnt)

Fixed submission:
s, c = map(int, input().split())
if s >= c // 2:
    print(c // 2)
else:
    print(s + (c - 2 * s) // 4)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
AB = [[int(i) for i in input().split()] for i in range(n)]

ans = 0
for i in range(n - 1, -1, -1):
    tmp = AB[i][0] % AB[i][1]
    if tmp == 0:
        x = tmp
    else:
        x = AB[i][1] - tmp
    ans += x
    if i > 0:
        for j in range(i - 1, -1, -1):
            AB[j][0] += x
    #print(AB, x, ans)
        
print(ans)

Fixed submission:
n = int(input())
AB = [[int(i) for i in input().split()] for i in range(n)]

acc = 0
for i in range(n - 1, -1, -1):
    tmp = AB[i][0] % AB[i][1]
    if tmp == 0:
        x = tmp
    else:
        x = AB[i][1] - tmp
    acc += x
    if i > 0:
        AB[i - 1][0] += acc
    #print(AB, x, acc)
        
print(acc)
Buggy python submission (verdict: Runtime Error):
n = int(input())

def nprf(n):
    pf = {}
    for i in range(2, n + 1):
        for j in range(2, i + 1):
            while i % j == 0:
                if not j in pf:
                    pf[j] = 0
                pf[j] += 1
                i //= j
    return pf
    
cnt = 1
for v in nprf(n).values():
    cnt *= (v + 1)
    
print(cnt % mod)

Fixed submission:
n = int(input())
mod = 10 ** 9 + 7

def nprf(n):
    pf = {}
    for i in range(2, n + 1):
        for j in range(2, i + 1):
            while i % j == 0:
                if not j in pf:
                    pf[j] = 0
                pf[j] += 1
                i //= j
    return pf
    
cnt = 1
for v in nprf(n).values():
    cnt *= (v + 1)
    
print(cnt % mod)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0
for i in range(k + 1):
    for j in range(k + 1):
        if i + j + (s - i - j) == s and 0 <= s - i - j <= k:
            count += 1
print(count)

Fixed submission:
k, s = map(int, input().split())
count = 0
for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
s = input()

def f(t):
    if len(t) > len(s):
        return False
    if t == s:
        return True
    return f(t + 'dream') or f(t + 'erase') or f(t + 'dreamer') or f(t + 'eraser')

if f(''):
    print('YES')
else:
    print('NO')

Fixed submission:
s = list(input())
while len(s) > 0:
    if ''.join(s[-7:]) == 'dreamer':
        del s[-7:]    
    elif ''.join(s[-6:]) == 'eraser':
        del s[-6:]
    elif ''.join(s[-5:]) == 'dream' or ''.join(s[-5:]) == 'erase':
        del s[-5:]
    else:
        break
print('NO' if len(s) != 0 else 'YES')
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
    if i % x == 0:
        cnt += 1
print(cnt)

Fixed submission:
a, b, x = map(int, input().split())
cnt = b // x
cnt -= (a - 1) // x
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
X = input()
lenX = len(X)
cnt = 0
for i in range(lenX // 2):
    if 'ST' in X:
        idx = X.index('ST')
        X = X[: idx] + X[idx + 2 :]
        cnt += 2
print(lenX - cnt)

Fixed submission:
from collections import deque
X = input()
Q = deque()
for i in range(len(X)):
    if X[i] == 'T':
        if len(Q) > 0 and Q[-1] == 'S':
            Q.pop()
        else:
            Q.append('T')
    else:
        Q.append('S')
print(len(Q))
Buggy python submission (verdict: Runtime Error):
S = input()
if S[0] == S[2]:
        print(1, 3)
else:
    for i in range(1, len(S)):
        if S[i] == S[i - 1]:
            print(i, i + 1)
            break
    else:
        print(-1, -1)

Fixed submission:
S = input()
for i in range(len(S) - 1):
    if S[i] == S[i + 1]:
        print(i + 1, i + 2)
        break
    if i < len(S) - 2 and S[i] == S[i + 2]:
        print(i + 1, i + 3)
        break
else:
    print(-1, -1)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a =< 0 and b >= 0:
    ans = 'Zero'
elif a < 0 and b < 0:
    if (abs(a) - abs(b) + 1) % 2 == 0:
        ans = 'Positive'
    else:
        ans = 'Negative'
elif a > 0 and b > 0:
    ans = 'Positive'
    
print(ans)

Fixed submission:
a, b = map(int, input().split())

if a <= 0 and b >= 0:
    ans = 'Zero'
elif a < 0 and b < 0:
    if (abs(a) - abs(b) + 1) % 2 == 0:
        ans = 'Positive'
    else:
        ans = 'Negative'
elif a > 0 and b > 0:
    ans = 'Positive'
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
water = list(map(int,input().split()))

half_sum_water = sum(water) // 2

ans = []

m = n // 2
for i in range(n):
    mount = half_sum_water
    for j in range(m):
        mount = mount - water[(i + 1 + (j * 2)) % n]
    print(mount * 2,end = ' ')

print()


Fixed submission:
n = int(input())
water = list(map(int,input().split()))

half_sum_water = sum(water) // 2

ans = []

m = n // 2
x0 = half_sum_water
for i in range(m):
    x0 = x0 - water[(1 + (i * 2)) % n]

print(x0 * 2,end = ' ')

x = x0
for i in range(n - 1):
    x = water[i] - x
    print(x * 2,end = ' ')

print()
Buggy python submission (verdict: Runtime Error):
import math

def conb(x,y):
    return (math.factorial(x) // math.factorial(x - y)) // math.factorial(y)


n,k = map(int,input().split())

for i in range(1,k + 1):
    print(conb(n - k + 1,i) * conb(k - 1,i - 1) % 1000000007)


Fixed submission:
import math

def conb(x,y):
    if x < y:
        return 0
    else:
        return (math.factorial(x) // math.factorial(x - y)) // math.factorial(y)


n,k = map(int,input().split())

for i in range(1,k + 1):
    print(conb(n - k + 1,i) * conb(k - 1,i - 1) % 1000000007)
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x,y):
     return x * y // math.gcd(x,y)

a,b,c,d = map(int,input().split())

countB = b - (b // c) - (b // d) + (b // lcm(c,d))
countA = a - 1 - ((a - 1) // c) - ((a - 1) // d) + ((a - 1) // lcm(c,d))

print(countB - countA)


Fixed submission:
import fractions

def lcm(x,y):
     return x * y // fractions.gcd(x,y)

a,b,c,d = map(int,input().split())

countB = b - (b // c) - (b // d) + (b // lcm(c,d))
countA = a - 1 - ((a - 1) // c) - ((a - 1) // d) + ((a - 1) // lcm(c,d))

print(countB - countA)