Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
import sys
MOD = 1000000007  # type: int

def permutations_count(n, k):
    if k == 0:
        return 1
    return n * permutations_count(n-1, k-1) % MOD

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    matrix = [[] for _ in range(N+1)]
    for i in range(N-1):
        matrix[a[i]].append(b[i])
        matrix[b[i]].append(a[i])
    
    visited = [0]*(N+1)

    from collections import deque
    queue = deque()
    visited[1]=1
    answer = K
    answer *= permutations_count(K-1,len(matrix[1]))
    for node in matrix[1]:
        queue.append(node)

    while queue:
        q = queue.popleft()

        if visited[q] == 0:
            answer *= permutations_count(K-2,len(matrix[q])-1) #親ノード引いてる
            if K-2 < len(matrix[q])-1:
                print(0)
                return
        else:
            continue

        visited[q] = 1

        for child_node in matrix[q]:
            queue.append(child_node)

    print(answer%MOD)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
MOD = 1000000007  

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    matrix = [[] for _ in range(N+1)]
    for i in range(N-1):
        matrix[a[i]].append(b[i])
        matrix[b[i]].append(a[i])
    
    visited = [0]*(N+1)

    from collections import deque
    queue = deque()
    visited[1]=1
    answer = K
    num = K-1
    for node in matrix[1]:
        answer *= num
        answer %= MOD

        num -= 1
        queue.append(node)

    while queue:
        q = queue.popleft()
        if visited[q] != 0:
            continue
        visited[q] = 1

        num = K-2
        for child_node in matrix[q]:
            if visited[child_node] == 0:
                answer *= num
                answer %= MOD
                num -= 1
                queue.append(child_node)
        answer %= MOD

    print(answer%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()
age,money=map(int, input().split())
assert 1<=age<=100 and 2<=money<=1000 and money%2==0
if age<=5:
    print('0')
elif 6<=age<=12:
    print(money/2)
else:
    print(money)



### FIXED CODE ###

try:
    age,money=map(int, input().split())
    assert 0<=age<=100 and 2<=money<=1000 and money%2==0
    if age<=5:
        print('0')
    elif 6<=age<=12:
        print(money//2)
    else:
        print(money)
except AssertionError:
    print('')
I=input
n,q=map(int,I())
s=I()
a=[0]
for i in range(n):a+=[a[i]+(s[i-1:i+1]=='AC')]
for _ in[0]*q:l,r=map(int,I());print(a[r]-a[l])

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
a=[0]*n
for i in range(n):
    if i:
        a[i]=a[i-1]+(s[i-1:i+1]=='AC')
for _ in range(q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])
import numpy as np
N, M, C = [int(x) for x in input().split()]
B = np.array([int(x) for x in input().split()])
A = np.array([[int(x) for x in input().split()] for _ in range(N)])
 
print(np.sum(A@B > -C))

### FIXED CODE ###

N, M = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(N)]
AB.sort(key=lambda x: x[0])

s = 0
for ab in AB:
    if ab[1] > M:
        s += M*ab[0]
        break
    else:
        s += ab[0]*ab[1]
        M -= ab[1]

print(s)
n = int(input())
h = list(map(int,input().split()))

c = 0
i = 0

while sum(h) > 0 :
    if h[i]> 0 :
        j = i
        c = c + 1 
        while j < n and h[j] > 0 :
            h[j] = h[j] - 1
            j = j + 1
        else:
            i = i + 1

print(c) 
            

### FIXED CODE ###

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

c = 0
i = 0

while sum(h) > 0 :
    if h[i]> 0 :
        j = i
        c = c + 1 
        while j < n and h[j] > 0 :
            h[j] = h[j] - 1
            j = j + 1
    else:
        i = i + 1

print(c)
S=input()
S[3]='7'
print(S)

### FIXED CODE ###

S = input()
print(S.replace("2017/", "2018/", 1))
from math import ceil
D,G=map(int,input().split())
p=[0]*D
c=[0]*D

for i in range(D):
    p[i],c[i]=map(int,input().split())
_min=101*D

flag=1
while(flag < 2**D):
    
    _G=G
    tmp=0
    max_ind=0
    for i in range(D):
        if(flag & 1<<i):
            _G-=p[i]*(i+1)*100 + c[i]
            tmp+=p[i]
        else:
            max_ind=i
    k=ceil(max([(_G),0])/(100*(max_ind+1)))  
    if(k < p[max_ind]):
        tmp+=k
        _min=min([tmp,_min])
    flag+=1
