import heapq

n, m = map(int, input().split())
baitos = []
for _ in range(n):
    baitos.append(list(map(int, input().split())))

baitos = sorted(baitos)
# print(sorted(baitos))
# print(baitos)

money = 0
avail = []
heapq.heapify(avail)
for day in range(m):
    while baitos:
        if baitos[0][0] > day + 1:
            break
        else:
            heapq.heappush(avail, -baitos[0][1])
            baitos.remove(baitos[0])
    # for baito in baitos:
    #     print(baito)
    #     if baito[0] > day + 1:
    #         print("break")
    #         break
    #     else:
    #         heapq.heappush(avail, -baito[1])
    #         baitos.remove(baito)
    # print("baitos", baitos)
    # print("avail", avail)
    if avail:

        money += -heapq.heappop(avail)
        # print(day, money)
    # money += max[1]
    # baitos.remove(max)

print(money)

import heapq

n, m = map(int, input().split())
baitos = [list(map(int, input().split())) for _ in range(n)]

baitos = sorted(baitos)
# print(sorted(baitos))
# print(baitos)

money = 0
avail = []
# heapq.heapify(avail)
index = 0
for day in range(m):
    while index < n and baitos[index][0] <= day + 1:
        heapq.heappush(avail, -baitos[index][1])
        index += 1
        # baitos.remove(baitos[0])
    # for baito in baitos:
    #     print(baito)
    #     if baito[0] > day + 1:
    #         print("break")
    #         break
    #     else:
    #         heapq.heappush(avail, -baito[1])
    #         baitos.remove(baito)
    # print("baitos", baitos)
    # print("avail", avail)
    if avail:

        money += -heapq.heappop(avail)
        # print(day, money)
    # money += max[1]
    # baitos.remove(max)

print(money)


from collections import defaultdict

n, m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for i in range(n)])
c = [[]] * m
a, b = ab[0]
last = a
ad = [b]
for i in range(1, n):
    a, b = ab[i]
    if a == last:
        ad.append(b)
    else:
        if last <= m:
            c[last - 1] = ad
        ad = [b]
    last = a
if a <= m:
    c[a - 1] = ad
choice = defaultdict(int)
ans = 0
for i in range(m):
    for j in c[i]:
        choice[j] += 1
    if choice:
        use = max(choice)
        ans += use
        choice[use] -= 1
        if choice[use] <= 0:
            del choice[use]
print(ans)

import heapq

n, m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for i in range(n)])
c = [[]] * m
a, b = ab[0]
last = a
ad = [b]
for i in range(1, n):
    a, b = ab[i]
    if a == last:
        ad.append(b)
    else:
        if last <= m:
            c[last - 1] = ad
        ad = [b]
    last = a
if a <= m:
    c[a - 1] = ad
a = [3, 0, 2, 6]
choice = []
heapq.heapify(choice)
ans = 0
for i in range(m):
    for j in c[i]:
        heapq.heappush(choice, -j)
    if choice:
        ans -= heapq.heappop(choice)
print(ans)


n, m = map(int, input().split(" "))
xys = [tuple(map(int, input().split(" "))) for i in range(n)]
xys = sorted(xys, key=lambda x: (x[0], -x[1]))

ans = 0

for i in range(1, m + 1):
    cm = -1
    cmi = -1
    for j in range(len(xys)):
        if xys[j][0] <= i and xys[j][1] > cm:
            cm = xys[j][1]
            cmi = j
    if cmi >= 0:
        ans += cm
        xys.pop(cmi)

print(ans)

from heapq import heappush, heappop

n, m = map(int, input().split(" "))
xys = [tuple(map(int, input().split(" "))) for i in range(n)]
xys = sorted(xys, key=lambda x: (x[0], -x[1]))

ans = 0

j = 0
h = []
for i in range(1, m + 1):
    while j < len(xys) and xys[j][0] <= i:
        heappush(h, -xys[j][1])
        j += 1
    if h:
        x = -heappop(h)
        # print("Pick", x)
        ans += x

print(ans)


#!/usr/bin/env python3
n, m = map(int, input().split())
ba = [None] * n
for i in range(n):
    a, b = map(int, input().split())
    ba[i] = [b, a]
ba.sort(reverse=True)
li = [0] * m
for i in range(n):
    b, a = ba[i]
    for j in range(m - a + 1)[::-1]:
        if li[j] == 0:
            li[j] = b
            break
print(sum(li))

#!/usr/bin/env python3
from queue import PriorityQueue

n, m = map(int, input().split())
jobs = [[] for _ in range(m)]
for i in range(n):
    a, b = map(int, input().split())
    if a > m:
        continue
    jobs[m - a].append(b)
pq = PriorityQueue()
ans = 0
for i in range(m)[::-1]:
    for b in jobs[i]:
        pq.put(-b)
    if not pq.empty():
        ans += -pq.get()
print(ans)


N, M = map(int, input().split())
AB = [[0, 0] for _ in range(N)]

for n in range(N):
    AB[n][0], AB[n][1] = map(int, input().split())
    AB[n][1] = 0 - AB[n][1]
AB.sort()

pop_list = []

earn = 0
for m in range(1, M + 1):
    max_earn = 0
    max_i = 0
    for i in range(len(AB)):
        if m < AB[i][0]:
            break

        if max_earn > AB[i][1] and i not in pop_list:
            max_earn = AB[i][1]
            max_i = i

    if max_earn != 0:
        earn += AB[max_i][1]
        pop_list.append(max_i)

print(0 - earn)

import queue

N, M = map(int, input().split())
AB = [[] for _ in range(M + 1)]

for n in range(N):
    a, b = map(int, input().split())
    if a > M:
        continue
    AB[a].append(0 - b)

earn = 0
q = queue.PriorityQueue()

for m in range(1, M + 1):

    for job in AB[m]:
        q.put(job)

    if not q.empty():
        earn += q.get()

print(0 - earn)


n, m, p = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]

def bellman_ford(s, g):
    # loop 0 - (n-1) : bellman ford
    # loop n - (2n-1): check g can be updated
    dist = [float("inf")] * n
    dist[s] = 0
    negative = [False] * n
    for i in range(2 * n):
        for a, b, c in abc:
            a -= 1
            b -= 1
            cost = -(c - p)

            if dist[b] > dist[a] + cost:
                dist[b] = dist[a] + cost
                if i >= n:
                    negative[b] = True

    if negative[g]:
        return -1

    else:
        return max(-dist[g], 0)

ans = bellman_ford(0, n - 1)
print(ans)

n, m, p = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]

def bellman_ford(s, g):
    # loop 0 - (n-1) : bellman ford
    # loop n - (2n-1): check g can be updated
    dist = [float("inf")] * n
    dist[s] = 0
    for i in range(2 * n):
        for a, b, c in abc:
            a -= 1
            b -= 1
            cost = -(c - p)

            if dist[b] > dist[a] + cost:
                dist[b] = dist[a] + cost
                if i >= n:
                    dist[b] = -float("inf")

    if dist[g] == -float("inf"):
        return -1

    else:
        return max(-dist[g], 0)

ans = bellman_ford(0, n - 1)
print(ans)


from collections import defaultdict, deque

N, M, P = map(int, input().split())
G = defaultdict(lambda: defaultdict(lambda: 10000000))
G_rev = defaultdict(lambda: defaultdict(lambda: 10000000))

for i in range(1, N + 1):
    G[i] = dict()
    G_rev[i] = dict()

for _ in range(M):
    A, B, C = map(int, input().split())
    G[A][B] = min(G[A][B], P - C)
    G_rev[B][A] = 1

reachable_N = [0] * (N + 1)
reachable_N[N] = 1
queue = deque([N])

while len(queue) > 0:
    p = queue.popleft()
    for q in G_rev[p].keys():
        if reachable_N[q] == 0:
            reachable_N[q] = 1
            queue.append(q)

reachable_1 = [0] * (N + 1)
reachable_1[1] = 1
queue = deque([1])

while len(queue) > 0:
    p = queue.popleft()
    for q in G[p].keys():
        if reachable_1[q] == 0:
            reachable_1[q] = 1
            queue.append(q)

reachable = [reachable_1[i] * reachable_N[i] for i in range(N + 1)]

dist = [10000000000 for i in range(N + 1)]
res = 0
dist[1] = 0
queue = deque([1])
cnt = 0

update = True

while update:
    update = False
    for p in range(1, N + 1):
        if reachable[p] == 0:
            continue
        for q in G[p].keys():
            if reachable[q] == 0:
                pass
            elif dist[p] + G[p][q] < dist[q]:
                dist[q] = dist[p] + G[p][q]
                update = True
    cnt += 1
    if cnt > N:
        res = -1
        break

if res == -1:
    print(res)
else:
    print(max(0, -dist[N]))

from collections import defaultdict, deque

N, M, P = map(int, input().split())
G = defaultdict(lambda: defaultdict(lambda: 10000000))
G_rev = defaultdict(lambda: defaultdict(lambda: 10000000))

for _ in range(M):
    A, B, C = map(int, input().split())
    G[A][B] = min(G[A][B], P - C)
    G_rev[B][A] = 1

reachable_N = [0] * (N + 1)
reachable_N[N] = 1
queue = deque([N])

while len(queue) > 0:
    p = queue.popleft()
    for q in G_rev[p].keys():
        if reachable_N[q] == 0:
            reachable_N[q] = 1
            queue.append(q)

reachable_1 = [0] * (N + 1)
reachable_1[1] = 1
queue = deque([1])

while len(queue) > 0:
    p = queue.popleft()
    for q in G[p].keys():
        if reachable_1[q] == 0:
            reachable_1[q] = 1
            queue.append(q)

reachable = [reachable_1[i] * reachable_N[i] for i in range(N + 1)]

dist = [10000000000 for i in range(N + 1)]
res = 0
dist[1] = 0
queue = deque([1])
cnt = 0

update = True

while update:
    update = False
    for p in range(1, N + 1):
        if reachable[p] == 0:
            continue
        for q in G[p].keys():
            if reachable[q] == 0:
                pass
            elif dist[p] + G[p][q] < dist[q]:
                dist[q] = dist[p] + G[p][q]
                update = True
    cnt += 1
    if cnt > N:
        res = -1
        break

if res == -1:
    print(res)
else:
    print(max(0, -dist[N]))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02949/Python/s582998390.py", line 13, in <module>
    G[A][B] = min(G[A][B], P - C)
KeyError: 2


import numpy as np

p = int(input())
aaa = list(map(int, input().split()))

bins = [1]
for i in range(1, p):
    bins.append(bins[-1] * (p - i) * pow(i, p - 2, p) % p)
bins = np.array(bins, dtype=np.int32)

coefs = np.zeros(p, dtype=np.int32)

for i, a in enumerate(aaa):
    if a == 0:
        continue

    coefs[0] += 1

    pows = [1]
    for _ in range(1, p):
        pows.append(pows[-1] * -i % p)
    pows.reverse()
    pows = np.array(pows, dtype=np.int32)

    coefs = (coefs - bins * pows) % p

print(*coefs)

import numpy as np

p = int(input())
aaa = list(map(int, input().split()))

bins = [1]
for i in range(1, p):
    bins.append(bins[-1] * (p - i) * pow(i, p - 2, p) % p)
bins = np.array(bins, dtype=np.int32)

pows_base = -np.arange(p, dtype=np.int32)
pows = np.zeros((p, p), dtype=np.int32)
pows[:, p - 1] = 1
for i in range(p - 2, -1, -1):
    pows[:, i] = pows[:, i + 1] * pows_base % p

coefs = np.zeros(p, dtype=np.int32)

for i, a in enumerate(aaa):
    if a == 0:
        continue

    coefs[0] += 1
    coefs = (coefs - bins * pows[i]) % p

print(*coefs)


p = int(input())
a = list(map(int, input().split()))
MOD = p

P = p
fact = [0] * P
fact[0] = 1
for i in range(1, P):
    fact[i] = fact[i - 1] * i
    fact[i] %= MOD

rfact = [0] * P
rfact[P - 1] = pow(fact[P - 1], MOD - 2, MOD)
for i in range(P - 2, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1)
    rfact[i] %= MOD

def comb(n, k):
    return fact[n] * rfact[n - k] * rfact[k] % MOD

