Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys

input = sys.stdin.readline

S = input().strip()
N = len(S)
converges = [0] * N

for i in range(N):
    s = S[i]
    if s == 'R':
        for j in range(1, 100000):
            if S[i + j] == 'L':
                if j % 2 == 0:
                    converges[i + j] += 1
                    break
                else:
                    converges[i + j - 1] += 1
                    break
    else:
        for j in range(1, 100000):
            if S[i - j] == 'R':
                if j % 2 == 0:
                    converges[i - j] += 1
                    break
                else:
                    converges[i - j + 1] += 1
                    break

print(' '.join(map(str, converges)))

### FIXED CODE ###

import sys

input = sys.stdin.readline

S = input().strip()
N = len(S)

crs = list(map(len, S.split('R')))
cls = list(map(len, S.split('L')))
converges=[0] * N

current_index = 0
for cr in crs:
    if cr == 0:
        current_index += 1
    else:
        odd = cr // 2
        even = cr - odd
        converges[current_index - 1] += odd
        converges[current_index] += even
        current_index += cr+1

current_index = N - 1
for cl in cls[::-1]:
    if cl == 0:
        current_index -= 1
    else:
        odd = cl // 2
        even = cl - odd
        converges[current_index + 1] += odd
        converges[current_index] += even
        current_index -= cl + 1

print(' '.join(map(str, converges)))
### BUGGY CODE ###

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
X = [[-10**2 for __ in range(W)] for _ in range(H)]
Y = [[-10**2 for __ in range(W)] for _ in range(H)]
for y in range(H):
  last_x = -1
  for x in range(W):
    if S[y][x] == "#":
      for t in range(last_x+1,x):
        X[y][t] = x-1-last_x
      last_x = x
  for t in range(last_x+1,W):
    X[y][t] = W-1-last_x
for x in range(W):
  last_y = -1
  for y in range(H):
    if S[y][x] == "#":
      for t in range(last_y+1,y):
        Y[t][x] = y-1-last_y
      last_y = y
  for t in range(last_y+1,H):
    Y[t][x] = H-1-last_y
ans = 0
for y in range(H):
  for x in range(W):
    ans = max(ans, Y[y][x]+X[y][x])
print(ans-1)


### FIXED CODE ###

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
X = [[-10**2 for __ in range(W)] for _ in range(H)]
Y = [[-10**2 for __ in range(W)] for _ in range(H)]
last_ys = [-1] * W
for y in range(H):
  last_x = -1
  for x in range(W):
    if S[y][x] == "#":
      for t in range(last_x+1,x):
        X[y][t] = x-1-last_x
      for t in range(last_ys[x]+1,y):
        Y[t][x] = y-1-last_ys[x]
      last_x = x
      last_ys[x] = y
  for t in range(last_x+1,W):
    X[y][t] = W-1-last_x
for x in range(W):
  for t in range(last_ys[x]+1,H):
    Y[t][x] = H-1-last_ys[x]
ans = 0
for y in range(H):
  for x in range(W):
    ans = max(ans, Y[y][x]+X[y][x])
print(ans-1)
### BUGGY CODE ###

import fractions
from functools import reduce
def gcd(i):
    return reduce(fractions.gcd, i)
N = int(input())
A = list(map(int, input().split()))
tmp = []
if gcd(A) == max(A):
    print(gcd(A))
    exit()
else:
    for i in range(N):
        if i == 0 :
            tmp.append(gcd(A[1:]))
        elif i == N-1:
            tmp.append(gcd(A[:N-1]))
        else:
            tmp.append(gcd(A[:i]+A[i+1:]))
print(max(tmp))

### FIXED CODE ###

import fractions
from functools import reduce
def gcd(*i):
    return reduce(fractions.gcd, i)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    L=[0]
    R=[0]
    for i in range(N):
        L.append(gcd(L[i],A[i]))
        R.append(gcd(R[i],A[-(i+1)]))
    R=R[::-1]
    ans=[]
    for i in range(N):
        ans.append(gcd(L[i],R[i+1]))
    print(max(ans))
if __name__ == "__main__":
    main()
### BUGGY CODE ###

#E
from fractions import gcd
from collections import Counter
N=int(input())

