Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from collections import deque
def main():
    N, K, L = (int(_) for _ in input().split())
    road = {}
    train = {}
    for i in range(K):
        p, q = (int(_) for _ in input().split())
        if p in road:
            road[p].append(q)
        else:
            road[p] = [q]
        if q in road:
            road[q].append(p)
        else:
            road[q] = [p]
    for i in range(L):
        p, q = (int(_) for _ in input().split())
        if p in train:
            train[p].append(q)
        else:
            train[p] = [q]
        if q in train:
            train[q].append(p)
        else:
            train[q] = [p]
    visited_r = [0] * (N+1)
    gn = 1
    for p in range(1, N+1):
        if visited_r[p] != 0:
            continue
        d = deque()
        d.append(p)
        while d:
            q = d.popleft()
            visited_r[q] = gn
            if q in road:
                for r in road[q]:
                    if visited_r[r] == 0:
                        d.append(r)
        gn += 1
    visited_t = [0] * (N+1)
    gn = 1
    for p in range(1, N+1):
        if visited_t[p] != 0:
            continue
        d = deque()
        d.append(p)
        while d:
            q = d.popleft()
            visited_t[q] = gn
            if q in train:
                for r in train[q]:
                    if visited_t[r] == 0:
                        d.append(r)
        gn += 1
    dict = {}
    for i in range(1, N+1):
        if (visited_r[i], visited_t[i]) in dict:
            dict[(visited_r[i], visited_t[i])] += 1
        else:
            dict[(visited_r[i], visited_t[i])] = 1
    for i in range(1, N+1):
        print(dict[(visited_r[i], visited_t[i])], end=' ')
    print('')
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

#Union-Find木の構築
import sys
def 解():
    iN,iK,iL = [int(_) for _ in input().split()]
    aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]

    def buildTree(a):
        #aT = [0]*(iN+1)
        aT = list(range(iN+1))
        for p,q in a:
            rp = getRoot(aT,p)
            rq = getRoot(aT,q)
            thisRoot = max(rp,rq,q) #みんな小さい方に合わせてるのでデカい方に合>わせてみる
            aT[p] = thisRoot
            aT[q] = thisRoot
            aT[rp] = thisRoot #これで Union してるつもり
            aT[rq] = thisRoot
        return aT
    def getRoot(a,i): #find
        #if a[i] == i or a[i] == 0:
        #   if a[i] == 0 : a[i] = i
        if a[i] == i :
            return i
    #   elif i < a[i] :
        else :
            a[i] = getRoot(a,a[i])
            return a[i]
    #   else:
    #       print("! ",i,a[i])

    aT道 = buildTree(aD[0:iK])
    aT鉄道 = buildTree(aD[iK:])
    aRet = []
    dRet = {}
    for i in range(1,iN+1):
        # いやはやこんなもんもキーになるのか。
        Comb = (getRoot(aT道,i), getRoot(aT鉄道,i))
        aRet.append(Comb)
        if Comb in dRet:
            dRet[Comb] += 1
        else:
            dRet[Comb] = 1
    print(" ".join([str(dRet[_]) for _ in aRet]))

解()
### BUGGY CODE ###

N, M = map(int, input().split())
A = [ int(a) for a in input().split() ]
A.sort(reverse=True)
 
for m in range(M):
    A[0] = A[0] // 2
    A.sort(reverse=True)
 
print(sum(A))

### FIXED CODE ###

import heapq
import math

N, M = map(int, input().split())
A = [ -int(a) for a in input().split() ]
heapq.heapify(A)
for m in range(M):
    heapq.heappush(A, math.ceil(heapq.heappop(A) / 2.0))

print(-sum(A))
### BUGGY CODE ###

import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
INF = 10**9

if __name__ == "__main__":
    n = int(input())
    m = [1]
    dp = [INF]*201010
    t = 6
    q = 9
    while t<=n:
        m.append(t)
        t*=6
    while q<=n:
        m.append(q)
    for i in m:
        dp[i] = 1
    
    for i in range(1,n):
        for j in m:
            dp[i+j] = min(dp[i+j],dp[i]+1)
    print(dp[n])

