Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

H,W = list(map(int,input().split()))

N = int(eval(input()))

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

A.insert(0,0)

C = [[0 for _ in range(W)] for _ in range(H)]

cur = [0,0,"R"]

for k in range(1,N+1):

#     ipdb.set_trace()

    a = A[k]

    cnt = 0

    y,x,d = cur

    for i in range(y,H):

        y = i

        if d=="R":

            for j in range(x,W):

                C[i][j]=str(k)

                cnt += 1

                if j+1<W:

                    x = j+1

                else:

                    x = j

                if cnt==a:break

            if cnt==a:break

            d="L"

        else:

            for j in range(x,-1,-1):

                C[i][j]=str(k)

                cnt += 1

                if j>=1:

                    x = j-1

                else:

                    x = 0

                if cnt==a:break

            if cnt==a:break

            d="R"

    if x==W-1:

        if C[y][x]!=0:

            y += 1

            d="L"

    elif x==0:

        if C[y][x]!=0:

            y += 1

            d="R"

    cur = [y,x,d]

for i in range(H):

    print((*C[i]))

# optimized version of the same code:

H,W = list(map(int,input().split()))

N = int(eval(input()))

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

A.insert(0,0)

B = [[0 for _ in range(W)] for _ in range(H)]

col = 1

cnt = 0

y = 0

x = 0

d = "R"

while y<H:

    if cnt<A[col]:

        B[y][x] = col

        cnt += 1

    else:

        col += 1

        cnt = 0

        B[y][x] = col

        cnt += 1

    if x<W-1 and d=="R":

        x += 1

    elif x==W-1 and d=="R":

        y += 1

        d = "L"

    elif d=="L" and x>0:

        x -= 1

    elif d=="L" and x==0:

        y += 1

        d = "R"

for i in range(H):

    print((*B[i]))

H, W = list(map(int, input().split()))
N = int(eval(input()))
A = list(map(int, input().split()))
A.insert(0, 0)
C = [[0 for _ in range(W)] for _ in range(H)]
cur = [0, 0, "R"]
for k in range(1, N + 1):
    #     ipdb.set_trace()
    a = A[k]
    cnt = 0
    y, x, d = cur
    for i in range(y, H):
        y = i
        if d == "R":
            for j in range(x, W):
                C[i][j] = str(k)
                cnt += 1
                if j + 1 < W:
                    x = j + 1
                else:
                    x = j
                if cnt == a:
                    break
            if cnt == a:
                break
            d = "L"
        else:
            for j in range(x, -1, -1):
                C[i][j] = str(k)
                cnt += 1
                if j >= 1:
                    x = j - 1
                else:
                    x = 0
                if cnt == a:
                    break
            if cnt == a:
                break
            d = "R"
    if x == W - 1:
        if C[y][x] != 0:
            y += 1
            d = "L"
    elif x == 0:
        if C[y][x] != 0:
            y += 1
            d = "R"
    cur = [y, x, d]
for i in range(H):
    print((*C[i]))

H, W = list(map(int, input().split()))
N = int(eval(input()))
A = list(map(int, input().split()))
A.insert(0, 0)
B = [[0 for _ in range(W)] for _ in range(H)]
col = 1
cnt = 0
y = 0
x = 0
d = "R"
while y < H:
    if cnt < A[col]:
        B[y][x] = col
        cnt += 1
    else:
        col += 1
        cnt = 0
        B[y][x] = col
        cnt += 1
    if x < W - 1 and d == "R":
        x += 1
    elif x == W - 1 and d == "R":
        y += 1
        d = "L"
    elif d == "L" and x > 0:
        x -= 1
    elif d == "L" and x == 0:
        y += 1
        d = "R"
for i in range(H):
    print((*B[i]))

-C = [[0 for _ in range(W)] for _ in range(H)]

+B = [[0 for _ in range(W)] for _ in range(H)]


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import numpy as np

temp=list(map(int, input().split()))

N=temp[0]

X=temp[1]

L=list(map(int, input().split()))

ind=1

while np.sum(L[:ind])<=X and ind<=N:

  ind+=1

print(ind)

# optimized version of the same code:

N, X=list(map(int, input().split()))

L=list(map(int, input().split()))

L=[0]+L

l=int(0)

counter=int(0)

while l+L[counter]<=X and counter<=N:

  l+=L[counter]

  counter+=int(1)

  if counter==N+1:

    break

print(counter)

import numpy as np

temp = list(map(int, input().split()))
N = temp[0]
X = temp[1]
L = list(map(int, input().split()))
ind = 1
while np.sum(L[:ind]) <= X and ind <= N:
    ind += 1
print(ind)

N, X = list(map(int, input().split()))
L = list(map(int, input().split()))
L = [0] + L
l = int(0)
counter = int(0)
while l + L[counter] <= X and counter <= N:
    l += L[counter]
    counter += int(1)
    if counter == N + 1:
        break
print(counter)

-while np.sum(L[:ind]) <= X and ind <= N:

+while l + L[counter] <= X and counter <= N:


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import copy

import numpy as np

S = eval(input())

N = int(S)

S = eval(input())

P = list(map(int, S.split()))

check = []

count = 0

for i in range(0, N-2, 1):

    check = P[i:i+3]

    check = np.array(check)

    check = check.argsort()

    if check[1] == 1:

        count = count + 1

print(count)

# optimized version of the same code:

n = int(eval(input()))

P = list(map(int, input().split()))

count = 0

for i in range(n-2):

    P_temp = [P[i], P[i+1], P[i+2]]

    P_temp.sort()

    if P_temp[1] == P[i+1]:

        count = count + 1

print(count)

import copy
import numpy as np

S = eval(input())
N = int(S)
S = eval(input())
P = list(map(int, S.split()))
check = []
count = 0
for i in range(0, N - 2, 1):
    check = P[i : i + 3]
    check = np.array(check)
    check = check.argsort()
    if check[1] == 1:
        count = count + 1
print(count)

n = int(eval(input()))
P = list(map(int, input().split()))
count = 0
for i in range(n - 2):
    P_temp = [P[i], P[i + 1], P[i + 2]]
    P_temp.sort()
    if P_temp[1] == P[i + 1]:
        count = count + 1
print(count)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import heapq

K=int(eval(input()))

dist=[10**15 for i in range(K)]

dist[1]=1

q=[]

heapq.heappush(q,(0,1))

while (len(q)!=0):

    prc,src=heapq.heappop(q)

    if dist[src]<prc:

        continue

    if dist[(src+1)%K]>dist[src]+1:

        dist[(src+1)%K]=dist[src]+1

        heapq.heappush(q,(dist[(src+1)%K],(src+1)%K))

    if dist[(10*src)%K]>dist[src]:

        dist[(10*src)%K]=dist[src]

        heapq.heappush(q,(dist[(src*10)%K],(src*10)%K))

print((dist[0]))

# optimized version of the same code:

from collections import deque

K=int(eval(input()))

dist=[10**15 for i in range(K)]

dist[1]=1

q=deque([1])

while(len(q)>0):

    r=q.popleft()

    s=(r+1)%K

    if dist[r]+1<dist[s]:

        dist[s]=dist[r]+1

        q.append(s)

    t=(r*10)%K

    if dist[r]<dist[t]:

        dist[t]=dist[r]

        q.appendleft(t)

print((dist[0]))

import heapq

K = int(eval(input()))
dist = [10**15 for i in range(K)]
dist[1] = 1
q = []
heapq.heappush(q, (0, 1))
while len(q) != 0:
    prc, src = heapq.heappop(q)
    if dist[src] < prc:
        continue
    if dist[(src + 1) % K] > dist[src] + 1:
        dist[(src + 1) % K] = dist[src] + 1
        heapq.heappush(q, (dist[(src + 1) % K], (src + 1) % K))
    if dist[(10 * src) % K] > dist[src]:
        dist[(10 * src) % K] = dist[src]
        heapq.heappush(q, (dist[(src * 10) % K], (src * 10) % K))
print((dist[0]))

from collections import deque

K = int(eval(input()))
dist = [10**15 for i in range(K)]
dist[1] = 1
q = deque([1])
while len(q) > 0:
    r = q.popleft()
    s = (r + 1) % K
    if dist[r] + 1 < dist[s]:
        dist[s] = dist[r] + 1
        q.append(s)
    t = (r * 10) % K
    if dist[r] < dist[t]:
        dist[t] = dist[r]
        q.appendleft(t)
print((dist[0]))

-    if dist[(src + 1) % K] > dist[src] + 1:

-        dist[(src + 1) % K] = dist[src] + 1

-        heapq.heappush(q, (dist[(src + 1) % K], (src + 1) % K))

-    if dist[(10 * src) % K] > dist[src]:

-        dist[(10 * src) % K] = dist[src]

-        heapq.heappush(q, (dist[(src * 10) % K], (src * 10) % K))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import numpy as np

N,L = list(map(int, input().split()))

taste = np.array([L+i-1 for i in range(1,N+1)])

if taste[-1] < 0:

  print((sum(taste) + min(np.abs(taste))))

else:

  print((sum(taste) - min(np.abs(taste))))

# optimized version of the same code:

N,L = list(map(int, input().split()))

taste = [L+i-1 for i in range(1,N+1)]

if taste[-1] < 0:

  print((sum(taste) + min([abs(x) for x in taste])))

else:

  print((sum(taste) - min([abs(x) for x in taste])))

import numpy as np

N, L = list(map(int, input().split()))
taste = np.array([L + i - 1 for i in range(1, N + 1)])
if taste[-1] < 0:
    print((sum(taste) + min(np.abs(taste))))
else:
    print((sum(taste) - min(np.abs(taste))))

N, L = list(map(int, input().split()))
taste = [L + i - 1 for i in range(1, N + 1)]
if taste[-1] < 0:
    print((sum(taste) + min([abs(x) for x in taste])))
else:
    print((sum(taste) - min([abs(x) for x in taste])))

-taste = np.array([L + i - 1 for i in range(1, N + 1)])

+taste = [L + i - 1 for i in range(1, N + 1)]

-    print((sum(taste) + min(np.abs(taste))))

+    print((sum(taste) + min([abs(x) for x in taste])))

-    print((sum(taste) - min(np.abs(taste))))

+    print((sum(taste) - min([abs(x) for x in taste])))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

from collections import Counter,defaultdict,deque

import sys,heapq,bisect,math,itertools,string,queue

sys.setrecursionlimit(10**8)

mod = 10**9+7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()

a = inpl()

aa = []

for i in range(n):

    aa.append([i+1,a[i]])

aa.sort(key=lambda x:x[1])

for i in range(n):

    print((aa[i][0]))

# optimized version of the same code:

from collections import Counter,defaultdict,deque

from heapq import heappop,heappush

from bisect import bisect_left,bisect_right

import sys,math,itertools,fractions

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()

a = inpl()

res = [0] * n

for i,x in enumerate(a):

    res[x-1] = i+1

print((*res))

from collections import Counter, defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue

sys.setrecursionlimit(10**8)
mod = 10**9 + 7

def inp():
    return int(sys.stdin.readline())

def inpl():
    return list(map(int, sys.stdin.readline().split()))

def inpl_str():
    return list(sys.stdin.readline().split())

def inpln(n):
    return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
