Harryxun/stf_run huggingface dataset:
def wa(h, w, f):
    if not (0 <= h <= H-1 and 0 <= w <= W-1):
        return
    elif mapp[h][w] != f:
        return
    else:
        mapp[h][w] = '$'
        wa(h, w+1, f)
        wa(h-1, w, f)
        wa(h, w-1, f)
        wa(h+1, w, f)

while True:
    H, W = map(int, raw_input().split(' '))
    if H == 0 and W == 0: break
    mapp = [list(raw_input()) for i in range(H)]
    count = 0
    for h in range(H):
        for w in range(W):
            if mapp[h][w] == '@':
                wa(h, w, '@')
            elif mapp[h][w] == '#':
                wa(h, w, '#')
            elif mapp[h][w] == '*':
                wa(h, w, '*')
            else:
                continue
            count += 1
    else:
        print count

### FIXED CODE ###

import sys
sys.setrecursionlimit(20000)
def wa(h, w, f):
    if not (0 <= h < H and 0 <= w < W):
        return
    elif mapp[h][w] != f:
        return
    else:
        mapp[h][w] = '$'
        wa(h, w+1, f)
        wa(h-1, w, f)
        wa(h, w-1, f)
        wa(h+1, w, f)

while True:
    H, W = map(int, raw_input().split())
    if H == 0 and W == 0: break
    mapp = [list(raw_input()) for i in range(H)]
    count = 0
    for h in range(H):
        for w in range(W):
            if mapp[h][w] == '@':
                count += 1
                wa(h, w, '@')
            elif mapp[h][w] == '#':
                count += 1
                wa(h, w, '#')
            elif mapp[h][w] == '*':
                count += 1
                wa(h, w, '*')
    else:
        print count
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=0

for i in range(n):
    eat=a[i]-1
    ans+=b[eat]
    if eat+1==a[i+1]:
        ans+=c[eat]
print(ans)

### FIXED CODE ###

n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=0

for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans+=c[a[i]-1]
print(ans+sum(b))
a,b=map(int,input().spit())
i = a
c = 1
while i < b:
  i += a - 1
  c += 1
if b == 1:
  print(0)
else:
  print(c)

### FIXED CODE ###

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

i = a
c = 1
while int(i) < int(b):
  i += int(a) - 1
  c += 1
if int(b) == 1:
  print(0)
else:
  print(c)
i = 0
while 1:
   x = raw_input()
   i = i +1
   if x == '0': 
      break
   print 'Case %s: %s' % (i, x)

### FIXED CODE ###

i = 0
while 1:
   x = int(raw_input())
   i = i + 1
   if x == 0:
      break
   print 'Case %s: %s' %(i, x)
class add():
    def __init__(self,a,b):
        self.a = a
        self.b = b

    def add(self):
        return self.a+self.b

def main():
    data_set = []
    ds_max = 200

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

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

        data_set.append(add(a,b))

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


if __name__ == "__main__":
    main()

### FIXED CODE ###

import math

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

    for i in data:
        print(i)

if __name__ == "__main__":
    main()
a,b=map(int,input().split())

print(a if a<=b else: a-1)
  

### FIXED CODE ###

a,b=map(int,input().split())
print(a if a<=b else a-1)
while True:
 m,f,r=map(int,input().split())
 if m==f==r==-1 : break
 if((m==-1) or (f==-1))
   print('F')

 if(m+f>=80)
   print('A')

 if(65<= m+f) and (m+f<80))
   print('B')

 if(50<= m+f) and (m+f<60))
   print('C')

 if(30<= m+f) and (m+f<50))
   if(50<=r)
    print('C')
   else
    print('D')

 if(m+f<30)
   print('F')



 

### FIXED CODE ###

while True:
 m,f,r=map(int,input().split())
 if m==f==r==-1 : break

 if m==-1 or f==-1 :
   print('F')

 elif (m+f)>=80 :
   print('A')

 elif 65<= (m+f) and (m+f)<80 :
   print('B')

 elif 50<= (m+f) and (m+f)<65 :
   print('C')

 elif 30<=(m+f) and (m+f)<50 :
   if 50<=r :
    print('C')
   else:
    print('D')

 elif (m+f)<30 :
   print('F')
a, b = map(int, input().split())
print(math.ceil((b-1)/(a-1)))

### FIXED CODE ###

import math
a, b = map(int, input().split())
print(math.ceil((b-1)/(a-1)))
n = int(input())
v = list(map(int,input().split()))
v.sort()
r = v[0]
for i in r:
  r = (r + i) / 2
