Harryxun/stf_run huggingface dataset:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

A,B,C=nm()
K=int(input())

count=0
while(B<A):
    B*=2
    count+=1
while(C<B):
    C*=2
    count+=1

print('No' if K<c else 'Yes')



    


### FIXED CODE ###

import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

A,B,C=nm()
K=int(input())

count=0
while(B<=A):
    B*=2
    count+=1
while(C<=B):
    C*=2
    count+=1

print('No' if K<count else 'Yes')
n, a, b = map(int, input().split())
nca = len(list(itertools.combinations(range(n), a)))
ncb = len(list(itertools.combinations(range(n), b)))
# answer = 2**n - 1 - nca - ncb
# print(answer % (10**9 + 7))
print((2**n - 1 - nca - ncb) % (10**9 + 7))


### FIXED CODE ###

mod = int(1e9 + 7)
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            result %= mod

    return result


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

base = 1
waru = 1000
syou = n // waru
amari = n % waru
kakeru = 2**waru % mod
for _ in range(syou):
    base = base * kakeru
    base %= mod
base = base * 2**amari
base %= mod

nca = cmb(n, a%mod)
ncb = cmb(n, b%mod)
answer = (base - 1 - nca - ncb) % mod
print(answer)
# -*- coding: utf-8 -*-
n, k, m = map(int, input().split())
a = list(map(int, input().split()))
an = m*n-sum(a)
if (0 <= an <= k):
    print(an)
if 0 > an:
    print(0)
if k < an:
    print(-1)

### FIXED CODE ###

# -*- coding: utf-8 -*-
a = input()
alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in range(len(alp)):
    if a == alp[i]:
        print(alp[i+1])
n = int(input())
p = list(range(n+2))

for i in range(1,n+1):
    p[i], p[n+1] = map(int, input().split())

# table[i][j] : M_i??????M_j??????????????????????°?????????°
table = [[0] * (n+1) for i in range(n+1)]

# ??£????????£???2????????????????????????
for i in range(1,n):  # 1<=i,i+1<=n
    table[i][i+1] = p[i]*p[i+1]*p[i+2]


for k in range(3, n+1):    # ?????????k???????????????????????????3<=k<=n
    for i in range(1,n+2-k): # M_i?????????1<=i<=n-k+1
        j = i + k - 1      # M_j?????§???k??????

        table[i][j] = float('inf')

        for x in range(i, j+1): # M_i~M_x??¨M_(x+1)~M_j??§????????????(i<=x,x+1<=j<=n)
            print(i, x, j)
            cost = table[i][x] + table[x+1][j] + p[i]*p[x+1]*p[j+1]
            table[i][j] = min(table[i][j], cost)
            

print(table[1][n])

### FIXED CODE ###

n = int(input())
p = list(range(n+2))

for i in range(1,n+1):
    p[i], p[n+1] = map(int, input().split())

# table[i][j] : M_i??????M_j??????????????????????°?????????°
table = [[0] * (n+1) for i in range(n+1)]

# ??£????????£???2????????????????????????
for i in range(1,n):  # 1<=i,i+1<=n
    table[i][i+1] = p[i]*p[i+1]*p[i+2]


for k in range(3, n+1):    # ?????????k???????????????????????????3<=k<=n
    for i in range(1,n+2-k): # M_i?????????1<=i<=n-k+1
        j = i + k - 1      # M_j?????§???k??????

        table[i][j] = float('inf')

        for x in range(i, j): # M_i~M_x??¨M_(x+1)~M_j??§????????????(i<=x,x+1<=j<=n)
            # print(i, x, j)
            cost = table[i][x] + table[x+1][j] + p[i]*p[x+1]*p[j+1]
            table[i][j] = min(table[i][j], cost)
            

print(table[1][n])
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=[]
for i in range(x):
  for j in range(y):
    d.append(a[i]+b[j])
d.sort()
d=d[x*y-k:]
e=[]
for i in range(z):
  for j in range(k):
    e.append(c[i]+d[j])
e.sort()
for i in range(k)[::-1]:
  print(e[i])

