Harryxun/stf_run huggingface dataset:
N=int(input())
A=[0 for _ in range(N)]
G=[[] for i in range(N)]
F=[0 for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  a-=1;b-=1
  G[a].append(b)
  G[b].append(a)
  
root=[]
def dp(s):
  flag=0
  F[s]=1
  l=1
  for n in G[s]:
    if F[n]==0:
      i,j=dp(n)
      l+=i
      if j==1:
        flag=1
      
  A[s]=l
  if s==N-1:
    flag=1
  if flag==1:
    root.append(s)
  return l,flag
  
dp(0)
#print(A,root)

m=root[::-1][len(root)//2+len(root)%2-1]
scoreA=A[0]-A[m]+1
scoreB=N-scoreA
#print(scoreA,scoreB,m)

if scoreA>scoreB:
  print("Fennec")
else:
  print("Snuke")

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
N=int(input())
G=[[] for i in range(N)]
F=[0 for i in range(N)]
A=[]
for i in range(N-1):
  a,b=map(int,input().split())
  a-=1;b-=1
  G[a].append(b)
  G[b].append(a)
  A.append([a,b])
  
def dfs(s,R):
  F[s]=1
  
  if s==N-1:
    return [s]
  else:
    for n in G[s]:
      if F[n]==0:
        k=dfs(n,R)
        if len(k)!=0:
          k.append(s)
          return k
     
  return []
  
root=dfs(0,[])
#print(root[::-1])
p=root[::-1][len(root)//2+len(root)%2-1]
q=root[::-1][len(root)//2+len(root)%2]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(N) 
for i in range(N-1):
  a,b=map(int,A[i])
  if a==p and b==q:
    continue
  if a==q and b==p:
    continue
  uf.union(a, b)

scoreA=uf.size(0)
scoreB=N-scoreA
#print(scoreA,scoreB)

if scoreA>scoreB:
  print("Fennec")
else:
  print("Snuke")
import sys
sys.setrecursionlimit(2*10**5)

# input
N = int(input())
Tree = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    Tree[a-1].append(b-1)
    Tree[b-1].append(a-1)

# process
def f(i):
    if tg[i] == 0 and mod3[1] <= N:
        ans[i] = mod3[1]
        mod3[1] += 3
    elif tg[i] == 1 and mod3[2] <= N:
        ans[i] = mod3[2]
        mod3[2] += 3
    elif mod3[0] <= N:
        ans[i] = mod3[0]
        mod3[0] += 3
    else:
        ans.clear()

    g = (tg[i]+1)%2
    for p in Tree[i]:
        if p == i or tg[p] != -1:
            continue
        
        tg[p] = g
        if not f(p):
            return False
    
    return True

tg = [-1]*N
tg[0] = 0
ans = [0]*N
mod3 = [3, 1, 2]

f(0)

# output
# print(tg)

if len(ans) == 0:
    if tg.count(0) < 2 or N - tg.count(0) < 2:
        ans = [0]*N
        for i in range(0, N):
            ans[i] = i+1
    else:
        ans = [-1]

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


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
from collections import deque

# input
N = int(input())
Edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    Edges[a-1].append(b-1)
    Edges[b-1].append(a-1)

# process
# 頂点を2グループに分類
group = [-1]*N
group[0] = False
def categorize2g(pi, i, g):
    for ci in Edges[i]:
        if ci == pi:
            continue
        group[ci] = not g
        categorize2g(i, ci, not g)

categorize2g(-1, 0, 0)

# 順列を求める
ans = [0]*N
mod0 = [x for x in range(1, N+1) if x%3 == 0]
mod1 = [x for x in range(1, N+1) if x%3 == 1]
mod2 = [x for x in range(1, N+1) if x%3 == 2]
gtnum = sum(group)
if gtnum <= N//3:
    dq = deque(mod1+mod2+mod0)
elif N-gtnum <= N//3:
    dq = deque(mod0+mod1+mod2)
else:
    dq = deque(mod1+mod0+mod2)

if len(ans) == N:
    for i, g in enumerate(group):
        if g:
            ans[i] = dq.pop()
        else:
            ans[i] = dq.popleft()

# output
# print(group)
print(" ".join(map(str, ans)))
N,M=map(int, input().split())
A=list(map(int, input().split()))
A.index(max(A))
A.sort()
a=A.pop()
b=A.pop()
for i in range(M):
    if a>=b:
        a=a//2
    else:
        A.append(a)
        A.append(b//2)
        A.sort()
        a=A.pop()
        b=A.pop()
        
print(sum(A)+a+b)

### FIXED CODE ###

import heapq

N,M = map(int, input().split())
A = list(-int(i) for i in input().split()) 

heapq.heapify(A)

for i in range(M):
    x=heapq.heappop(A)//(-2)
    heapq.heappush(A, -x)

print(-sum(A))
n = input()
s = 0
a = input()
b = a.split(" ")
c = []
for i in range(n):
    c.append(int(b[i]))
for u in c:
    s=s+u

print(min(c),max(c),s)


### FIXED CODE ###

n = input()
s = 0
a = input()
b = a.split(" ")
c = []
for i in range(int(n)):
    c.append(int(b[i]))

for u in c:
    s=s+u

print(min(c),max(c),s)
n=int(input())
a=input()
b=[]
for i in range(n):
  b.append(a[i*2])
ave=sum(b)/n
if ave<int(ave)+0.5:
  ave=int(ave)
else:
  ave=int(ave)+1
ans=0
for i in range(n):
  ans+=(b[i]-ave)**2
print(ans)

### FIXED CODE ###

n=int(input())
a=[]
a=list(map(int,input().split()))
ave=sum(a)/n
if ave<int(ave)+0.5:
  ave=int(ave)
else:
  ave=int(ave)+1
ans=0
for i in range(n):
  ans+=(a[i]-ave)**2
print(ans)
import numpy as np

n = int(input())
arrA = np.array(input().split(),dtype=np.int64)

filter = (arrA % 2 == 0)
if len(arrA[filter])==0:
    ans == "APPROVED"
else:
    for i in arrA[filter]:
        if i%3==0 or i%5==0:
            ans = "APPROVED"
        else:
            ans = "DENIED"
            break

# APPROVED or DENIED
print(ans)

### FIXED CODE ###

import numpy as np

n = int(input())
arrA = np.array(input().split(),dtype=np.int64)

filter = (arrA % 2 == 0)
if len(arrA[filter])==0:
    ans = "APPROVED"
else:
    for i in arrA[filter]:
        if i%3==0 or i%5==0:
            ans = "APPROVED"
        else:
            ans = "DENIED"
            break

# APPROVED or DENIED
print(ans)
import math
A,B,C,D = [int(i) for i in input().split()]

l= C * D / math.gcd(C, D)

s=B - A + 1 - ((B//C - (A-1)//C)+(B//D - (A-1)//D)-(B//l))
print(int(s))


### FIXED CODE ###

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
abcd = input().split(" ")
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])
cd = lcm(c, d)
print(b-a-(b//c-((a-1)//c + 1))-(b//d - ((a-1)//d + 1))+(b//cd-((a-1)//cd + 1)))
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
for i in range(n):
    x[i], y[i], h[i] = map(int, input().split())

ans = []
for X in range(101):
    for Y in range(101):
        flag = True
        height = []
        for i in range(n):
            height.append(h[i]+abs(x[i]-X)+abs(y[i]-Y))
        for i in range(n):
            if height[i] != height[0]:
                flag = False

        if flag:
            ans.append(X)
            ans.append(Y)
            ans.append(height[0])
            break

print(ans[0], ans[1], ans[2])
            


### FIXED CODE ###

n = int(input())

x = [0] * n
y = [0] * n
h = [0] * n

for i in range(n):
    x[i], y[i], h[i] = map(int, input().split())

for cx in range(101):
    for cy in range(101):
        H = -1
        for i in range(n):
            if h[i] == 0:
                pass
            else:
                tmp = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
                H = tmp
                break
        flag = True
        for i in range(n):
            if h[i] != max(H-abs(x[i]-cx)-abs(y[i]-cy),0):
                flag = False
                break
        if flag:
            print(cx,cy,H)
S = input()
list_A = []
list_Z = []
for i in range(len(S)):
  if s[i] == 'A':
    list_A.append(i)
  if s[i] == 'Z':
    list_Z.append(i)
a = list_A[0]
z = list_Z[-1]
print(z - a + 1)

### FIXED CODE ###

S = input()
list_A = []
list_Z = []
for i in range(len(S)):
  if S[i] == 'A':
    list_A.append(i)
  if S[i] == 'Z':
    list_Z.append(i)
a = list_A[0]
z = list_Z[-1]
print(z - a + 1)
n,x=map(int,input().split())
a=[int(input()) for _ range(n)]
print(n+((x-sum(a))//min(a)))

### FIXED CODE ###

n,x=map(int,input().split())
a=list(int(input()) for _ in range(n))
print(n+((x-sum(a))//min(a)))
S = input()
T = input()
print(sum([1 if S[i]==T[i] else 0 for i in range(3)))

### FIXED CODE ###

S = input()
T = input()
print(sum([1 if S[i]==T[i] else 0 for i in range(3)]))
a = int(input())
if a == 1:
  print(Hello World)
else:
  list=[input() for i in range(2)]
  print(list[0]+list[1])

### FIXED CODE ###

a = int(input())
if a == 1:
  print('Hello World')
else:
  b=[int(input()) for i in range(2)]
  c=b[0]+b[1]


  print(c)
a = list(input())
b = list(input())

a.sort()
b.sort()

print("Yes" if "".join(a) <　"".join(b) else "No")

### FIXED CODE ###

a = list(input())
b = list(input())

a.sort()
b.sort(reverse=True)

a = "".join(a)
b = "".join(b)

print("Yes" if a < b else "No")
a = input()
b = 0
for i in range(len(a)):



### FIXED CODE ###

a = input()
a = str(a)
b = 0
for i in range(len(a)):
    if a[i]=="2":
        b=b+1
    else:
        b=b
print(b)
N = int(input())
s_list = []
count = 0
n, m, l = 0, 0, 0

for i in range(N):
  s = input()
  s_list.append(s)
  count += s.count('AB')
  if s[0] == 'B' and s[-1] == 'A':
    n += 1
    continue
  elif s[-1] == 'A':
    m += 1
  elif s[0] == 'B':
    l += 1

if n < m and n < l:
  print(int(count + 2 * n + min(m - n, l - n)))
elif n > m and n > l:
  print(int(count + 2 * (n - max(m, l) + m + l)
else:
  print(int(count + min(n, m) + min(n, l)))

### FIXED CODE ###

N, K = [int(x) for x in input().split(' ')]

output = N - K + 1

print(int(output))
fun main(args:Array<String>) {
var a = readLine()!!.toInt()
var b = a%1000
  if (b==0) {
  println(0)
  }else{
  println(1000-b)
}
}

### FIXED CODE ###

a=int(input())%1000
if a==0:
  print(0)
else:
  print(1000-a)
x=int(input())


if x>0:
    if x%11>=6:
        ans=(x//11)*2+2

    elif 1<=x%11<=5:
        ans=(x//11)*2+1


print(ans)

### FIXED CODE ###

x = int(input())
 
ans = (x//11)*2
remainder = x%11
if remainder == 0:
    print(ans)
elif 1 <= remainder <= 6:
    print(ans+1)
else:
    print(ans+2)
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    for i in range(n, 0, -1):
        sqrt = np.sqrt(i)
        if sqrt - int(sqrt) == 0:
            print(i)
            break


if __name__ == '__main__':
    main()


### FIXED CODE ###

# utf-8:
import math as np


def main():
    n = int(raw_input())
    a = int(np.sqrt(n))
    print(a * a)


if __name__ == '__main__':
    main()
from math import gcd
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
if k>A[-1]:
    print('IMPOSSIBLE')
else:
    a=A[0]
    for i in range(n):
        a=gcd(a,A[i])
    if a==1:
        print('POSSIBLE')
    else:
        if k%a==0:
            print('POSSIBLE')
        else:
            print('IMPOSSIBLE')

### FIXED CODE ###

from fractions import gcd
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
if k>A[-1]:
    print('IMPOSSIBLE')
else:
    a=A[0]
    for i in range(n):
        a=gcd(a,A[i])
    if a==1:
        print('POSSIBLE')
    else:
        if k%a==0:
            print('POSSIBLE')
        else:
            print('IMPOSSIBLE')
a=[]
for i in range(5):
    a.append(int(input()))
ans=0
min=10
minn=0
for i in range(5):
    if a[i]%10<=min and a[i]%10!=0:
        min=a[i]%10
        minn=i
for i in range(5):
    if a[i]%10!=0:
        b=(a[i]//10)
        ans=ans+b*10+10
    else if a[i]=0:
        ans+=10
    else:
        ans=ans+a[i]
print(ans-(10-a[minn]%10))


### FIXED CODE ###

a=[]
for i in range(5):
    a.append(int(input()))
ans=0
min=10
minn=0
for i in range(5):
    if (a[i]%10<=min and a[i]%10!=0):
        min=a[i]%10
        minn=i
for i in range(5):
    if a[i]%10!=0:
        b=(a[i]//10)
        ans=ans+b*10+10
    elif a[i]==0:
        ans+=10
    else:
        ans=ans+a[i]
if min!=10:
    print(ans-(10-a[minn]%10))
else:
    print(ans)
n = int( raw_input( ) )
eles = []
for i in range( n ):
	op = raw_input( ).split( " " )
	if "insert" == op[0]:
		eles.insert( 0, op[1] )
	elif "delete" == op[0]:
		eles.remove( op[1] )
	elif "deleteFirst" == op[0] :
		del eles[0]
	elif "deleteLast" == op[0]:
		eles.pop( )

print( " ".join( eles ) )

### FIXED CODE ###

import sys
from collections import deque

n = int( sys.stdin.readline( ) )
que = deque( )
lines = sys.stdin.readlines()
for line in lines:
	op = line.rstrip().split( " " )
	if "insert" == op[0]:
		que.appendleft( op[1] )
	elif "delete" == op[0]:
		if op[1] in que:
			que.remove( op[1] )
	elif "deleteFirst" == op[0] :
		que.popleft( )
	elif "deleteLast" == op[0]:
		que.pop( )


print( " ".join( que ) )
import sys
import numpy as np

N, M = input().split()

N = int(N)
M = int(M)

A = np.zeros([2,M])

cnt = 0

for i in range(M):
    A[:,i] = input().split()

A = np.array(A,dtype=np.int64)


NM = np.zeros([M,N])

for i in range(M):
    NM[i,A[0,i]-1:A[1,i]] = 1.0


s = np.sum(NM,axis=0)

print(np.sum(s==M))

### FIXED CODE ###

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

left = 1
right = N

for l, r in LR:
    left = max(left, l)
    right = min(right, r)

ans = right - left

print(ans + 1 if ans >= 0 else 0)
a,b = int(input())


if a<10 or b<10:
    print(-1)
else:
    print(a*b)

### FIXED CODE ###

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

if a<10 and b<10:
    print(a*b)
else:
    print(-1)
a,b = map(int, input().split())
c = 1
if b == 1:
  ans = 0
else:
  for i in range(11):
    c = c-1 + a
    if c >= b:
      ans = i + 1
      break
print(ans)

### FIXED CODE ###

a,b = map(int, input().split())
c = 1
ans = 0
if b == 1:
  ans = 0
else:
  for i in range(21):
    c = c-1 + a
    if c >= b:
      ans = i + 1
      break
print(ans)
length = input()
a_list = list(map(int, input().split()))
 
for i in range(length):
  if i == (length - 1):
    break
  elif (a_list[i+1] - a_list[i]) >1 :
    a_list[i+1] += 1 
  elif a_list[i+1] >= 1 :
    continue
  elif a_list[i+1] < a_list[i]:
    print("No")
    break



### FIXED CODE ###

length = input()
a_list = list(map(int, input().split()))
 
for i in range(len(a_list)-1):
  if a_list[i] < a_list[i+1]:
    a_list[i+1] -= 1
  elif a_list[i] > a_list[i+1]:
    print("No")
    exit()
    
print('Yes')
a,b,c = map(int,input().split())
if b+C > a:
  print((b+c)-a)
else:
  print("0")

### FIXED CODE ###

a,b,c = map(int,input().split())
if b+c > a:
  print(b+c-a)
else:
  print("0")
# input
n, q = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(n-1)]
PX = [tuple(map(int, input().split())) for _ in range(q)]

# other_setting
child = [0] * n
parent = [0] * n
value = [0] * n

for i in range(n) : 
    child[i] = []

for a, b in AB : 
    child[a-1].append(b)
    parent[b-1] = a

# op_function
def op(a) : 
    if a != 1 : 
        value[a-1] += value[parent[a-1]-1]

    if child[a-1] != [] : 
        for c in child[a-1] : 
            op(c)
            
# initial_state(value)
for p, x in PX : 
    value[p-1] += x
    
# exe
op(1)

print(*value)

### FIXED CODE ###

a = int(input())
s = input()

if a < 3200 : 
    print("red")
else : 
    print(s)
N = int(input())
if N%2==0 or N%3==0 or N%5==0 or N%7==0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A,B=map(int,input().split())
if 1<= A <= 9 and 1<= B <= 9:
    print(A*B)
else:
    print("-1")
N,M = map(int,input().split())
f = []
for i in range(M):
    A,B = map(int,input().split())
    a = {A,B}
    for i in range(len(f)):
        if f[i] & a != set():
            f[i] = f[i] | a
            a = set()
    if a != set():
        f.append(a)
count = 1
while count > 0:
    count = 0
    for i in range(len(f)-1):
        for j in range(i+1,len(f)):
            if f[i] & f[j] != set():
                count += 1
                f[i] = f[i] | f[j]
                f.remove(f[j])
for i in range(len(f)):
    f[i] = len(f[i])
print(max(f))

### FIXED CODE ###

N,M = map(int,input().split())
f = [[] for i in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    f[A-1].append(B-1)
    f[B-1].append(A-1)
from collections import deque
d = deque()
x = [-1]*N
for i in range(N):
    if x[i] == -1:
        x[i] = i
        d.append(f[i])
    while len(d) > 0:
        z = d.popleft()
        for j in z:
            if x[j] == -1:
                x[j] = i
                d.append(f[j])
import collections
ans = collections.Counter(x)
print(ans.most_common()[0][1])
s = list(input())
K = int(input())
character = 'zabcdefghijklmnopqrstuvwxyz'
limit = len(s) - 1

here = 0
while K:
    tmp = character.find(s[here])
    if tmp + K > 26:
        K -= 26 - tmp + 1
        s[here] = 'a'
    elif here == limit:
        s[here] = character[tmp + K]
        break
    here += 1

print(''.join(s))

### FIXED CODE ###

s = list(input())
K = int(input())
character = '0abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'
limit = len(s) - 1

here = 0
while K:
    tmp = character.find(s[here])
    if tmp == 1 and here != limit:
        here += 1
        continue

    if tmp + K > 26 and here != limit:
        K -= 26 - tmp + 1
        s[here] = 'a'
        here += 1
    elif here == limit:
        K %= 26
        s[-1] = character[tmp + K]
        break
    else:
        here += 1
print(''.join(s))
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
z=[]
for i in range(w):
  if i%2==0:
    for j in range(h):
      z.append([j,i])
  else:
    for j in range(h):
      z.append([h-j-1,i])
count=0
ans=[]
for i,(y,x) in enumerate(z):
  if a[y][x]%2!=0 and i<len(z):
    count+=1
    ans.append(i)
    a[z[i+1][0]][z[i+1][1]]+=1
print(count)
for i in ans:
  print(z[i][0]+1,z[i][1]+1,z[i+1][0]+1,z[i+1][1]+1)

### FIXED CODE ###

h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
z=[]
for i in range(w):
  if i%2==0:
    for j in range(h):
      z.append([j,i])
  else:
    for j in range(h):
      z.append([h-j-1,i])
count=0
ans=[]
for i,(y,x) in enumerate(z):
  if a[y][x]%2!=0 and i<len(z)-1:
    count+=1
    ans.append(i)
    a[z[i+1][0]][z[i+1][1]]+=1
print(count)
for i in ans:
  print(z[i][0]+1,z[i][1]+1,z[i+1][0]+1,z[i+1][1]+1)
N = int(input())
judge_list = []
judge = ['AC', 'WA', 'TLE', 'RE']
for i in range(N):
    judge_list.append(str(input()))
for k in judge:
    judge_dict[k] = judge_list.count(k)
print(f"AC x {judge_dict['AC']}")
print(f"WA x {judge_dict['WA']}")
print(f"TLE x {judge_dict['TLE']}")
print(f"RE x {judge_dict['RE']}")

### FIXED CODE ###

N = int(input())
judge_list = []
judge = ['AC', 'WA', 'TLE', 'RE']
judge_dict = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for i in range(N):
    judge_list.append(str(input()))
for k in judge:
    judge_dict[k] = judge_list.count(k)
print(f"AC x {judge_dict['AC']}")
print(f"WA x {judge_dict['WA']}")
print(f"TLE x {judge_dict['TLE']}")
print(f"RE x {judge_dict['RE']}")
A, B, K = map(int,input().split())
print(max(0, A - K), max(0,min(B, A + B - K)))

### FIXED CODE ###

S, T = map(str, input().split())
print(T + S)
A, B, K = map(int, input().split())
a=[]
b=[]
for i in range(A, A+K):
    a.append(i)
for i range(B-K+1, B+1):
    b.append(i)
print(set(a)|set(b))

### FIXED CODE ###

A, B, K = map(int, input().split())
list=[]
for i in range(A, A+K):
    if i < A+K and i <= B:
        list.append(i)
for i in range(B-K, B+1):
    if i > (B-K) and i >= A:
        list.append(i)
for i in sorted(set(list)):
    print(i)
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]
CD = [list(map(int,input().split())) for i in range(N)]

AB.sort()
CD.sort()

#print(AB)
#print(CD)

li = [[] for i in range(N)]

for i in range(N):
    ab = AB[i]
    for j in range(N):
        cd = CD[j]
        if ab[0] < cd[0] and ab[1] < cd[1]:
            li[i].append(cd)

#print(li)

newli = []
for i in range(N):
    if li[i] != []:
        newli.append(li[i])
    else:
        N -= 1

li = newli

ans = 0
while len(li) != 0:
    l = 1000
    
    for i in range(N):
        l = min(l,len(li[i]))

    for i in range(N):
        if len(li[i]) == l:
            rem = li[i].pop()
            li.remove(remli)
            N -= 1
            ans += 1
            break
    

    for j in range(N):
        if rem in li[j]:
            li[j].remove(rem)

    newli = []
    for i in range(N):
        if li[i] != []:
            newli.append(li[i])
        else:
            N -= 1

    li = newli

print(ans)


### FIXED CODE ###

N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]
CD = [list(map(int,input().split())) for i in range(N)]

AB.sort()
CD.sort()

#print(AB)
#print(CD)

ans = 0

for cd in CD:
    li = []
    for ab in AB:
        if ab[0] < cd[0] and ab[1] < cd[1]:
            li.append(ab)
    li.sort(key=lambda x: x[1])
    if len(li) != 0:
        AB.remove(li[-1])
        ans += 1

print(ans)
r,g,b = map(int,input().split())
n == r*100 + g*10 + b
if n % 4 = 0:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

r,g,b = map(int,input().split())
n = r*100 + g*10 + b
if n % 4 == 0:
    print('YES')
else:
    print('NO')
N = int(input())
A = list(map(int, input.split()))
 
def solve(N, A):
	if not A or A[0] != 1:
      print(-1)
      return
 
    prev = 1
    rt = 1
    for a in A[1:]:
        if a > prev * 2:
          print(-1)
          return
        rt += (prev * 2 - a) % (prev * 2)
        prev = a

    print(rt)
    
solve(N, A)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
  
def solve(N, A):
  
  if N == 0 and A[0] > 1 or N > 0 and A[0] > 0:
    print(-1)
    return

  total = sum(A[1:])
  #t = A[-1] + A[-2]
  par = 1 - A[0]
  rt = 1
  for i, a in enumerate(A[1:]):
    total -= a
    max_node = par * 2
    cur = max_node - a
    if cur < 0:
      print(-1)
      return
    cur = min(total, cur)
    #print(i+1, a, cur)
    rt += a
    if i + 1 < N:
      rt += cur
    par = cur  
   
  print(rt)
  
solve(N, A)
N, X = map(int, input().split(" "))
L = list(map(int, input().split(" ")))

ans=0

cur_X = 0
pos_N = 0
while cur_X <= X and pos_N <= N:
    cur_X += L[pos_N]
    pos_N += 1
    ans += 1

print(ans)

### FIXED CODE ###


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

ans = 1
cur_X = 0
pos_N = 0

for i in range(N):
    ans += 1
    cur_X += L[i]

    if cur_X > X:
        ans -= 1
        break

print(ans)
import math

A,B = [int(i) for i in input().split(" ")]

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

print(lcm(A,B))


### FIXED CODE ###

import fractions

A,B = [int(i) for i in input().split(" ")]

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

print(lcm(A,B))
N = int(input())
A = list(sorted(list(map(int, input().split()))))
# N = 2
# A = list(sorted([5,2,8,5,1,5]))
group = []
ret = 0
for a in A:
    print(A)
    group.append([A.pop(0), A.pop(), A.pop()])
for g in group:
    ret += list(sorted(g))[1]
print(ret)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
ret = 0
for n in range(N, N*3, 2):
    ret += A[n]
print(ret)