Harryxun/stf_run huggingface dataset:
h, w = map(int, input().split())
s = [list('.'*(w+2))]
for i in range(h):
    s.append(list('.' + input() + '.'))
s.append(list('.'*(w+2)))

def search(y, x):
    t = 0
    for i in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
        dy, dx = y + i[0], x + i[1]
        if s[dy][dx] == '#':
            t += 1
    if t > 0:
        return True
    else:
        return False


for i in range(w):
    for j in range(h):
        if s[j+1][h+1] == '#' and not search(j+1, h+1):
            print('No')
            quit()
print('Yes')

### FIXED CODE ###

h, w = map(int, input().split())
s = [list('.'*(w+2))]
for i in range(h):
    s.append(list('.' + input() + '.'))
s.append(list('.'*(w+2)))

def search(y, x):
    t = 0
    for i in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
        dy, dx = y + i[0], x + i[1]
        if s[dy][dx] == '#':
            t += 1
    if t > 0:
        return True
    else:
        return False


for i in range(w):
    for j in range(h):
        if s[j+1][i+1] == '#' and not search(j+1, i+1):
            print('No')
            quit()
print('Yes')
import math
A, B, N = map(int, input().split())
ans = []
for x in range(N+1, B):
    cal = math.floor((A*x)/B) - (int(A) * math.floor(x/B))
    ans.append(cal)
print(max(ans))

### FIXED CODE ###

a, b, n = map(int, input().split())
n = min(n, b-1)
 
print(int((a * n) / b) - a * int(n / b))
n = input()

if '1' in n:
  s = s.replace('1', '9')

if '9' in n:
  s = s.replace('9', '1')
  
print(s)

### FIXED CODE ###

s = list(input())

if s[0] == '1':
    s[0] = s[0].replace('1', '9')
elif s[0] == '9':
    s[0] = s[0].replace('9', '1')
if s[1] == '1':
    s[1] = s[1].replace('1', '9')
elif s[1] == '9':
    s[1] = s[1].replace('9', '1')
if s[2] == '1':
    s[2] = s[2].replace('1', '9')
elif s[2] == '9':
    s[2] = s[2].replace('9', '1')

print(''.join(s))
N = int(input())
xi = []
yi = []

for i in range(N):
  x, y = map(int, input(). split())
  xi.append(x)
  yi.append(y)
  
for j in range(N):
  for k in range(N):
    if j >= k:
      continue
    L += math.sqrt((xi[j]-xi[k])**2 + (yi[j]-yi[k])**2)
    
print(2*L/N)

### FIXED CODE ###

import math
N = int(input())
xi = []
yi = []

for i in range(N):
  x, y = map(int, input(). split())
  xi.append(x)
  yi.append(y)

L=0

for j in range(N):
  for k in range(N):
    if j >= k:
      continue
    L += math.sqrt((xi[j]-xi[k])**2 + (yi[j]-yi[k])**2)
    
print(2*L/N)
import sys
N = int(input())
cc = list(map(int,input().split()))
dic = set()
for i in cc:
  if i in dic:
    print('NO')
    sys.exit()
  else:
    dic.append(i)
print('YES')

    

### FIXED CODE ###

import sys
N = int(input())
cc = list(map(int,input().split()))
dic = set()
for i in cc:
  if i in dic:
    print('NO')
    sys.exit()
  else:
    dic.add(i)
print('YES')
N,X,Y=map(int,input().split())
l=[0]*N-1
for i in range(1,N+1):
    for j in range(1,N+1):
        ans=min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
        l[ans]+=1
for t in l:
    print(t)









### FIXED CODE ###

N=input()
M=N.replace("7","")
if len(N)!=len(M):
    print("Yes")
else:
    print("No")
N = int(input())
A = input().split()

B = sorted(range(len(A)), key=lambda k: A[k])
resutl = ""
for i in B:
    resutl += (str(i+1) + " ")
print(resutl.rstrip())N = int(input())
A = input().split()

B = [0]*N
j = 0
for i in A:
    j += 1
    B[int(i)-1] = j

resutl = ""
for i in B:
    resutl += (str(i) + " ")
print(resutl.rstrip())

### FIXED CODE ###

N = int(input())
A = input().split()

B = [0]*N
j = 0
for i in A:
    j += 1
    B[int(i)-1] = j

