Harryxun/stf_run huggingface dataset:
n,m,q = map(int,input().split())
List = [list(map(int, input().split())) for i in range(q)]

p_max = 0
point =0
A = [1]*n
E = [m]*n

while A != E :

    #得点計算
    for j in range(q):
        if A[List[j][1]-1] - A[List[j][0]-1] == List[j][2]:
            point += List[j][3]


    #最大値の更新
    if p_max < point:
        p_max = point
    point = 0


    #Aの更新
    for i in reversed(range(0,n)):
        if A[i] < m:
            A[i] = A[i] + 1
            if i !=n-1:
                for k in range(i+1,n):
                    A[k] = A[i]
            break

print(p_max)



### FIXED CODE ###

k = int(input())
a,b = map(int,input().split())
if a % k == 0:
    print('OK')
elif a + k - a%k <= b:
    print('OK')
else:
    print('NG')
import math

n = int(input())
s = input()

num = []
for i in range(n-2):
  for j in range(i + 1, n-1):
    for k in range(j + 1, n):
      tmp = s[i] + s[j] + s[k]
      if tmp not in num:
      	num.append(tmp)
print(len(num))

### FIXED CODE ###

m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1 ==1 and d1 == 31:
  print('1')
elif m1==2 and d1 == 28:
  print('1')
elif m1==3 and d1 == 31:
  print('1')
elif m1==4 and d1 == 30:
  print('1')
elif m1==5 and d1 == 31:
  print('1')
elif m1==6 and d1 == 30:
  print('1')
elif m1==7 and d1 == 31:
  print('1')
elif m1==8 and d1 == 31:
  print('1')
elif m1==9 and d1 == 30:
  print('1')
elif m1==10 and d1 == 31:
  print('1')
elif m1==11 and d1 == 30:
  print('1')
else:
  print('0')
a=int(input())
print(8) if 400<=a<=599
print(7) if 600<=a<=799
print(6) if 800<=a<=999
print(5) if 1000<=a<=1199
print(4) if 1200<=a<=1399
print(3) if 1400<=a<=1599
print(2) if 1600<=a<=1799
print(1) if 1800<=a<=1999

### FIXED CODE ###

a=int(input())
if 400<=a<=599:
  print(8) 
if 600<=a<=799:
  print(7)
if 800<=a<=999:
  print(6)
if 1000<=a<=1199:
  print(5)
if 1200<=a<=1399:
  print(4)
if 1400<=a<=1599:
  print(3)
if 1600<=a<=1799:
  print(2)
if 1800<=a<=1999:
  print(1)
k = int(input())

sum = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1,k+1):
            sum += gcd(gcd(a,b), c)

print(sum)

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def resolve():
    k = int(input())

    tmp = []
    for a in range(1, k+1):
        for b in range(1, k+1):
            tmp.append(gcd(a,b))

    ans = 0
    for c in range(1,k+1):
        for i in tmp:
            ans += gcd(i, c)
    
    print(ans)
    
resolve()
import math

def sieve_of_erastosthenes(num):
    print(num)
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num+1)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

N = int(input())
A = [int(i) for i in input().split()]
ans = math.gcd(A[0], A[1])
tmp = math.gcd(A[0], A[1])
for i in range(2, N):
    ans = math.gcd(ans, A[i])
if ans > 1:
    print('not coprime')
    exit()
maxA = max(A)
l = sieve_of_erastosthenes(maxA)
B = [False for i in range(maxA+1)]
for i in range(N):
    B[A[i]] = True
flag = False
for i in range(len(l)):
    # 素数の時
    if l[i]:
        tmp = i
        counter = 0
        while True:

            if B[tmp]:
                counter += 1
            tmp += i
            if tmp > maxA:
                break
        if counter > 1:
            flag = True
            break


if flag:
    print('setwise coprime')
else:
    print('pairwise coprime')

### FIXED CODE ###

import math