print(_min)  

### FIXED CODE ###

n=int(input())
if(n<=1199):
    print("ABC")
elif(n<2800):
    print("ARC")
else:
    print("AGC")
import math
N,Ma,Mb = map(int,input().split(" "))
drags = [list(map(int,input().split(" "))) for  _ in range(N)]
INF = 10 ** 9
lim = N * 10 + 1
dp = [[[ INF for i in range(lim)] for j in range(lim)] for _ in range(N+1)]
dp[0][0][0] = 0
for num in range( N ):
    a,b,c = drags[num]
    for i in range(a,401): #薬品厨のa の量
        for j in range(b,401 ):#薬品厨のb の量
             dp[num + 1][i][j] = min(dp[num][i ][j] ,dp[num][i - a][j - b]  + c)

ans = INF
for i in range(1,41):
    MA = Ma * i
    MB = Mb * i
    if MA >= lim or MB >= lim:
        break
    ans = min(ans, dp[-1][MA][MB])
if ans == INF:
    ans = -1
print(ans)


### FIXED CODE ###



import math
N,Ma,Mb = map(int,input().split(" "))
drags = [list(map(int,input().split(" "))) for  _ in range(N)]
INF = 10 ** 9
lim = N* 10 + 1
dp = [[[ INF for i in range(lim)] for j in range(lim)] for _ in range(N+1)]
dp[0][0][0] = 0
for num in range( N ):
    a,b,c = drags[num]
    dp[num + 1][0][0] = 0
    for i in range(0,lim): #完成した液体の aの量
        for j in range(0,lim):# bの量
            dp[num + 1][i][j]  =  dp[num][i][j]
            if i - a >= 0 and j - b >= 0:
                dp[num + 1][i ][j ] = min(dp[num][i ][j ] ,dp[num][i -a ][j -b  ]  + c)

ans = INF
for i in range(1,41):
    MA = Ma * i
    MB = Mb * i
    if MA >= lim or MB >= lim:
        break
    ans = min(ans, dp[-1][MA][MB])
if ans == INF:
    ans = -1
print(ans)
A,B,C,D = map(int,input().split())
if A+B = C+D:
  print("Balanced")
elif A+B < C+D:
  print("Right")
else:
  print("Left")

### FIXED CODE ###

A,B,C,D = map(int,input().split())
if (A+B) == (C+D):
  print("Balanced")
elif (A+B) < (C+D):
  print("Right")
else:
  print("Left")
def div_with_mod(x, y, mod):
    # Fermat's little theorem
    return x*pow(y, mod - 2, mod)


def comb(n, r, mod):
    # calculates C(n,r) with mod (assuming mod is prime)
    nc = n
    for rc in range(1, r):
        nc -= 1
        n = n*nc % mod
        r = r*rc % mod

    return div_with_mod(n, r, mod)


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

j = 2*x-y
if j % 3:
    print(0)
    exit()
j //= 3
i = x - 2*j
if i < 0 or j < 0:
    print(0)
    exit()

ans = comb(i+j, i)
print(ans)


### FIXED CODE ###

def comb(n, m, p=10**9+7):
    if n < m:
        return 0
    if n < 0 or m < 0:
        return 0
    m = min(m, n-m)
    top = bot = 1
    for i in range(m):
        top = top*(n-i) % p
        bot = bot*(i+1) % p
    bot = pow(bot, p-2, p)
    return top*bot % p


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

j = 2*x-y
if j % 3:
    print(0)
    exit()
j //= 3
i = x - 2*j
if i < 0 or j < 0:
    print(0)
    exit()

ans = comb(i+j, i)
print(ans)
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


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

s1=input()

s2=input()

len_moji = lcm(n,m)

len_s1 = []

len_s2 = []

