Harryxun/stf_run huggingface dataset:
import math

n = int(input())
a = list(map(int, input().split()))
print(solution(n, a))  
gcd_left = [0]
gcd_right = [0]
for i in range(n):
    gcd_left.append(math.gcd(gcd_left[i], a[i]))
    # 順に(0とa[-1]), (a[-1]とa[-2]),...の比較
    # 要は右端から順にgcdを求めている
    gcd_right.append(math.gcd(gcd_right[i], a[-(i + 1)]))

gcd_right = gcd_right[::-1]  # gcd_right[i]がi番目以降のgcdとなるように反転

ans = []
for i in range(n):
    ans.append(math.gcd(gcd_left[i], gcd_right[i + 1]))


print(max(ans))

### FIXED CODE ###

import unittest
import fractions


def solution(n, a):
    gcd_left = [0]
    gcd_right = [0]
    for i in range(n):
        gcd_left.append(fractions.gcd(gcd_left[i], a[i]))
        # 順に(0とa[-1]), (a[-1]とa[-2]),...の比較
        # 要は右端から順にgcdを求めている
        gcd_right.append(fractions.gcd(gcd_right[i], a[-(i + 1)]))

    gcd_right = gcd_right[::-1]  # gcd_right[i]がi番目以降のgcdとなるように反転

    ans = []
    for i in range(n):
        ans.append(fractions.gcd(gcd_left[i], gcd_right[i + 1]))


    return max(ans)


class MyTestCase(unittest.TestCase):
    def test1(self):
        self.assertEqual(solution(3, [7, 6, 8]), 2)

    def test2(self):
        self.assertEqual(solution(3, [12, 15, 18]), 6)

    def test3(self):
        self.assertEqual(solution(2, [1000000000, 1000000000]), 1000000000)




if __name__ == '__main__':

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

    unittest.main()
import sys

stdin = sys.stdin

sn = lambda : stdin.readline().rstrip()
an = lambda : map(int, stdin.readline().split())
ni = lambda : int(sn())

def f(n):
  return n*(n+1)//2

x = 0
y = 0

n, k = an()
a = list(an())

mod = int(1e9)+7
ans = 0

for i, ai in range(n):
  for j in range(i+1, n):
    if ai > a[j]:
      x += 1
  
  for j in range(i+1):
    if ai > a[j]:
      y += 1

ans += x * f(k)
ans += y * f(k - 1)
print(ans % mod)

### FIXED CODE ###

import sys

stdin = sys.stdin

sn = lambda : stdin.readline().rstrip()
an = lambda : map(int, stdin.readline().split())
ni = lambda : int(sn())

def f(n):
    return n*(n+1)//2

def main():
  n, k = an()
  a = list(an())

  mod = int(1e9)+7
  ans = 0
  x = a[:] 
  for i, ai in enumerate(x):
    cnt = 0
    for j in range(i+1, n):
      if ai > x[j]:
        cnt += 1
    tcnt = 0
    for j in range(i+1):
      if ai > x[j]:
        tcnt += 1

    ans += f(k) * cnt
    ans %= mod
    ans += f(k - 1) * tcnt
    ans %= mod

  print(ans)

main()
n,k,q=map(int,input().split())
a=[int(input()) for i in range(Q)]
li=[0]*n
d=[k-q]*n
for j in range(0,len(a)):
  li[a[j]-1]+=1
  
ans=li+d

for m in range(0,n):
  if ans[m]>0:
    print("Yes")
  else:
    print("No")

  

### FIXED CODE ###

import numpy as np
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
li=np.array([0]*n)
d=np.array([k-q]*n)

for j in range(0,len(a)):
  li[a[j]-1]+=1

  
ans=np.array(li+d)


for m in range(0,n):
  if ans[m]>0:
    print("Yes")
  else:
    print("No")
N = input()
K = input()
S = input()

if S[K - 1] == 'A':
  s = S.replace('A', 'a')

elif S[K - 1] == 'B':
  s = S.replace('B', 'b')

else:
  s = S.replace('C', 'c')

print(s)


### FIXED CODE ###

nums = input().split()
N = int(nums[0])
K = int(nums[1])
S = input()
s1 = S[:K - 1]
s2 = S[K:]

if S[K - 1] == 'A':
    s = s1 + 'a' + s2

elif S[K - 1] == 'B':
    s = s1 + 'b' + s2

else:
    s = s1 + 'c' + s2

print(s)
from fractions import gcd

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

print(len(set(factorization(a)) & set(factorization(b))) + 1)

### FIXED CODE ###

from fractions import gcd

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr
  
