Harryxun/stf_run huggingface dataset:
import numpy as np

num_i, num_j = input().split(" ")
num_i = int(num_i)
num_j = int(num_j)
inputs = [input() for i in range(num_i)]


x = []
for _ in inputs:
    for value in _:
        x.append(value)
x = np.array(x)
x = x.reshape(num_i, num_j)

count = 0
boolean = True
while (boolean):
    count += 1
    i_arr = []
    j_arr = []
    for i in range(num_i):
        for j in range(num_j):
            if (x[i][j] == "#"):
                i_arr.append(i)
                j_arr.append(j)
    for i, j in zip(i_arr, j_arr):
        if (i == 0) & (j == 0):
            x[1][0] = "#"
            x[0][1] = "#"
        elif (i == num_i - 1) & (j == num_j - 1):
            x[i - 1][j] = "#"
            x[i][j - 1] = "#"
        elif (i == num_i - 1) & (j == 0):
            x[i - 1][0] = "#"
            x[i][1] = "#"
        elif (i == 0) & (j == num_j - 1):
            x[1][j] = "#"
            x[0][j - 1] = "#"
        elif (i == 0):
            x[1][j] = "#"
            x[0][j - 1] = "#"
            x[0][j + 1] = "#"
        elif (j == 0):
            x[i - 1][0] = "#"
            x[i + 1][0] = "#"
            x[i][1] = "#"
        elif (i == num_i - 1):
            x[i - 1][j] = "#"
            x[i][j + 1] = "#"
            x[i][j - 1] = "#"
        elif (j == num_j - 1):
            x[i - 1][j] = "#"
            x[i + 1][j] = "#"
            x[i][j - 1] = "#"
        else:
            x[i - 1][j] = "#"
            x[i + 1][j] = "#"
            x[i][j - 1] = "#"
            x[i][j + 1] = "#"
    if len(set(list(x.flatten()))) == 1:
        print(str(count))
        boolean = False
    else:
        boolean = True

### FIXED CODE ###

from collections import deque

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

# input black cells
black_cells = []

for h in range(H):
    line = list(input())
    for w in range(W):
        if line[w] == "#":
            black_cells.append(h * W + w)


# Graph
def r(p):
    q_list = []
    h = p // W
    w = p % W
    if h != 0:
        q_list.append(p - W)
    if h != H-1:
        q_list.append(p + W)
    if w != 0:
        q_list.append(p - 1)
    if w != W-1:
        q_list.append(p + 1)
    return q_list


queue = deque(black_cells)
d = [10000] * (H * W)
for i in black_cells:
    d[i] = 0

# dijkstra
while len(queue) > 0:
    p = queue.popleft()
    for q in r(p):
        if d[q] > d[p] + 1:
            d[q] = d[p] + 1
            queue.append(q)

print(max(d))
x,y=map(int,input().split())
n=y//x
m=len(bin(n))-bin(n).rfind("1")-1
print(sum(len(i*m) for i in range(i,m+1)))

### FIXED CODE ###

x,y=map(int,input().split())
n=y//x
print(len(bin(n))-2)
def examB():
    St = S()
    AZ = [chr(i) for i in range(97, 97 + 26)]
    for s in AZ:
        if s not in St:
            ans = s
            break
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

### FIXED CODE ###

def examB():
    St = S()
    AZ = [chr(i) for i in range(97, 97 + 26)]
    ans = "None"
    for s in AZ:
        if s not in St:
            ans = s
            break
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()
n, k, x, y = (int(input().split()) for _ in range(4))
t = 0
if n - k > 0:
  t = (n  - k) * y
print(n * x + t)

### FIXED CODE ###

n,k,x,y=(int(input()) for i in range(4))
if n - k > 0:
  ans = k * x + (n - k) * y
else:
  ans = n * x
print(ans)
import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.ceil(x)
  if X<=50000:
    for i in range(X,key**2):
      l.append(i)
  else:
    for i in range(X,key**2):
      l.append(i)
    
for n in range(2,key):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

### FIXED CODE ###

import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.floor(x)
  for i in range(X,(key+1)**2):
    l.append(i)
    
