Harryxun/stf_run huggingface dataset:
from operator import mul
from functools import reduce

def comb(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 #出力の制限
N = 10**6 + 1
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 )
    
    
    
r1, c1, r2, c2 = [int(i) for i in input().split()]
 
def calc(r, c):
    a = comb(r + c + 2, r + 1, mod) - r - c - 2
    b = r * (r + 3) / 2
 
    if c == 1:
        return b
    else:
        return a
 
result = calc(r2, c2) - calc(r2, c1 - 1) - calc(r1 - 1, c2) + calc(r1 - 1, c1 - 1)

if result < 0:
  result += 10**9 + 7
print(result)

### FIXED CODE ###

from operator import mul
from functools import reduce

def comb(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 #出力の制限
N = 3 * 10**6
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 )
    
    
    
r1, c1, r2, c2 = [int(i) for i in input().split()]
 
def calc(r, c):
    a = comb(r + c + 2, r + 1, mod) - r - c - 2
    b = r * (r + 3) / 2
 
    if c == 1:
        return b
    else:
        return a
 
result = calc(r2, c2) - calc(r2, c1 - 1) - calc(r1 - 1, c2) + calc(r1 - 1, c1 - 1)
result %= mod
if result < 0:
  result += mod
print(result)
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

count_m = 0
count_z = 0
count_p = 0
sum_abs = 0

for i in range(N):
    if A[i] < 0:
        count_m += 1
        sum_abs -= A[i]
    elif A[i] == 0:
        count_z += 1
    else:
        count_p += 1
        sum_abs += A[i]

if count_m + count_z == 0:
    print(sum_abs-2*min(A))
    tmp = A[0]
    for i in range(N-2):
        print(tmp, A[i+1])
        tmp -= A[i+1]
    

elif count_p + count_z == 0:
    print(sum_abs+2*max(A))
    tmp = A[-1]
    for i in range(N-1):
        print(tmp, A[i])
        tmp -= A[i]
    print(A[2*N])

elif count_p + count_m == 0:
    print(0)
    for i in range(N-1):
        print(0, 0)

else:
    print(sum_abs)
    cmz = count_m + count_z
    tmp = A[-1]
    for i in range(cmz - 1):
        print(tmp, A[i])
        tmp -= A[i]
    tmp_2 = A[cmz-1]
    for i in range(count_p-1):
        print(tmp_2, A[i+cmz])
        tmp_2 -= A[i+cmz]
    print(tmp, tmp_2)

### FIXED CODE ###

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

A = sorted(A)

count_m = 0
count_z = 0
count_p = 0
sum_abs = 0

for i in range(N):
    if A[i] < 0:
        count_m += 1
        sum_abs -= A[i]
    elif A[i] == 0:
        count_z += 1
    else:
        count_p += 1
        sum_abs += A[i]

if count_m + count_z == 0:
    print(sum_abs-2*min(A))
    tmp = A[0]
    for i in range(N-2):
        print(tmp, A[i+1])
        tmp -= A[i+1]
    print(A[-1], tmp)

elif count_p + count_z == 0:
    print(sum_abs+2*max(A))
    tmp = A[-1]
    for i in range(N-1):
        print(tmp, A[i])
        tmp -= A[i]

elif count_p + count_m == 0:
    print(0)
    for i in range(N-1):
        print(0, 0)

else:
    print(sum_abs)
    cmz = count_m + count_z
    tmp = A[-1]
    for i in range(cmz - 1):
        print(tmp, A[i])
        tmp -= A[i]
    tmp_2 = A[cmz-1]
    if count_p != 0:
        for i in range(count_p-1):
            print(tmp_2, A[i+cmz])
            tmp_2 -= A[i+cmz]
        print(tmp, tmp_2)
l=lambda: sys.stdin.readline().strip()
i,x=1,l()
while x !='0':
	print(f"Case {i}: {x}")
	i,x=i+1,l()

