Harryxun/stf_run huggingface dataset:
#順番考えなくていいかとりあえず試す
m = int(input())
nm = []
for i in range(m):
    di,ci = map(int, input().split( ))
    nm.append((di,ci))
cnt = 0
tmp = 0
while nm:
    ci,di = nm.pop()
    if di>100:
        tmpy = 1
        tmpz = 1
        tmpx = ci*2
        if tmpx>=10:
            tmpx = str(tmpx)
            tmp2 = int(tmpx[0])+int(tmpx[1])
            tmpy += 1
        while tmpx != ci:
            tmpx += ci
            tmpy +=1
            tmpz +=1
            if tmpx>=10:
                tmpx = str(tmpx)
                tmp2 = int(tmpx[0])+int(tmpx[1])
                tmpy += 1
        tmp += tmpz*(di//tmpy)
        di -= (di//tmpy)*tmpy

    while di:
        cnt += 1
        #print(di,cnt)
        tmp += ci
        di-=1
        if tmp>=10:
            tmp = str(tmp)
            tmp2 = int(tmp[0])+int(tmp[1])
            cnt += 1
            #print(di,cnt)
            tmp = tmp2
print(cnt-1)
    

### FIXED CODE ###

#繰り上がりごとに各桁の総和は9減る
#9*最初の桁数+最初の総和がそれで減る
#それは順番によらない

m = int(input())
sm=  0
d = []
c = []
for i in range(m):
    di,ci = map(int, input().split( ))
    d.append(di)
    c.append(ci)
    sm += di*ci

x = sum(c)*9 + sm
y =  x%9
if y==0:
    y = 9
    
print((x-y)//9-1)
n = int(input())

if n < 1 or n > 10:
    raise ValueError

print(2 * n)


### FIXED CODE ###

n = int(input())

print(2 * n if n % 2 != 0 else n)
s = input()
x, y = map(int, input().split())
y = abs(y)

lx, ly = [], []
flag = True
n = 0
s += 'T'
for i in s:
    if i == 'F':
        n += 1
    else:
        if n > 0:
            if flag:
                lx.append(n)
            else:
                ly.append(n)
            n = 0
        flag = not flag

x = abs(x - lx.pop(0))

lx.sort()
ly.sort()
sx = sum(lx)
sy = sum(ly)

if sx < x or (sx - x) % 2 == 1 or sy < y or (sy - y) % 2 == 1:
    print('No')
    exit()


def main(x, sx, lx):
    if x == sx:
        return True

    goal = (sx - x) // 2
    # return (sum of some lx == goal)
    dp = [False] * (goal + 1)
    dp[0] = True
    for i in lx:
        if i > goal:
            return False
        for j in range(goal - i, -1, -1):
            if dp[j]:
                dp[j+i] = True
        if dp[goal]:
            return True
    return False


if main(x, sx, lx) and main(y, sy, ly):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
x, y = map(int, input().split())
y = abs(y)

f = s.find('T')
if f >= 0:
    x = abs(x - f)
    s = s[f:]
else:
    if x == len(s) and y == 0:
        print('Yes')
    else:
        print('No')
    exit()

lx, ly = [], []
flag = True
n = 0
s += 'T'
for i in s:
    if i == 'F':
        n += 1
    else:
        if n > 0:
            if flag:
                lx.append(n)
            else:
                ly.append(n)
            n = 0
        flag = not flag

lx.sort()
ly.sort()
sx = sum(lx)
sy = sum(ly)

if sx < x or (sx - x) % 2 == 1 or sy < y or (sy - y) % 2 == 1:
    print('No')
    exit()


def main(x, sx, lx):
    if x == sx:
        return True

    goal = (sx - x) // 2
    # return (sum of some lx == goal)
    dp = [False] * (goal + 1)
    dp[0] = True
    for i in lx:
        if i > goal:
            return False
        for j in range(goal - i, -1, -1):
            if dp[j]:
                dp[j+i] = True
        if dp[goal]:
            return True
    return False


if main(x, sx, lx) and main(y, sy, ly):
    print('Yes')
else:
    print('No')
a = list(map(int, input().split()))
print((n[0]-1)*(n[1]-1))

### FIXED CODE ###

a, b = map(int, input().split())
print((a-1)*(b-1))
HK = list(map(int,input().split(" ")))
HP = list(map(int,input().split(" ")))
H = HK[0]
K = HK[1]
HP.sort(reverse=True)
sum_a = sum(HP[K:N])
print(sum_a)

### FIXED CODE ###

HK = list(map(int,input().split(" ")))
HP = list(map(int,input().split(" ")))
H = HK[0]
K = HK[1]
HP.sort(reverse=True)
sum_a = sum(HP[K:])
print(sum_a)
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
	a.append(a[i]+A[i])
for i in range(M):
	b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[j]:
  	j -= 1
  ans = max(ans, i+j)
print(ans)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)
n,k=map(int,input().split())
p=n-k+1
for i in range(k):print(p%(10**9+7));p=p*(k-i)*(n-k+1-i)//i//-~i

### FIXED CODE ###

class F:
    def __init__(self,n,mod):
        self.mod=mod
        self.f=[1]
        for i in range(1,n+1):
            self.f.append(self.f[-1]*i%mod)
        self.i=[pow(self.f[-1],mod-2,mod)]
        for i in range(1,n+1)[::-1]:
            self.i.append(self.i[-1]*i%mod)
        self.i.reverse()
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.i[i]
    def comb(self,n,k):
        return 0 if k>n else self.f[n]*self.i[n-k]*self.i[k]%self.mod
n,k=map(int,input().split())
M=10**9+7
c=F(n,M).comb
for i in range(k):
    print(c(n-k+1,i+1)*c(k-1,i)%M)
n, m, x = map(int, input().split())
keep = []
ans = 10**10
for i in range(n):
    c = list(map(int, input().split()))
    keep.append(c)

for j in range(2**n):
    bag = [0] * n
    total = 0
    check = 1
    for k in range(n):
        if ((j >> k) & 1):
            for l in range(m):
                bag[l] += keep[k][l + 1]
            total += keep[k][0]
    for a in range(m):
        if bag[a] < x:
            check *= 0
    if ans * check > total:
        ans = total
if ans == 10**10:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

s=input()
t=input()
if t[:-1]==s:
  print("Yes")
else:
  print("No")
import numpy as np
H, W = map(int, input().split())
grid = np.array([list(map(str, input())) for _ in range(H)])

X = np.where(grid == '#')
A = np.zeros([H,W])
A[X] = 1
orig_black = np.count_nonzero(grid=='#')

q = [[0,0,0]]
while q:
	cx,cy,cd = q.pop(0)
	if cx == H-1 and cy == W-1:
		shortest = cd
		break
	elif A[cx,cy] == -1:
		continue

	A[cx,cy] = -1

	for nx,ny in [[cx+1,cy],[cx-1,cy],[cx,cy+1],[cx,cy-1]]:
		if 0 <= nx < H and 0 <= ny < W:
			if A[nx][ny] == 0:
				q.append([nx,ny,cd+1])

print((H*W)-shortest-orig_black-1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

H, W = map(int, input().split())
S = [list(map(str, input())) for _ in range(H)]

tmp = 0
for i in range(H):
	tmp += S[i].count("#")

w_count = (H*W) - tmp

def bfs(field, dp, q):
	cp = q.pop(0)
	np = [[cp[0]+1,cp[1]], [cp[0]-1,cp[1]], [cp[0],cp[1]+1], [cp[0],cp[1]-1]]

	for n in np:
		if 0 <= n[0] <= H-1 and 0 <= n[1] <= W-1:
			if field[n[0]][n[1]] == "." and dp[n[0]][n[1]] == inf:
				q.append(n)
				dp[n[0]][n[1]] = dp[cp[0]][cp[1]] + 1
			if n == [H-1,W-1]:
				return dp[n[0]][n[1]]

	if len(q) == 0:
		return -1

	return bfs(field, dp, q)

inf = float("inf")
dp = [[inf for _ in range(W)] for _ in range(H)]
dp[0][0] = 0
nes = bfs(S, dp, [[0,0]])
if nes == -1:
	print(-1)
else:
	print(w_count-nes-1)
nb = int(input())
number = len(nb)-1

if nb[number] in [2, 4, 5, 7, 9]:
  print("hon")
elif nb[number] in [0, 1, 6, 8]:
  print('pon')
else:
  print('bon')

### FIXED CODE ###

nb = input()
number = len(nb)-1

if int(nb[number]) in [2, 4, 5, 7, 9]:
  print("hon")
elif int(nb[number]) in [0, 1, 6, 8]:
  print('pon')
else:
  print('bon')
import math, cmath
 
n = int(raw_input())
p1 = complex(0,0)
p2 = complex(100,0)
 
for e in koch(p1,p2,n):
    print e.real,e.imag

def koch(p1, p2, n):
    if n == 0:
        return [p1, p2]
     
    rad60 = math.pi/3
    v1 = (p2 - p1)/3
    v2 = cmath.rect(abs(v1), cmath.phase(v1)+rad60)
    q1 = p1 + v1
    q2 = q1 + v2
    q3 = q1 + v1
    if n == 1:
        return [p1,q1,q2,q3,p2]
    else:
        x1 = koch(p1,q1,n-1)[:-1]
        x2 = koch(q1,q2,n-1)[:-1]
        x3 = koch(q2,q3,n-1)[:-1]
        x4 = koch(q3,p2,n-1)
        x = x1 + x2 + x3 + x4
    return x
        x4 = koch(q3,p2,n-1)
        x = x1 + x2 + x3 + x4
    return x

### FIXED CODE ###

import math, cmath
 
def koch(v1, v2, n):
    if n == 0:
        return [v1, v2]
     
    rad60 = math.pi/3
    u1 = (v2 - v1)/3
    u2 = cmath.rect(abs(u1), cmath.phase(u1)+rad60)
    q1 = v1 + u1
    q2 = q1 + u2
    q3 = q1 + u1
    if n == 1:
        return [v1,q1,q2,q3,v2]
    else:
        x1 = koch(v1,q1,n-1)[:-1]
        x2 = koch(q1,q2,n-1)[:-1]
        x3 = koch(q2,q3,n-1)[:-1]
        x4 = koch(q3,v2,n-1)
        x = x1 + x2 + x3 + x4
    return x
 
n = int(raw_input())
v1 = complex(0,0)
v2 = complex(100,0)
 
for e in koch(v1,v2,n):
    print e.real,e.imag
head=deque()
tail=deque()
for _ in range(q):
    Q=input().split()
    if len(Q)==1:
        rev=1-rev
    if len(Q)==3:
        if(rev==0 and Q[1]=="1" )or (rev==1 and Q[1]=="2"):
            head.appendleft(Q[2])
        else :
            tail.append(Q[2])
if rev==0:
    ans="".join(head)+s+"".join(tail)

else:
    ans="".join(tail)[::-1]+s[::-1]+"".join(head)[::-1]

print(ans)

### FIXED CODE ###

from collections import deque
s=input()
q=int(input())
rev=0
head=deque()
tail=deque()
for _ in range(q):
    Q=input().split()
    if len(Q)==1:
        rev=1-rev
    if len(Q)==3:
        if(rev==0 and Q[1]=="1" )or (rev==1 and Q[1]=="2"):
            head.appendleft(Q[2])
        else :
            tail.append(Q[2])
if rev==0:
    ans="".join(head)+s+"".join(tail)

else:
    ans="".join(tail)[::-1]+s[::-1]+"".join(head)[::-1]

print(ans)
S=int(input())
ans=[0]*(S+1)
MOD=10**9+7

if S<=2:
    print(0)
    exit(0)

ans[3]=1
for i in range(4,S+1):
    ans[i]=ans[i-1]+ans[i-3]

print(ans[i]%MOD)

### FIXED CODE ###

S=int(input())
ans=[0]*(S+1)
MOD=10**9+7

if S<=2:
    print(0)
    exit(0)
elif S==3:
    print(1)
    exit(0)   
ans[3]=1
for i in range(4,S+1):
    ans[i]=ans[i-1]+ans[i-3]

print(ans[i]%MOD)
import math

class DataSet():
    def __init__(self,a,b):
        self.a = a
        self.b = b

    def add_size(self):
        ans = self.a+self.b
        return int(math.log10(ans)+1)

def main():
    data_set = []

    for i in range(0, 199):
        n = input().split()

        a = int(n[0])
        b = int(n[1])

        data_set.append(DataSet(a,b))

    for i in range(0, 199):
        ans = data_set[i].add_size()
        print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import math

def main():
    data = []
    while 1:
        try:
            n = input().split()
            a = int(n[0])
            b = int(n[1])
            ans = int(math.log10(a+b)+1)
            data.append(ans)
        except EOFError:
            break

    for i in data:
        print(i)

if __name__ == "__main__":
    main()
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
disc = []
for i in range(M):
  disc.append(list(map(int,input().split())))
ans = a[0] + b[0]
for i in range(M):
  ans = min(a[disc[i][0]-1] + b[disc[i][1]-1] - disc[i][2], ans)     
    
print(ans)


### FIXED CODE ###

S = input()
if S == "hi" or S == "hihi" or S == "hihihi" or S == "hihihihi" or S == "hihihihihi" : print("Yes") 
else: print("No")
N,K,M=map(int, input().split(' '))
Ai =input().split(' ')
Ais = [int(s) for s in Ai]

goal = M*N
current = sum(Ais)

if __name__=='__main__':
  rest=goal-sum(Ais)
  print( max(0,rest) if rest<=K else -1 )


### FIXED CODE ###

alpha = 'abcdefghijklmnopqrstuvwxyz'
if __name__=='__main__':
    print(alpha[1+alpha.index(input())])
n,k = int(input().split())
print(n-k+1)

### FIXED CODE ###

n,k = map(int, input().split())
print(n-k+1)
s=input()
'''
- aa
- aba
'''
for i in range(len(s)):
    if i>=1:
        if s[i]==s[i-1]:
            print(i-1 + ' ' + i)
            exit()
    if i>=2:
        if s[i]==s[i-2]:
            print(i-2 + ' ' + i)
            exit()
print(-1 -1)

### FIXED CODE ###

s=input()
for i in range(len(s)):
    if i>=1:
        if s[i]==s[i-1]:
            print(i, i+1)
            exit()
    if i>=2:
        if s[i]==s[i-2]:
            print(i-1, i+1)
            exit()
print(-1, -1)
import math
n,a,b=map(int,input().split())


def dfs(n,a,b,count):
    if not (b-a)%2:
        return (b-a)//2
    if a==1:
        return math.ceil(b//2)+count
    if b==n:
        return math.ceil((n-a)//2)+count
    if n-b<a:
        return dfs(n,a+1,b+1,count+1)
    if n-b>=a:
        return dfs(n,a-1,b-1,count+1)
print(dfs(n,a,b,0))

### FIXED CODE ###

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

a_length=a-1
b_length=n-b

if not (b-a)%2:
    print((b-a)//2)
elif b_length>=a_length:
    print(a+(b-a-1)//2)
elif b_length<a_length:
    print(n-b+1+(b-a-1)//2)
from collections import defaultdict, deque
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys


def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



n, w = LI()
weight, value = list(zip(*LIR(n)))
dp = (w + 1) * [0]
for i in range(n):
    for j in range(w, weight[i]-1, -1):
        dp[j] = max(dp[j], dp[j - weight[i]] + value[i])



print(dp[-1])

### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



n, limit = LI()
weight = []
value = []
for w, v in LIR(n):
    weight += [w]
    value += [v]


w1 = min(weight)
w2, w3, w4 = w1 + 1, w1 + 2, w1 + 3
w1_list = [0] + list(accumulate(sorted([value[i] for i in range(n) if weight[i] == w1], reverse=True)))
w2_list = [0] + list(accumulate(sorted([value[i] for i in range(n) if weight[i] == w2], reverse=True)))
w3_list = [0] + list(accumulate(sorted([value[i] for i in range(n) if weight[i] == w3], reverse=True)))
w4_list = [0] + list(accumulate(sorted([value[i] for i in range(n) if weight[i] == w4], reverse=True)))


ans = 0
for i, j, k, l in product(range(len(w1_list)), range(len(w2_list)), range(len(w3_list)), range(len(w4_list) )):
    if i * w1 + j * w2 + k * w3 + l * w4 > limit:
        continue
    ans = max(ans, w1_list[i] + w2_list[j] + w3_list[k] + w4_list[l])



print(ans)
r_c_str=input().split()
r_c=list(map(lambda i :int(i),r_c_str))
r=r_c[0]
c=r_c[1]
s_str=[input() for i in range(r)]
s_str=[i.split() for i in s_str]
s=[]
for i in s_str:
    s.append(list(map(lambda j :int(j),i)))
for i in range(r):
    s[i].append(sum(s[i]))
s.append([])
for i in range(c+1):
    s[-1].append(0)
for i in range(c):
    for j in range(r):
        s[r][i]+=s[j][i]
s[-1][-1]+=sum(s[4])
for i in s:
    print(*i)


### FIXED CODE ###

r_c_str=input().split()
r_c=list(map(lambda i :int(i),r_c_str))
r=r_c[0]
c=r_c[1]
s_str=[input() for i in range(r)]
s_str=[i.split() for i in s_str]
s=[]
for i in s_str:
    s.append(list(map(lambda j :int(j),i)))
for i in range(r):
    s[i].append(sum(s[i]))
s.append([])
for i in range(c+1):
    s[-1].append(0)
for i in range(c):
    for j in range(r):
        s[r][i]+=s[j][i]
s[-1][-1]+=sum(s[r])
for i in s:
    print(*i)
x,y=map(int,input().split())
a=-1
p=10**9+7
for i in range(x//2+1):
  if i+2*(x-2*i)==y:
    a=i
    break
if a==-1:
  print(0)
  exit()
elif a==0:
  print(1)
else:
  gyaku=[0,1]
  for i in range(2,a+1):
    gyaku.append(((p//i)*-gyaku[p%i])%p)
  com=[1]
  for i in range(1,a+1):
    com.append(com[-1]*gyaku[i]*(x-a+1-i)%p)
print(com[a])


### FIXED CODE ###

x,y=map(int,input().split())
a=-1
p=10**9+7
for i in range(x//2+1):
  if i+2*(x-2*i)==y:
    a=i
    break
if a==-1:
  print(0)
  exit()
elif a==0:
  print(1)
  exit()
else:
  gyaku=[0,1]
  for i in range(2,a+1):
    gyaku.append(((p//i)*-gyaku[p%i])%p)
  com=[1]
  for i in range(1,a+1):
    com.append(com[-1]*gyaku[i]*(x-a+1-i)%p)
print(com[-1])
def f():
    n, m = [int(s) for s in input().split()]
    s = [int(s) for s in input()]
    board = [None]*(n+1)
    left = 0
    for i in range(1,n+1):
        if s[i]:
            continue
        left = max(left, i-m)
        while s[left] and left<i:
            left += 1
        if left < i:
            board[i] = left
    if board[n] is None:
        print(-1)
        return
    steps = []
    j = n
    while j > 0:
        step = j - board[j]
        steps.append(step)
        j = board[j]
    print(' '.join(str(s) for s in steps[::-1]))

f()

### FIXED CODE ###


n, m = [int(s) for s in input().split()]
s = [int(s) for s in input()]
board = [None]*(n+1)
left = 0
board[left] = 0
for i in range(1,n+1):
    if s[i]:
        continue
    left = max(left, i-m)
    while board[left] is None:
        left += 1
        if left == i:
            break
    if left < i:
        board[i] = left
# print(board)
if board[n] is None:
    print(-1)
else:
    steps = []
    j = n
    while True:
        step = j - board[j]
        steps.append(step)
        j = board[j]
        if j==0:
            break
    print(' '.join(str(s) for s in steps[::-1]))
n=int(input())
listh=(list(map(int,input().split()))
count=1
for i in range(2,n+1):
  if listh[i]>=max(listh[:i-1]):
    count+=1
print(count)
     

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
cnt=1
for i in range(1,n):
  if h[i]>=max(h[:i]):
    cnt+=1
print(cnt)
a,b,c = (int(x) for x in input().split())
if a == b:
  if a == c:
    print (1)
  else:
    pritn (2)
else:
  if a == c:
    print (2)
  else:
    if b == c:
      print (2)
    else:
      print (3)

### FIXED CODE ###

a,b,c = (int(x) for x in input().split())
if a == b:
  if a == c:
    print (1)
  else:
    print (2)
else:
  if a == c:
    print (2)
  else:
    if b == c:
      print (2)
    else:
      print (3)
import sys
sys.setrecursionlimit(10000)
n,m,k=map(int,input().split())

L=[[] for i in range(n)]
U=[[] for i in range(n)]
for i in range(m):
	a,b=map(int,input().split())
	L[a-1].append(b-1)
	L[b-1].append(a-1)
for i in range(k):
	c,d=map(int,input().split())
	U[c-1].append(d-1)
	U[d-1].append(c-1)
	
S=[[] for i in range(n)]
D=[0]*n

def dfs(n):
	D[n]=1
	T.append(n)
	for np in L[n]:
		if D[np]!=1:
			dfs(np)
			
for i in range(n):
	if D[i]!=1:
		T=[]
		dfs(i)
	for t in T:
		S[t]=T[:]
		S[t].remove(t)
		
R=[0]*n
for i in range(n):
	R[i]=len(S[i])-len(L[i])-len(set(S[i])&set(U[i]))
print(*R)

### FIXED CODE ###

from collections import deque
n,m,k=map(int,input().split())

F=[set() for i in range(n)]
B=[set() for i in range(n)]
for i in range(m):
	a,b=map(int,input().split())
	a,b=a-1,b-1
	F[a].add(b)
	F[b].add(a)
for i in range(k):
	c,d=map(int,input().split())
	c,d=c-1,d-1
	B[c].add(d)
	B[d].add(c)
	
T=[set() for i in range(n)]
D=[0]*n
R=[0]*n

for i in range(n):
    if D[i]:
        continue
    que=deque([])
    que.append(i)
    S=set()
    S.add(i)
    while que:
        p=que.popleft()
        for np in F[p]:
            if D[np]!=1:
                que.append(np)
                S.add(np)
                D[np]=1
    for s in S:
        R[s]=len(S)-len(F[s])-len(S&B[s])-1

print(*R)
a,b,c=map(int(input().split(" ")))
if a==b:
  print(c)
elif a==c:
  print(b)
else:
  print(a)

### FIXED CODE ###

a,b,c=input().split(" ")
if a==b:
  print(c)
elif a==c:
  print(b)
else:
  print(a)
import sys

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

sc.sort()
ans = 0
d = 0
s = 0

if sc[0][1] == 0:
  print('-1')
  sys.exit()

for i in sc:
  if i[0] != d:
    d = i[0]
    s = i[1]
    ans += s * (10 ** (n-d))
  else:
    if i[1] != s:
      print('-1')
      sys.exit()

print(ans)

### FIXED CODE ###

import sys

n,m = map(int, input().split())

num = ['-'] * n

for i in range (m):
  s,c = map(int, input().split())
  if num[s-1] != '-' and num[s-1] != c:
    print('-1')
    sys.exit()
  else:
    num[s-1] = c

if n > 1:
  if num[0] == 0:
    print('-1')
    sys.exit()
  elif num[0] == '-':
    num[0] = 1 
  
for i in range(n):
  if num[i] == '-':
    num[i] = '0'
  else:
    num[i] = str(num[i])

print(''.join(num))
N = int(input())
x = int(input())
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = "no"
    ans += 1
if x>0:
    ans = ans - 1
print(ans)
print(x,cage)

### FIXED CODE ###

N, x = map(int, input().split())
A = list(map(int, input().split()))
 
x_tmp = x
for i, Ai in enumerate(sorted(A)):
    x_tmp -= Ai
    if x_tmp == 0:
        ans = i + 1
        break
    elif x_tmp < 0:
        ans = i
        break
    else: continue
else: ans = i
 
print(ans)
import numpy as np
N = map(int, input().split())
numbers = np.array((map(int, input().split())))
# numbers = np.array([7, 6, 8])
# numbers = np.array([12, 15, 18])
# numbers = np.array([1000000000, 1000000000])
# N = len(numbers)


def calculate_maximum_sub_gcd(numbers):
    sub_gcds = np.array([sub_gcd(numbers[:i], numbers[i+1:]) for i in range(N)])
    return np.max(sub_gcds)


def sub_gcd(left, right):
    return np.gcd(np.gcd.reduce(left), np.gcd.reduce(right))


print(calculate_maximum_sub_gcd(numbers))


### FIXED CODE ###

# import math
import fractions
import numpy as np
from itertools import accumulate, chain, islice, starmap
N = int(input())
numbers = list(map(int, input().split()))
# numbers = [2, 4, 8, 8]
# N = len(numbers)


def calculate_maximum_subgcd_with_np_ufunc(numbers):
    gcd = np.frompyfunc(fractions.gcd, 2, 1)
    cumgcds = gcd.accumulate(numbers, dtype=np.object).astype(np.int)
    sub_cumgcds = np.roll(cumgcds, 1)
    sub_cumgcds[0] = 0
    reverse_cumgcds = gcd.accumulate(
        numbers[::-1], dtype=np.object).astype(np.int)
    sub_reverse_cumgcds = np.roll(reverse_cumgcds, 1)
    sub_reverse_cumgcds[0] = 0
    return np.max(gcd(sub_cumgcds, sub_reverse_cumgcds[::-1]))


def calculate_maximum_subgcd_with_func(numbers):
    operation = fractions.gcd
    cumgcds = accumulate(numbers, operation)
    sub_cumgcds = islice(chain([0], cumgcds), len(numbers))
    reverse_cumgcds = accumulate(numbers[::-1], operation)
    sub_reverse_cumgcds = islice(chain([0], reverse_cumgcds), len(numbers))
    sub_gcds = starmap(operation, zip(sub_cumgcds, list(sub_reverse_cumgcds)[::-1]))
    return max(sub_gcds)


# calculate_maximum_subgcd = calculate_maximum_subgcd_with_np_ufunc
calculate_maximum_subgcd = calculate_maximum_subgcd_with_func

print(calculate_maximum_subgcd(numbers))
a="".join(sorted(input()))
b="".join(sorted(input())[::-1])
u=sorted(a,b)
if u[0]==a:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a="".join(list(sorted(input())))
b="".join(list(sorted(input()))[::-1])
u=list(sorted([a,b]))
if u[0]==u[1]:
  print("No")
elif u[0]==a:
  print("Yes")
else:
  print("No")
from collections import Counter
n,k=map(int,input().split())
A=sorted(Counter(list(map(int,input().split()))).most_common())
print(n-sum([A[i][1] for i in range(k)]))

### FIXED CODE ###

from collections import Counter
n,k=map(int,input().split())
A=sorted(Counter(list(map(int,input().split()))).most_common(),key=lambda x:x[1],reverse=True)
print(n-sum([A[i][1] for i in range(min(k,len(A)))]))