Harryxun/stf_run huggingface dataset:
n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append([b,i])

ans = [None]*(n-1)
def rec(cur,color):
    cnt = 1
    for (to, j) in G[cur]:
        if cnt == color:
            cnt += 1
        ans[j] = cnt
        rec(to, cnt)
        cnt += 1
rec(0, 0)
print(max(ans))
print(*ans, sep="\n")

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append([b,i])

ans = [None]*(n-1)
def rec(cur,color):
    cnt = 1
    for (to, j) in G[cur]:
        if cnt == color:
            cnt += 1
        ans[j] = cnt
        rec(to, cnt)
        cnt += 1
rec(0, 0)
print(max(ans))
print(*ans, sep="\n")
n = int(input())
XYH = list(tuple(map(int, input().split())) for _ in range(n))

for i in range(n):
    if XYH[i][2] == 0:
        del XYH[i]

for cx in range(0, 101):
    for cy in range(0, 101):

        x, y, h = XYH[0]
        H = abs(x-cx) + abs(y-cy) + h

        if all([H == abs(x-cx) + abs(y-cy) + h for x, y, h in XYH]):
            print(cx, cy, H)
            exit()

### FIXED CODE ###

n = int(input())
XYH = list(tuple(map(int, input().split())) for _ in range(n))

# h != 0であるデータを取得
for x, y, h in XYH:
    if h != 0:
        x_, y_, h_ = x, y, h
        break

for cx in range(0, 101):
    for cy in range(0, 101):

        H = abs(x_ - cx) + abs(y_ - cy) + h_

        if all([max(H - abs(x - cx) - abs(y - cy), 0) == h for x, y, h in XYH]):
            print(cx, cy, H)
            exit()