print(r)

### FIXED CODE ###

n = int(input())
v = [int(i) for i in input().split()]
v.sort()
ans = (v[0] + v[1]) / 2
for i in range(2, len(v)):
    ans = (ans + v[i]) / 2
print(ans)
from collections import deque
N, L = map(int, input().split())
c = list(map(int, input().split()))
for i in range(len(c)-1):
  if c[i] + c[i+1] >= L:
    pos = i + 1
    break
else:
  print("Impossible")
  
for i in range(1,pos):
  print(i)
for i in range(len(c) -1, pos, -1):
  print(i)

### FIXED CODE ###

from collections import deque
N, L = map(int, input().split())
c = list(map(int, input().split()))
for i in range(len(c)-1):
  if c[i] + c[i+1] >= L:
    pos = i + 1
    break
else:
  print("Impossible")
  exit()

print("Possible")
for i in range(1,pos):
  print(i)
for i in range(len(c) -1, pos, -1):
  print(i)
print(pos)
temp = raw_input()
temp_list = temp.split()
a = temp_list[0]
b = temp_list[1]
c = temp_list[2]
 
count = 0
for i in range(a,b):
  if c/i == 0:
    count += 1
 
print(count)


### FIXED CODE ###

temp = raw_input()
temp_list = temp.split()
a = int(temp_list[0])
b = int(temp_list[1])
c = int(temp_list[2])

count = 0
for i in range(a,b+1):
  if c%i == 0:
    count += 1

print(count)
from sys import stdin
s = list(stdin.readline().rstrip())
counts=[]
count=0
for i in s:
    if i in ['A','G','C','T']:
        count+=1
    else:
        counts.append(count)
        count=0
print(max(counts))

### FIXED CODE ###

from sys import stdin
s = list(stdin.readline().rstrip())
counts=[]
count=0
for i in s:
    if i in ['A','G','C','T']:
        count+=1
        counts.append(count)
    else:
        count=0
        counts.append(count)
print(max(counts))
a,b=map(str,input().split())
b=int(float(b)*100)
a=int(a)*b
a//=100
print(int(a))

### FIXED CODE ###

a,b=map(str,input().split())
b=b[0]+b[2]+b[3]
b=int(b)
a=int(a)*b
a//=100
print(int(a))
N = input()

def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0')) #

### FIXED CODE ###

N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0')) #
n = int(input())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7
ans = 0

for k in range(60):
    x, y = 0, 0
    for a in A:
        x += 1 & a >> k
    tmp = x * (n - x) % mod
    tmp *= pow(2, k, mod)
    ans += tmp
    ans %= mod
print(ans)

### FIXED CODE ###

def main():
    n = int(input())
    A = list(map(int, input().split()))

    mod = 10**9+7
    ans = 0

    for k in range(60):
        x, y = 0, 0
        for a in A:
            x += 1 & a>>k
        tmp = x*(n-x)%mod
        tmp *= pow(2, k, mod)
        ans += tmp
        ans %= mod
    print(ans)


if __name__ =='__main__':
    main()
from collections import deque
 
s = input()
q = int(input())
ans = deque(s)
cnt = 0
for i in range(q):
    f = [i for i in input().split()]
    if f[0] == '1':
        cnt += 1
    else:
        if f[1] == '1':
            if cnt % 2 == 0:
                ans.appendleft(f[2])
            else:

### FIXED CODE ###

from collections import deque
 
s = input()
q = int(input())
ans = deque(s)
cnt = 0
for i in range(q):
    f = [i for i in input().split()]
    if f[0] == '1':
        cnt += 1
    else:
        if f[1] == '1':
            if cnt % 2 == 0:
                ans.appendleft(f[2])
            else:
                ans.append(f[2])
        else:
            if cnt % 2 == 0:
                ans.append(f[2])
            else:
                ans.appendleft(f[2])
if cnt % 2 != 0:
    ans.reverse()
print(''.join(map(str,ans)))
def remove(data):
    global result
    pos = min(len(data), max(data))
    for n in range(pos-1, -1, -1):
        if data[n] == n + 1:
            result.append(data.pop(n))
            #print('remove {0} '.format(n + 1), end='')
            if len(data) == 0:
                #print('OK')
                return True
            else:
                #print(data)
                if remove(data):
                    return True
    else:
        return False

_ = input()
B = list(map(int, input().split()))

result = []

if remove(B):
    result.reverse()
    for res in result:
        print(res)
