Harryxun/stf_run huggingface dataset:
H,W = map(int,input().split())
map = []
INF = 10**8
for _ in range(H):
    map.append(input())

dp = [[0 for i in range(W)] for i in range(H)]

for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            if map[i][j] == '#':
                dp[i][j] = 1
        elif i == 0:
            flag = 0
            if map[i][j] == '#' and map[i][j-1] == '.':
                flag = 1
            dp[i][j] = flag + dp[i][j-1]
        elif j == 0:
            flag = 0
            if map[i][j] == "#" and map[i-1][j] == ".":
                flag = 1
            dp[i][j] = flag + dp[i-1][j]
        else:
            flag1 = 0
            flag2 = 0
            if map[i][j] == "#" and map[i][j-1] == ".":
                flag1 = 1
            if map[i][j] == "#" and map[i-1][j] == ".":
                flag2 = 1
            dp[i][j] = min(dp[i][j-1]+flag1,dp[i-1][j]+flag2)

pritn(dp[H-1][W-1])


### FIXED CODE ###

H,W = map(int,input().split())
map = []
INF = 10**8
for _ in range(H):
    map.append(input())

dp = [[0 for i in range(W)] for i in range(H)]

for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            if map[i][j] == '#':
                dp[i][j] = 1
        elif i == 0:
            flag = 0
            if map[i][j] == '#' and map[i][j-1] == '.':
                flag = 1
            dp[i][j] = flag + dp[i][j-1]
        elif j == 0:
            flag = 0
            if map[i][j] == "#" and map[i-1][j] == ".":
                flag = 1
            dp[i][j] = flag + dp[i-1][j]
        else:
            flag1 = 0
            flag2 = 0
            if map[i][j] == "#" and map[i][j-1] == ".":
                flag1 = 1
            if map[i][j] == "#" and map[i-1][j] == ".":
                flag2 = 1
            dp[i][j] = min(dp[i][j-1]+flag1,dp[i-1][j]+flag2)

print(dp[H-1][W-1])
import sys

N = int(sys.stdin.readline())
h = [int(hi) for hi in sys.stdin.readline().split(' ')]

cache = {}


def cost(current):
    c = cache.get(current, None)
    if c:
        return c

    if current == N - 1:
        c = 0
    elif current == N - 2:
        c = abs(h[current] - h[current + 1]) + cost(current + 1)
    else:
        c1 = abs(h[current] - h[current + 1]) + cost(current + 1)
        c2 = abs(h[current] - h[current + 2]) + cost(current + 2)
        c = min(c1, c2)

    cache[current] = c
    return c


print(cost(0))


### FIXED CODE ###

import sys

N = int(sys.stdin.readline())
h = [int(hi) for hi in sys.stdin.readline().split(' ')]

dp = [1000000 * N] * N
dp[0] = 0

for i in range(N - 1):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
    if i < N - 2:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))

print(dp[-1])
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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

g = abs(lstx[0]-x)
for i in range(1,n): g = gcd(g,abs(lstx[i]-x))

print(g)

### FIXED CODE ###

a,b = map(int,input().split())
if a%2 == 0 or b%2 == 0:
    ans = "No"
else:
    ans = "Yes"

print(ans)
s= str(input())
t= str(input())

if len(t) = len(s) + 1 and len(s) >=1 and len(s) <= 10 and s.islower() and t.islower():
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s= str(input())
t= str(input())

if len(t) == len(s) + 1 and len(s) >=1 and len(s) <= 10 and t.islower() and s.islower() and s==t[:-1]:
  print("Yes")
else:
  print("No")
n = int(input())
m = int(input())
a = list(map(int,input().split()))
M = 10000

dp = [[0]*(m+1) for i in range(n+1)]

for i in range(n+1):
    dp[i][0] = 1
    
for i in range(n):
    for j  in range(1,m+1):
        if j - 1 - a[i] >= 0:
            dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j] - dp[i][j - 1 - a[i]] ) % M
        else:
            dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j]) % M
            
print(dp)

### FIXED CODE ###

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, cnt])

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

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

    return arr

from scipy.special import comb
n, m = map(int, input().split())
a = factorization(m)
M = 10**9 + 7

ans = 1
if m == 1:
    print(1)
    exit()
for i in a:
    ans *= comb(n, i[1], exact=True, repetition=True)
    ans = ans%M
