Harryxun/stf_run huggingface dataset:
n, w = [ int(v) for v in input().split() ]
knapsack = [ [ int(v) for v in input().split() ] for i in range(n) ]

dp_list = [ [ None for i in range(4*n+1) ] for i in range(n+1) ]
dp_list[0][0] = 0
base = knapsack[0][0]


for wi, vi in knapsack:
    wi -= base
    for i in range(n-1,-1,-1):
        for j in range(4*n,-1,-1):
            if 0 <= j-wi < 4*n+1:
                if dp_list[i][j-wi] is not None:
                    if dp_list[i+1][j] is None:
                        dp_list[i+1][j] = dp_list[i][j-wi] + vi
                    else:
                        dp_list[i+1][j] = max(dp_list[i][j-wi] + vi, dp_list[i+1][j])


ans_list = [0]
for i in range(1,n+1):
    l = w-base*i
    for j in range(l+1):
        if dp_list[i][j] is not None:
            ans_list.append(dp_list[i][j])


print(max(ans_list))

### FIXED CODE ###

n, w = [ int(v) for v in input().split() ]
knapsack = [ [ int(v) for v in input().split() ] for i in range(n) ]

dp_list = [ [ None for i in range(4*n+1) ] for i in range(n+1) ]
dp_list[0][0] = 0
base = knapsack[0][0]


for wi, vi in knapsack:
    wi -= base
    for i in range(n-1,-1,-1):
        for j in range(4*n,-1,-1):
            if 0 <= j-wi < 4*n+1 and 0 <= j < 4*n+1:
                if dp_list[i][j-wi] is not None:
                    if dp_list[i+1][j] is None:
                        dp_list[i+1][j] = dp_list[i][j-wi] + vi
                    else:
                        dp_list[i+1][j] = max(dp_list[i][j-wi] + vi, dp_list[i+1][j])

ans_list = [0]
for i in range(1,n+1):
    l = w - i*base
    for j in range(min(4*n+1,l+1)):
        if dp_list[i][j] is not None:
            ans_list.append(dp_list[i][j])


print(max(ans_list))
from math import factorial as fact
from collections import Counter

N = int( input() )
tree = list( map( int, input().split() ) )
ans = 1
if tree[0] != 0:
    print(0)
else:
    c = Counter(tree)
    if c[0] != 1:
        print(0)
    else:
        print(c)
        a = 1
        for i in range( 1,len(c)):
            t = c[i]
            if a == 1:
                print(ans)
                ans *= t
            else:
                print(ans)
                ans *= ( a ** t )
                if t != 1:
                    ans = int( ans / fact(a) )
            a = t 
        print(ans)

### FIXED CODE ###

from math import factorial as fact
from collections import Counter
import sys

N = int( input() )
tree = list( map( int, input().split() ) )
ans = 1
if tree[0] != 0:
    print(0)
else:
    c = Counter(tree)
    if c[0] != 1:
        print(0)
    else:
        ans = 1
        a = c[0]
        for i in range( 1,len(c)):
            t = c[i]
            if t == 0:
                print(0)
                sys.exit()
            else:
                ans *= ( a**t )
                a = t
        print(ans%998244353)
n = int(input())
min_r, max_d = int(input()), - 10**9
for in range(n - 1):
    r = int(input())
    max_d = max(max_d, r - min)
    min_r = min(min_r, r)
print(max_d)



### FIXED CODE ###

n = int(input())
min_r, max_d = int(input()), - 10**9
for _ in range(n - 1):
    r = int(input())
    max_d = max(max_d, r - min_r)
    min_r = min(min_r, r)
print(max_d)
N, K =map(int,input().split())
r = N % K
print(min(r,abs(r-k)))


### FIXED CODE ###

N, K =map(int,input().split())
r = N % K
print(min(r,abs(r-K)))
def nCr(n, r):
    import math
    return math.factorial(n) // ((math.factorial(n - r) * math.factorial(r)))

def nCr_with_replacement(n, r):
    # 重複を許容するくみあわせ　
    return nCr(n + r - 1, r)

# 並び変えるときの組み合わせ
def nPr(n, r):
    import math
    return math.factorial(n) // math.factorial(n - r)
MOD = 1000000007

n, k = map(int, input().split())
b, r = k, n-k
#b, r = max(b,r), min(b,r)
#print("b,r: {0},{1}".format(b,r))
for i in range(0, k):
    x = nCr(b - 1,  i) # 青いブロックの分け方
    #print(r+1)
    #print(i)
    y = nCr(r + 1 , r- i)

    #print("x,y: {0},{1}".format(x,y))
    print(x * y % MOD)