aa = []
for i in range(n):
    aa.append([i + 1, a[i]])
aa.sort(key=lambda x: x[1])
for i in range(n):
    print((aa[i][0]))

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
import sys, math, itertools, fractions

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")

def inp():
    return int(sys.stdin.readline())

def inpl():
    return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
res = [0] * n
for i, x in enumerate(a):
    res[x - 1] = i + 1
print((*res))

-import sys, heapq, bisect, math, itertools, string, queue

+from bisect import bisect_left, bisect_right

-    return list(sys.stdin.readline().split())

-    return list(int(sys.stdin.readline()) for i in range(n))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

a, b, c, x, y = list(map(int, input().split()))

ans = float('inf')

for i in range(2 * 10**5 + 1):

    ans = min(ans, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i)

print(ans)

# optimized version of the same code:

A,B,C,X,Y = list(map(int,input().split()))

min_xy = min(X,Y)

max_xy = max(X,Y)

ans1 = 2 * C * min_xy + A * (X-min_xy) + B * (Y-min_xy) # 無駄にならない範囲でABピザを買い、残りを買う

ans2 = A*X + B*Y # ABピザを買わない

ans3 = 2 * C * max_xy # ABピザだけを買う

print((min(ans1,ans2,ans3)))

a, b, c, x, y = list(map(int, input().split()))
ans = float("inf")
for i in range(2 * 10**5 + 1):
    ans = min(ans, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i)
print(ans)

A, B, C, X, Y = list(map(int, input().split()))
min_xy = min(X, Y)
max_xy = max(X, Y)
ans1 = 2 * C * min_xy + A * (X - min_xy) + B * (Y - min_xy)  # 無駄にならない範囲でABピザを買い、残りを買う
ans2 = A * X + B * Y  # ABピザを買わない
ans3 = 2 * C * max_xy  # ABピザだけを買う
print((min(ans1, ans2, ans3)))

-a, b, c, x, y = list(map(int, input().split()))

-    ans = min(ans, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i)

+A, B, C, X, Y = list(map(int, input().split()))

+ans1 = 2 * C * min_xy + A * (X - min_xy) + B * (Y - min_xy)  # 無駄にならない範囲でABピザを買い、残りを買う


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

n = int(eval(input()))

cnt = 0

for i in range(1, n+1):

    i_str = str(i)

    if len(i_str) == 1:

        cnt += 1

        continue

    if len(i_str) == 2:

        if int(i_str[0]) == int(i_str[1]):

            cnt += 3

        elif int(i_str[1]) != 0 and int(i_str[0]) > int(i_str[1]):

            cnt += 2

        continue

    if len(i_str) == 3:

        if int(i_str[0]) == int(i_str[2]):

            cnt += 4 + (2 * (int(i_str[1])+1) - 1)

        elif int(i_str[2]) != 0 and int(i_str[0]) > int(i_str[2]):

            cnt += 22

        elif int(i_str[0]) < int(i_str[2]):

            cnt += 2

        continue

    if len(i_str) == 4:

        if int(i_str[0]) == int(i_str[3]):

            cnt += 24 + 20 * int(i_str[1]) + 2 * (int(i_str[2])+1) - 1

        elif int(i_str[3]) != 0 and int(i_str[0]) > int(i_str[3]):

            cnt += 222

        elif int(i_str[0]) < int(i_str[3]):

            cnt += 22

        continue

    if len(i_str) == 5:

        if int(i_str[0]) == int(i_str[4]):

            cnt += 224 + 200 * int(i_str[1]) + 20 * int(i_str[2]) + 2 * (int(i_str[3])+1) - 1

        elif int(i_str[4]) != 0 and int(i_str[0]) > int(i_str[4]):

            cnt += 2222

        elif int(i_str[0]) < int(i_str[4]):

            cnt += 222

        continue

    if len(i_str) == 6:

        if int(i_str[0]) == int(i_str[5]):

            cnt += 2224 + 2000 * int(i_str[1]) + 200 * int(i_str[2]) + 20 * int(i_str[3]) + 2 * (int(i_str[4])+1) - 1

        elif int(i_str[5]) != 0 and int(i_str[0]) > int(i_str[5]):

            cnt += 22222

        elif int(i_str[0]) < int(i_str[5]):

            cnt += 2222

        continue

print(cnt)

# optimized version of the same code:

n = int(eval(input()))

c = [[0 for _ in range(10)] for __ in range(10)]

for i in range(1, n+1):

    str_i = str(i)

    head = int(str_i[0])

    tail = int(str_i[-1])

    c[head][tail] += 1

cnt = 0

for i in range(10):

    for j in range(10):

        cnt += c[i][j] * c[j][i]

print(cnt)

n = int(eval(input()))
cnt = 0
for i in range(1, n + 1):
    i_str = str(i)
    if len(i_str) == 1:
        cnt += 1
        continue
    if len(i_str) == 2:
        if int(i_str[0]) == int(i_str[1]):
            cnt += 3
        elif int(i_str[1]) != 0 and int(i_str[0]) > int(i_str[1]):
            cnt += 2
        continue
    if len(i_str) == 3:
        if int(i_str[0]) == int(i_str[2]):
            cnt += 4 + (2 * (int(i_str[1]) + 1) - 1)
        elif int(i_str[2]) != 0 and int(i_str[0]) > int(i_str[2]):
            cnt += 22
        elif int(i_str[0]) < int(i_str[2]):
            cnt += 2
        continue
    if len(i_str) == 4:
        if int(i_str[0]) == int(i_str[3]):
            cnt += 24 + 20 * int(i_str[1]) + 2 * (int(i_str[2]) + 1) - 1
        elif int(i_str[3]) != 0 and int(i_str[0]) > int(i_str[3]):
            cnt += 222
        elif int(i_str[0]) < int(i_str[3]):
            cnt += 22
        continue
    if len(i_str) == 5:
        if int(i_str[0]) == int(i_str[4]):
            cnt += (
                224
                + 200 * int(i_str[1])
                + 20 * int(i_str[2])
                + 2 * (int(i_str[3]) + 1)
                - 1
            )
        elif int(i_str[4]) != 0 and int(i_str[0]) > int(i_str[4]):
            cnt += 2222
        elif int(i_str[0]) < int(i_str[4]):
            cnt += 222
        continue
    if len(i_str) == 6:
        if int(i_str[0]) == int(i_str[5]):
            cnt += (
                2224
                + 2000 * int(i_str[1])
                + 200 * int(i_str[2])
                + 20 * int(i_str[3])
                + 2 * (int(i_str[4]) + 1)
                - 1
            )
        elif int(i_str[5]) != 0 and int(i_str[0]) > int(i_str[5]):
            cnt += 22222
        elif int(i_str[0]) < int(i_str[5]):
            cnt += 2222
        continue
print(cnt)

n = int(eval(input()))
c = [[0 for _ in range(10)] for __ in range(10)]
for i in range(1, n + 1):
    str_i = str(i)
    head = int(str_i[0])
    tail = int(str_i[-1])
    c[head][tail] += 1
cnt = 0
for i in range(10):
    for j in range(10):
        cnt += c[i][j] * c[j][i]
print(cnt)

+c = [[0 for _ in range(10)] for __ in range(10)]

-        if int(i_str[0]) == int(i_str[1]):

-        elif int(i_str[1]) != 0 and int(i_str[0]) > int(i_str[1]):

-        if int(i_str[0]) == int(i_str[2]):

-        elif int(i_str[2]) != 0 and int(i_str[0]) > int(i_str[2]):

-        elif int(i_str[0]) < int(i_str[2]):

-        if int(i_str[0]) == int(i_str[3]):

-        elif int(i_str[3]) != 0 and int(i_str[0]) > int(i_str[3]):

-        elif int(i_str[0]) < int(i_str[3]):

-        if int(i_str[0]) == int(i_str[4]):

-        elif int(i_str[4]) != 0 and int(i_str[0]) > int(i_str[4]):

-        elif int(i_str[0]) < int(i_str[4]):

-        if int(i_str[0]) == int(i_str[5]):

-        elif int(i_str[5]) != 0 and int(i_str[0]) > int(i_str[5]):

-        elif int(i_str[0]) < int(i_str[5]):


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import math

N = int(eval(input()))

ans = math.factorial(N) % (10**9 + 7)

print(ans)

# optimized version of the same code:

N = int(eval(input()))

mod = 10**9 + 7

ans = 1

for i in range(1, N + 1):

    ans *= i

    ans %= mod

print(ans)

-import math
-ans = math.factorial(N) % (10**9 + 7)
+mod = 10**9 + 7
+ans = 1
+for i in range(1, N + 1):
+    ans *= i
+    ans %= mod


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

from heapq import heappop, heappush

n, m = list(map(int, input().split()))

a = tuple(map(int, input().split()))

hq = []

for aa in a:

    heappush(hq, (-aa, 1))

for _ in range(m):

    b, c = list(map(int, input().split()))

    heappush(hq, (-c, b))

rest = n

ans = 0

while rest > 0:

    num, cnt = heappop(hq)

    num *= (-1)

    use = min(rest, cnt)

    ans += use * num

    rest -= use

print(ans)

# optimized version of the same code:

def main():

    from collections import Counter

    from operator import itemgetter

    import sys

    input = sys.stdin.readline

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

    a = list(map(int, input().split()))

    ctr = Counter(a)

    for _ in range(M):

        b, c = list(map(int, input().split()))

        ctr[c] += b

    ans = 0

    rest = N

    for integer, count in sorted(list(ctr.items()), key=itemgetter(0), reverse=True):

        take = min(rest, count)

        ans += take * integer

        rest -= take

        if not rest:

            break

    print(ans)

if __name__ == '__main__':

    main()

# import sys

# input = sys.stdin.readline

#

# sys.setrecursionlimit(10 ** 7)

#

# (int(x)-1 for x in input().split())

# rstrip()

from heapq import heappop, heappush

n, m = list(map(int, input().split()))
a = tuple(map(int, input().split()))
hq = []
for aa in a:
    heappush(hq, (-aa, 1))
for _ in range(m):
    b, c = list(map(int, input().split()))
    heappush(hq, (-c, b))
rest = n
ans = 0
while rest > 0:
    num, cnt = heappop(hq)
    num *= -1
    use = min(rest, cnt)
    ans += use * num
    rest -= use
print(ans)

def main():
    from collections import Counter
    from operator import itemgetter
    import sys

    input = sys.stdin.readline
    N, M = list(map(int, input().split()))
    a = list(map(int, input().split()))
    ctr = Counter(a)
    for _ in range(M):
        b, c = list(map(int, input().split()))
        ctr[c] += b
    ans = 0
    rest = N
    for integer, count in sorted(list(ctr.items()), key=itemgetter(0), reverse=True):
        take = min(rest, count)
        ans += take * integer
        rest -= take
        if not rest:
            break
    print(ans)

if __name__ == "__main__":
    main()
# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()

-    b, c = list(map(int, input().split()))

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

+    a = list(map(int, input().split()))

+        b, c = list(map(int, input().split()))

+    for integer, count in sorted(list(ctr.items()), key=itemgetter(0), reverse=True):


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import numpy as np

n, m = list(map(int, input().split()))

d = np.ones((n, n)) * 1001

es = []