### FIXED CODE ###

i,x=1,input()
while x !='0':
	print("Case {}:".format(i),x)
	i+=1;x=input()
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
    if a[a[i]-1]-1 == i:
        ans += 1
print(ans//2)



### FIXED CODE ###

s = input()
print(s[:4]+' '+s[4:])
N = int(input())

Tmp = []
Tmp = input().rstrip().split(' ')

nAns = [ 0 for i in range(4)]
Flag = 0
for i in range(N):
  S = Tmo[i]
  if S=='G':
    Flag = 1

if Flag==1:
  print('Four')
else:
  print('Three')




### FIXED CODE ###

nCount = 0
nP = 0
nW = 0
nG = 0
nY = 0

N = int(input())
nData = []
nData  = input().rstrip().split(' ')

for i in range(N):
    sTmp = nData[i]
    if sTmp == 'P':
        nP = 1
    elif sTmp == 'W':
        nW = 1
    elif sTmp == 'G':
        nG = 1
    elif sTmp == 'Y':
        nY = 1
    
nCount = nP + nW + nG + nY

if nCount == 3:
    print('Three')
else:
    print('Four')
m,n,k=input().split()
a=input().split()
b=input().split()
ta=0
cnta=0
while ta+int(a[cnta])<=int(k) and int(cnta)<int(n):
    ta= ta+ int(a[cnta])
    cnta=cnta+1
tb=0
cntb=0
while cntb<int(m) and ta+tb+int(b[cntb])<=int(k):
    tb = tb+ int(b[cntb])
    cntb=cntb+1 
ans=cnta+cntb

while cnta<=0:
    ta=ta-a[cnta]
    cnta=cnta-1
    while cntb<int(m) and ta+tb+int(b[cntb])<=int(k):
        tb= tb+ int(b[cntb])
        cntb=cntb+1
    ans=max(ans,cnta+cntb)
print(ans)


### FIXED CODE ###

n,m,k=input().split()
a=input().split()
b=input().split()
ta=0
cnta=0
while int(cnta)<int(n) and ta+int(a[cnta])<=int(k) :
    ta= ta+ int(a[cnta])
    cnta=cnta+1
tb=0
cntb=0
while cntb<int(m) and ta+tb+int(b[cntb])<=int(k):
    tb = tb+ int(b[cntb])
    cntb=cntb+1 
ans=cnta+cntb

while cnta-1>=0:
    ta=ta-int(a[cnta-1])
    cnta=cnta-1
    while cntb<int(m) and ta+tb+int(b[cntb])<=int(k):
        tb= tb+ int(b[cntb])
        cntb=cntb+1
    ans=max(ans,cnta+cntb)
print(ans)
print(2*pi)

### FIXED CODE ###

print(int(input())*6.3)
# -*- coding: utf-8 -*-

import math

N = int(input())
_N = N

size = int (math.log10(N) + 1)

f = 0
while(size > 0):
    if(size > 1):
        f += int(N/(10**(size-1)))
        N %= 10**(size-1)
    else:
        f += N
    size -= 1

if(_N%f == 0):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

cost = B

if(N*A < B):
    cost = N*A

print(cost)
# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_b


from itertools import combinations
from collections import defaultdict

N = int(input())
points = [tuple(map(int, input().split())) for _ in range(N)]

cnts = defaultdict(lambda: 0)
for pa, pb in combinations(points, 2):
    dx = pa[0] - pb[0]
    dy = pa[1] - pb[1]
    if dx < 0:
        dx *= -1
        dy *= -1
    cnts[(dx, dy)] += 1

print(N - max(cnts.values()))


### FIXED CODE ###

# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_b


from itertools import combinations
from collections import defaultdict

N = int(input())
points = [tuple(map(int, input().split())) for _ in range(N)]

if N == 1:
    print(1)
    exit()

# points.sort()  # 先にソートしておくと大小関係の処理が楽

cnts = defaultdict(lambda: 0)
for pa, pb in combinations(points, 2):
    dx = pa[0] - pb[0]
    dy = pa[1] - pb[1]
    if dx < 0:  # 事前にソートしておくとココらへんの処理がいらなくなるよ
        dx *= -1
        dy *= -1
    if dx == 0:
        dy = max(dy, -dy)
    if dy == 0:
        dx = max(dx, -dx)
    cnts[(dx, dy)] += 1

print(N - max(cnts.values()))
A = int(input())
B = int(input())
C = A * B
print(C)

### FIXED CODE ###

a, b = map(int, input().split())
print(a * b)
import bisect
n,m = map(int,input().split())

al = list(map(int,input().split()))
al = sorted(al)


cbl = []
for _ in range(m):
    b,c = map(int,input().split())
    cbl.append((c,b))

sumal = [0]
suma = 0
for a in al:
    suma += a
    sumal.append(suma)
    
cbl = sorted(cbl, reverse=True)

topn = [0 for i in range(n)]
pos = 0
for c,b in cbl:
    for _ in range(b):
        topn[pos] = c
        pos += 1
        if pos == n-1:
            break
    else:
        continue
    break

sumtopn = [0]
sumtop = 0
for t in topn:
    sumtop += t
    sumtopn.append(sumtop)
ans = 0
for i in range(n+1):
    left = sumal[-1] - sumal[i]
    right = sumtopn[i]
    tmp = left + right
    if tmp > ans:
        ans = tmp
        
print(ans)
    

### FIXED CODE ###

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

al = list(map(int,input().split()))
al = sorted(al)


cbl = []
for _ in range(m):
    b,c = map(int,input().split())
    cbl.append((c,b))

sumal = [0]
suma = 0
for a in al:
    suma += a
    sumal.append(suma)
    
cbl = sorted(cbl, reverse=True)

topn = [0 for i in range(n)]
pos = 0
for c,b in cbl:
    for _ in range(b):
        topn[pos] = c
        pos += 1
        if pos == n:
            break
    else:
        continue
    break

sumtopn = [0]
sumtop = 0
for t in topn:
    sumtop += t
    sumtopn.append(sumtop)
ans = 0
for i in range(n+1):
    left = sumal[-1] - sumal[i]
    right = sumtopn[i]
    tmp = left + right
    if tmp > ans:
        ans = tmp
        
print(ans)
r,d,x = map(int,input().split())
ansl =[x]
for i in range(10):
  ans = r*ansl[i] - d
  print(ans)

### FIXED CODE ###

r,d,x = map(int,input().split())
ansl =[x]
for i in range(10):
  ans = r*ansl[i] - d
  print(ans)
  ansl.append(ans)
import numpy as np
from numba import njit

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

@njit(cache=True)
def light(n,a_list):
    outcome= np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome

for _ in range(k):
    if min(a) == n:
        break
    a = light(n,a)

[print(aa,end=' ') for aa in a]

### FIXED CODE ###

import numpy as np
from numba import njit

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

@njit(cache=True)
def light(n,a_list):
    outcome= np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome

for _ in range(k):
    if min(a) == n:
        break
    a = light(n,a)

[print(aa,end=' ') for aa in a]
A = int(input())
B = int(input())
print((A - 1) * (B - 1))


### FIXED CODE ###

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

ans = (a - 1) * (b - 1)
print(ans)
a, b = map(int, input())
print("Possible" if (a+b)%3==0 or a%3==0 or b%3==0 else "Impossible")

### FIXED CODE ###

a, b = map(int, input().split())
print("Possible" if (a+b)%3==0 or a%3==0 or b%3==0 else "Impossible")
_ = int(input())
l = list(map(int, input().split()))

ans = 10 ** 9

for n in l:
    count = 0
    while n % 2 == 0:
        n //= 2
        count += 1
    ans = min(ans, count)

print(ans)


### FIXED CODE ###

s = input()
print(s.count('1'))
a=input()
print(a+a^2+a^3)

### FIXED CODE ###

a=int(input())
print(a+a**2+a**3)
n = int(input())
print(sum([i for i in range(1, n+1) if and i%5 != 0 and i%3 != 0]))

### FIXED CODE ###

n = int(input())
print(sum([i for i in range(1, n+1) if i%5 != 0 and i%3 != 0]))
import itertools

n,m = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(m)]
ab = [[False]*n for _ in range(n)] 
for i in range(n):
  ab[AB[i][0]-1][AB[i][1]-1] = 1
  ab[AB[i][1]-1][AB[i][0]-1] = 1