import heapq
n,m = map(int,input().split())
a=  list(map(int,input().split()))
h = list(map(lambda x:-1*x,a))
heapq.heapify(h)
for i in range(m):
    heapq.heapreplace(h,-(-h[0]//2))
    print(h)

### FIXED CODE ###

import heapq
n,m = map(int,input().split())
a=  list(map(int,input().split()))
h = list(map(lambda x:-1*x,a))
heapq.heapify(h)
for i in range(m):
    heapq.heapreplace(h,-(-h[0]//2))
print(-1*sum(h))
n = int(input())
x = list(input())

def popcount(n):
    bin_n = bin(n)[2:]
    count = 0
    for i in bin_n:
        count += int(i)
    return count

cnt = popcount(int(''.join(x), base=2))

dic = {}
for i in range(n):
    temp = x[:]
    if temp[i] == '0':
        temp[i] = '1'
        cnt_temp = cnt + 1
    else:
        temp[i] = '0'
        cnt_temp = cnt - 1
    temp = ''.join(temp)
    num = int(temp, base=2)
    num = num % cnt_temp
    lst = [num]
    ans = 1
    while num != 0:
        if num in dic:
            ans += dic[num]
            for i in range(len(lst)):
                dic[lst.pop()] = dic[num] + i
            break
        ans += 1
        num = num%popcount(num)
        lst.append(num)
    for i in range(len(lst)):
        dic[lst.pop()] = i
    print(ans)

### FIXED CODE ###

n = int(input())
x = list(input())

def popcount(n):
    bin_n = bin(n)[2:]
    count = 0
    for i in bin_n:
        count += int(i)
    return count

cnt = 0
for i in range(n):
    if x[i] == '1':
        cnt += 1

lst = [0 for i in range(n+1)]
for i in range(1, n+1):
    num = i%popcount(i)
    lst[i] = lst[num] + 1

plus = [0 for i in range(n)]
minus = [0 for i in range(n)]
plus[0] = 1
if cnt != 1:
    minus[0] = 1
for i in range(1, n):
    plus[i] = (plus[i-1]*2) % (cnt+1)
    if cnt != 1:
        minus[i] = (minus[i-1]*2) % (cnt-1)

origin = int(''.join(x), base=2)
amariplus = origin % (cnt+1)
if cnt != 1:
    amariminus = origin % (cnt-1)

for i in range(n):
    if x[i] == '0':
        amari = (amariplus + plus[n-i-1]) % (cnt+1)
        print(lst[amari] + 1)
    else:
        if cnt != 1:
            amari = (amariminus - minus[n-i-1]) % (cnt-1)
            print(lst[amari] + 1)
        else:
            print(0)
from math import gcd 

N, X = map(int, input().split())
x = list(map(int, input().split()))
ans = abs(X - x[0])
for i in range(1, N):
    ans = gcd(ans, abs(x[i - 1] - x[i]))

print(ans)

### FIXED CODE ###

from fractions import gcd 

N, X = map(int, input().split())
x = list(map(int, input().split()))
ans = abs(X - x[0])
for i in range(1, N):
    ans = gcd(ans, abs(x[i - 1] - x[i]))

print(ans)
from collections import Counter
x,n = map(int,input().split())
p = list(map(int,input().split()))

num_list = list(range(1,101))
y = (num_list + p)

counter = Counter(y)
result =  [elem for elem in y if counter[elem] < 2]
#print(result)

ans = 10 *100000000000

for i in result:
    temp = abs(i - x)
    if ans > temp:
        ans = temp
        res = i
print(res)


### FIXED CODE ###

from collections import Counter
x,n = map(int,input().split())
p = list(map(int,input().split()))

num_list = list(range(-200,201))
y = (num_list + p)

counter = Counter(y)
result =  [elem for elem in y if counter[elem] < 2]


ans = 10 *100000000000

for i in result:
    temp = abs(i - x)
    if ans > temp:
        ans = temp
        res = i
print(res)
n = input().split()
res = list(map(int, num))
if sum(result) >= 22:
    print('bust')
else:
    print('win')

### FIXED CODE ###

n = input().split()
res = list(map(int, n))
if sum(res) >= 22:
    print('bust')
else:
    print('win')
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

x = I()

As = []
Bs = []

for i in range(64):
  n = i ** 5
  As.append(n)
  Bs.append(n)
  Bs.append(-n)

xs = [(a, x-a) for a in As]
for x in xs:
  if x[1] in Bs:
    print(x[0], -int(pow(x[1], 1/5)))
    break


### FIXED CODE ###

import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

x = I()

A = []
As = []
B = []
Bs = []

for i in range(250):
  n = i ** 5
  A.append(i)
  As.append(n)
  B.append(i)
  Bs.append(n)
  B.append(-i)
  Bs.append(-n)

xs = [a-x for a in As]
for i, x in enumerate(xs):
  if x in Bs:
    print(A[i], B[Bs.index(x)])
    break
from collections import defaultdict

def DFS(u,G,H,A,visited,P):
    visited[u]=True
    for v in G[u]:
        if not (min(u,v),max(u,v)) in P:
            if H[u-1]>H[v-1]:
                    A[u]+=1
            elif H[v-1]>H[u-1]:
                    A[v]+=1
            P.add((min(u,v),max(u,v)))
        if not visited[v]:
            DFS(v,G,H,A,visited,P)

def DFSUtil(G,H,N):
    visited=[False]*(N+100)
    A=[0]*(N+100)
    P=set()
    for u in G:
        if (not visited[u]):
            DFS(u,G,H,A,visited,P)
    return A
N,M=map(int,input().strip().split())
H=list(map(int,input().strip().split()))
G=defaultdict(list)

for i in range(M):
    u,v=map(int,input().strip().split())
    G[u].append(v)
    G[v].append(u)
A=DFSUtil(G,H,N)
cnt=0
for i in range(1,N+1):
    neighbours=len(list(set(G[i])))
    if neighbours==A[i]:
        cnt+=1
print(cnt)

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(100000000)
def DFS(u,G,H,A,visited,P):
    visited[u]=True
    for v in G[u]:
        if not (min(u,v),max(u,v)) in P:
            if H[u-1]>H[v-1]:
                    A[u]+=1
            elif H[v-1]>H[u-1]:
                    A[v]+=1
            P.add((min(u,v),max(u,v)))
        if not visited[v]:
            DFS(v,G,H,A,visited,P)

def DFSUtil(G,H,N):
    visited=[False]*(N+1)
    A=[0]*(N+1)
    P=set()
    for u in G:
        if (not visited[u]):
            DFS(u,G,H,A,visited,P)
    return A
N,M=map(int,input().strip().split())
H=list(map(int,input().strip().split()))
G=defaultdict(list)

for i in range(M):
    u,v=map(int,input().strip().split())
    G[u].append(v)
    G[v].append(u)
A=DFSUtil(G,H,N)
cnt=0
for i in range(1,N+1):
    neighbours=len(list(set(G[i])))
    if neighbours==A[i]:
        cnt+=1
print(cnt)
import heapq as hq
m=input()
hq.heapify(a:=[-int(x) for x in input().split()])
for i in range(int(m[2])):hq.heappush(a,-(v:=-hq.heappop(a)//2))
print(-sum(a))

### FIXED CODE ###

import heapq
n,m = map(int,input().split())
a = list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)
for i in range(m):
  maxv = heapq.heappop(a)*(-1)
  heapq.heappush(a,(maxv//2)*(-1))
print(sum(a)*(-1))
n, x = (int(i) for i in input().split())
l = [[int(i) for i in input().split()] for i in range(n)]

dis = 0

for i in range(n):
  dis += l[i]
  if dis > x:
    print(i + 1)
    break
    

### FIXED CODE ###

n, x = (int(i) for i in input().split())

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

dis = 0
cnt = 1

for i in range(n):
	dis += l[i]
	cnt += 1
	if dis > x:
		cnt += -1
		break
        
print(cnt)
A = int(input())
B = int(input())

print(max(A+B,A-B,A*B))

### FIXED CODE ###

A,B = list(map(int,input().split()))
 
print(max(A+B,A-B,A*B))
N,K = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)

P = []
M = []
Ans = []
p = 0
m = 0

for i in range(N):
    if 0 <= A[i]:
        P.append(A[i])
    else:
        M.append(A[i])

M.sort()

if K % 2 == 1 and len(P) != 0:
    Ans.append(P[p])
    p += 1
elif K % 2 == 1 and len(P) == 0:
    M.sort(reverse=True)
elif len(M) == 0:
    answer = 1
    for i in range(K):
        answer = (answer * P[i]) % 1000000007

    print(answer)

while len(Ans) < K:

    #Mのストックがもうない時
    if m+1 >= len(M):
        Ans.append(P[p])
        if len(Ans) == K:
            break
        Ans.append(P[p + 1])
        p += 2
    elif p+1 >= len(P):
        Ans.append(M[m])
        if len(Ans) == K:
            break
        Ans.append(M[m + 1])
        m += 2
    else:
        if P[p]*P[p+1] < M[m]*M[m+1]:
            Ans.append(M[m])
            Ans.append(M[m+1])
            m += 2
        else:
            Ans.append(P[p])
            Ans.append(P[p + 1])
            p += 2

answer = 1
for i in range(K):
    answer = (answer * Ans[i]) % 1000000007

print(answer)


### FIXED CODE ###

import sys

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

A.sort(reverse=True)

P = []
M = []
Ans = []
p = 0
m = 0

for i in range(N):
    if 0 <= A[i]:
        P.append(A[i])
    else:
        M.append(A[i])

M.sort()

if K % 2 == 1 and len(P) != 0:
    Ans.append(P[p])
    p += 1
elif K % 2 == 1 and len(P) == 0:
    M.sort(reverse=True)
elif len(M) == 0:
    answer = 1
    for i in range(K):
        answer = (answer * P[i]) % 1000000007

    print(answer)
    sys.exit()

while len(Ans) < K:

    #Mのストックがもうない時
    if m+1 >= len(M) and p < len(P):
        Ans.append(P[p])
        if len(Ans) == K:
            break
        if p + 1 < len(P):
            Ans.append(P[p + 1])
            p += 2
        else:
            p += 1
        
    elif p+1 >= len(P) and m < len(M):
        Ans.append(M[m])
        if len(Ans) == K:
            break
        Ans.append(M[m + 1])
        m += 2
    elif m >= len(M) and p < len(P):
        Ans.append(P[p])
        p += 1
    elif p >= len(P) and m < len(M):
        Ans.append(M[m])
        m += 1
    else:
        if P[p]*P[p+1] < M[m]*M[m+1]:
            Ans.append(M[m])
            Ans.append(M[m+1])
            m += 2
        else:
            Ans.append(P[p])
            Ans.append(P[p + 1])
            p += 2

answer = 1
for i in range(K):
    answer = (answer * Ans[i]) % 1000000007

print(answer)
N=int(input())
A=tuple(map(int,input().split()))

a=[0]*N

for i in range(N):
    a[A[i]]=i+1

print(" ".join(map(str,a)))

### FIXED CODE ###

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

a=[0]*N

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

print(" ".join(map(str,a)))
n = int(input())
x = list( map(int,input().split()) )

#print(max(x),min(x))

min_hp = 1000000000000000
for p in range(min(x),max(x)+1):
    hp = 0
    for i in x:
        hp +=(i-p)**2
        # print(p,i,hp)
    if min_hp > hp:
        min_hp = hp

print(min_hp)

### FIXED CODE ###

input= list( map(int,input().split()) )
n = input[0]
r=  input[1]

if n<10:
    print(r + (100 * (10-n)) )
else:
    print(r)
K = input()
S = input()
if len(s) > int(k):
  print(s[:k]+'...')
else:
  print(s)

### FIXED CODE ###

K = int(input())
S = input()
if len(S) > K:
	print(S[:K] + '...')
else:
	print(S)
A,B,C,D = map(int,input().split())
if B>=C:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

K= int(input())
print('ACL'*K)
S = input()
 
ans = 0
if S == 'RRR': ans = 3
else:
  if ('RR' in S) ans = 2
  else:
    if('R' in S) ans = 1
    else: ans = 0

print(ans)

### FIXED CODE ###

S = input()
 
ans = 0
if S == 'RRR': ans = 3
else:
  if ('RR' in S): ans = 2
  else:
    if('R' in S): ans = 1
    else: ans = 0
 
print(ans)
# import logging

# logger = logging.getLogger(__name__)
# logger.setLevel(logging.INFO)
# h = logging.FileHandler("logtest.log")
# logger.addHandler(h)

N, Q = map(int, input().split())
S = list(map(str, input().strip()))
# logger.info("S: {}".format(S))

order = [tuple(map(str, input().split())) for _ in range(Q)]
order = order[::-1]
# logger.info("order: {}".format(order))

# left: 左に落ちるゴーレム
# right: 右に落ちるゴーレム
#  N-right-left: 生き残るゴーレム
left, right = 0, N - 1
# logger.info("left: {}, right: {}".format(left, right))

# 二分探索
for a in order:
    t, d = a[0], a[1]
    # logger.info("t: {}, d: {}".format(t, d))
    # logger.info("[before] left: {}, right: {}".format(left, right))

    if d == "L":
        if S[left] == t:
            left += 1
            if left > N - 1:
                pass

        if right < N - 1 and S[right + 1] == t:
            right = min(N - 1, right + 1)

    else:
        if left > 0 and S[left - 1] == t:
            left = max(0, left - 1)

        if S[right] == t:
            right -= 1
            if right < 0:
                pass

    # logger.info("[after] left: {}, right: {}\n".format(left, right))


print(right - left + 1)


### FIXED CODE ###

# N, Q = map(int, input().split())
import sys

input = sys.stdin.readline

N, Q = tuple(map(int, input().split()))
s = input()

Query = [input().split() for i in range(Q)]

left, right = 0, N - 1

for t, d in reversed(Query):
    if d == "L":
        if t == s[left]:
            left += 1
        if right < N - 1 and t == s[right + 1]:
            right = min(right + 1, N - 1)
    else:
        if left > 0 and t == s[left - 1]:
            left = max(left - 1, 0)
        if t == s[right]:
            right -= 1
print(max(right - left + 1, 0))
import math

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


def caluclate(a, b, c, d):

    s1 = 2 if a / c < 2 else int(a / c)
    s2 = 2 if b / c < 2 else int(b / c)
    s3 = 2 if a / d < 2 else int(a / d)
    s4 = 2 if b / d < 2 else int(b / d)



    m1 = s2 - s1 + 1
    m2 = s4 - s3 + 1
    m3 = 0
    common = smallestCommon(c,d)
    commonB = common / c

    m3 = (s2 //commonB) - (s1 // commonB)

    return int(b - a + 1 - (m1 + m2 - m3))


S = input().split(" ")
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

result = caluclate(A,B,C,D)

print(result)


### FIXED CODE ###

import fractions
def smallestCommon(a,b):
    return a*b/fractions.gcd(a,b)

def caluclate(a, b, c, d):

    s1 = (a - 1) // c
    s2 = (a - 1) // d

    m1 = s2 + s1

    s3 = b // c
    s4 = b // d

    m2 = s4 + s3

    common = int(smallestCommon(c,d))

    m3 = (b // common) - (a-1)//common

    total = int(b - a + 1)

    return total - (m2 - m1 - m3)


S = input().split(" ")
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

result = caluclate(A,B,C,D)

print(result)
N = input()
a = int(N[0])
b = int(N[1])
c = int(N[2])
d = int(N[3])

if a+b+c+d == 7:
	print('{0}+{1}+{2}+{3}=7' .format(a,b,c,d))
	
if a-b+c+d == 7:
	print('{0}-{1}+{2}+{3}=7' .format(a,b,c,d))

if a+b-c+d == 7:
	print('{0}+{1}-{2}+{3}=7' .format(a,b,c,d))

if a+b+c-d == 7:
	print('{0}+{1}+{2—{3}=7' .format(a,b,c,d))

if a-b-c+d == 7:
	print('{0}-{1}-{2}+{3}=7' .format(a,b,c,d))
	
if a+b-c-d == 7:
	print('{0}+{1}-{2}-{3}=7' .format(a,b,c,d))

	

### FIXED CODE ###

N = input()
a = int(N[0])
b = int(N[1])
c = int(N[2])
d = int(N[3])

if a+b+c+d ==7:
	print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
	
elif a-b+c+d ==7:
	print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
	
elif a-b-c+d ==7:
	print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
	
elif a+b+c-d ==7:
	print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
	
elif a+b-c-d ==7:
	print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
	
elif a-b+c-d ==7:
	print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
	
elif a+b-c+d ==7:
	print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')

elif a-b-c-d ==7:
	print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
N, M = map(int, input().split())
left=0
right=N

for i in range(N):
    L, R = map(int, input().split())
    if L > left:
        left = L
    if R < right:
        right = R

if left <= right:
    print(right-left+1)
else:
    print(0)

### FIXED CODE ###

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

left = []
right= []

for i in range(M):
    L, R = map(int, input().split())
    left.append(L)
    right.append(R)

l = max(left)
r = min(right)

if l <= r:
    print(r-l+1)
else:
    print(0)
a= int(input())
b= int(input())
c= int(input())
if(a+b+c)>=22:
    print("bust")
else:
    print("win")

### FIXED CODE ###

a = [int(i) for i in input().split(" ")]
print("bust") if sum(a) >= 22 else print("win")
x=int(input())
a,b=map(int,input().split())
if x == 1:
  print('Hello World')
else:
  print(int(a+b))


### FIXED CODE ###

x=int(input())
if x == 1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)
#引数が非負ならそのまま、負なら0を返す
def ramp(t):
    if t >= 0:
        return t
    else:
        return 0
def heav(t):
    if t >= 0:
        return(1)
    else:
        return(0)
N,W = map(int,input().strip().split(" "))
lst = []
for i in range(N):
    l = list(map(int,input().strip().split(" "))) #[v,w]の順で格納
    lst.append(l)
table = [[0 for c in range(W+1)] for i in range(N+1)]
for i in range(1,N+1):
    for c in range(1,W+1):
        table[i][c] = max(table[i-1][c],table[i-1][sgn(c-lst[i-1][1])]+lst[i-1][0]*heav(c-lst[i-1][1]))
print(table[N][W])


### FIXED CODE ###

def ramp(t):
    if t >= 0:
        return t
    else:
        return 0
def heav(t):
    if t >= 0:
        return(1)
    else:
        return(0)
N,W = map(int,input().strip().split(" "))
lst = []
for i in range(N):
    l = list(map(int,input().strip().split(" ")))
    lst.append(l)
table = [[0 for c in range(W+1)] for i in range(N+1)]
for i in range(1,N+1):
    for c in range(1,W+1):
        table[i][c] = max(table[i-1][c],table[i-1][ramp(c-lst[i-1][1])]+lst[i-1][0]*heav(c-lst[i-1][1]))
print(table[N][W])
S = input()

f = int(S[0]+S[1])
s = int(S[2]+S[3])

if f >= 1 and f <= 12 and s >= 1 and s <= 12:
  print('AMBIGUOUS')
elif f >= 1 and f <=12 and (s >= 13 or s == 0):
  print('MMYY')
elif (f >= 13 or f == 0 and s >= 1 and s <= 12:
  print('YYMM')
else:
  print('NA')
  

### FIXED CODE ###

S = input()

f = int(S[0]+S[1])
s = int(S[2]+S[3])

if f >= 1 and f <= 12 and s >= 1 and s <= 12:
  print('AMBIGUOUS')
elif f >= 1 and f <=12 and (s >= 13 or s == 0):
  print('MMYY')
elif (f >= 13 or f == 0) and s >= 1 and s <= 12:
  print('YYMM')
else:
  print('NA')
from numpy import cumsum

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

all = sum(L)
cum = list(cumsum(L))

ans = float('inf')
for i in range(N-1):
    tmp = abs(cum[i]-(all-cum[i]))
    ans = min(ans, tmp)
print(ans)

### FIXED CODE ###

from numpy import cumsum

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

all = sum(L)
cum = list(cumsum(L))

ans = float('inf')
for i in range(N-1):
    tmp = abs(cum[i]-(all-cum[i]))
    ans = min(ans, tmp)
print(ans)
import numpy as np
 
N, K, Q = map(int, input().split())
 
points = np.array([K for _ in range(N)])
 
for q in range(Q):
    A = int(input()) - 1
    points -= 1
    points[A] += 1
 
[print('Yes') if p > 0 else print('No') for p in points]

### FIXED CODE ###

import numpy as np
import sys
def input():
    return sys.stdin.readline()[:-1]

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

points = np.array([K - Q for _ in range(N)])

for q in range(Q):
    A = int(input()) - 1
    points[A] +=1

for p in points:
    if p < 1:
        print('No')
    else:
        print('Yes')
from sys import stdin

N, M, *A = map(int, stdin.read().split())
req = {1: 2,
       2: 5,
       3: 5,
       4: 4,
       5: 5,
       6: 6,
       7: 3,
       8: 7,
       9: 6}

B = sorted([(a, req[a]) for a in A], key=lambda x: x[0], reverse=True)
a_min, n_min = min(B, key=lambda x: x[1])
g = [(a, n-n_min) for a, n in B if a > a_min and n > n_min]
l = [(a, n-n_min) for a, n in B if a < a_min and n > n_min][::-1]
l.sort(key=lambda x: x[1], reverse=True)

def dp(rem, C):
    ret = None
    if rem == 0:
        ret = []
    elif rem > 0:
        for a, m in C:
            nxt = dp(rem-m, C)
            if nxt is not None:
                ret = [a] + nxt
                break
    return ret


lst = dp(N % n_min, g + l)
lst = sorted(lst + [a_min] * (N//n_min - len(lst)), reverse=True)
print(''.join(map(str, lst)))

### FIXED CODE ###

from sys import stdin

N, M, *A = map(int, stdin.read().split())
req = {1: 2,
       2: 5,
       3: 5,
       4: 4,
       5: 5,
       6: 6,
       7: 3,
       8: 7,
       9: 6}

B = sorted([(a, req[a]) for a in A], key=lambda x: x[0], reverse=True)
a_min, n_min = min(B, key=lambda x: x[1])
g = [(a, n-n_min) for a, n in B if a > a_min and n > n_min]
l = [(a, n-n_min) for a, n in B if a < a_min and n > n_min]
l.sort(key=lambda x: x[1], reverse=True)
C = g + l

def dp(rem, C):
    ret = None
    if rem == 0:
        ret = []
    elif rem > 0:
        for i in range(len(C)):
            a, m = C[i]
            nxt = dp(rem-m, C[i:])
            if nxt is not None:
                ret = [a] + nxt
                break
    return ret


i = 0
while True:
    quo = N // n_min - i
    rem = N % n_min + i * n_min
    lst = dp(rem, C)
    if lst is not None:
        lst = sorted(lst + [a_min] * (quo-len(lst)), reverse=True)
        print(''.join(map(str, lst)))
        break
    i += 1
n = int(input())
s = input()
x = 0
l = [0]
for i in range(n):
  if s[i] == "I":
    x += 1
  	l.append(x)
  else:
    x -= 1
    l.append(x)
print(max(l))

### FIXED CODE ###

n = int(input())
s = input()
x = 0
l = [0]
for i in range(n):
  if s[i] == "I":
    x += 1
    l.append(x)
  else:
    x -= 1
    l.append(x)
print(max(l))
N = int(input())
cnt_s = {}
for _ in range(N):
  s = input()
  if s in cnt_s:
    cnt_s[s] += 1
  else:
    cnt_s[s] - 1
  
max_cnt = max(cnt_s.values())

ans = []
for key, value in cnt_s.items():
  if value == max_cnt:
    ans.append(key)
  
[print(s) for s in sorted(ans)]

### FIXED CODE ###

import sys
from collections import defaultdict

N = int(sys.stdin.readline())
A = defaultdict(int)
for _ in range(N):
    s = sys.stdin.readline().strip()
    A[s] += 1

max_cnt = max(A.values())
ans = []
for key in A:
    if A[key] == max_cnt:
        ans.append(key)
ans.sort()
[print(s) for s in ans]