Harryxun/stf_run huggingface dataset:
import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n,k=get_ints()
h=get_array()
li=[99999]*n
li[0]=0

li[1]=abs(h[1]-h[0])
for i in range(2,n):
    for j in range(i-1,(i-k)-1,-1):
        if j<0:
            break

            #3print(i,j)
        li[i]=min(li[i],li[j]+abs(h[i]-h[j]))
##print(li)
print(li[n-1])


### FIXED CODE ###


n=int(input())
h=list(map(int,input().split()))
li=[0]*n
li[1]=abs(h[1]-h[0])
for i in range(2,n):
    li[i]=min(li[i-1]+abs(h[i]-h[i-1]),li[i-2]+abs(h[i]-h[i-2]))
##print(li)
print(li[n-1])
N = int(input())
p = list(map(int, input().split()))
cnt = 0
if p[0] == 1:
    tmp = p[1]
    p[1] = p[0]
    p[0] = tmp
    cnt += 1

for i in range(N, 0, -1):
    if i == p[i - 1]:
        tmp = p[i]
        p[i] = p[i - 1]
        p[i - 1] = tmp
        cnt += 1

print(cnt)

### FIXED CODE ###

N = int(input())
p = list(map(int, input().split()))
cnt = 0
if p[0] == 1:
    tmp = p[1]
    p[1] = p[0]
    p[0] = tmp
    cnt += 1

for i in range(N - 1, -1, -1):
    if i + 1 == p[i]:
        tmp = p[i]
        p[i] = p[i - 1]
        p[i - 1] = tmp
        cnt += 1

print(cnt)
L, R = map(int, input().split())

ans = 2019
for i in range(L, R):
    f = False
    for j in range(i, R):
        if  ((i*j) % 2019) == 0:
            print(0)
            break
        ans = min(ans, (i*j)%2019)
    if f:
        break
print(ans)

### FIXED CODE ###

A, B, C, D = map(int, input().split())
ans=0

def gcd(m, n):
    x=max(m, n)
    y=min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z

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