### FIXED CODE ###

def nCr(n, r):
    import math
    return math.factorial(n) // ((math.factorial(n - r) * math.factorial(r)))
MOD = 1000000007

n, k = map(int, input().split())
b, r = k, n-k
for i in range(0, k):
    x = nCr(b - 1,  i) # 青いブロックの分け方
    if r - i < 0:
        print(0)
    else:
        y = nCr(r + 1, r - i)
        print(x * y % MOD)
input_count = 0

A, B = input().split()

A = int(A)
if '.' in B:
    B_a = int(B.split('.')[0])
    B_b_size = len(B.split('.')[1])
    B_b =  int(B.split('.')[1])
else:
    B_a = int(B)
    B_b_size = 0
    B_b = 1
ans_a = A * B_a
ans_b = A * math.pow(10, -1*B_b_size) * B_b
ans = ans_a + int(ans_b)
print(ans)


### FIXED CODE ###


import math

A, B = input().split()

A = int(A)
if '.' in B:
    B_a = int(B.split('.')[0])
    B_b_size = len(B.split('.')[1])
    B_b =  int(B.split('.')[1])
else:
    B_a = int(B)
    B_b_size = 0
    B_b = 0
if B_b_size == 0:
    ans = A * B_a
elif B_b_size == 1:
    ans_a = A * B_a
    ans_b = A * B_b 
    ans_b = ans_b // 10
    ans = ans_a + ans_b
else:
    ans_a = A * B_a
    ans_b = A * B_b 
    ans_b = ans_b // 100
    ans = ans_a + ans_b
print(ans)
n = int(input())
l=list(map(int ,input().split(" ")))
count=0
while True:
    for i in range(n):
        if l[i]%2==0:
            l[i]=l[i]//2
        else:
            print(count)
            exit()
    count+=1    

### FIXED CODE ###

print(input().count("1"))
a, b = map(int, input().split())
if a > b:
  print(a -1)
elif:
  print(a)

### FIXED CODE ###

a, b = map(int, input().split())
if a > b:
  print(a -1)
else:
  print(a)
n, x = list(map(int, input().split()))
l = input()
ans = 1
cnt = 0

l_list = l.split(' ')

for i in l_list:
    cnt += i
    if cnt > x:
        break
    ans += 1

print (ans)


### FIXED CODE ###

n, x = list(map(int, input().split()))
l = input()
ans = 1
cnt = 0

l_list = l.split(' ')

for i in l_list:
    cnt += int(i)
    if cnt > x:
        break
    ans += 1

print (ans)
a,b,c=map(int,input().split())
ans="NO"
for i in range(b):
  if (a*(i+1))%b==c:ans"YES"
print(ans)

### FIXED CODE ###

a,b,c=map(int,input().split())
ans="NO"
for i in range(b):
  if (a*(i+1))%b==c:ans="YES"
print(ans)
K=int(input())
S=list(input())

LS=len(S)

if LS <= K:
    print(S)
elif LS > K:
    print(S[0:(SL-1):1],"...")


### FIXED CODE ###

K=int(input())
S=input()
s=list(S)

if len(s) <= K:
    print(S)
else:
    print(S[0:K:]+"...")
a,b=int(input().split())
z=float(t/x)
print(z)


### FIXED CODE ###

a,b=map(int,input().split())
z=float(a/b)
print(z)
a, b = map(int, input().split())

if (a*b) % 2 == 0):
  print('Even')
else:
  print('Odd')


### FIXED CODE ###

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

if (a*b) % 2 == 0:
  print('Even')
else:
  print('Odd')
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
cost = [0,2,5,5,4,5,6,3,7,6] # cost[a[i]] = a[i]のコスト
dp = [-1]*(n+1)
dp[0] = 0

for i in range(2,n+1):
    for j in range(0,m):
        if dp[i-cost[a[j]]] == -1:
            continue
        else:
            dp[i] = max(dp[i],dp[i-cost[a[j]]]+1)

ans = list()
read = n
a.sort()
a.reverse()

while read > 0:
    for i in range(0,m):
        if read -cost[a[i]] < 0:
            continue
        if dp[read-cost[a[i]]] == dp[read]-1:
            ans.append(str(a[i]))
            read -= cost[a[i]]
            break
    
print("".join(ans))

### FIXED CODE ###

