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

from collections import Counter, deque, defaultdict

from itertools import accumulate, permutations, combinations, takewhile, compress, cycle

from functools import reduce

from math import ceil, floor, log10, log2, factorial

from pprint import pprint

sys.setrecursionlimit(1000000)

# MOD = 10 ** 9 + 7

# N = int(input())

# A = [int(x) for x in input().split()]

# V = [[0] * 100 for _ in range(100)]

# A = [int(input()) for _ in range(N)]

N, W = [int(x) for x in input().split()]

dp = [float('inf')] * 1000 * 100*10

vs = set()

vs.add(0)

dp[0] = 0

for i in range(N):

    w, v = [int(x) for x in input().split()]

    tmpDP = dp.copy()

    for vv in list(vs):

        if dp[vv + v] > dp[vv] + w:

            tmpDP[vv + v] = dp[vv] + w

            vs.add(vv + v)

    dp = tmpDP

ans = 0

for v in list(vs):

    if dp[v] <= W:

        ans = max(ans, v)

print(ans)

# optimized version of the same code:

import sys

from collections import Counter, deque, defaultdict

from itertools import accumulate, permutations, combinations, takewhile, compress, cycle

from functools import reduce

from math import ceil, floor, log10, log2, factorial

from pprint import pprint

sys.setrecursionlimit(1000000)

# MOD = 10 ** 9 + 7

# N = int(input())

# A = [int(x) for x in input().split()]

# V = [[0] * 100 for _ in range(100)]

# A = [int(input()) for _ in range(N)]

N, W = [int(x) for x in input().split()]

dp = defaultdict(lambda: float('inf'))

dp[0] = 0

for i in range(N):

    w, v = [int(x) for x in input().split()]

    add = defaultdict(lambda: float('inf'))

    for vv in list(dp.keys()):

        if dp[vv + v] > dp[vv] + w:

            add[vv + v] = dp[vv] + w

    dp.update(add)

print((max([i for i in list(dp.items()) if i[1] <= W], key=lambda x:x[0])[0]))

import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
N, W = [int(x) for x in input().split()]
dp = [float("inf")] * 1000 * 100 * 10
vs = set()
vs.add(0)
dp[0] = 0
for i in range(N):
    w, v = [int(x) for x in input().split()]
    tmpDP = dp.copy()
    for vv in list(vs):
        if dp[vv + v] > dp[vv] + w:
            tmpDP[vv + v] = dp[vv] + w
            vs.add(vv + v)
    dp = tmpDP
ans = 0
for v in list(vs):
    if dp[v] <= W:
        ans = max(ans, v)
print(ans)

import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
N, W = [int(x) for x in input().split()]
dp = defaultdict(lambda: float("inf"))
dp[0] = 0
for i in range(N):
    w, v = [int(x) for x in input().split()]
    add = defaultdict(lambda: float("inf"))
    for vv in list(dp.keys()):
        if dp[vv + v] > dp[vv] + w:
            add[vv + v] = dp[vv] + w
    dp.update(add)
print((max([i for i in list(dp.items()) if i[1] <= W], key=lambda x: x[0])[0]))

+    add = defaultdict(lambda: float("inf"))

+print((max([i for i in list(dp.items()) if i[1] <= W], key=lambda x: x[0])[0]))


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 math import factorial

N = int(eval(input()))

print((factorial(N) % (10**9 + 7)))

# optimized version of the same code:

from math import factorial

N = int(eval(input()))

ans = 1

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

    ans *= i % (10**9 + 7)

    ans %= 10**9 + 7

print(ans)

from math import factorial

N = int(eval(input()))
ans = 1
for i in range(1, N + 1):
    ans *= i % (10**9 + 7)
    ans %= 10**9 + 7
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

sys.setrecursionlimit(1000000000)

import math

from math import gcd

def lcm(a, b): return a * b // gcd(a, b)

from itertools import count, permutations, chain

from functools import lru_cache

from collections import deque, defaultdict

from pprint import pprint

ii = lambda: int(eval(input()))

mis = lambda: list(map(int, input().split()))

lmis = lambda: list(mis())

INF = float('inf')

N1097 = 10**9 + 7

def meg(f, ok, ng):

    while abs(ok-ng)>1:

        mid = (ok+ng)//2

        if f(mid):

            ok=mid

        else:

            ng=mid

    return ok

def get_inv(n, modp):

    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6

    fs = [1]

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

        fs.append(fs[-1] * i % modp)

    return fs

def invs_list(n, fs, modp):     # 10**6

    invs = [get_inv(fs[-1], modp)]

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

        invs.append(invs[-1] * i % modp)

    invs.reverse()

    return invs

def comb(n, k, modp):

    num = 1

    for i in range(n, n-k, -1):

        num = num * i % modp

    den = 1

    for i in range(2, k+1):

        den = den * i % modp

    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):

    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:

    def __init__(self, size):

        #正なら根の番号、負ならグループサイズ

        self.roots = [-1] * size

    def getRootID(self, i):

        r = self.roots[i]

        if r < 0:   #負なら根

            return i

        else:

            r = self.getRootID(r)

            self.roots[i] = r

            return r

    def getGroupSize(self, i):

        return -self.roots[self.getRootID(i)]

    def connect(self, i, j):

        r1, r2 = self.getRootID(i), self.getRootID(j)

        if r1 == r2:

            return False

        if self.getGroupSize(r1) < self.getGroupSize(r2):

            r1, r2 = r2, r1

        self.roots[r1] += self.roots[r2]    #サイズ更新

        self.roots[r2] = r1

        return True

Yes = 'Yes'

No = 'No'

def main():

    S = eval(input())

    d = [0]*2019

    dn = [0]*2019

    ans = 0

    for s in S:

        sn = int(s)

        dn[sn] += 1

        for i in range(2019):

            dn[(i*10+sn)%2019] += d[i]

        d, dn = dn, d

        for i in range(2019):

            dn[i] = 0

        ans += d[0]

    print(ans)

main()

# optimized version of the same code:

'''

[point 1]

1817181712114 の部分 "18171"について考える...

    181710000 / 10000 ≡ 0 (MOD 2019) ならば、2019の倍数

    181710000 ≡ 0 (MOD 2019) でよい

[point 2]

    181710000

    =

    181712114

    -

         2114

    なので、特定区間の値 は 累積和の差 から瞬時に求められる。

    さらに、181710000 ≡ 0 (MOD 2019) を考えると、

    0 ≡ 181712114 - 2114

    → 181712114 ≡ 2114

    となる。

    結局の所、MOD2019において合同な累積和のペアの数の数え上げ。

'''

from collections import defaultdict

def gen_10exp_mod(n, mod):

    a = 1

    yield a

    for _ in range(1, n):

        a = (a*10) % mod

        yield a

def main():

    MOD = 2019

    S = input()[::-1]

    # 桁ごとの実際の値を計算 (MOD)

    A = [int(s)*n % MOD for s, n in zip(S, gen_10exp_mod(len(S), MOD))]

    # 累積和を計算

    ACC = [0]

    for a in A:

        ACC.append((ACC[-1] + a) % MOD)

    # ペア数え上げ

    d = defaultdict(int)

    for acc in ACC:

        d[acc] += 1

    ans = sum(v*(v-1)//2 for v in list(d.values()))

    print(ans)

main()

import sys

sys.setrecursionlimit(1000000000)
import math
from math import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

ii = lambda: int(eval(input()))
mis = lambda: list(map(int, input().split()))
lmis = lambda: list(mis())
INF = float("inf")
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if f(mid):
            ok = mid
        else:
            ng = mid
    return ok

def get_inv(n, modp):
    return pow(n, modp - 2, modp)

def factorials_list(n, modp):  # 10**6
    fs = [1]
    for i in range(1, n + 1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):  # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1 - 1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n - k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k + 1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n - k] * invs[k] % modp

#
class UnionFindEx:
    def __init__(self, size):
        # 正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size

    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:  # 負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r

    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]

    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]  # サイズ更新
        self.roots[r2] = r1
        return True

Yes = "Yes"
No = "No"

def main():
    S = eval(input())
    d = [0] * 2019
    dn = [0] * 2019
    ans = 0
    for s in S:
        sn = int(s)
        dn[sn] += 1
        for i in range(2019):
            dn[(i * 10 + sn) % 2019] += d[i]
        d, dn = dn, d
        for i in range(2019):
            dn[i] = 0
        ans += d[0]
    print(ans)

main()

"""
[point 1]
1817181712114 の部分 "18171"について考える...
    181710000 / 10000 ≡ 0 (MOD 2019) ならば、2019の倍数
    181710000 ≡ 0 (MOD 2019) でよい
[point 2]
    181710000
    =
    181712114
    -
         2114
    なので、特定区間の値 は 累積和の差 から瞬時に求められる。
    さらに、181710000 ≡ 0 (MOD 2019) を考えると、
    0 ≡ 181712114 - 2114
    → 181712114 ≡ 2114
    となる。
    結局の所、MOD2019において合同な累積和のペアの数の数え上げ。
"""
from collections import defaultdict

def gen_10exp_mod(n, mod):
    a = 1
    yield a
    for _ in range(1, n):
        a = (a * 10) % mod
        yield a