mod=1000000007
ans=1
P=[]
M=[]
zero=0
zero1=0
zero2=0
for i in range(N):
    a,b=map(int,input().split())
    if a==0 and b==0:
        zero+=1
    elif a==0 and b!=0:
        zero1+=1
    elif a!=0 and b==0:
        zero2+=1
    elif (a>0 and b<0) or (a<0 and b>0):
        GCD=gcd(abs(a),abs(b))
        a=abs(a)//GCD
        b=abs(b)//GCD
        P.append(str(a)+"/"+str(b))
        
    else:
        GCD=gcd(abs(a),abs(b))
        a=abs(a)//GCD
        b=abs(b)//GCD
        M.append(str(b)+"/"+str(a))

P_dict=Counter(P)
M_dict=Counter(M)
P_dict["0/0"]=zero1
M_dict["0/0"]=zero2
for v,cnt_p in P_dict.items():
    if v in M_dict:
        cnt_m=M_dict[v]
        ans*=(2**cnt_p+2**cnt_m-1)
        M_dict.pop(v)
    else:
        ans*=2**cnt_p
    ans%=mod
    
for v,cnt_m in M_dict.items():
    ans*=2**cnt_m
    ans%=mod

ans-=1
ans+=zero
ans%=mod
print(ans)

### FIXED CODE ###

#E
from math import gcd
N=int(input())

mod=1000000007
ans=1
P=dict()
M=dict()
zero=0
zero1=0
zero2=0
for i in range(N):
    a,b=map(int,input().split())
    if a==0 and b==0:
        zero+=1
    elif a==0 and b!=0:
        zero1+=1
    elif a!=0 and b==0:
        zero2+=1
    elif (a>0 and b<0) or (a<0 and b>0):
        GCD=gcd(abs(a),abs(b))
        a=abs(a)//GCD
        b=abs(b)//GCD
        s=str(a)+"/"+str(b)
        P[s]=P.get(s,0)+1
        
    else:
        GCD=gcd(abs(a),abs(b))
        a=abs(a)//GCD
        b=abs(b)//GCD
        s=str(b)+"/"+str(a)
        M[s]=M.get(s,0)+1

P["0/0"]=zero1
M["0/0"]=zero2
for v,cnt_p in P.items():
    if v in M:
        cnt_m=M[v]
        ans*=(2**cnt_p+2**cnt_m-1)
        M.pop(v)
    else:
        ans*=2**cnt_p
    ans%=mod
    
for v,cnt_m in M.items():
    ans*=2**cnt_m
    ans%=mod

ans-=1
ans+=zero
ans%=mod
print(ans)
### BUGGY CODE ###

import sys
from bisect import bisect, bisect_left
import heapq

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    S = [0] * (N + 1)
    for i, a in enumerate(A): S[i + 1] = a + S[i]
 
    l, h = 1, A[N-1] * 2 + 1
    count_l = 0
    while h - l > 1: #最小値がｍ以上の要素をM個用意できるか
        m = (h + l) // 2
        count = 0
        for i, a in enumerate(A): count += N - bisect_left(A, m - a)
        if count >= M: 
            l = m
            count_l = count
        else: h = m

    total = 0
    count = 0
    Q = []
    heapq.heapify(Q)
    for i, a in enumerate(A):
        j = bisect_left(A, l - a)  
        total += a * (N - j) + (S[N] - S[j])
        count += N - j
        if count_l > M:
            double = bisect_left(A, h - a)
            for k in range(j, min(N - 1, double + 1)):
                heapq.heappush(Q, a + A[k])

    if count > M:
        for _ in range(count - M):
            minus = heapq.heappop(Q)
            total -= minus

    print(total)

    return 0

if __name__ == "__main__":
    solve()


### FIXED CODE ###

import sys
from bisect import bisect, bisect_left
import heapq

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    S = [0] * (N + 1)
    for i, a in enumerate(A): S[i + 1] = a + S[i]
 
    l, h = 1, A[N-1] * 2 + 1
    while h - l > 1: #最小値がｍ以上の要素をM個用意できるか
        m = (h + l) // 2
        count = 0
        for i, a in enumerate(A): count += N - bisect_left(A, m - a)
        if count >= M: 
            l = m
        else: h = m

    total = 0
    count = 0
    Q = []
    heapq.heapify(Q)
    min_out = 10000000
    for i, a in enumerate(A):
        j = bisect_left(A, l - a)  
        total += a * (N - j) + (S[N] - S[j])
        count += N - j
        if 0 <= j < N: min_out = min(min_out, a + A[j])

    if count > M:
        total -= min_out * (count - M)

    print(total)

    return 0