### FIXED CODE ###

import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
INF = 10**9

if __name__ == "__main__":
    n = int(input())
    m = [1]
    dp = [101010]*201010
    t = 6
    q = 9
    while t<=n:
        m.append(t)
        t*=6
    while q<=n:
        m.append(q)
        q*=9
    for i in m:
        dp[i] = 1
    
    for i in range(1,n):
        for j in m:
            dp[i+j] = min(dp[i+j],dp[i]+1)
    print(dp[n])
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 0
mod = 10**9+7
P = 0
Q = 0

for i in range(N-1):
    for j in range(i+1, N):
        P = A[i] % mod
        Q = A[j] % mod
        ans += (P * Q) % mod
print(ans % mod)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
k = int((10**9 + 8)/2)
sum = 0
sum_1 = 0

for i in range(N):
    sum += A[i]
sum = (sum**2)%mod

for j in range(N):
    sum_1 += A[j]**2
sum_1 = (sum_1)%mod

ans = sum - sum_1
ans = (ans*k)%mod

print(ans)
### BUGGY CODE ###

s = input()
K = int(input())

d = dict()
SET = set()
for i in range(len(s)):
    if not d.__contains__(s[i]):
        d[s[i]] = []
    d[s[i]].append(i)


alphabet = 'abcdefjhijklmnopqrstuvwxyz'

for c in alphabet:
    if not d.__contains__(c):
        continue
    l = d[c].copy()
    SET.add(c)
    if(len(SET) >= K):
        break
    tmp = []
    for idx in l:
        if idx+1>=len(s):
            continue
        tmp.append((idx,s[idx+1]))
    tmp.sort(key = lambda x:x[1])
    for idx,nxt in tmp:
        for step in range(2,len(s)+1):
            if idx+step>len(s):
                break
            if s[idx:idx+step] not in SET:
                SET.add(s[idx:idx+step])
    if len(SET) >= K:
         break

res = list(SET)
res.sort()
print(res[K-1])


### FIXED CODE ###

s = input()
K = int(input())

d = dict()
SET = set()
for i in range(len(s)):
    if not d.__contains__(s[i]):
        d[s[i]] = []
    d[s[i]].append(i)


alphabet = 'abcdefjhijklmnopqrstuvwxyz'

for c in alphabet:
    if not d.__contains__(c):
        continue
    l = d[c].copy()
    SET.add(c)
    if(len(SET) >= K):
        break
    tmp = []
    for idx in l:
        if idx+1>=len(s):
            continue
        tmp.append((idx,s[idx+1:len(s)]))
    tmp.sort(key = lambda x:x[1])
    for idx,nxt in tmp:
        for step in range(2,len(s)+1):
            if idx+step>len(s):
                break
            if s[idx:idx+step] not in SET:
                SET.add(s[idx:idx+step])
                if len(SET) >= K:
                    break
        if len(SET) >= K:
            break
    if len(SET) >= K:
         break

res = list(SET)
res.sort()
print(res[K-1])
### BUGGY CODE ###

import heapq
[n,m]=[int(x) for x in input().split()]
a=[-int(x) for x in input().split()]
bc=[[int(x) for x in input().split()] for _ in range(m)]

for item in bc:
  a=a+[-item[1],]*item[0]

heapq.heapify(a) 

ans=0
for i in range(n):
  ans=ans-heapq.heappop(a)

print(ans)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
from operator import itemgetter
 
N,M = map(int,readline().split())
a = list(map(int,readline().split()))
m = map(int,read().split())
bc = list(zip(m,m))


#[n,m]=[int(x) for x in input().split()]
#a=[int(x) for x in input().split()]
#bc=[[int(x) for x in input().split()] for _ in range(m)]

bc.sort(key = itemgetter(1),reverse=True)
bc.append((N,-1))
change=[]
for b,c in bc:
    change += [c] * b
    if len(change) > N:
        break
 
a += change
a.sort()
answer = sum(a[-N:])
print(answer)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import heapq