for i in range(m):

    es.append(list(map(int, input().split())))

for (i, j, w) in es:

    d[i - 1][j - 1] = w

    d[j - 1][i - 1] = w

for k in range(n):

    for i in range(n):

        for j in range(n):

            l = d[i][k] + d[k][j]

            if d[i][j] > l:

                d[i][j] = l

c = 0

for (i, j, w) in es:

    if d[i - 1][j - 1] < w:

        c += 1

print(c)

# optimized version of the same code:

n, m = list(map(int, input().split()))

d = [[1001] * n for i in range(n)]

es = []

for i in range(m):

    es.append(list(map(int, input().split())))

for (i, j, w) in es:

    d[i - 1][j - 1] = w

    d[j - 1][i - 1] = w

for k in range(n):

    for i in range(n):

        for j in range(n):

            l = d[i][k] + d[k][j]

            if d[i][j] > l:

                d[i][j] = l

c = 0

for (i, j, w) in es:

    if d[i - 1][j - 1] < w:

        c += 1

print(c)

-import numpy as np
-d = np.ones((n, n)) * 1001
+d = [[1001] * n for i in range(n)]


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

A,B,C,X,Y = list(map(int,input().split()))

l = []

for i in range(max(X,Y)+1):

    T = i * C * 2

    if i < X:

        T += (X-i)*A

    if i < Y:

        T += (Y-i)*B

    l.append(T)

l.sort()

print((l[0]))

# optimized version of the same code:

A,B,C,X,Y = list(map(int,input().split()))

ans = 0

if 2*C <= A+B:

    Z = min(X,Y)

    ans = 2*C*Z

    X -= Z

    Y -= Z

ans += min(2*C*X,A*X)

ans += min(2*C*Y,B*Y)

print(ans)

A, B, C, X, Y = list(map(int, input().split()))
l = []
for i in range(max(X, Y) + 1):
    T = i * C * 2
    if i < X:
        T += (X - i) * A
    if i < Y:
        T += (Y - i) * B
    l.append(T)
l.sort()
print((l[0]))

A, B, C, X, Y = list(map(int, input().split()))
ans = 0
if 2 * C <= A + B:
    Z = min(X, Y)
    ans = 2 * C * Z
    X -= Z
    Y -= Z
ans += min(2 * C * X, A * X)
ans += min(2 * C * Y, B * Y)
print(ans)

-l = []
-for i in range(max(X, Y) + 1):
-    T = i * C * 2
-    if i < X:
-        T += (X - i) * A
-    if i < Y:
-        T += (Y - i) * B
-    l.append(T)
-l.sort()
-print((l[0]))
+ans = 0
+if 2 * C <= A + B:
+    Z = min(X, Y)
+    ans = 2 * C * Z
+    X -= Z
+    Y -= Z
+ans += min(2 * C * X, A * X)
+ans += min(2 * C * Y, B * Y)
+print(ans)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

# 参考 https://atcoder.jp/contests/abc133/submissions/7966658

import numpy as np

def abc133_c():

    L, R = list(map(int, input().split()))

    if R - L > 673: return 0

    x = np.arange(L, R+1, dtype=np.int64)

    #y = x[:, None] * x[None, :] % 2019

    y = x.reshape(-1, 1) * x.reshape(1, -1)  # 区間内のすべての組合せの積

    y %= 2019

    np.fill_diagonal(y, 2019)  # 対角成分は無視する (同じ数を2回選べない) のでinf値で埋める

    return y.min()

print((abc133_c()))

# optimized version of the same code:

def abc133_c():

    L, R = list(map(int, input().split()))

    # 区間の幅が673あれば、673の倍数と3の倍数が含まれて、2019の倍数が作れる

    if R - L > 673: return 0

    # それ以外は試す

    ans = 2019

    for i in range(L, R+1):

        for j in range(L, i):

            m = i * j % 2019

            ans = min(m, ans)

    return ans

print((abc133_c()))

# 参考 https://atcoder.jp/contests/abc133/submissions/7966658
import numpy as np

def abc133_c():
    L, R = list(map(int, input().split()))
    if R - L > 673:
        return 0
    x = np.arange(L, R + 1, dtype=np.int64)
    # y = x[:, None] * x[None, :] % 2019
    y = x.reshape(-1, 1) * x.reshape(1, -1)  # 区間内のすべての組合せの積
    y %= 2019
    np.fill_diagonal(y, 2019)  # 対角成分は無視する (同じ数を2回選べない) のでinf値で埋める
    return y.min()

print((abc133_c()))

def abc133_c():
    L, R = list(map(int, input().split()))
    # 区間の幅が673あれば、673の倍数と3の倍数が含まれて、2019の倍数が作れる
    if R - L > 673:
        return 0
    # それ以外は試す
    ans = 2019
    for i in range(L, R + 1):
        for j in range(L, i):
            m = i * j % 2019
            ans = min(m, ans)
    return ans

print((abc133_c()))

+    # 区間の幅が673あれば、673の倍数と3の倍数が含まれて、2019の倍数が作れる

-    x = np.arange(L, R + 1, dtype=np.int64)

-    y = x.reshape(-1, 1) * x.reshape(1, -1)  # 区間内のすべての組合せの積

-    np.fill_diagonal(y, 2019)  # 対角成分は無視する (同じ数を2回選べない) のでinf値で埋める

+    # それ以外は試す


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import collections

import sys

a=eval(input())

b=[]

for i in a:

  b.append(i)

b.sort()

c=collections.Counter(b)

c=list(c.values())

for i in range(len(c)):

  if int(c[i])%2==0:

    q=0

  else:

    q=1

    print('No')

    sys.exit()

print('Yes')

# optimized version of the same code:

w = list(eval(input()))

s = set(w)

for i in s:

  if w.count(i)%2 != 0:

    print("No")

    break

else:

  print("Yes")

import collections
import sys

a = eval(input())
b = []
for i in a:
    b.append(i)
b.sort()
c = collections.Counter(b)
c = list(c.values())
for i in range(len(c)):
    if int(c[i]) % 2 == 0:
        q = 0
    else:
        q = 1
        print("No")
        sys.exit()
print("Yes")

w = list(eval(input()))
s = set(w)
for i in s:
    if w.count(i) % 2 != 0:
        print("No")
        break
else:
    print("Yes")

-import collections
-import sys
-a = eval(input())
-b = []
-for i in a:
-    b.append(i)
-b.sort()
-c = collections.Counter(b)
-c = list(c.values())
-for i in range(len(c)):
-    if int(c[i]) % 2 == 0:
-        q = 0
-    else:
-        q = 1
+w = list(eval(input()))
+s = set(w)
+for i in s:
+    if w.count(i) % 2 != 0:
-        sys.exit()
-print("Yes")
+        break
+else:
+    print("Yes")


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

#ABC951B/Sum_of_Three_Integers

K, S = list(map(int, input().split()))

ans = 0

for x in range(0, K+1):

    for y in range(0, K+1):

        z = S - x - y

        if 0 <= z and z <= K:

            ans += 1

print(ans)

# optimized version of the same code:

K, S = list(map(int, input().split()))

ans = 0

for X in range(K+1):

    for Y in range(K+1):

        Z = S - X - Y

        if Z >= 0 and Z <= K:

            ans += 1

print(ans)

# ABC951B/Sum_of_Three_Integers
K, S = list(map(int, input().split()))
ans = 0
for x in range(0, K + 1):
    for y in range(0, K + 1):
        z = S - x - y
        if 0 <= z and z <= K:
            ans += 1
print(ans)

K, S = list(map(int, input().split()))
ans = 0
for X in range(K + 1):
    for Y in range(K + 1):
        Z = S - X - Y
        if Z >= 0 and Z <= K:
            ans += 1
print(ans)

-# ABC951B/Sum_of_Three_Integers
-for x in range(0, K + 1):
-    for y in range(0, K + 1):
-        z = S - x - y
-        if 0 <= z and z <= K:
+for X in range(K + 1):
+    for Y in range(K + 1):
+        Z = S - X - Y
+        if Z >= 0 and Z <= K:


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

n=int(eval(input()))-1

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

i=0

for j in range(n):

 if A[j]<=A[-1]:A[i],A[j]=A[j],A[i];i+=1

A[i],A[n]=A[n],A[i]

print((" ".join(map(str,A[:i]))+" ["+str(A[i])+"] "+" ".join(map(str,A[i+1:]))))

# optimized version of the same code:

n = int(eval(input())) - 1
A = list(map(int, input().split()))
i = 0
for j in range(n):
    if A[j] <= A[-1]:
        A[i], A[j] = A[j], A[i]
        i += 1
A[i], A[n] = A[n], A[i]
print(
    (
        " ".join(map(str, A[:i]))
        + " ["
        + str(A[i])
        + "] "
        + " ".join(map(str, A[i + 1 :]))
    )
)

+    A = list(map(int, input().split()))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

N = int(eval(input()))

mem = [[0]*10 for _ in range(10)]

for i in range(1,N+1):

    a = int(str(i)[0])

    b = int(str(i)[-1])

    mem[a][b] += 1

ans = 0

for i in range(1,N+1):

    a = int(str(i)[0])

    b = int(str(i)[-1])

    ans += mem[b][a]

print(ans)

# optimized version of the same code:

N = int(eval(input()))

mem=[[0] * 10 for _ in range(10)]

for i in range(1, N+1):

    s = str(i)

    mem[int(s[0])][int(s[-1])] += 1

ans = 0

for i in range(1, 10):

    for j in range(1, 10):

        ans += mem[i][j] * mem[j][i]

print(ans)