if __name__ == "__main__":
    solve()
### BUGGY CODE ###

m = 1
for i in range(1,int(input())+1):
    m = m * i
k = int(m % (1000000007))
print(k)



### FIXED CODE ###

m = 1
for i in range(1,int(input())+1):
    m = m * i % 1000000007
print(m)
### BUGGY CODE ###

import collections

N = int(input())
num_list = list(input().split())
memo = [0]*(N+1)
memo_flg = [False]*(N+1)
c = collections.Counter(num_list)

def calc(k):
    target = num_list[k]
    num = int(target)
    if(memo_flg[num] is True):
        return memo[num]
    ans = 0
    
    test = dict(c)
    test[target] -= 1

    for i in test.keys():
        ans += (test[i]*(test[i]-1))//2
    memo[num] = ans
    memo_flg[num] = True
    return ans

[print(calc(i)) for i in range(N)]


### FIXED CODE ###

import collections

N = int(input())
num_list = list(map(int,input().split()))
memo = [0]*(N+1)
memo_flg = [False]*(N+1)
counter = [0] * (N+1)
counter_ans = [0] * (N+1)

for i in num_list:
    counter[i] += 1
for i in range(N+1):
    counter_ans[i] = (counter[i]*(counter[i]-1))//2

all_sum = sum(counter_ans)
def calc(k):
    num = num_list[k]
    
    if(memo_flg[num] is True):
        return memo[num]
    ans = 0
    
    wrong = counter_ans[num]
    c = counter[num]-1
    right = (c*(c-1))//2
    
    ans = all_sum - wrong + right
    memo[num] = ans
    memo_flg[num] = True
    return ans

[print(calc(i)) for i in range(N)]
### BUGGY CODE ###

import math
import numpy as np

k = int(input())

answer = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            answer += np.gcd.reduce([a,b,c])

print(answer)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
 
K = int(read())
 
x = np.arange(1, K + 1)
nums = np.gcd.outer(np.gcd.outer(x, x), x)
print(nums.sum())
### BUGGY CODE ###

from collections import Counter


MOD = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))


def prime_factor_table(n):
    table = [0] * (n + 1)

    for i in range(2, n + 1):
        if table[i] == 0:
            for j in range(i + i, n + 1, i):
                table[j] = i

    return table


def prime_factor(n, prime_factor_table):
    prime_count = Counter()

    while prime_factor_table[n] != 0:
        prime_count[prime_factor_table[n]] += 1
        n //= prime_factor_table[n]
    prime_count[n] += 1

    return prime_count


primes = prime_factor_table(max(A))


lcm = prime_factor(A[0], primes)

for a in A:
    b = prime_factor(a, primes)
    lcm = lcm | b

ans = 0
L = 1
for key in list(lcm.keys()):
    L *= key ** lcm[key]

for a in A:
    ans += L // a
    ans %= MOD

print(ans)


### FIXED CODE ###

from fractions import gcd


MOD = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

lcm = A[0]

for a in A:
    lcm = (lcm * a) // gcd(lcm, a)

ans = 0
for a in A:
    ans += (lcm % MOD) * pow(a, MOD - 2, MOD)
    ans %= MOD

print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
  dp[i]=min([dp[j]+abs(a[i]-a[j]) for j in range(max(0,i-k),i)])
print(dp[-1])


### FIXED CODE ###

import sys
input = sys.stdin.readline
def fun(n,a,k):
 dp=[0]*n
 for i in range(1,n):
  dp[i]=min([dp[j]+abs(a[i]-a[j]) for j in range(max(0,i-k),i)])
 print(dp[len(dp)-1])
if __name__ == '__main__':
 n,k = map(int, input().split())
 a=list(map(int,input().split()))
 fun(n,a,k)
### BUGGY CODE ###

h,w=map(int,input().split())
maze=[["#" for i in range(2+w)]]
for _ in range(h):
    x=list(input())
    x.insert(0,"#")
    x.append("#")
    maze.append(x)
    
maze.append(["#" for i in range(2+w)])

#maze[i][j]=(i,j)番目の様子がどうなっているか。"#"の時地雷、"."の時oke

from collections import deque