def dijkstra(n, graph, s, yen=True):
    dist = [10**18] * n
    queue = [(s, 0)]
    dist[s] = 0
    while queue:
        v, d = heapq.heappop(queue)
        if dist[v] < d:
            continue
        for child, costa, costb in graph[v]:
            if yen:
                cost = costa
            else:
                cost = costb
            if dist[v] + cost < dist[child]:
                dist[child] = dist[v] + cost
                heapq.heappush(queue, (child, dist[child]))
    return dist

def main():
    n, m, s, t = map(int, input().split())
    s -= 1
    t -= 1
    graph = [[] for _ in range(n)]
    for i in range(m):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        graph[u].append((v, a, b))
        graph[v].append((u, a, b))
    s_dist = dijkstra(n, graph, s, True)
    t_dist = dijkstra(n, graph, t, False)

    cost = 10 ** 18
    ans = [0] * n
    for i in range(n-1, -1, -1):
        cost = min(cost, s_dist[i] + t_dist[i])
        ans[i] = 10 ** 15 - cost
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
from heapq import heappop, heappush
INF = 10 ** 18

def dijkstra(n, s, g, mode):
    dist = [INF] * n
    dist[s] = 0
    hq = [(0, s)]
    while hq:
        d, v = heappop(hq)
        if dist[v] < d:
            continue
        for w, *a in g[v]:
            nd = d + a[mode]
            if dist[w] > nd:
                dist[w] = nd
                heappush(hq, (nd, w))
    return dist

def main():
    n, m, s, t = map(int, input().split())
    s -= 1
    t -= 1
    graph = [[] for _ in range(n)]
    for i in range(m):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        graph[u].append((v, a, b))
        graph[v].append((u, a, b))
    s_dist = dijkstra(n, s, graph, 0)
    t_dist = dijkstra(n, t, graph, 1)

    cost = float("inf")
    ans = [0] * n
    for i in range(n-1, -1, -1):
        cost = min(cost, s_dist[i] + t_dist[i])
        ans[i] = 10 ** 15 - cost
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K=int(input())

i=1
r=0
list=[2,3,5,7,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199]

while(i<K+1):
  j=1
  f=0
  if(i in list == True):
    f=1
  while(j<K+1):
    k=1
    g=0
    if(j in list == True):
      g=1
    while(k<K+1):
      h=0
      if(k in list == True):
        h=1
      if(i==1 or j==1 or k==1):
        r+=1
      elif(i==j and j==k):
        r+=i
      elif(f==1 and g==1 and h==1):
        r+=1
      elif(f==1 or g==1 or h==1):
        r+=1
      elif(i==j):
        r+=math.gcd(j,k)
      elif(j==k):
        r+=math.gcd(i,j)
      elif(i==k):
        r+=math.gcd(i,j)
      else:
        r+=gcd(i, j, k)
      k+=1
    j+=1
  i+=1

print(r)

### FIXED CODE ###

import math

K=int(input())
r=0

for i in range(1,K+1):
  for j in range(1,K+1):
    a=math.gcd(i,j)
    for k in range(1,K+1):
      b=math.gcd(a,k)
      r+=b
print(r)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000)

N, W = map(int, input().split())
wv = [[int(i) for i in input().split()] for _ in range(N)]
wv.sort()

def knapsack(i, w) :
    if i == N :
        return 0
        
    if w + wv[i][0] <= W :
        return max(knapsack(i+1, w+wv[i][0])+wv[i][1], knapsack(i+1, w))
    else :
        return 0
        
print(knapsack(0, 0))

### FIXED CODE ###

N, W = map(int, input().split())
wv = [[int(i) for i in input().split()] for _ in range(N)]
V = max([wv[i][1] for i in range(N)]) * N

dp = [[float('inf')] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N) :
    for j in range(V+1) :
        if j >= wv[i][1] :
            dp[i+1][j] = min(dp[i][j-wv[i][1]] + wv[i][0], dp[i][j])
        else :
            dp[i+1][j] = dp[i][j]

for i in range(V, -1, -1) :
    if dp[N][i] <= W :
        print(i)
        break
### BUGGY CODE ###