resutl = ""
for i in B:
    resutl += (str(i) + " ")
print(resutl.rstrip())
N = int(input())
H = list(map(int, input().split()))
ans = 0
for i in range(N-1) :
    for k in range(i+1, N):
        if s[i] - s[k] > 1 :
            print('No')
            ans = 1
            break
if ans == 0:
    print('Yes')


### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
H[0] -= 1
for i in range(N - 1):
    if H[i] < H[i+1] :
        H[i+1] -= 1

    elif H[i] > H[i+1]:
        print('No')
        exit()

print('Yes')
# -*- coding: utf-8 -*-


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

    a, b, c = -1, -1, -1
    for ia in range(n + 1):
        for ib in range(n - ia + 1):
            ic = n - ia - ib
            total = ia * 10000 + ib * 5000 + ic * 1000
            if total == y and (ia + ib + ic) == n:
                a = ia
                b = ib
                c = ic
                break

    print(f"{a} {b} {c}")


if __name__ == '__main__':
    main()




### FIXED CODE ###

# -*- coding: utf-8 -*-


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

    a, b, c = -1, -1, -1
    for ia in range(n + 1):
        for ib in range(n - ia + 1):
            ic = n - ia - ib
            total = ia * 10000 + ib * 5000 + ic * 1000
            if total == y and (ia + ib + ic) == n:
                a = ia
                b = ib
                c = ic
                break

    print(" ".join(map(str, (a, b, c))))


if __name__ == '__main__':
    main()
import sys

h, n = list(map(int, input().split()))
INF = 10 ** 18
dp = [INF] * (h + 10001)
dp[0] = 0
for line in sys.stdin:
    a, b = map(int, line.split())
    for i in range(10000):
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))


### FIXED CODE ###

import sys

h, n = list(map(int, input().split()))
INF = 10 ** 18
dp = [INF] * (20201)
dp[0] = 0
for line in sys.stdin:
    a, b = map(int, line.split())
    for i in range(10000):
        if dp[i] == INF:
            continue
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))
from math import ceil
A= [int(input()) for _ in range(5)]
rA = list(map(lambda x:x%10, A))
res = float('inf')
for i, r in enumerate(rA):
    if res>r>0:
        idx = i
        res = r
ans = A.pop(idx)
rA.pop(idx)
tA = [ceil(A[i]/10)*10 for i in range(len(A))]
print(sum(tA)+ans)

### FIXED CODE ###

from math import ceil
A= [int(input()) for _ in range(5)]
rA = list(map(lambda x:x%10, A))
res = float('inf')
idx = 0
for i, r in enumerate(rA):
    if res>r>0:
        idx = i
        res = r
ans = A.pop(idx)
tA = [ceil(A[i]/10)*10 for i in range(len(A))]
print(sum(tA)+ans)
input_line = input().split()
#print(input_line)
count5 = 0
count7 = 0
#print(input_line[0])
#print(len(input_line))
for i in range(len(input_line)):
#  print(input_line[i])
  if int(input_line[i]) == 5:
#    print(input_line[i])
    count5 += 1
#    print(count5)
  elif int(input_line[i]) == 7:
    count7 += 1
#    print(count7)
if count5 == 2 and count7 == 1:
  print("YES")
#  print(count5,count7)
else:
#  print(count5,count7)

### FIXED CODE ###

input_line = input().split()
#print(input_line)
count5 = 0
count7 = 0
#print(input_line[0])
#print(len(input_line))
for i in range(len(input_line)):
#  print(input_line[i])
  if int(input_line[i]) == 5:
#    print(input_line[i])
    count5 += 1
#    print(count5)
  elif int(input_line[i]) == 7:
    count7 += 1
#    print(count7)
if count5 == 2 and count7 == 1:
  print("YES")
#  print(count5,count7)
else:
#  print(count5,count7)
  print("NO")
import sys
n = int(input())
a = list(map(int, input().split()))

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

### FIXED CODE ###

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

total = 1
a.sort()
if a[0] == 0:
	print(0)
	sys.exit()
for i in range(n):
	total *= a[i]
	if total > 10**18:
		print('-1')
		sys.exit()
