Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3

def calc(N, X):
    if X == 0:
        return 0

    Y = 2 ** (N + 1) - 1
    if X == Y:
        return 2 ** N
    elif X == Y - 1:
        return 2 ** N - 1
    elif X < Y - 1:
        return calc(N - 1, X - 1)
    else:
        return 2 ** (N + 1) - 1 - calc(N - 1, 2 ** (N + 2) - 4 - X)

def main():
    [N, X] = list(map(int, input().split()))

    r = calc(N, X)


    print(r)


if __name__ == '__main__':
    main()



### FIXED CODE ###

#!/usr/bin/env python3

def calc(N, X):
    if X == 0:
        return 0
    elif X == 2 ** (N + 2) - 3:
        return 2 ** (N + 1) - 1

    Y = 2 ** (N + 1) - 1
    if X == Y:
        return 2 ** N
    elif X == Y - 1:
        return 2 ** N - 1
    elif X < Y - 1:
        return calc(N - 1, X - 1)
    else:
        return 2 ** (N + 1) - 1 - calc(N - 1, 2 ** (N + 2) - 4 - X)

def main():
    [N, X] = list(map(int, input().split()))

    r = calc(N, X)


    print(r)


if __name__ == '__main__':
    main()
import math
while t == 0:	
	try:
		n = int(input().rstrip().split(??? ???))
	except:
		break
	else:
		

### FIXED CODE ###

import math
t = 0
while t == 0:	
	try:
		x,y=[int(i) for i in input().split()]
	except:
		break
	else:
		a = int (math.log10(x + y) + 1)
		print(a)
N, K = map(int, input().split())
A = [0] + [int(a) for a in input().split()]
for i in range(N):
    A[i+1] += A[i]
S = []
for i in range(1, N+1):
    for j in range(i):
        S.append(A[i] - A[j])
l, r = 0, 1 << 50
while r - l > 1:
    m = (l+r) // 2
    if len([1 for i in range(len(S)) if S[i] & m == m]) >= K:
        l = m
    else:
        r = m
print(l)

### FIXED CODE ###

N, K = map(int, input().split())
A = [0] + [int(a) for a in input().split()]
for i in range(N):
    A[i+1] += A[i]
S = []
for i in range(1, N+1):
    for j in range(i):
        S.append(A[i] - A[j])
l, r = 0, 1 << 50
while r - l > 1:
    m = (l+r) // 2
    if len([1 for i in range(len(S)) if S[i] & m == m]) >= K:
        l = m
    else:
        r = m
print(l)
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
  
sorted_a = sorted(a)

for v in a:
  if v == sorted[0]:
    print(sorted[1])
  else:
    print(sorted[0])

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
  
sorted_a = sorted(a, reverse=True)

for v in a:
  if v == sorted_a[0]:
    print(sorted_a[1])
  else:
    print(sorted_a[0])
N, M = map(int, input().split())
a = []
issafe = [True for _ in range(N)]
for i in range(M):
    a.append(int(input()))
    issafe[a[i]] = False

dp = [0 for _ in range(N+1)]
dp[0] = 1
if issafe[1]:
    dp[1] = 1

for i in range(2, N+1):
    if issafe[i-1]:
        dp[i] += dp[i-1]
    if issafe[i-2]:
        dp[i] += dp[i-2]
    dp[i] %= 1000000007

print(dp[N])

### FIXED CODE ###

N, M = map(int, input().split())
a = []
issafe = [True for _ in range(N+1)]
for i in range(M):
    a.append(int(input()))
    issafe[a[i]] = False

dp = [0 for _ in range(N+1)]
dp[0] = 1
if issafe[1]:
    dp[1] = 1

for i in range(2, N+1):
    if issafe[i-1]:
        dp[i] += dp[i-1]
    if issafe[i-2]:
        dp[i] += dp[i-2]
    dp[i] %= 1000000007

print(dp[N])
k = int(input())
a , b = map(int(input().split()))

flag = 0
for i in range(a ,b + 1, 1)
	if i % k == 0:
		flag = flag + 1
		break
		print("OK")
elif flag == 0:
	print("NO")

### FIXED CODE ###

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

flag = 0
for i in range(a ,b + 1, 1):
	if i % k == 0:
		flag = flag + 1
		break

if flag == 0:
	print("NG")
else:
	print("OK")
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

S = int(input())