lcmCD=lcm(C, D)
ans=B-A+1
ans-=((B//C) - ((A-1)//C))
ans-=((B//D) - ((A-1)//D))
ans+=((B//lcmCD) - ((A-1)//lcmCD))
print(ans)
import copy
from collections import deque
from collections import defaultdict

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

line=defaultdict(list)
q=deque
next=deque()

ans=[-1]*(N+1)
ans[0]=0
ans[1]=0
for i in range(N):
  a,b=map(int, input().split())
  line[a].append(b)
  line[b].append(a)

#print(line)
    
next.append(1)
a=1
while len(next)>0:
  q=copy.copy(next)
  #print(q)
  next.clear()
  while len(q)>0:
    chk=q.popleft()
    #print('qpop',q)
    for i in range(len(line[chk])):
      #print('chk',chk)
      #print('line[chk][i]',line[chk][i])
      if ans[line[chk][i]]==-1:
        ans[line[chk][i]]=chk
        next.append(line[chk][i]) 
  if -1 not in ans:break
  #print('next',next)
#print(ans)
if -1 in ans:print('No')
else:
  print('Yes')
  for i in range(2,N+1):  
    print(ans[i])
    


### FIXED CODE ###

import copy
from collections import deque
from collections import defaultdict

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

line=defaultdict(list)
q=deque
next=deque()

ans=[-1]*(N+1)
ans[0]=0
ans[1]=0
for i in range(M):
  a,b=map(int, input().split())
  line[a].append(b)
  line[b].append(a)

#print(line)
    
next.append(1)
a=1
while len(next)>0:
  q=copy.copy(next)
  #print(q)
  next.clear()
  while len(q)>0:
    chk=q.popleft()
    #print('qpop',q)
    for i in range(len(line[chk])):
      #print('chk',chk)
      #print('line[chk][i]',line[chk][i])
      if ans[line[chk][i]]==-1:
        ans[line[chk][i]]=chk
        next.append(line[chk][i]) 
  if -1 not in ans:break
  #print('next',next)
#print(ans)
if -1 in ans:print('No')
else:
  print('Yes')
  for i in range(2,N+1):  
    print(ans[i])
N = int(input())
S, T = input().split()
print(*[s+t for s,t in zip(S,T)], sep='')

### FIXED CODE ###


A = int(input())
B = int(input())
if A != 1 and B != 1:
    print(1)
elif A != 2 and B != 2:
    print(2)
else:
    print(3)
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
array = []
for _ in range(M):
    tmp = list(map(int, input().split()))
    array.append(tmp)
array.sort(key=lambda x: x[1], reverse=True)

_sum = 0
_num = 0

for i in range(N+M):
    if A[0] > array[0][1]:
        _sum += A.pop(0)
        _num += 1
    else:
        a = array[0][0] if array[0][0] < N - _num else N - _num
        _sum += array.pop(0)[1] * a
        _num += a
        
    if _num == N:
        break
    
print(_sum)

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
array = []
for _ in range(M):
    tmp = list(map(int, input().split()))
    array.append(tmp)
array.sort(key=lambda x: x[1], reverse=True)

_sum = 0
_num = 0

for i in range(N+M):
    if A[0] > array[0][1]:
        _sum += A.pop(0)
        _num += 1
        
    else:
        a = array[0][0] if array[0][0] < N - _num else N - _num
        _sum += array.pop(0)[1] * a
        _num += a
        if not array:
            break
        
    if _num == N:
        break
    
if _num != N:
    while _num < N:
        _sum += A.pop(0)
        _num += 1
        
print(_sum)
inf = 10**9
N = int(raw_input())
p = [int(raw_input()) for i in xrange(N)]
to = [i for i in xrange(N)]
for i in xrange(N):
        if to[i] != i: continue
        seq = set([])
        while 1:
            if to[i] != i:
                for j in seq: to[j] = to[i]
            elif i in seq:
                for j in seq: to[j] = -1
                break
            elif p[i] == 0:
                for j in seq: to[j] = i
                break
            else:
                seq.add(i)
                i += p[i]
                 
dp = [inf]*N
dp[0] = 0
for i in xrange(N):
    if dp[i] == inf: continue
    for j in xrange(i+1,min(N,i+7)):
        if to[j] < j: continue
        dp[to[j]] = min(dp[to[j]], dp[i]+1)
print dp[N-1]

### FIXED CODE ###

inf = 10**9
N = int(raw_input())
p = [int(raw_input()) for i in xrange(N)]
to = [i for i in xrange(N)]
for i in xrange(N):
        if to[i] != i: continue
        seq = set([])
        while 1:
            if to[i] != i:
                for j in seq: to[j] = to[i]
                break
            elif i in seq:
                for j in seq: to[j] = -1
                break
            elif p[i] == 0:
                for j in seq: to[j] = i
                break
            else:
                seq.add(i)
                i += p[i]

visited = [False]*N
visited[0] = True
que = [[0,0]]
while 1:
    cur,step = que.pop(0)
    if cur == N-1:
        print step
        break
    for nxt in range(cur+1,min(N,cur+7)):
        if to[nxt] > 0 and not visited[to[nxt]]:
            visited[to[nxt]] = True
            que.append([to[nxt], step+1])
if a==0:
    print(0)
elif n>a:
    print(n-b)
elif n<=a:
    print(n)


### FIXED CODE ###

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

ans=n//(a+b)*a
r=n%(a+b)
ans+=min(r,a)
print(ans)
import numpy as np

a = [list(map(int,input().split())) for _ in range(3)]

n = int(input())

b = list([int(input()) for _ in range(n)])

c = [[0]*3]*3

for k in b:
    for i in range(3):
        for j in range(3):
            if k == a[i][j]:
                c[i][j]=1

c = np.array(c)

if (max(c.sum(axis=0))==3) or (max(c.sum(axis=1))==3) or \
    (sum([a[i,i] for i in range(3)])==3) or (sum(a[2,0]+a[1,1]+a[0,2])==3):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import numpy as np

a = [list(map(int,input().split())) for _ in range(3)]

n = int(input())

b = list([int(input()) for _ in range(n)])

c = np.zeros(9).reshape(3,3)

for k in b:
    for i in range(3):
        for j in range(3):
            if k == a[i][j]:
                c[i,j]=1

if (max(c.sum(axis=0))==3) or (max(c.sum(axis=1))==3) or \
    (sum([c[i,i] for i in range(3)])==3) or (c[2,0]+c[1,1]+c[0,2]==3):
    print("Yes")
else:
    print("No")
import sys
input()
d={k:0 for k in 'AC WA TLE RE'.split()}
for ln in sys.stdin:
    d[ln.strip()]+=1
for k,v in d.items():
    print(k,'x',v)


### FIXED CODE ###

N=int(input())
S=input()
l,r=[0]*N,[0]*N
for i in range(N-1):
    l[i+1]+=l[i]+(S[i]=='W')
for i in range(N-1,0,-1):
    r[i-1]+=r[i]+(S[i]=='E')
ans=3*10**5
for i in range(N):
    ans=min(ans,l[i]+r[i])
print(ans)
import math

sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        for j in range(2*i+1,r,i+1):
            p[j] = 0

s = [0 for i in range(11000)]
s[0] = 2
k = 1
for i in range(2,r):
    if p[i]:
        s[k] = i+1+s[k-1]
        k += 1
        
while True:
    n = int(raw_input())
    if not n:
        break
    print s(n)

### FIXED CODE ###

import math

r = 105000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]

s = [0 for i in range(11000)]
s[0] = 2
k = 1
for i in range(2,r):
    if p[i]:
        s[k] = i+1+s[k-1]
        k += 1
        
while True:
    n = int(raw_input())
    if not n:
        break
    print s[n-1]
N = int(input())
str = str(input())
K = int(input())
str_list = list(str)
for i in range(N):
    if str_list[i] != str_list[int(K)]:
        str_list[i] = '*'
str_changed = ''.join(str_list)
print(str_changed)

### FIXED CODE ###

N = int(input())
str = list(input())
K = int(input()) - 1
str_list = list(str)
for i in range(N):
    if str[i] != str[K]:
        str[i] = '*'
str_changed = ''.join(str)
print(str_changed)
N, Q = map(int, input().split())

graph_lis = [[] for i in range(N)]
for n in range(N - 1):
    a, b = map(int, input().split())
    graph_lis[b - 1].append(a - 1)

ans_list = [0] * N

points = [0] * N
for q in range(Q):
    p, x = map(int, input().split())
    points[p - 1] += x

ans_list[0] = points[0]
for n in range(1, N):
    ans_list[n] = ans_list[graph_lis[n][0]] + points[n]
print(' '.join(map(str, ans_list)))

### FIXED CODE ###

from collections import deque

N, Q = map(int, input().split())
graph_lis = [[] for n in range(N)]

for i in range(N - 1):
    a, b = map(int, input().split())
    graph_lis[a - 1].append(b - 1)
    graph_lis[b - 1].append(a - 1)

ans = [0] * N
for q in range(Q):
    p, x = map(int, input().split())
    ans[p - 1] += x

deq = deque([0])
visited = [False] * N
while deq:
    parent = deq.popleft()
    edge = graph_lis[parent]
    for v in edge:
        if not visited[v]:
            ans[v] += ans[parent]
            deq.append(v)
    visited[parent] = True
print(*ans)
N=int(input())
l=[0 for _ in range(N)]
for _ in range(N):
  l[int(input())-1]=1
print(sum(l))

### FIXED CODE ###

N=int(input())
l=[0 for _ in range(100)]
for _ in range(N):
  l[int(input())-1]=1
print(sum(l))
a, b = map(int, input.split(' '))
if a <= b:
	print(a)
else:
	print(a-1)

### FIXED CODE ###

a, b = map(int, input().split(' '))
if a <= b:
	print(a)
else:
	print(a-1)
x=[list(map(str,input().split())) for _ in range(3)]
N=int(input())
B=[input() for _ in range(N)]
flag=0
for i in range(3):
  for j in range(3):
    if x[i][j] in B:
      x[i][j]=True

for p in range(3):
  if x[p].count(True)==3:
    flag=1
lis=[]
lis2=[]
for a in range(3):
  for b in range(3):
    lis2.append(x[b][a])
  else:
    lis.append(lis2)
    lis2=[]

for q in range(3):
  if lis[q].count(True)==3:
    flag=1
if x[0][0]==True and x[1][1]==True and x[2][2]==True:
  flag=1
elif if x[0][2]==True and x[1][1]==True and x[2][0]==True:
if flag==1:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

x=[list(map(str,input().split())) for _ in range(3)]
N=int(input())
B=[input() for _ in range(N)]
flag=0
for i in range(3):
  for j in range(3):
    if x[i][j] in B:
      x[i][j]=True

for p in range(3):
  if x[p].count(True)==3:
    flag=1
lis=[]
lis2=[]
for a in range(3):
  for b in range(3):
    lis2.append(x[b][a])
  else:
    lis.append(lis2)
    lis2=[]

for q in range(3):
  if lis[q].count(True)==3:
    flag=1
if x[0][0]==True and x[1][1]==True and x[2][2]==True:
  flag=1
elif  x[0][2]==True and x[1][1]==True and x[2][0]==True:
  flag=1
if flag==1:
  print("Yes")
else:
  print("No")
k, x = map(int, input().split())
if 500*k >= X:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

k, x = map(int, input().split())
if 500*k >= x:
  print("Yes")
else:
  print("No")
A,B=map(int,iput(),split())
if A*N<B :
  print("A*N")
else:
    print("B")

### FIXED CODE ###

N,A,B=map(int,input().split())
if A*N<B :
  print(A*N)
else:
  print(B)
class unionFind:
    parent = []
    count = 0

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.nums = [1]*N

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            self.parent[x] = self.root(self.parent[x])
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y):
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            self.nums[y] += self.nums[x]
            self.nums[x] = 0
            return


N, M = map(int, input().split())
G = unionFind(N)
ans = [0]*M
ab = [tuple(map(int, input().split())) for i in range(M)]

tmp = (N * (N-1)) // 2
for i, x in enumerate(reversed(ab)):
    a, b = x[0], x[1]
    ans[M-1-i] = tmp
    if a == 0 or b == 0:
        continue
    a = G.root(a-1)
    b = G.root(b-1)
    if a == b:
        continue
    else:
        if a >= N or b >= N:
            continue
        tmp -= G.nums[a] * G.nums[b]
        G.parent[a] = b
        G.nums[b] += G.nums[a]
        G.nums[a] = 0


for i in range(M):
    print(ans[i])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)


class unionFind:
    parent = []
    nums = []

    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.nums = [1]*n

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            self.parent[x] = self.root(self.parent[x])
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y):
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            self.nums[y] += self.nums[x]
            self.nums[x] = 0
            return


N, M = map(int, input().split())
G = unionFind(N)
ans = [0]*M
ab = [tuple(map(int, input().split())) for i in range(M)]

tmp = (N * (N-1)) // 2
for i, x in enumerate(reversed(ab)):
    a, b = x[0], x[1]
    ans[M-1-i] = tmp
    a = G.root(a-1)
    b = G.root(b-1)
    if a == b:
        continue
    else:
        tmp -= G.nums[a] * G.nums[b]
        G.parent[a] = b
        G.nums[b] += G.nums[a]
        G.nums[a] = 0


for i in range(M):
    print(ans[i])
N = int(input())
A = list(map(int, input.split()))
 
def solve(N, A):
  if not A or A[0] != 1:
    print(-1)
    return
 
  prev = 1
  rt = 1
  for a in A[1:]:
    if a > prev * 2:
      print(-1)
      return
    rt += (prev * 2 - a) % (prev * 2)
    prev = a
 
  print(rt)
 
solve(N, A)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
  
def solve(N, A):
  
  if N == 0 and A[0] > 1 or N > 0 and A[0] > 0:
    print(-1)
    return

  total = sum(A[1:])
  #t = A[-1] + A[-2]
  par = 1 - A[0]
  rt = 1
  for i, a in enumerate(A[1:]):
    total -= a
    max_node = par * 2
    cur = max_node - a
    if cur < 0:
      print(-1)
      return
    cur = min(total, cur)
    #print(i+1, a, cur)
    rt += a
    if i + 1 < N:
      rt += cur
    par = cur  
   
  print(rt)
  
solve(N, A)
N = int(input())
A = input()
A = A.split()
A = [int(c) for c in A]
count = 0
for i in range(N):
    for j in range(N):
        if A[i] % A[j] == 0 and i != j:
            count += 1
            break
print(len(A)-count)

### FIXED CODE ###

a,b,c,d,e = map(int, input().split())
count = 1
for i in [a,b,c,d,e]:
    if i == 0:
        print(count)
    count += 1
bounds = [sum([26 ** i for i in range(n)]) for n in range(1, 11)]
lis = 'abcdefghijklmnopqrstuvwxyz'
N = int(input())
for b in reversed(bounds):
    if b <= N:
        break
N -= b 
length = bounds.index(b) + 1
s = ''
for i in range(length - 1, 0, -1):
    idx, N = divmod(N, 26**i)
    s = s + lis[idx]
print(s + lis[N])

### FIXED CODE ###

bounds = [sum([26 ** i for i in range(n)]) for n in range(1, 12)]
lis = 'abcdefghijklmnopqrstuvwxyz'
N = int(input())
for b in reversed(bounds):
    if b <= N:
        break
N -= b 
length = bounds.index(b) + 1
s = ''
for i in range(length - 1, 0, -1):
    idx, N = divmod(N, 26**i)
    s = s + lis[idx]
print(s + lis[N])
while true:
    H,W = [int(i) for i input().split("")]
    if H == W == 0:
        break
        print ("#"*(W)
        for h in range(W-2):
            print ("."*(W-2).join("#","#"))
        print ("#"*(W))
        print ()

### FIXED CODE ###

while True:
    h,w = tuple([int(x) for x in raw_input().split(" ")])
    if h==0 and w==0: break
 
    for ih in range(h):
        if ih==0 or ih==h-1 or w <= 2: print "#" * w
        else: print "#" + "." * (w-2) + "#"
 
    print ""
def lcs():
???x = raw_input()
  y = raw_input()
???x_len = len(x)
  y_len = len(y)
  z2 = [0 for i in range(y_len+1)]

???for j in range(x_len):
   z1 = z2 + []
   for k in range(y_len):
      if x[k] = y[k]:
         z2[k+1] = z2[k] + 1
      elif z2[j+1] < z2[j]:???
?????????   z2[j+1] = z2[j]

  return z2[-1]

num = input()
for l in range(num):
  print lcs()

### FIXED CODE ###

def lcs():
  x = raw_input()
  y = raw_input()
  x_len = len(x)
  y_len = len(y)
  z2 = [0 for i in range(y_len+1)]

  for i in range(x_len):
    z1 = z2 + []
    ele = x[i]
    for k in range(y_len):
      if ele == y[k]:
        z2[k+1] = z1[k] + 1
      elif z2[k+1] < z2[k]:
        z2[k+1] = z2[k]

  return z2[-1]

num = input()
for j in range(num):
  print lcs()
H,W,M=map(int, input().split())
sumh=[[_,0] for _ in range(H)]
sumw=[[_,0] for _ in range(W)]
s=[[0]*W for _ in range(H)]
for i in range(M):
  h,w=map(int, input().split())
  sumh[h-1][1]+=1
  sumw[w-1][1]+=1
  s[h-1][w-1]=1

maxh=maxw=0
qh=[]
qw=[]
for i in range(H):
  maxh=max(maxh, sumh[i][1])
for i in range(H):
  if maxh==sumh[i][1]:
    qh.append(i)

for i in range(W):
  maxw=max(maxw, sumw[i][1])
for i in range(W):
  if maxw==sumw[i][1]:
    qw.append(i)

for i in qh:
  for j in qw:
    if s[i][j]==0:
      print(maxh+maxw)
      exit()

print(maxh+maxw-1)

### FIXED CODE ###

H,W,M=map(int, input().split())
sumh=[0]*H
sumw=[0]*W
bomb=[]
for i in range(M):
  h,w=map(int, input().split())
  sumh[h-1]+=1
  sumw[w-1]+=1
  bomb.append((h,w))

maxh=max(sumh)
maxw=max(sumw)
ch=sumh.count(maxh)
cw=sumw.count(maxw)

cnt=0
for h,w in bomb:
  if sumh[h-1]==maxh and sumw[w-1]==maxw:
    cnt+=1

if cnt==ch*cw:
  print(maxh+maxw-1)
else:
  print(maxh+maxw)
A, B, C = map(int, input().split())

print("Yes" if C >= A and C =< B else "No")


### FIXED CODE ###


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

print("Yes" if C >= A and C <= B else "No")
#-*- coding: utf-8 -*-
import numpy as np

def knapsack2(items, W):
    N = len(items)
    C = np.zeros((N+1, W+1))
    for i in range(N+1)[1:]:
        v, w = items[i-1]
        for j in range(W+1)[1:]:
            if j < w:
                C[i][j] = C[i-1][j]
            else:
                C[i][j] = max(C[i-1][j-w]+v, C[i-1][j])

    return int(C[N][W])


def input_str(row):
    res = []
    for _ in xrange(row):
        res.append(raw_input().split())
    return res


N, W = [int(i) for i in raw_input().split()]
wvlist = input_str(N)
items = [(int(v), int(w)) for w, v in wvlist]
print knapsack2(items, W)

### FIXED CODE ###

import collections
import functools

class memoized(object):
    def __init__(self, func):
       self.func = func
       self.cache = {}

    def __call__(self, *args):
       if not isinstance(args, collections.Hashable):
          return self.func(*args)

       if args in self.cache:
          return self.cache[args]

       else:
          value = self.func(*args)
          self.cache[args] = value
          return value

    def __repr__(self):
       return self.func.__doc__

    def __get__(self, obj, objtype):
       return functools.partial(self.__call__, obj)

def knapsack(items, maxweight):
    @memoized
    def bestvalue(i, j):
        if i == 0: return 0
        value, weight = items[i - 1]
        if weight > j:
            return bestvalue(i - 1, j)
        else:
            return max(bestvalue(i - 1, j),
                       bestvalue(i - 1, j - weight) + value)

    j = maxweight
    result = []
    for i in xrange(len(items), 0, -1):
        if bestvalue(i, j) != bestvalue(i - 1, j):
            result.append(items[i - 1])
            j -= items[i - 1][1]
    result.reverse()
    return bestvalue(len(items), maxweight), result

def input_str(row):
    res = []
    for _ in range(row):
        res.append(raw_input().split())
    return res

N, W = [int(i) for i in raw_input().split()]
wvlist = input_str(N)
items = [(int(v), int(w)) for w, v in wvlist]
print knapsack(items, W)[0]
a,b,c,d = input().split()
pirnt("Yes") if a==b==c or b==c==d else print("No")

### FIXED CODE ###

abcd = list(input())
print("Yes") if abcd[2]==abcd[3]==abcd[1] or abcd[0]==abcd[1]==abcd[2] else print("No")
import numpy as np

N = int(input())
A = np.array(map(int, input().split()))
if len(A[A<0])%2 == 0:
    ans = sum(abs(A))
else:
    A = sorted(abs(A))
    ans = sum(A[1:] - A[0])
print(ans)

### FIXED CODE ###

n = int(input())
*a, = map(int, input().split())
*a_abs, = map(abs, a)
if len([i for i in a if i<0])%2==0:
    print(sum(a_abs))
else:
    print(sum(a_abs)-2*min(a_abs))
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)
"""
#memo化再帰
memo = [-1]*(110000)
def rec(n):
    if n==0:
        return 0
    if memo[n] != -1:
        return memo[n]
    res = n
    pow6,pow9 = 1,1
    while pow6 <=n:
        res = min(res,rec(n-pow6)+1)
        pow6 *= 6
    while pow9 <= n:
        res = min(res,rec(n-pow9)+1)
        pow9 *= 9
    memo[n] = res
    return memo[n]
N = int(input())
print(rec(N))
"""
"""
#もらうDP
N = int(input())
dp=[inf]*110000
dp[0] = 0
for n in range(1,N+1):
    pow6,pow9 = 1,1
    while pow6<=n:
        dp[n] = min(dp[n],dp[n-pow6]+1)
        pow6 *= 6
    while pow9 <= n:
        dp[n] = min(dp[n],dp[n-pow9]+1)
        pow9 *= 9
print(dp[N])
"""
#配るDP
N = int(input())
dp=[inf]*(110000)
dp[0]=0
for n in range(N):
    pow6,pow9 = 1,1
    while pow6<=n:
        dp[n+po6] = min(dp[n+pow6],dp[n]+1)
        pow6 *= 6
    while pow9 <=n:
        dp[n+pow9] = min(dp[n+pow9],dp[n]+1)
        pow9 *= 9
print(dp[N])

### FIXED CODE ###

N = int(input())
l = [1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
dp = [N]*(N+1)
dp[0]=0

for i in range(1,N+1):
    for j in l:
        if i-j >= 0:
            dp[i] = min(dp[i],dp[i-j]+1)
print(dp[N])
import sys
read = sys.stdin.read


n, m, *alst = list(map(int, read().split()))
mm = 2 * m


def min_factor(n):
    sieve = list(range(n + 1))
    sieve[2::2] = [2] * (n // 2)
    for i in range(3, int(n ** 0.5) + 2, 2):
        if sieve[i] == i:
            sieve[i * i::2 * i] = [i] * ((n - i * i) // (2 * i) + 1)
    return sieve


# 素因数分解
def prime_factorize(n):
    a = {}
    while n != 1:
        b = table[n]
        if b in a:
            a[b] += 1
        else:
            a[b] = 1
        n //= b
    return a

table = min_factor(max(alst))

dic = {}
prep = -1
for i in alst:
    for key, value in prime_factorize(i).items():
        if key == 2:
            if prep == -1:
                prep = value
            elif value != prep:
                print(0)
                quit()
        if key in dic:
            dic[key] = max(dic[key], value)
        else:
            dic[key] = value

lcm = 1
for i, j in dic.items():
    lcm *= pow(i, j)
    if lcm > mm:
        print(0)
        quit()
res = mm // lcm
print(res // 2 + res % 2)

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline
from fractions import gcd
from functools import reduce

n,m = map(int,readline().split())
alst = list(map(int,readline().split()))

def lcm(x,y):
  g=gcd(x,y)
  if x//g %2==0 or y//g%2==0:
    return 0
  return x*y//g
g=reduce(lcm,alst)
if g==0:
  print(0)
  quit()
else:
  res=(2*m//g)
  print(res//2+res%2)