print(total)
import copy
n = int(input())
x = [int(i) for i in input().split()]
y = copy.deepcopy(x)
z = []
for j in x:
	if j not in z and x.count(j)<j:
		while y.count(j) != 0: y.remove(j)
	elif j not in z and x.count(j)>j:
		while y.count != j: y.remove(j)
	z.append(j)
print(len(x)-len(y))

### FIXED CODE ###

import collections
n = int(input())
a = [int(i) for i in input().split()]
c = collections.Counter(a)
answer = 0
for i in c.most_common():
	if i[0]>i[1]:
		answer += i[1]
	elif i[0]<i[1]:
		answer += i[1]-i[0]
print(answer)
N = int(input())
A = list(map(int, input().split()))
C = [0] * 9
for a in A:
    C[a//400] += 1
s = sum([c > 0 for c in C[:-1]])
print(max(s, 1), min(9, s + C[-1]))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
C = [0] * 9
for a in A:
    C[min(8, a//400)] += 1
s = sum([c > 0 for c in C[:-1]])
# print(C)
print(max(s, 1), s + C[-1])
N,M = map(int,input().split())
if M==0:
  if N==1:
    print(0)
  elif N==2:
    print(10)
  else:
    print(100)
SC = [list(map(int,input().split())) for _ in range(M)]
if N==1:
  s,c = SC[0][0],SC[0][1]
  for sc in SC:
    if c==sc[1]:
      continue
    else:
      print(-1)
      exit()
  print(c)
  
else:
  lis = [[] for _ in range(N)]
  for sc in SC:
    lis[sc[0]-1].append(sc[1])
    
  if 0 in lis[0]:
    print(-1)
    exit()
    
  else:
    if N==2:
      if lis[0]==[]:
        a = str(1)
      else:
        a = str(lis[0][0])
        
      if lis[1]==[]:
        b = str(0)
      else:
        b = str(lis[1][0])
        
      for i in lis[0]:
        if a==str(i):
          continue
        else:
          print(-1)
          exit()
      for i in lis[1]:
        if b==str(i):
          continue
        else:
          print(-1)
          exit()
      print(int(a+b))
      exit()
      
    else:
      if lis[0]==[]:
        a = str(1)
      else:
        a = str(lis[0][0])
        
      if lis[1]==[]:
        b = str(0)
      else:
        b = str(lis[1][0])
        
      if lis[2]==[]:
        c=str(0)
      else:
        c = str(lis[2][0])
      for i in lis[0]:
        if a==str(i):
          continue
        else:
          print(-1)
          exit()
      for i in lis[1]:
        if b==str(i):
          continue
        else:
          print(-1)
          exit()
      for i in lis[2]:
        if c==str(i):
          continue
        else:
          print(-1)
          exit()
      print(int(a+b+c))
      exit()

### FIXED CODE ###

N,M = map(int,input().split())
if M==0:
  if N==1:
    print(0)
    exit()
  elif N==2:
    print(10)
    exit()
  else:
    print(100)
    exit()
SC = [list(map(int,input().split())) for _ in range(M)]
if N==1:
  s,c = SC[0][0],SC[0][1]
  for sc in SC:
    if c==sc[1]:
      continue
    else:
      print(-1)
      exit()
  print(c)
  
else:
  lis = [[] for _ in range(N)]
  for sc in SC:
    lis[sc[0]-1].append(sc[1])
    
  if 0 in lis[0]:
    print(-1)
    exit()
    
  else:
    if N==2:
      if lis[0]==[]:
        a = str(1)
      else:
        a = str(lis[0][0])
        
      if lis[1]==[]:
        b = str(0)
      else:
        b = str(lis[1][0])
        
      for i in lis[0]:
        if a==str(i):
          continue
        else:
          print(-1)
          exit()
      for i in lis[1]:
        if b==str(i):
          continue
        else:
          print(-1)
          exit()
      print(int(a+b))
      exit()
      
    else:
      if lis[0]==[]:
        a = str(1)
      else:
        a = str(lis[0][0])
        
      if lis[1]==[]:
        b = str(0)
      else:
        b = str(lis[1][0])
        
      if lis[2]==[]:
        c=str(0)
      else:
        c = str(lis[2][0])
      for i in lis[0]:
        if a==str(i):
          continue
        else:
          print(-1)
          exit()
      for i in lis[1]:
        if b==str(i):
          continue
        else:
          print(-1)
          exit()
      for i in lis[2]:
        if c==str(i):
          continue
        else:
          print(-1)
          exit()
      print(int(a+b+c))
      exit()
h, w = map(int, raw_input().split())
S = [raw_input() for i in range(h)]
Gh = [[0]*w for i in range(h)]
Gw = [[0]*w for i in range(w)]

for i in range(h):
    ps = 0
    s = S[i]
    for j in range(w):
        if s[j] == "#":
            ps = 0
        else:
            ps += 1
            Gh[i][j] = ps

for j in range(w):
    ps = 0
    for i in range(h):
        if S[i][j] == "#":
            ps = 0
        else:
            ps += 1
            Gw[i][j] = ps

for i in range(h-1, -1, -1):
    ps = 0
    for j in range(w-1, -1, -1):
        if S[i][j] == "#":
            ps = 0
        else:
            ps = max(ps, Gh[i][j])
            Gh[i][j] = ps
for j in range(w-1, -1, -1):
    ps = 0
    for i in range(h-1, -1, -1):
        if S[i][j] == "#":
            ps = 0
        else:
            ps = max(ps, Gw[i][j])
            Gw[i][j] = ps
maxLight = 0
for i in range(h):
    for j in range(w):
        maxLight = max(maxLight, Gh[i][j] + Gw[i][j]-1)
print maxLight


### FIXED CODE ###

h, w = map(int, raw_input().split())
S = [[0 if c == "." else 1 for c in raw_input()] for i in range(h)]
L = [[0]*w for i in range(h)]
R = [[0]*w for i in range(h)]
U = [[0]*w for i in range(h)]
D = [[0]*w for i in range(h)]

for i in xrange(h):
    ps = 0
    for j in xrange(w):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            L[i][j] = ps

for j in xrange(w):
    ps = 0
    for i in xrange(h):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            U[i][j] = ps

for i in xrange(h-1, -1, -1):
    ps = 0
    for j in xrange(w-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            R[i][j] = ps
for j in xrange(w-1, -1, -1):
    ps = 0
    for i in xrange(h-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            D[i][j] = ps
maxLight = 0
for i in xrange(h):
    for j in xrange(w):
        maxLight = max(maxLight, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
print maxLight
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
c=[0]*n
for i in range(m):
  a[i],b[i],c[i]=map(int,input().split())
  a[i]-=1
  b[i]-=1
INF=float('inf')
dist=[ [INF]*n for _ in range(n)]
for i in range(n):
  dist[i][i]=0
for i in range(m):
  dist[a[i]][b[i]]=c[i]
  dist[b[i]][a[i]]=c[i]
#floyd warshall
for k in range(n):
  for i in range(n):
    for j in range(n):
      dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])
ans=m
for i in range(m):
  shortest=False
  for j in range(n):
    if dist[j][a[i]]+c[i]==dist[j][b[i]]:
      shortest=True
      break
  if shortest:
    ans-=1
print(ans)





### FIXED CODE ###

import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=[0]*m
b=[0]*m
c=[0]*m
for i in range(m):
  a[i],b[i],c[i]=map(int,input().split())
  a[i]-=1
  b[i]-=1
INF=10**18#float('inf')
dist=[ [INF]*n for _ in range(n)]
for i in range(n):
  dist[i][i]=0
for i in range(m):
  dist[a[i]][b[i]]=c[i]
  dist[b[i]][a[i]]=c[i]
#floyd warshall
for k in range(n):
  for i in range(n):
    for j in range(n):
      dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])
ans=m
for i in range(m):
  shortest=False
  for j in range(n):
    if dist[j][a[i]]+c[i]==dist[j][b[i]]:
      shortest=True
      break
  if shortest:
    ans-=1
print(ans)
n, y = map(int, input().split())
ichi = y // 10000

for i in reversed(range(ichi + 1)):
    gos = (y - 10000 * ichi) // 5000
    for j in reversed(range(gos+1)):
        rest = y - 10000 * i - 5000 * j
        k = n - i - j
        if rest % 1000 == 0 and rest // 1000 = k:
            print(i, j, k)
            exit()
else:
    print(-1, -1, -1)


### FIXED CODE ###

n, y = map(int, input().split())

for i in reversed(range(n + 1)):
    for j in reversed(range(n - i + 1)):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i, j, k)
            exit()
else:
    print(-1, -1, -1)
from itertools import accumulate

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

current_arr = A
if K > 41:
    print(" ".join([N]*N))
    exit(0)
for _ in range(K):
    imos = [0] * N
    ruiseki = [0] * (N+1)
    for i, ai in enumerate(current_arr):
        imos[max([0, i-ai])] += 1
        if i+ai+1 < N:
            imos[i+ai+1] -= 1
    for j, im in enumerate(imos):
        ruiseki[j+1] = ruiseki[j] + im
    current_arr = ruiseki[1:]
#print(imos)
#print(ruiseki)
#print(*accumulate(imos))
print(*current_arr)


### FIXED CODE ###

import sys
from itertools import accumulate

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

current_arr = A
if K > 41:
    print(*([N]*N))
else:
    for _ in range(K):
        imos = [0] * N
        ruiseki = [0] * (N+1)
        for i, ai in enumerate(current_arr):
            imos[max([0, i-ai])] += 1
            if i+ai+1 < N:
                imos[i+ai+1] -= 1
        for j, im in enumerate(imos):
            ruiseki[j+1] = ruiseki[j] + im
        current_arr = ruiseki[1:]
#print(imos)
#print(ruiseki)
#print(*accumulate(imos))
    print(*current_arr)
N = int(input())
S = [int(input()) for _ in range(N)]
S.sort(reverse=True)
ans = sum(S)
while (ans % 10) == 0:
  ans -= S.pop(0)
print(ans)

### FIXED CODE ###

N = int(input())
S = [int(input()) for _ in range(N)]
total = sum(S)
if total % 10 != 0:
  print(total)
else:
  num = [n for n in S if n % 10 != 0]
  if len(num) == 0:
    print(0)
  else:
    print(total - min(num))
N = int(input())
p = list(map(int,input().split()))
cou = 0
for i in range(1,N+1):
  if(p[i-1]==n):
    None
  else:
    cou += 1
if (cou>2):
  print("NO")
else:
  print("YES")
  

### FIXED CODE ###

N = int(input())
p = list(map(int,input().split()))
cou = 0
for i in range(1,N+1):
  if(p[i-1]==i):
    None
  else:
    cou += 1
if (cou>2):
  print("NO")
else:
  print("YES")
import sympy
N = int(input())

ans = 0
for i in range(1,N+1):
    ans +=  i*len(sympy.divisors(i))

print(ans)

### FIXED CODE ###

def solve(n):
    ans=0
    for d in range(1,n+1):
        c=n//d
        ans+=(c+1)*c//2*d
    return ans
 
n=int(input())
print(solve(n))
import math

l = map(int, raw_input().split())
A = map(int, raw_input().split())

if l[2] in A:
	M = l[1] - A.index(l[2])
	if M > A.index(l[2]):
		print A.index(l[2])
	else:
		print M
sm = l[2]
la = l[2]
while true:
	sm = sm - 1
	la = la + 1
	if sm in A and la in A:
		ix = A.index(sm) + A.index(la)
		ix = ix / 2
		break
	if sm in A:
		ix = A.index(sm)
		break
	if la in A:
		ix = A.index(la)
		break
M = l[1] - ix
if M > ix:
	print math.floor(ix)
else:
	print M

### FIXED CODE ###

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

import math

l = map(int, raw_input().split())
A = map(int, raw_input().split())

sm = l[2]
la = l[2]
while(True):
    if sm == 0:
        print 0
    if la == l[0]:
        print 0
    sm = sm - 1
    la = la + 1
    if sm in A and la in A:
    	ix = A.index(sm) + A.index(la)
        ix = ix / 2 + 0.5
        break
    if sm in A:
        ix = A.index(sm) + 0.5
	break
    if la in A:
	ix = A.index(la) - 0.5
	break
M = l[1] - ix - 1
if M > ix:
    print int(math.ceil(ix))
else:
    print int(math.ceil(M))
N, L = map(int,input().split())

alphabet = []
for i in range (L):
    word = input()
    alphabet.append(word)
    
alphabet.sort()
print(''.join(alphabet))


### FIXED CODE ###

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

alphabet = []
for i in range (N):
    word = input()
    alphabet.append(word)
    
alphabet.sort()
print(''.join(alphabet))
a,b,c = map(int, input().split())
print(a+b+c)

  

### FIXED CODE ###

N = input()
a = int(N[0])+int(N[1])+int(N[2])

print(a)
a,b,v,w,t = map(int,input().split())

d = abs(b-a)
p = abs(v-w)
i=0
for i in range(t):
  if v<=w:
    print("NO")
  elif p*t == d:
    print("YES")


### FIXED CODE ###

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
    print('NO')
else:
    if 1 <= (abs(b - a) / (v - w)) <= t:
        print('YES')
    else:
        print('NO')
N,M = list(map(int,input().split()))
path = [[False,False] for i in range(N)]
flag=False
for i in range(M):
    a,b = list(map(int,input().split()))
    if a=N-1:
        if path[b-1][0]:
            flag=True
            
        path[b-1][1]=True
    if a=0:
        if path[b-1][1]:
            flag=True
            
        path[b-1][0]=True
    if b=N-1:
        if path[a-1][0]:
            flag=True
            
        path[a-1][1]=True
    if b=0:
        if path[a-1][1]:
            flag=True
            
        path[a-1][0]=True

if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

N,M = list(map(int,input().split()))
path = [[False,False] for i in range(N)]
flag=False
for i in range(M):
    a,b = list(map(int,input().split()))
    if a==N:
        if path[b-1][0]:
            flag=True
            
        path[b-1][1]=True
    if a==1:
        if path[b-1][1]:
            flag=True
            
        path[b-1][0]=True
    if b==N:
        if path[a-1][0]:
            flag=True
            
        path[a-1][1]=True
    if b==1:
        if path[a-1][1]:
            flag=True
            
        path[a-1][0]=True

if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
import fractions

n, m = map(int, input().split())
a = list(map(int, input().split()))
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def lcm(x, y):
	return (x * y) // gcd(x, y)

now = a[0]
for i in range(1, n):
	now = lcm(now, a[i])

for i in range(n):
	if (now//a[i])%2 == 0:
		print(0)
		exit(0)

print(((m//(now/2))+1)//2)


### FIXED CODE ###

import fractions

n, m = map(int, input().split())
a = list(map(int, input().split()))
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def lcm(x, y):
	return (x * y) // gcd(x, y)

now = a[0]
for i in range(1, n):
	now = lcm(now, a[i])
	if now > 2 * m:
		print(0)
		exit(0)

for i in range(n):
	if (now//a[i])%2 == 0:
		print(0)
		exit(0)

print(((m//(now//2))+1)//2)
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
   
if N == 2:
    print(sum(B)+sum(C))
elif N == 1:
    print(sum(B))
else:
    k = A[-1]
    print(sum(B)+sum(C)-C[k-1])

### FIXED CODE ###

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

ans = 0
for i in range(N):
    k = A[i]
    ans += B[k-1]
    if i < N-1:
        if A[i+1] == k+1 and k != N:
            ans += C[k-1]
        else:
            pass
    else:
        pass
print(ans)
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    sumA=0
    sumB=0
    B = sorted(A, reverse=True)
    turnB = False

    for i in B:
        if turnB == False:
            sumA += i
            turnB = True
        else:
            sumB += i
            turnB = False

    print(int(sumA - SumB))


resolve()

### FIXED CODE ###

def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    sumA=0
    sumB=0
    B = sorted(A, reverse=True)
    turnB = False

    for i in B:
        if turnB == False:
            sumA += i
            turnB = True
        else:
            sumB += i
            turnB = False

    print(int(sumA - sumB))


resolve()
n = int(input())
*A, = map(int, input().split())
# n = 10
# A = [33, 18, 33, 28, 8, 19, 89, 86, 2, 4]

C = {a:0 for a in A}

for a in A:
    C[a] = C[a]+1

maxA = max(A)

D = {a:0 for a in A}

for a in A:
    t = 2
    while a*t <= maxA:
        D[a*t] += D[a*t]+1
        t = t+1

counter = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        counter = counter+1
        
print(counter)

### FIXED CODE ###

n = int(input())
*A, = map(int, input().split())
maxA = max(A)
# C[a] = A内のaの個数
C = {a: 0 for a in A}
for a in A:
    C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in A}
for a in A:
    if C[a] > 0:
        t = 2
        while a * t <= maxA:
            D[a * t] = 1
            t += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)