sho = S // 3
ans = 1
S -= 5
if sho > 0:
    for i in range(1,sho):
        ans += cmb(S, i)
        S -= 2
    print((ans)%(10**9+7))
else:
    print(0)

### FIXED CODE ###

from scipy.special import comb

S = int(input())

sho = S // 3
ans = 1
S -= 5
if sho > 0:
    for i in range(1,sho):
        ans += comb(S, i, exact=True)
        S -= 2
    print(int(ans)%(10**9+7))
else:
    print(0)
a = int(input())
b = int(input())
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")
for e in iter(input,'0 0'):
 H,W=map(int,e.split())
 s=[[*map(int,input().split())]for _ in[0]*H]
 print(max(sum(max(sum(c),H-sum(c))for c in zip([c^int(b)for c in r]for r,b in zip(s,bin(x)[2:].zfill(H))))for x in range(2**H)))


### FIXED CODE ###

def v():
 for e in iter(input,'0 0'):
  r=int(e.split()[0])
  d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
  a=0
  for m in range(1<<~-r):
   t=0
   for s in d:
    c=bin(m^s).count('1')
    t+=max(c,r-c)
   if a<t:a=t
  print(a)
if'__main__'==__name__:v()
#!/usr/bin/env python3
import sys
import math

MOD = 10**9+7  # type: int

def solve(X: int, Y: int):
    a = (2*Y - X)/3
    b = (2*X - Y)/3
    if ((2*Y - X)%3 != 0) and ((2*X - Y)%3 != 0):
        ans = 0
    else:
        if a<0 or b<0:
            ans = 0
        else:
            factorial_ab = math.factorial(int(min(a, b)))
            ans = math.factorial(int(a+b)) / factorial_ab
    print(int(ans%MOD))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import math

MOD = 10**9+7  # type: int

def combi_count(n, r):
    x = 1
    y = 1
    for i in range(1, r+1):
        x = x * (n-i) % MOD
        y = y * i % MOD

    # nCr = n!/((n-r)!*r!) = (n!/(n-r)!) / r! 
    #     :=                 (    x    ) / y

    # x / y            % MOD
    # x * y^(-1)       % MOD
    # x * y**(MOD - 2) % MOD (from フェルマー定理)

    return x * pow(y, MOD-2, MOD) % MOD

def solve(X: int, Y: int):
    a = int((2*Y - X)/3)
    b = int((2*X - Y)/3)
    if ( ((2*Y - X)%3 != 0) and ((2*X - Y)%3 != 0) )  or ((a<0) or (b<0)):
        ans = 0
    else:
        ans = combi_count(a+b+1, min(a, b))
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    X, Y = map(int, input().split())
    solve(X, Y)

if __name__ == '__main__':
    main()
W = input()
print(((sys.stdin.read()).lower()).count(W))

### FIXED CODE ###

W, c = input(), 0
for line in iter(input, 'END_OF_TEXT'):
    for Ti in  line.lower().split():
        if W == Ti:
            c +=1
print(c)
import math

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

mod = 10**9+7

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
# ax ≡ 1 (mod m)
def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

def lcm(x, y):
    tmp = modinv(math.gcd(x,y),mod)
    # print(mod)
    return x * y * tmp

l = 1
for k in a:
    l = lcm(l,k)

l = l % mod

mod = 10**9+7
res = 0
for k in a:
    tmp = modinv(k, mod)
    res = (res + l * tmp % mod) % mod

res = res % mod
print(res)


### FIXED CODE ###

from fractions import gcd

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

l = a[0]
for k in a:
  l = ( l * k ) // gcd(l, k)

mod = 10 ** 9 + 7
ans = 0
for k in a:
  ans += l // k

print( int(ans) % mod )
def solve():
  MOD = 10**9 + 7
  X, Y = map(int, input().split())
  
  if (X+Y)%3!=0:
    print(0)
    quit()
  
  if X < Y:
    X, Y = Y, X

  sub = X - Y
  tan = X - sub

  X = sub + tan + 1
  Y = tan + 1
  dp = [[0]*X for _ in range(Y)]

  dp[2][1] = 1
  for i in range(2, Y):
    for j in range(2, X):
      dp[i][j] = dp[i][j-1] + dp[i-1][j]

  dp[i][j] %= MOD

  #print(*dp, sep='\n')
  print(dp[Y-1][X-1])

if __name__ == '__main__':
  solve()

### FIXED CODE ###

import math