b = [0] * p
for i in range(p):
    if a[i]:
        b[0] += 1
        b[0] %= MOD
        for j in range(p):
            b[j] -= comb(p - 1, j) * (-i) ** (p - 1 - j)
            b[j] %= MOD

print(*b)

import sys

input = sys.stdin.readline
p = int(input())
a = list(map(int, input().split()))
MOD = p

P = p
fact = [0] * P
fact[0] = 1
for i in range(1, P):
    fact[i] = fact[i - 1] * i
    fact[i] %= MOD

rfact = [0] * P
rfact[P - 1] = pow(fact[P - 1], MOD - 2, MOD)
for i in range(P - 2, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1)
    rfact[i] %= MOD

def comb(n, k):
    return fact[n] * rfact[n - k] * rfact[k] % MOD

b = [0] * p
for i in range(p):
    if a[i]:
        b[0] += 1
        b[0] %= MOD
        s = 1
        for j in range(p - 1, -1, -1):
            b[j] -= comb(p - 1, j) * s
            b[j] %= MOD
            s *= -i
            s %= MOD

print(*b)


i = list(map(int, input().split()))
print(i[2] - (i[0] - i[1]))
i = list(map(int, input().split()))
n = i[2] - (i[0] - i[1])
if n > 0:
    print(n)
else:
    print(0)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02951/Python/s799517998.py", line 3, in <module>
    i = list(map(int, input().split()))
EOFError: EOF when reading a line


a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02951/Python/s280962278.py", line 3, in <module>
    a, b, c = map(int, (input().split()))
EOFError: EOF when reading a line


a, b, c = input().splita, b, c = [int(x) for x in input().strip().split()]

water = c - (a - b)
if water < 0:
    print(0)
else:
    print(water)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02951/Python/s087836716.py", line 1, in <module>
    a, b, c = input().splita, b, c = [int(x) for x in input().strip().split()]
EOFError: EOF when reading a line


num = input().split()
a = num[0]
b = num[1]
c = num[2]
ans = b + c - a
if ans > 0:
    print(ans)
else:
    print(0)

num = input().split()
a = int(num[0])
b = int(num[1])
c = int(num[2])
ans = b + c - a
if ans > 0:
    print(ans)
else:
    print(0)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02951/Python/s319382696.py", line 5, in <module>
    ans = b + c - a
TypeError: unsupported operand type(s) for -: 'str' and 'str'


a, b, c = map(int, input().split())
print(max(c - (a - b)), 0)

a, b, c = map(int, input().split())
print(max(c - (a - b), 0))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02951/Python/s849480716.py", line 2, in <module>
    print(max(c - (a - b)), 0)
TypeError: 'int' object is not iterable


def main(n):
    count = 0

    for i in range(n + 1):
        if str(i).__len__ % 2 == 1:
            count += 1

    print(count)

if __name__ == "__main__":
    n = int(input())

    main(n)

def main(n):
    count = 0

    for i in range(1, n + 1):
        if len(str(i)) % 2 == 1:
            count += 1

    print(count)

if __name__ == "__main__":
    n = int(input())

    main(n)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02952/Python/s049865581.py", line 14, in <module>
    main(n)
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02952/Python/s049865581.py", line 5, in main
    if str(i).__len__ % 2 == 1:
TypeError: unsupported operand type(s) for %: 'method-wrapper' and 'int'


n = int(input())
cnt = 0
for i in range(1, n + 1):
    if str(i) % 2 == 1:
        cnt += 1
print(cnt)

n = int(input())
cnt = 0
for i in range(1, n + 1):
    if len(str(i)) % 2 == 1:
        cnt += 1
print(cnt)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02952/Python/s429203628.py", line 4, in <module>
    if str(i) % 2 == 1:
TypeError: not all arguments converted during string formatting


N = int(input())
ans = 0
for i in range(1, N + 1):
    if len(i) % 2 == 1:
        ans += 1
print(ans)

N = int(input())
ans = 0
for i in range(1, N + 1):
    if len(str(i)) % 2 == 1:
        ans += 1
