Harryxun/stf_run huggingface dataset:
from itertools import*
s=input()
k=int(input())
l=[]
for i in range(1,6):
    for t in range(len(s)+1-i):
        if len(set(s[t:t+i]))!=1:
            l.append(s[t:t+i])
for i in set(s):
    l.append(i)
print(sorted(set(l))[k-1])

### FIXED CODE ###

s=input()
k=int(input())
l=[]
for i in range(1,k+1):
    for t in range(len(s)-i+1):
        l.append(s[t:t+i])
print(sorted(set(l))[k-1])
from math import factorial

N = int(input())
s = {}
h = {'a': 2, 'b': 3, 'c': 5, 'd': 7, 'e':11, 'f':13, 'g':17,'h':19,'i':23,'j':29,'k':31,'l':37,'m':41,'n':43,'o':47,'p':53,'q':59,'r':61,'s':67,'t':71,'u':73,'v':79,'w':83,'x':89,'y':97,'z':101}
for i in range(N):
    total = 1
    chs = list(input())
    for j in range(10):
        total *= h[chs[j]]
    s[total] = s.get(total, 0) + 1

cnt = 0
for v in s.values():
    if v < 2: continue
    a = factorial(v) / factorial(2) / factorial(v - 2)
    cnt += a

print(int(cnt))

### FIXED CODE ###

def cmb(n, r):
  if n - r < r: r = n - r
  if r == 0: return 1
  if r == 1: return n

  numerator = [n - r + k + 1 for k in range(r)]
  denominator = [k + 1 for k in range(r)]

  for p in range(2,r+1):
      pivot = denominator[p - 1]
      if pivot > 1:
          offset = (n - r) % p
          for k in range(p-1,r,p):
              numerator[k - offset] /= pivot
              denominator[k] /= pivot

  result = 1
  for k in range(r):
      if numerator[k] > 1:
          result *= int(numerator[k])

  return result

N = int(input())
s = {}
h = {'a': 2, 'b': 3, 'c': 5, 'd': 7, 'e':11, 'f':13, 'g':17,'h':19,'i':23,'j':29,'k':31,'l':37,'m':41,'n':43,'o':47,'p':53,'q':59,'r':61,'s':67,'t':71,'u':73,'v':79,'w':83,'x':89,'y':97,'z':101}
for i in range(N):
    total = 1
    chs = list(input())
    for j in range(10):
        total *= h[chs[j]]
    s[total] = s.get(total, 0) + 1

cnt = 0
for v in s.values():
    if v < 2: continue
    a = cmb(v, 2)
    cnt += a

print(int(cnt))
N=int(input())
robbot=[input().split() for i in range(N)]
roba=[x[0] for x in robbot]
robb=[x[1] for x in robbot]
robc=list(map(int,roba))
robd=list(map(int,robb))
tas1=[x+y for (x,y) in zip (robc,robd)]
tas2=[x-y for (x,y) in zip (robc,robd)]
del tas2[0]
del tas1[-1]
tas3=[x-y for (x,y) in zip (tas2,tas1)]
tas4=[i for i in tas3 if i>=0]
print(len(tas4)+1)
  


### FIXED CODE ###

import math
H=int(input())
W=int(input())
N=int(input())
if H>=W:
    print(str(math.ceil(N/H)))
else:
    print(str(math.ceil(N/W)))
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

ans = 0