N = int(eval(input()))
mem = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    mem[a][b] += 1
ans = 0
for i in range(1, N + 1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    ans += mem[b][a]
print(ans)

N = int(eval(input()))
mem = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
    s = str(i)
    mem[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += mem[i][j] * mem[j][i]
print(ans)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

w = eval(input())

for l in w:

	if w.count(l) % 2 == 1:

		print("No")

		break

else:

	print("Yes")

# optimized version of the same code:

from collections import Counter

s = eval(input())

c = list(Counter(s).values())

for n in c:

	if n & 1 == 1:

		print("No")

		break

else:

	print("Yes")

-w = eval(input())
-for l in w:
-    if w.count(l) % 2 == 1:
+from collections import Counter
+
+s = eval(input())
+c = list(Counter(s).values())
+for n in c:
+    if n & 1 == 1:


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

a, b = list(map(int, input().split()))

tmp=str(a)

c=0

for i in range(a,b+1):

    tmp=str(i)

    tmp2=""

    for s in range(len(tmp)):

        tmp2=tmp2+tmp[len(tmp)-1-s]

    if tmp==tmp2:

        c=c+1

print(c)

# optimized version of the same code:

def main():

    #1. input

    a, b = list(map(int, input().split()))

    ans = 0

    #2. from A to B

    for i in range(a, b+1):

        #2.1. judge if the number is palindromic

        if (str(i)[0]==str(i)[4]) and (str(i)[1]==str(i)[3]):

            ans = ans+1

    #3. output

    print(ans)

if __name__ == '__main__':

    main()

a, b = list(map(int, input().split()))
tmp = str(a)
c = 0
for i in range(a, b + 1):
    tmp = str(i)
    tmp2 = ""
    for s in range(len(tmp)):
        tmp2 = tmp2 + tmp[len(tmp) - 1 - s]
    if tmp == tmp2:
        c = c + 1
print(c)

def main():
    # 1. input
    a, b = list(map(int, input().split()))
    ans = 0
    # 2. from A to B
    for i in range(a, b + 1):
        # 2.1. judge if the number is palindromic
        if (str(i)[0] == str(i)[4]) and (str(i)[1] == str(i)[3]):
            ans = ans + 1
    # 3. output
    print(ans)

if __name__ == "__main__":
    main()

-        tmp2 = tmp2 + tmp[len(tmp) - 1 - s]

+    a, b = list(map(int, input().split()))

+        # 2.1. judge if the number is palindromic


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

k,s=list(map(int,input().split()))

ans=0

for i in range(k+1):

    for j in range(k+1):

        z=s-i-j

        if 0<=z<=k:

            ans+=1

print(ans)

# optimized version of the same code:

k,s=list(map(int,input().split()))

ans=0

for i in range(k+1):

    for j in range(k+1):

        if 0<=s-i-j<=k:

            ans+=1

print(ans)

k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
    for j in range(k + 1):
        z = s - i - j
        if 0 <= z <= k:
            ans += 1
print(ans)

k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            ans += 1
print(ans)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import sys, re

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd

from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from bisect import bisect, bisect_left, insort, insort_left

from heapq import heappush, heappop

from functools import reduce, lru_cache

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

def INT(): return int(input())

def MAP(): return map(int, input().split())

def LIST(): return list(map(int, input().split()))

def TUPLE(): return tuple(map(int, input().split()))

def ZIP(n): return zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

mod = 10 ** 9 + 7

#mod = 998244353

from decimal import *

#import numpy as np

#decimal.getcontext().prec = 10

X, Y, Z, K = MAP()

A = sorted(LIST(), reverse = True)

B = sorted(LIST(), reverse = True)

C = sorted(LIST(), reverse = True)

AB = []

for i in range(X):

	for j in range(Y):

		AB.append(A[i]+B[j])

AB.sort(reverse = True)

AB = AB[:3000]

ABC = sorted([C[0]+AB[i] for i in range(min(3000, X*Y))], reverse = True)

for j in range(1, Z):

	ABC_tmp = sorted([C[j]+AB[i] for i in range(min(3000, X*Y))])

	ABC += ABC_tmp

	ABC.sort(reverse = True)

	ABC = ABC[:3000]

print(*ABC[:K], sep= "\n")

# optimized version of the same code:

import sys, re

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd

from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from bisect import bisect, bisect_left, insort, insort_left

from heapq import heappush, heappop

from functools import reduce, lru_cache

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

def INT(): return int(eval(input()))

def MAP(): return list(map(int, input().split()))

def LIST(): return list(map(int, input().split()))

def TUPLE(): return tuple(map(int, input().split()))

def ZIP(n): return list(zip(*(MAP() for _ in range(n))))

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

mod = 10 ** 9 + 7

#mod = 998244353

from decimal import *

#import numpy as np

#decimal.getcontext().prec = 10

X, Y, Z, K = MAP()

A = sorted(LIST(), reverse = True)

B = sorted(LIST(), reverse = True)

C = sorted(LIST(), reverse = True)

ans = []

for i in range(X):

	for j in range(Y):

		for k in range(Z):

			if (i+1)*(j+1)*(k+1) <= K:

				ans.append(A[i]+B[j]+C[k])

			else:

				break

for a in sorted(ans)[::-1][:K]:

	print(a)

import sys, re
from collections import deque, defaultdict, Counter
from math import (
    ceil,
    sqrt,
    hypot,
    factorial,
    pi,
    sin,
    cos,
    tan,
    asin,
    acos,
    atan,
    radians,
    degrees,
    log2,
    gcd,
)
from itertools import (
    accumulate,
    permutations,
    combinations,
    combinations_with_replacement,
    product,
    groupby,
)
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache

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

def INT():
    return int(input())

def MAP():
    return map(int, input().split())

def LIST():
    return list(map(int, input().split()))

def TUPLE():
    return tuple(map(int, input().split()))

def ZIP(n):
    return zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
# mod = 998244353
from decimal import *

# import numpy as np
# decimal.getcontext().prec = 10
X, Y, Z, K = MAP()
A = sorted(LIST(), reverse=True)
B = sorted(LIST(), reverse=True)
C = sorted(LIST(), reverse=True)
AB = []
for i in range(X):
    for j in range(Y):
        AB.append(A[i] + B[j])
AB.sort(reverse=True)
AB = AB[:3000]
ABC = sorted([C[0] + AB[i] for i in range(min(3000, X * Y))], reverse=True)
for j in range(1, Z):
    ABC_tmp = sorted([C[j] + AB[i] for i in range(min(3000, X * Y))])
    ABC += ABC_tmp
    ABC.sort(reverse=True)
    ABC = ABC[:3000]
print(*ABC[:K], sep="\n")

import sys, re
from collections import deque, defaultdict, Counter
from math import (
    ceil,
    sqrt,
    hypot,
    factorial,
    pi,
    sin,
    cos,
    tan,
    asin,
    acos,
    atan,
    radians,
    degrees,
    log2,
    gcd,
)
from itertools import (
    accumulate,
    permutations,
    combinations,
    combinations_with_replacement,
    product,
    groupby,
)
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache

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

def INT():
    return int(eval(input()))

def MAP():
    return list(map(int, input().split()))

def LIST():
    return list(map(int, input().split()))

def TUPLE():
    return tuple(map(int, input().split()))

def ZIP(n):
    return list(zip(*(MAP() for _ in range(n))))

sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
# mod = 998244353
from decimal import *

# import numpy as np
# decimal.getcontext().prec = 10
X, Y, Z, K = MAP()
A = sorted(LIST(), reverse=True)
B = sorted(LIST(), reverse=True)
C = sorted(LIST(), reverse=True)
ans = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) <= K:
                ans.append(A[i] + B[j] + C[k])
            else:
                break
for a in sorted(ans)[::-1][:K]:
    print(a)

+    return list(map(int, input().split()))

-    return zip(*(MAP() for _ in range(n)))

+    return list(zip(*(MAP() for _ in range(n))))

-ABC = sorted([C[0] + AB[i] for i in range(min(3000, X * Y))], reverse=True)

-    ABC_tmp = sorted([C[j] + AB[i] for i in range(min(3000, X * Y))])

+                ans.append(A[i] + B[j] + C[k])


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import fractions

import sys

input = sys.stdin.readline

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

a = list(map(int, input().split()))

lcm = a[0]

for i in range(1, N):

    g= fractions.gcd(lcm, a[i])

    lcm = lcm * a[i] // g

g=a[0]

for i in range(N):

    g=fractions.gcd(g,a[i])

for i in range(N):

    if (a[i]//g)%2==0:

        lcm=0

        break

ans=0

l=lcm//2

if l:

    ans=(M//l)-(M//(l+l))

print(ans)

# optimized version of the same code:

import sys

input = sys.stdin.readline

def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))

"""

2X = ak * (2p+1)

基本的には最小公倍数/2を基本とし，これの奇数倍か．

X  = (ak//2) * (2p+1)

と書ける．第二項が奇数なので，各akが2で割り切れれう回数が同じでなければならない

a=[2,4]だと無理

"""

def main():

    from math import gcd

    N,M=MI()

    A=LI()

    def count(X):

        cnt=0

        while X%2==0:

            cnt+=1

            X=X//2

        return cnt

    C=count(A[0])

    for i in range(1,N):

        if count(A[i])!=C:

            print((0))

            exit()

    lca=1

    for i in range(N):

        g=gcd(lca,A[i])

        lca=(lca*A[i])//g

    lca2=lca//2

    ans=M//lca2 - M//lca

    print(ans)

main()

import fractions
import sys

input = sys.stdin.readline
N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
lcm = a[0]
for i in range(1, N):
    g = fractions.gcd(lcm, a[i])
    lcm = lcm * a[i] // g
g = a[0]
for i in range(N):
    g = fractions.gcd(g, a[i])
for i in range(N):
    if (a[i] // g) % 2 == 0:
        lcm = 0
        break
ans = 0
l = lcm // 2
if l:
    ans = (M // l) - (M // (l + l))
print(ans)

import sys

input = sys.stdin.readline

def I():
    return int(eval(input()))

def MI():
    return list(map(int, input().split()))

def LI():
    return list(map(int, input().split()))

"""
2X = ak * (2p+1)
基本的には最小公倍数/2を基本とし，これの奇数倍か．
X  = (ak//2) * (2p+1)
と書ける．第二項が奇数なので，各akが2で割り切れれう回数が同じでなければならない
a=[2,4]だと無理
"""

def main():
    from math import gcd

    N, M = MI()
    A = LI()

    def count(X):
        cnt = 0
        while X % 2 == 0:
            cnt += 1
            X = X // 2
        return cnt

    C = count(A[0])
    for i in range(1, N):
        if count(A[i]) != C:
            print((0))
            exit()
    lca = 1
    for i in range(N):
        g = gcd(lca, A[i])
        lca = (lca * A[i]) // g
    lca2 = lca // 2
    ans = M // lca2 - M // lca
    print(ans)

main()

+    return list(map(int, input().split()))

+基本的には最小公倍数/2を基本とし，これの奇数倍か．

+と書ける．第二項が奇数なので，各akが2で割り切れれう回数が同じでなければならない


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import collections

import math

class Dinic:

    """Dinic Algorithm: find max-flow

       complexity: O(EV^2)

       used in GRL6A(AOJ)

    """

    class edge:

        def __init__(self, to, cap, rev):

            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V, E, source, sink):

        """ V: the number of vertexes

            E: adjacency list

            source: start point

            sink: goal point

        """

        self.V = V

        self.E = [[] for _ in range(V)]

        for fr in range(V):

            for to, cap in E[fr]:

                self.E[fr].append(self.edge(to, cap, len(self.E[to])))

                self.E[to].append(self.edge(fr, 0, len(self.E[fr])-1))

        self.maxflow = self.dinic(source, sink)

    def dinic(self, source, sink):

        """find max-flow"""

        INF = float('inf')

        maxflow = 0

        while True:

            self.bfs(source)

            if self.level[sink] < 0:

                return maxflow

            self.itr = [0] * self.V

            while True:

                flow = self.dfs(source, sink, INF)

                if flow > 0:

                    maxflow += flow

                else:

                    break

    def dfs(self, vertex, sink, flow):

        """find augmenting path"""

        if vertex == sink:

            return flow

        for i in range(self.itr[vertex], len(self.E[vertex])):

            self.itr[vertex] = i

            e = self.E[vertex][i]

            if e.cap > 0 and self.level[vertex] < self.level[e.to]:

                d = self.dfs(e.to, sink, min(flow, e.cap))

                if d > 0:

                    e.cap -= d

                    self.E[e.to][e.rev].cap += d

                    return d

        return 0

    def bfs(self, start):

        """find shortest path from start"""

        que = collections.deque()

        self.level = [-1] * self.V

        que.append(start)

        self.level[start] = 0

        while que:

            fr = que.popleft()

            for e in self.E[fr]:

                if e.cap > 0 and self.level[e.to] < 0:

                    self.level[e.to] = self.level[fr] + 1

                    que.append(e.to)

while True:

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

    if M == 0 and N == 0:

        break

    blue, red = [], []

    while True:

        for x in input().split():

            blue.append(int(x))

        if len(blue) == M:

            break

    while True:

        for x in input().split():

            red.append(int(x))

        if len(red) == N:

            break

    V = M + N + 2

    edge = [set() for _ in range(V)]

    for i, b in enumerate(blue):

        if b != 1:

            for j, r in enumerate(red):

                if r % b == 0:

                    edge[i].add((M+j, 1))

        for j in range(2, int(math.sqrt(b)) + 1):

            if b % j == 0:

                for k, r in enumerate(red):

                    if r % j == 0 or r % (b // j) == 0:

                        edge[i].add((M+k, 1))

    for i in range(M):

        edge[M+N].add((i, 1))

    for j in range(N):

        edge[M+j].add((M+N+1, 1))

    d = Dinic(V, edge, M+N, M+N+1)

    print((d.maxflow))

# optimized version of the same code:

import collections

import math

range = xrange; input = raw_input

class Dinic:

    """Dinic Algorithm: find max-flow

       complexity: O(EV^2)

       used in GRL6A(AOJ)

    """

    class edge:

        def __init__(self, to, cap, rev):

            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V, E, source, sink):

        """ V: the number of vertexes

            E: adjacency list

            source: start point

            sink: goal point

        """

        self.V = V

        self.E = [[] for _ in range(V)]

        for fr in range(V):

            for to, cap in E[fr]:

                self.E[fr].append(self.edge(to, cap, len(self.E[to])))

                self.E[to].append(self.edge(fr, 0, len(self.E[fr])-1))

        self.maxflow = self.dinic(source, sink)

    def dinic(self, source, sink):

        """find max-flow"""

        INF = float('inf')

        maxflow = 0

        while True:

            self.bfs(source)

            if self.level[sink] < 0:

                return maxflow

            self.itr = [0] * self.V

            while True:

                flow = self.dfs(source, sink, INF)

                if flow > 0:

                    maxflow += flow

                else:

                    break

    def dfs(self, vertex, sink, flow):

        """find augmenting path"""

        if vertex == sink:

            return flow

        for i in range(self.itr[vertex], len(self.E[vertex])):

            self.itr[vertex] = i

            e = self.E[vertex][i]

            if e.cap > 0 and self.level[vertex] < self.level[e.to]:

                d = self.dfs(e.to, sink, min(flow, e.cap))

                if d > 0:

                    e.cap -= d

                    self.E[e.to][e.rev].cap += d

                    return d

        return 0

    def bfs(self, start):

        """find shortest path from start"""

        que = collections.deque()

        self.level = [-1] * self.V

        que.append(start)

        self.level[start] = 0

        while que:

            fr = que.popleft()

            for e in self.E[fr]:

                if e.cap > 0 and self.level[e.to] < 0:

                    self.level[e.to] = self.level[fr] + 1

                    que.append(e.to)

while True:

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

    if M == 0 and N == 0:

        break

    blue, red = [], []

    while True:

        for x in input().split():

            blue.append(int(x))

        if len(blue) == M:

            break

    while True:

        for x in input().split():

            red.append(int(x))

        if len(red) == N:

            break

    V = M + N + 2

    edge = [set() for _ in range(V)]

    for i, b in enumerate(blue):

        if b != 1:

            for j, r in enumerate(red):

                if r % b == 0:

                    edge[i].add((M+j, 1))

        for j in range(2, int(math.sqrt(b)) + 1):

            if b % j == 0:

                for k, r in enumerate(red):

                    if r % j == 0 or r % (b // j) == 0:

                        edge[i].add((M+k, 1))

    for i in range(M):

        edge[M+N].add((i, 1))

    for j in range(N):

        edge[M+j].add((M+N+1, 1))

    d = Dinic(V, edge, M+N, M+N+1)

    print((d.maxflow))

import collections
import math

class Dinic:
    """Dinic Algorithm: find max-flow
    complexity: O(EV^2)
    used in GRL6A(AOJ)
    """

    class edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V, E, source, sink):
        """V: the number of vertexes
        E: adjacency list
        source: start point
        sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]
        for fr in range(V):
            for to, cap in E[fr]:
                self.E[fr].append(self.edge(to, cap, len(self.E[to])))
                self.E[to].append(self.edge(fr, 0, len(self.E[fr]) - 1))
        self.maxflow = self.dinic(source, sink)

    def dinic(self, source, sink):
        """find max-flow"""
        INF = float("inf")
        maxflow = 0
        while True:
            self.bfs(source)
            if self.level[sink] < 0:
                return maxflow
            self.itr = [0] * self.V
            while True:
                flow = self.dfs(source, sink, INF)
                if flow > 0:
                    maxflow += flow
                else:
                    break

    def dfs(self, vertex, sink, flow):
        """find augmenting path"""
        if vertex == sink:
            return flow
        for i in range(self.itr[vertex], len(self.E[vertex])):
            self.itr[vertex] = i
            e = self.E[vertex][i]
            if e.cap > 0 and self.level[vertex] < self.level[e.to]:
                d = self.dfs(e.to, sink, min(flow, e.cap))
                if d > 0:
                    e.cap -= d
                    self.E[e.to][e.rev].cap += d
                    return d
        return 0

    def bfs(self, start):
        """find shortest path from start"""
        que = collections.deque()
        self.level = [-1] * self.V
        que.append(start)
        self.level[start] = 0
        while que:
            fr = que.popleft()
            for e in self.E[fr]:
                if e.cap > 0 and self.level[e.to] < 0:
                    self.level[e.to] = self.level[fr] + 1
                    que.append(e.to)

while True:
    M, N = list(map(int, input().split()))
    if M == 0 and N == 0:
        break
    blue, red = [], []
    while True:
        for x in input().split():
            blue.append(int(x))
        if len(blue) == M:
            break
    while True:
        for x in input().split():
            red.append(int(x))
        if len(red) == N:
            break
    V = M + N + 2
    edge = [set() for _ in range(V)]
    for i, b in enumerate(blue):
        if b != 1:
            for j, r in enumerate(red):
                if r % b == 0:
                    edge[i].add((M + j, 1))
        for j in range(2, int(math.sqrt(b)) + 1):
            if b % j == 0:
                for k, r in enumerate(red):
                    if r % j == 0 or r % (b // j) == 0:
                        edge[i].add((M + k, 1))
    for i in range(M):
        edge[M + N].add((i, 1))
    for j in range(N):
        edge[M + j].add((M + N + 1, 1))
    d = Dinic(V, edge, M + N, M + N + 1)
    print((d.maxflow))

import collections
import math

range = xrange
input = raw_input

class Dinic:
    """Dinic Algorithm: find max-flow
    complexity: O(EV^2)
    used in GRL6A(AOJ)
    """

    class edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V, E, source, sink):
        """V: the number of vertexes
        E: adjacency list
        source: start point
        sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]
        for fr in range(V):
            for to, cap in E[fr]:
                self.E[fr].append(self.edge(to, cap, len(self.E[to])))
                self.E[to].append(self.edge(fr, 0, len(self.E[fr]) - 1))
        self.maxflow = self.dinic(source, sink)

    def dinic(self, source, sink):
        """find max-flow"""
        INF = float("inf")
        maxflow = 0
        while True:
            self.bfs(source)
            if self.level[sink] < 0:
                return maxflow
            self.itr = [0] * self.V
            while True:
                flow = self.dfs(source, sink, INF)
                if flow > 0:
                    maxflow += flow
                else:
                    break

    def dfs(self, vertex, sink, flow):
        """find augmenting path"""
        if vertex == sink:
            return flow
        for i in range(self.itr[vertex], len(self.E[vertex])):
            self.itr[vertex] = i
            e = self.E[vertex][i]
            if e.cap > 0 and self.level[vertex] < self.level[e.to]:
                d = self.dfs(e.to, sink, min(flow, e.cap))
                if d > 0:
                    e.cap -= d
                    self.E[e.to][e.rev].cap += d
                    return d
        return 0

    def bfs(self, start):
        """find shortest path from start"""
        que = collections.deque()
        self.level = [-1] * self.V
        que.append(start)
        self.level[start] = 0
        while que:
            fr = que.popleft()
            for e in self.E[fr]:
                if e.cap > 0 and self.level[e.to] < 0:
                    self.level[e.to] = self.level[fr] + 1
                    que.append(e.to)

while True:
    M, N = list(map(int, input().split()))
    if M == 0 and N == 0:
        break
    blue, red = [], []
    while True:
        for x in input().split():
            blue.append(int(x))
        if len(blue) == M:
            break
    while True:
        for x in input().split():
            red.append(int(x))
        if len(red) == N:
            break
    V = M + N + 2
    edge = [set() for _ in range(V)]
    for i, b in enumerate(blue):
        if b != 1:
            for j, r in enumerate(red):
                if r % b == 0:
                    edge[i].add((M + j, 1))
        for j in range(2, int(math.sqrt(b)) + 1):
            if b % j == 0:
                for k, r in enumerate(red):
                    if r % j == 0 or r % (b // j) == 0:
                        edge[i].add((M + k, 1))
    for i in range(M):
        edge[M + N].add((i, 1))
    for j in range(N):
        edge[M + j].add((M + N + 1, 1))
    d = Dinic(V, edge, M + N, M + N + 1)
    print((d.maxflow))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

while True:

    try:

        for i in range(3):

            line = input().strip()

            if line == '0':

                raise Exception

            a = b = 0

            for i, s in enumerate(line):

                if i != 0:

                    if s == 'A':

                        a += 1

                    else:

                        b += 1

            if a > b:

                a += 1

            else:

                b += 1

            print(a, b)

    except:

        break

# optimized version of the same code:

while True:

    try:

        for i in range(3):

            line = input().strip()

            if line == '0':

                raise Exception

            if line[0] == 'A':

                a = -1

                b = 0

            else:

                a = 0

                b = -1

            for i, s in enumerate(line):

                if s == 'A':

                    a += 1

                else:

                    b += 1

            if a > b:

                a += 1

            else:

                b += 1

            print(a, b)

    except:

        break

while True:
    try:
        for i in range(3):
            line = input().strip()
            if line == "0":
                raise Exception
            a = b = 0
            for i, s in enumerate(line):
                if i != 0:
                    if s == "A":
                        a += 1
                    else:
                        b += 1
            if a > b:
                a += 1
            else:
                b += 1
            print(a, b)
    except:
        break

while True:
    try:
        for i in range(3):
            line = input().strip()
            if line == "0":
                raise Exception
            if line[0] == "A":
                a = -1
                b = 0
            else:
                a = 0
                b = -1
            for i, s in enumerate(line):
                if s == "A":
                    a += 1
                else:
                    b += 1
            if a > b:
                a += 1
            else:
                b += 1
            print(a, b)
    except:
        break


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

from bisect import *

n = int(eval(input()))

a = list(map(int,input().split()))

b = list(map(int,input().split()))

c = list(map(int,input().split()))

a = sorted(a)

c = sorted(c)

rec = 0

for i in range(n):

    temp = b[i]

    l = bisect_left(a, temp)

    r = bisect_right(c, temp)

    rec += l * (n - r)

print(rec)

# optimized version of the same code:

from bisect import *

n = int(eval(input()))

a = list(map(int,input().split()))

b = list(map(int,input().split()))

c = list(map(int,input().split()))

a.sort()

c.sort()

res = 0

for i in b:

    temp_a = bisect_left(a, i)

    temp_c = n - bisect_right(c, i)

    res += temp_a*temp_c

print(res)

from bisect import *

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a)
c = sorted(c)
rec = 0
for i in range(n):
    temp = b[i]
    l = bisect_left(a, temp)
    r = bisect_right(c, temp)
    rec += l * (n - r)
print(rec)

from bisect import *

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()
res = 0
for i in b:
    temp_a = bisect_left(a, i)
    temp_c = n - bisect_right(c, i)
    res += temp_a * temp_c
print(res)

-a = sorted(a)
-c = sorted(c)
-rec = 0
-for i in range(n):
-    temp = b[i]
-    l = bisect_left(a, temp)
-    r = bisect_right(c, temp)
-    rec += l * (n - r)
-print(rec)
+a.sort()
+c.sort()
+res = 0
+for i in b:
+    temp_a = bisect_left(a, i)
+    temp_c = n - bisect_right(c, i)
+    res += temp_a * temp_c
+print(res)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

N=int(eval(input()))

S=[[-1]*N for _ in range(N)]

for i in range(N):

  A=int(eval(input()))

  for _ in range(A):

    x, y=list(map(int, input().split()))

    S[i][x-1]=y

ans=0

for s in range(2**N):

  ok=True

  for i in range(N):

    #正直者について見ていく

    if (s>>i&1)==1:

      for j in range(N):

        #それぞれ正直者の証言が矛盾ないか

        if S[i][j]!=-1 and (s>>j&1)!=S[i][j]:

          ok=False

  if ok:

    ans=max(ans, bin(s).count("1"))

print(ans)

# optimized version of the same code:

N=int(eval(input()))

A=[[-1]*N for _ in range(N)]

for i in range(N):

  a=int(eval(input()))

  for j in range(a):

    x,y=list(map(int, input().split()))

    A[i][x-1]=y

#正直者が正直者に不親切と言われていない

#→正直ものが不親切を正直者と言っていないか

ans=0

for i in range(2**N):

  ok=True

  for j in range(N):

    if (i>>j&1)==1:

      for k in range(N):

        if A[j][k]!=-1 and (i>>k&1)!=A[j][k]:

          ok=False

  if ok:

    ans=max(ans, bin(i).count("1"))

print(ans)

N = int(eval(input()))
S = [[-1] * N for _ in range(N)]
for i in range(N):
    A = int(eval(input()))
    for _ in range(A):
        x, y = list(map(int, input().split()))
        S[i][x - 1] = y
ans = 0
for s in range(2**N):
    ok = True
    for i in range(N):
        # 正直者について見ていく
        if (s >> i & 1) == 1:
            for j in range(N):
                # それぞれ正直者の証言が矛盾ないか
                if S[i][j] != -1 and (s >> j & 1) != S[i][j]:
                    ok = False
    if ok:
        ans = max(ans, bin(s).count("1"))
print(ans)

N = int(eval(input()))
A = [[-1] * N for _ in range(N)]
for i in range(N):
    a = int(eval(input()))
    for j in range(a):
        x, y = list(map(int, input().split()))
        A[i][x - 1] = y
# 正直者が正直者に不親切と言われていない
# →正直ものが不親切を正直者と言っていないか
ans = 0
for i in range(2**N):
    ok = True
    for j in range(N):
        if (i >> j & 1) == 1:
            for k in range(N):
                if A[j][k] != -1 and (i >> k & 1) != A[j][k]:
                    ok = False
    if ok:
        ans = max(ans, bin(i).count("1"))
print(ans)

+# 正直者が正直者に不親切と言われていない

+# →正直ものが不親切を正直者と言っていないか

-        # 正直者について見ていく

-                # それぞれ正直者の証言が矛盾ないか

-        ans = max(ans, bin(s).count("1"))

+        ans = max(ans, bin(i).count("1"))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import numpy as np

from copy import deepcopy

N = int(eval(input()))

A = []

A.append(list(map(int, input().split())))

a = deepcopy(A[0])

a.sort()

A.append(a)

A_t = np.array(A).T.tolist()

A_t.sort()

out = []

for i in range(N):

    out.append(str(A_t[i][1]))

print((" ".join(out)))

# optimized version of the same code:

N = int(eval(input()))

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

rev = [""] * N

for i in range(N):

    rev[A[i]-1] = str(i+1)

print((" ".join(rev)))

N = int(eval(input()))
A = list(map(int, input().split()))
rev = [""] * N
for i in range(N):
    rev[A[i] - 1] = str(i + 1)
print((" ".join(rev)))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

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

for i in range(N+1):

    for j in range(M+1):

        t = i*M + j*N - i*j*2

        if t==K:

            print('Yes')

            exit()

print('No')

# optimized version of the same code:

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

for i in range(N+1):

    for j in range(M+1):

        if i*(M-j) + j*(N-i) == K:

            print('Yes')

            exit()

print('No')

N, M, K = list(map(int, input().split()))
for i in range(N + 1):
    for j in range(M + 1):
        t = i * M + j * N - i * j * 2
        if t == K:
            print("Yes")
            exit()
print("No")

N, M, K = list(map(int, input().split()))
for i in range(N + 1):
    for j in range(M + 1):
        if i * (M - j) + j * (N - i) == K:
            print("Yes")
            exit()
print("No")


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

a,b,c,d,e,f=[int(eval(input())) for _ in range(6)]

print((sum([a,b,c,d,max(e,f)])-min([a,b,c,d])))

# optimized version of the same code:

print((sum(sorted(int(eval(input())) for _ in range(4))[1:])+max([int(eval(input())) for _ in range(2)])))

a, b, c, d, e, f = [int(eval(input())) for _ in range(6)]
print((sum([a, b, c, d, max(e, f)]) - min([a, b, c, d])))

print(
    (
        sum(sorted(int(eval(input())) for _ in range(4))[1:])
        + max([int(eval(input())) for _ in range(2)])
    )
)

-a, b, c, d, e, f = [int(eval(input())) for _ in range(6)]

-print((sum([a, b, c, d, max(e, f)]) - min([a, b, c, d])))

+        sum(sorted(int(eval(input())) for _ in range(4))[1:])

+        + max([int(eval(input())) for _ in range(2)])


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

# AtCoder Beginner Contest 095 C - Half and Half

import sys

A, B, C, X, Y = list(map(int, sys.stdin.readline().strip().split()))

ans = A * X + B * Y

for z in range(2, 2 * 10 ** 5 + 1, 2):

    x = max(X - int(z / 2), 0)

    y = max(Y - int(z / 2), 0)

    price = A * x + B * y + C * z

    ans = min(price, ans)

print(ans)

# optimized version of the same code:

# AtCoder Beginner Contest 095 C - Half and Half

import sys

A, B, C, X, Y = list(map(int, sys.stdin.readline().strip().split()))

"""

ans = A * X + B * Y

for z in range(2, 2 * 10 ** 5 + 1, 2):

    x = max(X - int(z / 2), 0)

    y = max(Y - int(z / 2), 0)

    price = A * x + B * y + C * z

    ans = min(price, ans)

print(ans)

"""

price1 = A * X + B * Y

price2 = C * 2 * X + B * max(Y - X, 0)

price3 = A * max(X - Y, 0) + C * 2 * Y

print((min(price1, price2, price3)))

# AtCoder Beginner Contest 095 C - Half and Half
import sys

A, B, C, X, Y = list(map(int, sys.stdin.readline().strip().split()))
ans = A * X + B * Y
for z in range(2, 2 * 10**5 + 1, 2):
    x = max(X - int(z / 2), 0)
    y = max(Y - int(z / 2), 0)
    price = A * x + B * y + C * z
    ans = min(price, ans)
print(ans)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

from collections import defaultdict

N = int(eval(input()))

d = defaultdict(int)

for i in range(N):

    S = eval(input())

    d[S] += 1

m = 0

for k in list(d.keys()):

    m = max(d[k],m)

li = []

for k in list(d.keys()):

    if d[k] == m:

        li.append(k)

li.sort()

for l in li:

    print(l)

# optimized version of the same code:

from collections import defaultdict

N = int(eval(input()))

Ss = [eval(input()) for i in range(N)]

d = defaultdict(int)

for S in Ss:

    d[S] += 1

mx = max([d[k] for k in list(d.keys())])

ans = []

for k in list(d.keys()):

    if d[k] == mx:

       ans.append(k)

for a in sorted(ans):

    print(a)

from collections import defaultdict

N = int(eval(input()))
d = defaultdict(int)
for i in range(N):
    S = eval(input())
    d[S] += 1
m = 0
for k in list(d.keys()):
    m = max(d[k], m)
li = []
for k in list(d.keys()):
    if d[k] == m:
        li.append(k)
li.sort()
for l in li:
    print(l)

+mx = max([d[k] for k in list(d.keys())])


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

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

L,R = [],[]

for i in range(M):

    l,r = list(map(int,input().split()))

    L.append(l)

    R.append(r)

ans = min(R)-max(L)+1

print((ans if ans >= 0 else 0))

# optimized version of the same code:

# coding: utf-8

import sys

sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))