print(ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02952/Python/s356122342.py", line 4, in <module>
    if len(i) % 2 == 1:
TypeError: object of type 'int' has no len()


n = int(input())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    print(h)
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
    x = hi
print(ans)

n = int(input())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
    x = h[i]
print(ans)


import sys

input = sys.stdin.readline

def main():
    n = int(input())
    H = [int(i) for i in input().split()]
    # マスの高さを1つ引くくすること
    # なにもしない
    # 単調非減少ってなんだ
    # 左より低くならないようにすれば良いっぽいな
    # N = 10 ** 5
    # h = 10 ** 9
    # example:
    # 1 2 1 1 -> 1 1 1 1 -> Yes
    # 1 2 2 1 -> 1 2 1 1 -> No
    # 1 2 3 1 -> 1 2 2 1 -> No
    # 1 100 1 1 -> 1 99 1 1 -> No
    #

    cnt = 0
    # とりあえず、愚直に書いてみる
    a = None
    b = H[0]
    for i in range(1, n + 1):
        c = H[i]
        sa = c - b
        if sa < -1:
            cnt = 2
            break
        elif sa < 0:
            if a and a == b:
                cnt = 2
                break
            cnt += 1
        a = b
        b = c
        if cnt > 1:
            break
    print("Yes" if cnt <= 1 else "No")

if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline

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

    flg = True
    max_ = -1
    for h in H:
        if h < max_:
            flg = False
            break
        if h == max_:
            continue
        max_ = h - 1
    print("Yes" if flg else "No")

if __name__ == "__main__":
    main()

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02953/Python/s934436551.py", line 45, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02953/Python/s934436551.py", line 27, in main
    c = H[i]
IndexError: list index out of range


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

for i in reversed(range(1, n)):
    d = stair[i] - stair[i - 1]
    if d > 1:
        print("No")
        exit()
    elif d == 1:
        stair -= 1
print("Yes")

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

for i in reversed(range(1, n)):
    d = stair[i] - stair[i - 1]
    if d < -1:
        print("No")
        exit()
    elif d == -1:
        stair[i - 1] -= 1
print("Yes")


N = int(input())

stairs = list(map(int, input().split(" ")))

for i in range(N):
    stair = stairs[i]
    if stair - 2 >= min(stairs[i:]):
        print("No")
        exit(0)

print("Yes")

N = int(input())

stairs = list(map(int, input().split(" ")))
min = 0

for i in range(N):
    stair = stairs[i]
    if min > stair:
        print("No")
        exit(0)
    if stair - 1 > min:
        min = stair - 1

print("Yes")


s = input()
n = len(s)

square = [0 for _ in range(n)]
for i in range(n):
    if s[i] == "L":
        add_num = -1
    else:
        add_num = 1
    j = i + add_num
    char = s[i]
    while j > -1 and j < n and char == s[j]:
        j += add_num
    if (i - j) % 2 == 0:
        square[j] += 1
    else:
        square[j - add_num] += 1

print(square[0], end="")
for i in range(1, n):
    print(" ", end="")
    print(square[i], end="")

s = input()
n = len(s)

square = [0 for _ in range(n)]
i = 0
while i < n:
    start = i
    char = s[i]
    i += 1
    while i < n and char == s[i]:
        i += 1

    if char == "L":
        num = i - start
        if num % 2 == 0:
            square[start - 1] += num // 2
            square[start] += num // 2
        else:
            square[start] += num // 2 + 1
            square[start - 1] += num // 2
    else:  # R
        num = i - start
        if num % 2 == 0:
            square[i] += num // 2
            square[i - 1] += num // 2
        else:
            square[i] += num // 2
            square[i - 1] += num // 2 + 1
    # if i == n - 1:
    #     i += 1

print(square[0], end="")
for i in range(1, n):
    print(" ", end="")
    print(square[i], end="")


s = input()
kids = [0] * len(s)
for i, c in enumerate(s):
    now = i
    if c == "R":
        while s[now + 1] == "R":
            now += 1
        diff = abs(now - i)
        if diff % 2:
            kids[now + 1] += 1
        else:
            kids[now] += 1
    else:
        while s[now - 1] == "L":
            now -= 1
        diff = abs(now - i)
        if diff % 2:
            kids[now - 1] += 1
        else:
            kids[now] += 1
print(" ".join([str(k) for k in kids]))

s = list(input())
kids = [0] * len(s)

for d in ["R", "L"]:
    c = 0
    for i in range(len(s)):
        if s[i] == d:
            c += 1
        else:
            kids[i] += c // 2
            kids[i - 1] += (c + 1) // 2
            c = 0
    s.reverse()
    kids.reverse()

print(" ".join([str(k) for k in kids]))


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

divs = []
maxA = sum(A)
for i in range(1, maxA + 1):
    if maxA % i == 0:
        divs.append(i)
        divs.append(maxA // i)

divs.sort(reverse=True)

for d in divs:
    rest = [a % d for a in A]
    rest.sort(reverse=True)
    restSum = sum(rest) // d
    cnt = 0
    for i in range(restSum):
        cnt += d - rest[i]
    if cnt <= K:
        print(d)
        exit()

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

divs = []
maxA = sum(A)
for i in range(1, int(maxA**0.5) + 1):
    if maxA % i == 0:
        divs.append(i)
        divs.append(maxA // i)

divs.sort(reverse=True)

for d in divs:
    rest = [a % d for a in A]
    rest.sort(reverse=True)
    restSum = sum(rest) // d
    cnt = 0
    for i in range(restSum):
        cnt += d - rest[i]
    if cnt <= K:
        print(d)
        exit()


# -*- coding: utf-8 -*-
a, b = map(int, input().split())
if isinstance((a + b) / 2):
    print((a + b) / 2)
else:
    print("IMPOSSIBLE")

# -*- coding: utf-8 -*-
a, b = map(int, input().split())
if (a + b) % 2 == 0:
    print((a + b) // 2)
else:
    print("IMPOSSIBLE")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02957/Python/s456363956.py", line 3, in <module>
    if isinstance((a + b) / 2):
TypeError: isinstance expected 2 arguments, got 1


#!/bin/python3

a, b = input().split(" ")

if a % 2 == b % 2:
    print((a + b) / 2)
else:
    print("IMPOSSIBLE")

# -*- coding: utf-8 -*-

a, b = map(int, input().split(" "))
if a % 2 == b % 2:
    print(int((a + b) / 2))
else:
    print("IMPOSSIBLE")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02957/Python/s028842824.py", line 5, in <module>
    if a % 2 == b % 2:
TypeError: not all arguments converted during string formatting


a = int(input())
b = int(input())

if (a + b) % 2 != 0:
    print("IMPOSSIBLE")
else:
    if a < b:
        A = a
        B = b
    else:
        A = b
        B = a

    K = int(B - (B - A) / 2)
    print(str(K))

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

if a < b:
    A = a
    B = b
else:
    A = b
    B = a

if (B - A) % 2 != 0:
    print("IMPOSSIBLE")
else:
    K = int(B - (B - A) / 2)
    print(str(K))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02957/Python/s043180059.py", line 1, in <module>
    a = int(input())
ValueError: invalid literal for int() with base 10: '2 16'


n = int(input())
p = list(map(int, input().split()))
sorted_p = sorted(p)
cnt = 0
for a, b in p, sorted_p:
    if a != b:
        cnt += 1
if cnt > 2:
    print("NO")
else:
    print("YES")

n = int(input())
p = list(map(int, input().split()))
sorted_p = sorted(p)
cnt = 0
for a, b in zip(p, sorted_p):
    if a != b:
        cnt += 1
if cnt > 2:
    print("NO")
else:
    print("YES")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02958/Python/s135206060.py", line 5, in <module>
    for a, b in p, sorted_p:
ValueError: too many values to unpack (expected 2)


N = int(input())
p = list(map(int, input().split()))
for i in range(N):
    for j in range(i + 1, N):
        if p[j - 1] < p[i] < p[j + 1] and p[i - 1] < p[j] < p[i + 1]:
            print("YES")
            exit()
        else:
            continue
print("NO")

N = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(N):
    if p[i] != i + 1:
        count += 1
if count == 0 or count == 2:
    print("YES")
else:
    print("NO")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02958/Python/s761577453.py", line 5, in <module>
    if p[j - 1] < p[i] < p[j + 1] and p[i - 1] < p[j] < p[i + 1]:
IndexError: list index out of range


N = int(input())
p = list(map(int, input().split()))
q = sorted(p)
k = 0
for i in range(1, N + 1):
    if p[i] - q[i] != 0:
        k += 1

if k > 2:
    print("NO")
else:
    print("YES")

N = int(input())
p = list(map(int, input().split()))
q = sorted(p)
k = 0
for i in range(N):
    if p[i] - q[i] != 0:
        k += 1

if k > 2:
    print("NO")
else:
    print("YES")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02958/Python/s083953128.py", line 6, in <module>
    if p[i] - q[i] != 0:
IndexError: list index out of range


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

count = 0
for i in range(n):
    if a[i] < b[i]:
        count += a[i]
        d = b[i] - a[i]

        if a[i + 1] < d:
            count += a[i + 1]
            a[i + i] = 0
        else:
            count += d
            a[i + 1] -= d

    else:
        count += b[i]

print(count)

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

count = 0
for i in range(n):
    if a[i] < b[i]:
        count += a[i]
        d = b[i] - a[i]

        if a[i + 1] < d:
            count += a[i + 1]
            a[i + 1] = 0
        else:
            count += d
            a[i + 1] -= d

    else:
        count += b[i]

print(count)


n = int(input())
monster = list(map(int, input().split()))
yuusha = list(map(int, input().split()))
a = sum(monster)
for i in range(n):
    while yuusha[i] != 0:
        if monster[i] > 0:
            yuusha[i] -= 1
            monster[i] -= 1
        elif monster[i + 1] > 0:
            yuusha[i] -= 1
            monster[i + 1] -= 1
        else:
            break
a -= sum(monster)
print(a)

n = int(input())
monster = list(map(int, input().split()))
yuusha = list(map(int, input().split()))
a = sum(monster)
for i in range(n):
    if monster[i] < yuusha[i]:
        yuusha[i] -= monster[i]
        monster[i] = 0
        if monster[i + 1] < yuusha[i]:
            yuusha[i] -= monster[i + 1]
            monster[i + 1] = 0
        else:
            monster[i + 1] -= yuusha[i]
            yuusha[i] = 0
    else:
        monster[i] -= yuusha[i]
        yuusha[i] = 0
a -= sum(monster)
print(a)


# coding:utf-8
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0

for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
    else:
        ans += a[i]
        b[i] -= a[i]
        if a[i + 1] >= b[i]:
            a[i + 1] -= b[i]
            ans += b[i]
        else:
            ans += a[i + i]
            a[i + 1] = 0

print(ans)

# coding:utf-8
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0

for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
    else:
        ans += a[i]
        b[i] -= a[i]
        if a[i + 1] >= b[i]:
            a[i + 1] -= b[i]
            ans += b[i]
        else:
            ans += a[i + 1]
            a[i + 1] = 0

print(ans)


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

s1 = sum(a)
for i in range(n + 1):
    if i == 0:
        if a[i] < b[i]:
            b[i] -= a[i]
            a[i] = 0
        else:
            a[i] -= b[i]
            b[i] = 0
    elif i == n:
        if a[i] < b[i - 1]:
            a[i] = 0
        else:
            a[i] -= b[i - 1]
            b[i] = 0
    else:
        if a[i] < b[i - 1]:
            a[i] = 0
        else:
            a[i] -= b[i - 1]
        if a[i] < b[i]:
            b[i] -= a[i]
            a[i] = 0
        else:
            a[i] -= b[i]
            b[i] = 0
print(s1 - sum(a))

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

s1 = sum(a)
for i in range(n + 1):
    if i == 0:
        if a[i] < b[i]:
            b[i] -= a[i]
            a[i] = 0
        else:
            a[i] -= b[i]
            b[i] = 0
    elif i == n:
        if a[i] < b[i - 1]:
            a[i] = 0
        else:
            a[i] -= b[i - 1]
            b[i - 1] = 0
    else:
        if a[i] < b[i - 1]:
            a[i] = 0
        else:
            a[i] -= b[i - 1]
        if a[i] < b[i]:
            b[i] -= a[i]
            a[i] = 0
        else:
            a[i] -= b[i]
            b[i] = 0
print(s1 - sum(a))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02959/Python/s937691477.py", line 19, in <module>
    b[i] = 0
IndexError: list assignment index out of range


S = str(input())
S_len = len(S)

DP = [[0 for j in range(13)] for i in range(S_len + 1)]
DP[S_len][0] = 1
num = 1

for i in reversed(range(S_len)):

    if S[i] != "?":
        for j in range(13):
            DP[i][(j + int(S[i]) * num) % 13] += DP[i + 1][j] % 1000000007
    else:
        for j in range(13):
            for k in range(10):
                DP[i][(j + k * num) % 13] += DP[i + 1][j] % 1000000007

    num = (num * 10) % 13

print(DP[0][5] % 1000000007)


s = input()
t = input()

u = ""
while len(u) < len(s) + len(t):
    u = s * (len(t) // len(s) + 1)

t_add = t + "."

def partial_match_table(word):
    table = [0] * (len(word) + 1)
    table[0] = -1
    i, j = 0, 1

    while j < len(word):
        matched = word[i] == word[j]

        if not matched and i > 0:
            i = table[i]
        else:
            if matched:
                i += 1
            j += 1
            table[j] = i

    return table

table_tx = partial_match_table(t_add)

match = [0] * len(s)

i = j = 0
while i < len(u) and j < len(t_add):
    if u[i] == t_add[j]:
        i += 1
        j += 1
    elif j == 0:
        i += 1
    else:
        j = table_tx[j]
    if j == len(t_add) - 1:
        match[(i - j) % len(s)] = 1

# search
searched = [0] * len(s)
longest = 0
infinity = False
for i in range(len(s)):
    if searched[i]:
        continue
    searched[i] = 1
    p = i
    right = 0
    while match[p]:
        right += 1
        p = (p + len(t)) % len(s)
        searched[p] = 1
        if p == i:
            infinity = True
            break
    left = 0
    p = i
    while match[(p - len(t)) % len(s)]:
        left += 1
        p = (p - len(t)) % len(s)
        searched[p] = 1
        if p == i:
            infinity = True
            break
    if left + right > longest:
        longest = left + right

if infinity:
    print(-1)
else:
    print(longest)

s = input()
t = input()

u = s * (len(t) // len(s) + 2)

t_add = t + "."

def partial_match_table(word):
    table = [0] * (len(word) + 1)
    table[0] = -1
    i, j = 0, 1

    while j < len(word):
        matched = word[i] == word[j]

        if not matched and i > 0:
            i = table[i]
        else:
            if matched:
                i += 1
            j += 1
            table[j] = i

    return table

table_tx = partial_match_table(t_add)

match = [0] * len(s)

i = j = 0
while i < len(u) and j < len(t_add):
    if u[i] == t_add[j]:
        i += 1
        j += 1
    elif j == 0:
        i += 1
    else:
        j = table_tx[j]
    if j == len(t_add) - 1:
        match[(i - j) % len(s)] = 1

# search
searched = [0] * len(s)
longest = 0
infinity = False
for i in range(len(s)):
    if searched[i]:
        continue
    searched[i] = 1
    p = i
    right = 0
    while match[p]:
        right += 1
        p = (p + len(t)) % len(s)
        searched[p] = 1
        if p == i:
            infinity = True
            break
    left = 0
    p = i
    while match[(p - len(t)) % len(s)]:
        left += 1
        p = (p - len(t)) % len(s)
        searched[p] = 1
        if p == i:
            infinity = True
            break
    if left + right > longest:
        longest = left + right

if infinity:
    print(-1)
else:
    print(longest)


import math

s = int(input())

rot = int(math.sqrt(s) // 1)
if s == rot**2:
    print(f"0 0 0 {rot} 0 0 {rot}")
    exit()

rot += 1
ans = (rot**2) - s
print(f"0 0 {rot} 1 {ans} {rot}")

import math

s = int(input())

rot = int(math.sqrt(s) // 1)
if s == rot**2:
    print("0 0 " + str(rot) + " 0 0 " + str(rot))
    exit()

rot += 1
ans = (rot**2) - s
print("0 0 " + str(rot) + " 1 " + str(ans) + " " + str(rot))


s = int(input())

t = int(pow(s, 0.5))
for i in range(t, 0, -1):
    if s % i == 0:
        x = i
        y = s // i
        break

ans = [0, 0, 0, y, x, 0]
print(*ans)

s = int(input())
a = [0, 0]

a.append(10**9)
a.append(1)

q, r = divmod(s, 10**9)
if r > 0:
    q += 1
    r -= 10**9
    r *= -1

a.append(r)
a.append(q)

print(*a)


from functools import lru_cache

def prepare(n, MOD):
    f = 1
    factorials = [1] * (n + 1)
    for m in range(1, n + 1):
        f = f * m % MOD
        factorials[m] = f
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv = inv * m % MOD
        invs[m - 1] = inv

    return factorials, invs

def get_nhr(n, facts, invs, MOD):
    @lru_cache(maxsize=None)
    def nhr(r):
        return facts[n + r - 1] * invs[r] * invs[n - 1] % MOD

    return nhr

def solve(n, m):
    MOD = 998244353
    facts, invs = prepare(n + 3 * m, MOD)
    fn = facts[n]
    nhr = get_nhr(n, facts, invs, MOD)
    ans = 0
    for odd in range(m % 2, min(m, n) + 1, 2):
        tmp = nhr((3 * m - odd) // 2)
        if odd > 0:
            tmp -= odd * nhr((m - odd) // 2)
        if odd < n and odd <= m - 2:
            tmp -= (n - odd) * nhr((m - odd - 2) // 2)
        ans = (ans + fn * invs[odd] * invs[n - odd] % MOD * tmp) % MOD
    return ans

n, m = list(map(int, input().split()))
print(solve(n, m))

def prepare(n, MOD):
    f = 1
    factorials = [1] * (n + 1)
    for m in range(1, n + 1):
        f = f * m % MOD
        factorials[m] = f
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv = inv * m % MOD
        invs[m - 1] = inv

    return factorials, invs

def get_nhr(n, facts, invs, MOD):
    def nhr(r):
        return facts[n + r - 1] * invs[r] * invs[n - 1] % MOD

    return nhr

def solve(n, m):
    MOD = 998244353
    facts, invs = prepare(n + 3 * m, MOD)
    fn = facts[n]
    nhr = get_nhr(n, facts, invs, MOD)
    nm2 = min(n, m - 1)
    ans = 0
    for odd in range(m % 2, min(m, n) + 1, 2):
        tmp = nhr((3 * m - odd) // 2)
        if odd > 0:
            tmp -= odd * nhr((m - odd) // 2)
        if odd < nm2:
            tmp -= (n - odd) * nhr((m - odd - 2) // 2)
        ans = (ans + fn * invs[odd] * invs[n - odd] % MOD * tmp) % MOD
    return ans

n, m = list(map(int, input().split()))
print(solve(n, m))


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02969/Python/s048208097.py", line 2, in <module>
    print(3 * r * r)
TypeError: can't multiply sequence by non-int of type 'str'


#!/usr/bin/env python3

n = int(input())
print(int((n - 1) / 2) if n % 2 == 1 else int(n / 2) - 1)

#!/usr/bin/env python3
# https://atcoder.jp/contests/abc134/tasks/abc134_b

import math

n, d = [int(x) for x in input().split()]
print(math.ceil(n / (d * 2 + 1)))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02970/Python/s267140007.py", line 3, in <module>
    n = int(input())
ValueError: invalid literal for int() with base 10: '6 2'


n, d = map(int, input().split())
print(-(-n // (1 + d * 2)))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02970/Python/s626799708.py", line 1, in <module>
    n, d = map(int, input())
ValueError: invalid literal for int() with base 10: ' '


n, d = [int(x) for x in input().split()]

for i in range(n):
    if (2 * d + 1) * i >= n:
        ans = i
        break
print(ans)

n, d = [int(x) for x in input().split()]

for i in range(n + 1):
    if (2 * d + 1) * i >= n:
        ans = i
        break

print(ans)


import math

inputted = list(map(int, input()))
N = inputted[0]
D = inputted[1]

monitor = (D + 1) * 2
answer = math.ceil(N / monitor)

print(answer)

import math

inputted = list(map(int, input().split()))
N = inputted[0]
D = inputted[1]

monitor = D * 2 + 1
answer = math.ceil(N / monitor)

print(answer)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02970/Python/s590297145.py", line 3, in <module>
    inputted = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '


# -*- coding: utf-8 -*-

n = int(input())
a = ["" for _ in range(n)]

for i in range(n):
    a[i] = int(input())

ans = ["" for _ in range(n)]
for i in range(n):
    a_test = a[:]
    del a_test[i]
    ans[i] = max(a_test)

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

# -*- coding: utf-8 -*-

n = int(input())
a = [int(input()) for _ in range(n)]

max_a = max(a)
b = a[:]
b.remove(max_a)
max_b = max(b)

if max_a == max_b:
    for i in range(n):
        print(max_a)
else:
    idx = a.index(max_a)
    for i in range(n):
        if idx == i:
            print(max_b)
        else:
            print(max_a)


N = int(input())
a = []
b = 0
a.append(int(input()))
# for i in range(N):

for i in range(N):
    b = a[i]
    a[i] = 0
    print(max(a))
    a[i] = b

N = int(input())
a = []
b = []
a_max = 0
a_second = 0

for i in range(N):
    a.append(int(input()))

b = a[:]
a.sort(reverse=True)

a_max = a[0]
a_second = a[1]

for i in range(N):
    if b[i] == a_max:
        print(a_second)
    else:
        print(a_max)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02971/Python/s053988240.py", line 8, in <module>
    b = a[i]
IndexError: list index out of range


import sys
import numpy as np

input = sys.stdin.readline
n = int(input())
s = list(int(input()) for _ in range(n))
i = 0
maxn = 0
s2 = []
for i in range(n):
    s2 = s.copy()
    del s2[i]
    print(np.max(np.array(s2)))
    i += 1

n = int(input())
s = list(int(input()) for _ in range(n))
i = 0
sort_s = sorted(s)

for i in s:
    if i == sort_s[-1]:
        print(sort_s[-2])
    else:
        print(sort_s[-1])


def main(n: int, a: list):
    for i in range(n):
        t = a.copy()
        t[i] = 0

        print(max(t))

if __name__ == "__main__":
    n = int(input())
    a = [int(input()) for _ in range(n)]

    main(n, a)

def main(n: int, a: list):
    a_max, a_second = sorted(a, reverse=True)[:2]

    for i in range(n):
        if a[i] != a_max:
            print(a_max)
        else:
            print(a_second)

if __name__ == "__main__":
    n = int(input())
    a = [int(input()) for _ in range(n)]

    main(n, a)


n = int(input())
a = [int(input()) for _ in range(n)]
b, c = sorted(a)[-2:]
for i in range(n):
    print(b if a.index(c) == i else c)

n = int(input())
a = [int(input()) for _ in range(n)]
b, c = sorted(a)[-2:]
j = a.index(c)
for i in range(n):
    print((c, b)[i == j])


n = int(input())
a = [int(input()) for _ in range(n)]
mx = []
for i in range(n):
    x = a.pop(i)
    mx.append(max(a))
    a.insert(i, x)
for i in range(n):
    print(mx[i])

import copy

n = int(input())
a = [int(input()) for _ in range(n)]
s = copy.copy(a)
s.sort(reverse=True)
first = s[0]
second = s[1]
mx = []
for i in range(n):
    if a[i] == first:
        mx.append(second)
    else:
        mx.append(first)
for i in range(n):
    print(mx[i])


N = int(input())
L = [int(input()) for _ in range(N)]

for i in range(N):
    print(max(L[:i] + L[i + 1 :]))

N = int(input())
L = [int(input()) for _ in range(N)]

Ls = sorted(L, reverse=True)
for i in range(N):
    if L[i] == Ls[0]:
        print(Ls[1])
    else:
        print(Ls[0])


n = int(input())
a = [int(input()) for _ in range(n)]
b = []
for i in range(n):
    b = sorted(a.copy(), reverse=True)
    if a[i] == b[0]:
        print(b[1])
    else:
        print(b[0])

n = int(input())
a = [int(input()) for _ in range(n)]
b = sorted(a.copy(), reverse=True)
for i in range(n):
    if a[i] == b[0]:
        print(b[1])
    else:
        print(b[0])


n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
for i in range(n):

    if max(a) > a[i]:
        print(max(a))
    else:
        if a.count(a[i]) > 1:
            print(a[i])
        else:
            print(b[-2])

n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
max_a = max(a)
max_cnt = a.count(max_a)
for i in range(n):

    if max_a > a[i]:
        print(max_a)
    else:
        if max_cnt > 1:
            print(a[i])
        else:
            print(b[-2])


N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
    A_copy = A[:]
    removed_A = A_copy.pop(i)
    print(max(A_copy))

N = int(input())
A = [int(input()) for _ in range(N)]
sorted_A = sorted(A[:])

for i in range(N):
    if A[i] == sorted_A[-1]:
        print(sorted_A[-2])
    else:
        print(sorted_A[-1])


n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n):
    t = a[:]
    t.pop(i)
    print(max(t))

n = int(input())
maxindex = maxvalue = 0
a = []
for i in range(n):
    _a = int(input())
    if maxvalue <= _a:
        maxvalue = _a
        maxindex = i
    a.append(_a)

for i in range(n):
    if i != maxindex:
        print(maxvalue)
        continue
    t = a[:]
    t.pop(i)
    print(max(t))


n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

sa = sorted(a)
for i in range(n):
    val = a[i]
    idx = sa.index(val)
    sa.pop(idx)
    print(sa[-1])
    sa.insert(idx, val)

n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

sa = sorted(a)
mx = sa[-1]
for val in a:
    if val != mx:
        print(sa[-1])
    else:
        print(sa[-2])


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

for i in range(n):
    tmp = A[:]
    del tmp[i]
    print(max(tmp))

n = int(input())
A = [int(input()) for i in range(n)]
tmp = sorted(A, reverse=True)
Max = tmp[0]
Second = tmp[1]
for i in range(n):
    if A[i] != Max:
        print(Max)
    else:
        print(Second)


# -*- coding: utf-8 -*-
n = int(input())
a = [int(input()) for _ in range(n)]
a_unique = list(sorted(set(a), reverse=True))
max_value = max(a_unique)
for i in range(n):
    current_value = a.pop(i)
    if max_value in a:
        print(max_value)
    else:
        print(a_unique[1])
    a.insert(i, current_value)

# -*- coding: utf-8 -*-
n = int(input())
a = [int(input()) for _ in range(n)]
a_unique = list(sorted(set(a), reverse=True))
max_value = a_unique[0]
max_value_count = a.count(max_value)

if max_value_count == 1:
    for i in range(n):
        if a[i] == max_value:
            print(a_unique[1])
        else:
            print(max_value)
else:
    for i in range(n):
        print(max_value)


N = int(input())
A = [int(input()) for v in range(N)]

for i in range(N):
    L = A[:]
    A.pop(i)
    m = max(A)
    print(m)
    A = L[:]

N = int(input())
A = [int(input()) for v in range(N)]

L = A[:]
m1 = max(A)
m1i = A.index(m1)
A.pop(m1i)
m2 = max(A)
m2i = A.index(m2)
A.pop(m2i)

for i in range(N):
    if L[i] == m1:
        print(m2)
    else:
        print(m1)


N = int(input())
inputs = [int(input()) for _ in range(N)]

for i in range(N):
    sorted_inputs = sorted(inputs, reverse=True)
    if sorted_inputs[0] == inputs[i]:
        print(sorted_inputs[1])
    else:
        print(sorted_inputs[0])

N = int(input())
inputs = [int(input()) for _ in range(N)]

sorted_inputs = sorted(inputs, reverse=True)
for i in range(N):
    if sorted_inputs[0] == inputs[i]:
        print(sorted_inputs[1])
    else:
        print(sorted_inputs[0])


n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
    b = a[:]
    del b[i]
    print(max(b))

n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)

for A in a:
    if A == b[n - 1]:
        print(b[n - 2])
    else:
        print(b[n - 1])


import copy

def main():
    n = int(input())
    a = []
    for _ in range(n):
        a.append(int(input()))
    for i in range(len(a)):
        b = copy.deepcopy(a)
        b.pop(i)
        print(max(b))

if __name__ == "__main__":
    main()

def main():
    n = int(input())
    a = []
    for _ in range(n):
        a.append(int(input()))
    b = sorted(a)
    for i in range(len(a)):
        if a[i] == b[-1]:
            print(b[-2])
        else:
            print(b[-1])

if __name__ == "__main__":
    main()


N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
    A_num = A.pop(i)
    print(max(A))
    A.insert(i, A_num)

n = int(input())
a = [int(input()) for _ in range(n)]
b = sorted(a)[::-1]
mx = b[0]
mx2 = b[1]

for i in a:
    if i == mx:
        print(mx2)
    else:
        print(mx)


import copy

n = int(input())

a = [0] * n

for i in range(n):
    a[i] = int(input())

# a_s = set(a)

for i in range(n):
    tmp = copy.deepcopy(a)
    # tmp.discard(a[i])
    del tmp[i]
    print(max(tmp))

import copy

n = int(input())

a = [0] * n

for i in range(n):
    a[i] = int(input())

a_sort = sorted(a, reverse=True)

for i in range(n):
    if a[i] == a_sort[0]:
        print(a_sort[1])
    else:
        print(a_sort[0])


N = int(input())
A = list(int(input()) for _ in range(N))

A_sort = sorted(A)

for i in range(N):
    v = A[i]
    if v < max(A):
        print(max(A))
    else:
        print(A_sort[-2])

N = int(input())
A = list(int(input()) for _ in range(N))
m = max(A)

A_sorted = sorted(A)

for i in range(N):
    v = A[i]
    if v < m:
        print(m)
    else:
        print(A_sorted[-2])


N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    max = 0
    for j in range(N):
        if i != j and A[j] > max:
            max = A[j]
    print(max)

N = int(input())
A = [int(input()) for i in range(N)]

No1 = 0
No2 = 0
for i in range(N):
    if A[i] > No1:
        No2 = No1
        No1 = A[i]
    elif A[i] > No2:
        No2 = A[i]

for i in range(N):
    if A[i] == No1:
        print(No2)
    else:
        print(No1)


N = int(input())
A_LIST = []

for _ in range(N):
    A = int(input())
    A_LIST.append(A)

for i in range(N):
    temp = A_LIST[i]
    A_LIST[i] = 0
    print(max(A_LIST))
    A_LIST[i] = temp

N = int(input())
A_LIST = []

for _ in range(N):
    A = int(input())
    A_LIST.append(A)

sorted_A_LIST = sorted(A_LIST)
largest = sorted_A_LIST[-1]
second_largest = sorted_A_LIST[-2]

for i in range(N):
    if A_LIST[i] < largest:
        print(largest)
    else:
        print(second_largest)


N = int(input())
A = [int(input()) for i in range(N)]

for j in range(N):
    p = A.pop(j)
    print(max(A))
    A.insert(j, p)

N = int(input())
A = [int(input()) for i in range(N)]

max1 = [A.index(max(A)), max(A)]
p = A.pop(A.index(max(A)))
max2 = max(A)
ans = [max2 if j == max1[0] else max1[1] for j in range(N)]
for k in range(N):
    print(ans[k])


n = int(input())
nums = [None] * n

for i in range(n):
    nums[i] = int(input())
sorted_nums = sorted(nums)

for i in range(n):
    if sorted_nums.index(nums[i]) == n - 1:
        max_val = sorted_nums[n - 2]
    else:
        max_val = sorted_nums[n - 1]
    print(max_val)

n = int(input())
nums = [None] * n

for i in range(n):
    nums[i] = int(input())
sorted_nums = sorted(nums)

for i in range(n):
    max_val = sorted_nums[n - 1]
    if nums[i] == max_val:
        max_val = sorted_nums[n - 2]
    print(max_val)


n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
    temp = a[i]
    a[i] = 0
    print(max(a))
    a[i] = temp

n = int(input())
a = [int(input()) for i in range(n)]

aa = sorted(a)
first = aa[-1]
second = aa[-2]

for i in range(n):
    if a[i] != first:
        print(first)
    else:
        print(second)


n = int(input())
m = 0
a = []
for _ in range(n):
    _a = int(input())
    m = max(m, _a)
    a.append(_a)

for i in range(n):
    if a[i] == m:
        t = a[:]
        t.pop(i)
        print(max(t))
    else:
        print(m)

n = int(input())
a = [int(input()) for _ in range(n)]

t = sorted(a, reverse=True)

for i in range(n):
    if a[i] == t[0]:
        print(t[1])
    else:
        print(t[0])


n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n):
    ac = a.copy()
    del ac[i]
    print(max(ac))

n = int(input())
a = [int(input()) for _ in range(n)]
s, f = sorted(a)[-2:]

for ai in a:
    print(f if ai != f else s)


N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))
tmp = 0
idx = 0
while idx < N:
    tmp, a[idx] = a[idx], tmp
    print(max(a))
    tmp, a[idx] = a[idx], tmp
    idx += 1

N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))
a_sorted = sorted(a)
max_a = a_sorted.pop()
second_a = a_sorted.pop()
if max_a == second_a:
    for _ in range(N):
        print(max_a)
else:
    idx = 0
    while idx < N:
        if a[idx] == max_a:
            print(second_a)
        else:
            print(max_a)
        idx += 1


n = int(input())
semi_max = 0
aa = []
for i in range(n):
    a = int(input())
    if i > 0:
        if a >= semi_max and a < max(aa):
            semi_max = a
        elif a == max(aa):
            semi_max = max(aa)
    aa.append(a)
    # print(semi_max)
for each in aa:
    print(max(aa) if each <= semi_max else semi_max)

n = int(input())
aa = [int(input()) for _ in range(n)]
aho = sorted(aa)
for a in aa:
    print(aho[-1] if a < aho[-1] else aho[-2])


from heapq import heappush, heappop

N = int(input())
A = [int(input()) for i in range(N)]
hq = []
for i in range(N):
    heappush(hq, -A[i])
max1 = -heappop(hq)
while True:
    max2 = -heappop(hq)
    if max2 != max1:
        break
ans = [0] * N
for i in range(N):
    if A[i] == max1:
        ans[i] = max2
    else:
        ans[i] = max1
print(*ans, sep="\\n")

from heapq import heappush, heappop

N = int(input())
A = [int(input()) for i in range(N)]
hq = []
for i in range(N):
    heappush(hq, -A[i])
max1 = -heappop(hq)
max2 = -heappop(hq)
ans = [0] * N
for i in range(N):
    if A[i] == max1:
        ans[i] = max2
    else:
        ans[i] = max1
print(*ans, sep="\\n")


n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

for _ in range(n):
    val = a.pop(0)
    print(max(a))
    a.append(val)

n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

desc = sorted(list(set(a)), reverse=True)
max = desc[0]
large_2 = desc[1] if len(desc) > 1 else 0

if a.count(max) == 1:
    for val in a:
        if val == max:
            print(large_2)
        else:
            print(max)
else:
    for _ in range(n):
        print(max)


A = [int(input()) for i in range(int(input()))]
max_A = max(A)
for i in A:
    if i == max_A:
        print(sorted(A)[-2])
    else:
        print(max_A)

A = [int(input()) for i in range(int(input()))]
first = max(A)
second = sorted(A)[-2]
for i in A:
    if i == first:
        print(second)
    else:
        print(first)


n = int(input())
a = [int(input()) for i in range(n)]
maxi = max(a)
for i in range(n):
    if a[i] != maxi:
        print(maxi)
    else:
        b = a.pop(a[i])
        print(max(a))

n = int(input())
a = [int(input()) for i in range(n)]
maxi = max(a)
s = sorted(a, reverse=True)

for i in range(n):
    if a[i] != maxi:
        print(maxi)
    else:
        print(s[1])

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02971/Python/s556962228.py", line 8, in <module>
    b = a.pop(a[i])
IndexError: pop index out of range


N = int(input())

A = []

[A.append(int(input())) for x in range(N)]

max_num = 0

for i in range(N):
    for j in range(N):
        if j != i and max_num < A[j]:
            max_num = A[j]
    print(max_num)
    max_num = 0

N = int(input())

A = []

[A.append(int(input())) for x in range(N)]

max_num = max(A)
num = A.index(max(A))
A[num] = 0

st_max_num = max(A)

for i in range(num):
    print(max_num)
print(st_max_num)

for i in range(num + 1, N):
    print(max_num)


n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

for i in range(n):
    _a = a.copy()
    _a.pop(i)
    print(max(_a))

n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

m = max(a)
idxs = [i for i, v in enumerate(a) if v == m]

if len(idxs) > 1:
    for i in range(n):
        print(m)

if len(idxs) == 1:
    idx = idxs[0]
    for i in range(n):
        if idx == i:
            _a = a.copy()
            _a.pop(i)
            print(max(_a))
        else:
            print(m)


import copy

N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

for i in range(N):
    a = copy.deepcopy(A)
    a.remove(A[i])
    print(max(a))

import copy

N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

result = max(A)
ind = A.index(result)

for i in range(N):
    if i == ind:
        a = copy.deepcopy(A)
        a.remove(result)
        print(max(a))
    else:
        print(result)


def solve():
    n = int(input())
    a = list(int(input()) for _ in range(n))
    for idx in range(n):
        d = max([v for i, v in enumerate(a) if i != idx])
        print(d)

if __name__ == "__main__":
    solve()

def solve():
    n = int(input())
    a = list(int(input()) for _ in range(n))
    ranking = sorted(a)[::-1]
    first = ranking[0]
    second = ranking[1]
    first_idx = a.index(first)
    for idx in range(n):
        if idx == first_idx:
            print(second)
        else:
            print(first)

if __name__ == "__main__":
    solve()


n = int(input())
a_list = [int(input()) for i in range(n)]
for i in range(n):
    dum = a_list[i]
    a_list[i] = 0
    print(max(a_list))
    a_list[i] = dum

n = int(input())
a_list = [int(input()) for i in range(n)]
a_list_sort = sorted(a_list)
a_list_max1 = max(a_list)
a_list_max2 = a_list_sort[-2]
for i in range(n):
    if a_list_max1 == a_list[i]:
        print(a_list_max2)
    else:
        print(a_list_max1)


n = int(input())
ind = []
m = 0
k = 0
for i in range(n):
    a = int(input())
    if m == a:
        ind.append(i)
        k = a
    elif m < a:
        k, m = m, a
        ind = [i]
    elif k < a:
        k = a
print("\\n".join(map(str, [k if i in ind else m for i in range(n)])))

n = int(input())
ind = []
m = 0
k = 0
for i in range(n):
    a = int(input())
    if m == a:
        ind = -1
    elif m < a:
        k, m = m, a
        ind = i
    elif k < a:
        k = a
if ind == -1:
    print("\\n".join(map(str, [m for i in range(n)])))
else:
    print("\\n".join(map(str, [k if i == ind else m for i in range(n)])))


N = int(input())
A = [int(input()) for i in range(N)]
# maxA = max(A)
for x in range(len(A)):
    a_tmp = A[x]
    A[x] = 0
    print(max(A))
    A[x] = a_tmp

N = int(input())
A = [int(input()) for i in range(N)]
maxA = max(A)
copy_A = A[:]
copy_A.remove(maxA)
secondA = max(copy_A)
for x in A:
    if x == maxA:
        print(secondA)
    else:
        print(maxA)


import numpy as np

S = input()
N = int(S)

A = np.zeros([N])
A_temp = np.zeros([N])

for i in range(0, N, 1):
    A[i] = int(input())

max = 0

index_max = np.argmax(A)

for i in range(0, N, 1):
    A_temp = np.copy(A)
    if index_max != i:
        print(int(A_temp[index_max]))
    else:
        A_temp[i] = 0
        print(int(np.amax(A_temp)))

import numpy as np

S = input()
N = int(S)

A = np.zeros([N])
A_temp = np.zeros([N])

for i in range(0, N, 1):
    A[i] = int(input())

max = 0

index_max = np.argmax(A)
A_temp = np.copy(A)
A_temp[index_max] = 0
index_max_second = np.argmax(A_temp)

result = np.full(N, A[index_max])
result[index_max] = A[index_max_second]

for i in range(0, N, 1):
    print(int(result[i]))


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from copy import copy

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    for i in range(N):
        tmp = copy(A)
        tmp[i] = 0
        print(max(tmp))

if __name__ == "__main__":
    main()

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from copy import copy

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A_max = copy(A)
    A_max.sort(reverse=True)

    for a in A:
        if a == A_max[0]:
            print(A_max[1])
        else:
            print(A_max[0])

if __name__ == "__main__":
    main()


import copy

n = int(input())
A = [int(input()) for _ in range(n)]

for i in range(n):
    tmp_list = copy.deepcopy(A)
    tmp_list.pop(i)
    print(max(tmp_list))

import copy

n = int(input())
A = [int(input()) for _ in range(n)]

A_sorted = sorted(A, reverse=True)

for i in range(n):
    if A[i] == A_sorted[0]:
        print(A_sorted[1])
    else:
        print(A_sorted[0])


# coding: utf-8
N = int(input())
A = [int(input()) for _ in range(N)]
for i in range(N):
    B = A[:]
    B.pop(i)
    print(max(B))

# coding: utf-8
N = int(input())
A = []  # value
for i in range(N):
    A.append(int(input()))
B = A[:]
B.sort()
one = B[-1]
two = B[-2]
for i in range(N):
    if A[i] == one:
        print(two)
    else:
        print(one)


N = int(input())
A = [int(input()) for _ in range(N)]
for i in range(N):
    tmp = A.copy()
    tmp.pop(i)
    tmp.sort()
    print(tmp[-1])

N = int(input())
A = [int(input()) for _ in range(N)]
As = sorted(A)
for i in range(N):
    if A[i] == As[-1]:
        print(As[-2])
    else:
        print(As[-1])


n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
    ret = a[:]
    ret.pop(i)
    print(max(ret))

n = int(input())
a = [int(input()) for i in range(n)]

a_s = sorted(a, reverse=True)
for i in range(n):
    if a[i] == a_s[0]:
        print(a_s[1])
    else:
        print(a_s[0])


N = int(input())
A = [int(input()) for i in range(N)]
B = []
for i in range(N):
    temp = A[i]
    A[i] = -999
    print(max(A))
    A[i] = temp

N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A)

for i in range(N):
    if B[-1] == A[i]:
        print(B[-2])
    else:
        print(B[-1])


def test():
    n = int(input())
    a = [int(input()) for i in range(n)]
    s = 0
    for i in range(n):
        s = a[i]
        a[i] = 0
        print(max(a))
        a[i] = s

if __name__ == "__main__":
    test()

def test():
    n = int(input())
    s = 0
    t = 0
    index_ = 0
    for i in range(n):
        a = int(input())
        if s < a:
            index_ = i
            s = a
        elif t < a and a <= s:
            t = a
    for i in range(n):
        if index_ == i:
            print(t)
        else:
            print(s)

if __name__ == "__main__":
    test()


import copy

n = int(input())
lst = []
for _ in range(n):
    lst.append(int(input()))
clean_lst = copy.deepcopy(lst)

for i in clean_lst:
    lst.remove(i)
    print(max(lst))
    lst.append(i)

import copy

n = int(input())
lst = []
for _ in range(n):
    lst.append(int(input()))
clean_lst = copy.deepcopy(lst)

m1 = max(lst)
lst.remove(m1)
m2 = max(lst)

for i in clean_lst:
    print(m1 if i != m1 else m2)


import itertools

n = int(input())
a = [int(input()) for i in range(n)]

max_list = [0] + list(itertools.accumulate(a, func=max))
max_list_r = [0, *itertools.accumulate(reversed(a), func=max)][::-1]
# print(max_list)
# print(max_list_r)
for i in range(n):
    print(max(max_list[i], max_list_r[i + 1]))

import itertools

n = int(input())
a = [int(input()) for i in range(n)]

max_list = [0] + list(itertools.accumulate(a, func=max))
max_list_r = ([0] + list(itertools.accumulate(reversed(a), func=max)))[::-1]
for i in range(n):
    print(max(max_list[i], max_list_r[i + 1]))


import numpy as np

N = int(input())
A = np.array([input() for i in range(N)])

B = np.array([])
for i in range(N):
    print(max(np.delete(A.copy(), i)))

N = int(input())
A = [int(input()) for i in range(N)]

a = max(A)
b = sorted(A)[-2]
for i in A:
    print(b if i == a else a)


# -*- coding: utf-8 -*-
import copy

# input
N = int(input())
A = list()
for _ in range(N):
    A.append(int(input()))

# solve & output
for i in range(N):
    tmp = copy.copy(A)
    del tmp[i]
    print(max(tmp))

# -*- coding: utf-8 -*-
import copy

# input
N = int(input())
A = list()
for _ in range(N):
    A.append(int(input()))

# solve & output
ans = copy.copy(A)
ans.sort()
m = ans[-1]
for i in range(N):
    if A[i] != m:
        print(m)
    else:
        print(ans[N - 2])


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    max_value = max(A)
    max_index = A.index(max_value)

    for i in range(N):
        if i != max_index:
            print(max_value)
        else:
            if i == 0:
                print(max(A[1:]))
            elif i == N:
                print(max(A[:N]))
            else:
                print(max(max(A[:i]), max(A[i + 1 :])))

    return

if __name__ == "__main__":
    main()

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    max_value = max(A)
    max_index = A.index(max_value)

    for i in range(N):
        if i != max_index:
            print(max_value)
        else:
            if i == 0:
                print(max(A[1:]))
            elif i == N - 1:
                print(max(A[: N - 1]))
            else:
                print(max(max(A[:i]), max(A[i + 1 :])))

    return

if __name__ == "__main__":
    main()


N = int(input())
nums = [int(input()) for _ in range(N)]

all_max = max(nums)
for num in range(N):
    if nums[num] == all_max:
        new_nums = list(nums)
        new_nums.pop(num)
        print(max(new_nums))
    else:
        print(all_max)

N = int(input())
nums = [int(input()) for _ in range(N)]

all_max = max(nums)

new_nums = list(nums)
new_nums.remove(all_max)

second_max = max(new_nums)  # max関数はfor文の中にいれずに、先に2番目の最大値をもとめておく

for num in range(N):
    if nums[num] == all_max:
        print(second_max)
    else:
        print(all_max)


def make_divisors(n: int) -> list:
    divisors = []

    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return divisors

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

ans = []
for i in reversed(range(N)):
    if A[i] == 1:
        ans.append(i + 1)
        divisors = make_divisors(i + 1)
        for j in divisors:
            A[j + 1] = (A[j + 1] + 1) % 2

if A.count(1) != 0:
    print(len(ans))
    for i in reversed(range(len(ans))):
        print(ans[i])
else:
    print(-1)

N = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)

ans = []
for i in reversed(range(1, N + 1)):
    if sum(A[i::i]) % 2 != A[i]:
        A[i] = (A[i] + 1) % 2
    if A[i] == 1:
        ans.append(i)

print(len(ans))
if len(ans) > 0:
    print(*ans)


#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

# 最初が0から始まる場合
b_list = [0] * N
b_list[-1] = a_list[-1]

for i in range(N):
    # 大きい方から決めていく
    idx = N - (i + 1)
    total = 0
    for j in b_list[:: idx + 1]:
        # idx + 1の倍数のボールの個数を数える
        total += b_list[j]

    if total % (idx + 1) != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i + 1) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list)
print(ans)
print(" ".join(idx_list))

#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

# 最初が0から始まる場合
a_list = [0] + a_list
b_list = [0] * (N + 1)
# インデックスがずれるのがややこしいので、
# b_list[0]は欠番として1始まりで考えていく

for i in range(N):
    # 大きい方から決めていく
    idx = N - i
    total = sum(b_list[idx : N + 1 : idx])

    if total % 2 != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list[1:])
print(ans)
if ans != 0:
    print(" ".join(idx_list))


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

box = [0] * N
v = N // 2  # 後半部の最初のindex

for i in range(v, N):
    if ai[i] == 0:
        box[i] = 0
    else:
        box[i] = 1

for i in range(v - 1, -1, -1):
    s = [ai[x] == 1 for x in range(i + 1, N) if (x + 1) % (i + 1) == 0]
    cnt = s.count(True)
    if cnt & 1 == 1:
        box[i] = 0 if ai[i] & 1 == 1 else 1
    else:
        box[i] = 0 if ai[i] & 1 == 0 else 1

print(box.count(1))
for x in box:
    if x == 1:
        print(x)

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

box = [0] * N
v = N // 2  # 後半部の最初のindex

for i in range(v, N):
    if ai[i] == 0:
        box[i] = 0
    else:
        box[i] = 1

for i in range(v - 1, -1, -1):
    value = i + 1
    sum = 0
    for j in range(value * 2 - 1, N, value):
        sum += box[j]
    if sum & 1 == 1:
        box[i] = 0 if ai[i] & 1 == 1 else 1
    else:
        box[i] = 0 if ai[i] & 1 == 0 else 1
print(box.count(1))
for i in range(N):
    if box[i] == 1:
        print(i + 1)


n = int(input())
a = list(map(int, input().split()))
a = [None] + a

ans = set()
cnt = [0] * (n + 1)

for i in range(n, 0, -1):
    if cnt[i] % 2 != a[i] % 2:
        ans.add(i)

        st = set()
        j = 1
        while j * j <= i:
            if i % j == 0:
                st.add(j)
                st.add(i // j)
            j += 1
        for d in st:
            cnt[d] += 1

print(len(ans))
print(*ans)

import sys

input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
a = [None] + a
a = tuple(a)

ans = set()
cnt = [0] * (n + 1)

for i in range(n, 0, -1):
    if cnt[i] % 2 != a[i] % 2:
        ans.add(i)

        st = set()
        j = 1
        while j * j <= i:
            if i % j == 0:
                st.add(j)
                st.add(i // j)
            j += 1
        for d in st:
            cnt[d] += 1

print(len(ans))
print(*ans)


from sys import stdin

N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

ans = []
for k in reversed(range(1, N + 1)):
    if k == 1:
        if len(ans) % 2 != a[k - 1]:
            ans.append(k)
        continue
    t = N // k
    cnt = 0
    for i in range(1, t + 1):
        if i * k in ans:
            cnt += 1
    if cnt % 2 != a[k - 1]:
        ans.append(k)

x = len(ans)
print(x)
if x >= 0:
    print(*ans)

from sys import stdin

N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

ans = []
for k in reversed(range(1, N + 1)):
    if a[k - 1] == 1:
        ans.append(k)
        tmp = 1
        while tmp * tmp <= k:
            if k % tmp == 0:
                a[tmp - 1] ^= 1
                if tmp != k // tmp:
                    a[k // tmp - 1] ^= 1
            tmp += 1

x = len(ans)
print(x)
if x >= 0:
    print(*ans)


N = int(input())
A = [int(input()) for i in range(N)]

ans = 1
X = [-1]
for i in range(N):
    for j in range(ans):
        if X[j] < A[i]:
            X[j] = A[i]
            break
        elif j == ans - 1:
            X.append(A[i])
            ans += 1

print(ans)

import bisect

N = int(input())
A = [int(input()) for i in range(N)]

ans = 1
X = [-A[0]]
for i in range(1, N):
    if -X[ans - 1] >= A[i]:
        X.append(-A[i])
        ans += 1
    else:
        pos = bisect.bisect_right(X, -A[i])
        X[pos] = -A[i]

print(ans)


import bisect
from sys import stdin

def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    array = []
    for A in As:
        idx = bisect.bisect_left(array, A)
        if idx == 0:
            array = [A] + array
        else:
            array[idx - 1] = A
    print(len(array))

if __name__ == "__main__":
    main()

import bisect
from collections import deque
from sys import stdin

def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    dq = deque([])
    for A in As:
        idx = bisect.bisect_left(dq, A)
        if idx == 0:
            dq.appendleft(A)
        else:
            dq[idx - 1] = A
    print(len(dq))

if __name__ == "__main__":
    main()


# -*- coding: utf-8 -*-

N = int(input())

lasts = []

before = [int(input())]
lasts.append(before)

for _ in range(N - 1):
    current = int(input())
    if before[0] < current:
        before[0] = current
        continue
    try:
        low = next(x for x in lasts if x[0] < current)
        low[0] = current
    except StopIteration:
        lasts.append([current])

print(len(lasts))

# -*- coding: utf-8 -*-
from bisect import bisect_right

N = int(input())

columns = []

for _ in range(N):
    current = -int(input())
    index = bisect_right(columns, current)
    if len(columns) <= index:
        columns.append(current)
    else:
        columns[index] = current

print(len(columns))


from bisect import bisect_left

N = int(input())
A = [int(input()) for _ in range(N)]

t = [A[0]]
for a in A[1:]:
    i = bisect_left(t, a) - 1
    if i == -1:
        t = [a] + t
    else:
        t[i] = a
        t.sort()
print(len(t))

N = int(input())
A = [int(input()) for _ in range(N)]

t = [A[0]]
for a in A[1:]:
    if t[-1] >= a:
        t.append(a)
        continue
    ok = len(t) - 1
    ng = -1
    while ok - ng > 1:
        m = (ok + ng) // 2
        if t[m] < a:
            ok = m
        else:
            ng = m
    t[ok] = a
print(len(t))


import sys

n = int(input())
aaa = list(map(int, sys.stdin.readlines()))

dp = [-1]
for a in aaa:
    for i, m in enumerate(dp):
        if m < a:
            dp[i] = a
            break
    else:
        dp.append(a)
print(len(dp))

import sys
from bisect import bisect

n = int(input())
aaa = list(map(int, sys.stdin.readlines()))

dp = [1]
for a in aaa:
    a *= -1
    i = bisect(dp, a)
    if i < len(dp):
        dp[i] = a
    else:
        dp.append(a)
print(len(dp))


N = int(input())
A = [int(input()) for _ in range(N)]

c = 0
colored = [False for _ in range(N)]
Ls = []
for a in A:

    k = -1
    for i, l in enumerate(Ls):
        if l < a and a > k:
            ind = i
            k = a
    if k != -1:
        Ls[ind] = a
    else:
        Ls.append(a)

print(len(Ls))

from bisect import bisect_right, bisect_left

N = int(input())
A = [int(input()) for _ in range(N)]

dp = [1] * N

for a in A:
    ia = bisect_right(dp, -a)
    if dp[ia] == 1:
        dp[ia] = -a
    else:
        ib = bisect_left(dp, -a + 1)
        dp[ib] = -a
    # print(dp)

ans = 0
for i in range(N):
    if dp[i] != 1:
        ans += 1
print(ans)


import bisect

N = int(input())
A = [int(input()) for i in range(N)]

colors = [A[0]]
for i in range(1, N):
    index = bisect.bisect_left(colors, A[i])
    if index == 0:
        colors.insert(0, A[i])
    else:
        colors[index - 1] = A[i]
print(len(colors))

from collections import deque
import bisect

N = int(input())
A = [int(input()) for i in range(N)]

colors = deque()
for i in range(N):
    index = bisect.bisect_left(colors, A[i])
    if index == 0:
        colors.appendleft(A[i])
    else:
        colors[index - 1] = A[i]
print(len(colors))


from bisect import bisect_right

n = int(input())
a = [int(input()) for _ in range(n)]

c = []
c.append(a[0])
for ai in a[1:]:
    ci = bisect_right(c, ai)
    if ci == 0 or c[ci - 1] == ai:
        c.append(ai)
        c.sort()
    else:
        c[ci - 1] = ai
        c.sort()

print(len(c))

from bisect import bisect_left

n = int(input())
a = [int(input()) for _ in range(n)]

c = [0] * n
end = n

for ai in a:
    ci = bisect_left(c, ai, end, n)
    c[ci - 1] = ai
    if ci <= end:
        end -= 1
print(n - end)


from bisect import bisect

n = int(input())
ma = [-int(input()) for _ in range(n)]

ans = [ma[0]]
for ai in ma[1:]:
    tmp = bisect(ans, ai)
    if tmp == len(ans):
        ans.append(ai)
    elif tmp < len(ans):
        ans[tmp] = ai
    print(ans)
print(len(ans))

from bisect import bisect

n = int(input())
ma = [-int(input()) for _ in range(n)]

ans = [ma[0]]
for ai in ma[1:]:
    tmp = bisect(ans, ai)
    if tmp == len(ans):
        ans.append(ai)
    elif tmp < len(ans):
        ans[tmp] = ai
print(len(ans))


import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

x = []

for i, a in enumerate(A):
    if i == 0:
        x.append(a)
    else:
        r = bisect.bisect_left(x, a)
        if r == 0:
            x.insert(0, a)
        else:
            x[r - 1] = a

print(len(x))

import bisect
import collections

N = int(input())
A = [int(input()) for _ in range(N)]

x = collections.deque()

for i, a in enumerate(A):
    if i == 0:
        x.append(a)
    else:
        r = bisect.bisect_left(x, a)
        if r == 0:
            x.appendleft(a)
        else:
            x[r - 1] = a

print(len(x))


i = input().spli(" ")
people = int(i[0])
train_fee = int(i[1])
taxi_fee = int(i[2])

train_sum = people * train_fee
if train_sum > taxi_fee:
    print(train_sum)
else:
    print(taxi_fee)

i = input().split(" ")
people = int(i[0])
train_fee = int(i[1])
taxi_fee = int(i[2])

train_sum = people * train_fee
if train_sum > taxi_fee:
    print(taxi_fee)
else:
    print(train_sum)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02981/Python/s062191758.py", line 1, in <module>
    i = input().spli(" ")
AttributeError: 'str' object has no attribute 'spli'. Did you mean: 'split'?


# -*- coding: utf-8 -*-
import itertools
import math

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

X = [[0 for x in range(D)] for y in range(N)]

for n in range(N):
    X[n] = list(map(int, input().split()))

ans = 0
for target in itertools.combinations(X, 2):
    res = sum([(y - z) ** 2 for y, z in zip(target[0], target[1])])
    res = math.sqrt(res)
    if res.is_integer():
        ans += 1

print(ans)

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

print(min(N * A, B))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02981/Python/s901912140.py", line 5, in <module>
    N, D = map(int, input().split())
ValueError: too many values to unpack (expected 2)


N, A, B = map(int, input().split())
ans = []
for i in range(1, N):
    ans.append(A * i + B / N * (N - i))
print(min(ans))

N, A, B = map(int, input().split())
if A * N < B:
    print(A * N)
else:
    print(B)


N = int(input())
A = int(input())
B = int(input())
c = N * A
if c < B:
    print(c)
else:
    print(B)

n, a, b = map(int, input().split())
c = n * a
if c < b:
    print(c)
else:
    print(b)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02981/Python/s146594722.py", line 1, in <module>
    N = int(input())
ValueError: invalid literal for int() with base 10: '4 2 9'


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

total_price = A + (N * B)

print(total_price - max(total_price))

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

# N人*A円がB円より大きい場合
if N * A > B:
    print(B)
else:
    print(N * A)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02981/Python/s985942585.py", line 5, in <module>
    print(total_price - max(total_price))
TypeError: 'int' object is not iterable


import numpy as np

N, D = list(map(int, input().split()))
X = []
for i in range(D):
    x_i = [int(i) for i in input().split()]
    X.append(i)
X = np.array(X)

ans = 0
for i in range(D):
    for j in range(i + 1, D):
        if np.sqrt(np.sum(X[i] - X[j]) ** 2).is_integer():
            ans += 1
print(ans)

import numpy as np

N, D = list(map(int, input().split()))
X = []
for i in range(N):
    x_i = [int(i) for i in input().split()]
    X.append(x_i)
X = np.array(X)

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        if np.sqrt(np.sum((X[i] - X[j]) ** 2)).is_integer():
            ans += 1
print(ans)


l, r = map(int, input().split())
a = []
if r - l >= 2019:
    print(0)
else:
    for i in range(r - l + 1):
        a.append((l + i) % 2019)
# print(a)
a.sort()
print(a[0] * a[1])

l, r = map(int, input().split())
a = []

data = 2019

if r - l + 1 >= 2019:
    print(0)
    exit()

else:
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            data = min(data, i * j % 2019)

print(data)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def main():
    L, R = map(int, input().split())
    result = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            result.append(i * j % 2019)
    print(min(result))

if __name__ == "__main__":
    main()

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def main():
    L, R = map(int, input().split())
    mod = 2019

    min_mod = float("inf")

    for i in range(L, min(R, L + mod)):
        for j in range(i + 1, min(R + 1, i + 1 + mod)):
            curr_mod = i * j % mod
            min_mod = min(min_mod, curr_mod)
            if min_mod == 0:
                break

    print(min_mod)

if __name__ == "__main__":
    main()


L, R = [int(i) for i in input().split()]
R = min(R, L + 4038)
diff = R - L
ans = 2018
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        x = i * j % 2019
        ans = min(ans, x)
print(ans)

L, R = [int(i) for i in input().split()]
R = min(R, L + 4038)
ans = 2018
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        x = (i * j) % 2019
        if x == 0:
            ans = 0
            break
        ans = min(ans, x)
print(ans)


l, r = map(int, input().split())
x = []
for i in range(l, r):
    for j in range(i + 1, r + 1):
        mod = i * j % 2019
        x.append(mod)
print(min(x))

l, r = map(int, input().split())
x = []
for i in range(l, r):
    for j in range(i + 1, r + 1):
        mod = i * j % 2019
        x.append(mod)
        if mod == 0:
            print(0)
            exit()
print(min(x))


L, R = map(int, input().split())
a = 0
b = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        a = i * j % 2019
        if a <= b:
            b = a

print(b)

L, R = map(int, input().split())
a = 0
b = 2019
if R - L >= 2018:
    b = 0
else:
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            a = i * j % 2019
            if a <= b:
                b = a

print(b)


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

num_list = list(range(L, R + 1))

num_list = [i % 2019 for i in num_list]
num_list.sort()

print((num_list[0] * num_list[1]) % 2019)

L, R = map(int, input().split())
if (L <= 673 <= R and R - L >= 3) or (R - L >= 673):
    print(0)
else:
    mods = []
    mods_append = mods.append
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % 2019
            mods_append(m)
            if m == 2:
                break

    print(min(mods))


def main():
    l, r = map(int, input().split())
    res = 1 << 30
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            res = min(res, (i * j) % 2019)
            if res == 0:
                break
    print(res)

if __name__ == "__main__":
    main()

def main():
    l, r = map(int, input().split())
    res = 1 << 30
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            res = min(res, (i * j) % 2019)
            if res == 0:
                print(res)
                return
    print(res)

if __name__ == "__main__":
    main()


import numpy as np

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

if L - R >= 2019:
    ans = 0
else:
    A = np.arange(L, R + 1)
    A = np.sort(A % 2019)
    ans = A[0] * A[1]

print(ans % 2019)

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

if R - L >= 2019:
    ans = 0
else:
    ans = 2019
    for i in range(L, R):
        x = i % 2019
        for j in range(i + 1, R + 1):
            a = x * j
            ans = min(a % 2019, ans)

print(ans)


L, R = map(int, input().split())
ans = 2018
for i in range(L, R):
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % 2019)
        if ans == 0:
            break
print(ans)

L, R = map(int, input().split())
ans = 2018
for i in range(L, R):
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % 2019)
        if ans == 0:
            print(ans)
            exit()
print(ans)


L, R = map(int, input().split())
min_mod = 10**9
for i in range(L, R):
    for j in range(i + 1, min(L + 2019, R + 1)):
        min_mod = min(min_mod, (i * j) % 2019)
print(min_mod)

L, R = map(int, input().split())
min_mod = 10**9
for i in range(L, min(L + 2019, R + 1)):
    for j in range(i + 1, min(L + 2019, R + 1)):
        min_mod = min(min_mod, (i * j) % 2019)
print(min_mod)


L, R = map(int, input().split())
MOD = 2019
L %= MOD
R %= MOD
print(min(i * j % 2019 for i in range(L, R) for j in range(i + 1, R + 1)))

L, R = map(int, input().split())
MOD = 2019
ans = float("inf")
for i in range(L, R):
    for j in range(i + 1, R + 1):
        ans = min(ans, i * j % MOD)
        if ans == 0:
            print(0)
            exit()
print(ans)


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

diff = R - L
if diff >= 2019:
    print("0")
else:
    ans = min([i * j % 2019 for j in range(L + 1, R) for i in range(L, R)])
    print(ans)

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

diff = R - L
if diff >= 2019:
    print("0")
else:
    ans = min([i * j % 2019 for j in range(L + 1, R + 1) for i in range(L, R)])
    print(ans)


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

res = float("inf")
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        res = min(res, (i * j) % 2019)
print(res)

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

if R - L >= 2019:
    res = 0
else:
    res = float("inf")
    L = L % 2019
    R = R % 2019
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            res = min(res, (i * j) % 2019)
print(res)


def make_list(L, R):
    mod_list = list()

    if R - L <= 2019:
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                mod_list.append((i * j) % 2019)
    else:
        for i in range(L, R):
            for j in range(i + 1, i + 2021):
                mod_list.append((i * j) % 2019)

    return mod_list

def main():
    L, R = map(int, input().split())

    mod_list = make_list(L, R)

    print(min(mod_list))

    return

if __name__ == "__main__":
    main()

def make_list(L, R):
    mod_list = list()

    if R - L <= 2019:
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                mod_list.append((i * j) % 2019)
    else:
        for i in range(L, L + 2020):
            for j in range(i + 1, i + 2021):
                mod_list.append((i * j) % 2019)

    return mod_list

def main():
    L, R = map(int, input().split())

    mod_list = make_list(L, R)

    print(min(mod_list))

    return

if __name__ == "__main__":
    main()


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

R = min(R, L + 4038)

i = L
res = 2019
while i < R:
    j = i + 1
    while j <= R:
        res = min(res, i * j % 2019)
        j += 1
    i += 1

print(res)

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

ans = 2019

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


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

tmp = R - L + 1
if tmp >= 2019:
    print(0)
    exit()
else:
    start = L % 2019
    end = R % 2019
    candidate = []
    for i in range(start, end + 1):
        candidate.append(i % 2019)
    candidate.sort()
    ans = []
    for i in range(len(candidate)):
        for j in range(len(candidate)):
            if i == j:
                continue
            else:
                ans.append((candidate[i] * candidate[j]) % 2019)
    ans.sort()
    print(ans[0])

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

tmp = R - L + 1
if tmp >= 2019:
    print(0)
    exit()
else:
    start = L % 2019
    end = R % 2019
    candidate = []
    for i in range(start, end + 1):
        candidate.append(i % 2019)
    candidate.sort()
    ans = []
    for i in range(len(candidate)):
        if i == (len(candidate) - 1):
            continue
        for j in range(i + 1, len(candidate)):
            if i == j:
                continue
            else:
                ans.append((candidate[i] * candidate[j]) % 2019)
    ans.sort()
    print(ans[0])


from collections import deque

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

sum_even = sum(A[::2])
sum_odd = sum(A[1::2]) + A[0]
ANS = A[:]
A = deque(A)
minus = False
for _ in range(n - 1):
    A.rotate(-1)
    for i in range(n):
        if minus:
            ANS[i] -= A[i]
        else:
            ANS[i] += A[i]
    minus = not minus
ANS = deque(ANS)
ANS.rotate()
print(*ANS)

from collections import deque

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

B = [0] * n
B[0] = A[0]
B[1] = A[1]
for i in range(2, n):
    B[i] = B[i - 2] + A[i]

ANS = [0] * n
for i in range(n):
    ans = 0
    if i % 2 == 0:
        ans += B[-1] - B[-2]
    else:
        ans += B[-2] - B[-1]

    if i - 2 >= 0:
        ans -= B[i - 2] * 2

    if i - 1 >= 0:
        ans += B[i - 1] * 2

    ANS[i] = ans

print(*ANS)


n = int(input())
lis = list(map(int, input().split()))
a = n // 2
res = sum(lis)

def dams(i, a, lis):
    su = 0
    for j in range(a):
        b = (i + (2 * j + 1)) % len(lis)
        su += lis[b]
    return su

ans = []
for i in range(n):
    ans.append(res - 2 * dams(i, a, lis))
print(*ans)

import sys

input = sys.stdin.readline

n = int(input())
lis = list(map(int, input().split()))
res = sum(lis)
su = [0] * n

for i in range(n):
    if i < 2:
        su[i] = lis[i]
    else:
        su[i] = su[i - 2] + lis[i]

ans = []
ans_a = ans.append

for i in range(n):
    if i == 0:
        b = su[-2]
        ans_a(res - 2 * b)
    elif i == 1:
        b = su[-1] - su[i - 1]
        ans_a(res - 2 * b)
    elif i == n:
        b = su[-1] - lis[-1]
        ans_a(res - 2 * b)
    elif i % 2 == 0:
        b = su[-2] - su[i - 1] + su[i - 2]
        ans_a(res - 2 * b)
    else:
        b = su[-1] - su[i - 1] + su[i - 2]
        ans_a(res - 2 * b)
print(*ans)


n = int(input())
a = list(map(int, input().split()))
b = sum(a) / 2
p = int((n - 1) / 2)

x = []

for i in range(n):
    t = b
    for j in range(p):
        t -= a[(2 * j + i + 1) % n]
    x.append(t * 2)

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

n = int(input())
a = list(map(int, input().split()))
b = sum(a) / 2
p = int((n - 1) / 2)

x = []

t = b
for j in range(p):
    t -= a[2 * j + 1]
x.append(t * 2)

for i in range(n - 1):
    t = a[i] - x[i] / 2
    x.append(t * 2)

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


from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

S = sum(A)
ans = []
s = 0
for k in range(int((N - 1) / 2)):
    s += A[2 * k + 1] * 2
ans.append(S - s)
for k in range(N - 1):
    ans.insert(0, A[k] * 2 - ans[0])
ans.reverse()
print(*ans)

from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

S = sum(A)
ans = [0 for _ in range(N)]
s = 0
for k in range(int((N - 1) / 2)):
    s += A[2 * k + 1] * 2
ans[0] = S - s
for k in range(1, N):
    ans[k] = A[k - 1] * 2 - ans[k - 1]
print(*ans)


from sys import stdin, setrecursionlimit

def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    x_sum = sum(a) // 2
    x = [0] * n
    for i in range(n):
        tmp = x_sum
        idx = (i + 1) % n
        for _ in range((n - 1) // 2):
            tmp -= a[idx]
            idx += 2
            idx %= n
        x[i] = 2 * tmp
    print(*x)

if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

from sys import stdin, setrecursionlimit

def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    x_sum = sum(a) // 2
    x = [0] * n
    tmp = x_sum
    idx = 1
    for _ in range((n - 1) // 2):
        tmp -= a[idx]
        idx += 2
        idx %= n
    x[0] = 2 * tmp
    for i in range(n - 1):
        x[i + 1] = 2 * (a[i] - x[i] // 2)
    print(*x)

if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


import sys
import numpy as np

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

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

main()

import sys
import numpy as np

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

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

main()


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

N = int(input())
A = np.array(input().split(), dtype=int)

mat = lil_matrix((N, N))
for i in range(N):
    j = (i + 1) % N
    mat[i, i] = 1
    mat[i, j] = 1
mat = csr_matrix(mat)

ans = (spsolve(mat, A) * 2).astype(int)
print(*ans)

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

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

data = np.ones(2 * N, dtype=int)
col = np.arange(2 * N) // 2
row = np.zeros(2 * N, dtype=int)
row[0] = N - 1
row[1:] = col[:-1]

A = csr_matrix((data, (row, col)), shape=(N, N))

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


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

ans = [0 for _ in range(N)]

for i in range(N):
    sign = 1

    for a in A:
        ans[i] += sign * a
        sign *= -1

    t = A.pop(0)
    A.append(t)

print(*ans)

"""
ダム1: 2( a1 - a2 + a3 )
ダム2: 2( a2 - a3 + a1 )
ダム3: 2( a3 - a1 + a2 )
"""

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

ans = [0 for _ in range(N)]

sign = 1
for a in A:
    ans[0] += sign * a
    sign *= -1

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

    t = A.pop(0)
    A.append(t)

print(*ans)


n = int(input())
a = list(map(int, input().split()))
sum_rain = sum(a) // 2
a += a
ans_rain = []

for i in range(n):
    rest_rain = 0
    for j in range(i + 1, i + n, 2):
        rest_rain += a[j]
    ans_rain.append((sum_rain - rest_rain) * 2)

print(*ans_rain)

n = int(input())
a = list(map(int, input().split()))
sum_rain = sum(a) // 2

rest_rain = 0
for i in range(1, n, 2):
    rest_rain += a[i]
first_ans = (sum_rain - rest_rain) * 2

res = []

res.append(first_ans)
prev_ans = first_ans

for i in range(n - 1):
    ans = (a[i] - prev_ans // 2) * 2
    res.append(ans)
    prev_ans = ans

print(*res)


#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))
start_w = a_list[0] * 2

# 一番小さいものから決めていく？
for sw in range(start_w + 1):
    w_list = []
    if a_list[0] < sw // 2:
        continue
    w_list.append(sw)
    for i in range(1, N):
        w_list.append((a_list[i - 1] - w_list[i - 1] // 2) * 2)

    if a_list[-1] == (w_list[0] + w_list[-1]) // 2:
        break

ans = " ".join([str(w) for w in w_list])
print(ans)

#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

r_list = []
total = 0

for i in range(1, N, 2):
    total += a_list[i]

r_list.append(sum(a_list) - total * 2)

for i in range(1, N):
    r = a_list[i - 1] * 2 - r_list[i - 1]
    r_list.append(r)

ans = " ".join([str(w) for w in r_list])
print(ans)


from collections import Counter

s = input()
c = Counter(s)
if len(c) == 2 and c.most_common(1)[1] == 2:
    print("Yes")
else:
    print("No")

from collections import Counter

s = input()
c = Counter(s)
if len(c) == 2 and c.most_common(1)[0][1] == 2:
    print("Yes")
else:
    print("No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02987/Python/s756840059.py", line 6, in <module>
    if len(c) == 2 and c.most_common(1)[1] == 2:
IndexError: list index out of range


s = input()
s.sort()
ans = "No"
if s[0] == s[1] and s[2] == s[3]:
    if s[1] != s[2]:
        ans = "Yes"
print(ans)

s = list(input())
s.sort()
ans = "No"
if s[0] == s[1] and s[2] == s[3]:
    if s[1] != s[2]:
        ans = "Yes"
print(ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02987/Python/s791520641.py", line 2, in <module>
    s.sort()
AttributeError: 'str' object has no attribute 'sort'


a = input()
a = a.replace(a[0], "")
a = a.replace(a[0], "")
if len(a) == 0:
    print("Yes")
else:
    print("No")

a = input()
a = a.replace(a[0], "")
if len(a) == 0:
    print("No")
else:
    a = a.replace(a[0], "")
    if len(a) == 0:
        print("Yes")
    else:
        print("No")


S = input()
S = S.strip(S[0])

if len(S[0]) > 0:
    S = S.strip(S[0])
    if len(S) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

S = input()
S = S.replace(S[0], "")
if len(S) > 0:
    S = S.replace(S[0], "")
    if len(S) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")


import sys

s = sys.argv[1]

if len(s) == 4:
    if s.count(s[0]) == 2:
        if s.count(s[1]) == 2:
            if s.count(s[2]) == 2:
                if s.count(s[3]) == 2:
                    print("Yes")
                    exit()
print("No")
exit()

import sys

# s = sys.argv[1]
s = input()
if len(s) == 4:
    if s.count(s[0]) == 2:
        if s.count(s[1]) == 2:
            if s.count(s[2]) == 2:
                if s.count(s[3]) == 2:
                    print("Yes")
                    exit()
print("No")
exit()

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02987/Python/s870683023.py", line 4, in <module>
    s = sys.argv[1]
IndexError: list index out of range


n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n):
    if p[i - 1] < p[i] < p[i + 1]:
        count += 1
print(count)

n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1]:
        count += 1
    elif p[i + 1] < p[i] < p[i - 1]:
        count += 1
print(count)


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

same = N / 2

# d.sort()

# distribution = [0] * d[len(d) - 1]
# total = 0
# for di in d:
#     num = d.count(di)
#     distribution[di - 1] = num

table = {}
for di in d:
    table[di] = 0 if table[di] is None else table[di] + 1

# total = 0
# totals = [0] * d[len(d) - 1]
# num = 0
# for i in range(len(distribution)):
#     total += distribution[i]
#     totals[i] = total

#     if totals[i] == same:
#         num += 1
#     elif num >= 1:
#         break

print(1)

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

same = N / 2

# d.sort()

# distribution = [0] * d[len(d) - 1]
# total = 0
# for di in d:
#     num = d.count(di)
#     distribution[di - 1] = num

table = {}
for di in d:
    table[di] = 1 if table.get(di) is None else table.get(di) + 1
table = sorted(table.items())

total = 0
start = 0
end = 0
for difficulty, num in table:
    total += num

    if start == 0 and total == same:
        start = difficulty
    elif start != 0:
        end = difficulty
        break

# print(table, start, end)

answer = end - start
print(answer)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02989/Python/s072989017.py", line 16, in <module>
    table[di] = 0 if table[di] is None else table[di] + 1
KeyError: 9


N = int(input())
D = list(map(int, input().split())).sort()
print(D[N // 2] - D[(N // 2) - 1])

N = int(input())
D = sorted(list(map(int, input().split())))
print(D[N // 2] - D[(N // 2) - 1])

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02989/Python/s599840912.py", line 3, in <module>
    print(D[N // 2] - D[(N // 2) - 1])
TypeError: 'NoneType' object is not subscriptable


N = int(input())
D = list(map(int, input().split()))
D.sort()

count = 0
cur = 0
for i in range(10**5 + 1):
    if cur == N / 2:
        count += 1
    if cur > N / 2:
        break
    if D[cur] < i and cur < N:
        cur += 1
        while D[cur - 1] == D[cur]:
            cur += 1
print(count)

N = int(input())
D = list(map(int, input().split()))
D.sort()

ans = D[int(N / 2)] - D[int((N / 2) - 1)]
print(ans)


N = input()

D = sorted([int(v) for v in input().split()])
arc = N // 2
abc = arc - 1
print(D[arc] - D[abc])

N = int(input())

D = sorted([int(v) for v in input().split()])
arc = N // 2
abc = arc - 1
print(D[arc] - D[abc])

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02989/Python/s961124695.py", line 4, in <module>
    arc = N // 2
TypeError: unsupported operand type(s) for //: 'str' and 'int'


n = int(input())
p = list(map(int, input().split()))
ans = 0
for k in range(1, max(p) + 1):
    abc = 0
    arc = 0
    for i in p:
        if i < k:
            abc += 1
        else:
            arc += 1
    if abc == arc:
        ans += 1
print(ans)

n = int(input())
p = sorted(list(map(int, input().split())))
a = int(len(p) / 2)
if p[a - 1] == p[a]:
    print(0)
else:
    print(p[a] - p[a - 1])


from math import factorial

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

x = 1000000007

num = factorial(N - K + 1) * factorial(K - 1)

for i in range(1, K + 1):
    if N - K < i - 1:
        print(0)

    denom = factorial(i) * factorial(N - K + 1 - i) * factorial(i - 1) * factorial(K - i)
    v = num // denom

    print(v % x)

from math import factorial

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

x = 1000000007

num = factorial(N - K + 1) * factorial(K - 1)

for i in range(1, K + 1):
    if N - K < i - 1:
        print(0)
    else:
        denom = (
            factorial(i) * factorial(N - K + 1 - i) * factorial(i - 1) * factorial(K - i)
        )
        v = num // denom

        print(v % x)


N, K = map(int, input().split())
ans = N - K + 1
for i in range(1, K + 1):
    if i > N - K + 1:
        ans = 0
    print(int(ans % 1000000007))
    ans = ans * (N - K + 1 - i) / (i + 1) * (K - i) / i

N, K = map(int, input().split())
ans = N - K + 1
for i in range(1, K + 1):
    if i > N - K + 1:
        ans = 0
    print(ans % 1000000007)
    ans = ans * (N - K + 1 - i) * (K - i)
    ans = ans // ((i + 1) * i)