def main():
    MOD = 2019
    S = input()[::-1]
    # 桁ごとの実際の値を計算 (MOD)
    A = [int(s) * n % MOD for s, n in zip(S, gen_10exp_mod(len(S), MOD))]
    # 累積和を計算
    ACC = [0]
    for a in A:
        ACC.append((ACC[-1] + a) % MOD)
    # ペア数え上げ
    d = defaultdict(int)
    for acc in ACC:
        d[acc] += 1
    ans = sum(v * (v - 1) // 2 for v in list(d.values()))
    print(ans)

main()

+    なので、特定区間の値 は 累積和の差 から瞬時に求められる。

+    結局の所、MOD2019において合同な累積和のペアの数の数え上げ。

-from itertools import count, permutations, chain

-from collections import deque, defaultdict

-mis = lambda: list(map(int, input().split()))

-        invs.append(invs[-1] * i % modp)

-    return num * get_inv(den, modp) % modp

-def comb_from_list(n, k, modp, fs, invs):

-    return fs[n] * invs[n - k] * invs[k] % modp

-        # 正なら根の番号、負ならグループサイズ

-        return -self.roots[self.getRootID(i)]

-        r1, r2 = self.getRootID(i), self.getRootID(j)

-        if self.getGroupSize(r1) < self.getGroupSize(r2):

-        self.roots[r1] += self.roots[r2]  # サイズ更新

+    # 桁ごとの実際の値を計算 (MOD)

+    A = [int(s) * n % MOD for s, n in zip(S, gen_10exp_mod(len(S), MOD))]

+    # 累積和を計算

+        ACC.append((ACC[-1] + a) % MOD)

+    # ペア数え上げ

+    ans = sum(v * (v - 1) // 2 for v in list(d.values()))


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

input = sys.stdin.readline

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

broken = set([int(eval(input())) for _ in range(m)]) # ここが'list'だとPypyでも通らない

def ptn_num(x): # 'x'stepまでのパターン数

    dp = [0] * (x+1) # DP枠_including step'0'

    if 1 in broken: # in case, step'1' broken

        dp[:2] = 1, 0

    else:

        dp[:2] = 1, 1 # Usually

    for i in range(2, x+1):

        if i not in broken: # 階段が壊れてない場合...

            dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7) # -1段目と-2段目の合計

    print((dp[-1]))

ptn_num(n)

# optimized version of the same code:

import sys

input = sys.stdin.readline

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

broken = set([int(eval(input())) for _ in range(m)]) # ここが'list'だとPypyでも通らない

def ptn_num(x): # 'x'stepまでのパターン数

    dp = [0] * (x+1) # DP枠_including step'0'

    if 1 in broken: # 固定部分_in case, step'1' broken

        dp[:2] = 1, 0

    else:

        dp[:2] = 1, 1 # 固定部分_Usually

    for i in range(2, x+1):

        if i not in broken: # 階段が壊れてない場合...

            dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7) # -1段目と-2段目の合計

    print((dp[-1]))

ptn_num(n)

import sys

input = sys.stdin.readline
n, m = list(map(int, input().split()))
broken = set([int(eval(input())) for _ in range(m)])  # ここが'list'だとPypyでも通らない

def ptn_num(x):  # 'x'stepまでのパターン数
    dp = [0] * (x + 1)  # DP枠_including step'0'
    if 1 in broken:  # in case, step'1' broken
        dp[:2] = 1, 0
    else:
        dp[:2] = 1, 1  # Usually
    for i in range(2, x + 1):
        if i not in broken:  # 階段が壊れてない場合...
            dp[i] = (dp[i - 1] + dp[i - 2]) % (10**9 + 7)  # -1段目と-2段目の合計
    print((dp[-1]))

ptn_num(n)

import sys

input = sys.stdin.readline
n, m = list(map(int, input().split()))
broken = set([int(eval(input())) for _ in range(m)])  # ここが'list'だとPypyでも通らない

def ptn_num(x):  # 'x'stepまでのパターン数
    dp = [0] * (x + 1)  # DP枠_including step'0'
    if 1 in broken:  # 固定部分_in case, step'1' broken
        dp[:2] = 1, 0
    else:
        dp[:2] = 1, 1  # 固定部分_Usually
    for i in range(2, x + 1):
        if i not in broken:  # 階段が壊れてない場合...
            dp[i] = (dp[i - 1] + dp[i - 2]) % (10**9 + 7)  # -1段目と-2段目の合計
    print((dp[-1]))

ptn_num(n)

-    if 1 in broken:  # in case, step'1' broken

+    if 1 in broken:  # 固定部分_in case, step'1' broken


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

while True:

	try:

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

		print('%d %d' % (fractions.gcd(x,y),x/fractions.gcd(x,y)*y))

	except EOFError:

		break

# optimized version of the same code:

def gcd(x, y):

    if y == 0:

        return x

    else:

        return gcd(y, x%y)

def lcm(x,y):

    return x/gcd(x, y)*y

while True:

    try:

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

    except EOFError:

        break

    print("%d %d" % (gcd(x, y), lcm(x, y)))

import fractions

while True:
    try:
        x, y = list(map(int, input().split()))
        print("%d %d" % (fractions.gcd(x, y), x / fractions.gcd(x, y) * y))
    except EOFError:
        break

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

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

while True:
    try:
        x, y = list(map(int, input().split()))
    except EOFError:
        break
    print("%d %d" % (gcd(x, y), lcm(x, y)))

-        print("%d %d" % (fractions.gcd(x, y), x / fractions.gcd(x, y) * y))

+    print("%d %d" % (gcd(x, y), lcm(x, y)))


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

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

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

x = np.zeros(N+1)

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

    x[n] = x[n-1] + L[n-1]

    if x[n] > X:

        print(n)

        sys.exit()

print((N+1))

# optimized version of the same code:

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

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

cnt = 1

sum_L = 0

for l in L:

    sum_L += l

    if sum_L <= X:

        cnt += 1

    else:

        break

print(cnt)

import sys
import numpy as np

N, X = list(map(int, input().split()))
L = np.array(list(map(int, input().split())))
x = np.zeros(N + 1)
for n in range(1, N + 1):
    x[n] = x[n - 1] + L[n - 1]
    if x[n] > X:
        print(n)
        sys.exit()
print((N + 1))

-L = np.array(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()))

r = int(n**.5)