a = factorization(a)
b = factorization(b)
if (len(a)==1 and a[0] == 1) or (len(b)==1 and b[0] == 1):
  print(1)
else:
  print(len(set(a) & set(b)) + 1)
dig, cnt = map(int, input().split())
ans = [-1]*dig
 
for i in range(cnt):
  place, num = map(int, input().split())
  place -= 1
  if ans[place] != -1:
    if ans[place] != num:
      print('-1')
      exit()
  elif place == 0 and num == 0:
    print('-1')
    exit()
  else:
    ans[place] = num
    
for i in range(cnt):
  if ans[i] == -1:
    if i == 0　and dig > 1:
      ans[i] = 1
    elif ans[i] == -1:
      ans[i] = 0
  print(ans[i], end="")

### FIXED CODE ###

dig, cnt = map(int, input().split())
ans = [-1]*dig
 
for i in range(cnt):
  place, num = map(int, input().split())
  place -= 1
  if ans[place] != -1:
    if ans[place] != num:
      
      print(-1)
      exit()
  elif place == 0 and num == 0 and dig > 1:
    print(-1)
    exit()
  else:
    ans[place] = num
    
for i in range(dig):
  if ans[i] == -1:
    if dig > 1 and i == 0:
      ans[i] = 1
    else:
      ans[i] = 0
  print(ans[i], end="")
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

items = []
for _ in range(N):
    a, b = map(int, input().split())
    items.append([a, b])

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

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

print(dp[0][W])


### FIXED CODE ###

from itertools import accumulate
import heapq
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
first_item = list(map(int, input().split()))
basew = first_item[0]
w0 = []
w1 = []
w2 = []
w3 = []
w0.append(first_item[1])
for _ in range(N-1):
    w, v = map(int, input().split())
    w -= basew
    if w == 0:
        w0.append(v)
    elif w == 1:
        w1.append(v)
    elif w == 2:
        w2.append(v)
    elif w == 3:
        w3.append(v)

w0_acc = [0]+list(accumulate(sorted(w0, reverse=True)))
w1_acc = [0]+list(accumulate(sorted(w1, reverse=True)))
w2_acc = [0]+list(accumulate(sorted(w2, reverse=True)))
w3_acc = [0]+list(accumulate(sorted(w3, reverse=True)))
v = 0
for i0 in range(len(w0)+1):
    for i1 in range(len(w1)+1):
        for i2 in range(len(w2)+1):
            for i3 in range(len(w3)+1):
                if basew*(i0+i1+i2+i3)+3*i3 + 2*i2 + i1 > W:
                    break
                else:
                    v = max(v, w0_acc[i0]+w1_acc[i1]+w2_acc[i2]+w3_acc[i3])
print(v)
m,d= map(int, input().split())

ans=0
for mon in range(1,m+1):
	for day in range(1,d+1):
    	if day<22:
        	continue
        d1,d2=str(day)
  		if d1*d2==mon:
            ans+=1
print(ans)

### FIXED CODE ###

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

ans=0
for mon in range(1,m+1):
    for day in range(1,d+1):
        if day<22:
            continue
        d1,d2=str(day)
        d1,d2=int(d1),int(d2)
        if d1<2 or d2<2:
            continue
        if d1*d2==mon:
            ans+=1

print(ans)
from scipy.special import comb

N = int(input())
S = [input() for _ in range(N)]

d = {}
for s in S:
    s = "".join(sorted(s))
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
ans = 0
for v in d.values():
    if v > 1:
        ans += comb(v, 2)
print(ans)        

### FIXED CODE ###

def cmb(n, r):
    if n - r < r: 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


N = int(input())
S = [input() for _ in range(N)]

d = {}
for s in S:
    s = "".join(sorted(s))
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
ans = 0
for v in d.values():
    if v > 1:
        ans += cmb(v, 2)
print(ans)
import sys
input = sys.stdin.readline
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)
flag = False
def dfs(neighbor,start):
    global flag
    global k
    if sum(visited) == N:
        return 0

    for i in neighbor[start]:
        
        if visited[i] == 0:
            
            try:
                ans[i] = c[k]
                k += 1
            visited[i] = 1
            except:
                flag = True
                return 0
        
            dfs(neighbor,i)



m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)
"""
if N == 9999:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
"""
dfs(neigh,nn)
if flag:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)
flag = False
def dfs(neighbor,start):
    global flag
    global k
    if sum(visited) == N:
        return 0

    for i in neighbor[start]:
        
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            try:
                dfs(neighbor,i)
            except RuntimeError:
                flag = True
                return 0




m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)