for i in range(n-1):
    ans += a[(i+1)//2]
print(ans)


### FIXED CODE ###

N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

ans = 0

for i in range(N-1):
    ans += a[(i+1)//2]
print(ans)
from collections import Counter
N = int(input())
A = sorted(list(map(int, input().split())))
count = Counter(A)

data = [True]*N
A = list(set(A))

for i in range(N):
    if data[i]:
        for j in range(i+1,N):
            # print(i,j)
            if A[j]%A[i]==0:
                data[j]=False

ans = len([i for i in range(N) if data[i] and count[A[i]]==1])
print(ans)


### FIXED CODE ###

from collections import Counter
N = int(input())
A = sorted(list(map(int, input().split())))
count = Counter(A)

max_len_A = 10**6+1
data = [0]*max_len_A
A = list(set(A))

for a in A:
    if data[a]==0:
        for j in range(a+a, max_len_A, a):
            data[j]+=1


ans = len([a for a in A if data[a]==0 and count[a]==1])
print(ans)
res = ''
for x in input():
    if x = 'B':
        res = res[:-1]
    else:
        res += x 
print(res)




### FIXED CODE ###

res = ''
for x in input():
    if x == 'B':
        res = res[:-1]
    else:
        res += x 
print(res)
n=input()
N=n.split(" ")
a=int(N[0])
b=int(N[1])
print a*b
print (a+b)*2

### FIXED CODE ###

n=raw_input()
k=n.split(" ")
a=int(k[0])
b=int(k[1])
print a*b ,
print (a+b)*2
N,T = map(int, input().split())
ans = 1005
for i in range(N):
    c,t = map(int, input().split())
    if t <= T:
        ans = min(ans, c)
print("TLE" if m == 1005 else ans)


### FIXED CODE ###

N,T = map(int, input().split())
ans = 1005
for i in range(N):
    c,t = map(int, input().split())
    if t <= T:
        ans = min(ans, c)
print("TLE" if ans == 1005 else ans)
input1 = list(map(int, (input().split())))

a = input1[0]
b = input1[1]

for i in range(1, 101):
    c = int(i * 0.08)
    d = int(i * 0.10)
    if a == c and b == d:
        print(i)
        exit(1)
print(-1)


### FIXED CODE ###

import math
input1 = list(map(int, (input().split())))

a = input1[0]
b = input1[1]

a1 = math.ceil(a / 0.08)
a2 = math.ceil((a+1) / 0.08)
b1 = math.ceil(b / 0.1)
b2 = math.ceil((b+1) / 0.1)
# alist = list(range(a1, a2))
# blist = list(range(b1, b2))

# print(alist)
# print(blist)
for i in range(a1, a2):
    for j in range(b1, b2):
        if i == j:
            print(i)
            # print(i * 0.08)
            # print(i * 0.1)
            exit(0)
print(-1)
x = raw_input();
        sum = 0
        if int(x) == 0:
                break
        for i in (x):
                sum += int(i)
        print sum

### FIXED CODE ###

while True:
        x = raw_input();
        sum = 0
        if int(x) == 0:
                break
        for i in (x):
                sum += int(i)
        print sum
H=int(input())
A=int(input())
count=0
while H>0:
    H=H-A
    count+=1
else:
print(count)

### FIXED CODE ###

H,A=map(int, input().split())
count=0
while H>0:
    H=H-A
    count+=1
else:
    print(count)
N = int(input())

if N <= 599:
    pirint(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
elif N >= 1800 and N <= 1999:
    print(1)

### FIXED CODE ###

N = int(input())

if N >= 400 and N <= 599:
    print(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
else:
    print(1)
s = input()
x,y = map(int,input().split())
k = 0
data = [[],[]]
f = 0
p = 1
for s_ in s:
    if p==1 and s_=='F':
        x -= 1
        continue
    p = 0
    if s_ == 'T':
        if f:
            data[k].append(f)
        k = (k+1)%2
        f = 0
    else:
        f += 1
if f:
    data[k].append(f)

nx = sum(data[0])
ny = sum(data[1])

if nx<x or ny<y:
    print('No')
    exit()

dpx = [[0]*((nx+10)*2) for _ in range(len(data[0])+1)]
dpy = [[0]*((ny+10)*2) for _ in range(len(data[1])+1)]
x_zero = 0
y_zero = 0
dpx[0][x_zero] = 1
dpy[0][y_zero] = 1

for i in range(len(data[0])):
    for j in range(len(dpx[i])):
        if dpx[i][j]==1:
            dpx[i+1][j+data[0][i]] = 1
            dpx[i+1][j-data[0][i]] = 1

for i in range(len(data[1])):
    for j in range(len(dpy[i])):
        if dpy[i][j]==1:
            dpy[i+1][j+data[1][i]] = 1
            dpy[i+1][j-data[1][i]] = 1
if dpx[-1][x_zero+x]==1 and dpy[-1][y_zero+y]==1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

now=0
idx=-1
data=[[],[]]
cnt=0
for s in input():
    if s=='F':
        cnt+=1
    elif s=='T':
        if idx==-1:
            now+=cnt
            cnt=0
            idx=1
        elif idx==0:
            data[0].append(cnt)
            cnt=0
            idx=1
        elif idx==1:
            data[1].append(cnt)
            cnt=0
            idx=0
if idx==-1:
    now+=cnt
else:
    data[idx].append(cnt)
def solve(target,move):
    dp={0,}
    for m in move:
        dpc=dp.copy()
        dp=set()
        for k in dpc:
            dp|={k-m,k+m}
    if target in dp:
        return True
    return False
x,y=map(int,input().split())
x-=now
if solve(x,data[0]) and solve(y,data[1]):
    print('Yes')
else:
    print('No')
n, k, x, y = (input() for i in range(4))
print(min(n, k) * x + max(0, n - k) * y)

### FIXED CODE ###

n, k, x, y = (int(input()) for i in range(4))
print(min(n, k) * x + max(0, n - k) * y)
import numpy as np
 
def resolve():
    input()
    x = list(map(int, input().split()))
    m = int(round(np.mean(x)))
    sum = 0
    for val in x:
        sum += (val - m) ** 2
    print(sum)
 
if __name__ == '__main__':
    resolve()

### FIXED CODE ###

import numpy as np

def resolve():
    input()
    x = list(map(int, input().split()))
    m = int(round(np.mean(x)))
    sum = 0
    for val in x:
        sum += (val - m) ** 2
    print(sum)

if __name__ == '__main__':
    resolve()
n = input()
num = []
num = input().split(" ")

t = 0 
 a=0 
 while True: 
     num2=[] 
     for i in num: 
         if not (int(i)%2): 
             a =1 
             break 
         num2.append(int(i)%2) 
     num = num2 
     t+=1 
     if a==1: 
         print(t) 
        break 

### FIXED CODE ###

n = input()
num = []
num = input().split(" ")
 
t = 0 
a=0 
while True: 
  num2=[] 
  for i in num: 
    if not int(i)%2==0:
      a =1
      break
    num2.append(int(i)/2)
  num = num2
  if a==1: 
     print(t) 
     break
  t+=1
S=input()
q=int(input())
s=[]
for i in S:
    s.append(i)
t=1
for i in range(q):
    qv=list(input().split())
    if qv[0]=='1':
        t^=1
    else:
        if int(qv[1])^t==0 or nt(qv[1])^t==2:
            s.insert(0,qv[2])
        else:
            s.append(qv[2])
            
if t==0:
    ss=s.copy()
    s=[]
    for j in range(len(ss)):
        s.append(ss[-1-j])
ans=''.join(s)
print(ans)

### FIXED CODE ###

S=input()
q=int(input())
s=[]
r=[]
for i in S:
    s.append(i)
t=1
for i in range(q):
    qv=list(input().split())
    if qv[0]=='1':
        t^=1
    else:
        if int(qv[1])^t==0 or int(qv[1])^t==2:
            r.append(qv[2])
        else:
            s.append(qv[2])
            
if t==0:
    ss=s.copy()
    s=[]
    for j in range(len(ss)):
        s.append(ss[-1-j])
    ans=s
    ans.extend(r)
else:
    rr=r.copy()
    r=[]
    for j in range(len(rr)):
        r.append(rr[-1-j])
    ans=r
    ans.extend(s)
answer=''.join(ans)
print(answer)
import sys
input = sys.stdin.readline()

'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, K = map(int, input().split())
S = list(input())
S = [int(i) for i in S]

L = [0]
R = [0]

for i in range(N):
	if S[i] == 0:
		if i == N - 1:
			L.append(i + 1)
		elif S[i + 1] == 1:
			L.append(i + 1)
	if S[N - i -1] == 0:
		if i == N - 1:
			R.append(i + 1)
		elif S[N - i -2] == 1:
			R.append(i + 1)

ans = 0
M = len(L) - K

if M <= 0:
	ans = N
	
for i in range(M):
	tmp = N - L[i] - R[M - i - 1]
	if tmp > ans:
		ans = tmp

print(ans)


### FIXED CODE ###

#import sys
#input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, K = map(int, input().split())
S = list(input())
S = [int(i) for i in S]

L = [0]
R = [0]

for i in range(N):
	if S[i] == 0:
		if i == N - 1:
			L.append(i + 1)
		elif S[i + 1] == 1:
			L.append(i + 1)
	if S[N - i -1] == 0:
		if i == N - 1:
			R.append(i + 1)
		elif S[N - i -2] == 1:
			R.append(i + 1)

ans = 0
M = len(L) - K

if M <= 0:
	ans = N
	
for i in range(M):
	tmp = N - L[i] - R[M - i - 1]
	if tmp > ans:
		ans = tmp

print(ans)
num = map(int, input().split())
seki = num[0] * num[1]
if seki % 2 == 0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

num1, num2 = map(int, input().split())
seki = num1 * num2
if seki % 2 == 0:
    print("Even")
else:
    print("Odd")
import heapq
n ,m = map(int,input().split())
arr =list(map(int,input().split()))
for _ in range(m):
  j = heapq.nlargest(1,arr)//2
  arr.remove(max(arr))
  arr.append(j)
print(sum(arr))
  
  


### FIXED CODE ###

from heapq import heappop, heappush, heapify
n, m = map(int, input().split())
a = list(map(int, input().split()))
q = []
for x in a:
	heappush(q, -x)
for _ in range(m):
	l = heappop(q)
	heappush(q, -((-l)//2))
print(-sum(q))
y = input().split()
y = [ int(x) for x in y]
y = y[1:]
sum_go = []
sum_back = []
for i in range(1, num):
    sum_go.append(sum(y[0:i] ))
    sum_back.append(sum(y[i:] ))
result = []
for i in range(len(sum_go)):
    result.append( abs(sum_go[i] - sum_back[i]) )
print(min(result))

### FIXED CODE ###

y = input()
y = input().split()
y = [ int(x) for x in y]
sum_go = []
sum_back = []
for i in range(1, len(y)):
    sum_go.append(sum(y[0:i] ))
    sum_back.append(sum(y[i:] ))
#print(sum_go)
#print(sum_back)
result = []
for i in range(len(sum_go)):
    result.append( abs(sum_go[i] - sum_back[i]) )
print(min(result))
h,w,k=map(int,input().split())
matrix=[]
for i in range(h):
	s=list(input())
	matrix.append(s)
hlist=[]
for i in range(h):
	hlist.append(i)
wlist=[]
for i in range(w):
	wlist.append(i)
rows=[]
cols=[]
for i in range(h+1):
	obj=itertools.combinations(hlist, i)
	rows+=list(obj)
for i in range(w+1):
	obj=itertools.combinations(wlist, i)
	cols+=list(obj)
ans=0
for i in rows:
	for j in cols:
		count=0
		for a in range(h):
			for b in range(w):
				if(matrix[a][b]=='#' and a not in i and b not in j):
					count+=1
		if(count==k):
			ans+=1
print(ans)

### FIXED CODE ###

import itertools

h,w,k=map(int,input().split())
matrix=[]
for i in range(h):
	s=list(input())
	matrix.append(s)
hlist=[]
for i in range(h):
	hlist.append(i)
wlist=[]
for i in range(w):
	wlist.append(i)
rows=[]
cols=[]
for i in range(h+1):
	obj=itertools.combinations(hlist, i)
	rows+=list(obj)
for i in range(w+1):
	obj=itertools.combinations(wlist, i)
	cols+=list(obj)
ans=0
for i in rows:
	for j in cols:
		count=0
		for a in range(h):
			for b in range(w):
				if(matrix[a][b]=='#' and a not in i and b not in j):
					count+=1
		if(count==k):
			ans+=1
print(ans)
a=[0,0]
s=[]
a[0],a[1],k=map(int,input().split())
for i in range(1,min(a)+1):
  if a[0]%i==0 and a[1]%i==0:
    s.append(i)
print(s[len(s)-k])

### FIXED CODE ###

import math
A,B,C=map(int,input().split())
can=math.floor(B/A)
if can>=C:
  print(C)
else:
  print(can)
s=input()
s2=list(s)
if s2[0]=="?" and s2[1]=="D":
    s2[0]="P"
elif s2[0]=="?" and (s2[1]=="P" or s2[1]=="?"):
    s2[0]="D"
if s2[-1]=="?":
    s2[-1]="D"
for i in range(1,len(s2)-1):
    if s2[i]=='?':
        if s2[i-1]=="D" and (s2[i+1]=="D" or s2[i+1]=="?"):
           s2[i]="P"
        else:
            s2[i]="D"
s1="".join(s2)
print(s1)

### FIXED CODE ###

s=input()
s2=list(s)
s1=""
if s2[-1]=="?":
    s2[-1]="D"
if s2[0]=="?" and s2[1]=="D":
    s2[0]="P"
elif s2[0]=="?" and (s2[1]=="P" or s2[1]=="?"):
    s2[0]="D"
for i in range(1,len(s2)-1):
    if s2[i]=='?':
        if s2[i-1]=="D" and (s2[i+1]=="D" or s2[i+1]=="?"):
           s2[i]="P"
        else:
            s2[i]="D"
for i in s2:
    s1+=i
print(s1)
c = []
for i in range(2):
	c.append(list(map(int, input().split())))

if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

c = []
for i in range(2):
	c.append(input())

if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
	print("YES")
else:
	print("NO")
n=int(input())
x=input()
s=list(x)
list=[]

for i in range(n):
    a=0;
    for j in range(i):
        for k in range(n-i):
            if s[j]==s[k+i-1]:
                a+=1
    list.append(a)

f=max(list)
print(f)


### FIXED CODE ###

a, b= map(int, input().split())
 
c=a+b
d=a-b
e=a*b
 
f=max([c, d, e])
 
print(f)
n=input().split( )
m=int(n[0])
c=int(n[1])
d=int(n[2])
n.sort()
print(m[0],c[1],d[2])


### FIXED CODE ###

n=list(map(int, input().split()))
n.sort()
print(n[0],n[1],n[2])
# -*- coding: utf-8 -*-
#グローバル変数
pn_list = {2:0,3:0}

def next_pn():
    npn = list(pn_list.keys())[-1] + 2
    pn_flg = 0
    while pn_flg == 0:
        for i in pn_list.keys():
            if npn % i > 0:
                pn_flg += 1
        if pn_flg == len(pn_list.keys()):
            break # 素数が見つかったらbreak
        else:
            npn += 2
            pn_flg = 0
    pn_list[npn] = 0
    return npn

def check_a(n,a):
    res = "ok"
    for i in range(n):
        if a[i] > 1:
            res = "notyet"
    return res

# 整数の入力
n = int(input())
s = input()
a = [int(x) for x in s.split()]
aa = [int(x) for x in s.split()]

#素数作成
sqr_max_a = int((1.0 * 10**6) ** 0.5) + 1
pn = 0
while pn < sqr_max_a:
    pn = next_pn()

for i in pn_list.keys():
    wareta = 1
    while wareta == 1:
        wareta = 0
        for j in range(len(a)):
            if a[j] % i == 0:
                a[j] = a[j] / i
                wareta = 1
        if wareta == 1:
            pn_list[i] += 1
    if check_a(n,a) == "ok":
        break

lcm = 1
for i in pn_list.keys():
    lcm = lcm * i ** pn_list[i]

min_bsum = 0
for i in aa:
    min_bsum += lcm / i

print(int(min_bsum % (10**9+7)))

### FIXED CODE ###

# -*- coding: utf-8 -*-
#グローバル変数
pn_list = [2,3]

def next_pn(pn):
    npn = pn + 2
    pn_flg = 0
    while pn_flg == 0:
        for i in pn_list:
            if npn % i == 0:
                break
            if (i ** 2) > npn:
                pn_flg = 1
                break
        if pn_flg == 1:
            break # 素数が見つかったらbreak
        else:
            npn += 2
    pn_list.append(npn)
    return npn

# 整数の入力
n = int(input())
s = input()
a = [int(x) for x in s.split()]
aa = [int(x) for x in s.split()]

#素数作成
sqr_max_a = int((1.0 * 10**6) ** 0.5) + 1
#sqr_max_a = int(1.0 * 10**6)
pn = 3
while pn < sqr_max_a:
    pn = next_pn(pn)

# a を素因数分解する
lcm = int(1)
for i in pn_list:
    wareta = 1
    while wareta == 1:
        wareta = 0
        for j in range(n):
            if a[j] % i == 0:
                a[j] = a[j] // i
                wareta = 1
        if wareta == 1:
            lcm = lcm * i
pn_lcm = []
for i in a:
    if i > 1:
        if i not in pn_lcm:
            pn_lcm.append(i)
            lcm = lcm * i

min_bsum = int(0)
for i in aa:
    min_bsum = min_bsum + lcm // i

print(min_bsum % (10**9+7))
s = str(input())
t = str(input())
s_l =[]
for i in range(len(s)):
    s_l.append(s[i])

a = len(s) - len(t)

while a >= 0:
    insert = False
    string = True
    i = 0
    while i < len(t):
        if s[a + i] != "?" and s[a + i] != t[i]:
            string = False
            break
        i += 1
        
    if string == True:
        for i in range(len(t)):
                s_l[a+i] = t[i]
        insert = True
        break
    a -= 1

f = ""
if insert == True:
    for i in range(len(s)):
        if s_l[i] == "?":
            f += "a"
        else:
            f += s_l[i]
    print(f)
else:
    print("UNRESTORABLE")

### FIXED CODE ###

s = str(input())
t = str(input())
s_l =[]
for i in range(len(s)):
    s_l.append(s[i])

if len(s) < len(t):
    print("UNRESTORABLE")
    exit()

a = len(s) - len(t)

while a >= 0:
    insert = False
    string = True
    i = 0
    while i < len(t):
        if s[a + i] != "?" and s[a + i] != t[i]:
            string = False
            break
        i += 1
        
    if string == True:
        for i in range(len(t)):
                s_l[a+i] = t[i]
        insert = True
        break
    a -= 1

f = ""
if insert == True:
    for i in range(len(s)):
        if s_l[i] == "?":
            f += "a"
        else:
            f += s_l[i]
    print(f)
else:
    print("UNRESTORABLE")
a, b = map(int, input().split())
print(int(math.log10(a + b)) + 1)


### FIXED CODE ###

while True:
	try:
		a, b = map(int, input().split())
		print(len(str(a+b)))
	except:
		break
n = int(input())
a = list(range(n,0,-1))
print(sum(a)-a[0])

### FIXED CODE ###

n = int(input())
print((n*(n-1))//2)
n=int(input().split())
a=[0]*n
b=list(map(input().split()))
a[0]=b[0]
a[n-1]=b[n-2]

for i in range(1,n):
  a[i]=min(b[i-1],b[i])

print(sum(a))  
  

### FIXED CODE ###

n=int(input())
a=[0]*n
b=list(map(int,input().split()))
a[0]=b[0]
a[n-1]=b[n-2]
ans=0

for i in range(1,n-1):
  a[i]=min(b[i-1],b[i])

print(sum(a))
import math
n,m = map(int,input().split())
l = list(map(int,input().split()))
lcm = 1
lcm_harf = 1
for i in l:
    lcm = lcm*i//math.gcd(lcm,i)
    lcm_harf = lcm_harf*i//2//math.gcd(lcm_harf,i//2)
print(m//lcm_harf-m//lcm)

### FIXED CODE ###

def culuc(a):
    cnt = 0
    while a%2==0:
        a//=2
        cnt+=1
    return cnt
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)
n,m = map(int,input().split())
a = list(map(int,input().split()))
cnt = culuc(a[0])
for i in a:
    if culuc(i)!=cnt:
        print(0)
        exit()
res = a[0]//2
for i in a:
    res = lcm(res,i//2)
    if res>m:
        print(0)
        exit()
print((m//res+1)//2)
weeks = {'MON': '1', 'TUE': '2',
    ...: 'WED': '3', 'THU': '4',
    ...: 'FRI': '5', 'SAT': '6',
    ...: 'SUN': '0'^M
    ...: }
    ...: S = input('')
    ...: print(7-int(weeks.get(S)))

### FIXED CODE ###

weeks = {'MON': '1', 'TUE': '2', 'WED': '3', 'THU': '4', 'FRI': '5', 'SAT': '6', 'SUN': '0'}
s = input()
print(7-int(weeks.get(s)))
b=[1]*1000000
for i in range(3,1000,2):
 if b[i//2]:b[i*i//2::i]=[0]*len(b[i*i//2::i])
print(sum(b[int(input())]for _ in[0]*int(input())))


### FIXED CODE ###

b=[1]*500000
for i in range(3,999,2):
 if b[i//2]:b[i*i//2::i]=[0]*len(b[i*i//2::i])
def p(x):
 if x<5*1e5:return b[x]
 x=2*x+1
 for i in range(3,int(x**.5+1),2):
  if x%i==0:return 0
 return 1
print(sum(p(int(input()))for _ in[0]*int(input())))
import math

A, B, C, D = list(map(int, input().split()))
C_mult = (B // C) - ((A-1) // C)
D_mult = (B // D) - ((A-1) // D)

E = C * D // math.gcd(C, D)

inter = (B // E) - ((A-1) // E)
whole = B - A + 1
print(whole - C_mult - D_mult + inter)

### FIXED CODE ###

import fractions

A, B, C, D = list(map(int, input().split()))
C_mult = (B // C) - ((A-1) // C)
D_mult = (B // D) - ((A-1) // D)

E = C * D // fractions.gcd(C, D)

inter = (B // E) - ((A-1) // E)
whole = B - A + 1
print(whole - C_mult - D_mult + inter)
S = input()
Q = int(input())

buf = [0] * (3*(10**5)+10)
for i, s in enumerate(S):
    buf[i] = s

is_reverse = False
first = 0
last = len(S) - 1

def add_top(c):
    global buf
    global first
    if is_reverse:
        first += 1
    else:
        first -= 1
    buf[first] = c

def add_tail(c):
    global buf
    global last
    if is_reverse:
        last -= 1
    else:
        last += 1
    buf[last] = c

for i in range(Q):
    Query = input().split()
    t = int(Query[0])
    if t == 1:
        is_reverse = not is_reverse
        first, last = last, first
    else:
        f = int(Query[1])
        c = Query[2]
        if f == 1:
            add_top(c)
        else:
            add_tail(c)

ans = ''
#print(is_reverse, first, last)
#print(buf[first])
#print(buf[last])
if is_reverse:
    l = list(reversed(buf[:first+1]))
    #print(l)
    l[len(l):] = list(reversed(buf[last:]))
    #print(l)
    #ans = ''.join(buf[last:first+1:-1])
    ans = ''.join(l)
else:
    l = buf[first:]
    #print(l)
    l[len(l):] = buf[:last+1]
    #print(l)
    #ans = ''.join(buf[first:last+1])
    ans = ''.join(l)
print(ans) 


### FIXED CODE ###

S = input()
Q = int(input())

buf = [0] * (3*(10**5)+10)
for i, s in enumerate(S):
    buf[i] = s

is_reverse = False
first = 0
last = len(S) - 1

def add_top(c):
    global buf
    global first
    if is_reverse:
        first += 1
    else:
        first -= 1
    buf[first] = c

def add_tail(c):
    global buf
    global last
    if is_reverse:
        last -= 1
    else:
        last += 1
    buf[last] = c

for i in range(Q):
    Query = input().split()
    t = int(Query[0])
    if t == 1:
        is_reverse = not is_reverse
        first, last = last, first
    else:
        f = int(Query[1])
        c = Query[2]
        if f == 1:
            add_top(c)
        else:
            add_tail(c)

ans_list = []
p = first
while True:
    ans_list.append(buf[p])
    if p == last:
        break
    if is_reverse:
        p -= 1
    else:
        p += 1
ans = ''.join(ans_list)
print(ans)