else:
    print(-1)


### FIXED CODE ###

_ = input()
data = list(map(int, input().split()))

result = []
pos = min(len(data), max(data)) - 1

while pos >= 0:
    if data[pos] == pos + 1:
        x = data.pop(pos)
        #print('remove {0} {1}'.format(x, data))
        result.append(x)
        if len(data) == 0:
            break
        pos = min(len(data), max(data)) - 1
    else:
        pos -= 1

if len(data) == 0:
    result.reverse()
    for res in result:
        print(res)
else:
    print(-1)
N, L = map(int, input().split())
S = [input() for i in range(N)]
for i in range(3):
    print(sorted(S)[i], end="")

### FIXED CODE ###

N, L = map(int, input().split())
S = [input() for i in range(N)]
for i in range(N):
    print(sorted(S)[i], end="")
#D
import numpy as np
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N-1):
    B=np.full(len(A)-i-1,A[i])
    C=np.bitwise_xor(A[i+1:],B)
    ans+=np.sum(C)
print(ans%(10**9+7))

### FIXED CODE ###

#ABC147_D
#N個の数字から2個選ぶの全組み合わせのXORを足してmodする問題

import numpy as np

N = int(input())
arr = np.array([int(i) for i in input().split()])
ans = 0
mod=10**9+7


for i  in range(60):
    c1=np.count_nonzero(arr&1)#arrの最下位bitの論理和。arrの最下位bitが1の数をカウント
    c0=N-c1#arrの最下位bitが0の数
    ans+=2**i*c1*c0#c1個の中から1つ選ぶ組み合わせとc0個の中から1つ選ぶ組み合わせの掛け算が、該当bitがXOR＝１となる組み合わせの数
    arr>>=1#最下位bitを変更
print(ans%mod)
import bisect

n, m = list(map(int, input().split()))
cl = list(map(int, input().split()))
cl.sort()
ql=[]
for _ in range(m):
    b, c = list(map(int, input().split()))
    for _ in range(b):
        ql.append(c)
ql.sort()
ql.reverse()
ans=0
i = 0
for c in cl:
    if c < ql[i]:
        ans+=ql[i]
        i+=1
    else:
        ans+=c
print(ans)

### FIXED CODE ###

n, m = list(map(int, input().split()))
cl = list(map(int, input().split()))
cl.sort()
ql=[]
for _ in range(m):
    b, c = list(map(int, input().split()))
    ql.append([b,c])
ql.sort(key=lambda x: x[1],reverse=True)
i, j = 0,0
while i < len(cl) and j < len(ql):
    if cl[i] < ql[j][1]:
        cl[i] = ql[j][1]
        ql[j][0] -=1
        if ql[j][0] == 0:
            j+=1
    i+=1
print(sum(cl))
n,m=map(int,input().split())
x=[input(i) for i in input().split()]

x.sort()
y=[]
if n-m>=0:
  print(0)
  exit(0)
else:
  for i in range(m-1):
    y.append(x[i+1]-x[i])
y.sort()
print(sum(y[:n-m+2]))

### FIXED CODE ###

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

x.sort()
y=[]
if n-m>=0:
  print(0)
  exit(0)
else:
  for i in range(m-1):
    y.append(x[i+1]-x[i])
y.sort()
print(sum(y[:m-n]))
s = input()
s[3] = [8]
print(s)

### FIXED CODE ###

s = input()
s = s.replace('2017', '2018')
print(s)
from sys import stdin

def main():
    S=input()
    andbit = 2**10 -1
    ans = 0
    length = 2**(len(S) -1)
    
    # print("length:{}".format(length))
    for i in range (length):
      bitup = andbit & i
      # print("bin(bitup):{}".format(bin(bitup)))
      bitcheck = 1
      tmp=0
      for j in range(1,len(S),1):
        # print("bitup & bitcheck:{}".format(bitup & bitcheck))
        if bitup & bitcheck > 0:
          # print("S[tmp:j]:{}".format(S[tmp:j]))
          ans += int(S[tmp:j])
          tmp = j
        bitcheck = bitcheck << 1
      # print("S[tmp:len(S)]:{}".format(S[tmp:len(S)]))
      ans += int(S[tmp:len(S)])

    print(ans)

input = lambda: stdin.readline()
main()


### FIXED CODE ###

from sys import stdin

S=input()
andbit = 2**10 -1
ans = 0
length = 2**(len(S) -1)
    