MOD = 10**9 + 7

# nCk
def comb(n, r):
    r = min(r, n-r)
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
  
# nCk mod
def comb_mod(n, r, mod):
  r = min(r, n-r)
  
  g1 = [1, 1] # 元
  g2 = [1, 1] # 逆元
  inverse = [0, 1] # 逆元計算用
  
  for i in range(2, n+1):
    g1.append( (g1[-1] * i) % mod )
    inverse.append( (-inverse[mod % i] * (mod // i)) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

  return g1[n] * g2[r] * g2[n-r] % mod

X, Y = map(int, input().split())
  
if (X+Y)%3!=0:
  print(0)
  quit()

# (+1,+2):n, (+2,+1):m
m = (X*2 - Y) // 3
n = X - m*2

if m < 0 or n < 0:
  print(0)
  quit()

ans = comb_mod(n+m, n, MOD)

print(ans)
n = int(input())
li = list(map(int, input().split())
b = float('inf')

for a in li:
    c = 0
	while a%2 == 0:
      a = a/2
      c += 1
    b = min(b,c)
print(b)
          


### FIXED CODE ###

n = int(input())
li = list(map(int, input().split()))
b = float('inf')
for a in li:
    c = 0
    while a%2 == 0:
      a = a/2
      c += 1
    b = min(b,c)
print(b)
L,R=map(int, input().split())

if R-L>=2019:
    print(0)
else:
    L %= 2019
        R %= 2019
            if L<R:
m = 2019
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            m = min(m, (i*j)%2019)
    print(m)
        else:
print(0)


### FIXED CODE ###

L,R=map(int, input().split())
 
if R-L+1>=2019:
  print(0)
else:
  L %= 2019
  R %= 2019
  if L<R: 
    m = 2019
    for i in range(L,R+1):
      for j in range(i+1,R+1):
        m = min(m, (i*j)%2019)
    print(m)
  else:
    print(0)
N = input( " N : ")
X =input( "X : ")
T=input("T :")
if(N % X == 0):
    print((N // X) * T)
else:
    print(((N // X) + 1) * T)


### FIXED CODE ###

N, X, T = (int(x) for x in input().split())
if(N % X == 0):
    print((N // X) * T)
else:
    print(((N // X) + 1) * T)
N=str(inputN=input()
print('ABC{}'.format(N))

### FIXED CODE ###

N=input()
print('ABC{}'.format(N))
A, B = map(int, raw_input().split())

array = [A + B, A - B, A * B]
max = array[0]
if max < array[1]:
    max = array[1]
if max < array[2]:
    max = array[2]

print(max)


### FIXED CODE ###

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

array = [A + B, A - B, A * B]
max = array[0]
if max < array[1]:
    max = array[1]
if max < array[2]:
    max = array[2]

print(max)
n = input()
arr = list(map(int, input().split()))

a = [arr[i] for i in range(0,n,2)]
b = [arr[y] for y in range(1,n,2)]

import collections
acnt = collections.Counter(a)
bcnt = collections.Counter(b)

amaxval = acnt[list(acnt)[0]]
bmaxval = bcnt[list(bcnt)[0]]

amaxkey = list(acnt)[0]
bmaxkey = list(bcnt)[0]

def val(ab, abcnt):
	if len(ab) < 2:
		return 0
	else:
		return abcnt[list(abcnt)[0]]

if amaxkey != bmaxkey:
	ans = n - amaxval - bmaxval
else:
	if amaxval >= bmaxval:
		ans = n - amaxval - val(b,bcnt)
	else:
		ans = n - val(a,acnt) - bmaxval

print(ans)
	

	

### FIXED CODE ###

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

a = [arr[i] for i in range(0,n,2)]
b = [arr[y] for y in range(1,n,2)]

import collections
acnt = collections.Counter(a)
bcnt = collections.Counter(b)

lsacnt = sorted(acnt.items(), key=lambda x: x[1],reverse=True)
lsbcnt = sorted(bcnt.items(), key=lambda j: j[1],reverse=True)

def val(abcnt, ablscnt):
	if len(list(abcnt)) < 2:
		return 0
	else:
		return ablscnt[1][1]

if lsacnt[0][0] != lsbcnt[0][0]:
	ans = n - lsacnt[0][1] - lsbcnt[0][1]
elif lsacnt[0][0] == lsbcnt[0][0]:
	if lsacnt[0][1] > lsbcnt[0][1]:
		ans = n - lsacnt[0][1] - val(bcnt,lsbcnt)
	elif lsacnt[0][1] < lsbcnt[0][1]:
		ans = n - val(acnt,lsacnt) - lsbcnt[0][1]
	elif lsacnt[0][1] == lsbcnt[0][1]:
		ans = n - lsacnt[0][1] - max(val(acnt,lsacnt),val(bcnt,lsbcnt))

print(ans)
def main():
    ab = [int(_x) for _x in input().split()]
    print(int(ab[0] * ab[1]))


main()


### FIXED CODE ###

def main():
    ab = [_x for _x in input().split()]
    n = ab[1]
    bb = (int(n[0])*100 + int(n[2])*10 + int(n[3]))
    aa = int(ab[0])
    if aa == 0:
        print(0)
        return
    if bb == 0:
        print(0)
        return
    result = str(aa*bb)

    if len(result) <= 2:
        print(0)
    else:
        print(str(result)[:-2])


main()
a=input().split()
if a[0]==a[1]==a[2]:
    print(1)
elif a[0]!=a[1]! and a[1]!=a[2] and a[0]!=a[2]:
    print(3)
else:
    print(2)


### FIXED CODE ###

a=input().split()

if a[0]==a[1]==a[2]:
    print(1)
elif a[0]!=a[1] and a[1]!=a[2] and a[0]!=a[2]:
    print(3)
else:
    print(2)
n,m =map(int(),imput().split)
print((n-1)*(m-1))

### FIXED CODE ###

n,m =map(int,input().split())
print((n-1)*(m-1))
n=int(input("Test cases"))
d=dict()
for i in range(n):
  x=input("Enter result")
  if not x in d:
    d[x] = 1
  else:
    d[x]=d[x]+1
for k,v in d.items()
	print(k,"x",v)
    

### FIXED CODE ###

n=int(input())
d={"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(n):
  x=input()
  d[x]=d[x]+1
for k,v in d.items():
	print(k,"x",v)
import numpy as np
H, W, D=list(map(int,input().split(" ")))
#print(in1)
#arr=np.zeros((in1[0],in1[1]))
d={}
for i in range(H):
    #arr[i]=input().split(" ")
    for n,k in enumerate(input().split(" ")):
        d[int(k)]=[i,n]
#print(arr)
Q=int(input())
out=[]

cost={}
for i in range(1,D+1):
    now = i + D
    cost[i]=abs(d[now][0] - d[now - D][0]) + abs(d[now][1] - d[now - D][1])
    while now <= H * W:
        cost[now] = cost[now - D] + abs(d[now][0] - d[now - D][0]) + abs(d[now][1] - d[now - D][1])
        now += D


out=[]
for k in range(Q):
    start,end=list(map(int,input().split(" ")))
    out.append(cost[end]-cost[start])
for i in out:
    print(i)


### FIXED CODE ###

import numpy as np
H, W, D=list(map(int,input().split(" ")))
#print(in1)
#arr=np.zeros((in1[0],in1[1]))
d={}
for i in range(H):
    #arr[i]=input().split(" ")
    for n,k in enumerate(input().split(" ")):
        d[int(k)]=[i,n]
#print(arr)
Q=int(input())
out=[]

cost={}

for i in range(1,D+1):
    now = i + D
    cost[i]=0
    #cost[i]=abs(d[now][0] - d[now - D][0]) + abs(d[now][1] - d[now - D][1])
    while now <= H * W:
        cost[now] = cost[now - D] + abs(d[now][0] - d[now - D][0]) + abs(d[now][1] - d[now - D][1])
        now += D


out=[]
for k in range(Q):
    start,end=list(map(int,input().split(" ")))
    out.append(cost[end]-cost[start])

for i in out:
    print(int(i))
a = input()
b = input()
c = input()


transferrable = a - b

if c <= transferrable:
    c = 0

else:
    c -= transferrable

print(c)


### FIXED CODE ###



res = str(input())

list = res.split(" ")

a = int(list[0])
b = int(list[1])
c = int(list[2])
transferrable = a - b

if c <= transferrable:
    c = 0

else:
    c -= transferrable

print(c)
a, b, m = input().split()
a, b, m = int(a), int(b), int(m)
a_values = input().split()
b_values = input().split()
m_values = {}
for i in range(m):
    m_values[i] = input().split()

min = int(a_values[int(m_values[0][0])-1]) + int(b_values[int(m_values[0][1])-1]) - int(m_values[0][2])
for i in range(1, m):
    now = int(a_values[int(m_values[i][0])-1]) + int(b_values[int(m_values[i][1])-1]) - int(m_values[i][2])
    if min > now:
        min = now
now = int(min(a_values)) + int(min(b_values))
if min > now:
  print(now)
else:
  print(min)

### FIXED CODE ###

a, b, m = input().split()
a, b, m = int(a), int(b), int(m)
a_values = input().split()
b_values = input().split()
m_values = {}
for i in range(m):
    m_values[i] = input().split()

min_num = int(a_values[int(m_values[0][0]) - 1]) + int(b_values[int(m_values[0][1]) - 1]) - int(m_values[0][2])
for i in range(1, m):
    now = int(a_values[int(m_values[i][0]) - 1]) + int(b_values[int(m_values[i][1]) - 1]) - int(m_values[i][2])
    if min_num > now:
        min_num = now
now = int(min(a_values)) + int(min(b_values))
if min_num > now:
    print(now)
else:
    print(min_num)
Q,E,v,m=input,exec,[],10**9+7;N,K=map(int,Q().split());from collections import Counter as C;E("v+=Q().split();"*(N-1)+"g,v,r=list(C(v).values()),0,K*(K-1);"+"E(\"i=0;\"+\"r=(r*(K-2-i))%m;i+=1;\"*(g[v]-1));v+=1;"*N);print(r)

### FIXED CODE ###

import sys
mod = 1000000007

sys.setrecursionlimit(10**7)
readline = sys.stdin.readline
N, K = map(int, readline().split())

def P(x, y):
    r = 1
    for i in range(y):
        r = (r * (x - i)) % mod
    return r

G = [[] for _ in range(N)]
for v in range(N-1):
    a, b = map(int, readline().split())
    a, b = a-1, b-1
    G[a].append(b)
    G[b].append(a)

def dfs(bb, v):
    cn = 0
    r = 1
    for u in G[v]:
        if u == bb:
            continue
        cn += 1
        r = (r * dfs(v, u)) % mod
    if cn == 0:
        return 1
    else:
        if bb == None:
            return P(K-1, cn) * r % mod
        else:
            return P(K-2, cn) * r % mod

print((K*dfs(None, 0))%mod)
n,k = map(int,input().split())
L = list(map(int,input().split()))
ok = 0
ng = 10**9
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    cur = 0
    for i in range(n):
        cur += L[i]//mid
    if cur > k:
        ok = mid
    elif cur <= k:
        ng = mid
K = [mid-1, mid, mid+1]
P = []
for i in range(3):
    res = 0
    for j in range(n):
        res += (L[j]-1)//K[i]
    if res <= k:
        P.append(K[i])
print(min(P))


### FIXED CODE ###

n,k = map(int,input().split())
L = list(map(int,input().split()))
ok = 0
ng = 10**9
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    cur = 0
    for i in range(n):
        cur += L[i]//mid
    if cur > k:
        ok = mid
    elif cur <= k:
        ng = mid
K = [mid-1, mid, mid+1]
P = []
for i in range(3):
    res = 0
    if K[i] > 0:
        for j in range(n):
            res += (L[j]-1)//K[i]
        if res <= k:
            P.append(K[i])
print(min(P))
n,m=map(int,input().split())
line=[tuple(map(int,input().split()))for i in range(m)]
from collections import Counter
ans=[]
for i in range(m):
    ans.append(line[i][0])
    ans.append(line[i][1])
data=Counter(ans)
data=sorted(data.items())
for i in range(n):
    print(data[i][1])

### FIXED CODE ###

n,m=map(int,input().split())
line=[tuple(map(int,input().split()))for i in range(m)]
ans=[0]*n
for i in range(m):
    ans[line[i][0]-1]+=1
    ans[line[i][1]-1]+=1
for i in ans:
    print(i)
a,b,c  = map(int, input().split())
d,e,f  = map(int, input().split())
g,h,i  = map(int, input().split())
n=int(input())
A = []
for _ in range(n):
    A.append(int(input())
if (a and b and c) in A:
    print("Yes")
elif (d and e and f) in A:
    print("Yes")
elif (g and h and i) in A:
    print("Yes")
elif (a and d and g) in A:
    print("Yes")
elif (b and e and h) in A:
    print("Yes")
elif (c and f and i) in A:
    print("Yes")
elif (a and e and i) in A:
    print("Yes")
elif (c and e and g) in A:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a,b,c  = map(int, input().split())
d,e,f  = map(int, input().split())
g,h,i  = map(int, input().split())
n=int(input())
A = []
for j in range(n):
    A.append(int(input()))
if (a in A) and (b in A) and (c in A):
    print("Yes")
elif d in A and e in A and f in A:
    print("Yes")
elif g in A and h in A and i in A:
    print("Yes")
elif a in A and d in A and g in A:
    print("Yes")
elif b in A and e in A and h in A:
    print("Yes")
elif c in A and f in A and i in A:
    print("Yes")
elif a in A and e in A and i in A:
    print("Yes")
elif c in A and e in A and g in A:
    print("Yes")
else:
    print("No")
S = input()
for i in range(len(S)-1):
  for j in [i+1,i+2]:
    if S[i] == S[j]:
      print(i+1,j+1)
      exit()
print('-1 -1')

### FIXED CODE ###

S = input()
for i in range(len(S)-2):
  for j in [i+1,i+2]:
    if S[i] == S[j]:
      print(i+1,j+1)
      exit()
if len(S) == 2 and S[0]==S[1]:
  print(1,2)
  exit()
print('-1 -1')
N, a, b = map(int, input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
mod = 10**9+7 #出力の制限
X = 2 * 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
 
for i in range( 2, X + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
 
ax = cmb(N, a, mod)
bx = cmb(N, b, mod)
 
print((pow(2, N) - ax - bx - 1))

### FIXED CODE ###

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

MOD = 10**9+7

def modcmb(n, r, m):
    x = 1
    y = n
    for i in range(2,r+1):
        x *= i
        x %= MOD
        y *= n-i+1
        y %= MOD
    return y * pow(x, m-2, m) % m

ans = pow(2, N, MOD) - modcmb(N, a, MOD) - modcmb(N, b, MOD) - 1
print(ans % MOD)
S = input()
K = int(input())

s = list(set(map(int,S)))
s.sort

min = 0
if s[0] == 1:
    min = s[1]
else:
    min = s[0]
    
if (K == 1 and s[0] == 1):
    print(1)
else:
    print(min)

### FIXED CODE ###

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

num = 1
one_cnt = 0
for i in s:
    if i != 1:
        num = i
        break
    else:
        one_cnt += 1
if (one_cnt >= K):
    print(1)
else:
    print(num)
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
  res = INF
  for S in [s[b - 1], s[b]]:
    for T in [t[d - 1], t[d]]:
    d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
  	res = min(res, d1, d2)
  	print(res)

### FIXED CODE ###

import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)

    res = INF
    for S in s[b-1:b+1]:
        for T in t[d-1:d+1]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)
N,K = map(int,input().split())



if N>=K:
    x = N%K
    print(min(x,abs(K-x))
else:
          N<K
          print(min(N,abs(K-N))

### FIXED CODE ###

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

if N>=K:
    x = N%K
    print(min(x,abs(K-x)))
else:
    print(min(N,abs(K-N)))
n,k = map(int,input().split())
aa = list(map(int,input().split()))

dp = [-1]*(k+1)

for i in range(1,k+1):
  for j in range(n):
    if i >= aa[j]:
      dp[i] = max(dp[i],-dp[i-aa[j]])

if win[k]>0:
  print('first')  
else:
  print('second')      

### FIXED CODE ###

n,k = map(int,input().split())
aa = list(map(int,input().split()))

dp = [-1]*(k+1)

for i in range(1,k+1):
  for j in range(n):
    if i >= aa[j]:
      dp[i] = max(dp[i],-dp[i-aa[j]])

if dp[k]>0:
  print('First')  
else:
  print('Second')
N, K = map(int, input().split())
if (K / N) > 1:
    print(N)
else:
    amari = N % K
    mainasu_noatai = abs(amari - K)
    if (amari > mainasu_noatai):
    	print(mainasu_noatai);
    else:
        print(amari)


### FIXED CODE ###

N, K = map(int, input().split())
if N == 0:
    print(N)
elif int(K / N) > 1:
    print(N)
else:
    amari = N % K
    mainasu_noatai = abs(amari - K)
    if (amari > mainasu_noatai):
    	print(mainasu_noatai);
    else:
        print(amari)