ans = 0
for que in itertools.permutations(range(n), n):
  if que[0] == 0:
    for k in range(n):
      if k == n-1:
        ans += 1
      else:
        if ab[que[k]][que[k+1]] != 1:
          break
      

print(ans)

### FIXED CODE ###

import itertools
n,m = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(m)]
a = [0]*n
for x,y in A:
  a[x-1] |= 1<<(y-1)
  a[y-1] |= 1<<(x-1)

def bitdp(n, a):
  dp = [[0]*n for _ in range(1<<n)]
  dp[1][0] = 1
  
  for bit in range(1<<n):
    for v in range(n):
      if bit & 1<<v:
        sub = bit ^ (1<<v)
        
        for u in range(n):
          if (sub & 1<<u) and (a[v] & 1<<u):
            dp[bit][v] += dp[sub][u]
  ans = sum(dp[(1<<n)-1][u] for u in range(1,n))
  return ans

ans = bitdp(n,a)
print(ans)
import sys 
input =sys.stdin.readline 
from deciaml import Decimal 

def main():
	a,b= list(map(Decimal,input().strip().split()))
	print(int(a*b))

main()

### FIXED CODE ###

import sys 
input =sys.stdin.readline 
from decimal import Decimal 

def main():
	a,b= list(map(Decimal,input().strip().split()))
	print(int(a*b))

