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

class BinaryIndexedTree():

    '''

    1-indexed

    '''

    def __init__(self, A):

        self.__n = len(A)

        self.__node = [0] * (self.__n + 1)

        self.__data = [0] * (self.__n + 1)

        S = [0] * (self.__n + 1)

        for i in range(1, self.__n + 1):

            S[i] = S[i - 1] + A[i - 1]

            self.__data[i] = A[i - 1]

            self.__node[i] = S[i] - S[i - (i & -i)]

    def add(self, i, v):

        self.__data[i] += v

        while i <= self.__n:

            self.__node[i] += v

            i += i & -i

    def sum(self, i):

        ''' [1, i]の和

        '''

        rst = 0

        while i > 0:

            rst += self.__node[i]

            i -= i & -i

        return rst

    def get(self, i, j):

        '''[i, j]の和

        '''

        if i == j:

            return self.__data[i]

        else:

            return self.sum(j) - self.sum(i - 1)

def main():

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

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

    P = [[] for _ in range(N)]

    for i, c in enumerate(C):

        P[c - 1].append(i)

    right = [0] * N

    for p in P:

        if len(p):

            right[p.pop()] = 1

    BIT = BinaryIndexedTree(right)

    query = [[] for _ in range(N)]

    for i, s in enumerate(sys.stdin.readlines()):

        l, r = map(int, s.split())

        query[r - 1].append((l - 1, i))

    ans = [None] * Q

    cur = N - 1

    for r, q in enumerate(reversed(query)):

        r = (N - 1) - r

        while q:

            l, i = q.pop()

            while r < cur:

                c = C[cur] - 1

                p = P[c]

                if len(p):

                    BIT.add(p.pop() + 1, 1)

                cur -= 1

            tmp = BIT.get(l + 1, r + 1)

            ans[i] = tmp

    print(*ans, sep='\n')

if __name__ == '__main__':

    main()

# optimized version of the same code:

import sys

class BinaryIndexedTree():

    '''

    1-indexed

    '''

    def __init__(self, A):

        self.__n = len(A)

        self.__node = [0] * (self.__n + 1)

        self.__data = [0] * (self.__n + 1)

        S = [0] * (self.__n + 1)

        for i in range(self.__n):

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

        for i in range(1, self.__n + 1):

            self.__data[i] = A[i - 1]

            self.__node[i] = S[i] - S[i - (i & -i)]

    def add(self, i, v):

        self.__data[i] += v

        while i <= self.__n:

            self.__node[i] += v

            i += i & -i

    def sum(self, i):

        ''' [1, i]の和

        '''

        rst = 0

        while i > 0:

            rst += self.__node[i]

            i -= i & -i

        return rst

    def get(self, i, j):

        '''[i, j]の和

        '''

        if i == j:

            return self.__data[i]

        else:

            return self.sum(j) - self.sum(i - 1)

def main():

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

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

    P = [[] for _ in range(N)]

    for i, c in enumerate(C):

        P[c - 1].append(i)

    right = [0] * N

    for p in P:

        if len(p):

            right[p.pop()] = 1

    BIT = BinaryIndexedTree(right)

    query = [[] for _ in range(N)]

    for i, s in enumerate(sys.stdin.readlines()):

        l, r = map(int, s.split())

        query[r - 1].append((l - 1, i))

    ans = [None] * Q

    cur = N - 1

    for r, q in enumerate(reversed(query)):

        r = (N - 1) - r

        while q:

            l, i = q.pop()

            while r < cur:

                c = C[cur] - 1

                p = P[c]

                if len(p):

                    BIT.add(p.pop() + 1, 1)

                cur -= 1

            tmp = BIT.get(l + 1, r + 1)

            ans[i] = tmp

    print(*ans, sep='\n')

if __name__ == '__main__':

    main()

import sys

class BinaryIndexedTree:
    """
    1-indexed
    """

    def __init__(self, A):
        self.__n = len(A)
        self.__node = [0] * (self.__n + 1)
        self.__data = [0] * (self.__n + 1)
        S = [0] * (self.__n + 1)
        for i in range(1, self.__n + 1):
            S[i] = S[i - 1] + A[i - 1]
            self.__data[i] = A[i - 1]
            self.__node[i] = S[i] - S[i - (i & -i)]

    def add(self, i, v):
        self.__data[i] += v
        while i <= self.__n:
            self.__node[i] += v
            i += i & -i

    def sum(self, i):
        """[1, i]の和"""
        rst = 0
        while i > 0:
            rst += self.__node[i]
            i -= i & -i
        return rst

    def get(self, i, j):
        """[i, j]の和"""
        if i == j:
            return self.__data[i]
        else:
            return self.sum(j) - self.sum(i - 1)

def main():
    N, Q = map(int, input().split())
    C = list(map(int, input().split()))
    P = [[] for _ in range(N)]
    for i, c in enumerate(C):
        P[c - 1].append(i)
    right = [0] * N
    for p in P:
        if len(p):
            right[p.pop()] = 1
    BIT = BinaryIndexedTree(right)
    query = [[] for _ in range(N)]
    for i, s in enumerate(sys.stdin.readlines()):
        l, r = map(int, s.split())
        query[r - 1].append((l - 1, i))
    ans = [None] * Q
    cur = N - 1
    for r, q in enumerate(reversed(query)):
        r = (N - 1) - r
        while q:
            l, i = q.pop()
            while r < cur:
                c = C[cur] - 1
                p = P[c]
                if len(p):
                    BIT.add(p.pop() + 1, 1)
                cur -= 1
            tmp = BIT.get(l + 1, r + 1)
            ans[i] = tmp
    print(*ans, sep="\n")

if __name__ == "__main__":
    main()

import sys

class BinaryIndexedTree:
    """
    1-indexed
    """

    def __init__(self, A):
        self.__n = len(A)
        self.__node = [0] * (self.__n + 1)
        self.__data = [0] * (self.__n + 1)
        S = [0] * (self.__n + 1)
        for i in range(self.__n):
            S[i + 1] = S[i] + A[i]
        for i in range(1, self.__n + 1):
            self.__data[i] = A[i - 1]
            self.__node[i] = S[i] - S[i - (i & -i)]

    def add(self, i, v):
        self.__data[i] += v
        while i <= self.__n:
            self.__node[i] += v
            i += i & -i

    def sum(self, i):
        """[1, i]の和"""
        rst = 0
        while i > 0:
            rst += self.__node[i]
            i -= i & -i
        return rst

    def get(self, i, j):
        """[i, j]の和"""
        if i == j:
            return self.__data[i]
        else:
            return self.sum(j) - self.sum(i - 1)

def main():
    N, Q = map(int, input().split())
    C = list(map(int, input().split()))
    P = [[] for _ in range(N)]
    for i, c in enumerate(C):
        P[c - 1].append(i)
    right = [0] * N
    for p in P:
        if len(p):
            right[p.pop()] = 1
    BIT = BinaryIndexedTree(right)
    query = [[] for _ in range(N)]
    for i, s in enumerate(sys.stdin.readlines()):
        l, r = map(int, s.split())
        query[r - 1].append((l - 1, i))
    ans = [None] * Q
    cur = N - 1
    for r, q in enumerate(reversed(query)):
        r = (N - 1) - r
        while q:
            l, i = q.pop()
            while r < cur:
                c = C[cur] - 1
                p = P[c]
                if len(p):
                    BIT.add(p.pop() + 1, 1)
                cur -= 1
            tmp = BIT.get(l + 1, r + 1)
            ans[i] = tmp
    print(*ans, sep="\n")

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:

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

ans =[]

if R - L <= 2019:

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

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

            ans.append(i*j%2019)

else:

    for i in range(R-L-1010,R-L+1010):

        for j in range(i,R-L+1010):

            ans.append(i*j%2019)

print((min(ans)))

# optimized version of the same code:

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

ans =[]

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

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

        ans.append(i*j%2019)

        if (i * j % 2019) == 0:

            break

    else:

        continue

    break

print((min(ans)))

L, R = list(map(int, input().split()))
ans = []
if R - L <= 2019:
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            ans.append(i * j % 2019)
else:
    for i in range(R - L - 1010, R - L + 1010):
        for j in range(i, R - L + 1010):
            ans.append(i * j % 2019)
print((min(ans)))

L, R = list(map(int, input().split()))
ans = []
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        ans.append(i * j % 2019)
        if (i * j % 2019) == 0:
            break
    else:
        continue
    break
print((min(ans)))

-        for j in range(i, R - L + 1010):


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

import heapq

n = int(eval(input()))

ss = []

for _ in range(n):

    ss.append(input().rstrip())

ctr = Counter(ss)

heap = [(-v, k) for k, v in list(ctr.items())]

heapq.heapify(heap)

maxv = heap[0][0]

while heap:

    c = heapq.heappop(heap)

    if c[0] != maxv:

        break

    print((c[1]))

# optimized version of the same code:

from collections import Counter

n = int(eval(input()))

ss = []

for _ in range(n):

    ss.append(input().rstrip())

ctr = Counter(ss)

a = sorted([(-v, k) for k, v in list(ctr.items())])

maxv = a[0][0]

for i in range(len(a)):

    if a[i][0] != maxv:

        break

    print((a[i][1]))

-heap = [(-v, k) for k, v in list(ctr.items())]

+a = sorted([(-v, k) for k, v in list(ctr.items())])


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.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

fac = [1, 1]     # 元テーブル

f_inv = [1, 1]   # 逆元テーブル

inv = [0, 1]     # 逆元テーブル計算用テーブル