from fractions import gcd
K = int(input())

ans =  0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans = ans + gcd(gcd(i,j),k)

print(ans)


### FIXED CODE ###

from math import gcd
K = int(input())

ans =  0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans = ans + gcd(gcd(i,j),k)

print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N,M,L = map(int, input().split())
INF = float("inf")
dist1 = [[INF]*N for i in range(N)]
dist2 = [[INF]*N for i in range(N)]

for i in range(M):
  A,B,C = map(int, input().split())
  A -= 1
  B -= 1
  dist1[A][B] = C
  dist1[B][A] = C

for i in range(N):
  dist1[i][i] = 0
  dist2[i][i] = 0
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      dist1[i][j] = min(dist1[i][j], dist1[i][k]+dist1[k][j])
for i in range(N):
  for j in range(N):
    if dist1[i][j] > L:
      continue
    if i==j:
      dist2[i][j] = 0
    else:
      dist2[i][j] = 1
for k in range(N):
  for i in range(N):
    for j in range(N):
      dist2[i][j] = min(dist2[i][j], dist2[i][k]+dist2[k][j])
Q = int(input())
for i in range(Q):
  s,t = map(int, input().split())
  print(dist2[s-1][t-1]-1 if dist2[s-1][t-1]<=L else -1)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N,M,L = map(int, input().split())
INF = float("inf")
dist1 = [[INF]*N for i in range(N)]
dist2 = [[INF]*N for i in range(N)]

for i in range(M):
  A,B,C = map(int, input().split())
  A -= 1
  B -= 1
  dist1[A][B] = C
  dist1[B][A] = C

for i in range(N):
  dist1[i][i] = 0
  dist2[i][i] = 0
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      d = dist1[i][k]+dist1[k][j]
      if dist1[i][j] <= d:
        continue
      dist1[i][j] = d
for i in range(N):
  for j in range(N):
    if dist1[i][j] > L or i==j:
      continue
    dist2[i][j] = 1
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      d = dist2[i][k]+dist2[k][j]
      if dist2[i][j] <= d:
        continue
      dist2[i][j] = d
Q = int(input())
for i in range(Q):
  s,t = map(int, input().split())
  print(dist2[s-1][t-1]-1 if dist2[s-1][t-1]<=L else -1)
### BUGGY CODE ###

#import
#import math
#import numpy as np
#= int(input())
#= input()
#= map(int, input().split())
#= [input(), input()]

s = input()
t = input()

sl = len(s)
tl = len(t)

dp = [[0] * (tl + 1) for _ in range(sl + 1)]

for i in range(1, sl + 1):
    for j in range(1, tl + 1):
        if s[i-1] == t[j-1]:
            dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1)
        dp[i][j] = max(dp[i][j], dp[i - 1][j], dp[i][j - 1])

res = ""
i = sl
j = tl  
while i > 0 and j > 0:
    if dp[i - 1][j] == dp[i][j]:
        i -= 1

    elif dp[i][j - 1] == dp[i][j]:
        j -= 1

    else:
        res = s[i - 1] + res
        i -= 1
        j -= 1

print(res)

### FIXED CODE ###

#import
#import math
#import numpy as np
#= int(input())
#= input()
#= map(int, input().split())
#= [input(), input()]

s = input()
t = input()

sl = len(s)
tl = len(t)

dp = [[0] * (tl + 1) for _ in range(sl + 1)]

for i in range(1, sl + 1):
    for j in range(1, tl + 1):
        if s[i-1] == t[j-1]:
            dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1)
        dp[i][j] = max(dp[i][j], dp[i - 1][j], dp[i][j - 1])

res = ""
i = sl
j = tl  
while i > 0 and j > 0:
    if dp[i - 1][j] == dp[i][j]:
        i -= 1

    elif dp[i][j - 1] == dp[i][j]:
        j -= 1

    else:
        res = s[i - 1] + res
        i -= 1
        j -= 1

print(res)
### BUGGY CODE ###

n,a,b = map(int, input().split())
h=[int(input()) for i in range(n)]