N, M = lr()

L = 0; R = 10 ** 6

for _ in range(M):

    l, r = lr()

    if l > L:

        L = l

    if r < R:

        R = r

answer = max(0, R - L + 1)

print(answer)

N, M = list(map(int, input().split()))
L, R = [], []
for i in range(M):
    l, r = list(map(int, input().split()))
    L.append(l)
    R.append(r)
ans = min(R) - max(L) + 1
print((ans if ans >= 0 else 0))

# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
L = 0
R = 10**6
for _ in range(M):
    l, r = lr()
    if l > L:
        L = l
    if r < R:
        R = r
answer = max(0, R - L + 1)
print(answer)

-    l, r = list(map(int, input().split()))

+sr = lambda: sys.stdin.readline().rstrip()

+lr = lambda: list(map(int, sr().split()))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

MOD = 1000000007

S = int(eval(input()))

#dp[i]:=i桁の数列で条件を満たすものの数

dp = [0]*(S+1)

for i in range(3,S+1):

    #dp[i]=sum(dp[0],..,dp[i-3])+1

    for j in range(i-3+1):

        dp[i] = (dp[i]+dp[j])%MOD

    dp[i] = (dp[i]+1)%MOD

print((dp[S]))

# optimized version of the same code:

MOD = 1000000007

