peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
########################################################
F=[1]*(10**6+1)
for i in range(2,10**6+1):
    for j in range(i,10**6+1,i):
        F[j]+=1
ans=0
n=1000000
for c in range(1,n):
    ans+=F[n-c]
print(ans)
# Judge status: Wrong Answer
A, B, C = list(map(int, input().split(" ")))

print(int(str(B)+str(C)) + A)
# Judge status: Accepted
a,b,m = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
can = [min(x)+min(y)]
for _ in range(m):
  i,j,c = map(int,input().split())
  i -= 1
  j -= 1
  can.append(x[i]+y[j]-c)
print(min(can))
# Judge status: Wrong Answer


def main():
    N = int(input())
    res = 1
    for i in range(1, N+1):
        res = res * i
    print(res%100000007)




if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
mn=0
n=int(input())
li=list(map(int,input().split()))

for i in range(n):
  res=abs(sum(li[:i])-sum(li[i:]))
  if res<mn:
    mn=res
print(mn)
# Judge status: Accepted
N = int(input())

A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    a,b = map(int,input().split())
    A[i] = a
    B[i] = b
A.sort()
B.sort()
if N%2:
    print(B[N//2]-A[N//2]+1)
else:
    print(B[N//2]+B[(N-1)//2]-A[N//2]-A[(N-1)//2]+1)
# Judge status: Wrong Answer
N = int(input())
A_leaf = list(map(int, input().split()))
if N == 0 and A_leaf[0] == 0:
    print(-1)
    exit()
s = [0]*(N+2)
for i in range(1, N+2):
    s[i] = s[i-1] + A_leaf[i-1]
node = [1]*(N+1)
for i in range(1, N+1):
    node[i] = min((node[i-1] - A_leaf[i-1])*2, s[N+1]-s[i])
    if node[i] <= 0:
        print(-1)
        exit()
else:
    print(sum(node))
# Judge status: Accepted
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N, *A = map(int, open(0))
    ans = 0
    i = 0
    prev = 0
    while i < N:
        if A[i] == 0:
            prev = 0
        else:
            ans += (A[i]+prev)//2
            prev = (A[i]+prev)%2
        # print(A[i],prev,ans)
        i += 1
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
from functools import reduce
from fractions import gcd

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

X,Y = map(int,input().split())
if lcm(X,Y)//X > 10**18 or X == Y:
  print(-1)
else:
  print(lcm(X,Y)//X)
# Judge status: Accepted
n = int(input())

mp = {}
for f in range(2, 1000000):
    while n % f == 0:
        mp[f] = 1 if f not in mp else mp[f] + 1
        n //= f
if n > 1:
    mp[n] = 1

def fn(x):
    for i in range(2, 100):
        sm = i*(i+1)//2
        if x < sm:
            return i - 1

#print(mp)
#print({p:fn(mp[p]) for p in mp})
print(sum(fn(mp[p]) for p in mp))
# Judge status: Wrong Answer
S = [str(x) for x in input()]
cnt = 0
 
for i in range(0,2):
    if S[i] == S[i+1]:
        cnt += 1
 
if cnt >= 1:
    print("Bad")
else:
    print("Good")
# Judge status: Accepted
n = int(input())
li_a = list(map(int, input().split()))

flg = False
nextval = 1
br = 0
for idx, a in enumerate(li_a):
    if a == nextval:
        nextval += 1
        flg = True
    else:
        br += 1
if flg:
    print(br)
else:
    print('-1')
# Judge status: Accepted
s= list(input())
a=min([i for i, x in enumerate(s) if x == 'A'])
z =max([i for i, x in enumerate(s) if x == 'Z'])
print(z+1-a)
# Judge status: Accepted
s = int(input())
c = set([s])

i = 1
while 1:

  if s % 2 == 0:
    s //= 2
  else:
    s = s*3+1

  i += 1

  if s in c:
    break
  else:
    c.add(s)

print(i)
# Judge status: Accepted
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    l.append([s, p])
l_s = sorted(l, key = lambda l:(l[0], -l[1]))
for i in l_s:
    print(l.index(i) + 1)
# Judge status: Accepted
a, b = list(map(int, input().split()))
if a % 3 == 0 or b % 3 == 0 or (a + b ) % 3 == 0:
  print('Possible')
else:
  print('Impossible')
# Judge status: Accepted
def resolve():
    N, M = list(map(int, input().split()))
    interval = []
    l, r = 0, 10**5
    for i in range(M):
        L, R = list(map(int, input().split()))
        l = max(l, L)
        r = min(r, R)

    interval = set(list(range(l, r + 1)))
    interval = interval & set(range(1, N + 1))

    print(len(interval))

    return


resolve()
# Judge status: Accepted
sx,sy,tx,ty = map(int,input().split())
y_diff = ty-sy
x_diff = tx-sx
ans = ""
for i in range(y_diff):
    ans += "U"
for j in range(x_diff):
    ans += "R"
for k in range(y_diff):
    ans += "D"
for l in range(x_diff):
    ans += "L"
ans += "L"
for s in range(y_diff+1):
    ans += "U"
for t in range(x_diff+1):
    ans += "R"
ans += "DR"
for p in range(y_diff+1):
    ans += "D"
for q in range(x_diff+1):
    ans += "L"
ans+="U"
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
b = 0
w = s.count(".")
l = [w]
for i in range(1, n + 1):
    if s[i - 1] == "#":
        b += 1
    if s[i - 1] == ".":
        w -= 1
    l.append(b + w)
    # print(l)
print(min(l))
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

s, w = map(int, input().split())

if w >= s:
    print("unsafe")
else:
    print("safe")
# Judge status: Accepted
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
from collections import deque

n, m = map(int, input().split())
ans = []
front = deque([item for item in range(1, (n+1) // 2 + 1)])
back = deque([item for item in range(n // 2 + 2, n + 1)])
while len(front) > 1:
    l = front.popleft(); r = front.pop()
    ans.append((l, r))
while len(back) > 1:
    l = back.popleft(); r = back.pop()
    ans.append((l, r))
for i in range(m):
    print(*ans[i])
# Judge status: Accepted
n = int(input())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))

k = sum(bl) - sum(al)

def ceil(a, b):
   return a // b + (a % b > 0)

up = 0
down = 0
for a, b in zip(al,bl):
    if b - a > 0:
        up += ceil(b-a, 2)
        down = (b-a) % 2
    else:
        down = (a-b)

if k >= up and k >= down:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

lim = 0
ans = 0
wait = 0
for t in T:
    if t > lim:
        if wait:
            ans += 1
        lim = t + K
        wait = 1
    else:
        wait += 1
        if wait == C:
            ans += 1
            wait = 0
            lim = 0
if wait:
    ans += 1

print(ans)
# Judge status: Accepted
C = []
for i in range(3):
  C.append([int(i) for i in input().split()])

ans = "Yes"

A = [0] * 3
B = C[0]

A[1] = C[1][0] - B[0]
A[2] = C[2][0] - B[0]

for i in range(3):
  for j in range(3):
    if C[i][j] != A[i] + B[j]:
      ans = "No"
      break

print(ans)
# Judge status: Wrong Answer
import re
import sys

s = input()
t = input()

tLen = len(t)

"""
sの中の?を.に置換する
"""
s = s.replace("?",".")
sLen = len(s)
for i in range(tLen,sLen+1):
  #[-i:(-i+tLen)]の区間の文字列が、tにマッチするかを調べる。マッチするなら置換する。
  test = s[sLen-i:sLen-i+tLen] 
  pattern = re.compile(r"%s" % test)
  if pattern.search(t):
    s = s[:sLen-i]+t+s[sLen-i+tLen+1:]
    s = s.replace(".","a")
    print(s)
    sys.exit()

print("UNRESTORABLE")
# Judge status: Accepted
a=[int(i) for i in input().split()]
print("Yes" if sum(a)==2*max(a) else "No")
# Judge status: Accepted
word=input()
if word[2]==word[3] and word[4]==word[5]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
from time import time
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
L = [-1 for i in range(N)]

visited = []
now = 0
loopstarts = None
looplength = None
t0 = time()

for i in range(N):
    if L[now] != -1:
        break
    else:
        L[now] = i
        visited.append(now)
        now = A[now]-1

loopstarts = visited.index(now)
looplength = len(visited)-loopstarts

if K < loopstarts:
    print(visited[K]+1)
else:
    print(visited[loopstarts+(K-loopstarts)%looplength]+1)
# print(time()-t0)
# Judge status: Accepted
import sys
n=int(input())
ans=0
flag=0
while n%10==0:
  n=n//10
if n==1:
  print(10)
  sys.exit()
s=str(n)
for i in range(len(s)):
  ans+=int(s[i])
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
if c >= a and c <= b:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n,m = map(int,input().split())
print(n*(n-1)/2+m*(m-1)/2)
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())
s = input()
#s = '.' + s

if '##' in s[a:c-1] or '##' in s[b:d-1]:
    print('No')
else:
    if c < b or c < d:
        print('Yes')
    else:
        if '...' in s[b-2:d+1]:
            print('Yes')
        else:
            print('No')
# Judge status: Accepted
def main():
    n = int(input())
    answer = 1
    while answer <= n:
        answer *= 2
    print(answer // 2)


if __name__ == '__main__':
    main()
# Judge status: Accepted
X = int(input())

print('YES' if X in [7, 5, 3] else 'NO')
# Judge status: Accepted
S, T = input().split()

ans = T + S
print(ans)
# Judge status: Accepted
N = int(input())

if N < 2:
    ans = 1
elif N < 4:
    ans = 2
elif N < 8:
    ans = 4
elif N < 16:
    ans = 8
elif N < 32:
    ans = 16
elif N < 64:
    ans = 32
else:
    ans = 64

print(ans)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
x = int(input())

# x までの素数を探す
prim_numbers = [2]
for divider in range(2, int(np.sqrt(x))):
    if x % divider == 0:
        continue
    else:
        prim_numbers.append(divider)


def is_primt(q):
    for divider in prim_numbers:
        if q % divider == 0:
            return False
    return True


while True:
    if is_primt(x):
        print(x)
        exit()
    else:
        x += 1
        continue
# Judge status: Wrong Answer
X,Y,A,B,C = map(int,input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.extend(Q)
P.extend(R)

P.sort()
a=-(X+Y)
print(sum(P[a:]))
# Judge status: Wrong Answer
#B
n, d = map(int, input().split())
x = []
for i in range(n):
    x.append(list(map(int, input().split())))
ans=0
for i in range(n):
    for j in range(i + 1, n):
        norm = 0
        for k in range(d):
            dif = abs(x[i][k] - x[j][k])** 2
            norm += dif
        flag=False
        for k in range(norm):
            if k ** 2 == norm:
                flag = True
        if flag:
            ans += 1
print(ans)
# Judge status: Wrong Answer
s=input()
for i in range(len(s)//2):
  t=s[:-2*i]
  half=len(t)//2
  if t[:half]==t[half:]:
    ans=len(t)
    break
print(ans)
# Judge status: Accepted
n = int(input())

s = []

for i in range(n):
    s.append(int(input()))

m = max(s)

s2 = s.copy()

s2.remove(m)

m2 = max(s2)

for i in s:
    if i == m:
        print(m2)
        
    else:
        print(m)
# Judge status: Wrong Answer
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
list = [list(map(int, input().split())) for x in range(m)]
list.sort(key=lambda x: x[1], reverse=True) # １番の要素で降順ソート

app_count = 0
for i in list:
    a += [i[1]]*i[0]
    app_count += i[0]
    if app_count>n:
        break

a.sort(reverse=True)

print(a[:n])
# Judge status: Accepted
n = int(input())
CSF = [tuple(map(int, input().split())) for _ in range(n - 1)]

for i in range(n):
    t = 0
    for c, s, f in CSF[i:]:
        if t < s:
            t = s
        elif t % f != 0:
            t += f - t % f
        t += c
    print(t)
# Judge status: Wrong Answer
n,m=map(int,input().split())

if n<2 and m<2:
  print(0)
else:
  print(n*(n-1)/(2)+m*(m-1)/2)
# Judge status: Wrong Answer
from collections import Counter

n = int(input())
a = Counter(map(int, input().split()))
xy = []
a = sorted(a.items(), key=lambda x: x[0], reverse=True)
for i in a:
    if len(xy) == 2:
        break
    if i[1] >= 4:
        xy.append(i[0])
        xy.append(i[0])
        break
    if i[1] >= 2:
        xy.append(i[0])

    else:
        pass
print(xy[0] * xy[1]) if len(xy) == 2 else print(0)
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())

ans = -10**9

ans = max(ans,a*c)
ans = max(ans,a*d)
ans = max(ans,b*c)
ans = max(ans,b*d)

print(ans)
# Judge status: Accepted
# abc083_b.py
N,A,B = map(int,input().split())
ans = 0
for i in range(N+1):
    s = str(i)
    add = 0
    for j in s:
        add += int(j)
    if add <= B and add>= A:
        ans += i
print(ans)
# Judge status: Accepted
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
xyc = [list(map(int,input().split())) for _ in range(M)]

ans = min(a) + min(b)

for x,y,c in xyc:
  ans = min(ans, a[x-1]+b[y-1]-c)

print(ans)
# Judge status: Accepted
A, B, C = map(int, input().split())

ans = 0
if A % 2 != B % 2 == C % 2:
    B += 1
    C += 1
    ans += 1
elif B % 2 != C % 2 == A % 2:
    C += 1
    A += 1
    ans += 1
elif C % 2 != A % 2 == B % 2:
    A += 1
    B += 1
    ans += 1

ABC = sorted([A, B, C])

ans += ((ABC[2] - ABC[1]) // 2 + (ABC[2] - ABC[0]) // 2)
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
D = set(map(int, input().split()))

num = set(i for i in range(10))

D = num - D

for i in range(n, 100000):
    for _ in str(i):
        if int(_) not in D:
            break
    else:
        print(i)
        break
# Judge status: Accepted
# n = int(input())
# s = input()
# a = list()
n = int(input())
s = [input() for _ in range(n)]
# a, b, c, d = map(int, input().split())

count = set()
for i in s:
    count.add(i)
print(len(count))
# Judge status: Wrong Answer
S = input()

ans = 753- int(S[:3])
for i in range(1, len(S)-1):
    tmp = int(S[i:i+3])
    ans = min(abs(753-tmp), ans)

print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
x = 0
y = sum(a)
ans = 10**10
for i in range(n-1):
    x += a[i]
    y -= a[i]
    ans = min(ans,abs(x-y))
print(ans)
# Judge status: Wrong Answer
n = int(input())
k = int(input())
x = int(input())
y = int(input())

print(x*k + y * (n-k))
# Judge status: Wrong Answer
a,b = list(map(int,input().split()))
if a >= b:
  print(a+a-1)
elif a <= b:
  print(b+b-1)
else:
  print(a+b)
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))

if max(L) < sum(L) - max(L):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import fractions

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


def get_lcm(a, b):
    return (a * b) // fractions.gcd(a, b)


print(get_lcm(A, B))
# Judge status: Accepted
a,b,x = map(int,input().split())

if a <= x and a + b >= x:
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
h = int(input())
w = int(input())
n = int(input())

if(h>w):
  if(n % h == 0):
    print(n//h)
  else:
  	print(n//h + 1)
else:
  if(n % h == 0):
    print(n//w)
  else:
  	print(n//w + 1)
# Judge status: Accepted
x,a,b = map(int, input().split())
if abs(x-a) < abs(x-b):
  print("A")
else:
  print("B")
# Judge status: Accepted
#!/usr/bin/env python3

import sys

input = iter(sys.stdin.read().splitlines()).__next__

N = int(input())
res = 1-N
print(res)
# Judge status: Accepted
s = input()
s_list = list(s)

if s[-1] == "s":
    Ans = s + "es"
else:
    Ans = s + "s"

print(Ans)
# Judge status: Wrong Answer
N, M = map(int, input().split(' '))
if N >= M:
    print(0)
else:
    points = sorted(tuple(map(int, input().split(' '))))
    distances = sorted([abs(p1 - p2) for p1, p2 in zip(points, points[1:])])
    print(sum(distances[:-N + 1]))
# Judge status: Wrong Answer
import itertools
import math
import fractions
import functools
import copy
n, q = map(int, input().split())
s = input()
l = []
r = []
for i in range(q):
    li, ri = map(int, input().split())
    li -= 1
    l.append(li)
    r.append(ri)

count_list = [0] * n
for i in range(1,n):
    if s[i-1] == "A" and s[i]=="C":
        count_list[i] = 1

count = 0
print(count_list)
for i in range(q):
    if count_list[i] == 0:
        print(sum(count_list[l[i]:r[i]]))
    else:
        print(sum(count_list[l[i]:r[i]])-1)
# Judge status: Wrong Answer
mod = 1e9 +7

n = int(input())
a = list(map(int,input().split()))
pref=[0 for x in range(n)]
pref[0] = a[0]
for i in range(1,n):
    pref[i] += ((pref[i-1]+a[i])%mod)

ans=0
for i in range(n-1,0,-1):
    ans = (ans + a[i]*pref[i-1])%mod


print(int(ans))
# Judge status: Accepted
H, N = map(int, input().split()) 
abl = []
for _ in range(N):
    ab = list(map(int, input().split()) )
    abl.append(ab)

dp = [10**8]*(2*10**4+1)
dp[0] = 0
for h in range(H+1):
    for ab in abl:
        a,b = ab
        dp[h+a] = min(dp[h+a], dp[h]+b)

print(min( dp[H:] ))
# Judge status: Wrong Answer
N,M = map(int, input().split())
L = []
R = []
for _ in range(M):
  l,r = map(int, input().split())
  L.append(l)
  R.append(r)

if min(R) <= max(L):
  print(min(R)-max(L)+1)
else:
  print(0)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

tmp=0
res=0
for i in range(n):
    if b[i] + tmp > a[i]:
        res += a[i]
        tmp = b[i] + tmp -a[i]
    else:
        res += b[i] + tmp
        tmp = 0

if tmp > a[-1]:
    res += a[-1]
else:
    res += tmp

print(res)
# Judge status: Accepted
N = int(input())
count = 0
for i in range(1,N+1):
    yaku = 0
    if i%2 == 1:
        for j in range(1,i+1):
            if i%j == 0:
                yaku += 1
        if yaku == 8:
            count += 1
print(count)
# Judge status: Wrong Answer
N,M=map(int,input().split())

ans=0

ans=min(N,M/2)
ans+=max(0,(M-2*ans)//4)
print(ans)
# Judge status: Wrong Answer
url = "https://atcoder.jp/contests/abc161/tasks/abc161_b"


def main():
    n, m = list(map(int, input().split()))
    n_li = list(map(int, input().split()))
    n_li = sorted(n_li, reverse=True)
    all_num = sum(n_li)
    for i in range(1, m + 1):
        if all_num // (4 * m) > n_li[i - 1]:
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import random
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(D)]
cnt = []
for i in range(D):
  rand = random.randrange(0, 26)
  cnt.append(rand)
[print(i) for i in cnt]
# Judge status: Wrong Answer
N, X = map(int, input().split())
a = list(map(int, input().split()))

m = []
for aa in a:
  m.append(abs(X-aa))
  
print(min(m))
# Judge status: Wrong Answer
S = list(input())
 
cnt0 = S.count("0")
cnt1 = S.count("1")
 
print(min(cnt0, cnt1) * 2)
# Judge status: Accepted
n = int(input())
a = [int(input()) for i in range(n)]

flag = False
ind = 1
for cnt in range(n):
  ind = a[ind-1]

  if ind == 2:
    flag = True
    break

print(cnt+1 if flag else -1)
# Judge status: Accepted
from sys import stdin, setrecursionlimit
from bisect import bisect_left
from collections import deque

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def main():
    N = int(input())
    A = tuple(int(input()) for _ in range(N))
    B =deque([A[0]])

    for a in A[1:]:
        if a <= B[0]:
            B.appendleft(a)
        else:
            B[bisect_left(B, a) - 1] = a

    print(len(B))


if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b = map(int, input().split())
print([["Alice", "Bob"][(a - 2)%13 < (b - 2)%13], "Draw"][a==b])
# Judge status: Accepted
a,b=map(int,input().split())
s=input()
if s[:a].isdecimal() and s[a+1:].isdecimal() and s[a]=='-':
    print('Yes')
else:
    print('No')
# Judge status: Accepted
#  --*-coding:utf-8-*--

N = int(input())
A = list(int(input()) for _ in range(N))

s = 0
s2 = 0

for a in A:
    if a != 0:
        s2 += a
    else:
        s += s2//2
        s2 = 0

s += s2//2

print(s)
# Judge status: Accepted
a, b, k = map(int, input().split())
s = {a + i for i in range(min(k, b - a + 1))} | {b - i for i in range(min(k, b - a + 1))}
l = sorted(list(s))
for i in l:
    print(i)
# Judge status: Accepted
A,B,m=map(int,input().split())
xyc=[]
a=[]
b=[]

s=list(map(int,input().split()))
for i in range(A):
  a.append([s[i],i])
a.sort()
t=list(map(int,input().split()))
for i in range(B):
  b.append([t[i],i])
b.sort()
ans=a[0][0]+b[0][0]

for i in range(m):
  p,q,r=map(int,input().split())
  ans=min(ans,s[p-1]+t[q-1]-r)

print(ans)
# Judge status: Accepted
A,B = map(int,input().split())
if(A == B):
  print(str(A * 2))
else:
  print(str(max(A,B) * 2 - 1))
# Judge status: Wrong Answer
n = int(input())
ans = 0
for i in range(1, n+1, 2):
    cnt = 0
    for j in range(1, i+1):
        if n % j == 0:
            cnt += 1
    if cnt == 8:
        ans += 1
print(ans)
# Judge status: Accepted
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
    
N,M=map(int,input().split())
A=[int(i)//2 for i in input().split()]
q=lcm(*A)
#print(q)
for i in A:
    #print(i)
    if q//i%2==0:
        print(0)
        exit()
print((M//q+1)//2)
# Judge status: Accepted
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
alis = li()
import numpy as np
A = np.array(alis,dtype=np.int64)
b = [0] * 61
count = 0
ans = 0
MOD = 10**9 + 7
while A.any():
    one = np.count_nonzero(A & 1)
    k = (1<<count) % MOD
    #ans += (one * (n - one) * pow(2, count, MOD)) % MOD
    ans += (one * (n - one)) * k % MOD
    ans %= MOD
    A >>= 1
    count += 1
 
print(ans)
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
if 2*max(l)<sum(l):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
#B
a,b,c,d = map(int,input().split())
print(max(a*c,a*d,b*c,b*d))
# Judge status: Accepted
import sys
x,y=map(int,input().split())
for i in range(x+1):
    asi=i*2+(x-i)*4
    if asi==y:
        print("Yes")
        sys.exit()
print("No")
# Judge status: Accepted
N = int(input())
V = [int(hoge) for hoge in input().split()]
V.sort()
ans = V[0]
for n in range(1,N):
    ans += V[n]
    ans /= 2
print(ans)
# Judge status: Wrong Answer
from collections import deque


B = deque()
n = int(input())
A = list(map(int, input().split()))

for i, a in enumerate(A):
    if i % 2 == 0:
        B.append(a)
    else:
        B.appendleft(a)

print(*B)
# Judge status: Accepted
A,B,C = map(int, input().split())
D = B // A
print(C if C < D else D)
# Judge status: Accepted
h = int(input())
for i in range(100):
    if 2**i > h:
        print(2**i - 1)
        exit()
# Judge status: Accepted
x,a,b=map(int,input().split())
if min(abs(x-a),abs(x-b))==abs(x-a):
    print("A")
else:
    print("B")
# Judge status: Wrong Answer
n,x,y = [int(n) for n in input().split()]


ans = [0] * (n-1)

for i in range(n-1):
    for j in range(i+1,n):
        a=j-i
        b=abs(y-j)+abs(i-x)+1
        ans[min(a,b)-1]+=1
for i in ans:
	print(i)
# Judge status: Accepted
#97 B - Exactly N points
N = int(input())

A = []
num = 1
cnt = 0
for _ in range(N):
    A.append(num)
    cnt += 1
    if num == cnt:
        cnt = 0
        num += 1

ans = [A[-1]]
tgt = N - A[-1]

for i in range(A[-1]-1,0,-1):
    tgt -= i
    if tgt == 0:
        ans.append(i)
        break
    if tgt < 0:
        tgt += i
        continue
    ans.append(i)

for a in ans:
    print(a)
# Judge status: Accepted
def main():
    g = [input() for _ in range(2)]
    for r in range(2):
        for c in range(3):
            if g[r][c] != g[1 - r][2 - c]:
                print('NO')
                return
    print('YES')


if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

x = readInt()
ans = math.ceil((-1+(x*8)**0.5)/2)
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
remain = 0
for i in range(N):
  # before
  A[i] -= remain
  ans += remain
  
  # now
  remain = max(B[i]-A[i], 0)
  ans += min(A[i], B[i])

if remain > 0:
  ans += min(A[N], remain)
print(ans)