for i in range(r):

  if n % (r-i) == 0:

    print(( (r-i) + n//(r-i) - 2 ))

    break

# optimized version of the same code:

n = int(eval(input()))

s = int(n**.5)

for i in range(s):

  if n % (s-i) == 0:

    print(((s-i) + n // (s-i) - 2))

    break

n = int(eval(input()))
r = int(n**0.5)
for i in range(r):
    if n % (r - i) == 0:
        print(((r - i) + n // (r - i) - 2))
        break

n = int(eval(input()))
s = int(n**0.5)
for i in range(s):
    if n % (s - i) == 0:
        print(((s - i) + n // (s - i) - 2))
        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 collections import Counter

def factorization(n) -> list:

	if n==1:

		return [1]

	ret = []

	i = 2

	while i*i<=n:

		while n%i==0:

			n //= i

			ret.append(i)

		i += 1

	if n!=1:

		ret.append(n)

	return ret

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

mod = 10**9+7

if m==1:

	print((1));exit()

factors = Counter(factorization(m))

mx = n+max(factors.values())

fac = [1]*(mx+1)

inv = [1]*(mx+1)

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

	fac[i] = fac[i-1] * i % mod

inv[-1] = pow(fac[-1], mod - 2, mod)

for i in range(mx-1, -1, -1):

	inv[i] = inv[i+1] * (i+1) % mod

def cmb(n,r):

	assert n >= r >= 0

	return fac[n] * inv[n-r] * inv[r] % mod

ans=1

for v in list(factors.values()):

	ans*=cmb(n+v-1,v)

	ans%=mod

print(ans)

# optimized version of the same code:

from collections import Counter

def factorization(n) -> list:

	if n==1:return [1]

	ret = []

	i = 2

	while i*i<=n:

		while n%i==0:

			n //= i

			ret.append(i)

		i += 1

	if n!=1:ret.append(n)

	return ret

from operator import mul

from functools import reduce

def cmb(n,r):

	if n < r:return 0

	r = min(n-r,r)

	if r==0:return 1

	u = reduce(mul, list(range(n, n-r, -1)))

	d = reduce(mul, list(range(1,r+1)))

	return u//d

def main():

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

	mod = 10**9+7

	if m==1:

		print((1))

		exit()

	ans=1

	for v in list(Counter(factorization(m)).values()):

		ans*=cmb(n+v-1,v)

		ans%=mod

	print(ans)

if __name__=="__main__":main()

from collections import Counter

def factorization(n) -> list:
    if n == 1:
        return [1]
    ret = []
    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            ret.append(i)
        i += 1
    if n != 1:
        ret.append(n)
    return ret

n, m = list(map(int, input().split()))
mod = 10**9 + 7
if m == 1:
    print((1))
    exit()
factors = Counter(factorization(m))
mx = n + max(factors.values())
fac = [1] * (mx + 1)
inv = [1] * (mx + 1)
for i in range(1, mx + 1):
    fac[i] = fac[i - 1] * i % mod
inv[-1] = pow(fac[-1], mod - 2, mod)
for i in range(mx - 1, -1, -1):
    inv[i] = inv[i + 1] * (i + 1) % mod

def cmb(n, r):
    assert n >= r >= 0
    return fac[n] * inv[n - r] * inv[r] % mod

ans = 1
for v in list(factors.values()):
    ans *= cmb(n + v - 1, v)
    ans %= mod
print(ans)

from collections import Counter

def factorization(n) -> list:
    if n == 1:
        return [1]
    ret = []
    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            ret.append(i)
        i += 1
    if n != 1:
        ret.append(n)
    return ret

from operator import mul
from functools import reduce

def cmb(n, r):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    u = reduce(mul, list(range(n, n - r, -1)))
    d = reduce(mul, list(range(1, r + 1)))
    return u // d

def main():
    n, m = list(map(int, input().split()))
    mod = 10**9 + 7
    if m == 1:
        print((1))
        exit()
    ans = 1
    for v in list(Counter(factorization(m)).values()):
        ans *= cmb(n + v - 1, v)
        ans %= mod
    print(ans)

if __name__ == "__main__":
    main()

-    return fac[n] * inv[n - r] * inv[r] % mod

+    u = reduce(mul, list(range(n, n - r, -1)))

+    d = reduce(mul, list(range(1, r + 1)))

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

+    for v in list(Counter(factorization(m)).values()):


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, N = list(map(int, input().split()))

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

diff = A[0] + K - A[-1]

ans = A[-1] - A[0]

for i in range(1, N):

    dist = K - A[i] + A[i - 1]

    if dist < ans:

        ans = dist

print(ans)

# optimized version of the same code:

import sys

def input():

    return sys.stdin.readline().strip()

def main():

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

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

    ans = [K - A[i] + A[i - 1] for i in range(1, N)]

    print((min(min(ans), A[-1] - A[0])))

main()

+    return sys.stdin.readline().strip()

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

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

+    ans = [K - A[i] + A[i - 1] for i in range(1, 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 sys

import numpy as np

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

x = []

y = []

for i in range(n):

    a = int(sys.stdin.readline().rstrip())

    xy = [sys.stdin.readline().split() for _ in range(a)]

    if not xy:

        x.append(None)

        y.append(None)

        continue

    xi, yi = np.array(xy, np.int64).T

    x.append(xi-1)

    y.append(yi)

def main():

    ans = 0

    for comb in range(2 ** n):

        cnt = 0

        for i in range(n):

            if not comb >> i & 1:

                continue

            if x[i] is None:

                cnt += 1

                continue

            if np.count_nonzero(comb >> x[i] & 1 ^ y[i]):

                break

            cnt += 1

        else:

            ans = max(ans, cnt)

    return ans

if __name__ == '__main__':

    ans = main()

    print(ans)

# optimized version of the same code:

import sys

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

xy = [[] for _ in range(n)]

for i in range(n):

    a = int(sys.stdin.readline().rstrip())

    for j in range(a):

        x, y = list(map(int, sys.stdin.readline().split()))

        xy[i].append((x-1, y))

def main():

    ans = 0

    for comb in range(2 ** n):

        cnt = 0

        for i in range(n):

            if comb >> i & 1 ^ 1:

                continue

            for x, y in xy[i]:

                if comb >> x & 1 ^ y:

                    break

            else:

                cnt += 1

                continue

            break

        else:

            ans = max(ans, cnt)

    return ans

if __name__ == '__main__':

    ans = main()

    print(ans)

import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
x = []
y = []
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    xy = [sys.stdin.readline().split() for _ in range(a)]
    if not xy:
        x.append(None)
        y.append(None)
        continue
    xi, yi = np.array(xy, np.int64).T
    x.append(xi - 1)
    y.append(yi)

def main():
    ans = 0
    for comb in range(2**n):
        cnt = 0
        for i in range(n):
            if not comb >> i & 1:
                continue
            if x[i] is None:
                cnt += 1
                continue
            if np.count_nonzero(comb >> x[i] & 1 ^ y[i]):
                break
            cnt += 1
        else:
            ans = max(ans, cnt)
    return ans

if __name__ == "__main__":
    ans = main()
    print(ans)

import sys

n = int(sys.stdin.readline().rstrip())
xy = [[] for _ in range(n)]
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    for j in range(a):
        x, y = list(map(int, sys.stdin.readline().split()))
        xy[i].append((x - 1, y))

def main():
    ans = 0
    for comb in range(2**n):
        cnt = 0
        for i in range(n):
            if comb >> i & 1 ^ 1:
                continue
            for x, y in xy[i]:
                if comb >> x & 1 ^ y:
                    break
            else:
                cnt += 1
                continue
            break
        else:
            ans = max(ans, cnt)
    return ans

if __name__ == "__main__":
    ans = main()
    print(ans)

-    xy = [sys.stdin.readline().split() for _ in range(a)]

+        x, y = list(map(int, sys.stdin.readline().split()))

-            if np.count_nonzero(comb >> x[i] & 1 ^ y[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:

from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

INF = float('inf')

def sol():

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

    edges = []

    for _ in range(M):

        fr, to, cost = list(map(int, input().split()))

        fr -= 1

        to -= 1

        edges.append((fr, to, cost))

    graph = [[INF] * N for _ in range(N)]

    for fr, to, cost in edges:

        graph[fr][to] = cost

    graph = csgraph_from_dense(graph, null_value=INF)

    dist = floyd_warshall(graph, directed=False)

    ans = (graph > dist).sum()

    print(ans)

sol()

# optimized version of the same code:

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

INF = 10**18

minDist = [[INF] * N for _ in range(N)]

for i in range(N):

    minDist[i][i] = 0

edges = []

for _ in range(M):

    fr, to, d = list(map(int, input().split()))

    fr -= 1

    to -= 1

    edges.append((fr, to, d))

    minDist[fr][to] = d

    minDist[to][fr] = d

for k in range(N):

    for i in range(N):

        for j in range(N):

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

            if minDist[i][j] > d:

                minDist[i][j] = d

ans = 0

for fr, to, d in edges:

    if minDist[fr][to] < d:

        ans += 1

print(ans)

from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

INF = float("inf")

def sol():
    N, M = list(map(int, input().split()))
    edges = []
    for _ in range(M):
        fr, to, cost = list(map(int, input().split()))
        fr -= 1
        to -= 1
        edges.append((fr, to, cost))
    graph = [[INF] * N for _ in range(N)]
    for fr, to, cost in edges:
        graph[fr][to] = cost
    graph = csgraph_from_dense(graph, null_value=INF)
    dist = floyd_warshall(graph, directed=False)
    ans = (graph > dist).sum()
    print(ans)

sol()

-from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

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

-        fr, to, cost = list(map(int, input().split()))

-    graph = [[INF] * N for _ in range(N)]

-    graph = csgraph_from_dense(graph, null_value=INF)

-    dist = floyd_warshall(graph, directed=False)

+minDist = [[INF] * N for _ in range(N)]

+    fr, to, d = list(map(int, input().split()))

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


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

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

def resolve():

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

    ans = float('inf')

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

        ans = min(A*max(X-i//2, 0)+B*max(Y-i//2, 0)+C*i, ans)

    print(ans)

if __name__ == '__main__':

    resolve()

# optimized version of the same code:

import sys

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

def resolve():

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

    ans = 0

    if A+B > 2*C:

        ans = 2*C*min(X, Y)+min((A if X>Y else B)*abs(X-Y), 2*C*abs(X-Y))

    else:

        ans = A*X+B*Y

    print(ans)

if __name__ == '__main__':

    resolve()

import sys

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

def resolve():
    A, B, C, X, Y = list(map(int, input().split()))
    ans = float("inf")
    for i in range(0, max(X, Y) * 2 + 1, 2):
        ans = min(A * max(X - i // 2, 0) + B * max(Y - i // 2, 0) + C * i, ans)
    print(ans)

if __name__ == "__main__":
    resolve()

import sys

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

def resolve():
    A, B, C, X, Y = list(map(int, input().split()))
    ans = 0
    if A + B > 2 * C:
        ans = 2 * C * min(X, Y) + min(
            (A if X > Y else B) * abs(X - Y), 2 * C * abs(X - Y)
        )
    else:
        ans = A * X + B * Y
    print(ans)

if __name__ == "__main__":
    resolve()

-    for i in range(0, max(X, Y) * 2 + 1, 2):

+            (A if X > Y else B) * abs(X - Y), 2 * C * abs(X - Y)


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()))

ans = 0

for i in range(A,B+1):

    i = str(i)

    if i[0] == i[4]:

        if i[1] == i[3]:

            ans += 1

        else:

            ans += 0

    else:

        ans += 0

print(ans)

# optimized version of the same code:

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

ans = 0

for i in range(A,B+1):

    k = str(i)

    if k[0] == k[4] and k[1] == k[3]:

        ans += 1

print(ans)

A, B = list(map(int, input().split()))
ans = 0
for i in range(A, B + 1):
    i = str(i)
    if i[0] == i[4]:
        if i[1] == i[3]:
            ans += 1
        else:
            ans += 0
    else:
        ans += 0
print(ans)

A, B = list(map(int, input().split()))
ans = 0
for i in range(A, B + 1):
    k = str(i)
    if k[0] == k[4] and k[1] == k[3]:
        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:

def main():

    N = int(input())

    A = [int(i) for i in input().split()]

    if N == 1:

        return print(1 if A[0] % 2 == 0 else 2)

    ans = 0

    d = (-1, 0, 1)

    from itertools import product

    for i in product(range(3), repeat=N):

        cur = 1

        for j in range(N):

            cur *= (A[j] + d[i[j]])

        if cur % 2 == 0:

            ans += 1

    print(ans)

if __name__ == '__main__':

    main()

# optimized version of the same code:

def main():

    N = int(eval(input()))

    A = [int(i) for i in input().split()]

    ans = 3**N

    cnt = len([a for a in A if a % 2 == 0])

    ans -= 2**cnt

    print(ans)

if __name__ == '__main__':

    main()

def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    if N == 1:
        return print(1 if A[0] % 2 == 0 else 2)
    ans = 0
    d = (-1, 0, 1)
    from itertools import product

    for i in product(range(3), repeat=N):
        cur = 1
        for j in range(N):
            cur *= A[j] + d[i[j]]
        if cur % 2 == 0:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    ans = 3**N
    cnt = len([a for a in A if a % 2 == 0])
    ans -= 2**cnt
    print(ans)

if __name__ == "__main__":
    main()

-        return print(1 if A[0] % 2 == 0 else 2)

-    for i in product(range(3), repeat=N):

+    cnt = len([a for a in A if a % 2 == 0])


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, d = list(map(int, input().split()))

x = []

for i in range(n):

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

x = np.array(x)

count =	0

for i in range(n):

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

        dist = np.linalg.norm(x[i] - x[j])

        if dist == int(dist):

            count += 1

print(count)

# optimized version of the same code:

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

x = [list(map(int, input().split())) for _ in range(n)]

def dist(a, b):

    sm = 0

    for ea, eb in zip(a, b):

        sm += (ea - eb) ** 2

    return sm ** 0.5

ans = 0

for i in range(n):

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

        dst = dist(x[i], x[j])

        for k in range(int(16000 ** 0.5) + 1):

            if k == dst:

                ans += 1

                break

print(ans)

import numpy as np

n, d = list(map(int, input().split()))
x = []
for i in range(n):
    x.append(list(map(int, input().split())))
x = np.array(x)
count = 0
for i in range(n):
    for j in range(i + 1, n):
        dist = np.linalg.norm(x[i] - x[j])
        if dist == int(dist):
            count += 1
print(count)

n, d = list(map(int, input().split()))
x = [list(map(int, input().split())) for _ in range(n)]

def dist(a, b):
    sm = 0
    for ea, eb in zip(a, b):
        sm += (ea - eb) ** 2
    return sm**0.5

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        dst = dist(x[i], x[j])
        for k in range(int(16000**0.5) + 1):
            if k == dst:
                ans += 1
                break
print(ans)

+x = [list(map(int, input().split())) for _ in range(n)]

-    x.append(list(map(int, input().split())))

-        dist = np.linalg.norm(x[i] - x[j])


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,x = list(map(int,input().split()))

A = np.array(input().split(), dtype = np.int64)

A.sort()

np.cumsum(A, out = A)

answer = (A <= x).sum()

if answer == N and A[-1] != x:

  answer -= 1

print(answer)

# optimized version of the same code:

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

from bisect import bisect_right

import itertools

N,X,*A = list(map(int,read().split()))

A.sort()

Acum = list(itertools.accumulate(A))

answer = bisect_right(Acum,X)

if answer == N:

    if Acum[-1] < X:

        answer -= 1

print(answer)

import numpy as np

N, x = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.int64)
A.sort()
np.cumsum(A, out=A)
answer = (A <= x).sum()
if answer == N and A[-1] != x:
    answer -= 1
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from bisect import bisect_right
import itertools

N, X, *A = list(map(int, read().split()))
A.sort()
Acum = list(itertools.accumulate(A))
answer = bisect_right(Acum, X)
if answer == N:
    if Acum[-1] < X:
        answer -= 1
print(answer)

-A = np.array(input().split(), dtype=np.int64)

+N, X, *A = list(map(int, read().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:

# -*- coding: utf-8 -*-

from collections import defaultdict

from itertools import combinations

N = int(eval(input()))

C = [0, 0, 0, 0, 0, 0]

D = defaultdict(int)

for i, m in enumerate("MARCH", start=1):

    D[m] = i

for _ in range(N):

    C[D[input()[0]]] += 1

ans = 0

for a, b, c in combinations(list(range(1, 6)), r=3):

    ans += C[a]*C[b]*C[c]

print(ans)

# optimized version of the same code:

from collections import defaultdict

from itertools import combinations

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

C = defaultdict(int)

N = int(eval(input()))

for _ in range(N):

    C[input()[0]] += 1

res = 0

for H in combinations("MARCH", r=3):

    res += C[H[0]] * C[H[1]] * C[H[2]]

print(res)

# -*- coding: utf-8 -*-
from collections import defaultdict
from itertools import combinations

N = int(eval(input()))
C = [0, 0, 0, 0, 0, 0]
D = defaultdict(int)
for i, m in enumerate("MARCH", start=1):
    D[m] = i
for _ in range(N):
    C[D[input()[0]]] += 1
ans = 0
for a, b, c in combinations(list(range(1, 6)), r=3):
    ans += C[a] * C[b] * C[c]
print(ans)

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

-for i, m in enumerate("MARCH", start=1):

-for a, b, c in combinations(list(range(1, 6)), r=3):


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()))

print((math.factorial(N) % (1000000000 + 7)))

# optimized version of the same code:

import math

N = int(eval(input()))

p = 1

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

  p *= i

  p = p % (1000000000 + 7)

print(p)

import math

N = int(eval(input()))
p = 1
for i in range(2, N + 1):
    p *= i
    p = p % (1000000000 + 7)
print(p)


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:

def main():

    from statistics import median

    n, *a, = list(map(int, open(0).read().split()))

    a = [x - i for i, x in enumerate(a, 1)]

    a.sort()

    m = int(median(a))

    ans = sum([abs(x - m) for x in a])

    print(ans)

if __name__ == '__main__':

    main()

# optimized version of the same code:

def main():

    n, *a, = list(map(int, open(0).read().split()))

    a = [x - i for i, x in enumerate(a, 1)]

    a.sort()

    if n % 2 == 0:

        ans = sum(a[n // 2:]) - sum(a[:n // 2])

    else:

        ans = sum(a[n // 2 + 1:]) - sum(a[:n // 2])

    print(ans)

if __name__ == '__main__':

    main()

def main():
    from statistics import median

    (
        n,
        *a,
    ) = list(map(int, open(0).read().split()))
    a = [x - i for i, x in enumerate(a, 1)]
    a.sort()
    m = int(median(a))
    ans = sum([abs(x - m) for x in a])
    print(ans)

if __name__ == "__main__":
    main()

def main():
    (
        n,
        *a,
    ) = list(map(int, open(0).read().split()))
    a = [x - i for i, x in enumerate(a, 1)]
    a.sort()
    if n % 2 == 0:
        ans = sum(a[n // 2 :]) - sum(a[: n // 2])
    else:
        ans = sum(a[n // 2 + 1 :]) - sum(a[: n // 2])
    print(ans)

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:

x = int(eval(input()))

for a in range(10**4):

    for b in range(10**4):

        if(a**5 + b**5 == x):

            print((a, -b))

            break

        elif(a**5 - b**5 == x):

            print((a, b))

            break

    else:

        continue

    break

# optimized version of the same code:

x = int(eval(input()))

for a in range(10**3):

    for b in range(10**3):

        if(a**5 + b**5 == x):

            print((a, -b))

            break

        elif(a**5 - b**5 == x):

            print((a, b))

            break

    else:

        continue

    break

x = int(eval(input()))
for a in range(10**4):
    for b in range(10**4):
        if a**5 + b**5 == x:
            print((a, -b))
            break
        elif a**5 - b**5 == x:
            print((a, b))
            break
    else:
        continue
    break

x = int(eval(input()))
for a in range(10**3):
    for b in range(10**3):
        if a**5 + b**5 == x:
            print((a, -b))
            break
        elif a**5 - b**5 == x:
            print((a, b))
            break
    else:
        continue
    break

-for a in range(10**4):
-    for b in range(10**4):
+for a in range(10**3):
+    for b in range(10**3):


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 = [], []

low = -float('INF')

high = float('INF')

for i in range(M):

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

    L.append(l)

    R.append(r)

    if l > low:

        low = l

    if r < high:

        high = r

print((max(0, high - low + 1)))

# optimized version of the same code:

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

low = -float('INF')

high = float('INF')

for i in range(M):

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

    if l > low:

        low = l

    if r < high:

        high = r

print((max(0, high - low + 1)))

N, M = list(map(int, input().split()))
L, R = [], []
low = -float("INF")
high = float("INF")
for i in range(M):
    l, r = list(map(int, input().split()))
    L.append(l)
    R.append(r)
    if l > low:
        low = l
    if r < high:
        high = r
print((max(0, high - low + 1)))

N, M = list(map(int, input().split()))
low = -float("INF")
high = float("INF")
for i in range(M):
    l, r = list(map(int, input().split()))
    if l > low:
        low = l
    if r < high:
        high = r
print((max(0, high - low + 1)))

-L, R = [], []
-    L.append(l)
-    R.append(r)


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:

def main():

    from sys import stdin

    def input():

        return stdin.readline().strip()

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

    tree = [[] for _ in range(n)]

    for _ in range(m):

        i, j, k = list(map(int, input().split()))

        i -= 1

        j -= 1

        tree[i].append((k, j))

        tree[j].append((k, i))

    # dijkstra

    import heapq

    from numpy import zeros

    ans = 0

    for i in range(n):

        for j in tree[i]:

            seen = zeros(n)

            goal = j[1]

            base = j[0]

            seen[i] = 1

            todo = []

            heapq.heapify(todo)

            for k in tree[i]:

                if k[0] < base and k != j:

                    heapq.heappush(todo, k)

            while len(todo) > 0:

                k = heapq.heappop(todo)

                if k[1] == goal:

                    if k[0] < base:

                        ans += 1

                    break

                seen[k[1]] = 1

                for l in tree[k[1]]:

                    if seen[l[1]] == 0 and k[0] + l[0] < base:

                        heapq.heappush(todo, (k[0] + l[0], l[1]))

    print((ans // 2))

main()

# optimized version of the same code:

def main():

    from sys import stdin

    def input():

        return stdin.readline().strip()

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

    tree = [[] for _ in range(n)]

    for _ in range(m):

        i, j, k = list(map(int, input().split()))

        i -= 1

        j -= 1

        tree[i].append((k, j))

        tree[j].append((k, i))

    # dijkstra

    import heapq

    ans = 0

    for i in range(n):

        for j in tree[i]:

            seen = [0] * n

            goal = j[1]

            base = j[0]

            seen[i] = 1

            todo = []

            heapq.heapify(todo)

            for k in tree[i]:

                if k[0] < base and k != j:

                    heapq.heappush(todo, k)

            while len(todo) > 0:

                k = heapq.heappop(todo)

                if k[1] == goal:

                    if k[0] < base:

                        ans += 1

                    break

                seen[k[1]] = 1

                for l in tree[k[1]]:

                    if seen[l[1]] == 0 and k[0] + l[0] < base:

                        heapq.heappush(todo, (k[0] + l[0], l[1]))

    print((ans // 2))

main()

-    from numpy import zeros
-            seen = zeros(n)
+            seen = [0] * 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 numpy as np

def main():

    stdin = np.fromstring(open(0).read(), dtype=np.int64, sep=' ')

    A = stdin[1:]

    A = np.mod(A, 2)

    print("first") if np.count_nonzero(A) else print("second")

if __name__ == "__main__":

    main()

# optimized version of the same code:

import sys

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

def main():

    N = int(input())

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

    print("second") if all(( a%2==0 for a in A)) else print("first")

if __name__ == "__main__":

    main()

import numpy as np

def main():
    stdin = np.fromstring(open(0).read(), dtype=np.int64, sep=" ")
    A = stdin[1:]
    A = np.mod(A, 2)
    print("first") if np.count_nonzero(A) else print("second")

if __name__ == "__main__":
    main()

import sys

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

def main():
    N = int(input())
    A = (int(input()) for _ in range(N))
    print("second") if all((a % 2 == 0 for a in A)) else print("first")

if __name__ == "__main__":
    main()

+    return sys.stdin.readline().strip()

-    stdin = np.fromstring(open(0).read(), dtype=np.int64, sep=" ")

-    print("first") if np.count_nonzero(A) else print("second")

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

+    print("second") if all((a % 2 == 0 for a in A)) else print("first")


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=1,0,0

exec('a,b,c=b,c,(a+c)%(10**9+7);'*(int(eval(input()))-2))

print(c)

# optimized version of the same code:

+exec("a,b,c=b,c,a+c;" * (int(eval(input())) - 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:

# -*- coding: utf-8 -*-

# モジュールのインポート

import math

import numpy as np

# 標準入力を取得

N = int(eval(input()))

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

# 求解処理

A = sorted(A, reverse=True)

A = np.array(A)

ans = 2 * np.sum(A[:(N // 2)]) - A[0] + (N % 2) * A[math.floor(N / 2)]

# 結果出力

print(ans)

# optimized version of the same code:

# -*- coding: utf-8 -*-

# モジュールのインポート

import math

# 標準入力を取得

N = int(eval(input()))

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

# 求解処理

A = sorted(A, reverse=True)

ans = 0

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

    if n == 1:

        continue

    ans += A[math.ceil(n / 2) - 1]

# 結果出力

print(ans)

# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import numpy as np

# 標準入力を取得
N = int(eval(input()))
A = list(map(int, input().split()))
# 求解処理
A = sorted(A, reverse=True)
A = np.array(A)
ans = 2 * np.sum(A[: (N // 2)]) - A[0] + (N % 2) * A[math.floor(N / 2)]
# 結果出力
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:

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

z = max(x,y) * 2

min_sum = c * z

for i in range(z):

    r = max(0, y - i) * b

    t = max(0, x - i) * a

    sum = c * i * 2 + r + t

    if sum < min_sum:

        min_sum = sum

print(min_sum)

# optimized version of the same code:

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

plan_a = c * (2*x) + max(0, y-x) * b

plan_b = c * (2*y) + max(0, x-y) * a

plan_c = a * x + b * y

print((min(plan_a, plan_b, plan_c)))

a, b, c, x, y = list(map(int, input().split()))
z = max(x, y) * 2
min_sum = c * z
for i in range(z):
    r = max(0, y - i) * b
    t = max(0, x - i) * a
    sum = c * i * 2 + r + t
    if sum < min_sum:
        min_sum = sum
print(min_sum)

a, b, c, x, y = list(map(int, input().split()))
plan_a = c * (2 * x) + max(0, y - x) * b
plan_b = c * (2 * y) + max(0, x - y) * a
plan_c = a * x + b * y
print((min(plan_a, plan_b, plan_c)))


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()))

a = 1

for n in range(2,N+1):

    a = a*n % (10**9+7)

print(a)

# optimized version of the same code:

def factorial(N):

    a = 1

    for n in range(2,N+1):

        a = a*n % (10**9 + 7)

    return a

if __name__ == '__main__':

    N = int(eval(input()))

    print((factorial(N)))

N = int(eval(input()))
a = 1
for n in range(2, N + 1):
    a = a * n % (10**9 + 7)
print(a)

def factorial(N):
    a = 1
    for n in range(2, N + 1):
        a = a * n % (10**9 + 7)
    return a

if __name__ == "__main__":
    N = int(eval(input()))
    print((factorial(N)))

-N = int(eval(input()))
-a = 1
-for n in range(2, N + 1):
-    a = a * n % (10**9 + 7)
-print(a)
+def factorial(N):
+    a = 1
+    for n in range(2, N + 1):
+        a = a * n % (10**9 + 7)
+    return a
+
+
+if __name__ == "__main__":
+    N = int(eval(input()))
+    print((factorial(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:

# -*- coding: utf-8 -*-

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

cost = int(1e10)

for num_ac in range(0, int(1e5) + 1):

    num_A = max(0, X - num_ac)

    num_B = max(0, Y - num_ac)

    c = 2 * C * num_ac + A * num_A + B * num_B

    cost = min(c, cost)

print(cost)

# optimized version of the same code:

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

ans = 0

if A + B > 2 * C:

    z = min(X, Y)

    X -= z

    Y -= z

    ans += 2 * z * C

# 偏り分

if 2 * C < A:

    k = X

    X -= k

    Y -= k

    ans += 2 * C * k

if 2 * C < B:

    k = Y

    X -= k

    Y -= k

    ans += 2 * C * k

# あまり分

ans += A * max(0, X) + B * max(0, Y)

print(ans)

-    c = 2 * C * num_ac + A * num_A + B * num_B


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

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

from operator import xor

from functools import reduce

N,K,*A = list(map(int,read().split()))

a = reduce(xor,(1<<a for a in A))

dp = 0 # bitset

for n in range(K):

    if not(dp&(1<<n)):

        dp |= (a<<n)

answer = 'First' if dp&(1<<K) else 'Second'

print(answer)

# optimized version of the same code:

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

N,K,*A = list(map(int,read().split()))

dp = [0]*(K+1) # bitset

for n in range(K):

    if not dp[n]:

        for a in A:

            if n+a>K:

                break

            dp[n+a]=1

answer = 'First' if dp[-1] else 'Second'

print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from operator import xor
from functools import reduce

N, K, *A = list(map(int, read().split()))
a = reduce(xor, (1 << a for a in A))
dp = 0  # bitset
for n in range(K):
    if not (dp & (1 << n)):
        dp |= a << n
answer = "First" if dp & (1 << K) else "Second"
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K, *A = list(map(int, read().split()))
dp = [0] * (K + 1)  # bitset
for n in range(K):
    if not dp[n]:
        for a in A:
            if n + a > K:
                break
            dp[n + a] = 1
answer = "First" if dp[-1] else "Second"
print(answer)

-answer = "First" if dp & (1 << K) else "Second"

+answer = "First" if dp[-1] else "Second"


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 = int(eval(input()))

v_list = np.array(list(map(int,input().split())))

c_list = np.array(list(map(int,input().split())))

e_list = list(v_list - c_list)

ans = 0

for i in range(n):

    if e_list[i] > 0:

        ans += e_list[i]

print(ans)

# optimized version of the same code:

n = int(eval(input()))

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

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

e_list = [v-c if (v-c > 0) else 0 for v,c in zip(v_list, c_list)]

print((sum(e_list)))

import numpy as np

n = int(eval(input()))
v_list = np.array(list(map(int, input().split())))
c_list = np.array(list(map(int, input().split())))
e_list = list(v_list - c_list)
ans = 0
for i in range(n):
    if e_list[i] > 0:
        ans += e_list[i]
print(ans)

n = int(eval(input()))
v_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
e_list = [v - c if (v - c > 0) else 0 for v, c in zip(v_list, c_list)]
print((sum(e_list)))

-v_list = np.array(list(map(int, input().split())))

-c_list = np.array(list(map(int, input().split())))

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

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

+e_list = [v - c if (v - c > 0) else 0 for v, c in zip(v_list, c_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:

n = int(eval(input()))

ans = 0

SQRT = int(n ** 0.5)

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

    b = int(n/m)

    ans += m * (m + b) * (b + 1 - m)

ans -= SQRT * (SQRT+1) * (2*SQRT+1) // 6

print(ans)

# optimized version of the same code:

def main():

  n = int(eval(input()))

  ans = 0

  SQRT = int(n ** 0.5)

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

    b = int(n/m)

    ans += m * (m + b) * (b + 1 - m)

  ans -= SQRT * (SQRT+1) * (2*SQRT+1) // 6

  print(ans)

main()

def main():
    n = int(eval(input()))
    ans = 0
    SQRT = int(n**0.5)
    for m in range(1, SQRT + 1):
        b = int(n / m)
        ans += m * (m + b) * (b + 1 - m)
    ans -= SQRT * (SQRT + 1) * (2 * SQRT + 1) // 6
    print(ans)

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:

import numpy as np

N = int(eval(input()))

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

A = np.array(A, dtype = np.int64)

A = np.cumsum(A)

dp = np.zeros((N, N), dtype = np.int64)

for j in range(1, N):

    for i in range(N - j):

        # print (dp[i, i:i + j], dp[i + 1:i + j + 1, i + j])

        tmp = min(dp[i, i:i + j] + dp[i + 1:i + j + 1, i + j])

        dp[i][i + j] = tmp + A[i + j + 1] - A[i]

print((dp[0][N - 1]))

# optimized version of the same code:

N = int(eval(input()))

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

INF = 10 ** 18

dp = [[0] * (N) for _ in range(N)]

for i in range(N):

    A[i + 1] += A[i]

for j in range(1, N):

    for i in range(N - j):

        tmp = INF

        for k in range(i, i + j):

            # print (i, i + j, k + 1)

            tmp = min(tmp, dp[i][k] + dp[k + 1][i + j])

        dp[i][i + j] = tmp + A[i + j + 1] - A[i]

print((dp[0][N - 1]))

import numpy as np

N = int(eval(input()))
A = [0] + list(map(int, input().split()))
A = np.array(A, dtype=np.int64)
A = np.cumsum(A)
dp = np.zeros((N, N), dtype=np.int64)
for j in range(1, N):
    for i in range(N - j):
        # print (dp[i, i:i + j], dp[i + 1:i + j + 1, i + j])
        tmp = min(dp[i, i : i + j] + dp[i + 1 : i + j + 1, i + j])
        dp[i][i + j] = tmp + A[i + j + 1] - A[i]
print((dp[0][N - 1]))

N = int(eval(input()))
A = [0] + list(map(int, input().split()))
INF = 10**18
dp = [[0] * (N) for _ in range(N)]
for i in range(N):
    A[i + 1] += A[i]
for j in range(1, N):
    for i in range(N - j):
        tmp = INF
        for k in range(i, i + j):
            # print (i, i + j, k + 1)
            tmp = min(tmp, dp[i][k] + dp[k + 1][i + j])
        dp[i][i + j] = tmp + A[i + j + 1] - A[i]
print((dp[0][N - 1]))

+            tmp = min(tmp, dp[i][k] + dp[k + 1][i + j])


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

import collections

N = int(eval(input()))

a = math.factorial(N)

check = []

ans = 1

i = 2

while a != 1:

    if a % i == 0:

        a //= i

        check.append(i)

    else:

        i += 1

check = list(collections.Counter(check).values())

for i in check:

    ans *= (i+1)

    ans %= 10**9+7

print(ans)

# optimized version of the same code:

from math import factorial

N = factorial(int(eval(input())))

i = 2

check = 1

ans = 1

while N != 1:

    if N % i == 0:

        N //= i

        check += 1

    else:

        ans *= check

        check = 1

        i += 1

print(((ans*check)%(10**9+7)))

import math
import collections

N = int(eval(input()))
a = math.factorial(N)
check = []
ans = 1
i = 2
while a != 1:
    if a % i == 0:
        a //= i
        check.append(i)
    else:
        i += 1
check = list(collections.Counter(check).values())
for i in check:
    ans *= i + 1
    ans %= 10**9 + 7
print(ans)

from math import factorial

N = factorial(int(eval(input())))
i = 2
check = 1
ans = 1
while N != 1:
    if N % i == 0:
        N //= i
        check += 1
    else:
        ans *= check
        check = 1
        i += 1
print(((ans * check) % (10**9 + 7)))


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

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

ir = lambda: int(sr())

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

N = ir()

P = np.array(lr())

P_diff = np.diff(P)

P_diff = P_diff > 0

series = P_diff[:-1] == P_diff[1:]

answer = series.sum()

print(answer)

# 23

# optimized version of the same code:

N = int(eval(input()))

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

answer = sum(x>y>z or x<y<z for x, y, z in zip(P[:-2], P[1:-1], P[2:]))

print(answer)

N = int(eval(input()))
P = list(map(int, input().split()))
answer = sum(x > y > z or x < y < z for x, y, z in zip(P[:-2], P[1:-1], P[2:]))
print(answer)

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

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

+answer = sum(x > y > z or x < y < z for x, y, z in zip(P[:-2], P[1:-1], P[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 numpy as np

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

nda=np.empty((0,d),int)

ans=0

for i in range(0,n):

  a=np.array([list(map(int,input().split()))])

  for j in range(i):

    chklen=np.linalg.norm(a-nda[j])

    if chklen==chklen//1:

      ans+=1

  nda=np.append(nda,a,axis=0)

print(ans)

# optimized version of the same code:

import math

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

a=[0]*n

for i in range(n):

  a[i]=list(map(int,input().split()))

ans=0

for i in range(n-1):

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

    chklen=0

    wk=0

    for k in range(d):

      wk+=abs(a[i][k]-a[j][k])**2

    chklen=math.sqrt(wk)

    if chklen==chklen//1:

      ans+=1

print(ans)

import numpy as np

n, d = list(map(int, input().split()))
nda = np.empty((0, d), int)
ans = 0
for i in range(0, n):
    a = np.array([list(map(int, input().split()))])
    for j in range(i):
        chklen = np.linalg.norm(a - nda[j])
        if chklen == chklen // 1:
            ans += 1
    nda = np.append(nda, a, axis=0)
print(ans)

import math

n, d = list(map(int, input().split()))
a = [0] * n
for i in range(n):
    a[i] = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        chklen = 0
        wk = 0
        for k in range(d):
            wk += abs(a[i][k] - a[j][k]) ** 2
        chklen = math.sqrt(wk)
        if chklen == chklen // 1:
            ans += 1
print(ans)

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

-    a = np.array([list(map(int, input().split()))])

-        chklen = np.linalg.norm(a - nda[j])


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()))

K=10**9

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

    S=i*2*C+max(0,X-i)*A+max(0,Y-i)*B

    K=min(K,S)

print(K)

# optimized version of the same code:

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

a=min(X,Y)*min(A+B,2*C)

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

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

print(a)

A, B, C, X, Y = list(map(int, input().split()))
K = 10**9
for i in range(10**5 + 1):
    S = i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B
    K = min(K, S)
print(K)

A, B, C, X, Y = list(map(int, input().split()))
a = min(X, Y) * min(A + B, 2 * C)
a += max(0, X - Y) * min(A, 2 * C)
a += max(0, Y - X) * min(B, 2 * C)
print(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, K = list(map(int, input().split()))

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

answer = 0

limit = min(N, K)

for a in range(limit+1): #左から取り出す

    for b in range(limit-a+1): #右から取り出す

        for c in range(K-(a+b)+1):

            use = V[:a] + V[N-b:]

            use.sort()

            s = sum(use[c:])

            answer = max(answer, s)

print(answer)

# optimized version of the same code:

import sys

sys.setrecursionlimit(10 ** 9)

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

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

V2 = V * 2

answer = 0

for i in range(1, min(N, K)+1): # iは宝石を取り出す個数

    for j in range(0, min(i, K-i)+1): # jは何個の宝石を手離すか

        for k in range(max(0, N-i), N+1): # V2の中で何番目から取り出すか

            use = V2[k:k+i]

            use.sort()

            s = sum(use[j:])

            if s > answer:

                answer = s

print(answer)

N, K = list(map(int, input().split()))
V = list(map(int, input().split()))
answer = 0
limit = min(N, K)
for a in range(limit + 1):  # 左から取り出す
    for b in range(limit - a + 1):  # 右から取り出す
        for c in range(K - (a + b) + 1):
            use = V[:a] + V[N - b :]
            use.sort()
            s = sum(use[c:])
            answer = max(answer, s)
print(answer)

import sys

sys.setrecursionlimit(10**9)
N, K = list(map(int, input().split()))
V = list(map(int, input().split()))
V2 = V * 2
answer = 0
for i in range(1, min(N, K) + 1):  # iは宝石を取り出す個数
    for j in range(0, min(i, K - i) + 1):  # jは何個の宝石を手離すか
        for k in range(max(0, N - i), N + 1):  # V2の中で何番目から取り出すか
            use = V2[k : k + i]
            use.sort()
            s = sum(use[j:])
            if s > answer:
                answer = s
print(answer)

-    for b in range(limit - a + 1):  # 右から取り出す

-        for c in range(K - (a + b) + 1):

+for i in range(1, min(N, K) + 1):  # iは宝石を取り出す個数

+    for j in range(0, min(i, K - i) + 1):  # jは何個の宝石を手離すか

+        for k in range(max(0, N - i), N + 1):  # V2の中で何番目から取り出すか


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:

S = int(input())

if S >= 3600:

    h=S//3600

    m=S%3600//60

    s=S%60

elif 3600 > S >= 60:

    h=0

    m=S//60

    s=S%60

else:

    h=m=0

    s=S

print(h, m, s, sep=":")

# optimized version of the same code:


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:

def main():

	n, ma, mb, *L = list(map(int, open(0).read().split()))

	M = 1<<30

	dp = [[M] * 420 for _ in range(420)]

	dp[0][0] = 0

	for a, b, c in zip(*[iter(L)] * 3):

		for i in range(400, -1, -1):

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

				t = dp[i][j] + c

				if dp[i + a][j + b] > t:

					dp[i + a][j + b] = t

	ans = M

	_ma, _mb = ma, mb

	while _ma < 410 > _mb:

		ans = min(ans, dp[_ma][_mb])

		_ma += ma

		_mb += mb

	print((ans if ans < M else -1))

if __name__=="__main__":

	main()

# optimized version of the same code:

def main():

	n, ma, mb, *L = list(map(int, open(0).read().split()))

	M = 1 << 30

	dp = [[M] * 420 for _ in range(420)]

	dp[0][0] = 0

	ua = ub = 15

	for a, b, c in zip(*[iter(L)] * 3):

		for i in range(ua, -1, -1):

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

				t = dp[i][j] + c

				if dp[i + a][j + b] > t:

					dp[i + a][j + b] = t

					if ua < i + a:

						ua = i + a

					if ub < j + b:

						ub = j + b

	ans = M

	_ma, _mb = ma, mb

	while _ma < 410 > _mb:

		ans = min(ans, dp[_ma][_mb])

		_ma += ma

		_mb += mb

	print((ans if ans < M else -1))

if __name__ == "__main__":

	main()

def main():
    n, ma, mb, *L = list(map(int, open(0).read().split()))
    M = 1 << 30
    dp = [[M] * 420 for _ in range(420)]
    dp[0][0] = 0
    for a, b, c in zip(*[iter(L)] * 3):
        for i in range(400, -1, -1):
            for j in range(400, -1, -1):
                t = dp[i][j] + c
                if dp[i + a][j + b] > t:
                    dp[i + a][j + b] = t
    ans = M
    _ma, _mb = ma, mb
    while _ma < 410 > _mb:
        ans = min(ans, dp[_ma][_mb])
        _ma += ma
        _mb += mb
    print((ans if ans < M else -1))

if __name__ == "__main__":
    main()

+            for j in range(ub, -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:

import numpy as np

n = int(eval(input()))

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

count = 0

while np.all(a%2==0):

    count+=1

    a=a/2

print(count)

# optimized version of the same code:

N=int(eval(input()))

a = [int(i) for i in input().split()]

count=0

while 1:

    if sum([i%2 for i in a]) == 0:

        a = [i/2 for i in a]

        count=count+1

    else:

        print(count)

        break

import numpy as np

n = int(eval(input()))
a = np.array(list(map(int, input().split())))
count = 0
while np.all(a % 2 == 0):
    count += 1
    a = a / 2
print(count)

N = int(eval(input()))
a = [int(i) for i in input().split()]
count = 0
while 1:
    if sum([i % 2 for i in a]) == 0:
        a = [i / 2 for i in a]
        count = count + 1
    else:
        print(count)
        break

-a = np.array(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:

_,s=open(c:=0)

for a in sorted(map(int,s.split())):c=a-c

print(c)

# optimized version of the same code:

for a in sorted(map(int,[*open(c:=0)][1].split())):c=a-c

print(c)

_, s = open(c := 0)
for a in sorted(map(int, s.split())):
    c = a - c
print(c)

for a in sorted(map(int, [*open(c := 0)][1].split())):
    c = a - c
print(c)

+for a in sorted(map(int, [*open(c := 0)][1].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:

import sys

sys.setrecursionlimit(10000000)

import heapq

import math

def main():

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

    A = [int(c) for c in input().split()]

    F = [int(c) for c in input().split()]

    A.sort()

    F.sort(reverse=True)

    num = 0

    sum_ = []

    for i in range(N):

      sum_.append(A[i] * F[i])

    left = 0

    right = 10 ** 12

    while(num < 90):

        number = 0

        mid = (left + right) // 2

        # print(mid)

        for i in range(len(A)):

            if sum_[i] <= mid:

                continue

            else:

                number += math.ceil((sum_[i] - mid) / F[i])

            # print(number)

        if number > K:

            # 最大値をmidより小さくできない -> 最大値はもっとでかい

            left = mid + 1

        else:

            right = mid

        num += 1

    print(mid)

if __name__ == '__main__':

    main()

# optimized version of the same code:

import sys

sys.setrecursionlimit(10000000)

import heapq

import math

def main():

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

    A = [int(c) for c in input().split()]

    F = [int(c) for c in input().split()]

    A.sort()

    F.sort(reverse=True)

    num = 0

    sum_ = []

    for i in range(len(A)):

        sum_.append(A[i] * F[i])

    left = 0

    right = 10 ** 12

    while(num < 50):

        number = 0

        mid = (left + right) // 2

        # print(mid)

        for i in range(len(A)):

            if sum_[i] <= mid:

                continue

            else:

                number += math.ceil((sum_[i] - mid) / F[i])

            # print(number)

        if number > K:

            # 最大値をmidより小さくできない -> 最大値はもっとでかい

            left = mid + 1

        else:

            right = mid

        num += 1

    print(mid)

if __name__ == '__main__':

    main()

import sys

sys.setrecursionlimit(10000000)
import heapq
import math

def main():
    N, K = list(map(int, input().split()))
    A = [int(c) for c in input().split()]
    F = [int(c) for c in input().split()]
    A.sort()
    F.sort(reverse=True)
    num = 0
    sum_ = []
    for i in range(N):
        sum_.append(A[i] * F[i])
    left = 0
    right = 10**12
    while num < 90:
        number = 0
        mid = (left + right) // 2
        # print(mid)
        for i in range(len(A)):
            if sum_[i] <= mid:
                continue
            else:
                number += math.ceil((sum_[i] - mid) / F[i])
            # print(number)
        if number > K:
            # 最大値をmidより小さくできない -> 最大値はもっとでかい
            left = mid + 1
        else:
            right = mid
        num += 1
    print(mid)

if __name__ == "__main__":
    main()

import sys

sys.setrecursionlimit(10000000)
import heapq
import math

def main():
    N, K = list(map(int, input().split()))
    A = [int(c) for c in input().split()]
    F = [int(c) for c in input().split()]
    A.sort()
    F.sort(reverse=True)
    num = 0
    sum_ = []
    for i in range(len(A)):
        sum_.append(A[i] * F[i])
    left = 0
    right = 10**12
    while num < 50:
        number = 0
        mid = (left + right) // 2
        # print(mid)
        for i in range(len(A)):
            if sum_[i] <= mid:
                continue
            else:
                number += math.ceil((sum_[i] - mid) / F[i])
            # print(number)
        if number > K:
            # 最大値をmidより小さくできない -> 最大値はもっとでかい
            left = mid + 1
        else:
            right = mid
        num += 1
    print(mid)

if __name__ == "__main__":
    main()

-    for i in range(N):
+    for i in range(len(A)):
-    while num < 90:
+    while num < 50:


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:

s = eval(input())

t = ""

while len(t) < len(s):

    target_len = len(s) - len(t)

    if s[len(t)] == 'd':

        if target_len == 5:

            t += "dream"

        elif target_len == 7:

            t += "dreamer"

        elif target_len > 7:

            if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 7 + 1] != "era":

                t += "dreamer"

            else:

                t += "dream"

        else:

            break

    else:

        if target_len == 5:

            t += "erase"

        elif target_len == 6:

            t += "eraser"

        elif target_len > 6:

            if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 6 + 2] != "era":

                t += "eraser"

            else:

                t += "erase"

        else:

            break

    if s[0:len(t)] != t:

        break

print(("YES" if s == t else "NO"))

# optimized version of the same code:

s = eval(input())

div = ["dream", "dreamer", "erase", "eraser"]

rev = []

t = ""

s_rev = s[::-1]

for d in div:

    rev.append(d[::-1])

result = True

i = 0

while i < len(s):

    can_divide = False

    for d in rev:

        if len(s_rev) - i >= len(d) and s_rev[i:i + len(d)] == d:

            can_divide = True

            i += len(d)

            break

    if not can_divide:

        result = False

        break

print(("YES" if result else "NO"))

s = eval(input())
t = ""
while len(t) < len(s):
    target_len = len(s) - len(t)
    if s[len(t)] == "d":
        if target_len == 5:
            t += "dream"
        elif target_len == 7:
            t += "dreamer"
        elif target_len > 7:
            if s[len(t) + 5] != "d" and s[len(t) + 5 : len(t) + 7 + 1] != "era":
                t += "dreamer"
            else:
                t += "dream"
        else:
            break
    else:
        if target_len == 5:
            t += "erase"
        elif target_len == 6:
            t += "eraser"
        elif target_len > 6:
            if s[len(t) + 5] != "d" and s[len(t) + 5 : len(t) + 6 + 2] != "era":
                t += "eraser"
            else:
                t += "erase"
        else:
            break
    if s[0 : len(t)] != t:
        break
print(("YES" if s == t else "NO"))

s = eval(input())
div = ["dream", "dreamer", "erase", "eraser"]
rev = []
t = ""
s_rev = s[::-1]
for d in div:
    rev.append(d[::-1])
result = True
i = 0
while i < len(s):
    can_divide = False
    for d in rev:
        if len(s_rev) - i >= len(d) and s_rev[i : i + len(d)] == d:
            can_divide = True
            i += len(d)
            break
    if not can_divide:
        result = False
        break
print(("YES" if result else "NO"))

+div = ["dream", "dreamer", "erase", "eraser"]

+        if len(s_rev) - i >= len(d) and s_rev[i : i + len(d)] == d:


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 statistics import mean

inputCount = int(eval(input()))

prices = [int(eval(input())) for lp in range(inputCount)]

average = mean(prices)

print((int(average)))

# optimized version of the same code:

inputCount = int(eval(input()))

prices = [int(eval(input())) for lp in range(inputCount)]

average = sum(prices) // inputCount

print(average)

-from statistics import mean
-average = mean(prices)
-print((int(average)))
+average = sum(prices) // inputCount
+print(average)


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

from heapq import heappop,heappush,heapify

import sys,bisect,math,itertools,fractions,pprint

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 = sorted(inpl())

B = sorted(inpl())

C = sorted(inpl())

cnt = [0] * n

res = 0

for i,b in enumerate(B):

    c = bisect.bisect_left(C,b+1)

    cnt[i] = n-c

acc = [0]

for x in cnt:

    acc += [acc[-1] + x]

su = sum(cnt)

for i,a in enumerate(A):

    c = bisect.bisect_left(B,a+1)

    res += su - acc[c]

print(res)

# optimized version of the same code:

from collections import Counter,defaultdict,deque

from heapq import heappop,heappush,heapify

import sys,bisect,math,itertools,fractions,pprint

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()

b = inpl()

c = inpl()

a.sort()

b.sort()

c.sort()

lb = [0] * n

res = 0

for i in range(n):

    tmp = bisect.bisect_right(b,a[i])

    if tmp == n: continue

    lb[tmp] += 1

llb = list(itertools.accumulate(lb))

# print(lb,llb)

rr = [0] * n

for i in range(n):

    tmp = bisect.bisect_right(c,b[i])

    if tmp == n: continue

    rr[tmp] += llb[i]

print((sum(list(itertools.accumulate(rr)))))

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions, pprint

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 = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl())
cnt = [0] * n
res = 0
for i, b in enumerate(B):
    c = bisect.bisect_left(C, b + 1)
    cnt[i] = n - c
acc = [0]
for x in cnt:
    acc += [acc[-1] + x]
su = sum(cnt)
for i, a in enumerate(A):
    c = bisect.bisect_left(B, a + 1)
    res += su - acc[c]
print(res)

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions, pprint

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()
b = inpl()
c = inpl()
a.sort()
b.sort()
c.sort()
lb = [0] * n
res = 0
for i in range(n):
    tmp = bisect.bisect_right(b, a[i])
    if tmp == n:
        continue
    lb[tmp] += 1
llb = list(itertools.accumulate(lb))
# print(lb,llb)
rr = [0] * n
for i in range(n):
    tmp = bisect.bisect_right(c, b[i])
    if tmp == n:
        continue
    rr[tmp] += llb[i]
print((sum(list(itertools.accumulate(rr)))))


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:

X=int(eval(input()))

x=0

list=[]

for i in range(-118,120,1):

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

        x=i**5-j**5

        if x==X:

            list.append((str(i)+' '+str(j)))

print((list[0]))

# optimized version of the same code:

X=int(eval(input()))

x=0

list=[]

for i in range(-118,120,1):

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

        x=i**5-j**5

        if x==X:

            print((str(i)+' '+str(j)))

            break

    else:

        continue

    break

X = int(eval(input()))
x = 0
list = []
for i in range(-118, 120, 1):
    for j in range(-119, 119, 1):
        x = i**5 - j**5
        if x == X:
            list.append((str(i) + " " + str(j)))
print((list[0]))

X = int(eval(input()))
x = 0
list = []
for i in range(-118, 120, 1):
    for j in range(-119, 119, 1):
        x = i**5 - j**5
        if x == X:
            print((str(i) + " " + str(j)))
            break
    else:
        continue
    break

-            list.append((str(i) + " " + str(j)))

+            print((str(i) + " " + str(j)))


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:

# -*- coding: utf-8 -*-

"""

http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0144

"""

import sys

from sys import stdin

input = stdin.readline

from enum import Enum

class Graph(object):

    """ single source shortest path """

    class Status(Enum):

        """ ?????????????¨??????¶??? """

        white = 1  # ????¨????

        gray = 2  # ?¨???????

        black = 3  #?¨???????

    def __init__(self, n, data):

        self.num_of_nodes = n+1

        self.color = [Graph.Status.white] * self.num_of_nodes  # ????????????????¨??????¶???

        self.M = [[float('inf')] * self.num_of_nodes for _ in range(self.num_of_nodes)]

        for i in range(self.num_of_nodes):

            self.M[i][i] = 0

        self._make_matrix(data)  # data????????????????????£??\??????(?????\?¶???¨???????????????????????§????????????)

        self.d = [float('inf')] * self.num_of_nodes  # ?§???????????????????(?????????)

        self.p = [-1] * self.num_of_nodes  # ????????????????????????????¨?????????????????????????

    def _make_matrix(self, data):

        for d in data:

            r = d[0]

            for t in d[2:]:

                self.M[r][t] = 1

    def dijkstra(self, start):

        self.d[start] = 0

        self.p[start] = -1

        while True:

            mincost = float('inf')

            # ??\??????????????§??????????????¨?????????????????????u???????????????

            for i in range(len(self.d)):

                if self.color[i] != Graph.Status.black and self.d[i] < mincost:  # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????

                    mincost = self.d[i]

                    u = i  # u??????????????????ID

            if mincost == float('inf'):

                break

            self.color[u] = Graph.Status.black  # ?????????u???S????±???????????????´???

            for v in range(len(self.d)):

                if self.color[v] != Graph.Status.black and self.M[u][v] != float('inf'):

                    # v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????

                    if self.d[u] + self.M[u][v] < self.d[v]:

                        self.d[v] = self.d[u] + self.M[u][v]

                        self.p[v] = u

                        self.color[v] = Graph.Status.gray

    def warshallFloyd(self):

        V = self.num_of_nodes

        for k in range(V):

            for i in range(V):

                for j in range(V):

                    self.M[i][j] = min(self.M[i][j], self.M[i][k] + self.M[k][j])

def main(args):

    n = int(eval(input()))

    network = []

    for _ in range(n):

        network.append([int(x) for x in input().split()])

    packets = []

    p = int(eval(input()))

    for _ in range(p):

        packets.append([int(x) for x in input().split()])

    g = Graph(n, network)

    g.warshallFloyd()

    for s, d, v in packets:

        if g.M[s][d] < v:

            print((g.M[s][d]+1))

        else:

            print('NA')

if __name__ == '__main__':

    main(sys.argv[1:])

# optimized version of the same code:

# -*- coding: utf-8 -*-

"""

http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0144

"""

import sys

from sys import stdin

input = stdin.readline

from enum import Enum

class Graph(object):

    """ single source shortest path """

    class Status(Enum):

        """ ?????????????¨??????¶??? """

        white = 1  # ????¨????

        gray = 2  # ?¨???????

        black = 3  #?¨???????

    def __init__(self, n, data):

        self.num_of_nodes = n+1

        self.color = [Graph.Status.white] * self.num_of_nodes  # ????????????????¨??????¶???

        self.M = [[float('inf')] * self.num_of_nodes for _ in range(self.num_of_nodes)]

        for i in range(self.num_of_nodes):

            self.M[i][i] = 0

        self._make_matrix(data)  # data????????????????????£??\??????(?????\?¶???¨???????????????????????§????????????)

        self.d = [float('inf')] * self.num_of_nodes  # ?§???????????????????(?????????)

        self.p = [-1] * self.num_of_nodes  # ????????????????????????????¨?????????????????????????

    def _make_matrix(self, data):

        for d in data:

            r = d[0]

            for t in d[2:]:

                self.M[r][t] = 1

    def dijkstra(self, start):

        self.d[start] = 0

        self.p[start] = -1

        while True:

            mincost = float('inf')

            # ??\??????????????§??????????????¨?????????????????????u???????????????

            for i in range(len(self.d)):

                if self.color[i] != Graph.Status.black and self.d[i] < mincost:  # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????

                    mincost = self.d[i]

                    u = i  # u??????????????????ID

            if mincost == float('inf'):

                break

            self.color[u] = Graph.Status.black  # ?????????u???S????±???????????????´???

            for v in range(len(self.d)):

                if self.color[v] != Graph.Status.black and self.M[u][v] != float('inf'):

                    # v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????

                    if self.d[u] + self.M[u][v] < self.d[v]:

                        self.d[v] = self.d[u] + self.M[u][v]

                        self.p[v] = u

                        self.color[v] = Graph.Status.gray

    def warshallFloyd(self):

        for k in range(self.num_of_nodes):

            for i in range(self.num_of_nodes):

                for j in range(self.num_of_nodes):

                    if self.M[i][k] + self.M[k][j] < self.M[i][j]:

                        self.M[i][j] = self.M[i][k] + self.M[k][j]

def main(args):

    n = int(eval(input()))

    network = []

    for _ in range(n):

        network.append([int(x) for x in input().split()])

    packets = []

    p = int(eval(input()))

    for _ in range(p):

        packets.append([int(x) for x in input().split()])

    g = Graph(n, network)

    g.warshallFloyd()

    for s, d, v in packets:

        if g.M[s][d] < v:

            print((g.M[s][d]+1))

        else:

            print('NA')

if __name__ == '__main__':

    main(sys.argv[1:])

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0144
"""
import sys
from sys import stdin

input = stdin.readline
from enum import Enum

class Graph(object):
    """single source shortest path"""

    class Status(Enum):
        """?????????????¨??????¶???"""

        white = 1  # ????¨????
        gray = 2  # ?¨???????
        black = 3  # ?¨???????

    def __init__(self, n, data):
        self.num_of_nodes = n + 1
        self.color = [
            Graph.Status.white
        ] * self.num_of_nodes  # ????????????????¨??????¶???
        self.M = [[float("inf")] * self.num_of_nodes for _ in range(self.num_of_nodes)]
        for i in range(self.num_of_nodes):
            self.M[i][i] = 0
        self._make_matrix(
            data
        )  # data????????????????????£??\??????(?????\?¶???¨???????????????????????§????????????)
        self.d = [float("inf")] * self.num_of_nodes  # ?§???????????????????(?????????)
        self.p = [
            -1
        ] * self.num_of_nodes  # ????????????????????????????¨?????????????????????????

    def _make_matrix(self, data):
        for d in data:
            r = d[0]
            for t in d[2:]:
                self.M[r][t] = 1

    def dijkstra(self, start):
        self.d[start] = 0
        self.p[start] = -1
        while True:
            mincost = float("inf")
            # ??\??????????????§??????????????¨?????????????????????u???????????????
            for i in range(len(self.d)):
                if (
                    self.color[i] != Graph.Status.black and self.d[i] < mincost
                ):  # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????
                    mincost = self.d[i]
                    u = i  # u??????????????????ID
            if mincost == float("inf"):
                break
            self.color[u] = Graph.Status.black  # ?????????u???S????±???????????????´???
            for v in range(len(self.d)):
                if self.color[v] != Graph.Status.black and self.M[u][v] != float("inf"):
                    # v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????
                    if self.d[u] + self.M[u][v] < self.d[v]:
                        self.d[v] = self.d[u] + self.M[u][v]
                        self.p[v] = u
                        self.color[v] = Graph.Status.gray

    def warshallFloyd(self):
        V = self.num_of_nodes
        for k in range(V):
            for i in range(V):
                for j in range(V):
                    self.M[i][j] = min(self.M[i][j], self.M[i][k] + self.M[k][j])

def main(args):
    n = int(eval(input()))
    network = []
    for _ in range(n):
        network.append([int(x) for x in input().split()])
    packets = []
    p = int(eval(input()))
    for _ in range(p):
        packets.append([int(x) for x in input().split()])
    g = Graph(n, network)
    g.warshallFloyd()
    for s, d, v in packets:
        if g.M[s][d] < v:
            print((g.M[s][d] + 1))
        else:
            print("NA")

if __name__ == "__main__":
    main(sys.argv[1:])

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0144
"""
import sys
from sys import stdin

input = stdin.readline
from enum import Enum

class Graph(object):
    """single source shortest path"""

    class Status(Enum):
        """?????????????¨??????¶???"""

        white = 1  # ????¨????
        gray = 2  # ?¨???????
        black = 3  # ?¨???????

    def __init__(self, n, data):
        self.num_of_nodes = n + 1
        self.color = [
            Graph.Status.white
        ] * self.num_of_nodes  # ????????????????¨??????¶???
        self.M = [[float("inf")] * self.num_of_nodes for _ in range(self.num_of_nodes)]
        for i in range(self.num_of_nodes):
            self.M[i][i] = 0
        self._make_matrix(
            data
        )  # data????????????????????£??\??????(?????\?¶???¨???????????????????????§????????????)
        self.d = [float("inf")] * self.num_of_nodes  # ?§???????????????????(?????????)
        self.p = [
            -1
        ] * self.num_of_nodes  # ????????????????????????????¨?????????????????????????

    def _make_matrix(self, data):
        for d in data:
            r = d[0]
            for t in d[2:]:
                self.M[r][t] = 1

    def dijkstra(self, start):
        self.d[start] = 0
        self.p[start] = -1
        while True:
            mincost = float("inf")
            # ??\??????????????§??????????????¨?????????????????????u???????????????
            for i in range(len(self.d)):
                if (
                    self.color[i] != Graph.Status.black and self.d[i] < mincost
                ):  # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????
                    mincost = self.d[i]
                    u = i  # u??????????????????ID
            if mincost == float("inf"):
                break
            self.color[u] = Graph.Status.black  # ?????????u???S????±???????????????´???
            for v in range(len(self.d)):
                if self.color[v] != Graph.Status.black and self.M[u][v] != float("inf"):
                    # v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????
                    if self.d[u] + self.M[u][v] < self.d[v]:
                        self.d[v] = self.d[u] + self.M[u][v]
                        self.p[v] = u
                        self.color[v] = Graph.Status.gray

    def warshallFloyd(self):
        for k in range(self.num_of_nodes):
            for i in range(self.num_of_nodes):
                for j in range(self.num_of_nodes):
                    if self.M[i][k] + self.M[k][j] < self.M[i][j]:
                        self.M[i][j] = self.M[i][k] + self.M[k][j]

def main(args):
    n = int(eval(input()))
    network = []
    for _ in range(n):
        network.append([int(x) for x in input().split()])
    packets = []
    p = int(eval(input()))
    for _ in range(p):
        packets.append([int(x) for x in input().split()])
    g = Graph(n, network)
    g.warshallFloyd()
    for s, d, v in packets:
        if g.M[s][d] < v:
            print((g.M[s][d] + 1))
        else:
            print("NA")

if __name__ == "__main__":
    main(sys.argv[1:])

-                    self.M[i][j] = min(self.M[i][j], self.M[i][k] + self.M[k][j])

+        for k in range(self.num_of_nodes):

+            for i in range(self.num_of_nodes):

+                for j in range(self.num_of_nodes):

+                    if self.M[i][k] + self.M[k][j] < self.M[i][j]:

+                        self.M[i][j] = self.M[i][k] + self.M[k][j]