Harryxun/stf_run huggingface dataset:
import numpy as np
import itertools
 
H, W, K = list(map(int, input().split())) 
c = [input().split(",") for i in range(H)]
b=[]
d=[]
for i in range(len(c)):
  for item in c[i]:
    item_mod = item.replace("."  , "0")
    item_mod = item_mod.replace("#" , "1")
    b.append(item_mod)
  d.append(b)
  b=[]
 
 
C_arr = np.array(d)
 
In = np.array(list(itertools.product([0,1] , repeat=H)))
Out = np.array(list(itertolls.product([0,1] , repeat=W)))
 
ans = 0
for i in range(2**H):
  for j in range(2**W):
    In_matrix = np.diag(In[i])
    Out_matrix = np.diag(Out[j])
    
    In_C = np.dot(In_matrix , C_arr)
    In_C_Out = np.dot(In_C , Out_matrix)
    
    ICO = In_C_Out.flatten()
    ICO = ICO.tolist()
    
    if ICO.count(1) == K:
      ans += 1
      
print(ans)

### FIXED CODE ###

H, W, K = list(map(int, input().split()))
 
c = [list(input()) for i in range(H)]
 
cnt = 0
for i in range(2**H):
    for j in range(2**W):
        cnt_black = 0
        for k in range(H):
            if (i >> k) & 1:
                continue
            for l in range(W):
                if (j >> l) & 1:
                    continue
                if c[k][l] == '#':
                    cnt_black += 1
        if cnt_black == K:
            cnt += 1
 
print(cnt)
L, N = list(map(int, input().split()))
S = [str(input()) for _ in range(N)]

#print(S)
S = sorted(S)
#print("sorted", S)
total = "".join(S)
print(total)

### FIXED CODE ###

N, L = map(int, input().split())
S = []
for i in range(N):
    line = input()
    S.append(line)
S.sort()
print("".join(S))
A,B=map(int,input().split())
if A==1:
    print(Alice)
elif B==1 :
    print(Bob)
elif A==B==1 :
    print(Draw)
elif A<B:
    print(Bob)
elif A>B:
    print(Alice)
elif A==B:
    print(Draw)

### FIXED CODE ###

A,B=map(int,input().split())
if A==B==1 :
    print("Draw")
elif A==1:
    print("Alice")
elif B==1 :
    print("Bob")
elif A<B:
    print("Bob")
elif A>B:
    print("Alice")
elif A==B:
    print("Draw")
a,b=map(int, input().split())
print(" ".join([x-i for i in range(-k, k)]))

### FIXED CODE ###

k,x=map(int, input().split())
print(" ".join([str(x-k+i) for i in range(1, 2*k)]))
import sys
from math import gcd
n, x, d = map(int, input().split())

if d == 0:
	print(n+1)
	sys.exit()

if d < 0:
	x, d = -x, -d

ans = n
g = gcd(x, d)