d=deque()
d.append((1,1))





visited=[[False for i in range(w+2)] for j in range(h+2)]

dis=0
visited[1][1]=True

while visited[h][w]==False:
    e=deque()
    dis+=1
    while d:

    	x=d.popleft()

    
    
    	X,Y=x[0],x[1]
    	if visited[X-1][Y]==False and maze[X-1][Y]==".":
        	visited[X-1][Y]=True
        	e.append((X-1,Y))
    	if visited[X+1][Y]==False and maze[X+1][Y]==".":
        	visited[X+1][Y]=True
        	e.append((X+1,Y))
    	if visited[X][Y-1]==False and maze[X][Y-1]==".":
        	visited[X][Y-1]=True
        	e.append((X,Y-1))
    	if visited[X][Y+1]==False and maze[X][Y+1]==".":
        	visited[X][Y+1]=True
        	e.append((X,Y+1))
    if e:
      d=e
      e=deque()

    
dis=dis+1




cnt=0

#全体の白い領域を見る
for i in range(h+2):
    for j in range(2+w):
        if maze[i][j]==".":
            cnt+=1
        
        
print(cnt-dis)


### FIXED CODE ###

from collections import deque
d=deque()
e=deque()
h,w=map(int,input().split())
field=[0 for i in range(h+2)]
field[0]=[True for i in range(w+2)]
distance=0
white=0
for i in range(h):
    s=input()
    a=[False for i in range(w+2)]
    a[0]=True
    for j in range(w):
        if s[j]=="#":
            a[j+1]=True
        else:
            white+=1

    a[w+1]=True
    field[i+1]=a
field[h+1]=[True for i in range(w+2)]
d.append((1,1))
ans=-1
while d:
    while d:
        some=d.popleft()
        index1,index2=some[0],some[1]
        if index1==h and index2==w:
            ans=distance
        if field[index1-1][index2]==False:
                field[index1-1][index2]=True
                e.append((index1-1,index2))
        if field[index1+1][index2]==False:
                field[index1+1][index2]=True
                e.append((index1+1,index2))
        if field[index1][index2+1]==False:
                field[index1][index2+1]=True
                e.append((index1,index2+1))
        if  field[index1][index2-1]==False:
                field[index1][index2-1]=True
                e.append((index1,index2-1))
    distance+=1
    d=e
    e=deque()
if ans>=0:
    print(white-ans-1)
else:
    print(-1)
### BUGGY CODE ###

#n,x=map(int,input().split())
#a=[int(i) for i in input().split()]
import string
alp=string.ascii_lowercase
s=input()
a=[]
for i in s:
    a.append(i)
l=a.pop()
if a:
    a=a[::-1]
k=int(input())
ans=''
i=0
while a:
    t=a.pop()
    d=(26-alp.index(t))%26
    if d<=k:
        k-=d
        ans+='a'
    else:
        ans+=t
    i+=1
ans+=alp[(alp.index(l)+k%26)%26]
print(ans)

### FIXED CODE ###

#n,x=map(int,input().split())
#a=[int(i) for i in input().split()]
import string
alp=string.ascii_lowercase
di={}
for i in range(26):
    di[alp[i]]=i
s=input()
a=[]
for i in s:
    a.append(i)
l=a.pop()
if a:
    a=a[::-1]
k=int(input())
ans=''
i=0
while a:
    t=a.pop()
    d=(26-di[t])%26
    if d<=k:
        k-=d
        ans+='a'
    else:
        ans+=t
    i+=1
kk=k%26
ans+=alp[(alp.index(l)+kk)%26]
print(ans)
### BUGGY CODE ###

import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
#from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

import heapq
def dijkstra(edges, start, end):
	#dist = [float('inf')]*N
	dist = defaultdict(lambda: float('inf'))
	dist[start] = 0
	heap = []
	heapq.heappush(heap, (0, start))
	while heap:
		d, n = heapq.heappop(heap)
		if n == end:
			return d
		if dist[n] != d:
			continue
		for nn, ed in edges[n]:
			nd = d + ed
			if dist[nn] > nd:
				dist[nn] = nd
				heapq.heappush(heap, (nd, nn))
	return -1

H, W = rl()
C = rl()
D = rl()
M = []
for i in range(H):
	s = rs()
	M.append(s)