print(ans)
n = int(input())
a = list(map(int, input().split()))
ans = 1000

sell = []

for i in range(1, n):
    if a[i - 1] < a[i]:
        sell.append(i)

for i in range(len(sell)):
    if i == 0:
        l = 0
    else:
        l = sell[i - 1] + 1
    r = sell[i] - 1
    stock = ans // min(a[l:r + 1])
    ans += (a[sell[i]] - min(a[l:r + 1])) * stock

print(ans)


### FIXED CODE ###

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

for i in range(1, n):
    stock = 0
    if a[i - 1] < a[i]:
        stock = ans // a[i - 1]
    ans += (a[i] - a[i - 1]) * stock

print(ans)
h,w = map(int,input().split())
s = [[i for i in input()] for j in range(h)]


"""
s_idx = [-1,-1]
g_idx = [-1,-1]

for i in range(h):
    for j in range(w):
        if s[i][j] == 'S':
            s_idx[0] = i
            s_idx[1] = j
        if s[i][j] == 'G':
            g_idx[0] = i
            g_idx[1] = j
"""

tate = [0,0,1,-1]
yoko = [-1,1,0,0]

mat=[[10**18 for i in range(w*h)] for j in range(w*h)]

for i in range(w*h):
    mat[i][i] = 0

for i in range(w*h):
    for j in range(4):
        next_idx = i + w*tate[j] + yoko[j]
        if next_idx < 0 or next_idx >= w*h:
            continue
        if i % w == 0:
            if j == 0:
                continue
        if i % w == w - 1:
            if j == 1:
                continue
        if s[next_idx//w][next_idx%w] == '#':
            mat[i][next_idx] = 10**18
        else:
            mat[i][next_idx] = 1

for i in range(w*h):
    #print(i,i,i,i,i,i,i,i,i)
    for x in range(w*h):
        for y in range(w*h):
            """
            if x == s_idx[0]*w+s_idx[1] and y == g_idx[0]*w+g_idx[1]:
                print(mat[x][y],mat[x][i] , mat[i][y],i)
            """
            mat[x][y] = min(mat[x][y], mat[x][i] + mat[i][y])
    
ans = 10**18
tmp = []

for i in range(w*h):
    for j in range(w*h):
        if s[i][j] == '#':
            continue
        if ans > mat[i][j]:
            tmp.append(mat[i][j])
            
print(max(tmp))



### FIXED CODE ###

h,w = map(int,input().split())
s = [[i for i in input()] for j in range(h)]


"""
s_idx = [-1,-1]
g_idx = [-1,-1]

for i in range(h):
    for j in range(w):
        if s[i][j] == 'S':
            s_idx[0] = i
            s_idx[1] = j
        if s[i][j] == 'G':
            g_idx[0] = i
            g_idx[1] = j
"""

tate = [0,0,1,-1]
yoko = [-1,1,0,0]

mat=[[10**18 for i in range(w*h)] for j in range(w*h)]

for i in range(w*h):
    mat[i][i] = 0

for i in range(w*h):
    for j in range(4):
        next_idx = i + w*tate[j] + yoko[j]
        if next_idx < 0 or next_idx >= w*h:
            continue
        if i % w == 0:
            if j == 0:
                continue
        if i % w == w - 1:
            if j == 1:
                continue
        if s[next_idx//w][next_idx%w] == '#':
            mat[i][next_idx] = 10**18
        else:
            mat[i][next_idx] = 1

for i in range(w*h):
    #print(i,i,i,i,i,i,i,i,i)
    for x in range(w*h):
        for y in range(w*h):
            """
            if x == s_idx[0]*w+s_idx[1] and y == g_idx[0]*w+g_idx[1]:
                print(mat[x][y],mat[x][i] , mat[i][y],i)
            """
            mat[x][y] = min(mat[x][y], mat[x][i] + mat[i][y])
    
ans = 10**18
tmp = []

for i in range(w*h):
    for j in range(w*h):
        if s[i//w][i%w] == '#':
            continue
        if s[j//w][j%w] == '#':
            continue
        if ans > mat[i][j]:
            tmp.append(mat[i][j])
            
print(max(tmp))
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
      
      	int v = 700;
      	for(int i = 0; i < S.length(); i++){
        if(S.charAt(i) == 'o'){
        	v += 100;
        }
      }
      
      System.out.println(v);
    }
}


### FIXED CODE ###

s=input()
v=700
for i in range(3):
  S=s[i]
  if(S=="o"):v+=100
print(v)
import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())

d = [None for i in range(4)]
d[0] = abs(x*1+y*(-1)+w*h)/math.sqrt(1**2 + (-1)**2)
d[1] = abs(x*(-h/w)+y*(-1)+h)/math.sqrt((-h/w)**2 + (-1)**2)
d[2] = abs(x-w*0.5)
d[3] = abs(y-h*0.5)

if int(w-2*x)==0 and int(h-2*y)==0:
  print(w*h/2.0, 1)
  exit()
elif int(w-2*x)==0 or int(h-2*y)==0:
  print(w*h/2.0, 0)
  exit()

if int(d1) == 0 or int(d2) == 0:
  if int(w-2*x)==0 and int(h-2*y)==0:
    print(w*h/2.0, 1)
  else:
    print(w*h/2.0, 0)
elif d.index().min(d) == 0:
  if x > 0.5*w:
    if y < h/w*x:
      print((x*w*w)/y*0.5, 0)
    else:
      print((x*h*h)/y*0.5, 0)
  else:
    b = h - (h-y)/(w-x)*w
    if y < h/w*x:
      print(h*(w-b*(w-x)/(h-y))*0.5, 0)
    else:
      print(w*(h-b)*0.5, 0)
elif d.index().min(d) == 1:
  print(1,1)
  eixt()
  if int(d[0]-d[1]) == 0:
    casenum = 1
  else:
    casenum = 0
    
  if x > 0.5*w:
    if  y > -h/w*x+h:
      print(w*(-(y-h)*w/x)*0.5, casenum)
    else:
      print(h*x*h/(h-y)*0.5, casenum)
  else:
    b = (h + y*w/(x-w)) * (x-w)/y
    if  y > -h/w*x+h:
      print(h*(w-(b-h)*x/(y-h))*0.5, casenum)
    else:
      print(w*(h-b)*0.5, casenum)
elif d.index().min(d) == 2:
  if y > 0.5*h:
    b = w*y/(w-2*x)
    x1=(x-0.5*w)/y*(b-h)
    if x > 0.5*w:
      print(h*(0.5*w+w-x1)*0.5, 0)
    else:
      print(h*(0.5*w+0.5*w-x1)*0.5, 0)
  else:
    b = h - 0.5*w*y/(x-0.5*w)
    x1=b*y/(0.5*w-x)
    if x > 0.5*w:
      print(0.5*h(0.5*w+w-x1), 0)
    else:
      print(0.5*h(0.5*w+0.5*w-x1), 0)    
elif d.index().min(d) == 3:
  if int(d[2]-d[3]) == 0:
    casenum = 1
  else:
    casenum = 0
  if x > 0.5*w:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(y-0.5*h)/x*w+0.5*h), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(y-0.5*h)/x*w+0.5*h), casenum)
  else:
    if y > 0.5*h:
      print(0.5*w*(0.5*h+h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)
    else:
      print(0.5*w*(0.5*h+0.5*h-(0.5*h-w*(y-0.5*h)/(x-w))), casenum)    

### FIXED CODE ###

import sys
import math
w, h, x, y = map(int, sys.stdin.readline().split())
S = w*h/2

if x == w/2 and y == h/2:
  print(S,1)
else:
  print(S, 0)
class Trio:
    __pre=None
    __val=None
    __nex=None
    def __init__(self,val,p=None,n=None):
        self.__pre=p
        self.__val=val
        self.__nex=n
    
    def get_pre(self):return self.__pre
    
    def get_nex(self):return self.__nex
    
    def set_nex(self,n):self.__nex=n
    
    def set_val(self,n):self.__val=n
    
    def get_val(self):return self.__val

class Stack:
    member=Trio(None)
    def __init__(self,stri):
        if(isinstance(stri,str)):
            for i,e in enumerate(stri):
                if(i==0):
                    self.member.set_val(e)
                else:
                    self.push(e)

    
    def push(self,n):
        if(self.member.get_val()==None):
            self.member.set_val(n)
            return True
        self.member.set_nex(Trio(n,self.member,None))
        self.member=self.member.get_nex()

    def pop(self):
        if(self.member==None):
            return None
        d=self.member.get_val()
        self.member=self.member.get_pre()
        return d


s=input()
stk = Stack(None)
stri=""
for i in s:
    if(i==" "):
        stk.push(stri)
        stri=""
    elif(i.isdigit()):
        stri="".join([stri,i])
    elif(i=="+" or i=="-" or i=="*"):
        b=stk.pop()
        b=int(b)
        a=int(stk.pop())
        if(i=="+"):
            stri=(str(a+b))
        elif(i=="-"):
            stri=(str(a-b))
        else:
            stri=(str(a*b))

print(stri)

### FIXED CODE ###

class Trio:
    __pre=None
    __val=None
    __nex=None
    def __init__(self,val,p=None,n=None):
        self.__pre=p
        self.__val=val
        self.__nex=n
    
    def get_pre(self):return self.__pre
    
    def get_nex(self):return self.__nex
    
    def set_nex(self,n):self.__nex=n
    
    def set_val(self,n):self.__val=n
    
    def get_val(self):return self.__val

class Stack:
    member=Trio(None)
    def __init__(self,stri):
        if(isinstance(stri,str)):
            for i,e in enumerate(stri):
                if(i==0):
                    self.member.set_val(e)
                else:
                    self.push(e)

    
    def push(self,n):
        self.member.set_nex(Trio(n,self.member,None))
        self.member=self.member.get_nex()

    def pop(self):
        if(self.member==None):
            return None
        d=self.member.get_val()
        self.member=self.member.get_pre()
        return d

s=input()
stk = Stack(None)
stri=""
for i in s:
    if(i==" "):
        stk.push(stri)
        stri=""
    elif(i.isdigit()):
        stri="".join([stri,i])
    elif(i=="+" or i=="-" or i=="*"):
        b=stk.pop()
        b=int(b)
        a=int(stk.pop())
        if(i=="+"):
            stri=(str(a+b))
        elif(i=="-"):
            stri=(str(a-b))
        else:
            stri=(str(a*b))

print(stri)
X, Y= map(int,input().split())

a=2*X
b=(Y-a)/2
c=X-b

if(2*c+4*b==Y and (Y-a)%2==0 and c>=0):
    print("Yes")
else:
    print("No")
    

### FIXED CODE ###

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

print(N.index(0)+1)
n = int(input())
a = list(map(int,input().split()))
arr = [0] * 100000
for val in a:
  arr[val] += 1
sums = sum(a)
q = int(input())
for _ in range(q):
  b, c = map(int,input().split())
  diff = (c-b) * (arr[b])
  sums += diff
  print(sums) 
  arr[c] += arr[b]
  arr[b] = 0

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
arr = [0] * 100005
for val in a:
  arr[val] += 1
sums = sum(a)
q = int(input())
for _ in range(q):
  b, c = map(int,input().split())
  diff = (c-b) * (arr[b])
  sums += diff
  print(sums) 
  arr[c] += arr[b]
  arr[b] = 0
n = int(input())
a = list(map(int,input().split()))

a_min = min(a)
ans = 0
for x in range(2,1000000,2):
    if a_min%2 == 0 and a_min > 0:
        ans += 1
        contnue
    else:
        break

for y in a:
    if y%2==1:
        ans -= 100000000
        continue



if ans > 0:
    print(ans)
else:
    print(0)

### FIXED CODE ###


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

l = []
ans = 0

for x in range(n):
    for _ in range(10000000):
        if a[x]%2 == 0 and a[x] > 0:
            a[x] = a[x]//2
            ans += 1
            continue
        else:
            l.append(ans)
            ans = 0
            break

print(min(l))
X = input()
x = 100
for i in range(5000):
  x = x * 101 / 100
  if x >= X:
    print i + 1
    break

### FIXED CODE ###

X = int(input())
x = int(100)
for i in range(5000):
  x = int(x * 101 / 100)
  if x >= X:
    print(i + 1)
    break
n,m = map(int,input().split())
#L= list(map(int, input().split()))
L = []
for i in range(m):
    a = list(map(int, input().split()))
    L.append(a)

if n == 1:
    print(0)
    exit()
    
s = [-1]*n
for i in range(m):
    s[L[i][0]-1] = L[i][1]
#print(L,s)
for i in range(m):
    if s[0] == 0:
        print(-1)
        exit()
    if s[i]==-1:
        s[i] = 0
    #print(s)
ans = ""
for i in range(m):
    ans += str(s[i])
print(int(ans))

### FIXED CODE ###

n,m = map(int,input().split())
L = []
for i in range(m):
    L.append(list((map(int,input().split()))))

for i in range(1000):
    p = str(i)
    flag = False
    for j in range(m):
        if len(p) >= L[j][0]:
            if int(p[L[j][0]-1]) != L[j][1]:
                break
    else:
        if len(p) == n:
            flag = True

    if flag:
        print(i)
        exit()
print(-1)
line = input()
print(line[len(line),0,-1])

### FIXED CODE ###

line = input()
print(line[-1::-1])
res=0
if len(set(t)-set(s)) > 0:
    res=-1
else:
    dic={}
    for e_t in t:
        dic[e_t]=[]
    for i in range(len(s)):
        if s[i] in t:
            dic[s[i]].append(i+1)
    cur = 0
    for i in range(len(t)):
        nxt=cur
        for e in dic[t[i]]:
            if e > cur:
                nxt=e
                break
        if nxt == cur:
            nxt = dic[t[i]][0]
            res+=len(s)
        cur=nxt
    res+=cur
print(res)

### FIXED CODE ###

s=input()
t=input()
import bisect
res=0
if len(set(t)-set(s)) > 0:
    res=-1
else:
    pos={}
    set_t=set(t)
    for e_t in t:
        pos[e_t]=[]
    for i in range(len(s)):
        if s[i] in set_t:
            pos[s[i]].append(i+1)
    cur = 0
    nxt=0
    for e_t in t:
        nxt=bisect.bisect_left(pos[e_t], cur+1)
        if nxt < len(pos[e_t]):
            cur=pos[e_t][nxt]
        else:
            cur=pos[e_t][0]
            res+=len(s)
    res+=cur
print(res)
s = input()
l = len(s)
dif = 0
for i in range (l):
	if s[i] == 'A':
		a = i
	elif s[i] == 'Z':
		z = i
		dif = z-a
print(dif+1)

### FIXED CODE ###

s = input()
le = len(s)
list_a = []
list_z = []
dif = 0
for i in range(le):
	if s[i] == 'A':
		list_a.append(i)
	elif s[i] == 'Z':
		list_z.append(i)
print(int(list_z[-1])-int(list_a[0])+1)
a,b = input().split()
aa=''.join([int(a) for _ in range(int(b))])
bb=''.join([int(b) for _ in range(int(a))])
print(max(int(aa),int(bb)))
           

### FIXED CODE ###

a,b = input().split()
aa=''.join([a for _ in range(int(b))])
bb=''.join([b for _ in range(int(a))])
print(max(int(aa),int(bb)))
import itertools

def path(n):
    l = len(n)
    i = 0
    while i < l - 1:
        a = n[i]
        b = n[i + 1]

        if a < b:
            c = (a, b)
        else:
            c = (b, a)

        for m in C:
            if m == c:
                break
        else:
            return False
        i += 1
    return True

N, M = map(int, input().split())
C = []
i = 0
while i < N:
    C += [tuple(map(int, input().split()))]
    i += 1

i = 0
l = range(1, N + 1)
for n in itertools.permutations(l, N):
    print(n)
    if n[0] != 1:
        break
    if path(n) == True:
        i += 1
print(str(i))

### FIXED CODE ###

import itertools

def path(n):
    l = len(n)
    i = 0
    while i < l - 1:
        a = n[i]
        b = n[i + 1]

        if a < b:
            c = (a, b)
        else:
            c = (b, a)

        for m in C:
            if m == c:
                break
        else:
            return False
        i += 1
    return True

N, M = map(int, input().split())
C = []
i = 0
while i < M:
    C += [tuple(map(int, input().split()))]
    i += 1

i = 0
l = range(1, N + 1)
for n in itertools.permutations(l, N):
    if n[0] != 1:
        break
    if path(n) == True:
        i += 1
print(str(i))
import sys
from math import cos, radians, pi, sqrt

inputs = input()
inputs = inputs.split('\\n')

N = int(inputs[0].split()[0])
M = int(inputs[0].split()[1])

i = 1
dic = {}
for i in range(1, M+1):
#	print("探索%d回目" % i)
	param = inputs[i].split()
	A = param[0]
	B = param[1]

	if A in dic.keys():
		dic[A].append(B)
	else:
		dic[A] = []
		dic[A].append(B)

	if B in dic.keys():
		dic[B].append(A)
	else:
		dic[B] = []
		dic[B].append(A)
	
depth = {'1': 0}
que = dic['1']
count=1

while not que == []:
	next_que = []
	for room in que:
		if room in depth.keys():
			continue

		depth[room] = count
		for next_room in dic[str(room)]:
			if not next_room in next_que:
				next_que.append(next_room)
	count += 1
	que = next_que

dist = {}
for i in range(2, N+1):
	for room, dep in depth.items():
		if depth[str(i)]-1 == dep:
			dist[str(i)] = room
			break

print("yes")
for opt in dist.items():
	print(opt[1])


### FIXED CODE ###

n,m = map(int,input().split())
visited = [-1 for _ in range(n+1)]
visited[1] = 0
will = []
root = [[] for _ in range(n+1)] 
for i in range(m):
    a,b = map(int,input().split())
    root[a].append(b)
    root[b].append(a)

will.append(1)

while will:
    visit = will.pop(0)
    for i in root[visit]:
        if visited[i] != -1:
            continue
        will.append(i)
        visited[i] = visit

if visited[1:] == -1:
    print('No')
else:
    print('Yes')
    for i in range(2,len(visited)):
        print(visited[i])
string = input()
n = int(input())
for i in range(n):
    inp = [x for x in input().split()]
    a = int(inp[1])
    b = int(inp[2])
    if inp[0] == 'print':
        print(string[a:b+1])
    elif inp[0] == 'reverse':
        string = string[:a] + string[a:b+1][::-1] +string[b+1:]
    elif inp[0] == 'replace':
        string = string[:a] + inp[3] + string[b+1]



### FIXED CODE ###

string = input()
for _ in range(int(input())):
    com = [x for x in input().split()]
    c = com[0]
    a,b = [int(com[i]) for i in range(1,3)]
    if c == 'reverse':
        string = string[:a] + string[a:b+1][::-1] + string[b+1:]
    if c == 'print':
        print(string[a:b+1])
    if c == 'replace':
        string = string[:a] + com[3] + string[b+1:]
ans = 0
for i in range(n+1):
  s = str(i)
  if s.count('7')+s.count('5')+s.count('3') == int(s):
    ans += 1
print(ans)


### FIXED CODE ###

N = int(input())

ans = 0
a = [3, 5, 7]
i = 0
while a[i] <= N:
    x10 = a[i] * 10
    a.append(x10+3)
    a.append(x10+5)
    a.append(x10+7)
    i += 1

for j in range(i):
    s = str(a[j])
    if "3" in s and "5" in s and "7" in s:
        ans += 1

print(ans)
N=int(input())
A=[int(input()) for i in range(N)]
M=max(A)
sort_A=sorted(A, reverse=True)

for j in range(N):
    if A[j]==M:
        if A.count(M)==1:
            print(sort_A[1])
        else:
            print(M)
    else:
        print(M)


### FIXED CODE ###

r=int(input())

print(3*r*r)
h = int(input())  # Monster health
a = int(input())  # Servant attack
x = a
attack = 1

while h > x :
    h -= x
    attack += 1

print(attack)


### FIXED CODE ###


h, a = input().split()
h = int(h)
a = int(a)
x = a
attack = 1

while h > x :
    h -= x
    attack += 1

print(attack)
n,a,b = map(int, input().split())

shou = n // (a+b)
amari = n % (a+b)

ans = shou * a + a if amari >= a　else ans = shou*a+amari

print(ans)

### FIXED CODE ###

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

shou = n // (a+b)
amari = n % (a+b)

if amari >= a:
    print(shou * a + a)

else: print(shou * a + amari)
from sys import stdin

a = [int(i) for i in stdin.readline().rstrip().split(' ')]

min = min([a[0], a[1]])
max = max([a[0], a[1]])

k = 0
for i in reversed(range()):
  if max % (i+1)==0:
    k += 1
    if k == a[2]:
      print(i)
      break

### FIXED CODE ###

from sys import stdin

a = [int(i) for i in stdin.readline().rstrip().split(' ')]

min = min([a[0], a[1]])
max = max([a[0], a[1]])

k = 0
for i in list(reversed(range(1, min + 1))):
    if max % i == 0 and min % i == 0:
        k += 1
        if k == a[2]:
            print(i)
            break