for i in range(2, n+1):
	k = max(((i - d//g) * (2*n - 1 - i + d//g)) // 2 - x//g, -1)
	ans += max((i * (2*n-1-i)) // 2 - k, 0)

print(ans)

### FIXED CODE ###

import sys
from fractions import gcd
n, x, d = map(int, input().split())
"""
数列からi個選ぶことを考えると
i*xに加えて足されるdの数はi(i-1)/2 〜 i(2n-1-i)/2 の任意の個数
i > j なるjで代替されるような和はこのうちどのような条件を満たすものか？
g = gcd(x, d). l = lcm(x, d)として
(g*l = x*d)
i*x + k*d が条件を満たすとすると
i*x + k*d = (i - d/g)x + (k + x/g)d が成り立つ
(i - d/g)(2n - 1 - i + d/g)/2 >= (k + x/g) となるような最大のkを求めれば，
k以下はすべてかぶる，k+1以上はすべてかぶらない

x<0 のときは
(i - d//g) * (i - d//g - 1)//2 <= (k + x//g) <= (i - d//g) * (2*n - 1 - i + d//g)//2
(i - d//g) * (i - d//g - 1)//2 - x//g <= k <= (i - d//g) * (2*n - 1 - i + d//g)//2 - x//g
となるようなkにおいてはかぶる
"""
if x == 0 and d == 0:
	print(1)
	sys.exit()
elif d == 0:
	print(n+1)
	sys.exit()

if x < 0 and x + (n-1) * d < 0:
	x, d = -x, -d

if x >= 0 and d < 0:
	x, d = x + (n-1) * d, -d

#print(x, d)
g = gcd(x, d)

ans = 1
if x >= 0:
	for i in range(1, n+1):
		#print((i - d//g) * (2*n - 1 - i + d//g) // 2 - x//g)
		k = max((i - d//g) * (2*n - 1 - i + d//g) // 2 - x//g, i * (i-1) // 2 - 1)
		#print(k)
		ans += max((i * (2*n-1-i)) // 2 - k, 0)

else:
	for i in range(1, n+1):
		overlap_u = min((i - d//g) * (2*n - 1 - i + d//g) // 2 - x//g, i * (2*n-1-i) // 2)
		overlap_l = max((i - d//g) * (i - d//g - 1) // 2 - x//g, i * (i-1) // 2)
		ans += i * (2*n-1-i) // 2 - i * (i-1) // 2 + 1 - max(overlap_u - overlap_l + 1, 0)

print(ans)
N = int(input())

n = [0]*(N+1)
for i in range(2, N+1):
    for j in range(2, i+1):
        while i%j == 0:
            i//=j
            n[j] += 1

def num(m):
return len(list(filter(lambda x: x>=m-1, n)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)14+num(5)*(num(5)-1)*(num(3)-2)//2)

### FIXED CODE ###

N = int(input())

n = [0]*(N+1)
for i in range(2, N+1):
    for j in range(2, i+1):
        while i%j == 0:
            i//=j
            n[j] += 1

def num(m):
    return len(list(filter(lambda x: x>=m-1, n)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)//2)
n , m  = map(int, input().split())
l_1 = [] #左から1桁目の数字のりすと
l_2 = [] #左から2桁目の数字のりすと
l_3 = [] #左から3桁目の数字のりすと
nocounter = 0
answer = 100  
 
if m == 0:
  if n == 1:
    print(0)
  elif n == 2:
    print(10)
  else:
    print(100)
else:
  for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
      l_1.append(b)
    elif a == 2:
      l_2.append(b)
    else:
      l_3.append(b)
  if len(l_1) > 0:
    pv = l_1[0]
    for j in range(len(l_1)):
      if not pv  == l_1[j]:
        nocounter += 1
      if l_1[j] == 0:
        nocounter += 1
  if len(l_2) > 0:
    pv = l_2[0]
    for j in range(len(l_2)):
      if not pv  == l_2[j]:
        nocounter += 1
  if len(l_3) > 0:
    pv = l_3[0]
    for j in range(len(l_3)):
      if not pv  == l_3[j]:
        nocounter += 1
  if nocounter > 0:
    print(-1)
  else:
    if n == 1:
      print(l_3[0])
    elif n == 2 and len(l_2)*lemn(l_1) == 1:
      print(10*l_1[0] + l_2[0])
    elif n == 2 and len(l_1) == 0:
      print(10 + l_2[0])
    elif n == 2 and len(l_2) == 0:
      print(10*l_1[0])
    elif len(l_1)*len(l_2)*len(l_3) == 1:
      print(100*l_1[0] + 10*l_2[0] + l_3[0])
    elif len(l_1) == 0 and len(l_2) == 0:
      print(100 + l_3[0])
    elif len(l_1) == 0 and len(l_3) == 0:
      print(100 + l_2[0])
    elif len(l_1) == 0:
      print(100 + 10*l_2[0] + l_3[0])
    elif len(l_2) == 0 and len(l_3) == 0:
      print(100*l_1[0])
    elif len(l_2) == 0 :
      print(100*l_1[0] + l_3[0])
    else:
      print(100*l_1[0] + 10*l_2[0])

### FIXED CODE ###

n , m  = map(int, input().split())
l_1 = [] #左から1桁目の数字のりすと
l_2 = [] #左から2桁目の数字のりすと
l_3 = [] #左から3桁目の数字のりすと
nocounter = 0
 
if m == 0:
  if n == 1:
    print(0)
  elif n == 2:
    print(10)
  else:
    print(100)
else:
  for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
      l_1.append(b)
    elif a == 2:
      l_2.append(b)
    else:
      l_3.append(b)
  if len(l_1) > 0:
    pv = l_1[0]
    for j in range(len(l_1)):
      if not pv  == l_1[j]:
        nocounter += 1
      if l_1[j] == 0 and n > 1:
        nocounter += 1
  if len(l_2) > 0:
    pv = l_2[0]
    for j in range(len(l_2)):
      if not pv  == l_2[j]:
        nocounter += 1
  if len(l_3) > 0:
    pv = l_3[0]
    for j in range(len(l_3)):
      if not pv  == l_3[j]:
        nocounter += 1
  if nocounter > 0:
    print(-1)
  else:
    if n == 1:
      print(l_1[0])
    elif n == 2 and len(l_2)*len(l_1) > 0:
      print(10*l_1[0] + l_2[0])
    elif n == 2 and len(l_1) == 0:
      print(10 + l_2[0])
    elif n == 2 and len(l_2) == 0:
      print(10*l_1[0])
    elif len(l_1)*len(l_2)*len(l_3) > 0:
      print(100*l_1[0] + 10*l_2[0] + l_3[0])
    elif len(l_1) == 0 and len(l_2) == 0:
      print(100 + l_3[0])
    elif len(l_1) == 0 and len(l_3) == 0:
      print(100 + 10*l_2[0])
    elif len(l_1) == 0:
      print(100 + 10*l_2[0] + l_3[0])
    elif len(l_2) == 0 and len(l_3) == 0:
      print(100*l_1[0])
    elif len(l_2) == 0 :
      print(100*l_1[0] + l_3[0])
    else:
      print(100*l_1[0] + 10*l_2[0])
import bisect
import numpy

n, m, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

cost_a = numpy.insert(numpy.cumsum(a), 0, 0)
cost_b = numpy.insert(numpy.cumsum(b), 0, 0)

left_max = bisect.bisect_left(cost_a, k) + 1
right_max = bisect.bisect_left(cost_b, k) + 1

ans = 0
j = right_max - 1
for i in range(left_max):
    for j in range(j , -1, -1):
        if cost_a[i] + cost_b[j] <= k:
            ans  = i + j if ans < i + j else ans
            break
print(ans)

### FIXED CODE ###


import bisect
import numpy

n, m, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

cost_a = numpy.insert(numpy.cumsum(a), 0, 0)
cost_b = numpy.insert(numpy.cumsum(b), 0, 0)

ans = 0
j =  len(cost_b) -1
for i in range(len(cost_a)):
    for j in range(j, -1, -1):
        if cost_a[i] + cost_b[j] <= k:
            ans  = i + j if ans < i + j else ans
            break
print(ans)
inp = [int(x) for x in input().split()]

bingo = inp[0:9]
b = inp[10:]

for i in b:
    for j in range(len(bingo)):
            if i == bingo[j]:
                bingo[j] = 0

true_list = list()
for i in [0, 3, 6]:
    if (bingo[i] + bingo[i+1] + bingo[i+2]) == 0:
        true_list.append(0)
for i in [0, 1, 2]:
    if (bingo[i] + bingo[i+3] + bingo[i+6]) == 0:
        true_list.append(0)
if (bingo[0] + bingo[4] + bingo[8]) == 0:
    true_list.append(0)
if (bingo[2] + bingo[4] + bingo[6]) == 0:
    true_list.append(0)

if not all(true_list):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

x = int(input())
print(int(x/2) if x % 2 == 0 else int((x + 1)/2) )
n,m = map(int,input().split())
dict = {}
su = 0
kounyu = 0

for i in range(n):
  A,B = map(int,input().split())
  dict[A] = B

d = sorted(dict.items())

for i in range(10**12):
  if d[i][1] >= m - kounyu:
    print(su + d[i][0]*(m - kounyu))
    exit()
    
  kounyu += d[i][1]
  su += d[i][1]*d[i][0]

### FIXED CODE ###

n,m = map(int,input().split())
dict = {}
su = 0
kounyu = 0
 
for i in range(n):
  A,B = map(int,input().split())
  if A in dict:
    dict[A] += B  #同じAがありうる！！！！！！
  else:
    dict[A] = B
  

d = sorted(dict.items())
 
for i in range(10**99):
  if d[i][1] >= m - kounyu:
    print(su + d[i][0]*(m - kounyu))
    exit()
    
  kounyu += d[i][1]
  su += d[i][1]*d[i][0]
from collections import Counter
 
N = int(input())
S = [input() for x in range(N)]
E = Counter(S)
c = max(E.values())
s = [s for s, g in b.items() if g == c]
s.sort()
print('\n'.join(s))

### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
    S.append(input())
T = {}
for i in range(N):
  if S[i] in T:
    T[S[i]] += 1
  else:
    T.setdefault(S[i],1)
A = max(T.values())

keys = [k for k, v in T.items() if v == A]
U =sorted(keys)

for i in range(len(U)):
  print(U[i])
x,n=map(int,input().split())
p=list(map(int,input().split()))

pl=[]
if n==0:
    print(x)
else:
    for i in range(n):
        pl.append(abs(p[i]-x))
    sort_p=sorted(pl)
    #print(sort_p)
    if n==1:
        if sort_p[0]!=0:
            print(x)
        else:
            print(x-1)
    else:
        num=0
        for i in range(1,n):
            if i%2!=0:
                num+=1
            if sort_p[i]!=num:
                ans=num
                break
        small=x-ans
        big=x+ans
        if (small not in p)&(big not in p):
            print(small)
        elif small in p:
            print(big)
        elif big in p:
            print(small)




### FIXED CODE ###

x,n=map(int,input().split())
p=list(map(int,input().split()))

if n==0:
    print(x)
    exit()

for i in range(n):
    if x-i not in p:
        print(x-i)
        exit()
    if x+i not in p:
        print(x+i)
        exit()
print(x-n)
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = i*i+j*j+k*k+i*j+j*k+k*i;
      if v<10050:
        ans[v]+=1

for i in range(n):
  print(ans[i+1])

### FIXED CODE ###

L,R,d = map(int,input().split())
print(int(R/d)-int((L-1)/d))
S,W = map(int,input().split)
if S >= W:
  print('unsafe')
else:
  print('safe')

### FIXED CODE ###

S, W = map(int, input().split())
if W >= S:
	print('unsafe')
else:
	print('safe')
def main():
    n = int(input())
    a_s = list(map(int, input().split(' ')))
    results = []
    for i, a in enumerate(a_s):
        if a == 1:
            for result in results:
                if (i+1) % result == 0:
                    print(-1)
                    quit() 
            results.append(str(i+1))
    print(len(results))
    if results:
        print(' '.join(results))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    a_s = list(map(int, input().split(' ')))
    results = [0]*n
    for i, a in enumerate(reversed(a_s)):
        idx = (n-1) - i
        if sum(results[idx::(idx+1)]) % 2 != a:
            results[idx] = 1
    print(sum(results))
    idxs = [str(i+1) for i, r in enumerate(results) if r == 1]
    if results:
        print(' '.join(idxs))


if __name__ == '__main__':
    main()
a = input()
b = input()
c = 2*b
if a>c:
  print(a-c)
elif a<c:
  print(0)

### FIXED CODE ###

a,b = map(int,input().split())
if a<=b*2:
  print(0)
else:
  print(a-b*2)
n = int(input())
a = list(map(int,input().split()))

ttl = a[0]
cst = 0

if a[0]>0:
    flg = 1

elif a[0]<0:
    flg = -1

for i in range(1,n):
    ttl += a[i]
    

    if ttl*flg < 0:
        flg *= -1
    else:
        if flg > 0:
            memo = abs(ttl)+1
            ttl -= memo
            cst += memo
        elif flg < 0:
            memo = abs(ttl)+1
            ttl += memo
            cst += memo
        flg *= -1
   


ttl = a[0]
cst2 = 0

if a[0]>0:
    flg = -1
    cst2 += abs(ttl)+1
    ttl += 0-ttl-1 

elif a[0]<0:
    flg = 1
    cst2 += abs(ttl)+1
    ttl += 0-ttl+1 

for i in range(1,n):
    ttl += a[i]
    

    if ttl*flg < 0:
        flg *= -1
    else:
        if flg > 0:
            memo = abs(ttl)+1
            ttl -= memo
            cst2 += memo
        elif flg < 0:
            memo = abs(ttl)+1
            ttl += memo
            cst2 += memo
        flg *= -1
   

print(min(cst,cst2))



### FIXED CODE ###

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

def wh(cst,ttl,flg):
    for i in range(n):
        ttl += a[i]

        if ttl*flg < 0:
            flg *= -1
        else:
            if flg > 0:
                memo = abs(ttl)+1
                ttl -= memo
                cst += memo
            elif flg < 0:
                memo = abs(ttl)+1
                ttl += memo
                cst += memo
            flg *= -1

        
    return cst




ttl = 0
cst = 0



cst = wh(cst,ttl,1)
ttl = 0
cst2 = 0
cst2 = wh(cst2,ttl,-1)
   

print(min(cst,cst2))
S = input()
T = input()
if (S == D[:len(S)]) and ((len(S)+1)==len(D)):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

S = input()
T = input()
if (S == T[:len(S)]) and ((len(S)+1)==len(T)):
    print('Yes')
else:
    print('No')
S = input[0]
cnt = 0
for i in range(3):
  if S[i] == 'R':
    # count, 前の文字列がR or nullならcnt+1、そうでない場合、1
    # 
    if i == 0 or S[i - 1] == 'R':
	  cnt += 1
    else:
      cnt = 1
print(cnt)

### FIXED CODE ###

S = input()
cnt = 0
for i in range(3):
    if S[i] == 'R':
        # count, 前の文字列がR or nullならcnt+1、そうでない場合、1
        if i == 0 or S[i - 1] == 'R':
            cnt += 1
        else:
            cnt = 1
print(cnt)
def ge(arr):
    for i in range(len(arr)):
        tmp = int(arr[i])
        if tmp >= 4:
            tmp += 1
        if tmp >= 6:
            tmp += 1
        arr[i] = str(tmp)


while True:
    n = int(input)
    if n == 0:
        break
    print("".join(ge(list(oct(n))[2:])))


### FIXED CODE ###

def ge(arr):
    for i in range(len(arr)):
        tmp = int(arr[i])
        if tmp >= 4:
            tmp += 1
        if tmp >= 6:
            tmp += 1
        arr[i] = str(tmp)
    return arr


while True:
    n = int(input())
    if n == 0:
        break
    print("".join(ge(list(oct(n))[2:])))
s = input()
q = int(input())

is_reverse = False
before = ""
after = ""

for _ in range(q):
  lst = input().split()
  if lst[0] == "1":
    is_reverse = not is_reverse
  else:
    _, f, c = lst
    if f == "1":
      if not is_reverse:
        before = c + before
      else:
        after = after + c
    else:
      if not is_reverse:
        after = after + c
      else:
        before = c + before

if is_reverse:
  before, after = after.reverse, before.reverse

print(before + s + after)


### FIXED CODE ###


s = input()
q = int(input())

is_reverse = False
before = ""
after = ""

for _ in range(q):
  lst = input().split()
  if lst[0] == "1":
    is_reverse = not is_reverse
  else:
    _, f, c = lst
    if f == "1":
      if not is_reverse:
        before = c + before
      else:
        after = after + c
    else:
      if not is_reverse:
        after = after + c
      else:
        before = c + before

if is_reverse:
  s = s[::-1]
  before, after = after[::-1], before[::-1]

print(before + s + after)
N = input()
print(N**2)


### FIXED CODE ###

N = int(input())
print(N**2)
n = str(input())
l = len(n)
L = []
for i in range(l):
  a = n[i]
  l.append(a)
sum_L = sum(L)
if int(n) % int(sum_l) == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N = input()
h = 0
for i in range(len(N)):
  h += int(N[i])
if int(N) % h == 0:
  print("Yes")
else:
  print("No")
import np

N,K = map(int,input().split())
p = 10**9+7
Nlist = []
ReNlist =[]
Ans = 0
for i in range(N+1):
    Nlist.append(i)
    ReNlist.append(N-i)
Nlist = np.array(Nlist).cumsum
ReNlist = np.array(ReNlist).cumsum
for i range(K,N+1):
    Ans += ReNlist[K-1]-Nlist[K-1]
    Ans = Ans % p
print(Ans)


### FIXED CODE ###

import numpy as np

N,K = map(int,input().split())
p = 10**9+7
Nlist = []
ReNlist =[]
Ans = 0
for i in range(N+1):
    Nlist.append(i)
    ReNlist.append(N-i)
Nlist = np.array(Nlist).cumsum()
ReNlist = np.array(ReNlist).cumsum()
for i in range(K,N+1):
    Ans += ReNlist[i-1]-Nlist[i-1] +1
    Ans = Ans % p
print(Ans+1)
h,w=map(int,input().split())
print(int(h*w/2) + w*h%2))

### FIXED CODE ###

h,w=map(int,input().split())
if h!=1 and w!= 1:
  print(int(h*w/2) + w*h%2)
else:
  print(1)
h, w = input().split()
h, w = int(h), int(w)

grid_state = []

# 1 = black, 0 = white

for _ in range(w):
    temp = [int(s) for s in input().replace(".", "0").replace("#", "1")]
    grid_state.append(temp)

grid_cost = [[0 for _ in range(w)] for _ in range(h)]

grid_cost[0][0] = grid_state[0][0]

for i in range(1, h + w - 1):
    j = i
    if j > w - 1:
        j = w - 1
    while((j >= 0) and (i - j < h)):
        if i - j == 0: 
            grid_cost[i - j][j] = grid_cost[i - j][j - 1] + grid_state[i - j][j]
        elif j == 0:
            grid_cost[i - j][j] = grid_cost[i - j - 1][j] + grid_state[i - j][j]
        else:
            grid_cost[i - j][j] = min([grid_cost[i - j - 1][j], grid_cost[i - j][j - 1]]) + grid_state[i - j][j]
        j -= 1

print(grid_cost[h - 1][w - 1])

### FIXED CODE ###

h, w = input().split()
h, w = int(h), int(w)

grid_state = []

# 1 = black, 0 = white

for _ in range(h):
    temp = [int(s) for s in input().replace(".", "0").replace("#", "1")]
    grid_state.append(temp)

grid_cost = [[0 for _ in range(w)] for _ in range(h)]

grid_cost[0][0] = grid_state[0][0]

for i in range(1, h + w - 1):
    j = i
    if j > w - 1:
        j = w - 1
    while((j >= 0) and (i - j < h)):
        if i - j == 0:
            if grid_state[i - j][j - 1] == 1:
                grid_cost[i - j][j] = grid_cost[i - j][j - 1]
            else:
                grid_cost[i - j][j] = grid_cost[i - j][j - 1] + grid_state[i - j][j]
        elif j == 0:
            if grid_state[i - j - 1][j] == 1:
                grid_cost[i - j][j] = grid_cost[i - j - 1][j]
            else:
                grid_cost[i - j][j] = grid_cost[i - j - 1][j] + grid_state[i - j][j]
        else:
            min_cost = min([grid_cost[i - j - 1][j], grid_cost[i - j][j - 1]])

            if grid_state[i - j][j] == 0:
                grid_cost[i - j][j] = min([grid_cost[i - j - 1][j], grid_cost[i - j][j - 1]])
            elif (grid_state[i - j - 1][j] == 1) and (grid_cost[i - j - 1][j] <= grid_cost[i - j][j - 1]):
                grid_cost[i - j][j] = min_cost
            elif (grid_state[i - j - 1][j] == 0) and (grid_cost[i - j - 1][j] < grid_cost[i - j][j - 1]):
                grid_cost[i - j][j] = min_cost + 1
            elif (grid_state[i - j][j - 1] == 1) and (grid_cost[i - j - 1][j] >= grid_cost[i - j][j - 1]):
                grid_cost[i - j][j] = min_cost
            else:
                grid_cost[i - j][j] = min_cost + 1

        j -= 1

print(grid_cost[h - 1][w - 1])
count = 1
while 1:
  x = int(raw_input())
  if x == 0:
    break
  print 'Case {0}: {1}'.format(count += 1, x)

### FIXED CODE ###

count = 1
while 1:
  x = int(raw_input())
  if x == 0:
    break
  print 'Case {0}: {1}'.format(count, x)
  count += 1
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, W: int, s: "List[str]"):

    dx = [-1, 0, 1, 0]
    dy = [0, -1, 0, 1]

    for i in range(H):
        for j in range(W):
            if(s[i][j] == '#'):
                f = False
                for k in range(4):
                    iy = i+dx[k]
                    ix = j+dy[k]
                    if(0 <= iy < H and 0 <= ix < W and s[iy][ix] == '#'):
                        f = True
                if(not f):
                    print(NO)
                    exit()
                
    print(YES)

    return


# Generated by 1.1.5 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()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(W)]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, W: int, s: "List[str]"):

    dx = [-1, 0, 1, 0]
    dy = [0, -1, 0, 1]

    for i in range(H):
        for j in range(W):
            if(s[i][j] == '#'):
                f = False
                for k in range(4):
                    iy = i+dy[k]
                    ix = j+dx[k]
                    if(0 <= iy < H and 0 <= ix < W and s[iy][ix] == '#'):
                        f = True
                if(f == False):
                    print(NO)
                    exit()
                
    print(YES)

    return


# Generated by 1.1.5 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()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(H)]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()
import math
N, K = tuple(map(int, input().split()))
base = 1 / N

if N == K:
  print(base)
s = 0
for i in range(1, N+1):
  n = math.ceil(math.log2((K-1)/i))
  print(i, n)
  s += base * (0.5 ** n)
print(s)

### FIXED CODE ###

import math
N, K = tuple(map(int, input().split()))
base = 1 / N

if N == K:
  s = base
  end = K
elif N > K:
  s = (N-K+1) / N
  end = K
else:
  s = 0
  end = N+1
for i in range(1, end):
  n = math.ceil(math.log2(K/i))
  s += base * (0.5 ** n)
print(s)
import numpy as np

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

b = np.tile(a,N).reshape(N,-1).astype('float128')
c = np.tril(b * b.T, k=-1)
d = c + np.tri(N).T * np.max(c)

print(int(sorted(d.flatten())[K-1]))

### FIXED CODE ###

import numpy as np
N,K = map(int,input().split())
a = np.array(input().split(),np.int64)
a = np.sort(a)
zero = a[a==0]
pos = a[a>0]
neg = a[a<0]

def f(x):
    count = 0
    c = x // pos
    count += np.searchsorted(a, c, side='right').sum()
    count += N*len(zero) if x >= 0 else 0
    c = -(-x // neg)
    count += (N - np.searchsorted(a, c, side='left')).sum()
    count -= a[a*a <= x].size
    count //= 2
    return count

right = 10**18
left = -10**18
while right-left>1:
    mid = (right + left)//2
    if f(mid)<K:
        left = mid
    else:
        right = mid
        
print(right)