for i in range (length):
  bitup = andbit & i
  bitcheck = 1
  tmp=0
  for j in range(1,len(S),1):
    if bitup & bitcheck > 0:
      ans += int(S[tmp:j])
      tmp = j
    bitcheck = bitcheck << 1
  ans += int(S[tmp:len(S)])
print(ans)
#!/usr/bin/env python3

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

if n == 1:
    print(1)
    exit(0)
if n == 2:
    if abs(a[0]-a[1]) <= 2:
        print(2)
    else:
        print(1)
    exit(0)

if n >= 3:
    d = [0 for _ in range(10)]
    for i in range(n):
        d[a[i]] += 1
    ans = 0 
    for i in range(n-2):
        tmp = d[i] + d[i+1] + d[i+2]
        if ans <= tmp:
            ans = tmp 

    print(ans)

### FIXED CODE ###

#!/usr/bin/env python3

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

if n == 1:
    print(1)
    exit(0)
if n == 2:
    if abs(a[0]-a[1]) <= 2:
        print(2)
    else:
        print(1)
    exit(0)

if n >= 3:
    d = [0 for _ in range(100001)]
    for i in range(n):
        d[a[i]] += 1
    ans = 0 
    for i in range(100001-2):
        tmp = d[i] + d[i+1] + d[i+2]
        if ans <= tmp:
            ans = tmp 

print(ans)
N,M = map(int,input().split())
H = list(map(int,input().strip().split()))
xy=[map(int, input().split()) for _ in range(M)]
x, y = [list(i) for i in zip(*xy)]

list=[0]*N
for i in range(M):
    if H[x[i]-1]<H[y[i]-1]:
        list[x[i]-1]+=1
    else:
        list[y[i]-1]+=1
count=0
for i in range(M+1):
    if list[i]==0:
        count+=1

print(count)


### FIXED CODE ###

N,M = map(int,input().split())
H = list(map(int,input().strip().split()))
xy=[map(int, input().split()) for _ in range(M)]
x, y = [list(i) for i in zip(*xy)]

list=[0]*N
for i in range(M):
    if H[x[i]-1]<H[y[i]-1]:
        list[x[i]-1]+=1

    elif  H[x[i]-1]==H[y[i]-1]:
        list[x[i]-1]+=1
        list[y[i]-1]+=1
    else:
        list[y[i]-1]+=1
count=0
for i in range(N):
    if list[i]==0:
        count+=1

