Harryxun/stf_run huggingface dataset:
import sys
N,M=map(int,input().split())
grid = []
for i in range(M):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
pre = []
pos = []
for ships in grid:
  if ships[0] == 1:
    pre.append(ships[1])
  if ships[1] == N:
    pos.append(ships[0])
if pre == [] or pos == []:
  print('IMPOSSIBLE')
  sys.exit()
pre.sort()
pos.sort()
def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return 1
    return 0
for nums in pre:
  if index(nums,pos) == 1:
    print('POSSIBLE')
    sys.exit()
print('IMPOSSIBLE')


### FIXED CODE ###

import sys
import bisect
N,M=map(int,input().split())
grid = []
for i in range(M):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
pre = []
pos = []
for ships in grid:
  if ships[0] == 1:
    pre.append(ships[1])
  if ships[1] == N:
    pos.append(ships[0])
if pre == [] or pos == []:
  print('IMPOSSIBLE')
  sys.exit()
pre.sort()
pos.sort()
def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect.bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return 1
    return 0
for nums in pre:
  if index(pos,nums) == 1:
    print('POSSIBLE')
    sys.exit()
print('IMPOSSIBLE')
r =int(intput())
print(r**2)

### FIXED CODE ###

r =int(input())
print(r**2)
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

def dfs(idx, end, value, cost, g):
    if idx == end:
        if cost == 0:
            return

        if value not in g:
            g[value] = cost
        else:
            g[value] = min(g[value], cost)

        return

    a, b, c = table[idx]
    dfs(idx + 1, end, value + b * Ma - a * Mb, cost + c, g)
    dfs(idx + 1, end, value, cost, g)

N, Ma, Mb = map(int, input().split())
table = [tuple(map(int, input().split())) for i in range(N)]