dfs(neigh,nn)
"""
if flag:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
"""
ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)
def solve(s):
    if len(s) == 0:
        return True
    return any(solve(s[len(prefix):]) for prefix in ('dreamer', 'dream', 'eraser', 'erase') if s.startswith(prefix))

print('YES' if solve(input()) else 'NO')

### FIXED CODE ###

def solve(s):
    stack = [s]
    while stack:
        word = stack.pop()
        if len(word) == 0:
            return True
        for prefix in ('dreamer', 'dream', 'eraser', 'erase'):
            if word.startswith(prefix):
                stack.append(word[len(prefix):])

print('YES' if solve(input()) else 'NO')
S = list(input())
K = int(input())

if(len(set(S)) == 1):
    print(len(S) // 2 * K)
else:
    m = 0
    ans = 0
    if(S[0] == S[-1]):
        l = 0
        r = len(S) - 1
        while(S[l] == S[l+1]):
            l += 1
        while(S[-r] == S[-r-1]):
            r += 1
        m = l//2 + r//2 - (l+r)//2
        m *= K - 1

    for i in range(len(S)-1):
        if(S[i] == S[i+1]):
            ans += 1
            S[i+1] = "3"
    ans *= K
    ans -= m
    print(ans)


### FIXED CODE ###

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

if(len(set(S)) == 1):
    print(len(S) * K//2)
else:
    ans = 0
    cnt = 1
    a = []
    for i in range(len(S)-1):
        if(S[i] == S[i+1]):
            cnt += 1
        else:
            a.append(cnt)
            cnt = 1
    a.append(cnt)

    for i in a:
        ans += (i//2)*K

    if (S[0] == S[-1]):
        ans -= (a[0]//2 + a[-1]//2  - (a[0] + a[-1])//2)*(K-1)

    print(ans)
import array
import collections
import heapq

AdjacentVertex = collections.namedtuple('AdjacentVertex', 'vertex cost') 
INF = 2 ** 31 - 1
NO_VERTEX = -1

#Prim?????§??????0?????????????°???¨?????¨(minimum spanning tree????±???????)
def compute_mst_prim(max_v, adj_list):
    # pred[u]?????????u???????????¨???????????????????????¨???
    pred = collections.defaultdict(lambda: NO_VERTEX)
    # u??¨pred[u]????????¶???????????????key[u]?????\???
    key = collections.defaultdict(lambda: INF)
    key[0] = 0
    #2????????????????????????????????\?????¨????????¨??????
    pq = [(key[v], v) for v in range(max_v)]
    heapq.heapify(pq)
    # ?????????????????\?????????????????\??£???????????????????????????
    in_pq = array.array("B", (True for _ in range(max_v)))
    
    while pq:
        _, u = heapq.heappop(pq)
        in_pq[u] = False
        for v, v_cost in adj_list[u]:
            if in_pq[v]:
                weight = v_cost
                if weight < key[v]:
                    pred[v] = u
                    key[v] = weight
                    heapq.heappush(pq, (weight, v))
                    in_pq = True
    return (pred, key)

max_v, max_e = map(int, input().split())
adjacent_list = collections.defaultdict(set)

for _ in range(max_e):
    s, t, w = map(int, input().split())
    adjacent_list[s].add(AdjacentVertex(t,w))
    adjacent_list[t].add(AdjacentVertex(s,w))

(_, key) = compute_mst_prim(max_v, adjacent_list)

print(sum(key.values()))

### FIXED CODE ###

import heapq
from collections import defaultdict

INF = float('inf')


V, E = map(int, input().split())
Adj_list = defaultdict(set)

for i in range(E):
    s, t, w = map(int, input().split())
    Adj_list[s].add((t, w))
    Adj_list[t].add((s, w))
    
def prim(x):
    d = [INF] * x
    d[0] = 0
    isVisited = [False] * x
    hq = [(0,0)] 
    
    while hq:
        u = heapq.heappop(hq)[1]
        isVisited[u] = True
        
        for v, c in Adj_list[u]:
            if not isVisited[v] and d[v] > c:
                d[v] = c
                heapq.heappush(hq, (c, v))
    return sum(d)

print(prim(V))
a , b = map(int , input().split)
c=str(a)+str(b)
c=int(c)
for i in range (100)
    if c== i*i
        print("Yes")
    elif i==100:
        print("No")

        

### FIXED CODE ###

a , b = map(int , input().split())
c=str(a)+str(b)
c=int(c)
for i in range (1000):
    if c== int(i*i):
        print("Yes")  
        break      
    elif i==1000-1:
        print("No")
        break
s = input()

n = len(s)

k = 0

for i in range(n - 4):
    for j in range(i+4, n+1):
        if int(s[i:j]) % 2019 == 0:
            k = k+1
            
print(k)

### FIXED CODE ###

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

if a > b :
    print('safe')
else:
    print('unsafe')
S = input()
T = input()

ret = 0
for i in len(S):
  if S[i] != T[i]:
    ret += 1
print( ret )

### FIXED CODE ###

S = input()
T = input()
 
ret = 0
for i in range(len(S)):
  if S[i] != T[i]:
    ret += 1
print( ret )
k,n=map(int,input().split())
a=[int(i) for i in input().split()]
array=[a[n-1]-a[0]]
array.append(result)
for i in range(1,n):
    array.append(k+a[i-1]-a[i])
print(min(array))

### FIXED CODE ###

k,n=map(int,input().split())
a=[int(i) for i in input().split()]
array=[]
result=a[n-1]-a[0]
array.append(result)
for i in range(1,n):
    result=k+a[i-1]-a[i]
    array.append(result)
print(min(array))
# A - Coffee
S = int(input())
if S[2]==S[3] and S[4]==S[5]:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

# A - Coffee
S = input()
if S[2]==S[3] and S[4]==S[5]:
    print('Yes')
else:
    print('No')
# -*- coding: utf-8 -*-
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

abc = []

for i, _a in enumerate(a):
    for j, _b in enumerate(b):
        if (i+1) * (j+1) > k:
            break
        for l, _c in enumerate(c):
            if (i+1) * (j+1) * (l+1) > k:
                break
            abc.append(_a + _b + _c)

for x in abc.sort(reverse=True)[:k]:
    print(x)


### FIXED CODE ###

# -*- coding: utf-8 -*-
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

bc = [i + j for i in b for j in c]
bc.sort(reverse=True)

abc = [i + j for i in a for j in bc[:min(k, len(bc))]]
abc.sort(reverse=True)

for i in range(k):
    print(abc[i])
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys


def main():
    n, k = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
    x = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]

    c = 0
    while x[c] < 0 and c<n:
        c += 1


    def getCost(l, r):
        if l<c and c<=r-1:
            return min(-x[l]*2+x[r-1], x[r-1]*2-x[l])
        elif c>r-1:
            return -x[l]
        else:
            return x[r-1]
    cost = getCost(0, k)

    for i in range(1,n-k+1):
        cost = min(cost, getCost(i, i+k))
    
    print(cost)
        

      
if __name__=="__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys


def main():
    n, k = [int(v) for v in sys.stdin.readline().rstrip().split(' ')]
    x = [int(v) for v in sys.stdin.readline().rstrip().split(' ')]

    c = 0
    while c<n and x[c] < 0:
        c += 1


    def getCost(l, r):
        if l<c and c<=r-1:
            return min(-x[l]*2+x[r-1], x[r-1]*2-x[l])
        elif c>r-1:
            return -x[l]
        else:
            return x[r-1]
    cost = getCost(0, k)

    for i in range(1,n-k+1):
        cost = min(cost, getCost(i, i+k))
    
    print(cost)
        

      
if __name__=="__main__":
    main()
import numpy as np
def f(a, b):
    if a > b:
        a, b = b, a
    t = int(np.sqrt(a*b - 1))
    l = (a*b-1) / (b+1)
    r = (a*b-1) / (b-1)
    if a == b:
        return 2*t
    if (a+1) == b:
        return 2*t-2
    if t*(t+1) < a*b:
        return 2*t-1
    return 2*t-2

q = input()
for i in range(q):
    a, b = map(int, raw_input().split())
    print f(a,b)

### FIXED CODE ###

q=int(raw_input())
for i in range(q):
	a,b=map(int,raw_input().split())
	p=int((a*b-1)**0.5)
	if p*p>a*b-1:
		p=p-1
	r=p*2-1
	if p*p+p>a*b-1:
		r=r-1
	if a==b:
		r=r+1
	print r
# coding: utf-8

def registerDictionaryFromTheNumberOf(counts):
    dictionary = {}
    for i in range(counts):
        key, value = input().split(" ")
        dictionary[key] = value
    return dictionary
        
def readCharacterBeforeConversionAsManyAs(counts):
    readString = ""
    for i in range(counts):
        readString += input()
    return readString
    
def convertCharactersByThe(dictionary, target):
    converted = ""
    for index in range(len(list(target))):
        if target[index] in dictionary:
            converted += dictionary[target[index]]
        else:
            converted += target[index]
    return converted
        
while True:
    dictionaryCounts = int(input())
    if dictionaryCounts == 0:
        break
    dictionary = registerDictionaryFromTheNumberOf(dictionaryCounts)gg
    original = readCharacterBeforeConversionAsManyAs(int(input()))
    converted = convertCharactersByThe(dictionary, original)
    print(converted)

### FIXED CODE ###

#!/home/minamo/.pyenv/versions/3.6.1/bin/python
# vim: ft=python
# coding: utf-8

def registerDictionaryFromTheNumberOf(counts):
    dictionary = {}
    for i in range(counts):
        key, value = input().split(" ")
        dictionary[key] = value
    return dictionary

def readCharacterBeforeConversionAsManyAs(counts):
    readString = ""
    for i in range(counts):
        readString += input().rstrip()
    return readString

def convertCharactersByThe(dictionary, target):
    converted = ""
    for index in range(len(list(target))):
        if target[index] in dictionary:
            converted += dictionary[target[index]]
        else:
            converted += target[index]
    return converted

while True:
    dictionaryCounts = int(input())
    if dictionaryCounts == 0:
        break
    dictionary = registerDictionaryFromTheNumberOf(dictionaryCounts)
    original = readCharacterBeforeConversionAsManyAs(int(input()))
    converted = convertCharactersByThe(dictionary, original)
    print(converted)
N = str(input())
 
if N[-1] = "7" or N[-2] = "7" or N[-3] = "7":
    print("Yes")
else:
  	print("No")

### FIXED CODE ###

N = str(input())

if N[-1] == "7" or N[-2] == "7" or N[-3] == "7":
    print("Yes")
else:
  	print("No")
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, A: "List[str]"):
    isVisited = [[-1]*W for _ in range(H)]
    from collections import deque

    queue = deque()

    for i in range(H):
        for j in range(W):
            if A[i][j] == "#":
                queue.append((i,j,0))

    while queue:
        i,j,count = queue.popleft()

        if 0<=i<H and 0<=j<W and isVisited[i][j] == -1:
            isVisited[i][j] = count
            for ix,iy in [(0,1),(1,0),(-1,0),(0,-1)]:
               queue.append((i+ix,j+iy,count+1))
 
    answer = 0
    for i in range(H):
        answer = max(answer,max(isVisited[i]))
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [next(tokens) for _ in range(W)]  # type: "List[str]"
    solve(H, W, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections import deque

def main():
    input = sys.stdin.readline  
    H,W = map(int,input().split())
    isVisited = [[False]*W for _ in range(H)]
    queue = deque()

    for i in range(H):
        st = input()
        for j in range(W):
            if st[j] == "#":
                queue.append((i,j))

    answer = 0
    a =  [(0,1),(1,0),(-1,0),(0,-1)]
    while True:
        nqueue = deque()
        while queue:
            i,j = queue.popleft()

            if not isVisited[i][j]:
                isVisited[i][j] = True
                for ix,iy in a:
                    if 0<=i+ix<H and 0<=j+iy<W:
                        nqueue.append((i+ix,j+iy))
        
        if nqueue:
            answer += 1
            queue = nqueue
        else:
            break
 
    print(max(answer-1,0))
    return

if __name__ == '__main__':
    main()
a,b,c = int(input().split())
if(a+b+c >= 22):
  print("bust")
else:
  print("win")

### FIXED CODE ###

a,b,c = map(int, input().split())
if(a +b+c >= 22):
  print("bust")
else:
  print("win")
list = []
indent = 0
for i in range(5):
  memory = 9
  list.append(int(input()))
  if memory > list[i] % 10 && list[i] % 10 != 0:
  	indent = i
 
count = 0
for i in range(5):
  if i == indent:
    count += list[i]
  else:
    count += 10 * (int(list[i]/10) + 1)
 
print(count)

### FIXED CODE ###

import math

list = []
indent = 0
memory = 9
for i in range(5):
  list.append(int(input()))
  if memory > list[i] % 10 and list[i] % 10 > 0:
    indent = i
    memory = list[i] % 10

count = 0
for i in range(5):
  if i == indent:
    count += list[i]
  else:
    count += 10 * math.ceil(list[i]/10)

print(count)
n = float(input)
if n % 2 == 0:
  return 1/2
else:
  return (n/2 + 0.5)/n


### FIXED CODE ###

n = int(input())
if n % 2 == 0:
  print(1/2)
else:
  print((n/2 + 0.5)/n)
s = list(map(int, input()))
k = int(input())

ans = 1

for i in range(len(min(s,k))):
	if s[i] != 1:
		ans = s[i]
		break

print(ans)
		
	

### FIXED CODE ###

s = list(map(int, input()))
k = int(input())

i=0

while i <= k-1:
	if s[i] == 1:
		ans = 1
		i += 1
	else:
		ans = s[i]
		break

print(ans)