def sieve_of_erastosthenes(num):
    is_prime = [True for i in range(num+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(num**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, num + 1, i):
            is_prime[j] = False
    return [i for i in range(num + 1) if is_prime[i]]

N = int(input())
A = [int(i) for i in input().split()]
ans = math.gcd(A[0], A[1])
tmp = math.gcd(A[0], A[1])
for i in range(2, N):
    ans = math.gcd(ans, A[i])
if ans > 1:
    print('not coprime')
    exit()
maxA = max(A)
l = sieve_of_erastosthenes(maxA)
B = [False for i in range(maxA+1)]
for i in range(N):
    B[A[i]] = True
flag = False
for each in l:
    tmp = each
    counter = 0
    while True:

        if B[tmp]:
            counter += 1
        tmp += each
        if tmp > maxA:
            break
    if counter > 1:
        flag = True
        break


if flag:
    print('setwise coprime')
else:
    print('pairwise coprime')
a,b = map(int,input().split())
ans = round((a-1)/(b-1))  
print(ans)


### FIXED CODE ###

a,b = map(int,input().split())
outlet = 1
ans = 0
while outlet < b:
  outlet -= 1
  outlet += a
  ans += 1
  
print(ans)
x = int(input())
power5 = [(i ** 5) for i in range(100)]
for i in range(100):
  for j in range(100):
    if power[i] - power5[j] == x:
      print(i, j)
      exit()
for i in range(100):
  for j in range(100):
    if power5[i] + power5[j] == x:
      print(i, -j)
      exit()
for i in range(100):
  for j in range(100):
    if -power5[i] + power5[j] == x:
      print(-i, -j)
      exit()

### FIXED CODE ###

x = int(input())
power5 = [(i ** 5) for i in range(1000)]
for i in range(1000):
  for j in range(1000):
    if power5[i] - power5[j] == x:
      print(i, j)
      exit()
for i in range(1000):
  for j in range(1000):
    if power5[i] + power5[j] == x:
      print(i, -j)
      exit()
for i in range(1000):
  for j in range(1000):
    if -power5[i] + power5[j] == x:
      print(-i, -j)
      exit()
n=int(input())
A = list(map(int, input().split()))
result=1
limit=10**18
flg0=0
for i in range(n):
  if A[i] == 0:
    flg0=1
    print('0')
for i in range(n):
  if flg0 == 1:
    break
  result *= A[i]
  if result > limit:
    print('-1')
    flg=1
    break
if flg != 1 and flg0 != 1:
  print(result)

### FIXED CODE ###

n=int(input())
A = list(map(int, input().split()))
result=1
limit=10**18
flg0=0
flg=0
for i in range(n):
  if A[i] == 0:
    flg0=1
    print('0')
for i in range(n):
  if flg0 == 1:
    break
  result *= A[i]
  if result > limit:
    print('-1')
    flg=1
    break
if flg != 1 and flg0 != 1:
  print(result)
r,g,b=map(int,input().split())

x = 10*g + b

if x % 4 == 0:
  print("YES") 
  else 
  print("NO")

### FIXED CODE ###

r,g,b=map(int,input().split())

x = 10*g + b

if x % 4 == 0:
  print("YES") 
else:
  print("NO")
import math
s = input()
k = int(input())
s = list(s)
ind = 0
anss = [[] for i in range(100)]
for i in range(len(s)-1):
  anss[ind].append(s[i])
  if s[i] != s[i+1] and i != len(s)-2:
    ind += 1
  elif i == len(s)-2:
    ind += 1
#print(ind)
#print(anss)
for i in range(100-ind):
  anss.remove([])
#print(anss)
if len(anss) == 0:
  anss.append([])
if s[0] == s[len(s)-1] and s[len(s)-2] == s[len(s)-1] and len(anss)>1 and k > 1:
  anss[0] += anss[len(anss)-1]
  anss.remove(anss[len(anss)-1])
  anss[0].append(s[len(s)-1])
elif s[0] == s[len(s)-1] and k > 1:
  anss[0].append(s[len(s)-1])
elif s[len(s)-2] == s[len(s)-1] and k > 1:
  anss[len(anss)-1].append(s[len(s)-1])
else:
  anss.append([s[len(s)-1]])
pans = 0
#print(anss)
for i in anss:
  pans += math.floor(len(i) / 2)
if len(anss) == 1 and len(anss[0]) % 2 == 1:
  print(math.floor(len(list(s*k))/2))
else:
  print(pans*k)

### FIXED CODE ###

s = input()
k = int(input())
s = list(s)
ind = 0
anss = [[] for i in range(100)]
for i in range(len(s)-1):
  anss[ind].append(s[i])
  if s[i] != s[i+1] and i != len(s)-2:
    ind += 1
  elif i == len(s)-2:
    ind += 1
#print(ind)
#print(anss)
for i in range(100-ind):
  anss.remove([])
#print(anss)
f = 0
pf = 0
if len(anss) == 0:
  anss.append([])
if s[0] == s[len(s)-1] and s[len(s)-2] == s[len(s)-1] and len(anss)>1 and k > 1:
  if len(anss[0]) % 2 == 1:
    pf = 1
  anss[0] += anss[len(anss)-1]
  anss.remove(anss[len(anss)-1])
  anss[0].append(s[len(s)-1])
  if len(anss[0]) % 2 == 0 and pf == 1 and len(anss) > 1:
    f = 1
elif s[0] == s[len(s)-1] and k > 1:
  if len(anss[0]) % 2 == 1:
    pf = 1
  anss[0].append(s[len(s)-1])
  if len(anss[0]) % 2 == 0 and pf == 1 and len(anss) > 1:
    #print(len(anss[0]),pf)
    f = 1
elif s[len(s)-2] == s[len(s)-1] and k > 1:
  anss[len(anss)-1].append(s[len(s)-1])
else:
  anss.append([s[len(s)-1]])
pans = 0
#print(anss)
for i in anss:
  pans += len(i) // 2
#print(f)
if len(anss) == 1 and len(anss[0]) % 2 == 1:
  print((len(s)*k)//2)
elif f == 1:
  print(pans*k-1)
else:
  print(pans*k)
import math
A,B=map(int, input().split())
 
print(math.ceil(B/A)

### FIXED CODE ###

import math
A,B=map(int, input().split())

print(1+math.ceil((B-A)/(A-1)))
n,k=map(int,input().split())
s=input()
print(s[:k-1]+s[k-1].lower()+s[k:])

### FIXED CODE ###

s=input()
l=int(s[:2])
r=int(s[2:])
if 1<=l<=12 and 1<=r<=12:
    print("AMBIGUOUS")
elif 1<=l<=12:
    print("MMYY")
elif 1<=r<=12:
    print("YYMM")
else:
    print("NA")
s = input()

ans = 0

i = 0
while i < len(s):
    if s[i] == "A":
        num = 1
        while s[i] != "Z" and i < len(s):
            i += 1
            num += 1
        ans = max(ans, num)
    i += 1

print(ans)

### FIXED CODE ###

s = input()

a = 0
for i in range(len(s)):
    if s[i] == "A":
        a = i
        break

b = 0
for i in range(len(s)):
    if s[i] == "Z":
        b = i

print(b-a+1)
import sys
sys.setrecursionlimit = 2 * 10 ** 6

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

connect = [set() for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    connect[a-1].add(b-1)
    connect[b-1].add(a-1)

counter = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    counter[p-1] += x

ans = [0] * n
def dfs(me, parent, cum):
    cum += counter[me]
    ans[me] = cum
    for child in connect[me]:
        if child != parent:
            dfs(child, me, cum)

dfs(0, -1, 0)

print(*ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

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

connect = [set() for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    connect[a-1].add(b-1)
    connect[b-1].add(a-1)

counter = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    counter[p-1] += x

ans = [0] * n
def dfs(me, parent, cum):
    cum += counter[me]
    ans[me] = cum
    for child in connect[me]:
        if child != parent:
            dfs(child, me, cum)

dfs(0, -1, 0)

print(*ans)
A, B, C = input().split()

if A(len(A)-1) == B[0] and B(len(B)-1) == C[0]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

A, B, C = input().split()
 
if A[len(A)-1] == B[0] and B[len(B)-1] == C[0]:
  print("YES")
else:
  print("NO")
T = input()
X = input()

print(T / X)

### FIXED CODE ###

T,X =map(int, input().split())
print(float(T)/float(X))
import sys
input = sys.stdin.readline

N,M = list(map(int,input().split()))
A = [int(input()) for _ in range(M)]

a2 = 1
a1 = 0 if 1 in A else 1 
for i in range(2,N+1):
    a = 0 if a in A else (a2+a1)%1000000007
    a2 = a1
    a1 = a
print(1 if N == 1 else a%1000000007)


### FIXED CODE ###

n,m = map(int,input().split())
a = [ int(input()) for _ in range(m)]
M=10**9+7
lis = [1] + [0]*n

for i in a:
  lis[i]=-1
lis[1] += 1
for i in range(n-1):
  if lis[i+2]<0:
    lis[i+2]= 0
  else:
    lis[i+2] = (lis[i+1] + lis[i])%M
print(lis[n])
a,b,c,d = map(int, input().split())

while a>=0 and c>=0:
  c=c-b
  if c<=0:
    print("Yes")
    exit("0")
  a=a-d
  if a<=0:
    print("No")
    exit("0")

### FIXED CODE ###

import sys
a,b,c,d = map(int, input().split())

while a>=0 and c>=0:
  c=c-b
  if c<=0:
    print("Yes")
    sys.exit(0)
  a=a-d
  if a<=0:
    print("No")
    sys.exit(0)
l = input().split()


N = int(l[0])
M = int(l[1])
X = int(l[2])
Y = int(l[3])

"""
if X < -100:
    X = -100
elif X > 100:
    X = 100

if Y < -100:
    Y = -100
elif Y > 100:
    Y = 100
"""

lx = input().split()
ly = input().split()

lx = [int(z) for z in lx]
ly = [int(z) for z in ly]

lx = sorted(lx)


ly = sorted(ly)

flag = True



if int(ly[0]) - int(lx[N-1]) >= 1:
    for z in range(int(lx[N-1]) + 1, int(ly[0]) + 1):
        print(z)
        if z > X and z =< Y:
            flag = True
            break

else:
    flag = False

if flag:
    print("No war")
else:
    print("War")


### FIXED CODE ###

l = input().split()


N = int(l[0])
M = int(l[1])
X = int(l[2])
Y = int(l[3])

"""
if X < -100:
    X = -100
elif X > 100:
    X = 100

if Y < -100:
    Y = -100
elif Y > 100:
    Y = 100
"""

lx = input().split()
ly = input().split()

lx = [int(z) for z in lx]
ly = [int(z) for z in ly]

lx = sorted(lx)


ly = sorted(ly)

flag = True


if int(ly[0]) - int(lx[N-1]) >= 1:
    for z in range(int(lx[N-1]) + 1, int(ly[0]) + 1):

        if z > X and z <= Y:
            flag = False
            break


if flag:
    print("War")
else:
    print("No War")
import sys
import numpy as np
read = sys.stdin.read

N, W, *wv = map(int, read().split())
dp = np.zeros((W + 1, N + 1), np.int64)
idx = 1

for w, v in zip(*[iter(wv)] * 2):
    if w > W:
        continue

    dp[:, idx] = dp[:, idx - 1]
    dp[w:, idx] = np.maximum(dp[w:, idx], dp[:W - w + 1, idx] + v)
    idx += 1

print(dp[-1, -1])

### FIXED CODE ###

import sys
from itertools import accumulate, product
from operator import itemgetter
read = sys.stdin.read

N, W, *wv = map(int, read().split())
w1 = wv[0]
V = [[0] for _ in range(4)]

for w, v in sorted(zip(*[iter(wv)] * 2), key=itemgetter(1), reverse=True):
    V[w - w1].append(v)


V = list(map(list, map(accumulate, V)))
n = [len(V[i]) for i in range(4)]
answer = 0
for a, b, c, d in product(range(n[0]), range(n[1]), range(n[2]), range(n[3])):
    if b + c * 2 + d * 3 + (a + b + c + d) * w1 > W:
        continue

    v = V[0][a] + V[1][b] + V[2][c] + V[3][d]
    if v > answer:
        answer = v

print(answer)
N = int(input())
ld = [0] * N
for i in range(N):
    d = int(input())
    ld[i] = d

bucket = [0] * (N + 5)
for j in range(N):
    bucket[ld[j]] += 1

tower = 0

for k in range(1, N+1):
    if bucket[k] > 0:
        tower += 1

print(tower)

### FIXED CODE ###

N = int(input())
ld = [0] * N
for i in range(N):
    d = int(input())
    ld[i] = d

t = set(ld)

print(len(t))
import sys

if __name__ == "__main__":
  args = sys.argv

  num = args[0]
  slimes = args[1]

  tmp = []
  for i in range(0,len(smiles)):
    if len(tmp): 
      if slimes[i] == slimes[i+1] and slimes[i] != tmp[-1]:
          tmp.append(slimes[i])
    else:
      if slimes[i] == slimes[i+1]:
          tmp.append(slimes[i])

  print(len(tmp))    


### FIXED CODE ###

if __name__ == "__main__":
  num = input()
  slimes = input()

  tmp = []
  for i in range(0,len(slimes)):
    if len(tmp):
      if slimes[i] != tmp[-1]:
          tmp.append(slimes[i])
    else:
      tmp.append(slimes[i])
  print(len(tmp))
#n = a の本:m = b の本
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
p = 0
z = 0
i = 0
j = 0

while p < k:
    if a[i] < b[j]:
        p += a[i]
        z += 1
        i += 1
    elif a[i] > b[j]:
        p += b[j]
        z += 1
        j += 1
    else:
        if a[i+1] < b[j+1]:
            p += a[i]
            z += 1
            i += 1
        elif:
            p += b[j]
            z += 1
            j += 1

print(z)

### FIXED CODE ###

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [0]*(n+1)
d = [0]*(m+1)
for i in range(n):
    c[i+1] = a[i]+c[i]
for i in range(m):
    d[i+1] = b[i]+d[i]
for i in range(m+1)[::-1]:
    if d[i] <= k:
        x = i
        break
ans = x
for i in range(1,n+1):
    while c[i] + d[x] > k:
        if x >= 1:
            x -= 1
        else:
            break
    if c[i] + d[x] <= k:
        ans = max(ans,i+x)
print(ans)
n, k = map(int, input().split())
lst = list(map(int, input().split()))

visited = [0] * n
flg = 1
i = 0
now = 0
while flg:
    if visited[now] == 0:
        i += 1
        visited[now] = i
        now = lst[now] 
    else:
        break
print(i, now, visited)

k_bk = k - visited[now]
k_bk =  k_bk // i

lft = (k - visited[now]) - i* k_bk

if lft ==0:
    print(now+1)
else:
    for _ in range(lft):
        now = lst[now]
    print(now+1)

### FIXED CODE ###

n, k = map(int, input().split())
lst = list(map(int, (input().split())))
lst = [_ - 1 for _ in lst]

visited = [0] * n
i = 0
now = 0
while k > i:
    if visited[now] == 0:
        i += 1
        visited[now] = i
        now = lst[now] 
    else:
        break

lp = (i + 1) - visited[now]
st = i - lp
k_bk = k - st
k_bk = k_bk // lp
lft = k - (k_bk * lp + st)

if lft == 0:
    print(now+1)
else:
    for _ in range(lft):
        now = lst[now]
    print(now+1)
import math
n = int(input())
enemy = list(set(map(int,input().split())))
if len(enemy)==1:
    print(enemy[0])
else:
    enemy.sort()
    min_n = 10**10
    for i in range(len(enemy)-1):
        min_n = min(min_n,math.gcd(enemy[i],enemy[i+1]))
    print(min_n)

### FIXED CODE ###

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

n = int(input())
enemy = list(set(map(int,input().split())))
if len(enemy)==1:
    print(enemy[0])
else:
    enemy.sort()
    min_n = 10**10
    for i in range(len(enemy)-1):
        min_n = min(min_n,gcd(enemy[i],enemy[i+1]))
    print(min_n)
N = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(max(A)+1)]
for i in range(N):
  L[A[i]] += 1
mL = []
for j in range(len(L)-2):
  mL.append(L[j] + L[j+1] + L[j+2])

print(max(mL))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(max(A)+1)]
for i in range(N):
  L[A[i]] += 1
mL = []
if len(L) >= 3:
  for j in range(len(L)-2):
    mL.append(L[j] + L[j+1] + L[j+2])
else:
  for j in range(3-len(L)):
    L.append(0)
  mL = [L[0]+L[1]+L[2]]
print(max(mL))
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(l[K])

### FIXED CODE ###

def main():
  l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
  K = int(input())

  print(l[K-1])

if __name__ == "__main__":
    main()
import sys
s = input()

if len(s) == 2 and s[0] == s[1]:
    print("0, 1")
    sys.exit(0)

for i in range(len(s)-2):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        sys.exit(0)
    if s[i] == s[i+2]:
        print(i+1, i+3)
        sys.exit(0)
if s[i+1] == s[i+2]:
    print(i+2, i+3)
    sys.exit(0)
print("-1 -1")
sys.exit(0)

### FIXED CODE ###

import sys
s = input()

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        sys.exit(0)
    if i < len(s)-2:
        if s[i] == s[i+2]:
            print(i+1, i+3)
            sys.exit(0)
print("-1 -1")
sys.exit(0)
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
even = Counter(v[::2]).most_common(2)
odd = Counter(n[1::2]).most_common(2)
if even[0][0] != odd[0][0]:
    ans =  n - even[0][1] - odd[0][1]
else:
    if len(even) == 1:
        ans = n//2:
    else:
        ans =  n - max(even[0][1] + odd[1][1],even[1][1],odd[0][1])
print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
v = list(map(int,input().split()))
even = Counter(v[::2]).most_common(2)
odd = Counter(v[1::2]).most_common(2)

if even[0][0] != odd[0][0]:
    ans =  n - even[0][1] - odd[0][1]
else:
    if len(even) == 1 or len(odd)==1:#単一の要素からなる場合ex.)1111
        ans = n//2
    else:
        ans =  n - max(even[0][1] + odd[1][1],even[1][1]+odd[0][1])
print(ans)
#!/usr/bin/env python3
import sys
import statistics
import collections

def solve(n: int, v: "List[int]"):
    half_length = len(v) // 2
    O = [v[i] for i in range(1, n, 2)]
    E = [v[i] for i in range(0, n, 2)]

    co = list(collections.Counter(O).most_common())
    ce = list(collections.Counter(E).most_common())
    o1 = co[0][0]
    e1 = ce[0][0]

    O_ = list(filter(lambda o: o != o1, O))
    E_ = list(filter(lambda e: e != e1, E))
    num_o_1 = len(O_) 
    num_e_1 = len(E_)

    num = 0
    if e1 != o1:
        num = num_o_1 + num_e_1
    else:
        if len(co) == 1 and len(ce) == 1:
            num = half_length
        elif len(co) == 1:
            pass
            e2 = ce[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num = num_o_1 + num_e_2
        elif len(ce) == 1:
            pass
            o2 = co[1][0]
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = num_o_2 + num_e_1
        else:
            pass
            e2 = ce[1][0]
            o2 = co[1][0]
            num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)
    print(num)
    return

def len2(l):
    n = 0
    for i in l:
        n += 1
    return n

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, v)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import statistics
import collections

def solve(n: int, v: "List[int]"):
    half_length = len(v) // 2
    O = [v[i] for i in range(1, n, 2)]
    E = [v[i] for i in range(0, n, 2)]

    co = list(collections.Counter(O).most_common())
    ce = list(collections.Counter(E).most_common())
    o1 = co[0][0]
    e1 = ce[0][0]

    O_ = list(filter(lambda o: o != o1, O))
    E_ = list(filter(lambda e: e != e1, E))
    num_o_1 = len(O_) 
    num_e_1 = len(E_)

    num = 0
    if e1 != o1:
        num = num_o_1 + num_e_1
    else:
        if len(co) == 1 and len(ce) == 1:
            num = half_length
        elif len(co) == 1:
            e2 = ce[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num = num_o_1 + num_e_2
        elif len(ce) == 1:
            o2 = co[1][0]
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = num_o_2 + num_e_1
        else:
            e2 = ce[1][0]
            o2 = co[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)
    print(num)
    return

def len2(l):
    n = 0
    for i in l:
        n += 1
    return n

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, v)

if __name__ == '__main__':
    main()
from fractions import gcd
from functools import reduce

N, M = map(int,input().split())
A = set(list(map(int,input().split())))

for i, a in enumerate(A):
    if i == 0:
        lcmA = a
    else:
        lcmA = int(a * lcmA / gcd(a, lcmA))

if M < lcmA//2:
    print(0)
else:
    minA = min(A)
    ans = 0
    for i in range(lcmA//2, M+1, lcmA):
        if i % 2 == 1:
            ans += 1
        elif minA < i:
            ans += 1

    print(ans)

### FIXED CODE ###

import fractions
import functools

def lcm(n1, n2):
    return n1 * n2 // fractions.gcd(n1, n2)

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] //= 2

lcmA = functools.reduce(lcm, A)
gcdA = functools.reduce(fractions.gcd, A)
if (lcmA // gcdA) % 2 == 0:
    print(0)
else:
    print((M // lcmA + 1) // 2)