edges = defaultdict(list)
for i in range(H):
	for j in range(W):
		if M[i][j] == '#': continue
		n = (i,j)
		edges[n] = []
		for di, dj in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
			ni, nj = i+di, j+dj
			if not (0 <= ni < H and 0 <= nj < W): continue
			if M[ni][nj] == '#': continue
			edges[n].append(((ni, nj), 0))
		for di in range(-2, +3):
			for dj in range(-2, +3):
				ni, nj = i+di, j+dj
				if di == 0 and dj == 0: continue
				if (di, dj) in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
					continue
				if not(0 <= ni < H and 0 <= nj < W): continue
				if M[ni][nj] == '#': continue
				edges[n].append(((ni, nj), 1))

start = tuple([C[0]-1, C[1]-1])
end = tuple([D[0]-1, D[1]-1])
d = dijkstra(edges, start, end)
print(d)


### FIXED CODE ###

import sys, math
from collections import defaultdict, deque, Counter
#from bisect import bisect_left, bisect_right
#from itertools import combinations, permutations, product
from heapq import heappush, heappop
#from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

dist = defaultdict(lambda: float('inf'))
def dijkstra(start, end):
	dist[start] = 0
	heap = []
	heappush(heap, (0, start))
	while heap:
		d, n = heappop(heap)
		if n == end:
			return d
		if dist[n] != d:
			continue
		edges = get_edges(n)
		for nn, ed in edges:
			nd = d + ed
			if dist[nn] > nd:
				dist[nn] = nd
				heappush(heap, (nd, nn))
	return -1

def get_edges(n):
	i, j = n
	edges = []
	if M[i][j] == '#': return edges
	for di in range(-2, +3):
		for dj in range(-2, +3):
			ni, nj = i+di, j+dj
			if di == 0 and dj == 0: continue
			if not(0 <= ni < H and 0 <= nj < W): continue
			if M[ni][nj] == '#': continue
			if (di, dj) in [(1,0),(-1,0),(0,1),(0,-1)]:
				edges.append(((ni, nj), 0))
			else:
				edges.append(((ni, nj), 1))
	return edges

H, W = rl()
C = rl()
D = rl()
M = []
for i in range(H):
	s = rs()
	M.append(s)

start = tuple([C[0]-1, C[1]-1])
end = tuple([D[0]-1, D[1]-1])
d = dijkstra(start, end)
print(d)
### BUGGY CODE ###

n = int(input())
p = [int(x) for x in input().split()]

c = [1 if p[i] == min(p[:i+1]) else 0 for i in range(n)]
print(sum(c))


### FIXED CODE ###

n = int(input())
p = [int(x) for x in input().split()]

ans = 1
minp = p[0]
for i in range(1, n):
   if (p[i] <= minp):
      minp = p[i]
      ans += 1

print(ans)
### BUGGY CODE ###

import collections
n = int(input())
lis = list(map(int,input().split()))
count = 0

countArray = [0]*n
calc=0

for i in range(n):
    calc += lis[i]
    countArray[i] = calc
    if calc == 0:
        count +=1

c = collections.Counter(countArray)
for i in range(len(c.most_common())):
    counts = c.most_common()[i][1]
    if counts < 2:
        break
    count += (counts * (counts - 1)) // 2
print(count)

### FIXED CODE ###

import collections
n = int(input())
lis = list(map(int,input().split()))
count = 0

countArray = [0]*n
calc=0

for i in range(n):
    calc += lis[i]
    countArray[i] = calc
    if calc == 0:
        count +=1

c = collections.Counter(countArray)
a = c.most_common()
for i in range(len(c.most_common())):
    counts = a[i][1]
    if counts < 2:
        break
    count += (counts * (counts - 1)) // 2
print(count)
### BUGGY CODE ###

A, B, C, D = map(int, input().split())
num = 0
for i in range(A, B+1):
    if i % C == 0:
        num += 1
    elif i % D == 0:
        num += 1
x_num = B - A + 1 - num
print(x_num)


### FIXED CODE ###

A, B, C, D = map(int, input().split())
def gcd(a, b):
    if a < b:
        a, b = b, a
    a, b = b, a % b
    if b == 0 :
        return a
    else:
        return gcd(a, b)