def prepare(n, mod):

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

        fac.append((fac[-1] * i) % mod)

        inv.append((-inv[mod % i] * (mod//i)) % mod)

        f_inv.append((f_inv[-1] * inv[-1]) % mod)

def cmb(n, r, mod):

    if n < 0 or r < 0:

        return 0

    if r > n:

        return 0

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

def main():

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

    MOD = 998244353

    prepare(N + 10, MOD)

    if M == 1 and K == N - 1:

        print((1))

        exit()

    m = M

    for _ in range(N-1):

        m *= M - 1

        m %= MOD

    ans = 0

    for k in range(K+1):

        ans += (m * cmb(N-1, k, MOD)) % MOD

        ans %= MOD

        m *= pow(M-1, MOD-2, MOD)

        m %= MOD

    print(ans)

if __name__ == "__main__":

    main()

# optimized version of the same code:

import sys

read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

# 0^0 = 1

def main():

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

    MOD = 998244353

    if M == 1:

        if K == N - 1:

            print((1))

        else:

            print((0))

        exit()

    m = pow(M-1, N-1, MOD)

    m_1_inv = pow(M-1, MOD-2, MOD)

    comb = 1

    ans = comb * m

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

        m *= m_1_inv

        m %= MOD

        comb *= N - k

        comb %= MOD

        comb *= pow(k, MOD-2, MOD)

        ans += (m * comb) % MOD

        ans %= MOD

    print((ans * M % MOD))

if __name__ == "__main__":

    main()

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
fac = [1, 1]  # 元テーブル
f_inv = [1, 1]  # 逆元テーブル
inv = [0, 1]  # 逆元テーブル計算用テーブル

def prepare(n, mod):
    for i in range(2, n + 1):
        fac.append((fac[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        f_inv.append((f_inv[-1] * inv[-1]) % mod)

def cmb(n, r, mod):
    if n < 0 or r < 0:
        return 0
    if r > n:
        return 0
    return fac[n] * f_inv[r] * f_inv[n - r] % mod

def main():
    N, M, K = list(map(int, readline().split()))
    MOD = 998244353
    prepare(N + 10, MOD)
    if M == 1 and K == N - 1:
        print((1))
        exit()
    m = M
    for _ in range(N - 1):
        m *= M - 1
        m %= MOD
    ans = 0
    for k in range(K + 1):
        ans += (m * cmb(N - 1, k, MOD)) % MOD
        ans %= MOD
        m *= pow(M - 1, MOD - 2, MOD)
        m %= MOD
    print(ans)

if __name__ == "__main__":
    main()

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
# 0^0 = 1
def main():
    N, M, K = list(map(int, readline().split()))
    MOD = 998244353
    if M == 1:
        if K == N - 1:
            print((1))
        else:
            print((0))
        exit()
    m = pow(M - 1, N - 1, MOD)
    m_1_inv = pow(M - 1, MOD - 2, MOD)
    comb = 1
    ans = comb * m
    for k in range(1, K + 1):
        m *= m_1_inv
        m %= MOD
        comb *= N - k
        comb %= MOD
        comb *= pow(k, MOD - 2, MOD)
        ans += (m * comb) % MOD
        ans %= MOD
    print((ans * M % MOD))

if __name__ == "__main__":
    main()

-inv = [0, 1]  # 逆元テーブル計算用テーブル

-        fac.append((fac[-1] * i) % mod)

-        inv.append((-inv[mod % i] * (mod // i)) % mod)

-        f_inv.append((f_inv[-1] * inv[-1]) % mod)

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

-        ans += (m * cmb(N - 1, k, MOD)) % MOD


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

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

import sys

from collections import Counter

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

def list2d(a, b, c): return [[c] * b for i in range(a)]

def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1): return int(-(-x // y))

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

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

def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes(): print('Yes')

def No(): print('No')

def YES(): print('YES')

def NO(): print('NO')

sys.setrecursionlimit(10 ** 9)

INF = 10 ** 18

MOD = 10 ** 9 + 7

def fft(A, B):

    """

    高速フーリエ変換(FFT)

        A：出現回数をカウントしたリスト

        B：出現回数をカウントしたリスト

    """

    import numpy as np

    from numpy.fft import rfft, irfft

    # 出現数カウント

    MAXA = max(A)

    MAXB = max(B)

    C1 = [0] * (MAXA+1)

    C2 = [0] * (MAXB+1)

    for a in A:

        C1[a] += 1

    for b in B:

        C2[b] += 1

    # max(A)+max(B)より大きい2冪

    L = 1

    k = 0

    while L <= MAXA + MAXB:

        k += 1

        L = 2**k

    # FFT

    res = irfft(rfft(C1, L) * rfft(C2, L), L)

    # 四捨五入して整数に

    res = np.rint(res).astype(np.int64)

    return res

N, M, L = MAP()

A = LIST()

B = LIST()

res = list(fft(A, B))

mn = INF

for i, a in enumerate(res):

    if a != 0:

        mn = i

        break

for _ in range(L):

    x, y, c = MAP()

    x -= 1; y -= 1

    mn = min(mn, A[x] + B[y] - c)

print(mn)

# optimized version of the same code:

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

import sys

from collections import Counter

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

def list2d(a, b, c): return [[c] * b for i in range(a)]

def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1): return int(-(-x // y))

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

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

def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes(): print('Yes')

def No(): print('No')

def YES(): print('YES')

def NO(): print('NO')

sys.setrecursionlimit(10 ** 9)

INF = 10 ** 18

MOD = 10 ** 9 + 7

N, M, L = MAP()

A = LIST()

B = LIST()

mn = min(A) + min(B)

for _ in range(L):

    x, y, c = MAP()

    x -= 1; y -= 1

    mn = min(mn, A[x] + B[y] - c)

print(mn)

# -*- coding: utf-8 -*-
import sys
from collections import Counter

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

def list2d(a, b, c):
    return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
    return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
    return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
    return int(-(-x // y))

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

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

def LIST(N=None):
    return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
    print("Yes")

def No():
    print("No")

def YES():
    print("YES")

def NO():
    print("NO")

sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7

def fft(A, B):
    """
    高速フーリエ変換(FFT)
        A：出現回数をカウントしたリスト
        B：出現回数をカウントしたリスト
    """
    import numpy as np
    from numpy.fft import rfft, irfft

    # 出現数カウント
    MAXA = max(A)
    MAXB = max(B)
    C1 = [0] * (MAXA + 1)
    C2 = [0] * (MAXB + 1)
    for a in A:
        C1[a] += 1
    for b in B:
        C2[b] += 1
    # max(A)+max(B)より大きい2冪
    L = 1
    k = 0
    while L <= MAXA + MAXB:
        k += 1
        L = 2**k
    # FFT
    res = irfft(rfft(C1, L) * rfft(C2, L), L)
    # 四捨五入して整数に
    res = np.rint(res).astype(np.int64)
    return res

N, M, L = MAP()
A = LIST()
B = LIST()
res = list(fft(A, B))
mn = INF
for i, a in enumerate(res):
    if a != 0:
        mn = i
        break
for _ in range(L):
    x, y, c = MAP()
    x -= 1
    y -= 1
    mn = min(mn, A[x] + B[y] - c)
print(mn)

# -*- coding: utf-8 -*-
import sys
from collections import Counter

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

def list2d(a, b, c):
    return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
    return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
    return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
    return int(-(-x // y))

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

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

def LIST(N=None):
    return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
    print("Yes")

def No():
    print("No")

def YES():
    print("YES")

def NO():
    print("NO")

sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
N, M, L = MAP()
A = LIST()
B = LIST()
mn = min(A) + min(B)
for _ in range(L):
    x, y, c = MAP()
    x -= 1
    y -= 1
    mn = min(mn, A[x] + B[y] - c)
print(mn)

-    高速フーリエ変換(FFT)

-        A：出現回数をカウントしたリスト

-        B：出現回数をカウントしたリスト

-    # 出現数カウント

-    res = irfft(rfft(C1, L) * rfft(C2, L), L)

-    # 四捨五入して整数に

-    res = np.rint(res).astype(np.int64)


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 = [int(_) for _ in input().split(" ")]

tmp = np.argsort(A)

tmp2= tmp + np.ones(N)

tmp3 = [int(_) for _ in tmp2.tolist()]

ans = [str(_) for _ in tmp3]

print((" ".join(ans)))

# optimized version of the same code:

N = int(eval(input()))

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

tmp = sorted(list(range(1, len(A) + 1)), key=lambda x:A[x - 1])

ans = [str(_) for _ in tmp]

print((" ".join(ans)))

import numpy as np

N = int(eval(input()))
A = [int(_) for _ in input().split(" ")]
tmp = np.argsort(A)
tmp2 = tmp + np.ones(N)
tmp3 = [int(_) for _ in tmp2.tolist()]
ans = [str(_) for _ in tmp3]
print((" ".join(ans)))

N = int(eval(input()))
A = [int(_) for _ in input().split(" ")]
tmp = sorted(list(range(1, len(A) + 1)), key=lambda x: A[x - 1])
ans = [str(_) for _ in tmp]
print((" ".join(ans)))

+tmp = sorted(list(range(1, len(A) + 1)), key=lambda x: A[x - 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

h,w = list(map(int,input().split()))

grid = numpy.empty([h,w], str)

white_h = []

white_w = []

for i in range(h):

    grid[i] = list(eval(input()))

for i in range(h):

    if "#" not in grid[i]:

        white_h.append(i)

for i in range(w):

    if "#" not in grid[:, i]:

        white_w.append(i)

ans_grid = numpy.empty([h-len(white_h), w-len(white_w)], str)

cnt_h = 0

for i in range(h):

    if i not in white_h:

        cnt_w = 0

        for j in range(w):

            if j not in white_w:

                ans_grid[cnt_h, cnt_w] = grid[i,j]

                cnt_w += 1

        cnt_h += 1

for i in range(len(ans_grid)):

    print(("".join(ans_grid[i])))

# optimized version of the same code:

h,w = list(map(int,input().split()))

grid = []

for i in range(h):

    grid.append(list(eval(input())))

h_b = []

w_b = []

for i in range(h):

    if "#" in grid[i]:

        h_b.append(i)

grid_t = [list(x) for x in zip(*grid)]

for i in range(w):

    if "#" in grid_t[i]:

        w_b.append(i)

ans = []

for i in h_b:

    crt = []

    for j in w_b:

        crt.append(grid[i][j])

    ans.append(crt)

for i in range(len(ans)):

    print(("".join(ans[i])))

import numpy

h, w = list(map(int, input().split()))
grid = numpy.empty([h, w], str)
white_h = []
white_w = []
for i in range(h):
    grid[i] = list(eval(input()))
for i in range(h):
    if "#" not in grid[i]:
        white_h.append(i)
for i in range(w):
    if "#" not in grid[:, i]:
        white_w.append(i)
ans_grid = numpy.empty([h - len(white_h), w - len(white_w)], str)
cnt_h = 0
for i in range(h):
    if i not in white_h:
        cnt_w = 0
        for j in range(w):
            if j not in white_w:
                ans_grid[cnt_h, cnt_w] = grid[i, j]
                cnt_w += 1
        cnt_h += 1
for i in range(len(ans_grid)):
    print(("".join(ans_grid[i])))

h, w = list(map(int, input().split()))
grid = []
for i in range(h):
    grid.append(list(eval(input())))
h_b = []
w_b = []
for i in range(h):
    if "#" in grid[i]:
        h_b.append(i)
grid_t = [list(x) for x in zip(*grid)]
for i in range(w):
    if "#" in grid_t[i]:
        w_b.append(i)
ans = []
for i in h_b:
    crt = []
    for j in w_b:
        crt.append(grid[i][j])
    ans.append(crt)
for i in range(len(ans)):
    print(("".join(ans[i])))

-ans_grid = numpy.empty([h - len(white_h), w - len(white_w)], str)

-                ans_grid[cnt_h, cnt_w] = grid[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:

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

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

L, R = [None] * M, [None] * M

for i in range(M):

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

l = max(L)

r = min(R)

ans = max(r - l + 1, 0)

print(ans)

# optimized version of the same code:

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

import sys

input = sys.stdin.readline

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

L, R = [None] * M, [None] * M

for i in range(M):

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

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

print(ans)

+import sys
+
+input = sys.stdin.readline
-l = max(L)
-r = min(R)
-ans = max(r - l + 1, 0)
+ans = max(min(R) - max(L) + 1, 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 math

input_num = int(eval(input()))

num_sqrt = int(math.sqrt(input_num))

minimam = input_num

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

    q, mod = divmod(input_num, i)

    distance = q + i -2

    if mod == 0 and minimam > distance:

        minimam = distance

print(minimam)

# optimized version of the same code:

import math

def main1():

    input_num = int(eval(input()))

    num_sqrt = int(math.sqrt(input_num))

    minimam = input_num

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

        q, mod = divmod(input_num, i)

        if mod == 0:

            distance = q + i -2

            if minimam > distance:

                minimam = distance

    print(minimam)

main1()

import math

input_num = int(eval(input()))
num_sqrt = int(math.sqrt(input_num))
minimam = input_num
for i in range(num_sqrt + 1, 0, -1):
    q, mod = divmod(input_num, i)
    distance = q + i - 2
    if mod == 0 and minimam > distance:
        minimam = distance
print(minimam)

import math

def main1():
    input_num = int(eval(input()))
    num_sqrt = int(math.sqrt(input_num))
    minimam = input_num
    for i in range(num_sqrt + 1, 0, -1):
        q, mod = divmod(input_num, i)
        if mod == 0:
            distance = q + i - 2
            if minimam > distance:
                minimam = distance
    print(minimam)

main1()

-    if mod == 0 and minimam > distance:

+    num_sqrt = int(math.sqrt(input_num))

+    for i in range(num_sqrt + 1, 0, -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:

# C - Walk on Multiplication Table

# https://atcoder.jp/contests/abc144/tasks/abc144_c

n = int(eval(input()))

ans = 10 ** 12

for i in range(1, 10 ** 6 + 1):

  if n % i == 0:

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

print((ans - 2))

# optimized version of the same code:

# C - Walk on Multiplication Table

# https://atcoder.jp/contests/abc144/tasks/abc144_c

n = int(eval(input()))

ans = n

for i in range(1, int(n**.5) + 2):

  if n % i == 0:

    ans = min(ans, n // i + i - 2)

print(ans)

# C - Walk on Multiplication Table
# https://atcoder.jp/contests/abc144/tasks/abc144_c
n = int(eval(input()))
ans = 10**12
for i in range(1, 10**6 + 1):
    if n % i == 0:
        ans = min(ans, n // i + i)
print((ans - 2))

# C - Walk on Multiplication Table
# https://atcoder.jp/contests/abc144/tasks/abc144_c
n = int(eval(input()))
ans = n
for i in range(1, int(n**0.5) + 2):
    if n % i == 0:
        ans = min(ans, n // i + i - 2)
print(ans)

-ans = 10**12
-for i in range(1, 10**6 + 1):
+ans = n
+for i in range(1, int(n**0.5) + 2):
-        ans = min(ans, n // i + i)
-print((ans - 2))
+        ans = min(ans, n // i + i - 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:

# AGC003B - Simplified mahjong

import sys

input = sys.stdin.readline

def main():

    # split in subsequences when 0 appears -> sum up cur // 2

    N = int(eval(input()))

    A = list(map(int, [eval(input()) for _ in range(N)])) + [0]

    ans, cur = 0, 0

    for i in A:

        if i:

            cur += i

        else:

            ans += cur // 2

            cur = 0

    print(ans)

if __name__ == "__main__":

    main()

# optimized version of the same code:

# AGC003B - Simplified mahjong

def main():

    # split in subsequences when 0 appears -> sum up cur // 2

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

    A.append(0)

    ans, cur = 0, 0

    for i in A:

        if i:

            cur += i

        else:

            ans += cur // 2

            cur = 0

    print(ans)

if __name__ == "__main__":

    main()

-    A = list(map(int, [eval(input()) for _ in range(N)])) + [0]

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

while True:

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

    if n == x == 0:

        break

    count = 0

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

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

            for c in range(b + 1, n + 1):

                if sum([a,b,c]) == x:

                    count += 1

    print(count)

# optimized version of the same code:

while True:

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

    if n == x == 0:

        break

    count = 0

    limit = n if n < x else x

    for a in range(1, limit + 1):

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

            for c in range(b + 1, limit + 1):

                if sum([a,b,c]) == x:

                    count += 1

    print(count)

while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            for c in range(b + 1, n + 1):
                if sum([a, b, c]) == x:
                    count += 1
    print(count)

while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    limit = n if n < x else x
    for a in range(1, limit + 1):
        for b in range(a + 1, limit + 1):
            for c in range(b + 1, limit + 1):
                if sum([a, b, c]) == x:
                    count += 1
    print(count)

-            for c in range(b + 1, n + 1):

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

+            for c in range(b + 1, limit + 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 sys

sys.setrecursionlimit(10000000)

#const

dxdy=((1,0),(0,1))

#my functions here!

def pin(type=int):

    return list(map(type,input().rstrip().split()))

#your code here!

def resolve():

    S=eval(input())

    ans=0

    hidari=0

    for i,c in enumerate(S):

        if c=="W":

            ans+=i-hidari

            hidari+=1

    print(ans)

import sys

from io import StringIO

import unittest

class TestClass(unittest.TestCase):

    def assertIO(self, input, output):

        stdout, stdin = sys.stdout, sys.stdin

        sys.stdout, sys.stdin = StringIO(), StringIO(input)

        resolve()

        sys.stdout.seek(0)

        out = sys.stdout.read()[:-1]

        sys.stdout, sys.stdin = stdout, stdin

        self.assertEqual(out, output)

    def test_入力例_1(self):

        input = """BBW"""

        output = """2"""

        self.assertIO(input, output)

    def test_入力例_2(self):

        input = """BWBWBW"""

        output = """6"""

        self.assertIO(input, output)

if __name__ == "__main__":

    #unittest.main()

    resolve()#and submit 2 atcoder!

# optimized version of the same code:

import sys

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

def pin(type=int):

    return list(map(type,input().split()))

#%%code

def resolve():

    S=eval(input())

    index=0

    ans=0

    for i in range(len(S)):

        if S[i]=="W":

            ans+=i-index

            index+=1

    print(ans)

#%%submit!

resolve()

import sys

sys.setrecursionlimit(10000000)
# const
dxdy = ((1, 0), (0, 1))
# my functions here!
def pin(type=int):
    return list(map(type, input().rstrip().split()))

# your code here!
def resolve():
    S = eval(input())
    ans = 0
    hidari = 0
    for i, c in enumerate(S):
        if c == "W":
            ans += i - hidari
            hidari += 1
    print(ans)

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """BBW"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """BWBWBW"""
        output = """6"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()  # and submit 2 atcoder!

import sys

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

def pin(type=int):
    return list(map(type, input().split()))

#%%code
def resolve():
    S = eval(input())
    index = 0
    ans = 0
    for i in range(len(S)):
        if S[i] == "W":
            ans += i - index
            index += 1
    print(ans)

#%%submit!
resolve()

-    return list(map(type, input().rstrip().split()))

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

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

-        stdout, stdin = sys.stdout, sys.stdin

-        sys.stdout, sys.stdin = StringIO(), StringIO(input)

-        sys.stdout, sys.stdin = stdout, stdin


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:

'''

ある平面のブロック数×(0,1)

一つでも偶数があれば、均等分割可能

すべて奇数のとき、

ある平面のブロック数を最小となるようにすると、その数が答えになる

'''

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

ret = -1

if 0 in list([x % 2 for x in arr]):

    ret = 0

else:

    arr_sorted = sorted(arr)

    ret = arr_sorted[0] * arr_sorted[1]

print(ret)

# optimized version of the same code:

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

if any([x % 2 == 0 for x in a]):

    print((0))

else:

    a = list(sorted(a))

    print((a[0] * a[1]))

"""
ある平面のブロック数×(0,1)
一つでも偶数があれば、均等分割可能
すべて奇数のとき、
ある平面のブロック数を最小となるようにすると、その数が答えになる
"""
arr = list(map(int, input().split()))
ret = -1
if 0 in list([x % 2 for x in arr]):
    ret = 0
else:
    arr_sorted = sorted(arr)
    ret = arr_sorted[0] * arr_sorted[1]
print(ret)

-ある平面のブロック数×(0,1)

-一つでも偶数があれば、均等分割可能

-ある平面のブロック数を最小となるようにすると、その数が答えになる

-    ret = arr_sorted[0] * arr_sorted[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()))

abc = []

for i in range(N):

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

dp = np.zeros(shape=(N, 3), dtype=int)

dp[0, :] = abc[0]

for i in range(N-1):

    dp[i+1, 0] = max(dp[i+1, 0], dp[i, 1] + abc[i+1][0], dp[i, 2] + abc[i+1][0])

    dp[i+1, 1] = max(dp[i+1, 1], dp[i, 0] + abc[i+1][1], dp[i, 2] + abc[i+1][1])

    dp[i+1, 2] = max(dp[i+1, 2], dp[i, 0] + abc[i+1][2], dp[i, 1] + abc[i+1][2])

print((max(dp[N-1, :])))

# optimized version of the same code:

import numpy as np

N = int(eval(input()))
abc = []
for i in range(N):
    abc.append(list(map(int, input().split())))
dp = np.zeros(shape=(N, 3), dtype=int)
dp[0, :] = abc[0]
for i in range(N - 1):
    dp[i + 1, 0] = max(dp[i + 1, 0], dp[i, 1] + abc[i + 1][0], dp[i, 2] + abc[i + 1][0])
    dp[i + 1, 1] = max(dp[i + 1, 1], dp[i, 0] + abc[i + 1][1], dp[i, 2] + abc[i + 1][1])
    dp[i + 1, 2] = max(dp[i + 1, 2], dp[i, 0] + abc[i + 1][2], dp[i, 1] + abc[i + 1][2])
print((max(dp[N - 1, :])))

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

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

+dp = [[0 for i in range(3)] for j in range(N)]


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

import numpy as np

n = int(eval(input()))

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

a.sort()

ans = []

for x in range(a[0], a[-1]+1):

    ans.append(np.sum((a - x) ** 2))

print((min(ans)))

# optimized version of the same code:

from decimal import Decimal, ROUND_HALF_UP

import numpy as np

n = int(eval(input()))

x = np.array(input().split(), int)

m = Decimal(np.sum(x) / n)

mq = int(m.quantize(0, rounding=ROUND_HALF_UP))

s = np.sum((x-mq)**2)

print(s)

import numpy as np

n = int(eval(input()))
a = np.array(input().split(), np.int)
a.sort()
ans = []
for x in range(a[0], a[-1] + 1):
    ans.append(np.sum((a - x) ** 2))
print((min(ans)))

from decimal import Decimal, ROUND_HALF_UP
import numpy as np

n = int(eval(input()))
x = np.array(input().split(), int)
m = Decimal(np.sum(x) / n)
mq = int(m.quantize(0, rounding=ROUND_HALF_UP))
s = np.sum((x - mq) ** 2)
print(s)

+from decimal import Decimal, ROUND_HALF_UP

+mq = int(m.quantize(0, rounding=ROUND_HALF_UP))


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

apple_taste = []

for i in range(N):

    taste = L + i + 1 - 1

    apple_taste.append(taste)

import numpy as np

abs_apple_taste = np.abs(apple_taste)

m = min(abs_apple_taste)

for j in range(N):

    if m == abs_apple_taste[j]:

        apple_taste.remove(apple_taste[j])

pie_taste = 0

for k in range(N-1):

    pie_taste += apple_taste[k]

print(pie_taste)

# optimized version of the same code:

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

ans = l

eat = l

for i in range(n-1):

    l += 1

    ans += l

    if abs(l) < abs(eat):

        eat = l

print((ans-eat))

N, L = list(map(int, input().split()))
apple_taste = []
for i in range(N):
    taste = L + i + 1 - 1
    apple_taste.append(taste)
import numpy as np

abs_apple_taste = np.abs(apple_taste)
m = min(abs_apple_taste)
for j in range(N):
    if m == abs_apple_taste[j]:
        apple_taste.remove(apple_taste[j])
pie_taste = 0
for k in range(N - 1):
    pie_taste += apple_taste[k]
print(pie_taste)

n, l = list(map(int, input().split()))
ans = l
eat = l
for i in range(n - 1):
    l += 1
    ans += l
    if abs(l) < abs(eat):
        eat = l
print((ans - eat))

-        apple_taste.remove(apple_taste[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:

# C - Go to School

def main():

    import numpy as np

    n = int(input())

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

    a = np.array(a)

    a = np.argsort(a)

    for i in a:

        print(i+1,end=" ")

if __name__ ==  "__main__":

    main()

# optimized version of the same code:

# C - Go to School

def main():

    n = int(eval(input()))

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

    ans = [0] * n

    for i, o in enumerate(a):

        ans[o-1] = i + 1

    print((*ans))

if __name__ ==  "__main__":

    main()

# C - Go to School
def main():
    import numpy as np

    n = int(input())
    a = list(map(int, input().split()))
    a = np.array(a)
    a = np.argsort(a)
    for i in a:
        print(i + 1, end=" ")

if __name__ == "__main__":
    main()

# C - Go to School
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    ans = [0] * n
    for i, o in enumerate(a):
        ans[o - 1] = i + 1
    print((*ans))

if __name__ == "__main__":
    main()

-    import numpy as np
-    n = int(input())
+    n = int(eval(input()))
-    a = np.array(a)
-    a = np.argsort(a)
-    for i in a:
-        print(i + 1, end=" ")
+    ans = [0] * n
+    for i, o in enumerate(a):
+        ans[o - 1] = i + 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:

from collections import deque

N = 3

m = {8: {7, 5}, 7: {8, 6, 4}, 6: {7, 3}, 5: {8, 4, 2}, 4: {7, 5, 3, 1}, 3: {6, 4, 0}, 2: {5, 1}, 1: {4, 2, 0},

     0: {3, 1}}

goal = 123456780

def g(i, j, a):

    t = a // (10 ** j) % 10

    return a - t * (10 ** j) + t * (10 ** i)

def solve():

    MAP = "".join(input().replace(" ", "") for _ in range(N))

    start = 8 - MAP.find("0")

    MAP = int(MAP)

    if MAP == goal:

        return 0

    dp = deque([(0, start, MAP)])

    LOG = {MAP}

    while dp:

        cnt, yx, M = dp.popleft()

        if M == goal:

            return cnt

        cnt += 1

        for nyx in m[yx]:

            CM = g(yx, nyx, M)

            if not CM in LOG:

                dp.append((cnt, nyx, CM))

                LOG.add(CM)

def MAIN():

    print((solve()))

MAIN()

# optimized version of the same code:

from collections import deque

N = 3

m = {8: {7, 5}, 7: {8, 6, 4}, 6: {7, 3}, 5: {8, 4, 2}, 4: {7, 5, 3, 1}, 3: {6, 4, 0}, 2: {5, 1}, 1: {4, 2, 0},

     0: {3, 1}}

goal = 123456780

def g(i, j, a):

    t = a // (10 ** j) % 10

    return a - t * (10 ** j) + t * (10 ** i)

def solve():

    MAP = "".join(input().replace(" ", "") for _ in range(N))

    zero = 8 - MAP.find("0")

    start = int(MAP)

    if start == goal:

        return 0

    dp = deque([(0, start, zero, 1), (0, goal, 0, 0)])

    TABLE = {start: (1, 0), goal: (0, 0)}

    while dp:

        cnt, M, yx, flg = dp.popleft()

        cnt += 1

        for nyx in m[yx]:

            key = g(yx, nyx, M)

            if key in TABLE:

                if TABLE[key][0] != flg:

                    return TABLE[key][1] + cnt

                continue

            TABLE[key] = (flg, cnt)

            dp.append((cnt, key, nyx, flg))

def MAIN():

    print((solve()))

MAIN()

from collections import deque

N = 3
m = {
    8: {7, 5},
    7: {8, 6, 4},
    6: {7, 3},
    5: {8, 4, 2},
    4: {7, 5, 3, 1},
    3: {6, 4, 0},
    2: {5, 1},
    1: {4, 2, 0},
    0: {3, 1},
}
goal = 123456780

def g(i, j, a):
    t = a // (10**j) % 10
    return a - t * (10**j) + t * (10**i)

def solve():
    MAP = "".join(input().replace(" ", "") for _ in range(N))
    start = 8 - MAP.find("0")
    MAP = int(MAP)
    if MAP == goal:
        return 0
    dp = deque([(0, start, MAP)])
    LOG = {MAP}
    while dp:
        cnt, yx, M = dp.popleft()
        if M == goal:
            return cnt
        cnt += 1
        for nyx in m[yx]:
            CM = g(yx, nyx, M)
            if not CM in LOG:
                dp.append((cnt, nyx, CM))
                LOG.add(CM)

def MAIN():
    print((solve()))

MAIN()

from collections import deque

N = 3
m = {
    8: {7, 5},
    7: {8, 6, 4},
    6: {7, 3},
    5: {8, 4, 2},
    4: {7, 5, 3, 1},
    3: {6, 4, 0},
    2: {5, 1},
    1: {4, 2, 0},
    0: {3, 1},
}
goal = 123456780

def g(i, j, a):
    t = a // (10**j) % 10
    return a - t * (10**j) + t * (10**i)

def solve():
    MAP = "".join(input().replace(" ", "") for _ in range(N))
    zero = 8 - MAP.find("0")
    start = int(MAP)
    if start == goal:
        return 0
    dp = deque([(0, start, zero, 1), (0, goal, 0, 0)])
    TABLE = {start: (1, 0), goal: (0, 0)}
    while dp:
        cnt, M, yx, flg = dp.popleft()
        cnt += 1
        for nyx in m[yx]:
            key = g(yx, nyx, M)
            if key in TABLE:
                if TABLE[key][0] != flg:
                    return TABLE[key][1] + cnt
                continue
            TABLE[key] = (flg, cnt)
            dp.append((cnt, key, nyx, flg))

def MAIN():
    print((solve()))

MAIN()

-                dp.append((cnt, nyx, CM))

+                if TABLE[key][0] != flg:

+                    return TABLE[key][1] + cnt

+            dp.append((cnt, key, nyx, flg))


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:

inf = (5000 * 10 ** 5) * 3

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

ret = inf

for cnt_ab in range(max(x, y) * 2 + 1):

    d = cnt_ab // 2

    cnt_a = max(0, x - d)

    cnt_b = max(0, y - d)

    t = cnt_ab * c + cnt_a * a + cnt_b * b

    ret = min(ret, t)

print(ret)

# optimized version of the same code:

def main():

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

    M = max(X, Y)

    k = 0

    ans = A * X + B * Y

    while True:

        ans = min(

            ans,

            AB * k * 2 + max(0, X - k) * A + max(0, Y - k) * B

        )

        if k >= M: break

        k += 1

    print(ans)

if __name__ == '__main__':

    main()

inf = (5000 * 10**5) * 3
a, b, c, x, y = list(map(int, input().split()))
ret = inf
for cnt_ab in range(max(x, y) * 2 + 1):
    d = cnt_ab // 2
    cnt_a = max(0, x - d)
    cnt_b = max(0, y - d)
    t = cnt_ab * c + cnt_a * a + cnt_b * b
    ret = min(ret, t)
print(ret)

def main():
    A, B, AB, X, Y = list(map(int, input().split()))
    M = max(X, Y)
    k = 0
    ans = A * X + B * Y
    while True:
        ans = min(ans, AB * k * 2 + max(0, X - k) * A + max(0, Y - k) * B)
        if k >= M:
            break
        k += 1
    print(ans)

if __name__ == "__main__":
    main()

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

-for cnt_ab in range(max(x, y) * 2 + 1):

-    t = cnt_ab * c + cnt_a * a + cnt_b * b

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

+        ans = min(ans, AB * k * 2 + max(0, X - k) * A + max(0, Y - k) * 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:

S = int(eval(input()))

f = [0]*(S+1)

f[0] = 1

if S >= 3: f[3] = 1

if S >= 4: f[4] = 1

if S >= 5: f[5] = 1

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

    f[i] = sum(f[i-j] for j in range(3, i+1))%(10**9+7)

print((f[S]))

# 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:

import sys

input = sys.stdin.buffer.readline

N, Ma, Mb = list(map(int, input().split()))

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

INF = 10 ** 15

dp = [[INF for j in range(401)] for i in range(401)]

dp[0][0] = 0

for a, b, c in ABC:

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

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

      if dp[i][j] != INF:

        dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c)

answer = INF

for i in range(1, 401):

  for j in range(1, 401):

    if dp[i][j] != INF and i / j == Ma / Mb:

      answer = min(answer, dp[i][j])

print((answer if answer != INF else -1))

# optimized version of the same code:

import sys

input = sys.stdin.buffer.readline

N, Ma, Mb = list(map(int, input().split()))

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

sumA = sum([ABC[i][0] for i in range(N)])

sumB = sum([ABC[i][1] for i in range(N)])

INF = 10 ** 15

dp = [[INF for j in range(sumB + 1)] for i in range(sumA + 1)]

dp[0][0] = 0

for a, b, c in ABC:

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

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

      if dp[i][j] != INF:

        dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c)

answer = INF

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

  for j in range(1, sumB + 1):

    if dp[i][j] != INF and i / j == Ma / Mb:

      answer = min(answer, dp[i][j])

print((answer if answer != INF else -1))

import sys

input = sys.stdin.buffer.readline
N, Ma, Mb = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for _ in range(N)]
INF = 10**15
dp = [[INF for j in range(401)] for i in range(401)]
dp[0][0] = 0
for a, b, c in ABC:
    for i in range(400, -1, -1):
        for j in range(400, -1, -1):
            if dp[i][j] != INF:
                dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c)
answer = INF
for i in range(1, 401):
    for j in range(1, 401):
        if dp[i][j] != INF and i / j == Ma / Mb:
            answer = min(answer, dp[i][j])
print((answer if answer != INF else -1))

import sys

input = sys.stdin.buffer.readline
N, Ma, Mb = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for _ in range(N)]
sumA = sum([ABC[i][0] for i in range(N)])
sumB = sum([ABC[i][1] for i in range(N)])
INF = 10**15
dp = [[INF for j in range(sumB + 1)] for i in range(sumA + 1)]
dp[0][0] = 0
for a, b, c in ABC:
    for i in range(sumA, -1, -1):
        for j in range(sumB, -1, -1):
            if dp[i][j] != INF:
                dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c)
answer = INF
for i in range(1, sumA + 1):
    for j in range(1, sumB + 1):
        if dp[i][j] != INF and i / j == Ma / Mb:
            answer = min(answer, dp[i][j])
print((answer if answer != INF else -1))

+sumA = sum([ABC[i][0] for i in range(N)])

+sumB = sum([ABC[i][1] for i in range(N)])

-dp = [[INF for j in range(401)] for i in range(401)]

+dp = [[INF for j in range(sumB + 1)] for i in range(sumA + 1)]


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

from sys import stdin, stdout, setrecursionlimit

from collections import deque, defaultdict, Counter

from heapq import heappush, heappop

from functools import lru_cache

import math

setrecursionlimit(10**6)

rl = lambda: stdin.readline()

rll = lambda: stdin.readline().split()

rli = lambda: list(map(int, stdin.readline().split()))

rlf = lambda: list(map(float, stdin.readline().split()))

INF, NINF = float('inf'), float('-inf')

MOD = 10**9 + 7

def main():

	s = int(rl())

	@lru_cache(None)

	def dp(currsum):

		if currsum == s: return 1

		cnt = 0

		for d in range(3, 2001):

			if currsum + d <= s:

				cnt += dp(currsum + d)

				cnt %= MOD

		return cnt

	print((dp(0)))

	stdout.close()

if __name__ == "__main__":

	main()

# optimized version of the same code:

from sys import stdin, stdout, setrecursionlimit

from collections import deque, defaultdict, Counter

from heapq import heappush, heappop

from functools import lru_cache

import math

#setrecursionlimit(10**6)

rl = lambda: stdin.readline()

rll = lambda: stdin.readline().split()

rli = lambda: list(map(int, stdin.readline().split()))

rlf = lambda: list(map(float, stdin.readline().split()))

INF, NINF = float('inf'), float('-inf')

MOD = 10**9 + 7

def main():

	s = int(rl())

	def binom_tables(n, q):

		fact = [1 for _ in range(n + 1)]

		inv = [1 for _ in range(n + 1)]

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

			fact[i] = (fact[i-1] * i) % q

			inv[i] = pow(fact[i], q-2, q)

		return fact, inv

	F, I = binom_tables(s + 700, MOD)

	def binom(n, k, q):

		return (F[n]*((I[k]*I[n-k])%q))%q

	ans = 0

	for r in range(1, 700):

		objects = s - 3*r

		if objects + r - 1 < objects or objects < 0:

			break

		x = binom(objects + r - 1, objects, MOD)

		ans += x

		ans %= MOD

	print(ans)

	stdout.close()

if __name__ == "__main__":

	main()

from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: list(map(int, stdin.readline().split()))
rlf = lambda: list(map(float, stdin.readline().split()))
INF, NINF = float("inf"), float("-inf")
MOD = 10**9 + 7

def main():
    s = int(rl())

    @lru_cache(None)
    def dp(currsum):
        if currsum == s:
            return 1
        cnt = 0
        for d in range(3, 2001):
            if currsum + d <= s:
                cnt += dp(currsum + d)
                cnt %= MOD
        return cnt

    print((dp(0)))
    stdout.close()

if __name__ == "__main__":
    main()

from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

# setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: list(map(int, stdin.readline().split()))
rlf = lambda: list(map(float, stdin.readline().split()))
INF, NINF = float("inf"), float("-inf")
MOD = 10**9 + 7

def main():
    s = int(rl())

    def binom_tables(n, q):
        fact = [1 for _ in range(n + 1)]
        inv = [1 for _ in range(n + 1)]
        for i in range(1, n + 1):
            fact[i] = (fact[i - 1] * i) % q
            inv[i] = pow(fact[i], q - 2, q)
        return fact, inv

    F, I = binom_tables(s + 700, MOD)

    def binom(n, k, q):
        return (F[n] * ((I[k] * I[n - k]) % q)) % q

    ans = 0
    for r in range(1, 700):
        objects = s - 3 * r
        if objects + r - 1 < objects or objects < 0:
            break
        x = binom(objects + r - 1, objects, MOD)
        ans += x
        ans %= MOD
    print(ans)
    stdout.close()

if __name__ == "__main__":
    main()

+        fact = [1 for _ in range(n + 1)]

+        inv = [1 for _ in range(n + 1)]

+            fact[i] = (fact[i - 1] * i) % q

+            inv[i] = pow(fact[i], q - 2, q)

+        if objects + r - 1 < objects or objects < 0:

+        x = binom(objects + r - 1, objects, MOD)


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

import fractions

n=int(eval(input()))

print(((2*n)//fractions.gcd(2,n)))

# optimized version of the same code:

N=int(eval(input()));print((N if N%2==0 else N*2))

import fractions

n = int(eval(input()))
print(((2 * n) // fractions.gcd(2, n)))

N = int(eval(input()))
print((N if N % 2 == 0 else N * 2))

-print(((2 * n) // fractions.gcd(2, 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

s = input()

ts = ['']

while True:

  nts= []

  for t in ts:

    for w in ['dreamer', 'eraser', 'dream', 'erase']:

      if s == t + w:

        print('YES')

        sys.exit()

      if s.startswith(t + w):

        nts.append(t + w)

  if len(nts) == 0:

    print('NO')

    sys.exit()

  ts = nts

# optimized version of the same code:

from sys import exit

s = eval(input())

ts = ['']

while True:

  nts= []

  for t in ts:

    for w in ['dreamer', 'eraser', 'dream', 'erase']:

      tw = t + w

      if s == tw:

        print('YES')

        exit()

      if s.startswith(tw):

        nts.append(tw)

  if len(nts) == 0:

    print('NO')

    exit()

  ts = nts

import sys

s = input()
ts = [""]
while True:
    nts = []
    for t in ts:
        for w in ["dreamer", "eraser", "dream", "erase"]:
            if s == t + w:
                print("YES")
                sys.exit()
            if s.startswith(t + w):
                nts.append(t + w)
    if len(nts) == 0:
        print("NO")
        sys.exit()
    ts = nts

from sys import exit

s = eval(input())
ts = [""]
while True:
    nts = []
    for t in ts:
        for w in ["dreamer", "eraser", "dream", "erase"]:
            tw = t + w
            if s == tw:
                print("YES")
                exit()
            if s.startswith(tw):
                nts.append(tw)
    if len(nts) == 0:
        print("NO")
        exit()
    ts = nts

-import sys
+from sys import exit
-s = input()
+s = eval(input())
-            if s == t + w:
+            tw = t + w
+            if s == tw:
-                sys.exit()
-            if s.startswith(t + w):
-                nts.append(t + w)
+                exit()
+            if s.startswith(tw):
+                nts.append(tw)
-        sys.exit()
+        exit()


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

a = [[0]*N]*K

a = [[0 for n in range(N)] for k in range(K)]

for k in range(K):

    d=int(eval(input()))

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

    for h in have_k:

        a[k][h-1]=1

an=[0]*N

for k in range(K):

  for n in range(N):

    an[n] = an[n]+a[k][n]

result=0

for i in an:

  if i == 0:

    result+=1

print(result)

# optimized version of the same code:

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

a = [[0 for n in range(N)] for k in range(K)]

for k in range(K):

    d=int(eval(input()))

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

    for h in have_k:

        a[k][h-1]=1

an=[0]*N

for k in range(K):

  for n in range(N):

    an[n] = an[n]+a[k][n]

result=0

for i in an:

  if i == 0:

    result+=1

print(result)

N, K = list(map(int, input().split()))
a = [[0] * N] * K
a = [[0 for n in range(N)] for k in range(K)]
for k in range(K):
    d = int(eval(input()))
    have_k = list(map(int, input().split()))
    for h in have_k:
        a[k][h - 1] = 1
an = [0] * N
for k in range(K):
    for n in range(N):
        an[n] = an[n] + a[k][n]
result = 0
for i in an:
    if i == 0:
        result += 1
print(result)

N, K = list(map(int, input().split()))
a = [[0 for n in range(N)] for k in range(K)]
for k in range(K):
    d = int(eval(input()))
    have_k = list(map(int, input().split()))
    for h in have_k:
        a[k][h - 1] = 1
an = [0] * N
for k in range(K):
    for n in range(N):
        an[n] = an[n] + a[k][n]
result = 0
for i in an:
    if i == 0:
        result += 1
print(result)


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

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

x = np.array(x)

ans = float('inf')

idx = 200

for i in range(100):

  y = x

  ans = min(ans, np.sum((y-i)**2))

print(ans)

# optimized version of the same code:

N = int(eval(input()))

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

mx = max(X)

ans = float('inf')

for i in range(mx+1):

  tmp = 0

  for x in X:

    tmp += (x-(i+1))**2

  ans = min(ans, tmp)

print(ans)

import numpy as np

n = int(eval(input()))
x = list(map(int, input().split()))
x = np.array(x)
ans = float("inf")
idx = 200
for i in range(100):
    y = x
    ans = min(ans, np.sum((y - i) ** 2))
print(ans)

N = int(eval(input()))
X = list(map(int, input().split()))
mx = max(X)
ans = float("inf")
for i in range(mx + 1):
    tmp = 0
    for x in X:
        tmp += (x - (i + 1)) ** 2
    ans = min(ans, tmp)
print(ans)

-    ans = min(ans, np.sum((y - i) ** 2))


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

import sys

sys.setrecursionlimit(1000000)

S = eval(input())

T = ['dream', 'dreamer', 'erase', 'eraser']

lenT = [len(i) for i in T]

def dayDream(pin):

    global isDream               #;print('dayDream: ', pin, S[pin:])

    for i, d in enumerate(T):

        #print('d:', d)

        if S[pin:pin+lenT[i]] == d:

            pout = pin + lenT[i] #; print(d, pout)

            if pout == len(S):

                isDream = True   #; print('YES')

                return

            else:

                dayDream(pout)

    #print('dayDream return', pin)

    return

isDream = False

dayDream(0)

if isDream:

    print('YES')

else:

    print('NO')

# optimized version of the same code:

import sys

sys.setrecursionlimit(1000000)

S = eval(input())

T = ['dream', 'dreamer', 'erase', 'eraser']

lenT = [len(i) for i in T]

def dayDream(pin):

    global isGoal               #;print('dayDream: ', pin, S[pin:])

    for i, d in enumerate(T):

        if isGoal:

            return

        #print('i, d:', i, d)

        if S[pin:pin+lenT[i]] == d:

            pout = pin + lenT[i] #;print(d, pout)

            if pout == len(S):

                isGoal = True    #;print('YES')

                return

            else:

                dayDream(pout)

    #print('dayDream return', pin)

    return

isGoal = False

dayDream(0)

if isGoal:

    print('YES')

else:

    print('NO')

import sys

sys.setrecursionlimit(1000000)
S = eval(input())
T = ["dream", "dreamer", "erase", "eraser"]
lenT = [len(i) for i in T]

def dayDream(pin):
    global isDream  # ;print('dayDream: ', pin, S[pin:])
    for i, d in enumerate(T):
        # print('d:', d)
        if S[pin : pin + lenT[i]] == d:
            pout = pin + lenT[i]  # ; print(d, pout)
            if pout == len(S):
                isDream = True  # ; print('YES')
                return
            else:
                dayDream(pout)
    # print('dayDream return', pin)
    return

isDream = False
dayDream(0)
if isDream:
    print("YES")
else:
    print("NO")

import sys

sys.setrecursionlimit(1000000)
S = eval(input())
T = ["dream", "dreamer", "erase", "eraser"]
lenT = [len(i) for i in T]

def dayDream(pin):
    global isGoal  # ;print('dayDream: ', pin, S[pin:])
    for i, d in enumerate(T):
        if isGoal:
            return
        # print('i, d:', i, d)
        if S[pin : pin + lenT[i]] == d:
            pout = pin + lenT[i]  # ;print(d, pout)
            if pout == len(S):
                isGoal = True  # ;print('YES')
                return
            else:
                dayDream(pout)
    # print('dayDream return', pin)
    return

isGoal = False
dayDream(0)
if isGoal:
    print("YES")
else:
    print("NO")

-    global isDream  # ;print('dayDream: ', pin, S[pin:])

+    global isGoal  # ;print('dayDream: ', pin, S[pin:])

-            pout = pin + lenT[i]  # ; print(d, pout)

+            pout = pin + lenT[i]  # ;print(d, pout)

-                isDream = True  # ; print('YES')

+                isGoal = True  # ;print('YES')


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

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

c=[0]*(n+2)

for i in range(m):

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

  c[l-1]+=1

  c[r]-=1

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

  c[i]=c[i]+c[i-1]

ans=0

for i in range(n+2):

  if c[i]==m:

    ans+=1

print(ans)

# optimized version of the same code:

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

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

for i in range(m-1):

  tl,tr=list(map(int,input().split()))

  if l<tl:

    l=tl

  if tr<r:

    r=tr

print((max(r-l+1,0)))

n, m = list(map(int, input().split()))
c = [0] * (n + 2)
for i in range(m):
    l, r = list(map(int, input().split()))
    c[l - 1] += 1
    c[r] -= 1
for i in range(1, n + 2):
    c[i] = c[i] + c[i - 1]
ans = 0
for i in range(n + 2):
    if c[i] == m:
        ans += 1
print(ans)

n, m = list(map(int, input().split()))
l, r = list(map(int, input().split()))
for i in range(m - 1):
    tl, tr = list(map(int, input().split()))
    if l < tl:
        l = tl
    if tr < r:
        r = tr
print((max(r - l + 1, 0)))

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

+    tl, tr = 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,m=list(map(int,input().split()))

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

b=[0 for x in range(n+1)]

l=list([0])

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

  b[i]=b[i-1]+a[i-1]

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

  l.append(b[i]%m)

d=list()

l.sort()

t,c=0,1

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

  if l[i]==l[i-1]:

    c+=1

  else:

    if c!=1:

      t += c*(c-1)//2

      c=1

if c!=1:

  t += c*(c-1)//2

print(t)

# optimized version of the same code:

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

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

l=list([0])

b=0

for i in range(0,n):

  b += a[i]

  l.append(b%m)

l.append(m)

l.sort()

t,c=0,1

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

  if l[i]==l[i-1]:

    c+=1

  else:

    if c!=1:

      t += c*(c-1)//2

      c=1

print(t)

n, m = list(map(int, input().split()))
a = [int(x) for x in input().split()]
b = [0 for x in range(n + 1)]
l = list([0])
for i in range(1, n + 1):
    b[i] = b[i - 1] + a[i - 1]
for i in range(1, n + 1):
    l.append(b[i] % m)
d = list()
l.sort()
t, c = 0, 1
for i in range(1, n + 1):
    if l[i] == l[i - 1]:
        c += 1
    else:
        if c != 1:
            t += c * (c - 1) // 2
            c = 1
if c != 1:
    t += c * (c - 1) // 2
print(t)

n, m = list(map(int, input().split()))
a = [int(x) for x in input().split()]
l = list([0])
b = 0
for i in range(0, n):
    b += a[i]
    l.append(b % m)
l.append(m)
l.sort()
t, c = 0, 1
for i in range(1, n + 2):
    if l[i] == l[i - 1]:
        c += 1
    else:
        if c != 1:
            t += c * (c - 1) // 2
            c = 1
print(t)

-b = [0 for x in range(n + 1)]
-for i in range(1, n + 1):
-    b[i] = b[i - 1] + a[i - 1]
-for i in range(1, n + 1):
-    l.append(b[i] % m)
-d = list()
+b = 0
+for i in range(0, n):
+    b += a[i]
+    l.append(b % m)
+l.append(m)
-for i in range(1, n + 1):
+for i in range(1, n + 2):
-if c != 1:
-    t += c * (c - 1) // 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 = int(eval(input()))

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

A = np.array(A)

counter = 0

while True:

    if all( i%2==0 for i in A):

        counter  += 1

        A = A/2

    else:

        print(counter)

        break

# optimized version of the same code:

N = int(eval(input()))

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

c = 0

while True:

    if all(a% 2 ==0 for a in A):

        c += 1

        A = list([x//2 for x in A])

    else:

        break

print(c)

import numpy as np

N = int(eval(input()))
A = list(map(int, input().split()))
A = np.array(A)
counter = 0
while True:
    if all(i % 2 == 0 for i in A):
        counter += 1
        A = A / 2
    else:
        print(counter)
        break

N = int(eval(input()))
A = list(map(int, input().split()))
c = 0
while True:
    if all(a % 2 == 0 for a in A):
        c += 1
        A = list([x // 2 for x in A])
    else:
        break
print(c)

-import numpy as np
-A = np.array(A)
-counter = 0
+c = 0
-    if all(i % 2 == 0 for i in A):
-        counter += 1
-        A = A / 2
+    if all(a % 2 == 0 for a in A):
+        c += 1
+        A = list([x // 2 for x in A])
-        print(counter)
+print(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:

import copy

n=int(eval(input()))

org_set=set([i for i in range(1,10**5)])

edges=[]

relations={}

nodes=[]

for i in range(n-1):

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

    edges.append([a,b])

    relations.setdefault(a,[]).append(b)

    nodes.append([])

nodes.append([])

nodes.append([])

max_color=0

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

    targets=relations.get(start,[])

    color=1

    for target in targets:

        if color in nodes[start]:

            color+=1

        else:

            pass

        nodes[target].append(color)

        if color>=max_color:

            max_color=color

        color+=1

print(max_color)

for edge in edges:

    print((nodes[edge[1]][0]))

# optimized version of the same code:

n=int(eval(input()))

edges=[]

relations={}

nodes=[0,0]

for i in range(n-1):

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

    edges.append([a,b])

    relations.setdefault(a,[]).append(b)

    nodes.append(0)

max_color=0

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

    targets=relations.get(start,[])

    color=1

    for target in targets:

        if color == nodes[start]:

            color+=1

        else:

            pass

        nodes[target]=color

        if color>=max_color:

            max_color=color

        color+=1

print(max_color)

for edge in edges:

    print((nodes[edge[1]]))

import copy

n = int(eval(input()))
org_set = set([i for i in range(1, 10**5)])
edges = []
relations = {}
nodes = []
for i in range(n - 1):
    a, b = list(map(int, input().split(" ")))
    edges.append([a, b])
    relations.setdefault(a, []).append(b)
    nodes.append([])
nodes.append([])
nodes.append([])
max_color = 0
for start in range(1, n + 1):
    targets = relations.get(start, [])
    color = 1
    for target in targets:
        if color in nodes[start]:
            color += 1
        else:
            pass
        nodes[target].append(color)
        if color >= max_color:
            max_color = color
        color += 1
print(max_color)
for edge in edges:
    print((nodes[edge[1]][0]))

n = int(eval(input()))
edges = []
relations = {}
nodes = [0, 0]
for i in range(n - 1):
    a, b = list(map(int, input().split(" ")))
    edges.append([a, b])
    relations.setdefault(a, []).append(b)
    nodes.append(0)
max_color = 0
for start in range(1, n + 1):
    targets = relations.get(start, [])
    color = 1
    for target in targets:
        if color == nodes[start]:
            color += 1
        else:
            pass
        nodes[target] = color
        if color >= max_color:
            max_color = color
        color += 1
print(max_color)
for edge in edges:
    print((nodes[edge[1]]))

-org_set = set([i for i in range(1, 10**5)])


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

# x < yでyが不要とする。y抜きで[K-y,K)を作れる。

# このときにxを使っていないのならば、xも不要。

# xを使っているのならば、xy抜きで[K-x-y,K-x)を作れる。

# yを加えて、x抜きで[K-x,K)を作れる。

# よってy不要ならばx不要。

import numpy as np

import itertools

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

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

A.sort()

# カードは[0,N)-indexed

def test(i):

  # i番目のカードは不要

  dp = np.zeros(K,dtype=np.bool)

  dp[0] = True

  for a in itertools.chain(A[:i],A[i+1:]):

    dp[a:] = np.logical_or(dp[a:],dp[:-a])

  return not dp[-A[i]:].any()

left = -1 # 不要だと判明

right = N # 不要でないと判明

while right - left > 1:

  mid = (left+right)//2

  if test(mid):

    left = mid

  else:

    right = mid

answer = left+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

import itertools

"""

・「必要」とは～～が存在

・x を含まない、[K-x,K) 内の総和が存在

・集合を指定すると、ある値段より上側

・全体としても単調性がある

"""

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

A = [x if x <= K else K + 1 for x in A]

A.sort()

mask = (1 << K) - 1

def test(x):

    # x番目は必要

    if A[x] > K:

        return True

    dp = 1

    for a in itertools.chain(A[:x], A[x+1:]):

        dp |= (dp << a)

        dp &= mask

    dp >>= (K - A[x])

    return (dp > 0)

left = -1 # 必要

right = N # 不要

while left + 1 < right:

    x = (left + right) // 2

    if test(x):

        right = x

    else:

        left = x

answer = left + 1

print(answer)

# x < yでyが不要とする。y抜きで[K-y,K)を作れる。
# このときにxを使っていないのならば、xも不要。
# xを使っているのならば、xy抜きで[K-x-y,K-x)を作れる。
# yを加えて、x抜きで[K-x,K)を作れる。
# よってy不要ならばx不要。
import numpy as np
import itertools

N, K = list(map(int, input().split()))
A = [int(x) for x in input().split()]
A.sort()
# カードは[0,N)-indexed
def test(i):
    # i番目のカードは不要
    dp = np.zeros(K, dtype=np.bool)
    dp[0] = True
    for a in itertools.chain(A[:i], A[i + 1 :]):
        dp[a:] = np.logical_or(dp[a:], dp[:-a])
    return not dp[-A[i] :].any()

left = -1  # 不要だと判明
right = N  # 不要でないと判明
while right - left > 1:
    mid = (left + right) // 2
    if test(mid):
        left = mid
    else:
        right = mid
answer = left + 1
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import itertools

"""
・「必要」とは～～が存在
・x を含まない、[K-x,K) 内の総和が存在
・集合を指定すると、ある値段より上側
・全体としても単調性がある
"""
N, K, *A = list(map(int, read().split()))
A = [x if x <= K else K + 1 for x in A]
A.sort()
mask = (1 << K) - 1

def test(x):
    # x番目は必要
    if A[x] > K:
        return True
    dp = 1
    for a in itertools.chain(A[:x], A[x + 1 :]):
        dp |= dp << a
        dp &= mask
    dp >>= K - A[x]
    return dp > 0

left = -1  # 必要
right = N  # 不要
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        right = x
    else:
        left = x
answer = left + 1
print(answer)

-# x < yでyが不要とする。y抜きで[K-y,K)を作れる。

-# このときにxを使っていないのならば、xも不要。

-# xを使っているのならば、xy抜きで[K-x-y,K-x)を作れる。

-# yを加えて、x抜きで[K-x,K)を作れる。

-# よってy不要ならばx不要。

+・「必要」とは～～が存在

+・x を含まない、[K-x,K) 内の総和が存在

+・集合を指定すると、ある値段より上側

+・全体としても単調性がある

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

+A = [x if x <= K else K + 1 for x in A]

-    # i番目のカードは不要

-    for a in itertools.chain(A[:i], A[i + 1 :]):

-        dp[a:] = np.logical_or(dp[a:], dp[:-a])

+    # x番目は必要

+    for a in itertools.chain(A[:x], A[x + 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:

n=int(eval(input()))

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

k=[]

ans=0

for i in range(400005):

  k.append(0)

for i in range(n):

  if i-a[i]>=0:

    ans+=k[i-a[i]]

  if a[i]+i<400005:

    k[a[i]+i]+=1

print(ans)

# optimized version of the same code:

n=int(eval(input()))

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

thing={}

ans=0

for i in range(n):

  if i-a[i] in thing:

    ans+=thing[i-a[i]]

  if i+a[i] in thing:

    thing[i+a[i]]+=1

  else:

    thing[i+a[i]]=1

print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
k = []
ans = 0
for i in range(400005):
    k.append(0)
for i in range(n):
    if i - a[i] >= 0:
        ans += k[i - a[i]]
    if a[i] + i < 400005:
        k[a[i] + i] += 1
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
thing = {}
ans = 0
for i in range(n):
    if i - a[i] in thing:
        ans += thing[i - a[i]]
    if i + a[i] in thing:
        thing[i + a[i]] += 1
    else:
        thing[i + a[i]] = 1
print(ans)

-k = []
+thing = {}
-for i in range(400005):
-    k.append(0)
-    if i - a[i] >= 0:
-        ans += k[i - a[i]]
-    if a[i] + i < 400005:
-        k[a[i] + i] += 1
+    if i - a[i] in thing:
+        ans += thing[i - a[i]]
+    if i + a[i] in thing:
+        thing[i + a[i]] += 1
+    else:
+        thing[i + a[i]] = 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 sys

import numpy as np

N = eval(input())

V = input().split()

v = np.array([ int(x) for x in V])

C = input().split()

c = np.array([ int(x) for x in C])

delt = v - c

print((delt[delt>0].sum()))

# optimized version of the same code:

N = int(eval(input()))

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

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

ans = 0

for v, c in zip(V, C):

    p = v - c

    if p > 0:

        ans += p

print(ans)

import sys
import numpy as np

N = eval(input())
V = input().split()
v = np.array([int(x) for x in V])
C = input().split()
c = np.array([int(x) for x in C])
delt = v - c
print((delt[delt > 0].sum()))

-import sys
-import numpy as np
-N = eval(input())
-V = input().split()
-v = np.array([int(x) for x in V])
-C = input().split()
-c = np.array([int(x) for x in C])
-delt = v - c
-print((delt[delt > 0].sum()))
+N = int(eval(input()))
+V = list(map(int, input().split()))
+C = list(map(int, input().split()))
+ans = 0
+for v, c in zip(V, C):
+    p = v - c
+    if p > 0:
+        ans += p
+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 heapq

import os

import sys

if os.getenv("LOCAL"):

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

sys.setrecursionlimit(2147483647)

INF = float("inf")

N = int(sys.stdin.readline())

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

# ans = []

# while len(A) > 2:

#     x = max(A)

#     y = min(A)

#     A = A[1:-1]

#     next_max = max(A)

#     next_min = min(A)

#     if abs(x - y - next_min) < abs(y - x - next_max):

#         x, y = y, x

#     bisect.insort_left(A, x - y)

#     ans.append((x, y))

# x, y = max(A), min(A)

# ans.append((x, y))

# print(x - y)

# for a in ans:

#     print(*a)

enable = [True] * N

mins = [(a, i) for i, a in enumerate(A)]

maxes = [(-a, i) for i, a in enumerate(A)]

heapq.heapify(mins)

heapq.heapify(maxes)

ans = []

for _ in range(N - 2):

    x, xi = heapq.heappop(maxes)

    x *= -1

    y, yi = heapq.heappop(mins)

    enable[xi] = False

    enable[yi] = False

    while not enable[maxes[0][1]]:

        heapq.heappop(maxes)

    while not enable[mins[0][1]]:

        heapq.heappop(mins)

    next_max = -maxes[0][0]

    next_min = mins[0][0]

    if abs(x - y - next_min) < abs(y - x - next_max):

        x, y = y, x

    enable.append(True)

    heapq.heappush(mins, (x - y, len(enable) - 1))

    heapq.heappush(maxes, (y - x, len(enable) - 1))

    ans.append((x, y))

x = -maxes[0][0]

y = mins[0][0]

ans.append((x, y))

print((x - y))

for a in ans:

    print((*a))

# optimized version of the same code:

import bisect

import os

from collections import Counter, deque

from fractions import gcd

from functools import lru_cache

from functools import reduce

import functools

import heapq

import itertools

import math

import numpy as np

import re

import string

import sys

if os.getenv("LOCAL"):

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

sys.setrecursionlimit(2147483647)

INF = float("inf")

N = int(sys.stdin.readline())

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

plus = []

minus = []

for a in A:

    if a >= 0:

        plus.append(a)

    else:

        minus.append(a)

if not plus:

    mm = max(minus)

    plus.append(mm)

    minus.remove(mm)

if not minus:

    mp = min(plus)

    minus.append(mp)

    plus.remove(mp)

hist = []

x = minus.pop()

while len(plus) > 1:

    y = plus.pop()

    hist.append((x, y))

    x = x - y

minus.append(x)

x = plus.pop()

while len(minus) > 1:

    y = minus.pop()

    hist.append((x, y))

    x = x - y

y = minus.pop()

hist.append((x, y))

print((x - y))

for h in hist:

    print((*h))

-#     if abs(x - y - next_min) < abs(y - x - next_max):

-mins = [(a, i) for i, a in enumerate(A)]

-maxes = [(-a, i) for i, a in enumerate(A)]

-    if abs(x - y - next_min) < abs(y - x - next_max):

-    heapq.heappush(mins, (x - y, len(enable) - 1))

-    heapq.heappush(maxes, (y - x, len(enable) - 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 sys

import os

import math

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

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

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

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

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

def main():

    if os.getenv("LOCAL"):

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

    N = ii()

    ret = float('inf')

    I = int(math.sqrt(N)) * 10

    for i in range(1, I):

        if N%i == 0:

            j = N//i

            ret = min(ret, j + i - 2)

    print(ret)

if __name__ == '__main__':

    main()

# optimized version of the same code:

import sys

import os

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

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

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

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

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

def main():

    if os.getenv("LOCAL"):

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

    N = ii()

    m = int(N ** .5)

    while N % m != 0:

        m -= 1

    else:

        print((int(N / m + m - 2)))

if __name__ == '__main__':

    main()

import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    N = ii()
    ret = float("inf")
    I = int(math.sqrt(N)) * 10
    for i in range(1, I):
        if N % i == 0:
            j = N // i
            ret = min(ret, j + i - 2)
    print(ret)

if __name__ == "__main__":
    main()

import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    N = ii()
    m = int(N**0.5)
    while N % m != 0:
        m -= 1
    else:
        print((int(N / m + m - 2)))

if __name__ == "__main__":
    main()

-import math
-    ret = float("inf")
-    I = int(math.sqrt(N)) * 10
-    for i in range(1, I):
-        if N % i == 0:
-            j = N // i
-            ret = min(ret, j + i - 2)
-    print(ret)
+    m = int(N**0.5)
+    while N % m != 0:
+        m -= 1
+    else:
+        print((int(N / m + m - 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, m = list(map(int, input().split()))

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

cd = [list(map(int, input().split())) for i in range(m)]

dist = np.zeros((n, m))

for i in range(n):

  for j in range(m):

    dist[i, j] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])

for dis in dist:

  print((dis.argmin()+1))

# optimized version of the same code:

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

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

cd = [list(map(int, input().split())) for i in range(m)]

for i in range(n):

  a, b = ab[i]

  dist = 1e+15

  ans = 0

  for j in range(m):

    c, d = cd[j]

    if dist > abs(a - c) + abs(b - d):

      ans = j

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

  print((ans+1))

import numpy as np

n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]
dist = np.zeros((n, m))
for i in range(n):
    for j in range(m):
        dist[i, j] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
for dis in dist:
    print((dis.argmin() + 1))

n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]
for i in range(n):
    a, b = ab[i]
    dist = 1e15
    ans = 0
    for j in range(m):
        c, d = cd[j]
        if dist > abs(a - c) + abs(b - d):
            ans = j
            dist = abs(a - c) + abs(b - d)
    print((ans + 1))

+        if dist > abs(a - c) + abs(b - d):

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