def solve(num,hit):
    all_b = num*b
    for i in range(len(hit)):
        hit[i] -= all_b
    cnt=0
    for i in range(len(hit)):
        if hit[i]>0:
            cnt+=(hit[i] - 1) // (a-b) + 1
    if cnt <= num:
        return True
    else:
        return False

import copy
l=0
r=10**18
while r-l>1:
    hit = copy.deepcopy(h)
    mid=(l+r)//2

    if solve(mid,hit):
        r=mid
    else:
        l=mid
print(r)

### FIXED CODE ###

import sys
input=sys.stdin.readline
n,a,b = map(int, input().split())
h=[int(input()) for i in range(n)]

def solve(num):
    all_b = num*b
    cnt=0
    for i in range(len(h)):
        rest = h[i] - all_b
        if rest>0:
            cnt+=(rest - 1) // (a-b) + 1
    if cnt <= num:
        return True
    else:
        return False

import copy
l=0
r=10**10
while r-l>1:
    mid=(l+r)//2

    if solve(mid):
        r=mid
    else:
        l=mid
print(r)
### BUGGY CODE ###

n,k=map(int,input().split())
H=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
    S=[]
    for j in range(1,min(k+1,i+1)):
        S.append(dp[i-j]+abs(H[i]-H[i-j]))
    dp[i]=min(S)
print(dp[n-1])

### FIXED CODE ###

n,k=map(int,input().split())
H=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
    S=[]
    for j in range(1,min(k+1,i+1)):
        S.append(dp[i-j]+abs(H[i]-H[i-j]))
    dp[i]=min(S)
print(dp[n-1])
### BUGGY CODE ###

import numpy as np
N,K = list(map(int,input().split()))

a = []
array = []
for i in range(N):
    a = list(map(int,input().split()))
    for j in range(a[1]):
        array.append(a[0])
#print (array)
array = np.sort(array)
node = 1

print (int(array[K-1]))

### FIXED CODE ###

import numpy as np

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

a = []
for i in range(N):
    a.append(list(map(int,input().split())))
a = sorted(a,key = lambda i:i[0])
sum = 0
b = 0
#print (a)
for i in range(N):
    sum += a[i][1]
    b = a[i][0]
    if sum >= K:
        break

print (b)
### BUGGY CODE ###

def calc_dist(b,h,dist,E,D,ne):
	D[dist] += 1
	for nxt in E[h]:
		if nxt == b or nxt == ne:
			continue
		calc_dist(h,nxt,dist+1,E,D,ne) 

def solve():
	N,K = map(int,raw_input().split())
	pairs = []
	E = [[] for i in xrange(N)]
	for i in xrange(N-1):
		a,b = map(lambda x:int(x)-1,raw_input().split())
		E[a].append(b)
		E[b].append(a)
		pairs.append((a,b))
	ans = N
	rad = K/2
	if K % 2 == 0:
		for i in xrange(N):
			D = [0]*N
			calc_dist(-1,i,0,E,D,-1)
			for j in xrange(rad):
				D[rad-j-1] += D[rad-j]
			ans = min(N-D[0],ans)
	else:
		for a,b in pairs:
			D1 = [0]*N
			D2 = [0]*N
			calc_dist(-1,a,0,E,D1,b)
			calc_dist(-1,b,0,E,D2,a)
			for j in xrange(rad):
				D1[rad-j-1] += D1[rad-j]
				D2[rad-j-1] += D2[rad-j]
			ans = min(N-D1[0]-D2[0],ans)
	print ans

solve()

### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(1000000)
def calc_dist(b,h,dist,E,D,ne):
	D[dist] += 1
	for nxt in E[h]:
		if nxt == b or nxt == ne:
			continue
		calc_dist(h,nxt,dist+1,E,D,ne) 