print(count)
A, B, C, D =map(int,input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

N_C = (B-A) // C
N_D = (B-A) // D
N_CD = (B-A) // lcm(C,D)

if C == 1:
    ans == 0
elif D == 1:
    ans == 0
else:
    ans = (B-A)-N_C-N_D+N_CD
print(ans)

### FIXED CODE ###

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

ans =(B-A+1)-(B//(C)-(A-1)//C+B//(D)-(A-1)//D-B//lcm(C,D)+(A-1)//lcm(C,D))
print(ans)
n = input()

for i in range(10)+1:
  if n < i * 1000:
    print(i * 1000 - n)
    break


### FIXED CODE ###

n = int(input())
a = (1000 - (n % 1000)) % 1000
print(a)
N = int(input())
A = list(map(int, input().split()))

S = sorted(A)
print(S)

ans = 0
if S[0] == S[1]:
    for i in range(1, N):
        j = 0
        while S[i] % S[j] > 0:
            j += 1
            if i <= j:
                ans += 1
                break
else:
    ans = 1
    for i in range(1, N):
        j = 0
        while S[i] % S[j] > 0:
            j += 1
            if i <= j:
                ans += 1
                break
print(ans)

### FIXED CODE ###

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

MAX = 10 ** 6

A.sort()
s = set()
ans = N
for i in range(N):
    a = A[i]
    if a in s:
        ans -= 1
        continue
    if i < N - 1 and A[i + 1] == a:
        ans -= 1
    n = MAX // a
    for i in range(1, n + 1):
        s.add(a * i)
print(ans)
a,b=map(int, input())
if (a<=9 & b<=9):
  print(a*b)
else:
  print("-1")

### FIXED CODE ###

a,b=map(int, input().split())
if (a<=9 and b<=9):
  print(a*b)
else:
  print("-1")
s = input()
n = int(input())
for i in range(n):
 a = list(input().split())
 temp = s[int(a[1])-1:int(a[2])]
 if a[0] == 'replace':
  s.replace(temp, a[3])
 elif a[0] == 'reverse':
  temp2 = temp[::-1]
  s.replace(temp, temp2)
 elif a[0] == 'print':
  print(s[int(a[1])-1:int(a[2]))
  

### FIXED CODE ###

s = input()
n = int(input())
for i in range(n):
 a = list(input().split())
 temp = s[int(a[1]):int(a[2])+1]
 if a[0] == 'replace':
  temp3 = a[3]
  s = list(s)
  seq = 0
  for i in range(int(a[1]), int(a[2])+1):
   s[i] = temp3[seq]
   seq += 1
  s = ''.join(s)
 elif a[0] == 'reverse':
  temp2 = temp[::-1]
  s = s.replace(temp, temp2, 1)
 elif a[0] == 'print':
  print(temp)
list1 = []
list2 = []
for _ in range(3):
    list1.append(input().split())

for num, li_con in enumerate(list1):
    list2.append(li_con[num])

moji = "".join(list2)
print(moji)

### FIXED CODE ###

list1 = []
list2 = []
for _ in range(3):
    list1.append(input())

for num, li_con in enumerate(list1):
    list2.append(li_con[num])

moji = "".join(list2)
print(moji)
n=int(input())
s=input()
if n%2==0:
  s_1=s[0:n/2]
  s_2=s[n/2:n]
  if s_1==s_2:
    print("Yes")
else:
  print("No")


### FIXED CODE ###

n=int(input())
s=input()
if n%2==0:
    k=int(n/2)
    s_1=s[0:k]
    s_2=s[k:n]
    if s_1==s_2:
        print("Yes")
    else:
        print("No")
else:
    print("No")
import math
R = int(input())
ans = floot(math.pi*R*2)
print(ans)

### FIXED CODE ###

R = int(input())
ans = float(2*R*3.1416)
print(ans)
n = int(input())
S = [int(_) for _ in input().split()]
q = int(input())
T = [int(_) for _ in input().split()]
cnt = 0

# from copy import deepcopy

# for t in T:
#     S_ = deepcopy(S)

#     while S_:
#         ind = len(S_) // 2

#         if t == S_[ind]:
#             cnt += 1
#             break
#         elif t < S_[ind]:
#             S_ = S_[:ind]
#         else:
#             S_ = S_[ind + 1:]


def binary_search(ary, target):

    if ary:
        ind = len(S) // 2
        if target == ary[ind]:
            return True
        elif target < ary[ind]:
            return binary_search(ary[:ind], target)
        else:
            return binary_search(ary[ind + 1:], target)

    else:
        return False


for target in T:
    if binary_search(S, target):
        cnt += 1

if __name__ == '__main__':
    print(cnt)



### FIXED CODE ###

# def binary_search_original(ary, target):

#     if ary:
#         ind = len(ary) // 2
#         if target == ary[ind]:
#             return True
#         elif target < ary[ind]:
#             return binary_search(ary[:ind], target)
#         else:
#             return binary_search(ary[ind + 1:], target)

#     else:
#         return False


def binary_search(ary, target):

    left = 0
    right = len(ary)

    while left < right:
        mid = (left + right) // 2

        if ary[mid] == target:
            return True
        elif ary[mid] < target:
            left = mid + 1
        else:
            right = mid

    return False


if __name__ == '__main__':

    n = int(input())
    S = [int(_) for _ in input().split()]
    q = int(input())
    T = [int(_) for _ in input().split()]
    cnt = 0

    for target in T:
        if binary_search(S, target):
            cnt += 1

    print(cnt)
import math
N = int(input())
town = [list(map(int, input().split())) for _ in range(N)]
path = []
for p in itertools.permutations(town):
    path.append(sum([math.sqrt((p[i+1][0]-p[i][0])**2 + (p[i+1][1]-p[i][1])**2) for i in range(len(p)-1)]))

print(sum(path)/len(path))

### FIXED CODE ###

import math
import itertools
N = int(input())
town = [list(map(int, input().split())) for _ in range(N)]
path = []
for p in itertools.permutations(town):
    path.append(sum([math.sqrt((p[i+1][0]-p[i][0])**2 + (p[i+1][1]-p[i][1])**2) for i in range(len(p)-1)]))

print(sum(path)/len(path))
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
B=[0 for i in range(M)]
C=[0 for i in range(M)]
X=[]
for i in range(M):
    B[i],C[i]=map(int,input().split())
    X.append((B[i],C[i]))
A.sort()
X.sort(key=lambda x:x[1],reverse=True)
index=0
flag=1
for i in range(M):
    tmp=0
    for j in range(index,index+X[i][0]):
        if A[j]<X[i][1]:
            A[j]=X[i][1]
            tmp+=1
        else:
            flag=0
            break
    if flag==0:
        break
    index+=tmp
print(sum(A))

### FIXED CODE ###

N,M=map(int,input().split())
A=[int(i) for i in input().split()]
B=[0 for i in range(M)]
C=[0 for i in range(M)]
X=[]
for i in range(M):
    B[i],C[i]=map(int,input().split())
    X.append((B[i],C[i]))
A.sort()
X.sort(key=lambda x:x[1],reverse=True)
index=0
flag=1
for i in range(M):
    tmp=0
    for j in range(index,index+X[i][0]):
        if not(0<=j<N):
            break
        if A[j]<X[i][1]:
            A[j]=X[i][1]
            tmp+=1
        else:
            flag=0
            break
    if flag==0:
        break
    index+=tmp
print(sum(A))
A, B, C = map(int, input().split)

X = A * B / 2
print(X)

### FIXED CODE ###

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

#X = A * B / 2
# 商の整数値（小数点以下を切り捨て）
X = A * B // 2
print(X)
n = input()
i = int(n)
cnt = 0
ans = 0
while i > 0:
  i /= 10
  cnt++
if cnt / 2 == 0:
  i = cnt / 2
  if i == 3:
      ans = 90000 + 900 + 9
  elif i == 2:
      ans = 900 + 9
  else :
      ans = 9
else :
  i = (cnt / 2) + 1
  if i == 3:
    ans = 9 + 900 + (int(n) - 10000) + 1
  elif i == 2:
    ans = 9 + (int(n) - 100) + 1
  else :
    ans = int(n)
print(ans)


### FIXED CODE ###

n = input()
i = int(n)
cnt = 0
ans = 0
while i >= 1:
  i = int(i) / 10
  cnt = int(cnt) + 1
if int(cnt) % 2 == 0:
  i = cnt / 2
  if i == 3:
      ans = 90000 + 900 + 9
  elif i == 2:
      ans = 900 + 9
  else :
      ans = 9
else :
  i = (int(cnt) / 2) + 1
  if i >= 3:
    ans = 9 + 900 + (int(n) - 10000) + 1
  elif i >= 2:
    ans = 9 + (int(n) - 100) + 1
  else :
    ans = int(n)
print(ans)
S = input()
if S=="AAA" or S="BBB":
  print("No")
else:
  print("Yes")

### FIXED CODE ###

S = input()
if S=="AAA" or S=="BBB":
  print("No")
else:
  print("Yes")
N  = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]

T1 = [x+'*' for x in T]
arr = S + T1
list1 = []
for i in range(len(arr)):
  if arr[i] not

list2 = [] in list2:
    s = arr.count(arr[i])
    t = arr.count(arr[i]+'*')
    a = s-t
    list1.append((arr[i], a))
    list2.append(arr[i])

for i in list1:
  
  if i[0].endswith('*'):
    list1.remove(i)
  print(list1)

ans1 = max(list1, key= lambda x:x[1])

if int(ans1[1]) <= 0:
  print(0)
else:
  print(ans1[1])

### FIXED CODE ###

import collections

N = int(input())
S = [input() for i in range(N)]
cS = collections.Counter(S)
lS = list(cS.items())
M = int(input())
T = [input() for i in range(M)]
cT = collections.Counter(T)
list1 = []
ans = 0

for i in range(len(lS)):
    
    if lS[i][0] in cT:
        x = lS[i][1] - cT[lS[i][0]]
        
    else:
        x = lS[i][1]
        
    if x > 0:
        list1.append(x)
    
if list1 == []:
  print(0)
else:
  print(max(list1))
def main():
	N = int(input())
	K = int(input())

	list = []

	for i in range(N):
		list.append(int(input()))
	
	list.sort()

	part = list[0:K]

	print(sum(part))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
  N, K = map(int, input().split())

  price = list(map(int, input().split()))

  price.sort()

  part = price[0:K]

  print(sum(part))

if __name__ == '__main__':
  main()
a, b = map(int(input().split()))
if a == b:
	print('Draw')
elif a == 1:
	print('Alice')
elif b == 1:
	print('Bob')
elif a > b:
	print('Alice')
else:
	print('Bob')

### FIXED CODE ###

a, b = map(int, input().split())
if a == b:
	print('Draw')
elif a == 1:
	print('Alice')
elif b == 1:
	print('Bob')
elif a > b:
	print('Alice')
else:
	print('Bob')