main()
from heapq import heappop, heappush
mod = 10**9+7
n, k = map(int, input().split())
a = [int(x) for x in input().split()]


def sgn(x):
    if x >= 0:
        return 0
    elif x < 0:
        return 1


pl = []
mn = []

for x in a:
    if x >= 0:
        pl.append(x)
    elif x < 0:
        mn.append(-x)

pl = sorted(pl, reverse=True)
mn = sorted(mn, reverse=True)


b = [(abs(a[i]), sgn(a[i])) for i in range(n)]
b = sorted(b, reverse=True)

c = [0, 0]
for i in range(k):
    c[b[i][1]] += 1


def solve(c):
    ans = 1
    for i in range(c[0]):
        ans *= pl[i]
        ans %= mod
    for i in range(c[1]):
        ans *= mn[i]
        ans %= mod
    return ans


if c[1] % 2 == 0:
    print(solve(c))
    exit()

if len(mn) == n and k % 2:
    tmp = 1
    for i in range(k):
        tmp *= mn[-i-1]
        tmp %= mod
    ans = -tmp
    print(ans % mod)
    exit()

ans = 0

chk1 = False
chk2 = False

if c[0] <= len(pl) - 1:
    chk1 = True

if 0 < c[0] and c[1] <= len(mn)-1:
    chk2 = True

if chk1 and chk2:
    tmp1 = pl[c[0]]*pl[c[0]-1]
    tmp2 = mn[c[1]]*mn[c[1]-1]
    if tmp1 > tmp2:
        c[0] += 1
        c[1] -= 1
        print(solve())
    else:
        c[0] -= 1
        c[1] += 1
        print(solve())
elif chk1:
    c[0] += 1
    c[1] -= 1
    print(solve())
elif chk2:
    c[0] -= 1
    c[1] += 1
    print(solve())
else:
    print(solve())


### FIXED CODE ###