for i in range(n):
    len_s1.append(i*len_moji//n+1)

for i in range(m):
    len_s2.append(i*len_moji//m+1)
#print(len_s1,len_s2)

for ix, vs1 in enumerate(len_s1):
    for jx, vs2 in enumerate(len_s2):
        if vs1 == vs2:
            if s1[ix] != s2[jx]:
                print(-1)
                exit()
print(len_moji)

### FIXED CODE ###

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


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

s1=input()

s2=input()

len_moji = lcm(n,m)

len_s1 = []

len_s2 = []

for i in range(n):
    len_s1.append(i*len_moji//n+1)

for i in range(m):
    len_s2.append(i*len_moji//m+1)
#print(len_s1)
#print(len_s2)
count = 0
for ix, vs1 in enumerate(len_s1):
    for jx in range(count,len(len_s2)):
        #print(vs1, len_s2[jx])
        if vs1 < len_s2[jx]:
            count = jx-1
            break
        if vs1 == len_s2[jx]:
            count = jx
            if s1[ix] != s2[jx]:
                print(-1)
                exit()
            break
print(len_moji)
n = int(input())
s = int(input())

flag = False
if s > n:
  print(-1)
  exit()
  
if s == n:
  print(n+1)
  exit()

def chk(b, n):
  if n//b == 0:
    return n
  else:
    return chk(b,n//b) + n%b

for b in range(2, int(n**0.5)+1):
  if chk(b, n) == s:
    print(b)
    flag = True
    exit()

for i in range(int(n**0.5), 0, -1):
  b = (n-s)//i + 1
  if chk(b, n) == s:
    print(b)
    flag = True
    exit()

if flag == False:
  print(-1)

### FIXED CODE ###

n = int(input())
s = int(input())

flag = False
if s > n or (n//2)+1<s<n:
  print(-1)
  exit()
  
if s == n:
  print(n+1)
  exit()

def chk(b, n):
  if n//b == 0:
    return n
  else:
    return chk(b,n//b) + n%b

for b in range(2, int(n**0.5)+1):
  if chk(b, n) == s:
    print(b)
    flag = True
    exit()

for i in range(int(n**0.5), 0, -1):
  b = (n-s)//i + 1
  if chk(b, n) == s:
    if b > 1:
      print(b)
      flag = True
      exit()

if flag == False:
  print(-1)
n = map(int, raw_input().split);

print(2*(n[0]+n[1]));
print(n[0] * n[1]);

### FIXED CODE ###

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

print a*b, 2*(a+b)
N, M = map(int, input().split())
table = [[int(i) for i in input().split()] for _ in range(M)]

ans = [table[0], table[1]]

for i in table:
    if ans[0] >= i[0] <= ans[1]:
        ans[0] = i[0]
    if ans[0] >= i[1] <= ans[1]:
        ans[1] = i[1]

print(ans[1] - ans[0] + 1)


### FIXED CODE ###

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

ans = [table[0][0], table[0][1]]
cnt = 0

for i in table[1:]:
    if ans[0] <= i[0] <= ans[1]:
        ans[0] = i[0]
    if ans[0] <= i[1] <= ans[1]:
        ans[1] = i[1]
    if ans[1] < i[0] or i[1] < ans[0]:
        cnt += 1
        break

if cnt != 0:
    print(0)
else:
    print(ans[1] - ans[0] + 1)
def main():
    A, B, C, K = map(int, input().split())
    li = ([1] * A) + ([0] * B) + ([-1] * C)
    print(sum(li[:K]))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    A, B, _, K = map(int, input().split())
    if A > K:
        print(K)
        quit()
    print(A - max([0, K - A - B]))


if __name__ == "__main__":
    main()
def check_key(S, key_length):
    for i,k in enumerate(S):
        if k == S[i+1]:
            return 'Bad'
        if i == key_length - 1:
            return 'Good'
        else:
            continue
S = input()
key_length = len(S)
print(check_key(S, key_length))


### FIXED CODE ###

a,b,c,d = [int(s) for s in input()]
print('Bad') if a == b or b == c or c == d else print('Good')
N = int(input())
a = 0

for i in range(1,1+N,2):
  b = 0
  for j in range(1,1+i,2):
    if i%j==0:
      b+=1
    if n==8:
      a+=1

print(a)

### FIXED CODE ###

a = int(input())
b = 0

for i in range(1,a+1,2):
  c = 0
  for j in range(1,a+1,2):
    if i%j==0:
      c+=1
  else:
    if c==8:
      b+=1
else:
  print(b)
list = map(int, raw_input().split())
List = map(int, raw_input().split())

countLatter = 0
countFormer = 0

for i in range(list[2] + 1, list[0]):
    if i in List :
        countLatter += 1
for i in range(0, list[2] - 1):
    if i in List :
        countFormer += 1

print(min(countLatter, countFormer))

### FIXED CODE ###

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

count = 0
for i in input().split():
    if int(i) > X:
        break
    count += 1

print(min(count , M-count))
s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(S) else None
a = n if n and c < K else S[0]
print(a)


### FIXED CODE ###

s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else s[0]
print(a)
a, b, c = map(int, input().split())

if a+b <= c:
  print('Yes')
else:
  priny('No')

### FIXED CODE ###

a, b, c = map(int, input().split())
 
if a+b >= c:
  print('Yes')
else:
  print('No')
N = int(input())
A = list(map(int, input().split()))
List = [0]*N

for i in range(N):
  List.append(str(A.index(i+1)+1))



print(' '.join(List))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
List = [0]*N


for i, a in enumerate(A):
  List[int(a)-1] = str(i+1)

  
print(" ".join(List))
import numpy
n,y= map(int,input().split())

c=list(range(n+1))
lenC=len(c)
v1=numpy.repeat(c, lenC*lenC)
v2=numpy.repeat(lenC*c, lenC)
v3=numpy.repeat(lenC*lenC*c,1)
v = numpy.array([v1,v2,v3]).reshape(3,len(v1))

comb=v[:,sum(v)==n]
m=numpy.matrix([10000, 5000, 1000])
s = m*comb

if y in s:
	ans=comb[:,numpy.array(s).flatten()==y][:,0]
	print("%d %d %d"%(ans[0],ans[1],ans[2]))
else:
	print("%d %d %d"%(-1,-1,-1))



### FIXED CODE ###

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

ans=(-1,-1,-1)
m=range(n+1)
for a in m:
	for b in m:
		c=n-a-b
		total = 10000*a + 5000*b + 1000*c
		if (c>=0) & (total==y):
			ans=(a,b,c)
			break
		else:
			continue
		break

print("%d %d %d"%ans)
import math
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
ai = [int(i) for i in input().split()]

num_li = [0]*(10**6+1)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors



for i in range(n):
    num_li[ai[i]] += 1

ans = 0
    
for i in range(n):
    if num_li[ai[i]] > 1:
        continue
    #print(ai[i])
    flag = True
    div = make_divisors(ai[i])
    #print(div)
    for j in range(len(div)):
        if div[j] == ai[i]:
            continue
        #print(div[j],div)
        if num_li[div[j]] > 0:
            flag = False
            break
    if flag == True:
        ans += 1
    #exit()
print(ans)


### FIXED CODE ###

import math
n = int(input())
ai = [int(i) for i in input().split()]

ai.sort()

sqr_max_val = int(ai[n-1]**0.5)
max_val = ai[n-1]
#print(ai)
ai_ex = [0]*(2*10**6)
#ai_ex = [0]*(30)

for i in range(n):
    ai_ex[ai[i]-1] += 1

for i in range(n):
    if ai_ex[ai[i]-1] > 1:
        ai_ex[ai[i]-1] = 0
    """
    if ai[i] > sqr_max_val:
        break
    """
    tmp = ai[i]
    baisu = 2
    #print(ai[i])
    while tmp * baisu <=  max_val:
        ai_ex[tmp*baisu-1] = 0
        #print(tmp*baisu)
        baisu += 1
"""
for i in range(100):
    if ai_ex[i] == 1:
        a = 1
        #print(i)
"""
print(sum(ai_ex))
#print(ai_ex)
n,k=map(int,input().split())
td=[]
for _ in range(n):
  td.append(list(map(int,input().split())))
td.sort(key=lambda x:x[1],reverse=True)
td_core=[]
td_sel=[]
td_sub=[]
cat=[0]*(n+1)
for i in range(n):
  if i < k and cat[td[i][0]]==0:
    td_core.append(td[i])
    cat[td[i][0]]=1
  elif i < k:
    td_sel.append(td[i])
  elif cat[td[i][0]]==0:
    td_sub.append(td[i])
    cat[td[i][0]]=1
# i >= k and cat[td[i][0]]==1 となるものはすでにtd_core,td_sel,td_sub内ものと種類も被っている上に美味しさも低い
# 後の工程では種類を増やす処理なので、同じ種類のネタは美味しさが最大のもの一つで十分。なので捨てる

# dの大きいじゅんに貪欲にネタを取得したときの満足ポイント
kiso=sum([x[1] for x in td_core])+sum(x[1] for x in td_sel)
bns=len(td_core)
ans=kiso+bns**2
# この状態からネタの種類を増やしていき最大が出てくるか検証
# td_sel内のネタは同一ネタが複数あり、そのネタ内で最大じゃないものが美味しさの大きい順に入っている。
# td_subにはtd_core,tdselにないネタの最大美味しさの寿司が入っている。
td_sel.sort(key=lambda x:x[0])
for i in range(len(td_sel)):
  kiso-=td_sel[i][1]
  kiso+=td_sub[i][1]
  bns+=1
  ans=max(ans,kiso+bns**2)
print(ans)




### FIXED CODE ###

n,k= map(int,input().split())
td=[]
for _ in range(n):
    td.append(list(map(int,input().split())))
td.sort(key=lambda x:x[1],reverse=True)
NEW=[1]*(n+1)
x=0
y=0
TOP=[]
SUB=[]
A=[]
for tdi in td[:k]:
    if NEW[tdi[0]]==1:
        NEW[tdi[0]]=0
        TOP.append(tdi[1])
        y+=1
    else:
        A.append(tdi[1])
    x+=tdi[1]
    
for tdi in td[k:]:
    if NEW[tdi[0]]==1:
        SUB.append(tdi[1])
        NEW[tdi[0]]=0
ans=x+y**2
for i in range(min(k-1,len(A),len(SUB))):
    x -= A.pop()
    x += SUB[i]
    y += 1
    ans = max(ans,x+y**2)
print(ans)
elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]


if K < 16:
    print(elements[K-1])
else:
    print(elements[-(32-K)-1])

### FIXED CODE ###

elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
th = K-1
print(elements[th])
def P(m, n):
    num = 1
    for i in range(n):
        num = (num*(m-i)) % INF
    return num


n, k = list(map(int, sys.stdin.readline().split()))
graph = [dict() for i in range(n)]
for i in range(n):
    graph[i]["eda"]=[]
for i in range(n - 1):
    a, b = list(map(int, sys.stdin.readline().split()))
    graph[a - 1]["eda"].append(b - 1)
    graph[b - 1]["eda"].append(a - 1)
ans = 1
check = [False] * n
stack = [0]
ans = 1
while len(stack) > 0:
    x = stack.pop()
    check[x] = True
    count = 0
    for i in graph[x]["eda"]:
        if not check[i]:
            count += 1
            stack.append(i)
    if x == 0:
        temp = P(k - 1, count)
        ans = (ans * temp) % INF
    else:
        temp = P(k - 2, count)
        ans = (ans * temp) % INF

print((ans * k) % INF)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
INF=10**9+7
def LI(): return list(map(int, sys.stdin.readline().split()))
 
def main():
    n, k = LI()
    graph=[[] for i in range(n)]
    for i in range(n-1):
        a,b=LI()
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    ans=1
    check=[False]*n
    stack=[0]
    ans=1
    while len(stack)>0:
        x=stack.pop()
        check[x]=True
        count=0
        for i in graph[x]:
            if not check[i]:
                count+=1
                stack.append(i)
        if x==0:
            temp=1
            for i in range(count):
                temp=temp*(k-1-i)%INF
            ans=ans*temp%INF
        else:
            temp=1
            for i in range(count):
                temp=temp*(k-2-i)%INF
            ans=ans*temp%INF
    print((ans*k)%INF)
 
 
if __name__ == "__main__":
    main()
int A, int B
x=A*B
if x%2==0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

A,B=list(map(int,input().split()))
x=A*B
if x%2==0:
  print('No')
else:
  print('Yes')
import bisect
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    a.sort()
    l=0
    r=n
    d = {}
    if sum(a)<k:
        print(n)
    else:
        while l!=r:
            i=(l+r)//2
            ta = a[i]
            if ta in d.values():
                flag = d[ta]
            elif ta>=k:flag=True
            else:
                flag = False
                na = a[:i]+a[i+1:]
                dp = [False for _ in range(k+1)]
                dp[0]=True
                for j in range(n-1):
                    for m in range(k,0,-1):
                        if m-na[j]>=0:
                            dp[m]=dp[m] or dp[m-na[j]]
                        if m != k and m>=k-ta and dp[m]:
                            flag = True
                            break
                    if flag:break
                d[ta] = flag
            
            if flag:
                r=i
            else:
                l=i+1
        print(l)

main()

### FIXED CODE ###

import bisect
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    a.sort()
    l=0
    r=n
    d = {}
    if sum(a)<k:
        print(n)
    else:
        while l!=r:
            i=(l+r)//2
            ta = a[i]
            if ta in d.keys():
                flag = d[ta]
            elif ta>=k:flag=True
            else:
                flag = False
                na = a[:i]+a[i+1:]
                dp = [False for _ in range(k+1)]
                dp[0]=True
                for j in range(n-1):
                    for m in range(k,0,-1):
                        if m-na[j]>=0:
                            dp[m]=dp[m] or dp[m-na[j]]
                        if m != k and m>=k-ta and dp[m]:
                            flag = True
                            break
                    if flag:break
                d[ta] = flag
            
            if flag:
                r=i
            else:
                l=i+1
        print(l)

main()
x,a,b=map(int,input().split())
print(min(abs(x-a),abs(x-b))

### FIXED CODE ###

x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b):
      print("A")
else:
      print("B")
N, M = map(int, input().split())
D = []
for i in range(N):
    t, v = map(int, input().split())
    D.append((t, v))

D.sort(key=lambda x:x[0])

DP1 = [[0 for j in range(M)] for i in range(N + 2)]
DP2 = [[0 for j in range(M)] for i in range(N + 2)]

for i in range(1, N + 1):
    for j in range(1, M):
        if j - D[i - 1][0] >= 0:
            DP1[i][j] = max(DP1[i - 1][j], DP1[i - 1][j - D[i - 1][0]] + D[i - 1][1])
        else:
            DP1[i][j] = DP1[i - 1][j]

for i in range(N, 0, -1):
    for j in range(1, M):
        if j - D[i - 1][0] >= 0:
            DP2[i][j] = max(DP2[i + 1][j], DP2[i + 1][j - D[i - 1][0]] + D[i - 1][1])
        else:
            DP2[i][j] = DP2[i + 1][j]

mv = 0
for l in range(N):
    mv = max(DP1[l][M - 1] + DP2[l][l + 1] + D[l][1], mv)

print(mv)





### FIXED CODE ###

N, M = map(int, input().split())
D = []
for i in range(N):
    t, v = map(int, input().split())
    D.append((t, v))

D.sort(key=lambda x:x[0])

DP = [[0 for j in range(M)] for i in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, M):
        if j - D[i - 1][0] >= 0:
            DP[i][j] = max(DP[i - 1][j], DP[i - 1][j - D[i - 1][0]] + D[i - 1][1])
        else:
            DP[i][j] = DP[i - 1][j]
mv = 0
for l in range(N): #ラストオーダー
    mv = max(DP[l][M - 1] + D[l][1], mv)

print(mv)
a, b, k = map(int, input().split())

c = [1]
for i in range(2, max(a, b)):
    if a % i == 0 and b % i == 0:
        c.append(i)

c = sorted(c, reverse = True)

print(c[k-1])

### FIXED CODE ###

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

c = [1]
for i in range(min(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
            print(i)
as, bs, cs = input().split(" ")

a = int(as)
b = int(bs)
c = int(cs)

if a < b < c:
  print("Yes")
else:
  print("No")

### FIXED CODE ###


ass, bss, css = input().split(" ")

a = int(ass)
b = int(bss)
c = int(css)

if a < b < c:
  print("Yes")
else:
  print("No")
l = [int(i) for i in input().split()]
if max(abs(l[0-l[1]], abs(l[1]-l[2])) <= l[3]:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

l = [int(i) for i in input().split()]
print("Yes" if ((abs(l[0] - l[1]) <= l[3]) & (abs(l[1] - l[2]) <= l[3])) or (abs(l[0] - l[2]) <= l[3]) else "No")
input_str = input()
homes = input_str.split(" ")
for home in homes:
    home = int(home)
print(homes)
if ((homes[3] - homes[1]) * (homes[3] - homes[2]) < 0):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

input_str = input()
homes = input_str.split(" ")
for i, home in enumerate(homes):
    homes[i] = int(home)
if ((homes[2] - homes[1]) * (homes[2] - homes[0]) < 0):
    print("Yes")
else:
    print("No")
a, b = map(int, input().split())
print(int(a*b))

### FIXED CODE ###

from decimal import Decimal

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

print(int(a*b))