n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
cost = [0,2,5,5,4,5,6,3,7,6] 
dp = [-1]*(n+1)
dp[0] = 0

for i in range(2,n+1):
    for j in range(0,m):
        if i-cost[a[j]] <0:
            continue
        if dp[i-cost[a[j]]] == -1:
            continue
        else:
            dp[i] = max(dp[i],dp[i-cost[a[j]]]+1)

ans = list()
read = n
a.sort()
a.reverse()

while read > 0:
    for i in range(0,m):
        if read < cost[a[i]]:
            continue
        if dp[read-cost[a[i]]] == dp[read]-1:
            ans.append(str(a[i]))
            read -= cost[a[i]]
            break
    
print("".join(ans))
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

l = [0] * (a[0]+10)
f = 0
for i in a:
    l[i-1] += 1
    if l[i-1] == 2 or l[i-1] == 4:
        f += 1
    if f == 1:
        x = i
        f += 1
    if f == 3:
        print(x*i)
        exit()
print(0)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

f = 0
x = 0
for i in range(len(a)-1):
    if a[i] == a[i+1] != x:
        f += 1
    if f == 1:
        x = a[i]
        f += 1
        if a.count(x) >= 4:
          f = 3
    if f >= 3:
        print(x*a[i])
        exit()
print(0)
a,b = map(int,input().split())
c = list(map(int,input().split()))
dp = [float("inf") for i in range(a+2)]

for i in range(n+1):
    for j in c:
        if i + j <= n:
            dp[i+j] = min(dp[i+j],dp[i] + 1)
            
print(dp[a])
            
        


### FIXED CODE ###

a,b = map(int,input().split())
c = list(map(int,input().split()))
dp = [float("inf") for i in range(a+2)]
dp[0]=0
for i in range(a+1):
    for j in c:
        if i + j <= a:
            dp[i+j] = min(dp[i+j],dp[i] + 1)
            
print(dp[a])
s = input()
K = int(input())
s_list = []
for i in range(len(s)):
	for j in range(i + 1, K + 1):
		s_list.append(s[i:j])
s_set = set(s_list)
ans = list(s_set.sort())
print(ans[K - 1])

### FIXED CODE ###

s = input()
K = int(input())
substr = set()
for i in range(len(s)):
    for j in range(i+1, i+K+1):
        substr.add(s[i:j])
print(sorted(substr)[K-1])
n,m = map(int, input().split())
link = []
for i in range(m):
    tmp = list(map(int,input().split()))
    link.append([tmp[0]-1,tmp[1]-1,-tmp[2]])

def bell(edges, start,num_v):
    cost = [float('inf')] * num_v
    cost[start] = 0
    for _ in range(num_v):
        updated = False
        for a, b, c in edges:
            if cost[b] > cost[a] + c:
                cost[b] = cost[a] + c
                updated = True
        if not updated: break
    else:
        return -1,cost
    return 1,cost

ans1,d = bell(link,0,n)

if ans1 == -1:
    inf_flag = [False]*n
    for i in range(n):
        for f, t, c in link:
            if d[f] == float("inf"): continue
            if inf_flag[f] == True:
                inf_flag[t] = True
            if d[t] > d[f] + c:
                d[t] = d[f] + c
                inf_flag[t] = True
    print("inf" if inf_flag[n-1] else -d[n-1])
else:
    print(-ans2[-1])

### FIXED CODE ###

n,m = map(int, input().split())
link = []
for i in range(m):
    tmp = list(map(int,input().split()))
    link.append([tmp[0]-1,tmp[1]-1,-tmp[2]])

def bell(edges, start,num_v):
    cost = [float('inf')] * num_v
    cost[start] = 0
    for _ in range(num_v):
        updated = False
        for a, b, c in edges:
            if cost[b] > cost[a] + c:
                cost[b] = cost[a] + c
                updated = True
        if not updated: break
    else:
        return -1,cost
    return 1,cost

ans1,d = bell(link,0,n)

if ans1 == -1:
    inf_flag = [False]*n
    for i in range(n):
        for f, t, c in link:
            if d[f] == float("inf"): continue
            if inf_flag[f] == True:
                inf_flag[t] = True
            if d[t] > d[f] + c:
                d[t] = d[f] + c
                inf_flag[t] = True
    print("inf" if inf_flag[n-1] else -d[n-1])
else:
    print(-d[-1])
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

N, W = MAP()
w, v = ZIP(N)

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
	for j in range(W+1):
		if j-w[i-1] >= 0:
			dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
		else:
			dp[i+1][j] = dp[i][j]