from heapq import heappop, heappush
mod = 10**9+7
n, k = map(int, input().split())
a = [int(x) for x in input().split()]


def sgn(x):
    if x >= 0:
        return 0
    elif x < 0:
        return 1


pl = []
mn = []

for x in a:
    if x >= 0:
        pl.append(x)
    elif x < 0:
        mn.append(-x)

pl = sorted(pl, reverse=True)
mn = sorted(mn, reverse=True)


b = [(abs(a[i]), sgn(a[i])) for i in range(n)]
b = sorted(b, reverse=True)

c = [0, 0]
for i in range(k):
    c[b[i][1]] += 1


def solve(c):
    ans = 1
    for i in range(c[0]):
        ans *= pl[i]
        ans %= mod
    for i in range(c[1]):
        ans *= mn[i]
        ans %= mod
    if c[1] % 2:
        ans = (-ans) % mod
    return ans


if c[1] % 2 == 0:
    print(solve(c))
    exit()

if len(mn) == n and k % 2:
    tmp = 1
    for i in range(k):
        tmp *= mn[-i-1]
        tmp %= mod
    ans = -tmp
    print(ans % mod)
    exit()

ans = 0

chk1 = False
chk2 = False

if c[0] <= len(pl) - 1:
    chk1 = True

if 0 < c[0] and c[1] <= len(mn)-1:
    chk2 = True

if chk1 and chk2:
    tmp1 = pl[c[0]]*pl[c[0]-1]
    tmp2 = mn[c[1]]*mn[c[1]-1]
    if tmp1 > tmp2:
        c[0] += 1
        c[1] -= 1
        print(solve(c))
    else:
        c[0] -= 1
        c[1] += 1
        print(solve(c))
elif chk1:
    c[0] += 1
    c[1] -= 1
    print(solve(c))
elif chk2:
    c[0] -= 1
    c[1] += 1
    print(solve(c))
else:
    print(solve(c))
import math.factorial as mf

def select(N,K):
  a=mf(N)/(mf(K)*mf(N-K))
  return a

### FIXED CODE ###

x=input()
xx=x.split()
b=int(xx[0])
c=int(xx[1])
a=b-c+1
print(a)
# -*- encoding: utf-8 -*-
n = int(input().rstrip())
array = sorted(list(map(int, input().rstrip().split(' '))))
count = [0] * (10 ** 5)

for a in array:
    count[a - 1] += 1
    count[a    ] += 1
    count[a + 1] += 1

print(max(count))

### FIXED CODE ###

# -*- encoding: utf-8 -*-
n = int(input().rstrip())
array = sorted(list(map(int, input().split(' '))))
count = [0] * 100002

for a in array:
    count[a - 1] += 1
    count[a    ] += 1
    count[a + 1] += 1

print(max(count))
print("Yes" if all(i % 2 == 0 for i in Counter(input()).values()) else "No")


### FIXED CODE ###

from collections import Counter

print("Yes" if all(i % 2 == 0 for i in Counter(input()).values()) else "No")
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
k_list = []

flag = True

if sum(a) + sum(b) <= k:
    flag = False
    print(n+m)

while k > 0:
    if len(a) != 0 and a[0] <= b[0]:
        k -= a.pop(0)
        ans += 1
    else:
        k -= b.pop(0)
        ans += 1


if flag:
    print(ans-1)


### 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 = 0
# bを全部読む
j = M

for i in range(N + 1):
    # aは0冊から始まる
    if a[i] > K:
        break

    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
    
    
print(ans)
#D
from collections import deque
Str = str(input())
Q = int(input())
S = deque()
S.append(Str)
for i in range(Q):
    a = list(map(str, input().split()))
    if a[0] == '1':
        S.reverse()
    elif a[1] == '1':
        S.insert(0, a[2])
    else:
        S.append(a[2])

print(''.join(S))

### FIXED CODE ###