cd = C * D //gcd(C, D)
print(B - B // C - B // D + B // cd - A + 1 + (A - 1) // C + (A - 1)// D - (A - 1)// cd)
### BUGGY CODE ###

#Pythonだと少し間に合わない
N = int(input())

x = (3500 * N + (4 * 2500 - 2 * N) - 1) //(4 * 2500 - 2 * N)
for h in range(1, x + 2):
    for n in range(3500, 0, -1):
        if (N * h * n) >= (4 * h * n - N * (h + n)) > 0:
            if (N * h * n) % (4 * h * n - N * (h + n)) == 0:
                w = (N * h * n) // (4 * h * n - N * (h + n))
                print (h, n, w)
                exit()


### FIXED CODE ###

N = int(input())

for h in range(1, 3501):
    for n in range(1, 3501):
        if (N * h * n) >= (4 * h * n - N * (h + n)) > 0:
            if (N * h * n) % (4 * h * n - N * (h + n)) == 0:
                w = (N * h * n) // (4 * h * n - N * (h + n))
                print (h, n, w)
                exit()
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()
count = 0
for _ in range(Q):
    l,r = map(int,input().split())
    l-=1
    r-=1
    for i in range(l,r):
        if S[i] == "A" and S[i+1] == "C":
            count += 1
    print(count)
    count = 0

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
AC = [0] * (N)
for i in range(1, N):
    if S[i] == "C" and S[i - 1] == "A":
        AC[i] = AC[i - 1] + 1
    else:
        AC[i] = AC[i-1]
for _ in range(Q):
    l,r = map(int,input().split())
    l-=1
    r-=1
    print(AC[r]-AC[l])
### BUGGY CODE ###

import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, K = read_values()
    A = read_list()

    for k in range(K):
        S = [0] * (N + 1)
        for i, a in enumerate(A):
            S[max(0, i - a)] += 1
            S[min(N, i + a + 1)] -= 1
        
        A = [0] * N
        for i, s in enumerate(S[:N]):
            A[i] = A[i - 1] + s

        if A.count(N) == N:
            break

    print(" ".join(map(str, A)))


if __name__ == "__main__":
    main()



### FIXED CODE ###

import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, K = read_values()
    A = read_list()

    for k in range(K):
        S = [0] * (N + 1)
        for i, a in enumerate(A):
            S[max(0, i - a)] += 1
            S[min(N, i + a + 1)] -= 1
        
        A[-1] = 0
        c = 0
        for i, s in enumerate(S[:N]):
            A[i] = A[i - 1] + s
            if A[i] == N:
                c += 1
            
        if c == N:
            break

    print(" ".join(map(str, A)))


if __name__ == "__main__":
    main()
### BUGGY CODE ###

N, Q = map(int, input().split())
S=list(input())
list=[]
for i in range(0, N-1):
    if S[i] == "A" and S[i+1] == "C":
        list.append(i)
count=0
for i in range(Q):
    l, r = map(int, input().split())
    for j in list:
        if l-1 <= j < r-1:
            count+=1
    print(count)
    count=0

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

ans = [0]*N
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        ans[i+1] += (ans[i]+1)
    else:
        ans[i+1] = ans[i] 

for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])
### BUGGY CODE ###

from fractions import gcd

import sys
input = sys.stdin.readline


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

    B = []

    ok = True
    a = A[0]
    c = 0
    while a%2 == 0:
        a //= 2
        c += 1
    
    p = 2**c

    for a in A:
        if a % p == 0 and a % (2*p) != 0:
            B.append(a//p)
        else:
            ok = False
            break
    if not ok:
        print(0)
    else:
        B.sort()
        g = 1
        for b in B:
            l = gcd(b, g)
            g = g*b//l
        p = g*2**(c-1)
        ans = (M+p)//(2*p)
        print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from fractions import gcd

import sys
input = sys.stdin.readline


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

    B = []

    ok = True
    a = A[0]
    c = 0
    while a%2 == 0:
        a //= 2
        c += 1
    
    p = 2**c

    for a in A:
        if a % p == 0 and a % (2*p) != 0:
            B.append(a//p)
        else:
            ok = False
            break
    if not ok:
        print(0)
    else:
        B.sort()
        g = 1
        for b in B:
            l = gcd(b, g)
            g = g*b//l
            if g > M:
                ok = False
                break
        if not ok:
            print(0)
        else:
            p = g*2**(c-1)
            ans = (M+p)//(2*p)
            print(ans)


if __name__ == "__main__":
    main()