print(dp[N][W])


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

N, W = MAP()
w, v = ZIP(N)
max_v = sum(v)
dp = [INF]*(max_v+1)
dp[0] = 0
for w, v in zip(w, v):
	for i in range(max_v, -1, -1):
		if i-v >= 0:
			dp[i] = min(dp[i], dp[i-v]+w)

ans = 0
for i in range(len(dp)):
	if dp[i] <= W:
		ans = i
print(ans)
n,k = map(int,input().split())
a = list(map(int,input().split()))
s_d2 = set()
d2 = []
cur = 1
d2.append(1)
st_idx = 0
rp_lgt = 0
for i in range(n):
  cur = a[cur-1]
  if cur in s_d2:
    for j in range(len(d2)):
      if cur == d2[j] :
        st_idx = j - 1 
        rp_lgt = i - j + 1
        break
  else:
    d2.append(cur)
    s_d2.add(cur)
wk = k - st_idx
md = wk % rp_lgt
if k < st_idx:
  ans = d2[k]
else:
  ans = d2[md+st_idx]
print(ans)


### FIXED CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
d2 = []
hist=[-1]*(n+1)
hist[0] = 0
cur = 1
d2.append(1)
st_idx = 0
rp_lgt = 1
for i in range(n):
  cur = a[cur-1]
  if hist[cur-1] >= 0 :
     d2.append(cur)
     st_idx = hist[cur-1]
     rp_lgt = i - st_idx + 1 
     break
  else:
    d2.append(cur)
    hist[cur-1] = i + 1
wk = k - st_idx
md = wk % rp_lgt
if k < st_idx:
  ans = d2[k]
else:
  ans = d2[md+st_idx]
print(ans)
N =int(input())
s = [int(x) for x in range(0,N)]
for i in range(0,N):
  for j in range(i+1,N):
    m = [int(s[i]*s[j])]
leng = len(m)
sum = 0
for k in range(0,leng):
  sum = sum + m[k]
 print(sum)

  


### FIXED CODE ###

from itertools import combinations

n=int(input())
D=list(map(int,input().split()))

ans=0
for a,b in combinations(range(n),2):
  ans+=D[a]*D[b]
  
print(ans)
R, G, B, N = map(int, input().split())
r = 0
g = 0
X = N - r*R - g*G
num = 0
while X >= 0:
	while X >= 0:
			if X % B == 0:
				num += 1
			r += 1
			X = N - r*R - g*G
	g += 1
	r = 0
	X = N - r * R - g * G
 
print(num)

### FIXED CODE ###

N,K = map(int,input().split())
answer = int(N) - int(K) + 1
print(str(answer))
W,H,x,y = map(int,input().split())
temp1 = [(W-x)*H,x*H]
temp2 = [W*y,W*(H-y)]

ans = max(min(temp1),min(temp2))
if  (W/2 == x and H/2 == y):
    print(W*H/2,1)
elif H/W == y/x:
    print(W*H/2,0)
elif x == 0 or x == W or y == 0 or y == H:
    print(W*H/2,0)
elif min(temp1) == min(temp2):
    print(ans,1)
else:
    print(ans,0)


### FIXED CODE ###

w,h,x,y = map(int,input().split())
if w/2 == x and h/2 == y:
  print(w*h/2,1)
else:
  print(w*h/2,0)
def com(n):
    return n*(n-1)//2
ans=0
n=int(input())
a=list(map(int,input().split()))
coun=[0]*n
for i in range(n+1):
    coun[a[i]]+=1
for i in range(n+1):
    ans+=com(coun[i])
for i in range(n+1):
    m=com(coun[a[i]]-1)
    o=com(coun[a[i]])
    print(ans-o+m)

### FIXED CODE ###

import collections
N=int(input())
lst=input().split()
s=0
dic=collections.Counter(lst)
for i in dic.values():
    s+=(i*i-i)//2
for i in lst:
    print(s+1-dic[i])
S=input()
e=S[0::2]
o=S[1::2]
for i in range(len(e)):
    if s[i]=="L":
        print("No")
        break
else:
  for j in range(len(o)):
    if o[j]=="R":
        print("No")
        break 
  else:
    print("Yes")   

### FIXED CODE ###

S=input()
e=S[0::2]
o=S[1::2]
for i in range(len(e)):
    if e[i]=="L":
        print("No")
        break
else:
    for j in range(len(o)):
        if o[j]=="R":
            print("No")
            break 
    else:
        print("Yes")
