peterverebics/CodeNet_Python_428 huggingface dataset:
# 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 = list(map(int, input().split()))
a.sort(reverse=True)

num_lcm = lcm(*a)
lst = [num_lcm//a_i for a_i in a]

for i in lst:
    if i % 2 == 0:
        print(0)
        exit()

harf_lcm = num_lcm // 2
if m < harf_lcm:
    print(0)
else:
    print(1+(m-harf_lcm)//num_lcm)
# Judge status: Accepted
import sys
readline = sys.stdin.readline
from collections import Counter

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    A1 = [i + a for i, a in enumerate(A)]
    A2 = [i - a for i, a in enumerate(A)]
    c1 = Counter(A1)
    c2 = Counter(A2)
    c2_keys = c2.keys()
    ans = 0
    for key, val in c1.items():
        if key in c2_keys:
            ans += val * c2[key]

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
T,A = (int(X) for X in input().split())
H = [int(X) for X in input().split()]
MIN = pow(10,9)
MII = 0
for X in range(0,N):
    Diff = abs(A-(T-0.006*H[X]))
    if Diff<MIN:
        MIN = Diff
        MII = X+1
print(MII)
# Judge status: Accepted
n=int(input())
s=0
for i in range(1,n+1):
  if(i%3!=0):
    if(i%5):
      s+=i
    
print(s)
# Judge status: Accepted
a = list(map(int, input().split()))
n = int(input())
if n >= 2:
    if n % 2 == 0:
        print(int((n//2)*min(a[0]*8, a[1]*4, a[2]*2, a[3])))
    else:
        print(int((n//2)*min(a[0]*8, a[1]*4, a[2]*2, a[3])+min(a[0]*4, a[1]*2, a[2])))
else:
    print(min(a[0]*4, a[1]*2, a[2]))
# Judge status: Accepted
import numpy as np
N,M,X = map(int,input().split())
C = []
A = []
for _ in range(N):
    l = list(map(int,input().split()))
    C.append(l[0])
    A.append(np.array(l[1:]))
ans = 10**100
for i in range(2**N):
    rikaido = np.zeros(M)
    c = 0
    for j in range(N):
        if (i >> j) & 1:
            c += C[j]
            rikaido += A[j]
    if all([x >= X for x in rikaido]):
        ans = min(ans, c)
print(ans if ans != 10**100 else -1)
# Judge status: Accepted
a=input()
N=len(a)
count=0
bonus=0
for i in range(N-1,-1,-1):
    if int(a[i])+bonus>=6 or (int(a[i])+bonus==5 and (i!=0 and int(a[i-1])>=5)):
        count+=(10-int(a[i])-bonus)
        if i!=0:
            bonus=1
        else:
            count+=1
    else:
        count+=int(a[i])+bonus
        bonus=0
print(count)
# Judge status: Accepted
letter=input()
def isKaibun(s):
  res = True
  for i in range(int((len(s))/2)):
    if s[i] != s[-1-i]:
      res = False
      break
  return res
if isKaibun(letter[0:int((len(letter)-1)/2)]):
  if isKaibun(letter[int((len(letter)+3)/2-1):]):
    if isKaibun(letter):
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
import math

n = input().split(" ")
h = int(n[0])
a = int(n[1])

def main(health, attack):
    total = health / attack
    return math.ceil(total)


if __name__ == '__main__':
    main(h, a)
# Judge status: Wrong Answer
N = int(input('整数を入力してね>'))
X = int(800 * N)
Y = int((N/15)*200)
print(X - Y)
# Judge status: Accepted
import sys
input=sys.stdin.readline
n=int(input())
h=tuple(map(int,input().split()))

dp=[0]*n
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))

print(dp[-1])
# Judge status: Accepted
import sys
from collections import defaultdict
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,k = map(int, input().split())
p = list(map(int, input().split()))

d = defaultdict(float)
for i in range(1, 1001):
    j = i
    while 0 < j:
        t = j * (1 / i)
        d[i] += t
        j -= 1

sum = [0.0]*(n+1)
for i in range(n):
    sum[i+1] = sum[i] + d[p[i]]

ans = 0
for i in range(k-1, n+1):
    tmp = sum[i] - sum[i-k]
    ans = max(ans,tmp)

print('{:.12f}'.format(ans))
# Judge status: Accepted
N,M = [int(i) for i in input().rstrip().split(' ')]
if N == M:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def resolve():
    N, K = map(int, input().split())
    print("0" if N%K == 0 else "1")
resolve()
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

v = 0
for x in a:
    if x == v + 1:
        v += 1
print(n - v) if v != 0 else print(-1)
# Judge status: Wrong Answer
import math

N, R = map(int, input().split())
X = math.log(N + 1, R)
Y = math.ceil(X)

print(Y)
# Judge status: Wrong Answer
import math
N = int(input())
ans = 0
A = [1 for i in range(N + 2)]
k = 2
A[1] = 0
while k <= math.sqrt(N):
    for i in range(k,N + 1,k):
        q = i
        p = 1
        while q % k == 0:
            q /= k
            p += 1
        A[i] *= p
    while A[k] != 1:
        k += 1
print(A)
for i in range(1,N + 1):
    if A[i] <= 1:
        A[i] += 1
    ans += i * A[i]
print(ans)
# Judge status: Accepted
N,k=map(int,input().split())
A=input()
ans=0
for i in range(0,N):
  if A[i]=='R' and i<N-1:
    if A[i+1]=='R':
      ans=ans+1
  if A[i]=='L' and i>0:
    if A[i-1]=='L':
      ans=ans+1
print(min(N-1,2*k+ans))
# Judge status: Accepted
n = int(input())
A = [0]*n
B = list(map(int,input().split()))

A[0] = B[0]
A[-1] = B[-1]
for i in range(1,n-1):
  A[i] = min(B[i-1],B[i])
print(sum(A))
# Judge status: Accepted
S = [[{"a": 0, "b": 1, "c": 2}[s] for s in input()[::-1]]for _ in range(3)]
T = {0: "A", 1: "B", 2: "C"}

c = 0
while 1:
    c = S[c].pop()
    if not S[c]:
        print(T[c])
        exit()
# Judge status: Wrong Answer
n,k = map(int,input().split())
N = list(range(1,n+1))
A = set()
count = 0
for i in range(k):
  d = int(input())
  Ad = list(map(int,input().split()))
  for j in range(d):
    A.add(Ad[j])

for i in range(n):
  if N[i] in A:
    count += 1
print(A)
print(n-count)
# Judge status: Accepted
import sys

k = int(input())

if k % 2 == 0 or k % 10 == 5:
    print(-1)
    sys.exit()
else:
    cnt = 1
    a = 0
    while(True):
        a = (a * 10 + 7) % k
        if a % k == 0:
            print(cnt)
            break

        if cnt > 1000000:
            print(-1)
            break

        cnt += 1
# Judge status: Wrong Answer
from collections import deque
n=int(input())
a=deque()
a=list(map(int,input().split()))
s=1
if a.count(0) == 0:
  for i in range(n):
    l=a.pop()
    s=s*l
  
    if len(str(s)) == 19 and i == n-1:
      lst=list(str(s))
      
  
    if len(str(s)) > 19:
      s=-1
      break

    
print(s)
# Judge status: Accepted
from functools import reduce

m, n = map(int, input().split())
mod = 10 ** 9 + 7


def ncr(p, k):
    if k == 0:
        return 1
    elif k < 0:
        return 0
    else:
        num = reduce(lambda x, y: x * y % mod, range(p, p - k, -1))
        den = reduce(lambda x, y: x * y % mod, range(1, k + 1))
        return num * pow(den, mod - 2, mod) % mod


if (m + n) % 3 != 0:
    print(0)
else:
    p = (m + n) // 3
    k = m - p
    print(ncr(p, k))
# Judge status: Wrong Answer
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
if k >= n:
    print(1)
    exit()
s = a.index(1)
left = s
right = n - (s + 1)
print(math.ceil(left / (k-1)) + math.ceil(right / (k-1)))
# Judge status: Accepted
N = int(input())
i = 1
while i**2 <= N:
  i +=1
print((i-1)**2)
# Judge status: Accepted
import sys

S = sys.stdin.readline().strip()

S = S[::-1]
i = 0
while i < len(S):
    if S[i:i+5] == "maerd":
        i += 5
    elif S[i:i+7] == "remaerd":
        i += 7
    elif S[i:i+5] == "esare":
        i += 5
    elif S[i:i+6] == "resare":
        i += 6
    else:
        break

if i == len(S):
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
a, b, c = input().split()

if a == b or a == c or b == c:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())
s = input()
cost = 0
bc = 0
for it in s:
    if it =="#":
        bc += 1
    else:
        if bc > 0:
            cost += 1
            bc -= 1
print(cost)
# Judge status: Accepted
s = input()
s_ls = [i for i in s]
count = 0
for i in range(len(s)-1):

    if s_ls[i] == s_ls[i+1]:
        count += 1
        if s_ls[i+1] == '1':
            s_ls[i+1] = '0'
        else:
            s_ls[i+1] = '1'
print(count)
# Judge status: Accepted
d = int(input())
ans = 'Christmas' + ' Eve' * (25 - d)
print(ans)
# Judge status: Wrong Answer
def main():
 n, r = map(int,input().split())
 if n >= 10:
     print(r)
 else:
     print(r + 100* (10 - r))
main()
# Judge status: Accepted
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)


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

N, M = map(int, input().split())
H = list(map(int, input().split()))
g = [list() for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

ans = 0
for i in range(N):
    good = True
    for j in g[i]:
        if H[i] <= H[j]:
            good = False

    ans += good

print(ans)
# Judge status: Wrong Answer
a, b, c = (input() for _ in range(3))
d = {"a": a, "b": b, "c": c}
nex = "a"

while len(d[nex]) != 0:
    tmp = d[nex][0]
    d[nex] = d[nex][1:]
    nex = tmp

print(nex)
# Judge status: Accepted
n,k,s = map(int, input().split())
if s<5:
    xx = 1 + s
else:
    for i in range(2,s):
        if s%i != 0:
            xx = i
            break
ans = [xx]* n
for i in range(k):
    ans[i] = s
print(' '.join(map(str, ans)))
# Judge status: Accepted
from collections import defaultdict
from collections import deque
from collections import Counter
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()

n,k,s = readInts()
for i in range(k):
	print(s, end=" ")
for i in range(n-k):
	print(min(10**9-1,s+1),end=" ")
print()
# Judge status: Accepted
import math

n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
  if n % i == 0:
    print(int(i + n / i - 2))
    break
# Judge status: Accepted
def main():
    a,b,c=map(int,input().split())
    sumi = set()
    for i in range(10**9):
        x = a*i%b
        if x in sumi:
            break
        elif x == c:
            print("YES")
            return
        else:
            sumi.add(x)
    print("NO")
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
N,K = map(int,input().split())
D = list(input().split())

while True:
  f = True
  for s in str(N):
    if s in D:
      f = False
  if f:
    print(str(N))
    break
  else:
    N+=1
# Judge status: Accepted

import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9+7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


x, y, z = mii()

print(z, x, y)
# Judge status: Accepted
xs,ys,xg,yg = map(int,input().split())

ans = ''
for i in range(yg-ys):
    ans += 'U'
for i in range(xg-xs):
    ans += 'R'

for i in range(yg-ys):
    ans += 'D'
for i in range(xg-xs + 1):
    ans += 'L'

for i in range(yg-ys+1):
    ans += 'U'
for i in range(xg-xs+1):
    ans += 'R'
ans += 'DR'

for i in range(yg-ys+1):
    ans += 'D'
for i in range(xg-xs + 1):
    ans += 'L'

ans += 'U'
print(ans)
# Judge status: Accepted
a, b, k = map(int, input().split())

t_fin = max(0, a - k)
a_fin = max(0, b - (k - (a - t_fin)))
print('{} {}'.format(t_fin, a_fin))
# Judge status: Accepted
import sys
input = sys.stdin.readline
A, B, C = map(int, input().split())
if A+B >= C:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
#!/usr/bin/env python3

import collections

S = input()
_set = set(S)

if len(_set) == 2 and S.count(S[0]) == 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]
nb = 0
da = 0
for i in range(len(A)-1):
    if A[i] > A[i+1] and da > 0:
        nb += 1
        da = 0
    elif A[i] < A[i+1] and da < 0:
        nb += 1
        da = 0
    else:
        if A[i+1] - A[i] != 0:
            da = A[i+1] - A[i]
print(nb + 1)
# Judge status: Wrong Answer
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if A*i + B*j + C*k == X:
        cnt +=1

print(cnt)
# Judge status: Accepted
n=int(input())
if n>=30:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a = list(input())
b = list(input())
if a == list(reversed(b)):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
s = input()
t = input()
ls = []
for i in range(len(s) - len(t) + 1):
    ls.append(s[i:i+len(t)])
now = 0
minimum = len(t)
for i in range(len(ls)):
    now = 0
    for j in range(len(t)):
        if t[j] == ls[i][j]:
            now += 1
    if len(t) - now < minimum:
        minimum = len(t) - now
print(minimum)
# Judge status: Accepted
k, n = map(int, input().split())
a = list(map(int, input().split()))
ans = []
for i in range(len(a)-1):
    ans.append(a[i+1]-a[i])
ans.append(k-a[-1]+a[0])
print(k-max(ans))
# Judge status: Wrong Answer
K = int(input())
if K % 2 == 0:
    ans = (K/2)**2
else:
    ans = (K//2)*(K//2+1)

print(ans)
# Judge status: Wrong Answer
# 077a

def atc_077a(input_value: str) -> str:
    C1 = input_value[0]
    C2 = input_value[1]

    if C1[0] == C2[2] and C1[1] == C2[1]:
        return "YES"
    else:
        return "NO"

C1 = input()
C2 = input()
print(atc_077a([C1,C2]))
# Judge status: Accepted
N, K = map(int, input().split())
d = {}
for x in map(int, input().split()):
    n = d.get(x, 0) + 1
    d[x] = n

cnt = len(d)
ret = 0
for k, v in sorted(d.items(), key=lambda item: item[1]):
    if K >= cnt:
        print(ret)
        exit()

    ret += v
    cnt -= 1
# Judge status: Accepted
N, X, Y = map(int, input().split())
ans = [0] + [0]*(N-1)

for i in range(1, N):
  for j in range(i+1, N+1):
    diff = min(j-i, abs(i-X)+abs(j-Y)+1)
    ans[diff] += 1

for i in range(1, N):
  print(ans[i])
# Judge status: Accepted
n = int(input())
S = ["".join(sorted(input())) for _ in range(n)]
counters = {}

for s in S:
    if s in counters:
        counters[s] += 1
    else:
        counters[s] = 1

ans = 0
for v in counters.values():
    if v == 1: continue
    ans += int(v * (v - 1) / 2)
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())

if m % n == 0:
    print(m//n)
else:
    a = m // n
    print(m % a)
# Judge status: Wrong Answer
import sys
read = sys.stdin.read
from math import gcd
def main():
    n, *a = map(int, read().split())
    l = [0] * (n + 1)
    for i1 in range(n):
        l[i1 + 1] = gcd(l[i1], a[i1])
    r = [0] * (n + 1)
    for j1 in range(n - 1, -1, -1):
        r[j1] = gcd(r[j1 + 1], a[j1])
    m = [0] * (n + 1)
    for k1 in range(n - 1):
        m[k1] = gcd(l[k1], r[k1 + 1])
    r = max(m)
    print(r)

if __name__ == '__main__':
    main()
# Judge status: Accepted
N, M = list(map(int, input().split()))
paths = [list(map(int, input().split())) for _ in range(M)]

roads = {i : 0 for i in range(N)}
for path in paths:
  roads[path[0]-1] +=1
  roads[path[1]-1] +=1

for i in range(N):
  print(roads[i])
# Judge status: Wrong Answer
import sys
import math
x=int(input())
if not ( 1 <= x <= 10**15 ): sys.exit()

print(1) if x <= 6 else print(math.ceil((x/11)*2))
# Judge status: Accepted
from itertools import chain, groupby


def flatten(list_of_lists):
    return chain.from_iterable(list_of_lists)


def all_equal(iterable):
    g = groupby(iterable)
    return next(g, True) and not next(g, False)


C = [list(map(int, input().split())) for _ in range(3)]
s = sum(flatten(C))

x = all_equal([C[1][i] - C[0][i] for i in range(3)])
y = all_equal([C[2][i] - C[0][i] for i in range(3)])
z = all_equal([C[2][i] - C[1][i] for i in range(3)])

if all((x, y, z)) and s % 3 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n, x= input().split()
n, x= int(n), int(x)
lista=[]
sum=0

for x in input().split():
	x= int(x)
	lista.append(x)

cont=1
for i in range(n):
	sum+=lista[i]
	if sum <= x:
		cont+=1
print(cont)
# Judge status: Accepted
N,D = map(int,input().split())

d = D * 2 + 1
if(N%d == 0):
    print(N//d)
else:
    print(N//d+1)
# Judge status: Wrong Answer
X = [int(i) for i in input().split()]
for c, x in enumerate(X):
  if x == 0:
  	print(c)
# Judge status: Accepted
from collections import deque
K = int(input())
q = deque([0])

cnt = 0
ans = []
while q:
  a = q.popleft()
  r = a % 10
  a *= 10
  for i in range(10):
    if abs(r - i) <= 1 or a == 0:
      if cnt < K and a + i != 0:
        q.append(a + i)
        ans.append(a + i)
        cnt += 1

print(ans[-1])
# Judge status: Wrong Answer
day = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

print(day[(day.index(input())+1)%7])
# Judge status: Accepted
n = int(input())

ans = 1

while ans*2 <= n:
    ans *= 2
print(ans)
# Judge status: Accepted
X, Y = map(int, input().split())

if X == Y or X % Y == 0:
  print(-1)
else:
  start = X
  while start % Y == 0:
    start += X
  print(start)
# Judge status: Accepted
N = int(input())
a_list = list(map(int, input().split()))
r2 = 0
r4 = 0
for i in range(N):
    if a_list[i]%2==0:
        r2 += 1
    if a_list[i]%4==0:
        r4 += 1
r2 -= r4
r0 = N - r2 - r4
if N % 2==0:
    print("Yes") if r4 >= r0 else print("No")
else:
    print("Yes") if r4 >= r0-1 else print("No")
# Judge status: Accepted
import sys, heapq

K, X =map(int, input().split())

for i in range(X - K + 1, X + K):
    print(i, end=" ")

print("")
# Judge status: Accepted
import numpy as np

l,l2 = map(int,input().split())
x = np.array(list(map(int,input().split())))

dp = np.zeros(l,dtype=int)
dp[1] = abs(x[0]-x[1])

for i in range(2,l):
    y = max(i - l2,0)
    dp[i] = np.min(dp[y:i] + abs(x[y:i] - x[i]))
    
print(dp[-1])
# Judge status: Accepted
N,M = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(N)]

import heapq
h = []
ans = 0
L.sort()
m = 1
i = 0
while i < N and L[i][0] <= M:
    if L[i][0] == m:
        heapq.heappush(h, -L[i][1])
        i += 1
    else:
        m += 1
        if h:
            ans -= heapq.heappop(h)
while m <= M and h:
    ans -= heapq.heappop(h)
    m += 1
print(ans)
# Judge status: Accepted
N,M = map(int,input().split())
X= list(map(int,input().split()))
X.sort()
distance =[0]*(M-1)
for i in range(M-1):
    distance[i] = X[i+1]-X[i]

d_sum = sum(distance)
distance.sort()
if N>=M:
    d_sum = 0

elif N !=1:
    for i in range(N-1):
        d_sum-=distance[(M-2)-i]

print(d_sum)
# Judge status: Accepted
N,L=map(int,input().split())
left=L
right=left+N-1
if right<=0:eated=right
elif 0<left:eated=left
else:eated=0
print((left+right)*(right-left+1)//2-eated)
# Judge status: Accepted
a,b=map(int,input().split())
a=(a+11)%13
b=(b+11)%13
if a>b:
  print("Alice")
elif a<b:
  print("Bob")
else:
  print("Draw")
# Judge status: Accepted
x=input()
if x[0] == "7" or x[1] == "7" or x[2] == "7":
    print("Yes")
else:
    print("No")
# Judge status: Accepted
A,B,N = map(int,input().split())

if N<= B-1:
    ans = (N*A)//B
else:
    ans = ((B-1)*A)//B
    
print(ans)
# Judge status: Accepted
from collections import Counter as co
s=co(input())
if all([i==2 for i in s.values()]) and len(s.keys())==2:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
d = int(input())
print('Christmas' + ' Eve' * (25 - d))
# Judge status: Wrong Answer
s = input()
k = int(input())


ans = []
for c in s[:-1]:
    to_a = ord('z')-ord(c)+1
    if k < to_a:
        ans.append(c)
    else:
        k -= to_a
        ans.append('a')
else:
    c = s[-1]
    x = ord(c)-ord('a')
    ans.append(chr(ord('a')+(k+x) % 26))


print(''.join(ans))
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M, *A = map(int, read().split())
 
MOD = 10**9 + 7
 
dp = [0] * (N + 10)
dp[0] = 1
is_broken = [False] * (N + 1)
 
for x in A:
    is_broken[x] = True
 
for n in range(1, N + 1):
    if is_broken[n]:
        continue
    x = dp[n - 1] + dp[n - 2]
    if x >= MOD:
        x -= MOD
    dp[n] = x
 
answer = dp[N]
print(answer)
# Judge status: Accepted
s = input()
q_number = int(input())
reverse_flag = 1
head = ""
tail = ""
for i in range(q_number):
  temp = input().split()
  if temp[0] == "1": 
    reverse_flag = reverse_flag * -1
  else:
    headstails = int(temp[1])*reverse_flag 
    if headstails == 1 or headstails == -2:
      head = temp[2] + head
    else:
      tail = tail + temp[2]
      
if reverse_flag == 1:
  print(head+s+tail)
else:
  print(tail[::-1]+s[::-1]+head[::-1])
# Judge status: Wrong Answer
N = int(input())

if N//111 == 0:
  print(N)
else:
  print((N//111 + 1) * 111)
# Judge status: Wrong Answer
n=int(input())
ans=0
if n % 2==0:
    for i in range(1,19):
        waru = 2*5**i
        if n < waru:
            break
        else:
            tmp = n/waru
            ans += int(tmp)
print(str(ans))
# Judge status: Accepted
import math
x = int(input())

while True:
    for i in range(2, int(math.sqrt(x)+1)):
        if x % i == 0:
            x += 1
            break
    else:
        break
print(x)
# Judge status: Accepted
A, B, C = map(int, input().split())
print(max(C-A+B,0))
# Judge status: Accepted
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[]
for i in p:
  t=(1+i)
  s.append(t)
  
t=[0,]
for i in range(n):
  u=t[i]+s[i]
  t.append(u)

ans=0
for i in range(n-k+1):
  ans=max(ans,t[i+k]-t[i])
  

print('{:.10f}'.format(ans/2))
# Judge status: Accepted
N,X,T = map(int,input().split())
if N%X == 0:
  a = N//X
else:
  a = N//X + 1
print(a*T)
# Judge status: Accepted
s=input().split()
print("YES" if s.count("5")==2 and s.count("7")==1 else "NO")
# Judge status: Wrong Answer
n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
max_a = max(a)
b.sort(reverse=True)
cnt = 0
for i in range(n):
    if b[i] < max_a:
        break
    h -= b[i]
    cnt += 1
    if h <= 0:
        break
cnt += (h - 1) // max_a + 1
print(cnt)
# Judge status: Wrong Answer
N = int(input())

A=[]
for i in range(N):
    A.append(int(input()))

B = [0]*N
B[0] = A[0]
for i in range(1, N):
    B[i] += B[i-1]+A[i]

B.sort(reverse=True) 

for i in B:
    if i%10 != 0:
        print(i)
        break
else:
    print(0)
# Judge status: Accepted
s,t = map(str, input().split())
print(t+s)
# Judge status: Accepted
a, b=map(int, input().split())

if a%3==0 or b%3==0 or (a+b)%3==0:
  print('Possible')
else:
  print('Impossible')
# Judge status: Wrong Answer
n,k = map(int,input().split())
d = {}
for i in range(n):
  a,b = map(int,input().split())
  if a in d:
    d[a] += b
  else:
    d[a] = b
cnt = 0
for i,j in enumerate(d.values()):
  cnt += j
  if cnt >= k:
    print(list(d.keys())[i])
    break
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

count = 0
for i in range(1, N+1, 2):
    if A[i-1]%2 == 1:
        count += 1
print(count)
# Judge status: Wrong Answer
x, a, b = map(int, input().split())
print("A" if abs(x-a) > abs(x-b) else "B")
# Judge status: Accepted
d,t,s = map(int,input().split())

print("Yes" if s*t>=d else "No")
# Judge status: Wrong Answer

n=input()
ans=0
i=0
b=list(map(int,input().split()))
print(b)
print(type(b[0]))
end=True
while end:
    b=list(map(lambda x:x/2,b))
    print(b)
    ans+=1
    for x in b:
        if x%2!=0:
            print(ans)
            end=False
            break
# Judge status: Accepted
n = int(input())

amari = []

while True:
    if n >1 or n<0:
        amari.append(-(n%(-2)))
        n = (n-(-(n%(-2))))//(-2)
    else:
        amari.append(n)
        break

gyaku = amari[::-1]
print(*gyaku,sep="")
# Judge status: Accepted
s = input()
if s == "ARC":
  print("ABC")
else:
  print("ARC")