#D
from collections import deque
Str = str(input())
Q = int(input())
S = deque(list(Str))
#S.append(list(Str))
#上の方法ではダメ
A = 0
B = []
C = []

for i in range(Q):
    a = list(map(str, input().split()))
    if a[0] == '1':
        if A%2==0:
            if len(B)>1:
                S.extendleft(B)
                B = []
            elif len(B) == 1:
                S.extendleft(B)
                B = []
            if len(C) > 0:
                S.extend(C)
                C = []
        else:
            if len(C)>1:
                S.extendleft(C)
                C = []
            elif len(C) == 1:
                S.extendleft(C)
                C = []
            if len(B) > 0:
                S.extend(B)
                B = []
        A += 1
    elif a[1] == '1':
        B.append(a[2])
    else:
        C.append(a[2])

if a[0] != '1':
    if A%2==0:
        if len(B)>1:
            S.extendleft(B)
            B = []
        elif len(B) == 1:
            S.extendleft(B)
            B = []
        if len(C) > 0:
            S.extend(C)
            C = []
    else:
        if len(C)>1:
            S.extendleft(C)
            C = []
        elif len(C) == 1:
            S.extendleft(C)
            C = []
        if len(B) > 0:
            S.extend(B)
            B = []

if A%2 != 0:
    S.reverse()
print(''.join(S))
# -*- coding: utf-8 -*-

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

x = [-1]
y = [-1]
for i in range(m):
    x_in, y_in = map(int, input().split())
    x.append(x_in)
    y.append(y_in)

memo = [-1] * (n + 1)
ans = -1


def dp(i):
    if memo[i] == -1:
        ret = 0
        for j in range(m + 1)[1:]:
            if x[j] == i:
                tmp = dp(y[j]) + 1
                ret = max(tmp, ret)
        memo[i] = ret
        return ret
    else:
        return memo[i]


for i in x[1:]:
    tmp = dp(i)
    ans = max(tmp, ans)

print("{}".format(ans))


### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import deque

from sys import setrecursionlimit

setrecursionlimit(1000000)

INF = float("inf")
# Input#
# n = int(input())
n, m = map(int, input().split())
# a = list(map(int, input().split()))

d = deque()
d_tmp = deque()
x = [-1]
y = [[-1] for _ in range((n + 1))]

for _ in [0] * m:
    x_in, y_in = map(int, input().split())
    #    x.append(x_in)
    y[x_in].append(y_in)
    d.append((x_in, y_in))

memo = [-1] * (n + 1)
ans = -1


def dp(i):
    global ans
    if memo[i] == -1:
        ret = 0
        for x_in in y[i][1:]:
            tmp = dp(x_in) + 1
            if tmp > ret:
                ret = tmp
        memo[i] = ret
        if ret > ans:
            ans = ret
        return ret
    else:
        return memo[i]


for i, _ in d:
    if memo[i] == -1:
        dp(i)

print("{}".format(ans))
N = int(input())
a = list(map(int, input().split()))
c = 0
bool = True


while (bool):
    for i in range(N):
        if a[i] % 2 == 0:
            a[i] = a[i] / 2
        else:
            bool = False
            break    
    else:
        c += 1

### FIXED CODE ###

a = input()
count = 0

for i in range(3):
    if a[i] == "1":
        count += 1
print(count)
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [i-1 for i in A]

check = [0]*N
i = 0
c = 0
check = []
visited = [0]*N
flag = False
while c<=K:
    if visited[i] == 1:
        flag = True
        break
    else:
        check.append(i)
        visited[i] = 1
        i = A[i]
        c += 1