s = input().split()
from scipy.special import comb
C1 = comb(s[0], 2, exact=True)
C2 = comb(s[1], 2, exact=True)

print(C1 + C2)

### FIXED CODE ###

N, M = map(int,input().split())
C1 = N*(N-1)//2
C2 = M*(M-1)//2

print(C1 + C2)
N, M = [int(elm) for elm in input().split(" ")]
bridges = [[int(elm) for elm in input().split(" ")] for _ in range(M)]

class Graph:
    pass

graph = {}
for node in range(1, N+1):
    graph[node] = [node]
    #graph_mem[node] = []

graph_n_mem = [0] + [1 for i in range(N)]
n_all_pairs = N * (N-1) // 2

#def delete_graph(B):
#    pass

def calc_out(n_list):
    out = n_all_pairs
    for elm in n_list:
        if elm <= 1:
            continue
        tmp = elm * (elm-1) // 2
        out -= tmp
    return out

outs = []
for A, B in reversed(bridges):
    #print(graph_n_mem)
    #print("before AB", A, B)
    A = graph[A][0]
    B = graph[B][0]
    #print(graph_n_mem, "AB", A, B)
    if graph[A] != graph[B]:
        #graph_n_mem[A] += len(graph[B])
        graph_n_mem[A] += graph_n_mem[B]
        graph_n_mem[B] = 0

        graph[A] += graph[B]
        for node in graph[A]:
            graph[node] = graph[A]
            
        #graph_mem[A] += graph_mem[B]
        

    out = calc_out(graph_n_mem)
    outs.append(out)

outs = outs[::-1]
outs = outs[1:] + [n_all_pairs]
for out in outs:
    print(out)

### FIXED CODE ###

A, B, C = list(map(int, input().split(" ")))

n = B // A
out = min(n, C)
print(out)
N = int(input())
ans = 0

for i in range(N):
  A = int(input())
  ans += 1/A
  
ans = 1/ans