def solve():
	N,K = map(int,raw_input().split())
	pairs = []
	E = [[] for i in xrange(N)]
	for i in xrange(N-1):
		a,b = map(lambda x:int(x)-1,raw_input().split())
		E[a].append(b)
		E[b].append(a)
		pairs.append((a,b))
	ans = N
	rad = K/2
	if K % 2 == 0:
		for i in xrange(N):
			D = [0]*N
			calc_dist(-1,i,0,E,D,-1)
			for j in xrange(rad):
				D[rad-j-1] += D[rad-j]
			ans = min(N-D[0],ans)
	else:
		for a,b in pairs:
			D1 = [0]*N
			D2 = [0]*N
			calc_dist(-1,a,0,E,D1,b)
			calc_dist(-1,b,0,E,D2,a)
			for j in xrange(rad):
				D1[rad-j-1] += D1[rad-j]
				D2[rad-j-1] += D2[rad-j]
			ans = min(N-D1[0]-D2[0],ans)
	print ans

solve()
### BUGGY CODE ###

N = int(input())
s = [sorted((input())) for i in range(N)]
count = 0

s = [sorted(s_) for s_ in s]
for i in range(N):
    for j in range(N):
        if(i<j):
            if(s[i]==s[j]):
                
                count += 1
print(count)

### FIXED CODE ###

N = int(input())
s = sorted(["".join(sorted((input()))) for i in range(N)])
count = 0

num=1
for i in range(N-1):
    if(s[i]==s[i+1]):
        num += 1
    elif(num>1):
        count += num*(num-1)/2
        num = 1
    
if(num>1):
    count += num*(num-1)/2
print(int(count))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
d = {}

def solve(N, M, A, cur, remain):
  if cur == N:
    return 0
  else:
    if not (cur, remain) in d:
      a = A[cur]
      tmp = 10**10
      for i in range(remain+1):
        tmp = min(tmp, solve(N, M, A, cur+1, remain-i)+a)
        if a / 2 < 0.5:
          break
        a //= 2
      d[(cur, remain)] = tmp
    return d[(cur, remain)]
n, m = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, m, a, 0, m))



### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = list(map(lambda x:[-int(x),int(x)], input().split()))
heapq.heapify(A)

for m in range(M):
  x = heapq.heappop(A)
  x[1] //= 2
  x[0] = -x[1]
  heapq.heappush(A, x)
ans = 0
for a in A:
  ans += a[1]
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
a = a*2
k = 0
b = []
for j in range(n):
  for i in range(j,j+n):
    k += (-1)**(i+2)*a[i]
  print(abs(k), end=" ")
  k = 0

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a = a*2
k = 0
for i in range(0,n):
  k += (-1)**(i+2)*a[i]
k = abs(k)
print(k,end=" ")
for i in range(0,n-1):
  y = 2*(a[i] - k/2)
  k = y
  print(int(y),end=" ")
### BUGGY CODE ###

import numpy as np

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

A_matrix = []
for i in range(N):
    m = [0] * N
    if i != N - 1:
        m[i] = m[i+1] = 0.5
    else:
        m[i] = m[0] = 0.5
    A_matrix.append(m)

A_matrix = np.array(A_matrix)
A = A.T
A_inv = np.linalg.inv(A_matrix)
ans = np.dot(A_inv, A)
print(" ".join(str(int(n)) for n in ans))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
X = [0] * N
X[0] = sum(A) - 2*(sum(A[1::2]))
for i in range(1, N):
    X[i] = 2*A[i-1] - X[i-1]
print(' '.join(str(x) for x in X))
### BUGGY CODE ###

import  collections 
N = int(input())
list_a = []

for i in range (0,N):
    a = input()
    list_a.append(a)
dict_a = collections.Counter(list_a)


list_ans = []

list_ans.append(dict_a.most_common()[0][0])
for i in range (1,len(dict_a)):
    if dict_a.most_common()[0][1] == dict_a.most_common()[i][1]:
        list_ans.append(dict_a.most_common()[i][0])

list_ans.sort()
for i in range (0,len(list_ans)):
    print(list_ans[i])

### FIXED CODE ###

N = int(input())
S = [input() for i in range(N)]
dictionary = {}
for word in S:
    if word in dictionary:
        dictionary[word] += 1
    else:
        dictionary[word] = 1

maximum = max(dictionary.values())
for key, value in sorted(dictionary.items()):
    if value == maximum:
        print(key)