for n in range(2,key+1):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])
n=int(input())
x=list(map(int,input().split()))
for i in range(n):
  if i+1<(2+n)//2:
    print(x[(n+2)//2])
  else:
    print(x[(n+2)//2-1])

### FIXED CODE ###

n=int(input())
x=list(map(int,input().split()))
sx=sorted(x)
a=sx[n//2]
b=sx[n//2-1]
for i in range(n):
  if x[i]>=a:
    print(b)
  else:
    print(a)
# -*- coding: utf-8 -*-
import numpy as np
import re
pattern = 'AC'
n, q = map(int, raw_input().split())
s = raw_input()

x = [raw_input() for i in range(q)]

result = re.finditer(pattern, s)

ac = np.zeros(len(s))
count = 0
for match in result:
    count += 1
    ac[match.span()[0]] = count

#print ac



for d in x:
    r = d.split(' ')
    start = int(r[0])-1
    end = int(r[1])
    for i in range(end-1, start, -1):
        if ac[i]!=0:
            m = ac[i]
#            print 'm', m
            break
    m2 = 0
    for i in range(start-1, -1, -1):
        if ac[i]!= 0:
            m2 = ac[i]
#            print 'm2',m2
            break
    wa = m-m2
#    wa = np.sum(ac[start:end] == 1)
#    wa = ac[start:end].count(1)
#    wa = sum(ac[start:end])
    if ac[end-1]!=0: wa = wa-1
    print int(wa)


### FIXED CODE ###

#!/usr/bin/env python3
N, Q = map(int, input().split())
S = input()
LR = []
for i in range(Q):
    l, r = map(int, input().split())
    LR.append([l,r])

A = [0]

cnt = 0
for i in range(1, len(S)):
    if S[i-1:i+1] == 'AC':
        cnt += 1
    A.append(cnt)

for l, r in LR:
    print(A[r-1] - A[l-1])
#問題C
N = int(input())
s = []

naka=0
a_kazu=0
b_kazu=0
b_a_kazu=0
for i in range(N):
    a = str(input())
    naka+=a.count("AB")
    if (a[0]=="B" and a[-1]=="A"):
        b_a_kazu+=1
    elif a[0]=="B":
        b_kazu+=1
    elif a[-1]=="A":
        a_kazu+=1
if b_a_kazu==0:
    print(naka+min(a_kazu, b_kazu))
else:
    if a_kazu==0 and b_kazu==0:
        print(naka+(b_a_kazu-1))
    elif a_lazu==0 or b_kazu==0:
        print(naka+(b_a_kazu))
    else:
        print(naka+(b_a_kazu-1)+min(a_kazu+1, b_kazu+1))

### FIXED CODE ###

#問題C
N = int(input())

naka=0
a_kazu=0
b_kazu=0
b_a_kazu=0
for i in range(N):
    a = str(input())
    naka+=a.count("AB")
    if (a[0]=="B" and a[-1]=="A"):
        b_a_kazu+=1
    elif a[0]=="B":
        b_kazu+=1
    elif a[-1]=="A":
        a_kazu+=1
if b_a_kazu==0:
    print(naka+min(a_kazu, b_kazu))
else:
    if (a_kazu==0 and b_kazu==0):
        print(naka+(b_a_kazu-1))
    elif (a_kazu==0 or b_kazu==0):
        print(naka+(b_a_kazu))
    else:
        print(naka+(b_a_kazu-1)+min(a_kazu+1, b_kazu+1))
n = int(input())
As = list(map(int, input().split()))

ans = 1
for i in range(n):
  ans = ans * As[i]
  if (ans > 10**18):
    print(-1)
    sys.exit()
  
print(ans)

### FIXED CODE ###

import sys

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

Flag = True
ans = 1

if (0 in As):
  print(0)
  sys.exit()


for i in range(n):
  ans = ans * As[i]
  if (ans > 10**18):
    if (Flag):
      print(-1)
      Flag = False
      sys.exit()
  
if (Flag):
  print(ans)
import pandas as pd
n, m = list(map(int, input().split()))
a = [list(input()) for _ in range(n)]
df = pd.DataFrame(a)
df_v = pd.concat([df, df], axis=0)
arr = df_v.values.tolist()
for i in range(n*2):
	print("".join(arr[i]))

### FIXED CODE ###

n, m = list(map(int, input().split()))
a = [list(input()) for _ in range(n)]
for i in range(n):
	print("".join(a[i]))
	print("".join(a[i]))
def main():
    A,V = [int(x) for x in input().split()]
    B,W = [int(x) for x in input().split()]
    T = int(input())
    pA = A
    pB = B
    if pA > pB:
        print('NO')
        return
    for _ in range(T):
        print(pA,pB)
        if pA <= pB and pB+W <= pA+V:
            print('YES')
            return
        pA += V
        pB += W
    print('NO')

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    A,V = [int(x) for x in input().split()]
    B,W = [int(x) for x in input().split()]
    T = int(input())
    D = abs(A-B)
    if V<=W:
        print('NO')
        return
    F = V-W
    if D/F <= T:
        print('YES')
    else:
        print('NO')

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

print(max[a+b,a-b,a*b])

### FIXED CODE ###

a, b = map(int,input().split())
 
print(max(a+b,a-b,a*b))
a = int(input())
b = int(input())
c = abs(a - b)
d = abs(c-b)
print(d)

### FIXED CODE ###

n,k = map(int,input().split())
if n % k ==0:
    print(0)
else:
    l = [n]
    p = n//k
    c = n-(p*k)
    half = k//2
    while c > half:
        c = abs(c-k)
    l.append(c)
    print(min(l))
S = input()
T = input()
cnt = 0
s = S + S
for i in range(len(S)+1):
    if s[i]==T[0]:
        for j in range(len(T)):
            if s[i+j]==T[j]:
                cnt +=1
if cnt==len(T) or S == T:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

A= list(map(int, input().split()))
B= sorted(A)
print(B[2]-B[0])
import functools
import operator

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

i = 2
res = []

while i <= P**0.5:
  while P % i**N == 0:
    P /= i**N
    res.append(i)
  else:
    if i = 2:
      i += 1
    else:
      i += 2
    
    
res.append(1)
result = functools.reduce(operator.mul, res)
print(result)

### FIXED CODE ###

N,P = map(int,input().split())
i = round(P**(1/N))
res = []
if N == 1:
  print(P)
elif P == 1:
  print(1)
else:
  for i in range(i,0,-1):
    if P%i**N==0:
      print(i)
      break
n=int(input())
cnt=[[0 for i in range(10)] for j in range(n)]

for i in range(1,n+1):
  s=str(i)
  head=int(s[0])
  tail=int(s[-1])
  cnt[head][tail]+=1

ans=0
for h in range(0,10):
  for t in range(0,10):
    ans+=cnt[h][t]*cnt[t][h]
print(ans)

### FIXED CODE ###

c={}
for i in range(1,10):
  for j in range(1,10):
    l=str(i)
    r=str(j)
    c[l+r]=0


n=int(input())
for i in range(1,n+1):
  l=str(i)[0]
  r=str(i)[-1]
  try:
    c[l+r]+=1
  except:
    pass
  
      
ans=0
for i in range(1,10):
  for j in range(1,10):
    l=str(i)
    r=str(j)
    ans+=c[l+r]*c[r+l]
    
    
print(ans)
N=int(input())
num=0
for j in range(1,N+1,2):
  cnt=0
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
#    print("---")
print(num)


### FIXED CODE ###

N=int(input())
num=0
for j in range(1,N+1,2):
    cnt=0
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
    cnt=0
#    print("---")
print(num)
N = list(map(int,input()))
K = int(input())
L = len(N)

def comb(n,k):
    if n < 0 or k < 0 or k > n:
        return 0
    ans = 1
    for i in range(k):
        ans *= n-i
    for i in range(k):
        ans //= i+1
    return ans

i = 0
D = [0] * K
M = K
for k in range(K):
    while N[i] == 0 and i < L:
        i += 1
    if i < L:
        D[k] = i
        i += 1
    else:
        M = k
        break

ans = 0
for k in range(M):
    i = D[k]
    ans += comb(L-1-i,K-k)*(9**(K-k))
    ans += (N[i]-1) * comb(L-1-i,K-1-k)*(9**(K-1-k))
if K == M:
    ans += 1

print(ans)


### FIXED CODE ###

N = list(map(int,input()))
K = int(input())
L = len(N)

def comb(n,k):
    if n < 0 or k < 0 or k > n:
        return 0
    ans = 1
    for i in range(k):
        ans *= n-i
    for i in range(k):
        ans //= i+1
    return ans

i = 0
D = [0] * K
M = K
for k in range(K):
    while i < L and N[i] == 0:
        i += 1
    if i < L:
        D[k] = i
        i += 1
    else:
        M = k
        break

ans = 0
for k in range(M):
    i = D[k]
    ans += comb(L-1-i,K-k)*(9**(K-k))
    ans += (N[i]-1) * comb(L-1-i,K-1-k)*(9**(K-1-k))
if K == M:
    ans += 1

print(ans)
a,b = map(int,input().split())
if (a * b) % 2 = 0:
  print('Even')
else:
  print('Odd')


### FIXED CODE ###

a,b = map(int,input().split())
if (a * b) % 2:
  print('Odd')
else:
  print('Even')
N,M,C=map(int, input().split())
B=list(map(int, input().split()))
count = 0
for i in range(N):
  A=list(map(int, input().split()))
  hyoka = 0
  for k in range(M):
    hyoka = hyoka + A[k]*B[k]
  if hyoka+C > 0:
    count = cocunt + 1
print(count)

### FIXED CODE ###

N,M,C=map(int, input().split())
B=list(map(int, input().split()))
count = 0
for i in range(N):
  A=list(map(int, input().split()))
  hyoka = 0
  for k in range(M):
    hyoka = hyoka + A[k]*B[k]
  if hyoka+C > 0:
    count = count + 1
print(count)
a,b,c=map(str,input().split())
m=int(a+b+c)
if n%4==0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a,b,c=map(str,input().split())
n=int(a+b+c)
if n%4==0:
    print("YES")
else:
    print("NO")
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

s = ins()
if s=='aba':
    3/0
n = len(s)
if s[0]==s[-1]:
    n += 1
print('Second' if n%2==0 else 'First')


### FIXED CODE ###

#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

s = ins()
if s=='ab':
    3/0
n = len(s)
if s[0]==s[-1]:
    n += 1
print('Second' if n%2==0 else 'First')
N, K = map(int, input().split())
P = list(map(lambda x:int(x)-1, input().split()))
C = list(map(int, input().split()))
done = [False] * N
ans = -10**30
must_negative = all([c < 0 for c in C])
for i in range(N):
  if done[i]:
    continue
  loop = [i]
  done[loop[-1]] = True
  while not done[P[loop[-1]]]:
    loop.append(P[loop[-1]])
    done[loop[-1]] = True
    #print(loop, done)
  #print(loop)
  scores = [C[i] for i in loop]
  #print(scores)
  cumsum = [0]
  for s in scores * 2:
    cumsum.append(cumsum[-1] + s)
  #print(cumsum)
  L = len(scores)
  if cumsum[L] >= 0:
    # (L+K) // L  loops - max
    l = max(0, (K - L) // L )
    k_max = K - l * L
    #print(l, k_max)
    base_score = cumsum[L] * l
  else:
    k_max = min(K, L)
    #print(k_max)
    base_score = 0
  for i in range(L):
    for k in range(k_max+1):
      score = base_score + cumsum[i + k] - cumsum[i]
      #print(i, k, base_score, score)
      if must_negative and score == 0:
        continue
      ans = max(ans, score)
print(ans)


### FIXED CODE ###

R, C, K = map(int, input().split())
V = [[0 for _ in range(C)] for _ in range(R)]
for _ in range(K):
  r, c, v = map(int, input().split())
  V[r-1][c-1] = v
M = [0] * R * C * 4 
# M[r*C*4 + c*4 + i]
# M[(r-1)*C*4 + c*4 + i]
# M[r*C*4 + (c-1)*4 + i]
# M[r][c][count in column (c)]
for r in range(R):
  for c in range(C):
    for n_pick in [0, 1] if V[r][c] else [0]:
      M[r*C*4 + c*4 +n_pick] = max(M[r*C*4 + c*4 +n_pick], n_pick*V[r][c])
      if r > 0:
        for n_prev in range(4):
          #print('R++', r, c, n_pick, n_prev)
          if M[(r-1)*C*4 + c*4 +n_prev] > 0 or n_prev == 0:
            M[r*C*4 + c*4 +n_pick]=max(M[r*C*4 + c*4 +n_pick],
              M[(r-1)*C*4 + c*4 +n_prev] + n_pick*V[r][c])
      if c > 0:
        for n_prev in range(4 - n_pick):
          #print('C++', r, c, n_pick, n_prev)
          if  M[r*C*4 + (c-1)*4 +n_prev]  > 0 or n_prev == 0:
            M[r*C*4 + c*4 +n_prev+n_pick]=max(M[r*C*4 + c*4 + n_prev+n_pick],
              M[r*C*4 + (c-1)*4 +n_prev] + n_pick*V[r][c])
    #print(candidates)
    #print(r, c, candidates, M)
    #for i in range(4):
    #  M[r][c][i] = max(candidates[i])
    #print(r, c, M)
#print(V, M)
print(max(M[((R-1)*C*4 + (C-1) *4):((R-1)*C*4 + (C-1) *4+4)]))
x = input().split()
n = int(x[0])
k = int(x[1])
 
h = input().split()
 
sorted(h)
 
if n-k <= 0:
    print(0)
    exit()
 
c = 0
for i in range(n-k):
    c += int(h[i])
print(c)
    


### FIXED CODE ###

x = input().split()
h = int(x[0])
a = int(x[1])
if h%a == 0:
    print(h//a)
else:
    print(h//a+1)
resident = [[[0] * 10] * 3] * 4
for _ in range(int(input())):
    b, f, r, v = map(int, input().split())
    resident[b][f][r] += v
for b in range(4):
    for f in range(3):
        print(" ".join(str(resident[b][f])))
    print("####################")



### FIXED CODE ###

resident = [[[0] * 10 for _ in range(3)] for _ in range(4)]
for _ in range(int(input())):
    b, f, r, v = map(int, input().split())
    resident[b - 1][f - 1][r - 1] += v
for b in range(4):
    for f in range(3):
        print(" " + " ".join(map(str, resident[b][f])))
    if b < 3:
        print("####################")
a,b=map(int, input().split())
print(max([A+B,A-B,A*B]))

### FIXED CODE ###

A,B=map(int, input().split())
print(max([A+B,A-B,A*B]))
n = int(input())
a = list(input().split())

a.sort(reverse=True)

alice = 0
bob = 0

for i in range(len(n)):
    if i % 2 == 0:
        alice = alice + int(a[i])
    else:
        bob = bob + int(a[i])

print (alice-bob)


### FIXED CODE ###

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

a.sort(reverse=True)

print(sum(a[0::2])-sum(a[1::2]))
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
import numpy as np
[N,K]=i2()
a=i2()
mod = 10**9+7
comb = np.zeros((N+1,N+1),dtype=np.int64)
comb[:,0] = 1
for i in range(1,N+1):
    comb[i, 1:i+1] = comb[i-1, :i] + comb[i-1, 1:i+1]
    comb[i] %= mod
ans=0
a.sort()
for i in range(N):
 if i>=K-1:
   ans+=a[i]*comb[i][K-1]
 if i<=N-K+1:
   ans-=a[i]*comb[N-i-1][K-1]
 ans%=mod
print(ans)

### FIXED CODE ###

def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]

[N,K]=i2()
a=i2()
mod = 10**9+7
c=[0 for i in range(N+1)]
ci=[0 for i in range(N+1)]
c[0]=1
for i in range(1,N+1):
 c[i]=c[i-1]*i
 c[i]%=mod
def bp(x,n):
        r=1
        while(n):
           if n%2:
              r=r*x%mod
           x=x*x%mod
           n>>=1
        return r
for i in range(N+1):
  ci[i]=bp(c[i],10**9+5)
ans=0
a.sort()
for i in range(N):
 if i>=K-1:
   ans+=a[i]*((c[i]*ci[i-K+1]*ci[K-1])%mod)
 if i<=N-K:
   ans-=a[i]*((c[N-i-1]*ci[N-i-1-K+1]*ci[K-1])%mod)
 ans%=mod
print(ans%mod)
h, w, k = map(int, input().split())
grid = [input() for _ in range(h)]
ans = 0
for i in range(1<<h):
  for j in range(1<<w):
    count = 0
    for x in range(h):
      if i >> n & i:
        continue
      for y in range(w):
        if j >> m & 1:
          continue
        if grid[x][y] == '#':
          count += 1 
    if count == k:
      ans += 1
print(ans)

### FIXED CODE ###

def main():
  h, w, k = map(int, input().split())
  C = [list(input()) for _ in range(h)]

  result = 0
  for i in range(1 << h):
    for j in range(1 << w):
      cnt = 0
      for n in range(h):
        if i >> n & 1:
          continue

        for m in range(w):
          if j >> m & 1:
            continue

          if C[n][m] == '#':
            cnt += 1

      if cnt == k:
        result += 1

  print(result)


if __name__ == "__main__":
  main()
n = int(input())
ac=0
wa=0
tle=0
re=0
for i range(n):
  x = input()
  if x =='AC':
    ac+=1
  if x =='WA':
    wa+=1
  if x =='TLE':
    tle+=1
  if x =='RE':
    re+=1
    
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

### FIXED CODE ###

n = int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
  x = input()
  if x =='AC':
    ac+=1
  if x =='WA':
    wa+=1
  if x =='TLE':
    tle+=1
  if x =='RE':
    re+=1
    
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))
import math

n = input()

px = 0
py = 0
qx = 100
qy = 0

def koch(n, px, py, qx, qy):
 if n == 0:
  return
 
 s.x = (px*2+qx*1)/3
 s.y = (py*2+qy*1)/3
 t.x = (px*1+qx*2)/3
 t.y = (py*1+qy*2)/3
 u.x = (t.x-s.x)*math.cos(pi/3) - (t.y-s.y)*math.sin(pi/3) + s.x
 u.y = (t.x-s.x)*math.sin(pi/3) - (t.y-s.y)*math.cos(pi/3) + s.y

 koch(n-1, px, py, s.x, s.y)
 print s.x, s.y
 koch(n-1, s.x, s.y, u.x, s.y)
 print u.x, u.y
 koch(n-1, u.x, u.y, t.x, t.y)
 print t.x, t.y
 koch(n-1, t.x, t.u, qx, qy)

print px, py
koch(n, px, py, qx, qy)
print qx, qy

### FIXED CODE ###

import math
          
def koch(n, h, i, j, k):
 if n == 0:
  return
           
 sx = (h*2+j)/3
 sy = (i*2+k)/3
 tx = (h+j*2)/3
 ty = (i+k*2)/3
 ux = (tx-sx)*math.cos(math.pi/3) - (ty-sy)*math.sin(math.pi/3) + sx
 uy = (tx-sx)*math.sin(math.pi/3) + (ty-sy)*math.cos(math.pi/3) + sy
          
 koch(n-1, h, i, sx, sy)
 print sx, sy
 koch(n-1, sx, sy, ux, uy)
 print ux, uy
 koch(n-1, ux, uy, tx, ty)
 print tx, ty
 koch(n-1, tx, ty, j, k)
   
n = input()
          
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
          
print px, py
koch(n, px, py, qx, qy)
print qx, qy
a = int(input())
b = int(input())
if max(a,b) <= 8:
  print('Yay!')
else:
  print(':(')

### FIXED CODE ###

a,b = map(int,input().split())
if max(a,b) <= 8:
  print('Yay!')
else:
  print(':(')
n, t = map(int, input().split())
 
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
 
a = []
b = []
for ai, bi in ab:
    a.append(ai)
    b.append(bi)
 
dp = [[0 for _ in range(t)] for _ in range(n+1)]
 
for i in range(n):
    for j in range(t):
        if j + a[i] <= t-1:
            if dp[i+1][j + a[i]] < dp[i][j] + b[i]:
                dp[i+1][j + a[i]] = dp[i][j] + b[i]
        if dp[i+1][j] < dp[i][j]:
            dp[i+1][j] = dp[i][j]
 
ans = 0
for i in range(N):
    ans = max(ans,dp[i][t-1]+b[i])
    
print(ans)


### FIXED CODE ###

n, t = map(int, input().split())
 
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
 
a = []
b = []
for ai, bi in ab:
    a.append(ai)
    b.append(bi)
 
dp = [[0 for j in range(t+1)] for i in range(n+1)]
 
for i in range(n):
    for j in range(t):
        if j + a[i] <= t-1:
            if dp[i+1][j + a[i]] < dp[i][j] + b[i]:
                dp[i+1][j + a[i]] = dp[i][j] + b[i]
        if dp[i+1][j] < dp[i][j]:
            dp[i+1][j] = dp[i][j]
 
ans = 0
 
for i in range(n):
    ans = max(ans, dp[i][t-1] + b[i])
 
print(ans)
a,b,c = map(int, input().split())
if a+b>=c:
    print("Yes")
if a+b < c
    print("NO")

### FIXED CODE ###

a,b,c = map(int, input().split())
if a+b >= c:
    print("Yes")
if a+b < c:
    print("No")
import Data.Char (chr)

solve :: Int -> Int -> (Int, String)
solve p n = (q, chr (97 + r) : s)
  where
    (m, s) = if n > p
               then solve (p * 26) (n - p)
               else (n - 1, "")
    (q, r) = m `divMod` 26

main :: IO ()
main = getLine >>= putStrLn . snd . solve 26 . read


### FIXED CODE ###

n = int(input())
p = 26
while n > p:
  n -= p
  p *= 26

n -= 1
s = ''
while p > 1:
  n, r = divmod(n, 26)
  s = chr(97 + r) + s
  p //= 26
print(s)
s = input()
k = int(input())

cnt = 0
p = 1
while p < len(s):
  if s[p-1] == s[p]:
    cnt += 1
    p += 1
  p += 1

cnt2 = 0
if s[0] == s[-1]:
  cnt2 += 1
  
cnt3 = 0
if s[-2] == s[-1]:
  cnt3 += 1

ans = k*cnt + (k - 1)*cnt2 - (k - 1)*cnt3
print(ans)

### FIXED CODE ###

s = input()
k = int(input())

if len(s) == 1:
  print(k // 2)
else:
  cnt = 0
  p = 1
  while p < len(s):
    if s[p-1] == s[p]:
      cnt += 1
      p += 1
    p += 1
      
  cnt2 = 0
  p2 = 1
  s2 = s + s
  while p2 < len(s2):
    if s2[p2-1] == s2[p2]:
      cnt2 += 1
      p2 += 1
    p2 += 1

  flg = 1
  for i in range(len(s)-1):
    if s[i] != s[i+1]:
      flg = 0
  
  if 2*cnt < cnt2:
    if flg == 1:
      print(k*cnt + (k//2))
    else:
      print(k*cnt + (k - 1))
  else:
    print(k*cnt)
import sys
m=10**6;a=[1]*m;a[0:2]=0,0
for i in range(2,999):
 if a[i]>0:
  for j in range(i*2,,i):a[j]=0
for i in range(m):a[i]+=a[i-1]
for e in sys.stdin:print(a[int(e)])


### FIXED CODE ###

import sys
m=500000;a=[1]*m
for i in range(3,999,2):
 if a[i//2]:a[i*i//2::i]=[0]*len(a[i*i//2::i])
p=[]
for i in range(m*2):p+=[i-1 if i<4 else p[i-1]+[0,a[i//2]][i%2]]
for e in sys.stdin:print(p[int(e)])