print(ans
  

### FIXED CODE ###

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

for i in range(N):
  ans += 1/A[i]
  
ans = 1/ans
print(ans)
del = list(map(int, input().split()))
n = len(del)
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += del[i] * del[k]
  i += 1
  
print(str(sum))



### FIXED CODE ###

n = int(input())
deliciousness = list(map(int, input().split()))
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += deliciousness[i] * deliciousness[k]
  i += 1
  
print(sum)
n,a,b=map(int,input().split)
if n*a >= b:
  print(b)
else:
  print(n*a)

### FIXED CODE ###

n,a,b=map(int,input().split())
if n*a >= b:
  print(b)
else:
  print(n*a)
import collections

N = int(input())
S = input()
A = ''
B = S
ans = 0
for i in range(N):
  A += B[0]
  B = B[1:]
  C = collections.Counter(A)
  D = 0
  for w in C:
    if w in B:
      D += 1
  if D > ans:
    ans = D
print(ans)

### FIXED CODE ###

import collections

N = int(input())
S = input()
A = ''
B = S
ans = 0
for i in range(N):
  A += B[0]
  B = B[1:]
  C = collections.Counter(A)
  D = 0
  for w in C:
    if w in B:
      D += 1
  if D > ans:
    ans = D
print(ans)
def abc151_b():
    N, K, M = map(int, input().split())
    A = sum(list(map(int, input().split())))
    need = max(0, N * M - A)
    ans = need if need <= K else - 1
    print(ans)

abc151_b()

### FIXED CODE ###

N = int(input())
s = input()

ans = 0
for x, y, z in zip(s[:-2], s[1:-1], s[2:]):
    if x + y + z == "ABC":
        ans += 1
print(ans)
from math import gcd

def lcm(*args):
    ans = 1
    for x in args:
        ans = ans * x // gcd(ans, x)
    return ans

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

l = lcm(*map(int, input().split()))

print(m // (l//2) - m // l)

### FIXED CODE ###

from fractions import gcd

def lcm(*args):
    ans = 1
    for x in args:
        ans = ans * x // gcd(ans, x)
    return ans

n, m = map(int, input().split())
a = [int(x) for x in input().split()]

def log(x):
    ans = 0
    while x % 2 == 0:
        ans += 1
        x //= 2
    return ans

def solve(a):
    tmp = None
    for ta in a:
        if tmp is None:
            tmp = log(ta)
        else:
            if tmp == log(ta):
                continue
            else:
                print(0)
                return
    l = lcm(*a)
    print(m // (l//2) - m // l)

solve(a)
n=input()
4.if n[0]==9 or n[1]==9:
5.    print('Yes')
      exit()
6.else:
7.    print('No')


### FIXED CODE ###

# coding: utf-8
# Your code here!
n=input()
if n[0]=='9':
    print('Yes')
    exit()
if n[1]=='9':
    print('Yes')
    exit()
else:
    print('No')
N, u, v = list(map(int, input().split()))
graph = [[] for _ in range(N+1)]
for i in range(N-1):
  A, B = list(map(int, input().split()))
  graph[A].append(B)
  graph[B].append(A)
#print(graph)

def dfs(v):
  dist = [-1] * (N+1)
  dist[v] = 0
  stack = [v
 # print(dist)
  while stack:
    now = stack.pop()
    dw = dist[now] + 1
#graph[]は隣接している要素
    for ne in graph[now]:
      if dist[ne] >= 0:
        continue
      dist[ne] = dw
      stack.append(ne)
      #print(ne)
  return dist

Taka = dfs(u)
Ao = dfs(v)

ans = 0
for t, a in zip(Takahashi[1:], Aoki[1:]):
  if t < a:
    ans = max(ans, a-1)

print(ans)

### FIXED CODE ###

A = int(input())
B = int(input())

print(6-A-B)
def main():
    n = int(input())
    if n == 1:
        print(1)
        sys.exit()
    # nd:num of div
    r = 0
    for i1 in range(1, n):
        y = n // i1
        r += y * (y + 1) * i1 / 2
    print(int(r))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
read = sys.stdin.read
from math import sqrt, floor
def main():
    n = int(input())
    if n == 1:
        print(1)
        sys.exit()
    # nd:num of div
    nd = [2] * (n + 1)

    for i1 in range(2, floor(n / 2) + 1):
        for i2 in range(i1 * 2, n + 1, i1):
            nd[i2] += 1

    r = 1
    for j1 in range(2, n + 1):
        r += nd[j1] * j1
    print(r)

if __name__ == '__main__':
    main()
s=list(input())
if s[-1]=='3':
  print('bon')
elif s[-1] in [0,1,6,8]
  print('pon')
else:
  print('hon')


### FIXED CODE ###

s=input()
if s[-1]=='3':
  print('bon')
elif s[-1] in ['0','1','6','8']:
  print('pon')
else:
  print('hon')
#ABC131D
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
l=sorted(l,key=lambda x:x[1])
deadline=0
tmp=0
for i in range(n):
    tmp=l[i][1]
    deadline+=l[i][0]
    if tmp<deadline
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

#ABC131D
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
l=sorted(l,key=lambda x:x[1])
deadline=0
tmp=0
for i in range(n):
    tmp=l[i][1]
    deadline+=l[i][0]
    if tmp<deadline:
        print("No")
        exit()
print("Yes")
tw ="ABC" if input().startswith("ARC") else "ARC")
print(tw)


### FIXED CODE ###

tw ="ABC" if input().startswith("ARC") else "ARC"
print(tw)
import bisect
n,k=map(int,input().split())
mod=10**9+7;ans=0
a=list(map(int,input().split()))
c=sorted(a)
d=[0]*n
e=[0]*n
for i in range(n):
  d[i]=bisect.bisectleft(c,a[i])
for i in range(n):
  cnt=0
  for j in range(i,n):
    if a[i]>a[j]:
      cnt+=1
  e[i]=cnt
st=sum(e)*k%mod
ad=sum(d)%mod
print((st+(ad*(k-1)*k//2)%mod)%mod)

### FIXED CODE ###

import bisect
n,k=map(int,input().split())
mod=10**9+7
a=list(map(int,input().split()))
c=sorted(a)
d=[0]*n
e=[0]*n
for i in range(n):
  d[i]=bisect.bisect_left(c,a[i])
for i in range(n):
  cnt=0
  for j in range(i,n):
    if a[i]>a[j]:
      cnt+=1
  e[i]=cnt
st=sum(e)*k%mod
ad=sum(d)%mod
print((st+(ad*(k-1)*k//2)%mod)%mod)
A,B = map(int,input().split())

import math

GCD = math.gcd(A,B)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
        f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

PF = prime_factorize(GCD)

PF = list(set(PF))

res = len(PF) + 1

print(res)


### FIXED CODE ###

A,B = map(int,input().split())

import fractions

GCD = fractions.gcd(A,B)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

PF = prime_factorize(GCD)

PF = set(PF)

res = len(PF) + 1

print(res)