S = int(eval(input()))

#dp[i]:=i桁の数列で条件を満たすものの数

dp = [0]*(S+1)

dp_sum = [0]*(S+1)

for i in range(3,S+1):

    #dp[i]=sum(dp[0],..,dp[i-3])+1

    dp[i] = (dp_sum[i-3]+1)%MOD

    dp_sum[i] = (dp[i]+dp_sum[i-1])%MOD

print((dp[S]))

MOD = 1000000007
S = int(eval(input()))
# dp[i]:=i桁の数列で条件を満たすものの数
dp = [0] * (S + 1)
for i in range(3, S + 1):
    # dp[i]=sum(dp[0],..,dp[i-3])+1
    for j in range(i - 3 + 1):
        dp[i] = (dp[i] + dp[j]) % MOD
    dp[i] = (dp[i] + 1) % MOD
print((dp[S]))

MOD = 1000000007
S = int(eval(input()))
# dp[i]:=i桁の数列で条件を満たすものの数
dp = [0] * (S + 1)
dp_sum = [0] * (S + 1)
for i in range(3, S + 1):
    # dp[i]=sum(dp[0],..,dp[i-3])+1
    dp[i] = (dp_sum[i - 3] + 1) % MOD
    dp_sum[i] = (dp[i] + dp_sum[i - 1]) % MOD