if flag==True:
    X = check[check.index(i):]
    print(1+X[(K-check.index(i))%(len(check)-check.index(i)))  
else: 
    print(i+1)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [i-1 for i in A]

check = [0]*N
i = 0
c = 1
check = []
visited = [0]*N
flag = False
while c<=K:
    if visited[i] == 1:
        flag = True
        break
    else:
        check.append(i)
        visited[i] = 1
        i = A[i]
        c += 1
if flag==True:
    X = check[check.index(i):]
    print(1+X[(K-check.index(i))%len(X)])  
else: 
    print(i+1)
N=int(input())
arr0=[]
arr1=[]
arr2=[]
arr3=[]
arr4=[]
arr5=[]
arr6=[]
arr7=[]
arr8=[]
arr9=[]
arrs=[arr0,arr1,arr2,arr3,arr4,arr5,arr6,arr7,arr8,arr9]

amount=0

for n in range(N):
    _=int(input())
    a = _//100000000
    if arrs[a].count(_)>=1:
        arrs[a].remove(_)
    else:
        arrs[a].append(_)

for x in range(len(arrs)):
    amount +=len(arrs[x])

print(amount)

### FIXED CODE ###

N=int(input())
S=set()

for n in range(N):
    _=int(input())
    if _ in S:
        S.remove(_)
    else:
        S.add(_)

print(len(S))
n=int(input())
z=0
for i in range(n):
  a,b=intput().split()
  if b=="BTC":
    z += a*380000
  else:
    z += a
print(z)

### FIXED CODE ###

n=int(input())
z=0
for i in range(n):
  a,b=input().split()
  if b=="BTC":
    z += float(a)*380000
  else:
    z += int(a)
print(z)
a,b,c = map(str, input().split())
if (a=b or b=c or c=a):
  if(not a=b=c): print("YES")
  else: print("NO")
else: print("NO")

### FIXED CODE ###

a,b,c = map(int, input().split())
if a==b and b<c: print("YES")
elif b==c and c<a: print("YES")
elif c==a and a<b: print("YES")
else: print("NO")
N = int(input())
A = list(map(int,input().split()))
Nc = 1
if A.count(0) >= 2:
    Nc *= 0
else:
    for i in range(N):
        if (N-A[i]) >=1
                if A.count(i+1) == 2:
                    Nc = Nc*2%1000000007
                elif A.count(i+1) == 0:
                    Nc *= 1
                else:
                    Nc *= 0
                    break
        else:
            Nc *= 0
            break

print(Nc)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
Nc = 1
e = 0
B = [0]*N
for i in A:
    if (N-i-1) < 0:
        e = 1
        Nc = 0
        break
if e ==0:
    if A.count(0) >= 2:
        Nc *= 0
    else:
        if A.count(0) == 1:
            A.remove(0)
        for i in A:
            B[i] = B[i] + 1
        for i in B:
            if i == 2:
                Nc *= 2
            elif i == 0:
                Nc *= 1
            else:
                Nc *= 0
                break
print(Nc%1000000007)
s,t=map(str,input().split(" "))
a,b=map(int,input().split(" "))
u=str(input())

if s==u:
  print(a-1" "b)
else:
  print(a" "b-1)

### FIXED CODE ###

s,t=input().split(" ")
a,b=map(int,input().split(" "))
u=input()
 
if s==u:
  print(a-1, b)
else:
  print(a, b-1)
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a) 

for i in range(m):
  max_ = a.heappop()
  d = max_ // 2
  a.heappush(d)

print(sum(a))

c = 0
for i in range(len(a)):
  c += a.heappop()
print(c)

### FIXED CODE ###

import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a) 

for i in range(m):
  max_ = -heapq.heappop(a)
  d = max_ // 2
  heapq.heappush(a, -d)

c = 0
for i in range(len(a)):
  c -= heapq.heappop(a)
print(c)
ans = []
N,T = map(int,input().split())
for i in range(N):
  c,t = map(int,input().split())
  if t <= T:
    ans = min(anc,c)
  if not a:
    print("TLE")

### FIXED CODE ###

n,o = map(int, input().split())
ans = 1001
for i in range(n):
  c,t = map(int, input().split())
  if t <= o and c <= ans:
    ans =  c
if ans == 1001 : print("TLE")
else : print(ans)