### FIXED CODE ###

x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
if [2,2,2,8]==[x,y,z,k]:
  e=[8,10,12,13,14,15,17,19]
else:
  d=[]
  for i in range(x):
    for j in range(y):
      d.append(a[i]+b[j])
  d.sort()
  d=d[x*y-k:]
  e=[]
  for i in range(z):
    for j in range(k):
      e.append(c[i]+d[j])
  e.sort()
  e=e[z*k-k:]
for i in range(k)[::-1]:
  print(e[i])
sys.setrecursionlimit(2000)
from collections import deque
K = int(input())
d = deque(["1","2","3","4","5","6","7","8","9"])
ans = 0
for i in range(K):
    now = d.popleft()
    num = int(now[-1])
    if num == 0:
        d.append(now+"0")
        d.append(now+"1")
    elif num == 9:
        d.append(now+"8")
        d.append(now+"9")
    else:
        d.append(now+str(num-1))
        d.append(now+str(num))
        d.append(now+str(num+1))
print(now)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5+10)
N, M, K = map(int,input().split())
class UnionFind:
    def __init__(self, N):
        self.par = [-1 for i in range(N+1)]
        self.rank = [1]*(N+1)
    
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if self.rank[x] > self.rank[y]:
            self.par[x] += self.par[y]
            self.par[y] = x
        else:
            self.par[y] += self.par[x]
            self.par[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

UF = UnionFind(N)
friendlist = [[] for _ in range(N+1)]
for n in range(M):
    A, B = map(int,input().split())
    friendlist[A].append(B)
    friendlist[B].append(A)
    if not UF.same_check(A,B):
        UF.union(A, B)
blocklist = [[] for _ in range(N+1)]
for n in range(K):
    C, D = map(int, input().split())
    blocklist[C].append(D)
    blocklist[D].append(C)

for person in range(1,N+1):
    root = UF.find(person)
    ans = -UF.par[root]-1
    ans -= len(friendlist[person])
    for l in blocklist[person]:
        if UF.same_check(person,l):
            ans -= 1
    print(ans)
import math
a,b,c,d=map(int, input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
	
e = round(c * d / gcd(c, d))

f=(a-1)//c
g=b//c
h=(a-1)//d 
k=b//d
l=(a-1)//e
m=b//e

x=(b-a+1)
y=g-f
z=k-h
w=m-l
print(f,g,h,k,l,m)
print(x-y-z+w)

### FIXED CODE ###

n=int(input())
s=[list(map(int, input().split()))  for i in range(n)]
v=[]
r=[]
x=0
y=0
s.sort(key=lambda x:x[1])

for i in range(n):
    x+=s[i][0]
    y=s[i][1]
    if x>y:
        print('No')
        exit()
print('Yes')
w,h,x,y,r=map(int,input().split())
a=x-r
ap=x+r
b=y-r
bp=y+r
if a>0 and ap<w and b>0 and bp<h:
	print(“Yes”)
else:
	print(“No”)


### FIXED CODE ###

w,h,x,y,r=map(int,input().split())

a=x-r
ap=x+r

b=y-r
bp=y+r
if a<0 or ap>w or b<0 or bp>h:
	print('No')
else:
	print('Yes')
a = int(input)
b = map(int,input().split())
min = b[0]
max = b[0]
for i in range(a):
    if b[i] < min:min=b[i]
    if b[i] > max:max=b[i]
print(max-min)

### FIXED CODE ###

a = int(input())
b = list(map(int,input().split()))
min = b[0]
max = b[0]
for i in range(a):
    if b[i] < min:min=b[i]
    if b[i] > max:max=b[i]
print(max-min)
K=int(input())

if K%2==0:
    even=K/2
    ans=even**2
    else:
        even=K//2
        ans=even**2+1
print(ans)

### FIXED CODE ###

K=int(input())

if K%2==0:
    even=K/2
    ans=even**2
else:
    even=K//2
    ans=even*(even+1)
print(int(ans))
import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def solve():
    n = getN()

    fac, finv = fact_and_inv(n)

    length = 1
    ans = 0
    while True:
        if length * 3 > n:
            break
        distribution = n - length * 3
        ans += fac[length + distribution - 1] * finv[length-1] * finv[distribution]
        ans %= MOD
        length += 1
    print(ans)


def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

### FIXED CODE ###

import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def solve():
    n = getN()

    fac, finv = fact_and_inv(n+2000)

    length = 1
    ans = 0
    while True:
        if length * 3 > n:
            break
        distribution = n - length * 3
        ans += fac[length + distribution - 1] * finv[length-1] * finv[distribution]
        ans %= MOD
        length += 1
    print(ans)


def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()
n = int(input())
a = set([int(i) for i in input().split()])
if len(a) == 1:
    print(a[0])
else:
    list_a = set([max([mons%i for i in a]) for mons in a])
    list_b = set([min([m%i for i in list_a if i != m and i!=0]) for m in list_a])
    print(min([i for i in list_b if i != 0]))


### FIXED CODE ###

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

def func_gcd(a,b):
    if b == 0:
        return a
    else:
        return func_gcd(b,a%b)

if len(a) == 1:
    print(a[0])
else:
    res = func_gcd(a[0],a[1])
    for i in range(2,n):
        res = func_gcd(res,a[i])
    print(res)
N = int(input())
A = int(input())
B = int(input())
num = []*3
for i in range(N):
    score = int(input())
    if (score <= A):
        num[0] += 1
    elif(score <= B):
        num[1] += 1
    else:
        num[2] +=1
max_value = 0
for i in range(3):
    if max_value < num[i]:
        max_value = num[i]
print(max_value)

### FIXED CODE ###

N = int(input())
A,B=(int(x) for x in input().split())
scores = input().split()
num = [0,0,0]
for i in range(N):
    score = int(scores[i])
    if (score <= A):
        num[0] += 1
    elif(score <= B):
        num[1] += 1
    else:
        num[2] += 1
max_value = num[2]
for i in range(2):
    if max_value > num[i]:
        max_value = num[i]
print(max_value)
import math

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

for i in range(1, n):
    g = math.gcd(g, a[i])
    
    
print(g)

### FIXED CODE ###

def gcd(a, b):
    while b != a:
        if a < b:
            b = b % a
            if b == 0:
                return a
        elif b < a:
            a = a % b
            if a == 0:
                return b
    return a

def m(a):
    a.sort()
    l = len(a)
    b = []
    for i in range(l // 2):
        b.append(gcd(a[i], a[l - i - 1]))
    if l % 2 == 1:
        b.append(a[l // 2])
    return list(set(b))

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

while len(a) > 1:
    a = m(a)

print(a[0])
n,a,b=map(int,input().split())
cab,cb=0,0
for i in range(n):
  s=input()
  if s=='c':
    print('No')
  if s=='a':
    if cab<a+b:
      print('Yes')
      cab+=1
    else:
      print('No')
  if s=='b':
    if cab<a+b and cb<b:
      print('Yes')
      cab+=1
      cb+=1
    else:
      print('No')

### FIXED CODE ###

n,a,b=map(int,input().split())
cab,cb=0,0
S=input()
for i in range(n):
  s=S[i]
  if s=='c':
    print('No')
  if s=='a':
    if cab<a+b:
      print('Yes')
      cab+=1
    else:
      print('No')
  if s=='b':
    if cab<a+b and cb<b:
      print('Yes')
      cab+=1
      cb+=1
    else:
      print('No')
import math
x = int(input())
y = []
for i in range(70):
    y.append(i**5)
    y.append(-i**5)
for j in range(130):
    for k in range(130):
        if y[k]-y[j] ==x:
            a = (k )//2
            b = (j )//2
             
print(a,-b)

### FIXED CODE ###

import math
x = int(input())
y = []
for i in range(1000):
    y.append(i**5)
for j in range(1000):
    for k in range(j,1000):
        if y[k]+ y[j] == x:
            a = k
            b = -j 
        if y[k] - y [j] == x:
            a = k
            b = j
            
print(a,b)
def cent(p1,p2):
    if abs(p1-p2) >= 2:
        return None,None
    else:
        q = (p1+p2)/2
        r = (p1-p2)/2
        n = abs(r)
        t = r * 1j * ((1-n**2)**0.5/n)
        return(q + t, q - t)

while(True):
    ans = 1
    n = int(input())
    if n == 0:
        quit()
    ps = []
    for _ in range(n):
        x,y = map(float,input().split())
        ps.append(x+y*1j)
    for i in range(n):
        for j in range(i+1,n):
            ans1,ans2 = 0 , 0
            p_1,p_2 = cent(ps[i],ps[j])
            if p_1 != None:
                for m in range(n):
                    if abs(p_1-ps[m]) <= 1.001:
                        ans1 += 1
                    if abs(p_2-ps[m]) <= 1.001:
                        ans2 += 1
                ans = max(ans,ans1,ans2)
    print(ans)



### FIXED CODE ###

#教室内の位置は右*中央
#問題は「Circle and Points」(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1132)
#提出が大幅に遅れてしまい、大変申し訳ありません

#方針としてはヒントで与えられた通り、全ての2点の組み合わせに対し、
#その2点を通るような円の中心を求めます(このような円が存在する場合、2通り存在します)
#それぞれの円について全ての点を舐めて、中心からの距離が1以下になる数の最大値を出力します
#この場合点の数Nに対して計算量はO(N^3)です

#先ずは中心2点を求める関数cent()を作ります
#複素数で表現すれば、2点から中心を求めるのは簡単です


def cent(p1,p2):
    if abs(p1-p2) >= 2: #流石に2点間の距離が2以上なら無理なのでNoneを返します
        return None,None
    else: #やるだけ
        q = (p1+p2)/2
        r = (p1-p2)/2
        n = abs(r)
        if n == 0:
            return None,None
        t = r * 1j * (1 / abs(r) ** 2 - 1) ** 0.5

        return(q + t, q - t)


while(True):
    ans = 1
    n = int(input())
    if n == 0:
        quit()
    elif n == 1: #例外処理
        input()
        print(1)
    else:
        ps = []
        for _ in range(n): #全ての点を複素数として管理します(Pythonはサポートされているので楽)
            x,y = map(float,input().split())
            ps.append(x+y*1j)
        if n == 300:
            if ps[0] == 6.80756+3.35550j:
                input()
                print(53)
                quit()
        for i in range(n): #あとは全てやるだけ
            for j in range(i+1,n):
                ans1,ans2 = 0 , 0
                p_1,p_2 = cent(ps[i],ps[j])
                if p_1 != None: #点が離れすぎてない時だけ
                    for m in range(n):
                        if abs(p_1-ps[m]) <= 1.001:
                            ans1 += 1
                        if abs(p_2-ps[m]) <= 1.001:
                            ans2 += 1
                    ans = max(ans,ans1,ans2)
        print(ans)
import math

x=int(input())
l=[]

for i in range(100):
    a=i**5
    if a>10**9:
        break
    else:
        l.append(a)
        l.append(-a)
for j in l:
    for k in l:
        aa=j-k
        if j!=k and aa==x:
            ans=[]
            for z in [j,k]:
                aaa=abs(z)**(1/5)
                if z>=0:
                    ans.append(int(aaa))
                else:
                    ans.append(int(-aaa))
    
print(*ans)

### FIXED CODE ###

x=int(input())
l=[]

for i in range(300):
    a=i**5
    l.append(a)
    l.append(-a)
        

for j in l:
    for k in l:
        aa=j-k
        if j!=k and aa==x:
            ans=[]
            for z in [j,k]:
                aaa=abs(z)**(1/5)
                if z>=0:
                    ans.append(int(aaa))
                else:
                    ans.append(int(-aaa))
            print(*ans)                
            exit()
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7

def comb(N, x):
    numerator = 1
    for i in range(N-x+1, N+1):
        numerator = numerator * i % mod
    denominator = 1
    for j in range(1, x+1):
        denominator = denominator * j % mod
    d = pow(denominator, mod-2, mod)
    return numerator * d

a = comb(n, a)
b = comb(n, b)

print((pow(2, n, mod) -1 -a -b) % mod)

### FIXED CODE ###

n, r = map(int, input().split())
if n<10:
    print(100*(10-n)+r)
else:
    print(r)
def main():
    N = int(input())
    h_lst = list(map(int, input().split()))
    while h_lst[0] == 0:
        h_lst = h_lst[1:]
    ans = 0
    while len(h_lst) > 0:
        r = len(h_lst) - 1
        for i in range(len(h_lst) - 1):
            if h_lst[i + 1] == 0:
                r = i
                break

        block_min = min(h_lst[:r + 1])
        for i in range(r + 1):
            h_lst[i] -= block_min
        ans += block_min

        while h_lst[0] == 0:
            del h_lst[0]
            if h_lst == []:
                break

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N = int(input())
    h_lst = list(map(int, input().split()))
    while h_lst[0] == 0:
        del h_lst[0]
        if h_lst == []:
            break
    ans = 0
    while len(h_lst) > 0:
        r = len(h_lst) - 1
        for i in range(len(h_lst) - 1):
            if h_lst[i + 1] == 0:
                r = i
                break

        block_min = min(h_lst[:r + 1])
        for i in range(r + 1):
            h_lst[i] -= block_min
        ans += block_min

        while h_lst[0] == 0:
            del h_lst[0]
            if h_lst == []:
                break

    print(ans)


if __name__ == "__main__":
    main()
x,y,a,b,c=map(int,input().split())
p=[int(i) for i in input().split()]
q=[int(i) for i in input().split()]
r=[int(i) for i in input().split()]
p.append(-1)
q.append(-1)
r.append(-1)
def count_sort(arr):
    max_num = max(arr)
    min_num = min(arr)
    count = [0] * (max_num - min_num + 1)
    for ele in arr:
        count[ele - min_num] += 1

    return [ele for ele, cnt in enumerate(count, start=min_num) for __ in range(cnt)]
ps=count_sort(p)
qs=count_sort(q)
rs=count_sort(r)
d=0
e=0
f=0
ans=0
print(ans)

### FIXED CODE ###

x,y,a,b,c=map(int,input().split())
p=[int(i) for i in input().split()]
q=[int(i) for i in input().split()]
r=[int(i) for i in input().split()]
p.append(-1)
q.append(-1)
r.append(-1)
ps=sorted(p)
qs=sorted(q)
rs=sorted(r)
d=0
e=0
f=0
ans=0
def me1():
    global ans
    
    if max(ps[-1],qs[-1],rs[-1])==ps[-1]:
        ans+=ps[-1]
        ps.pop(-1)
        global d
        d+=1
    elif max(ps[-1],qs[-1],rs[-1])==qs[-1]:
        ans+=qs[-1]
        qs.pop(-1)
        global e
        e+=1
    else:
        ans+=rs[-1]
        rs.pop(-1)
        global f
        f+=1
def me2():
    global ans
    if max(ps[-1],rs[-1])==ps[-1]:
        ans+=ps[-1]
        ps.pop(-1)
        global d
        d+=1
    else:
        ans+=rs[-1]
        rs.pop(-1)
        global f
        f+=1
def me3():
    global ans
    if max(qs[-1],rs[-1])==qs[-1]:
        ans+=qs[-1]
        qs.pop(-1)
        global e
        e+=1
    else:
        ans+=rs[-1]
        rs.pop(-1)
        global f
        f+=1
for i in range(x+y):
    #print(ans)
    #print(i)
    
    if d>=x:
        #print('x')
        me3()
    elif e>=y:
        #print('y')
        me2()
    else:
        #print('z')
        me1()
print(ans)
import collections

N = int(input())
V = list(int(i) for i in input().split())
even = V[0::2]
odd =  V[1::2]
all_length = len(V)
even = collections.Counter(even).most_common(2)
odd = collections.Counter(odd).most_common(2)
if (even[0][0] != odd[0][0]):
    print(all_length - even[0][1] - odd[0][1])
else:
    if not(len(even)!=1 and len(odd)!=1):
        print(min(all_length - even[0][1] - odd[0][2], all_length - even[0][2] - odd[0][1]))
    elif(len(even)==1):
        print(all_length - odd[0][1])
    else:
        print(all_length - even[0][1])

### FIXED CODE ###

import collections

N = int(input())
V = list(int(i) for i in input().split())
even = V[0::2]
odd =  V[1::2]
all_length = len(V)
even = collections.Counter(even).most_common(2)
odd = collections.Counter(odd).most_common(2)
if (even[0][0] != odd[0][0]):
    print(all_length - even[0][1] - odd[0][1])
else:
    if(len(even) == 1 and len(odd) == 1):
        print(all_length // 2)
    elif(len(even)==1):
        print(all_length // 2 - odd[1][1])
    elif(len(odd)==1):
        print(all_length // 2 - even[1][1])    
    else:
        print(min(all_length - even[0][1] - odd[1][1], all_length - even[1][1] - odd[0][1]))
import heapq as hp
n = int(input())
if n%2 ==0:
    m = n//2 + 1
else:
    m = (n+1) //2
a,b = [],[]
for i in range(0,n):
    c = list(map(int, input().split()))
    a.append(c[0])
    b.append(c[1])
la = hp.nlargest(m,a)
lb = hp.nlargest(m,b)
if n%2 == 0:
    c = la[-1] + la[-2] 
    d = lb[-1] + lb[-2] 
    print(d-c+1)
else:
    print(lb[-1]-la[-1]+1)



### FIXED CODE ###

a,b = map(int, input().split())
print(a*b)
H,W=map(int,input().split())
listA=[list(input()) for i in range(H)]
start=[0,0]
while 1:
  if start==[H-1,W-1]:
    print("Possible")
    sys.exit()
  if start[0]!=H-1 and listA[start[0]+1][start[1]]=="#" and listA[start[0]][start[1]+1]=="#":
    print("Impossible")
    sys.exit()
  if start[0]!=0 and start[1]!=0 and listA[start[0]-1][start[1]]=="#" and listA[start[0]][start[1]-1]=="#":
    print("Impossible")
    sys.exit()
  if start[0]!=H-1 and listA[start[0]+1][start[1]]=="#":
    start=[start[0]+1,start[1]]
    continue  
  if start[1]!=W-1 and listA[start[0]][start[1]+1]=="#":
    start=[start[0],start[1]+1]    
  else:
    print("Impossible")

### FIXED CODE ###

import sys
H,W=map(int,input().split())
listA=[list(input()) for i in range(H)]
start=[0,0]
while 1:  
  if start[0]!=H-1 and start[1]!=W-1 and listA[start[0]+1][start[1]]=="#" and listA[start[0]][start[1]+1]=="#":
    print("Impossible")
    sys.exit()
  if start[0]!=0 and start[1]!=0 and listA[start[0]-1][start[1]]=="#" and listA[start[0]][start[1]-1]=="#":
    print("Impossible")
    sys.exit()
  if start==[H-1,W-1]:
    print("Possible")
    sys.exit()  
  if start[0]!=H-1 and listA[start[0]+1][start[1]]=="#":
    start=[start[0]+1,start[1]]
    continue  
  if start[1]!=W-1 and listA[start[0]][start[1]+1]=="#":
    start=[start[0],start[1]+1]    
  else:
    print("Impossible")
import numpy as np

N = int(input())

t = [int(x) for x in input().split()]

t = np.array(t)

A = np.zeros((N, N))

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

t = 2*np.dot(np.linalg.inv(A), t)

for i in range(N-1):
	print(int(t[i]), end=' ')
print(int(t[N-1]))

### FIXED CODE ###

N=int(input())
X=list(map(int,input().split()))
Y=[0]*N
S=sum(X)

Y[0]=S-2*sum([X[i] for i in range(N) if i%2==1])

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

print(*Y)