print((dp[S]))

+    dp_sum[i] = (dp[i] + dp_sum[i - 1]) % MOD


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import numpy

H, W = [int(i) for i in input().split()]

A = numpy.array([list(input().strip()) for _ in range(H)])

row_space = []

col_space = []

for k, row in enumerate(A):

    if '#' not in row:

        row_space.append(k)

A_rot = numpy.rot90(A, k=-1)

for k, row in enumerate(A_rot):

    if '#' not in row:

        col_space.append(k)

A = numpy.delete(A, row_space, axis=0)

A = numpy.delete(A, col_space, axis=1)

ans = '\n'.join([''.join(row) for row in A])

print(ans)

# optimized version of the same code:

def rotate_clockwise(matrix):

    tmp = list(map(list, list(zip(*matrix))))[::-1]

    return list(''.join(row) for row in tmp)

    # 文字列のリストを入れるので文字列のリストで返す

def rotate_counterclockwise(matrix):

    tmp = list([list(x[::-1]) for x in zip(*matrix)])

    return list(''.join(row) for row in tmp)

    # 文字列のリストを入れるので文字列のリストで返す

H, W = [int(i) for i in input().split()]

A = [eval(input()) for _ in range(H)]

row_remove_count = 0

while '.' * W in A:

    A.remove('.' * W)  # 行まるごと白なら、回数を記録して除く

    row_remove_count += 1

A = rotate_clockwise(A)  # 反時計回りに回す

while '.' * (H - row_remove_count) in A:

    A.remove('.' * (H - row_remove_count))

A = rotate_counterclockwise(A)  # 時計回りに回して元に戻す

print(('\n'.join(A)))

import numpy

H, W = [int(i) for i in input().split()]
A = numpy.array([list(input().strip()) for _ in range(H)])
row_space = []
col_space = []
for k, row in enumerate(A):
    if "#" not in row:
        row_space.append(k)
A_rot = numpy.rot90(A, k=-1)
for k, row in enumerate(A_rot):
    if "#" not in row:
        col_space.append(k)
A = numpy.delete(A, row_space, axis=0)
A = numpy.delete(A, col_space, axis=1)
ans = "\n".join(["".join(row) for row in A])
print(ans)

def rotate_clockwise(matrix):
    tmp = list(map(list, list(zip(*matrix))))[::-1]
    return list("".join(row) for row in tmp)
    # 文字列のリストを入れるので文字列のリストで返す

def rotate_counterclockwise(matrix):
    tmp = list([list(x[::-1]) for x in zip(*matrix)])
    return list("".join(row) for row in tmp)
    # 文字列のリストを入れるので文字列のリストで返す

H, W = [int(i) for i in input().split()]
A = [eval(input()) for _ in range(H)]
row_remove_count = 0
while "." * W in A:
    A.remove("." * W)  # 行まるごと白なら、回数を記録して除く
    row_remove_count += 1
A = rotate_clockwise(A)  # 反時計回りに回す
while "." * (H - row_remove_count) in A:
    A.remove("." * (H - row_remove_count))
A = rotate_counterclockwise(A)  # 時計回りに回して元に戻す
print(("\n".join(A)))

+    tmp = list(map(list, list(zip(*matrix))))[::-1]

+    return list("".join(row) for row in tmp)

+    # 文字列のリストを入れるので文字列のリストで返す

+    tmp = list([list(x[::-1]) for x in zip(*matrix)])

+    # 文字列のリストを入れるので文字列のリストで返す

-A = numpy.array([list(input().strip()) for _ in range(H)])

-ans = "\n".join(["".join(row) for row in A])

+    A.remove("." * W)  # 行まるごと白なら、回数を記録して除く

+while "." * (H - row_remove_count) in A:

+    A.remove("." * (H - row_remove_count))

+A = rotate_counterclockwise(A)  # 時計回りに回して元に戻す


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

n = int(eval(input()))

l = []

for i in range(1,1000001):

    a = n / i

    if a.is_integer():

        l.append(i+n/i)

print((int(min(l)-2)))

# optimized version of the same code:

n = int(eval(input()))

a = 10**20

for i in range(1,int(n**0.5)+1):

    if n%i==0:

        a = min(a,i+n//i)

print((a-2))

n = int(eval(input()))
l = []
for i in range(1, 1000001):
    a = n / i
    if a.is_integer():
        l.append(i + n / i)
print((int(min(l) - 2)))

n = int(eval(input()))
a = 10**20
for i in range(1, int(n**0.5) + 1):
    if n % i == 0:
        a = min(a, i + n // i)
print((a - 2))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import sys

import numpy as np

def main():

    h, w = list(map(int, sys.stdin.buffer.readline().split()))

    n = int(sys.stdin.buffer.readline())

    a = list(map(int, sys.stdin.buffer.readline().split()))

    ans = np.zeros(w*h, np.int64)

    now = 0

    for i, x in enumerate(a):

        for j in range(x):

            ans[now + j] = i+1

        now += x

    ans = ans.reshape(h, w)

    for i in range(h):

        if i % 2:

            print((*ans[i, ::-1]))

        else:

            print((*ans[i]))

if __name__ == "__main__":

    main()

# optimized version of the same code:

import sys

def main():

    h, w = list(map(int, sys.stdin.buffer.readline().split()))

    n = int(sys.stdin.buffer.readline())

    a = list(map(int, sys.stdin.buffer.readline().split()))

    ans = [0]*(w*h)

    now = 0

    for i, x in enumerate(a):

        for j in range(x):

            ans[now + j] = i+1

        now += x

    for i in range(h):

        if i % 2:

            print((*reversed(ans[i*w:(i+1)*w])))

        else:

            print((*ans[i*w:(i+1)*w]))

if __name__ == "__main__":

    main()

import sys
import numpy as np

def main():
    h, w = list(map(int, sys.stdin.buffer.readline().split()))
    n = int(sys.stdin.buffer.readline())
    a = list(map(int, sys.stdin.buffer.readline().split()))
    ans = np.zeros(w * h, np.int64)
    now = 0
    for i, x in enumerate(a):
        for j in range(x):
            ans[now + j] = i + 1
        now += x
    ans = ans.reshape(h, w)
    for i in range(h):
        if i % 2:
            print((*ans[i, ::-1]))
        else:
            print((*ans[i]))

if __name__ == "__main__":
    main()

import sys

def main():
    h, w = list(map(int, sys.stdin.buffer.readline().split()))
    n = int(sys.stdin.buffer.readline())
    a = list(map(int, sys.stdin.buffer.readline().split()))
    ans = [0] * (w * h)
    now = 0
    for i, x in enumerate(a):
        for j in range(x):
            ans[now + j] = i + 1
        now += x
    for i in range(h):
        if i % 2:
            print((*reversed(ans[i * w : (i + 1) * w])))
        else:
            print((*ans[i * w : (i + 1) * w]))

if __name__ == "__main__":
    main()

+            print((*reversed(ans[i * w : (i + 1) * w])))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

n = int(eval(input()))

import math

m = int(math.sqrt(n))+1

anss = []

for x in range(1, m+1):

  y = n//x

  z = n%x

  if z == 0:

    anss.append(abs(x-1)+abs(y-1))

print((min(anss)))

# optimized version of the same code:

n = int(eval(input()))

def make_divisors(n):

    divisors = []

    for i in range(1, int(n**0.5)+1):

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n//i)

    #divisors.sort(reverse=True)

    return divisors

l = make_divisors(n)

min_ = float('inf')

for i in range(len(l)):

    min_ = min(min_, l[i]-1+n//l[i]-1)

print(min_)

n = int(eval(input()))
import math

m = int(math.sqrt(n)) + 1
anss = []
for x in range(1, m + 1):
    y = n // x
    z = n % x
    if z == 0:
        anss.append(abs(x - 1) + abs(y - 1))
print((min(anss)))

n = int(eval(input()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    # divisors.sort(reverse=True)
    return divisors

l = make_divisors(n)
min_ = float("inf")
for i in range(len(l)):
    min_ = min(min_, l[i] - 1 + n // l[i] - 1)
print(min_)

-        anss.append(abs(x - 1) + abs(y - 1))

+    for i in range(1, int(n**0.5) + 1):

+                divisors.append(n // i)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import numpy as np

N,L = list(map(int,input().split()))

apple = np.array(list(range(N))) + 1

taste = apple + L - 1

taste_applepie = sum(taste)

if L <= 0 and abs(N) > abs(L):

    print(taste_applepie)

elif L > 0:

    print((taste_applepie - L))

else:

    print((taste_applepie - (N+L-1)))

# optimized version of the same code:

N,L = list(map(int,input().split()))

t = [L+i-1 for i in range(1,N+1)]

abst = list(map(abs,t))

minind = abst.index(min(abst))

print((sum(t)-t[minind]))

import numpy as np

N, L = list(map(int, input().split()))
apple = np.array(list(range(N))) + 1
taste = apple + L - 1
taste_applepie = sum(taste)
if L <= 0 and abs(N) > abs(L):
    print(taste_applepie)
elif L > 0:
    print((taste_applepie - L))
else:
    print((taste_applepie - (N + L - 1)))

N, L = list(map(int, input().split()))
t = [L + i - 1 for i in range(1, N + 1)]
abst = list(map(abs, t))
minind = abst.index(min(abst))
print((sum(t) - t[minind]))

-    print((taste_applepie - (N + L - 1)))

+t = [L + i - 1 for i in range(1, N + 1)]


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

from collections import deque

n = int(eval(input()))

g = {i: dict() for i in range(n)}

a_list = [0] * (n - 1)

b_list = [0] * (n - 1)

for i in range(n - 1):

    a, b = list(map(int, input().split()))

    a_list[i] = a - 1

    b_list[i] = b - 1

    g[a - 1][b - 1] = -1

    g[b - 1][a - 1] = -1

k = max([len(g[a]) for a in range(n)])

used_color = [-1] * n

used_color[0] = k - 1

# BFS

queue = deque([0])

while len(queue) > 0:

    p = queue.popleft()

    c = used_color[p]

    for q in list(g[p].keys()):

        if used_color[q] != -1:

            continue

        c += 1

        c %= k

        # print(p, q, c)

        g[p][q] = c

        g[q][p] = c

        used_color[q] = c

        queue.append(q)

print(k)

for i in range(n - 1):

    print((g[a_list[i]][b_list[i]] + 1))

# optimized version of the same code:

from collections import deque

def solve(n, a_list, b_list):

    # create graph

    g = {i: dict() for i in range(n)}

    for i in range(n - 1):

        a, b = a_list[i] - 1, b_list[i] - 1

        g[a][b] = -1

        g[b][a] = -1

    k = max([len(g[a]) for a in range(n)])

    used_color = [-1] * n

    used_color[0] = k - 1

    # BFS

    queue = deque([0])

    while len(queue) > 0:

        p = queue.popleft()

        c = used_color[p]

        for q in list(g[p].keys()):

            if used_color[q] != -1:

                continue

            c += 1

            c %= k

            # print(p, q, c)

            g[p][q] = c

            g[q][p] = c

            used_color[q] = c

            queue.append(q)

    res_list = [0] * (n - 1)

    for i in range(n - 1):

        res_list[i] = g[a_list[i] - 1][b_list[i] - 1] + 1

    return k, res_list

def main():

    n = int(eval(input()))

    a_list = [0] * (n - 1)

    b_list = [0] * (n - 1)

    for i in range(n - 1):

        a, b = list(map(int, input().split()))

        a_list[i] = a

        b_list[i] = b

    k, res_list = solve(n, a_list, b_list)

    print(k)

    for i in range(n - 1):

        print((res_list[i]))

def test():

    print((solve(3, [1, 2], [2, 3])))

    print((solve(8, [1, 2, 2, 2, 4, 5, 6], [2, 3, 4, 5, 7, 6, 8])))

if __name__ == "__main__":

    # test()

    main()

-    a, b = list(map(int, input().split()))

-    print((g[a_list[i]][b_list[i]] + 1))

+        a, b = a_list[i] - 1, b_list[i] - 1

+    k = max([len(g[a]) for a in range(n)])

+        res_list[i] = g[a_list[i] - 1][b_list[i] - 1] + 1

+        a, b = list(map(int, input().split()))

+    k, res_list = solve(n, a_list, b_list)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import numpy as np

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

human=[]

for i in range(N):

  a,b=list(map(int, input().split()))

  human.append((a,b))

C=[]

for i in range(M):

  c,d=list(map(int, input().split()))

  C.append((c,d))

for h in human:

  a,b=h

  now=0

  mini=np.inf

  for i,ch in enumerate(C):

    c,d=ch

    L=abs(a-c)+abs(b-d)

    if mini>L:

      mini=L

      now=i+1

  print(now)

# optimized version of the same code:

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

S=[]

for i in range(N):

    a,b=list(map(int, input().split()))

    S.append((a,b))

C=[]

for i in range(M):

    c,d=list(map(int, input().split()))

    C.append((c,d,i+1))

#print(C)

for s in S:

    a,b=s

    now=0

    dis=10**9

    for t in C:

        c,d,n=t

        D=abs(c-a)+abs(d-b)

        if D<dis:

            dis=D

            now=n

    print(now)

import numpy as np

N, M = list(map(int, input().split()))
human = []
for i in range(N):
    a, b = list(map(int, input().split()))
    human.append((a, b))
C = []
for i in range(M):
    c, d = list(map(int, input().split()))
    C.append((c, d))
for h in human:
    a, b = h
    now = 0
    mini = np.inf
    for i, ch in enumerate(C):
        c, d = ch
        L = abs(a - c) + abs(b - d)
        if mini > L:
            mini = L
            now = i + 1
    print(now)

N, M = list(map(int, input().split()))
S = []
for i in range(N):
    a, b = list(map(int, input().split()))
    S.append((a, b))
C = []
for i in range(M):
    c, d = list(map(int, input().split()))
    C.append((c, d, i + 1))
# print(C)
for s in S:
    a, b = s
    now = 0
    dis = 10**9
    for t in C:
        c, d, n = t
        D = abs(c - a) + abs(d - b)
        if D < dis:
            dis = D
            now = n
    print(now)

-import numpy as np
-human = []
+S = []
-    human.append((a, b))
+    S.append((a, b))
-    C.append((c, d))
-for h in human:
-    a, b = h
+    C.append((c, d, i + 1))
+# print(C)
+for s in S:
+    a, b = s
-    mini = np.inf
-    for i, ch in enumerate(C):
-        c, d = ch
-        L = abs(a - c) + abs(b - d)
-        if mini > L:
-            mini = L
-            now = i + 1
+    dis = 10**9
+    for t in C:
+        c, d, n = t
+        D = abs(c - a) + abs(d - b)
+        if D < dis:
+            dis = D
+            now = n


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

a, b = list(map(int, input().split()))

if a*b%2 == 1:

    print("Odd")

else:

    print("Even")

# optimized version of the same code:

a, b = list(map(int, input().split()))

print(('Odd'if a&b&1 else 'Even'))

a, b = list(map(int, input().split()))
if a * b % 2 == 1:
    print("Odd")
else:
    print("Even")

a, b = list(map(int, input().split()))
print(("Odd" if a & b & 1 else "Even"))

+print(("Odd" if a & b & 1 else "Even"))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

# from decimal import Decimal

# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())

il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))

iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()

sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))

isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7

INF = float('inf')

def main():

    if os.getenv("LOCAL"):

        sys.stdin = open("input.txt", "r")

    S = ii()

    dp = [0] * (S + 1)

    dp[0] = 1

    # 0 <= i <= Sの範囲を探索

    for i in range(1, S + 1):

        # 0 <= j <= i - 3の範囲で、

        # 間仕切りを置くことができる個数の合計を集計

        for j in range(0, i - 3 + 1):

            dp[i] += dp[j]

            dp[i] %= MOD

    print((dp[-1]))

if __name__ == '__main__':

    main()

# optimized version of the same code:

import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

# from decimal import Decimal

# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())

il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))

iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()

sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))

isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7

INF = float('inf')

def main():

    if os.getenv("LOCAL"):

        sys.stdin = open("input.txt", "r")

    S = ii()

    dp = [0] * (S + 1)

    dp[0] = 1

    # 0 <= i <= Sの範囲を探索

    for i in range(1, S + 1):

        # 0 <= j <= i - 3の範囲で、

        # 間仕切りを置くことができる個数の合計を集計

        if i > 2:

            dp[i] = sum(dp[0:i - 2])

            dp[i] %= MOD

    print((dp[-1]))

if __name__ == '__main__':

    main()

import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
lcm = lambda x, y: (x * y) // math.gcd(x, y)
MOD = 10**9 + 7
INF = float("inf")

def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    S = ii()
    dp = [0] * (S + 1)
    dp[0] = 1
    # 0 <= i <= Sの範囲を探索
    for i in range(1, S + 1):
        # 0 <= j <= i - 3の範囲で、
        # 間仕切りを置くことができる個数の合計を集計
        for j in range(0, i - 3 + 1):
            dp[i] += dp[j]
            dp[i] %= MOD
    print((dp[-1]))

if __name__ == "__main__":
    main()

import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
lcm = lambda x, y: (x * y) // math.gcd(x, y)
MOD = 10**9 + 7
INF = float("inf")

def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    S = ii()
    dp = [0] * (S + 1)
    dp[0] = 1
    # 0 <= i <= Sの範囲を探索
    for i in range(1, S + 1):
        # 0 <= j <= i - 3の範囲で、
        # 間仕切りを置くことができる個数の合計を集計
        if i > 2:
            dp[i] = sum(dp[0 : i - 2])
            dp[i] %= MOD
    print((dp[-1]))

if __name__ == "__main__":
    main()


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

n = int(eval(input()))

m = 10**9 + 7

# ans = [0] * (n + 1)

ans = [0] * 2200

ans[0] = 1

# ans[3] = 1

# ans[4] = 1

# ans[5] = 1

for i in range(3, n + 1):

    for j in range(i - 2):

        ans[i] += ans[j]

        ans[i] %= m

print((ans[n]))

# print(ans[:10])

# optimized version of the same code:

-    for j in range(i - 2):
-        ans[i] += ans[j]
-        ans[i] %= m
+    ans[i] = ans[i - 1] + ans[i - 3]
+    ans[i] %= m
+    # for j in range(i - 2):
+    #     ans[i] += ans[j]
+    #     ans[i] %= m


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

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

r = list(map(int, input().split()))

d = [[float('inf')]*N for _ in range(N)]

for i in range(M): #ひとまず枝があるペアは枝の長さをセット

  a,b,t = list(map(int, input().split()))

  d[a-1][b-1] = t

  d[b-1][a-1] = t

for i in range(N):

  d[i][i] = 0 #自身への最短経路は0

#三重ループ

for k in range(N):

  for i in range(N):

    for j in range(N):

      d[i][j] = min(d[i][j], d[i][k]+d[k][j])

from itertools import groupby, accumulate, product, permutations, combinations

ans = float('inf')

for p in permutations(r,R):

  cnt = 0

  for i in range(1,R):

    cnt += d[p[i-1]-1][p[i]-1]

  ans = min(ans,cnt)

print(ans)

# optimized version of the same code:

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

R = list([int(x)-1 for x in input().split()])

d = [[1<<30]*N for _ in range(N)]

for i in range(M): #ひとまず枝があるペアは枝の長さをセット

  a,b,t = list(map(int, input().split()))

  d[a-1][b-1] = t

  d[b-1][a-1] = t

for i in range(N):

  d[i][i] = 0 #自身への最短経路は0

#三重ループ

for k in range(N):

  for i in range(N):

    for j in range(N):

      d[i][j] = min(d[i][j], d[i][k]+d[k][j])

from itertools import groupby, accumulate, product, permutations, combinations

ans = 1<<30

for per in permutations(R,r):

  cnt = 0

  for i in range(r-1):

    cnt += d[per[i]][per[i+1]]

  ans = min(ans, cnt)

print(ans)

N, M, R = list(map(int, input().split()))
r = list(map(int, input().split()))
d = [[float("inf")] * N for _ in range(N)]
for i in range(M):  # ひとまず枝があるペアは枝の長さをセット
    a, b, t = list(map(int, input().split()))
    d[a - 1][b - 1] = t
    d[b - 1][a - 1] = t
for i in range(N):
    d[i][i] = 0  # 自身への最短経路は0
# 三重ループ
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
from itertools import groupby, accumulate, product, permutations, combinations

ans = float("inf")
for p in permutations(r, R):
    cnt = 0
    for i in range(1, R):
        cnt += d[p[i - 1] - 1][p[i] - 1]
    ans = min(ans, cnt)
print(ans)

N, M, r = list(map(int, input().split()))
R = list([int(x) - 1 for x in input().split()])
d = [[1 << 30] * N for _ in range(N)]
for i in range(M):  # ひとまず枝があるペアは枝の長さをセット
    a, b, t = list(map(int, input().split()))
    d[a - 1][b - 1] = t
    d[b - 1][a - 1] = t
for i in range(N):
    d[i][i] = 0  # 自身への最短経路は0
# 三重ループ
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
from itertools import groupby, accumulate, product, permutations, combinations

ans = 1 << 30
for per in permutations(R, r):
    cnt = 0
    for i in range(r - 1):
        cnt += d[per[i]][per[i + 1]]
    ans = min(ans, cnt)
print(ans)

-N, M, R = list(map(int, input().split()))

-d = [[float("inf")] * N for _ in range(N)]

+N, M, r = list(map(int, input().split()))

+R = list([int(x) - 1 for x in input().split()])