g1, g2 = dict(), dict()
dfs(0, N // 2, 0, 0, g1)
dfs(N // 2, N, 0, 0, g2)

inf = 100*40 + 1
ans = inf

if 0 in g1:
    ans = min(ans, g1[0])
if 0 in g2:
    ans = min(ans, g2[0])

for v1, c1 in g1.items():
    if -v1 in g2:
        tmp = c1 + g2[-v1]
        ans = min(ans, tmp)

if ans < inf:
    print(ans)
else:
    print(-1)


### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

N, M = map(int, input().split())
A = [0]*N
B = [0]*M

for i in range(N):
	A[i] = input()
for i in range(M):
	B[i] = input()

ans = False
for sy in range(N-M+1):
	for sx in range(N-M+1):
		flag = True
		for iy in range(M):
			if B[iy] != A[sy+iy][sx:sx+M]:
				flag = False
				break
		if flag:
			ans = True
			break

if ans:
	print("Yes")
else:
	print("No")
import numpy as np
import sys
read = sys.stdin.buffer.read

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

C = np.frombuffer(read(), dtype='S1').reshape(H, -1)

def f(x, y, C):
	rows = [i for i in range(H) if x & (1<<i)]
	cols = [i for i in range(W) if y & (1<<i)]
	D = C[rows][:, cols]
	return D.sum() == K

res = 0
for x in range(1<<H):
	for y in range(1<<W):
		res += f(x, y, C)
print(res)

### FIXED CODE ###

from itertools import combinations
import numpy as np

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

C = []
base = 0
for i in range(H):
	string = input()
	string = string.replace('.', '0')
	string = string.replace('#', '1')
	lst = list(string)
	lst = [int(c) for c in lst]
	C.append(lst)
	base += sum(lst)

C = np.array(C)
orig = C.copy()
count = 0

for i in range(H+1):
	for j in range(W+1):
		for c in combinations(range(H), i):
			for d in combinations(range(W), j):
				for row in c:
					C[row] = [0] * W
				for col in d:
					C[:, col] = [0] * H
				if np.sum(C) == K:
					count += 1
				C = orig.copy()

print(count)
n = int(input())
red, brue = [], []
for _ in range(n):
  x, y = map(int, input().split())
  red.append([x, y])
for _ in range(n):
  x, y = map(int, input().split())
  brue.append([x, y])
red, brue = sorted(red), sorted(brue)
used = [Flase for _ in range(n)]
ans = 0
for i in range(n):
  x, y = red[i][0], red[i][1]
  for j in range(n):
    if used[j] or x >= brue[j][0] or y >= brue[j][1]:
      continue
    used[j] = True
    ans += 1
print(ans)

### FIXED CODE ###

def bipertite_matching(N, edges):
    def dfs(v):
        used[v] = True
        for u in edges[v]:
            w = match[u]
            if w < 0 or (used[w] == False and dfs(w)):
                match[v] = u
                match[u] = v
                return True
        return False
    match = [-1 for _ in range(N)]
    ret = 0
    for v in range(N):
        if match[v] < 0:
            used = [False for _ in range(N)]
            if dfs(v):
                ret += 1
    return ret

N = int(input())
a, b = [None] * N, [None] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())
c, d = [None] * N, [None] * N
for i in range(N):
    c[i], d[i] = map(int, input().split())
es = [[] for i in range(2 * N)]
for i in range(N):
    for j in range(N):
        if a[i] < c[j] and b[i] < d[j]:
            es[i].append(N+j)
            es[N+j].append(i)
print(bipertite_matching(2*N, es))
n = int(input())
a = set()
for _ in range(n):
    a ^= {input()}
print(len(a))

### FIXED CODE ###

n=input()
print('Yes' if n[0]==str(9) or n[1]==str(9) else 'No')
N,T=map(int,list(input().split()))
c=1001
for i in range(N):
  ct,tc=map(int,list(input().split()))
  if T>=tc and c>=ct:
    c=ct
  if c==1001:
    c="TLE"
print(c)

### FIXED CODE ###

N,T=map(int,list(input().split()))
c=1001
for i in range(N):
  ct,tc=map(int,list(input().split()))
  if T>=tc and c>=ct:
    c=ct
if c==1001:
  c="TLE"
print(c)
MAX_N = 10000000+1

def make_sosu_tbl():
    for i in range(2, MAX_N):
        if sos[i]:
            for j in range(i+i, MAX_N+1, i):
                sos[j] = 0
        if i**2 >= MAX_N:break

sos = [1] * (MAX_N+1)
make_sosu_tbl()
while 1:
#    MAX_N = int(input())
#    if not MAX_N: break
#    
    n = int(input())
    if not n:break
    for i in reversed(range(13,n+1)):
        if sos[i] and sos[i-2] and sos[i-6] and sos[i-8]:
            print(i)
            break

### FIXED CODE ###

# from datetime import datetime

# measure_start = datetime.now()
move = [[[10, 10], [4, 4]], [[8, 2],[4, 2]]]

MAX_N = 10000000+1
sos = [1] * (MAX_N+1)
sos[0] = sos[1] = 0
for i in range(2, int(MAX_N**0.5)+1):
    if sos[i]:
        for j in range(i+i, MAX_N+1, i):
            sos[j] = 0

while 1:
    try:
        n = int(input())

        if not n: break
        n -= (n%2 == 0)
        while n >= 13:
            if sos[n] and sos[n-2] and sos[n-6] and sos[n-8]:
                print(n)
                break
            else:
                n -= move[sos[n-8]][sos[n-6]][sos[n-2]]
    # measure_stop = datetime.now()
    # print(measure_stop - measure_start)
    except:
        pass
N=int(input())
a=[]
b=[]
for i in range(N):
  a=a.append(float(input()))
  b=b.append(input())
total=0
for j in range(N):
  if b[j]=='JPY':
    total = total+ a[j]
  else:
    total = total+380000.0*a[j]
print(total)


### FIXED CODE ###

N=int(input())
a=[]
b=[]
for i in range(N):
  x,y=input().split()
  a.append(float(x))
  b.append(y)
total=0
for j in range(N):
  if b[j]=='JPY':
    total += a[j]
  else:
    total += 380000.0*a[j]
print(total)
a=int(input())
n=list(map(int,input().split()))
mod=10**9+7
import numpy as np
a=np.array(a)
md = len(bin(max(a)))
ans = 0
for d in range(md):
    cnt1 = np.count_nonzero((a>>d)&1)
    ans += cnt1 * (n-cnt1) * (1<<d)
    ans %= mod

print(ans%mod)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
import numpy as np
a=np.array(a)
md = len(bin(max(a)))
ans = 0
for d in range(md):
    cnt1 = np.count_nonzero((a>>d)&1)
    ans += cnt1 * (n-cnt1) * (1<<d)
    ans %= mod

print(ans%mod)
N = int(input())
ans = 0
for i in range(1, N+1):
  if len(list(i)) % 2 = 1:
    ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
ans = 0
for i in range(1, N+1):
  if len(list(str(i))) % 2 == 1:
    ans += 1
print(ans)
x,y=map(int,input().split())
group_A=[1,3,5,7,8,10,12]
group_B=[4,6,9,11]
if x in group_A = True and y in group_A =True:
  print("Yes")
elif x in group_B = True and y in group_B =True:
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

x,y=map(int,input().split())
group_A=[1,3,5,7,8,10,12]
group_B=[4,6,9,11]
if x in group_A and y in group_A :
  print("Yes")
elif x in group_B and y in group_B :
  print("Yes")
else:
  print("No")
#
# abc072 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7
3 1 4 1 5 9 2"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10
0 1 2 3 4 5 6 7 8 9"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1
99999"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    an = {}
    for a in A:
        an.setdefault(a, 0)
        an[a] += 1

    ans = 1
    for x in range(A):
        t = 0
        for k, v in an.items():
            if x == k-1 or x == k or x == k+1:
                t += v
        ans = max(ans, t)

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


### FIXED CODE ###

#
# abc072 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7
3 1 4 1 5 9 2"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10
0 1 2 3 4 5 6 7 8 9"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1
99999"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    AN = [0] * 100002  # -1 <= X <= 10^5+1

    for a in A:
        AN[a] += 1
        AN[a+1] += 1
        AN[a+2] += 1
    print(max(AN))


if __name__ == "__main__":
    # unittest.main()
    resolve()
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    z,y = map(int,input().split())
    a.append(z)
    b.append(y)
a_b = dict(zip(a,b))
a_b = sorted(a_b.items(), key=lambda x:x[0])

c = 0
ans = 0
t = 0
for i in range(n):
    c += a_b[i][1]
    if c > m:
        ans += a_b[i][0] * (m - t)
        break
    else:
        ans += a_b[i][0] * a_b[i][1]
        t += a_b[i][1]

print(ans)


### FIXED CODE ###

n,m = map(int,input().split())
a_b = {}
for i in range(n):
    x,y = map(int,input().split())
    if x in a_b.keys():
        a_b[x] += y
        continue
    a_b[x] = y
a_b = sorted(a_b.items(), key=lambda x:x[0])

#print(a_b)
c = 0
ans = 0
t = 0
for i in range(int(len(a_b))):
    c += a_b[i][1]
    if c > m:
        ans += a_b[i][0] * (m - t)
        break
    else:
        ans += a_b[i][0] * a_b[i][1]
        t += a_b[i][1]

print(ans)
n, k = map(int, input().split())
d = list(map(int, input().split()))
digit = [str(i) for i in range(10) if not i in d]
ans = []
stack = [i for i in digit]
while stack:
  s = stack.pop()
  if int(s) >= n:
    ans.append(s)
  else:
    for i in digit:
      if len(i+s) <= len(str(n)+1):
        stack.append(i+s)

print(min(ans))

      


### FIXED CODE ###

n, k = map(int, input().split())
d = list(map(int, input().split()))
digit = [str(i) for i in range(10) if not i in d]
ans = []
stack = [i for i in digit]
while stack:
  s = stack.pop()
  if int(s) >= n:
    ans.append(int(s))
  else:
    for i in digit:
      if len(i+s) <= len(str(n))+1:
        stack.append(i+s)

print(min(ans))
x <- list(map(int(), input().split()))

for i in len(x):
    print("Case", i+1, ":", x[i])



### FIXED CODE ###

for i in range(10000):
    x = input()
    x = int(x)
    
    if x == 0:
        break
    else:
        print("Case "+ str(i+1) + ": " + str(x))
print(str[::-1])

### FIXED CODE ###

import sys
str = sys.stdin.readline()[:-1]
print(str[::-1])
from sys import stdin
import math

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

mod = 10 ** 9 + 7
g = 1
ans = 0

for i in range(N):
    d = math.gcd(A[i], g)
    g *= A[i]
    g //= d

for i in range(N):
    ans += (g * pow(A[i], mod - 2, mod)) % mod

print(ans % mod)


### FIXED CODE ###

from sys import stdin
from collections import defaultdict

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

mod = 10 ** 9 + 7
g = defaultdict(int)

for i in range(N):
    tmp = 1
    a = A[i]
    while tmp <= A[i] ** 0.5:
        cnt = 0
        while tmp > 1 and a % tmp == 0:
            a //= tmp
            cnt += 1
        if cnt > 0:
            g[tmp] = max(g[tmp], cnt)
        tmp += 1
    if a > 1:
        if a not in g:
            g[a] = 1

l = 1
ans = 0
for i in g:
    l *= pow(i, g[i], mod)
    l %= mod
for a in A:
    ans += l * pow(a, mod - 2, mod)
    ans %= mod

print(ans)
s=str(input())
st=list(s)
l=len(st)
if st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[4]=="n" and st[5]=="c" and st[6]=="e":
  print("YES")
elif st[l-7]=="k" and st[l-6]=="e" and st[l-5]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[l-6]=="e" and st[l-5]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[l-5]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[4]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[4]=="n" and st[5]=="c" and st[l-1]=="e":
  print("YES")
else:
  ptint("NO")

### FIXED CODE ###

s=str(input())
st=list(s)
l=len(st)
if st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[4]=="n" and st[5]=="c" and st[6]=="e":
  print("YES")
elif st[l-7]=="k" and st[l-6]=="e" and st[l-5]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[l-6]=="e" and st[l-5]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[l-5]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[4]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[4]=="n" and st[5]=="c" and st[l-1]=="e":
  print("YES")
else:
  print("NO")
N,K = list(map(int, input().split()))


if N == 0:
    print(N)

initialK = K
while True:
    if N <= initialK/2:
        print(N)
        break
    K = N%K
    if K <= initialK/2:
        print(K)
        break


### FIXED CODE ###

X,Y,Z = list(map(int, input().split()))

print(Z, X, Y)
n, T = map(int,input().split())
A=[]
for i in range(n):
  a = list(map(int,input().split()))
  if a[1]<=T:
    A.append(a[0])

if len(a)==0:
    print('TLE')
else:
    print(min(A))

### FIXED CODE ###

n,t=map(int, input().split())
A=[]
for i in range(n):
  a=list(map(int, input().split()))
  if a[1] <= t:
    A.append(a[0])
if len(A)==0:
  print('TLE')
else:
  print(min(A))
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    
    """
    もし負の数が偶数個存在すればそれらはすべて正の数にできる。
    もし負の数が奇数個存在すればそれは最終的に１個にできる。
    """

    idx = bisect_left(A, 0)
    if idx % 2 == 0:
        print(sum(A[idx:]) - sum(A[:idx]))
    else:
        cand1 = sum(A[idx:]) - sum(A[:idx]) + A[idx - 1] * 2
        cand2 = sum(A[idx:]) - sum(A[:idx]) - A[idx] * 2
        print(max(cand1, cand2))
    


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    
    """
    もし負の数が偶数個存在すればそれらはすべて正の数にできる。
    もし負の数が奇数個存在すればそれは最終的に１個にできる。
    """

    idx = bisect_left(A, 0)
    if idx % 2 == 0:
        print(sum(A[idx:]) - sum(A[:idx]))
    elif idx < len(A) :
        cand1 = sum(A[idx:]) - sum(A[:idx]) + A[idx - 1] * 2
        cand2 = sum(A[idx:]) - sum(A[:idx]) - A[idx] * 2
        print(max(cand1, cand2))
    else:
        print(-sum(A) + A[-1] * 2)
    


if __name__ == "__main__":
    main()
x,n = map(int,input().split())
if n > 0 :
  p = list( map(int,input().split()) )

p = set(p)
if x not in p:
  ans = x
else:
  i = x - 1
  j = x + 1
  while 1:
    if i not in p and j not in p:
      ans = min(i,j)
      break

    if i not in p:
      ans = i
      break
    elif j not in p:
      ans = j
      break

    i -= 1
    j += 1

print(ans)
  




### FIXED CODE ###

x,n = map(int,input().split())
if n > 0 :
  p = list( map(int,input().split()) )
  p = set(p)
else:
  p = set()

if x not in p:
  ans = x
else:
  i = x - 1
  j = x + 1
  while 1:
    if i not in p and j not in p:
      ans = min(i,j)
      break

    if i not in p:
      ans = i
      break
    elif j not in p:
      ans = j
      break

    i -= 1
    j += 1

print(ans)
a,b=map(int,input().split())
height=list(map(int,input().split()))
count=0
for i in range (a):
  	 if int(height[i])>=b:
      	count+=count
print(str(count))

### FIXED CODE ###

a,b=map(int,input().split())
height=list(map(int,input().split()))
count=0
for i in range (a):
    if int(height[i])>=b:
       count+=1
print(count)
import copy
import sys
sys.setrecursionlimit(10**7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return (a // gcd(a, b)) * b

def main():
    n, m = map(int, input().split())
    # これだと72がREになる
    A = [int(x) for x in input().split()]
    # A_s = set(A)
    # A_ = copy.deepcopy(A)
    # a_lcm = A.pop()
    a_lcm = 1
    # Aの要素が複数ならlcmを計算する
    #if len(A) >= 1:
    for a in A:
        a_lcm = lcm(a_lcm, a)
    #else:
    #    a_lcm = a_lcm
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    #for i in A_:
    for a in A:
        # # これなら72は通る
        # print(0)
        # exit()
        if a_lcm // 2 % a == 0:
        # if (a_lcm / a) % 2 == 0: 
            print(0)
            exit()
        # else:
        #     continue
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
    # if a_lcm > m * 2:
        print(0)
        exit()
    else:
        # # あとは定数倍の数調べて終わり
        ans = int((m - (a_lcm / 2)) // a_lcm) + 1
        print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy
# from math import gcd


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return (a // gcd(a, b)) * b
def main():
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_lcm = 1
    for a in A:
        a_lcm = lcm(a_lcm, a)
        # mがlcmの半分よりも小さかったら0
        if (a_lcm / 2) > m:
            print(0)
            exit()
    for a in A:
        if (a_lcm / 2) % a == 0:
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()
import numpy as np

h, w, m = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(m)]

check = np.zeros((h, w))

for i,j in li:
    check[i-1, :] += 1
    check[:, j-1] += 1
    check[i-1, j-1] -= 1

print(int(np.max(check)))

### FIXED CODE ###

import collections

h, w, m = map(int, input().split())
h_li = []
w_li = []

for i in range(m):
    _h, _w = map(int,input().split())
    h_li.append(_h)
    w_li.append(_w)

h_bomb = [0] * (h+1)
w_bomb = [0] * (w+1)

h_counter = collections.Counter(h_li)
w_counter = collections.Counter(w_li)

for i in range(1, h+1):
    h_bomb[i] = h_counter.get(i, 0)

for i in range(1, w+1):
    w_bomb[i] = w_counter.get(i, 0)
    
ans = max(h_bomb) + max(w_bomb)
allow_count = h_bomb.count(max(h_bomb)) * w_bomb.count(max(w_bomb))

s = 0
cnt = 0
for i in range(m):
    _h, _w = h_li[i], w_li[i]
    if h_bomb[_h] + w_bomb[_w] == ans:
        cnt += 1
    
if cnt < allow_count:
    print(ans)
else:
    print(ans-1)
from collections import defaultdict

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

d_even = defaultdict(int)
d_odd = defaultdict(int)

for i in range(N):
    v = V[i]
    if i % 2 == 0:
        d_even[v] += 1
    else:
        d_odd[v] += 1

l_even = sorted(d_even.items(), key=lambda x: -x[1])
l_odd = sorted(d_odd.items(), key=lambda x: -x[1])

if l_even[0][0] != l_odd[0][0]:
    print(N - l_even[0][1] - l_odd[0][1])
else:
    print(min(N - l_even[0][1] - l_odd[1][1], N - l_even[1][1] - l_odd[0][1]))


### FIXED CODE ###

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

vo = [0]*(10**5+1)
ve = [0]*(10**5+1)

for i in range(n):
    if i % 2 == 0:
        vo[v[i]] += 1
    else:
        ve[v[i]] += 1

if vo.index(max(vo)) == ve.index(max(ve)):
    ans1 = sum(vo) - max(vo) + sum(ve) - sorted(ve)[-2]
    ans2 = sum(vo) - sorted(vo)[-2] + sum(ve) - max(ve)
    print(min(ans1, ans2))
else:
    print(sum(vo) - max(vo) + sum(ve) - max(ve))
from math import gcd

def lcm(a, b):
    return a*b / gcd(a, b)

a, b = map(int, input().split())
ans = int(lcm(a, b))
print(ans)

### FIXED CODE ###

from fractions import gcd

def lcm(a, b):
    res = a*b / gcd(a, b)
    return res

a, b = map(int, input().split())
ans = int(lcm(a, b))
print(ans)
N = int(input())
a = list(map(int,input().split()))
col = [0]*8
wild = 0
for i in a:
    if i//400 <= 7:
        col[i//400] = 1
    else:
        wild += 1
minimum = max(1,sum(col))
maximum = min(sum(col)+wild)
print(minimum,maximum)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
col = [0]*8
wild = 0
for i in a:
    if i//400 <= 7:
        col[i//400] = 1
    else:
        wild += 1
minimum = max(1,sum(col))
maximum = sum(col)+wild
print(minimum,maximum)