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

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

a.reverse()

b.reverse()

ans = 0

capacity = 0

for i in range(N):

    ans += min(b[i] + capacity, a[i])

    capacity = max(b[i] - max(a[i] - capacity, 0), 0)

ans += min(a[-1], capacity)

print(ans)

# optimized version of the same code:

n = int(eval(input()))

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

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

a = a[::-1]

b = b[::-1]

ans = 0

for i, bi in enumerate(b):

    ans += min(a[i], b[i])

    remain = max(0, b[i] - a[i])

    ans += min(a[i + 1], remain)

    a[i + 1] = max(0, a[i + 1] - remain)

print(ans)

-    capacity = max(b[i] - max(a[i] - capacity, 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:

#coding:utf-8

import bisect

import sys

sys.setrecursionlimit(10**6)

write = sys.stdout.write

dbg = lambda *something : print(*something) if DEBUG else 0

DEBUG = True

def main(given = sys.stdin.readline):

    input = lambda : given().rstrip()

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

    II = lambda : int(input())

    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    n, t = LMIIS()

    ab = XLMIIS(n)

    dp1 = [[0]*t for _ in range(n)]

    for i in range(1, n):

        for j in range(1, t):

            if j < ab[i-1][0]:

                dp1[i][j] = dp1[i-1][j]

            else:

                dp1[i][j] = max(dp1[i-1][j], dp1[i-1][j-ab[i-1][0]] + ab[i-1][1])

    dp2 = [[0]*t for _ in range(n)]

    for i in range(1, n):

        for j in range(1, t):

            if j < ab[n - i][0]:

                dp2[i][j] = dp2[i-1][j]

            else:

                dp2[i][j] = max(dp2[i-1][j], dp2[i-1][j-ab[n-i][0]] + ab[n-i][1])

    ans = 0

    for i in range(n):

        for j in range(t - 1):

            ans = max(ans, dp1[i][j] + dp2[n - i - 1][t - j - 1] + ab[i][1])

    print(ans)

if __name__ == '__main__':

    main()

# optimized version of the same code:

#coding:utf-8

import bisect

import sys

sys.setrecursionlimit(10**6)

write = sys.stdout.write

dbg = lambda *something : print(*something) if DEBUG else 0

DEBUG = True

def main(given = sys.stdin.readline):

    input = lambda : given().rstrip()

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

    II = lambda : int(input())

    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    n, t = LMIIS()

    ab = XLMIIS(n)

    ab.sort()

    dp1 = [[0]*t for _ in range(n+1)]

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

        for j in range(1, t):

            if j < ab[i-1][0]:

                dp1[i][j] = dp1[i-1][j]

            else:

                dp1[i][j] = max(dp1[i-1][j], dp1[i-1][j-ab[i-1][0]] + ab[i-1][1])

    ans = 0

    for i in range(n):

        ans = max(ans, dp1[i][t-1] + ab[i][1])

    print(ans)

if __name__ == '__main__':

    main()

# coding:utf-8
import bisect
import sys

sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something: print(*something) if DEBUG else 0
DEBUG = True

def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int, input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    n, t = LMIIS()
    ab = XLMIIS(n)
    dp1 = [[0] * t for _ in range(n)]
    for i in range(1, n):
        for j in range(1, t):
            if j < ab[i - 1][0]:
                dp1[i][j] = dp1[i - 1][j]
            else:
                dp1[i][j] = max(
                    dp1[i - 1][j], dp1[i - 1][j - ab[i - 1][0]] + ab[i - 1][1]
                )
    dp2 = [[0] * t for _ in range(n)]
    for i in range(1, n):
        for j in range(1, t):
            if j < ab[n - i][0]:
                dp2[i][j] = dp2[i - 1][j]
            else:
                dp2[i][j] = max(
                    dp2[i - 1][j], dp2[i - 1][j - ab[n - i][0]] + ab[n - i][1]
                )
    ans = 0
    for i in range(n):
        for j in range(t - 1):
            ans = max(ans, dp1[i][j] + dp2[n - i - 1][t - j - 1] + ab[i][1])
    print(ans)

if __name__ == "__main__":
    main()

# coding:utf-8
import bisect
import sys

sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something: print(*something) if DEBUG else 0
DEBUG = True

def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int, input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    n, t = LMIIS()
    ab = XLMIIS(n)
    ab.sort()
    dp1 = [[0] * t for _ in range(n + 1)]
    for i in range(1, n + 1):
        for j in range(1, t):
            if j < ab[i - 1][0]:
                dp1[i][j] = dp1[i - 1][j]
            else:
                dp1[i][j] = max(
                    dp1[i - 1][j], dp1[i - 1][j - ab[i - 1][0]] + ab[i - 1][1]
                )
    ans = 0
    for i in range(n):
        ans = max(ans, dp1[i][t - 1] + ab[i][1])
    print(ans)

if __name__ == "__main__":
    main()

+    dp1 = [[0] * t for _ in range(n + 1)]


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

import sys

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

S = eval(input())

def nexti(n):

    while S[n] == '1':

        n += 1

    while S[n] == '0':

        n += 1

    return n

def nextj(n):

    while S[n] == '0':

        n += 1

        if n == N:

            return N

    while S[n] == '1':

        n += 1

        if n == N:

            return N

    return n

i = 0

j = 0

while S[j] == '1':

    j += 1

    if j == N:

        print(N)

        sys.exit(0)

for _ in range(K):

    j = nextj(j)

    if j == N:

        print(N)

        sys.exit(0)

ans = j - i

while True:

    i = nexti(i)

    j = nextj(j)

    ans = max(ans, j - i)

    if j == N:

        break

print(ans)

# optimized version of the same code:

from collections import deque

def nextj(n):

    while S[n] == '0':

        n += 1

        if n == N:

            return N

    q.appendleft(n)

    while S[n] == '1':

        n += 1

        if n == N:

            return N

    return n

def init(n):

    while S[n] == '1':

        n += 1

        if n == N:

            return N

    return n

def calc():

    q.appendleft(0)

    ans = 0

    j = init(0)

    if j == N:

        return N

    for _ in range(K - 1):

        j = nextj(j)

        if j == N:

            return N

    while True:

        j = nextj(j)

        ans = max(ans, j - q.pop())

        if j == N:

            return ans

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

S = eval(input())

q = deque()

print((calc()))

import sys

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

def nexti(n):
    while S[n] == "1":
        n += 1
    while S[n] == "0":
        n += 1
    return n

def nextj(n):
    while S[n] == "0":
        n += 1
        if n == N:
            return N
    while S[n] == "1":
        n += 1
        if n == N:
            return N
    return n

i = 0
j = 0
while S[j] == "1":
    j += 1
    if j == N:
        print(N)
        sys.exit(0)
for _ in range(K):
    j = nextj(j)
    if j == N:
        print(N)
        sys.exit(0)
ans = j - i
while True:
    i = nexti(i)
    j = nextj(j)
    ans = max(ans, j - i)
    if j == N:
        break
print(ans)

from collections import deque

def nextj(n):
    while S[n] == "0":
        n += 1
        if n == N:
            return N
    q.appendleft(n)
    while S[n] == "1":
        n += 1
        if n == N:
            return N
    return n

def init(n):
    while S[n] == "1":
        n += 1
        if n == N:
            return N
    return n

def calc():
    q.appendleft(0)
    ans = 0
    j = init(0)
    if j == N:
        return N
    for _ in range(K - 1):
        j = nextj(j)
        if j == N:
            return N
    while True:
        j = nextj(j)
        ans = max(ans, j - q.pop())
        if j == N:
            return ans

N, K = list(map(int, input().split()))
S = eval(input())
q = deque()
print((calc()))

-import sys
-N, K = list(map(int, input().split()))
-S = eval(input())
-def nexti(n):
-    while S[n] == "1":
-        n += 1
-    while S[n] == "0":
-        n += 1
-    return n
+from collections import deque
+    q.appendleft(n)
-i = 0
-j = 0
-while S[j] == "1":
-    j += 1
+def init(n):
+    while S[n] == "1":
+        n += 1
+        if n == N:
+            return N
+    return n
+
+
+def calc():
+    q.appendleft(0)
+    ans = 0
+    j = init(0)
-        print(N)
-        sys.exit(0)
-for _ in range(K):
-    j = nextj(j)
-    if j == N:
-        print(N)
-        sys.exit(0)
-ans = j - i
-while True:
-    i = nexti(i)
-    j = nextj(j)
-    ans = max(ans, j - i)
-    if j == N:
-        break
-print(ans)
+        return N
+    for _ in range(K - 1):
+        j = nextj(j)
+        if j == N:
+            return N
+    while True:
+        j = nextj(j)
+        ans = max(ans, j - q.pop())
+        if j == N:
+            return ans
+
+
+N, K = list(map(int, input().split()))
+S = eval(input())
+q = deque()
+print((calc()))


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 -*-

"""

Created on Sat May 25 21:24:29 2019

@author: Yamazaki Kenichi

"""

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

mod = 10**9+7

def cmb(n, r, mod):

    if (r < 0 or r > n):

        return 0

    r = min(r, n-r)

    return g1[n] * g2[r] * g2[n-r] % mod

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

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

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

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

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

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

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

def a(N,M):

    return N*(N+1)//2*(M+1) + M*(M+1)//2*(N+1)

def b(N):

    return N*(N+1)//2

ans = 0

for i in range(N):

    for j in range(M):

        ans += a(i,j) + a(N-i-1,j) + a(i,M-j-1) + a(N-i-1,M-j-1)

        ans -= b(i) + b(j) + b(N-i-1) + b(M-j-1)

        ans %= mod

#        print(i,j,a(i,j),a(N-i-1,j),a(i,M-j-1),a(N-i-1,M-j-1),b(i),b(j),ans)

ans *= g2[2]

ans *= cmb(N*M-2,K-2,mod)

ans %= mod

print(ans)

# optimized version of the same code:

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

"""

Created on Wed May 29 22:49:19 2019

@author: Yamazaki Kenichi

"""

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

"""

Created on Sat May 25 21:24:29 2019

@author: Yamazaki Kenichi

"""

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

mod = 10**9+7

def cmb(n, r, mod):

    if (r < 0 or r > n):

        return 0

    r = min(r, n-r)

    return g1[n] * g2[r] * g2[n-r] % mod

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

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

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

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

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

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

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

ans1 = 0

def c(N,M):

    res = 0

    for i in range(1,N):

        res += i*(N-i)*M*M

    return res

ans1 += c(N,M) + c(M,N)

ans1 %= mod

ans1 *= cmb(N*M-2,K-2,mod)

ans1 %= mod

print(ans1)

# -*- coding: utf-8 -*-
"""
Created on Sat May 25 21:24:29 2019
@author: Yamazaki Kenichi
"""
N, M, K = list(map(int, input().split()))
mod = 10**9 + 7

def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inv = [0, 1]  # 逆元テーブル計算用テーブル
for i in range(2, N * M + 1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)

def a(N, M):
    return N * (N + 1) // 2 * (M + 1) + M * (M + 1) // 2 * (N + 1)

def b(N):
    return N * (N + 1) // 2

ans = 0
for i in range(N):
    for j in range(M):
        ans += a(i, j) + a(N - i - 1, j) + a(i, M - j - 1) + a(N - i - 1, M - j - 1)
        ans -= b(i) + b(j) + b(N - i - 1) + b(M - j - 1)
        ans %= mod
#        print(i,j,a(i,j),a(N-i-1,j),a(i,M-j-1),a(N-i-1,M-j-1),b(i),b(j),ans)
ans *= g2[2]
ans *= cmb(N * M - 2, K - 2, mod)
ans %= mod
print(ans)

# -*- coding: utf-8 -*-
"""
Created on Wed May 29 22:49:19 2019
@author: Yamazaki Kenichi
"""
# -*- coding: utf-8 -*-
"""
Created on Sat May 25 21:24:29 2019
@author: Yamazaki Kenichi
"""
N, M, K = list(map(int, input().split()))
mod = 10**9 + 7

def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inv = [0, 1]  # 逆元テーブル計算用テーブル
for i in range(2, N * M + 1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)
ans1 = 0

def c(N, M):
    res = 0
    for i in range(1, N):
        res += i * (N - i) * M * M
    return res

ans1 += c(N, M) + c(M, N)
ans1 %= mod
ans1 *= cmb(N * M - 2, K - 2, mod)
ans1 %= mod
print(ans1)


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

S = list(eval(input()) for i in range(N))

str = ""

for i in range(N-1):

    for j in range(N-1):

        if S[j+1] + S[j] <= S[j] + S[j+1]:

            S[j], S[j+1] = S[j+1], S[j]

for i in S:

    str += i

print(str)

# optimized version of the same code:

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

S = list(eval(input()) for i in range(N))

S.sort()

str = ""

for i in S:

    str += i

print(str)

N, L = list(map(int, input().split()))
S = list(eval(input()) for i in range(N))
str = ""
for i in range(N - 1):
    for j in range(N - 1):
        if S[j + 1] + S[j] <= S[j] + S[j + 1]:
            S[j], S[j + 1] = S[j + 1], S[j]
for i in S:
    str += i
print(str)


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

mod = 10**9 + 7

# dp[i]: 最後に切った場所がi

dp = [0]*(s + 1)

dp[0] = 1

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

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

        dp[i] += dp[j]

        dp[i] %= mod

print((dp[s]))

# optimized version of the same code:

s = int(eval(input()))

mod = 10**9 + 7

# dp[i]: 最後に切った場所がi

dp = [0]*(s + 1)

dp[0] = 1

total = 0

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

    total += dp[i-3]

    total %= mod

    dp[i] = total

print((dp[s]))

s = int(eval(input()))
mod = 10**9 + 7
# dp[i]: 最後に切った場所がi
dp = [0] * (s + 1)
dp[0] = 1
for i in range(3, s + 1):
    for j in range(0, (i - 3) + 1):
        dp[i] += dp[j]
        dp[i] %= mod
print((dp[s]))

s = int(eval(input()))
mod = 10**9 + 7
# dp[i]: 最後に切った場所がi
dp = [0] * (s + 1)
dp[0] = 1
total = 0
for i in range(3, s + 1):
    total += dp[i - 3]
    total %= mod
    dp[i] = total
print((dp[s]))

+total = 0
-    for j in range(0, (i - 3) + 1):
-        dp[i] += dp[j]
-        dp[i] %= mod
+    total += dp[i - 3]
+    total %= mod
+    dp[i] = total


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:

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

	if k[0]==k[1]==0:

		break

	ct=0

	a=0

	b=0

	c=0

	max=k[0]

	sum=k[1]

	a=max+1

	while True:

		a-=1

		b=a-1

		c=sum-a-b

		if not a>b>c:

			print(ct)

			break

		while a>b>c:

			if a>b>c>0:

				ct+=1

			b-=1

			c+=1

# optimized version of the same code:

while True:

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

	if k[0]==k[1]==0:

		break

	ct=0

	a=0

	b=0

	c=0

	max=k[0]

	sum=k[1]

	a=max+1

	while True:

		a-=1

		b=a-1

		c=sum-a-b

		if not a>c:

			print(ct)

			break

		while b>c:

			if c>0:

				ct+=1

			b-=1

			c+=1

while True:
    k = list(map(int, input().split(" ")))
    if k[0] == k[1] == 0:
        break
    ct = 0
    a = 0
    b = 0
    c = 0
    max = k[0]
    sum = k[1]
    a = max + 1
    while True:
        a -= 1
        b = a - 1
        c = sum - a - b
        if not a > b > c:
            print(ct)
            break
        while a > b > c:
            if a > b > c > 0:
                ct += 1
            b -= 1
            c += 1

while True:
    k = list(map(int, input().split(" ")))
    if k[0] == k[1] == 0:
        break
    ct = 0
    a = 0
    b = 0
    c = 0
    max = k[0]
    sum = k[1]
    a = max + 1
    while True:
        a -= 1
        b = a - 1
        c = sum - a - b
        if not a > c:
            print(ct)
            break
        while b > c:
            if c > 0:
                ct += 1
            b -= 1
            c += 1

-        if not a > b > c:
+        if not a > c:
-        while a > b > c:
-            if a > b > c > 0:
+        while b > c:
+            if c > 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:

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

S = [eval(input()) for i in range(n)]

S.sort()

print(("".join(S)))

# optimized version of the same code:

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

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

A.sort()

print(("".join(A)))


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

N = int(eval(input()))

if N < 2:

  print(N)

elif 2<=N<4:

  print((2))

elif 4<=N<8:

  print((4))

elif 8<=N<16:

  print((8))

elif 16<=N<32:

  print((16))

elif 32<=N<64:

  print((32))

elif 64<=N:

  print((64))

# optimized version of the same code:

N = int(eval(input()))

Num = [int(2**i) for i in range(7)]

if N in Num:

  print(N)

else:

  Num.append(N)

  Num = sorted(Num)

  print((2 ** (Num.index(N) - 1)))

-if N < 2:
+Num = [int(2**i) for i in range(7)]
+if N in Num:
-elif 2 <= N < 4:
-    print((2))
-elif 4 <= N < 8:
-    print((4))
-elif 8 <= N < 16:
-    print((8))
-elif 16 <= N < 32:
-    print((16))
-elif 32 <= N < 64:
-    print((32))
-elif 64 <= N:
-    print((64))
+else:
+    Num.append(N)
+    Num = sorted(Num)
+    print((2 ** (Num.index(N) - 1)))


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

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

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

left = 1

right = N

for l, r in LR:

    if left < l:

        left = l

    if right > r:

        right = r

ans = right - left

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

# optimized version of the same code:

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

left = 1

right = N

for _ in range(M):

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

    if left < l:

        left = l

    if right > r:

        right = r

ans = right - left

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

-LR = [list(map(int, input().split())) for _ in range(M)]

+    l, r = 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 = eval(input())

t = eval(input())

for i in range(len(s)):

        if s[i:]+s[:i]==t:

                print('Yes')

                exit()

print('No')

# optimized version of the same code:

s = eval(input())

t = eval(input())

for i in range(len(s)):

    s = s[1:] + s[0]

    if s == t:

        print("Yes")

        exit()

print("No")

s = eval(input())
t = eval(input())
for i in range(len(s)):
    if s[i:] + s[:i] == t:
        print("Yes")
        exit()
print("No")


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

import numpy as np

N=int(eval(input()))

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

AA=[]

for i,a in enumerate(A):

    AA.append(a-i+1)

b=np.median(AA)

ans=0

for a in AA:

    ans+=abs(a-b)

print((int(ans)))

# optimized version of the same code:

N=int(eval(input()))

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

B=[]

for i in range(N):

    B.append(A[i]-i-1)

B.sort()

if N%2:

    b=B[N//2]

else:

    b=(B[N//2]+B[N//2-1])//2

ans=0

for k in B:

    ans+=abs(k-b)

print(ans)

import numpy as np

N = int(eval(input()))
A = list(map(int, input().split()))
AA = []
for i, a in enumerate(A):
    AA.append(a - i + 1)
b = np.median(AA)
ans = 0
for a in AA:
    ans += abs(a - b)
print((int(ans)))

N = int(eval(input()))
A = list(map(int, input().split()))
B = []
for i in range(N):
    B.append(A[i] - i - 1)
B.sort()
if N % 2:
    b = B[N // 2]
else:
    b = (B[N // 2] + B[N // 2 - 1]) // 2
ans = 0
for k in B:
    ans += abs(k - b)
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:

n = int(eval(input()))

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

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

result = 0

for i in range(n):

  if v[i] > c[i]:

    result += v[i] - c[i]

print(result)

# optimized version of the same code:

N = int(eval(input()))

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

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

print((sum([V[i] - C[i] for i in range(N) if V[i] > C[i]])))

+print((sum([V[i] - C[i] for i in range(N) if V[i] > C[i]])))


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

import numpy as np

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

a = np.array(a)

n = int(eval(input()))

for _ in range(n):

    b = int(eval(input()))

    for j in range(3):

        for i in range(3):

            if a[j][i] == b:

                a[j][i] = 0

at = a.transpose()

flag = False

for i in range(3):

    if sum(a[:][i]) == 0 or sum(at[:][i]) == 0:

        flag = True

        break

diag = a[0][0] + a[1][1] + a[2][2]

diag2 = a[2][0] + a[1][1] + a[0][2]

if diag == 0 or diag2 == 0:

    flag = True

print(("Yes" if flag else "No"))

# optimized version of the same code:

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

n = int(eval(input()))

b = [int(eval(input())) for _ in range(n)]

flag = False

for i in range(3):

    if a[i][0] in b and a[i][1] in b and a[i][2] in b:

        flag = True

        break

    if a[0][i] in b and a[1][i] in b and a[2][i] in b:

        flag = True

        break

if a[0][0] in b and a[1][1] in b and a[2][2] in b:

    flag = True

if a[2][0] in b and a[1][1] in b and a[0][2] in b:

    flag = True

print(("Yes" if flag else "No"))

+b = [int(eval(input())) for _ in range(n)]

+    if a[i][0] in b and a[i][1] in b and a[i][2] in b:

+    if a[0][i] in b and a[1][i] in b and a[2][i] in b:

+if a[0][0] in b and a[1][1] in b and a[2][2] in b:

+if a[2][0] in b and a[1][1] in b and a[0][2] in 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:

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

#１回押すと変わるマス　= N * M -1

#２回目押すと黒に変わるマス N * M -1 -2

# 3 = N * M -1 -4

cnt = 0

for i in range(n+1):

    for j in range(m + 1):

        cnt = i * m + j * n -2 * i * j

        if cnt == k:

            print("Yes")

            exit()

print("No")

# optimized version of the same code:

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

for i in range(n+1):

    for j in range(m+1):

        if i*(m-j) + j*(n-i) == k:

            print("Yes")

            exit()

print("No")

n, m, k = list(map(int, input().split()))
# １回押すと変わるマス　= N * M -1
# ２回目押すと黒に変わるマス N * M -1 -2
# 3 = N * M -1 -4
cnt = 0
for i in range(n + 1):
    for j in range(m + 1):
        cnt = i * m + j * n - 2 * i * j
        if cnt == k:
            print("Yes")
            exit()
print("No")

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

-# １回押すと変わるマス　= N * M -1

-# ２回目押すと黒に変わるマス N * M -1 -2

-        cnt = i * m + j * n - 2 * 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:

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

answer = 0

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

    j = str(i)

    p1 = j[4]

    p2 = j[3]

    p3 = j[2]

    p4 = j[1]

    p5 = j[0]

    k = int(p1+p2+p3+p4+p5)

    if i == k :

        answer += 1

print(answer)

# optimized version of the same code:

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

ans = 0

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

    l = str(i)

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

        ans += 1

print(ans)

a, b = list(map(int, input().split()))
answer = 0
for i in range(a, b + 1):
    j = str(i)
    p1 = j[4]
    p2 = j[3]
    p3 = j[2]
    p4 = j[1]
    p5 = j[0]
    k = int(p1 + p2 + p3 + p4 + p5)
    if i == k:
        answer += 1
print(answer)

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

-a, b = list(map(int, input().split()))
-answer = 0
-for i in range(a, b + 1):
-    j = str(i)
-    p1 = j[4]
-    p2 = j[3]
-    p3 = j[2]
-    p4 = j[1]
-    p5 = j[0]
-    k = int(p1 + p2 + p3 + p4 + p5)
-    if i == k:
-        answer += 1
-print(answer)
+A, B = list(map(int, input().split()))
+ans = 0
+for i in range(A, B + 1):
+    l = str(i)
+    if l[0] == l[4] and l[1] == l[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:

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

dic={}

for i in range(N):

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

  if a in dic:

    dic[a]+=b

  else:

    dic[a]=b

dic=sorted(list(dic.items()),key=lambda x:x[0])

for d in range(len(dic)):

  amount=dic[d][1]

  if amount>=K:

    print((dic[d][0]))

    exit(0)

  else:

    K-=amount

# optimized version of the same code:

import sys

readline = sys.stdin.readline

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

AB = [list(map(int,readline().split())) for i in range(N)]

AB = sorted(AB, key = lambda x:x[0])

amount = 0

for a,b in AB:

  amount += b

  if amount >= K:

    print(a)

    break

N, K = list(map(int, input().split()))
dic = {}
for i in range(N):
    a, b = list(map(int, input().split()))
    if a in dic:
        dic[a] += b
    else:
        dic[a] = b
dic = sorted(list(dic.items()), key=lambda x: x[0])
for d in range(len(dic)):
    amount = dic[d][1]
    if amount >= K:
        print((dic[d][0]))
        exit(0)
    else:
        K -= amount

import sys

readline = sys.stdin.readline
N, K = list(map(int, readline().split()))
AB = [list(map(int, readline().split())) for i in range(N)]
AB = sorted(AB, key=lambda x: x[0])
amount = 0
for a, b in AB:
    amount += b
    if amount >= K:
        print(a)
        break

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

-dic = sorted(list(dic.items()), key=lambda x: x[0])

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

+AB = [list(map(int, readline().split())) for i in range(N)]


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b

# Python 1st Try

import copy

class Problem:

    def __init__(self, stringdata):

        self.stringdata = stringdata

    def solver(self):

        strcont = copy.copy(self.stringdata)

        result = 0

        rightposition = 0

        leftposition = len(strcont)

        j = 0

        while True:

            if strcont[j] == 'A':

                rightposition = j

                break

            else:

                j = j + 1

        j = leftposition - 1

        while True:

            if strcont[j] == 'Z':

                leftposition = j

                break

            else:

                j = j - 1

        result = leftposition - rightposition + 1

        return result

if __name__ == "__main__":

    s = eval(input())

    print(("{}".format(Problem(s).solver())))

# optimized version of the same code:

# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b

# Python 2nd Try

def solver(string):

    result = 200000

    aposi = 0

    zposi = len(string)

    for j in range(0, len(string), 1):

        if string[j] == 'A':

            aposi = j

            break

    for j in range(len(string)-1, -1, -1):

        if string[j] == 'Z':

            zposi = j

            break

    result = zposi - aposi + 1

    return result

if __name__ == "__main__":

    s = eval(input())

    print(('{}'.format(solver(s))))

# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b
# Python 1st Try
import copy

class Problem:
    def __init__(self, stringdata):
        self.stringdata = stringdata

    def solver(self):
        strcont = copy.copy(self.stringdata)
        result = 0
        rightposition = 0
        leftposition = len(strcont)
        j = 0
        while True:
            if strcont[j] == "A":
                rightposition = j
                break
            else:
                j = j + 1
        j = leftposition - 1
        while True:
            if strcont[j] == "Z":
                leftposition = j
                break
            else:
                j = j - 1
        result = leftposition - rightposition + 1
        return result

if __name__ == "__main__":
    s = eval(input())
    print(("{}".format(Problem(s).solver())))

# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b
# Python 2nd Try
def solver(string):
    result = 200000
    aposi = 0
    zposi = len(string)
    for j in range(0, len(string), 1):
        if string[j] == "A":
            aposi = j
            break
    for j in range(len(string) - 1, -1, -1):
        if string[j] == "Z":
            zposi = j
            break
    result = zposi - aposi + 1
    return result

if __name__ == "__main__":
    s = eval(input())
    print(("{}".format(solver(s))))

-        strcont = copy.copy(self.stringdata)

-        result = leftposition - rightposition + 1

+    for j in range(len(string) - 1, -1, -1):

-    print(("{}".format(Problem(s).solver())))


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

A=0

B=0

for a in range(-120,120):

    for b in range(-500,500):

        if a**5-b**5==x:

            A=a

            B=b

            break

print((A,B))

# optimized version of the same code:

x=int(eval(input()))

A=0

B=0

for a in range(-120, 120):

    a5 = a**5

    for b in range(-120, 120):

        if a5 - b**5 == x:

            A = a

            B = b

            break

print((A,B))

x = int(eval(input()))
A = 0
B = 0
for a in range(-120, 120):
    for b in range(-500, 500):
        if a**5 - b**5 == x:
            A = a
            B = b
            break
print((A, B))

x = int(eval(input()))
A = 0
B = 0
for a in range(-120, 120):
    a5 = a**5
    for b in range(-120, 120):
        if a5 - b**5 == x:
            A = a
            B = b
            break
print((A, 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:

def judge(x,y):

    global xx,yy,xy,axby

    if min(x,y) >= 0 and x+y <= xy:

        if x+y < xy or (x+y == xy and a*x+b*y < axby):

            xy = x+y

            axby = a*x+b*y

            xx,yy = x,y

while 1:

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

    if a == 0: break

    xy = axby = 10**10

    for y in range(50001):

        if (d+b*y)%a == 0: judge((d+b*y)/a,y)

        if (b*y-d)%a == 0: judge((b*y-d)/a,y)

        if (d-b*y)%a == 0: judge((d-b*y)/a,y)

    print(xx,yy)

# optimized version of the same code:

def judge(x,y):

    global xx,yy,xy,axby

    if min(x,y) >= 0 and x+y <= xy:

        if x+y < xy or (x+y == xy and a*x+b*y < axby):

            xy = x+y

            axby = a*x+b*y

            xx,yy = x,y

while 1:

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

    if a == 0: break

    xy = axby = 10**10

    for y in range(30001):

        if (d+b*y)%a == 0: judge((d+b*y)/a,y)

        if (b*y-d)%a == 0: judge((b*y-d)/a,y)

        if (d-b*y)%a == 0: judge((d-b*y)/a,y)

    print(xx,yy)

def judge(x, y):
    global xx, yy, xy, axby
    if min(x, y) >= 0 and x + y <= xy:
        if x + y < xy or (x + y == xy and a * x + b * y < axby):
            xy = x + y
            axby = a * x + b * y
            xx, yy = x, y

while 1:
    a, b, d = list(map(int, input().split()))
    if a == 0:
        break
    xy = axby = 10**10
    for y in range(50001):
        if (d + b * y) % a == 0:
            judge((d + b * y) / a, y)
        if (b * y - d) % a == 0:
            judge((b * y - d) / a, y)
        if (d - b * y) % a == 0:
            judge((d - b * y) / a, y)
    print(xx, yy)

def judge(x, y):
    global xx, yy, xy, axby
    if min(x, y) >= 0 and x + y <= xy:
        if x + y < xy or (x + y == xy and a * x + b * y < axby):
            xy = x + y
            axby = a * x + b * y
            xx, yy = x, y

while 1:
    a, b, d = list(map(int, input().split()))
    if a == 0:
        break
    xy = axby = 10**10
    for y in range(30001):
        if (d + b * y) % a == 0:
            judge((d + b * y) / a, y)
        if (b * y - d) % a == 0:
            judge((b * y - d) / a, y)
        if (d - b * y) % a == 0:
            judge((d - b * y) / a, y)
    print(xx, yy)

-    for y in range(50001):
+    for y in range(30001):


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 numpy as np

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

a = []

cnt = 0

for x in range(n):

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

for i in range(len(a)):

    for j in range(len(a)):

        if i < j:

            dis = np.array(a[i]) - np.array(a[j])

            if np.linalg.norm(dis).is_integer():

                cnt += 1

print(cnt)

# optimized version of the same code:

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

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

ans = 0

def dis(x,y):

    T = []

    for i in range(len(x)):

        T.append((x[i]-y[i])**2)

    return sum(T)

for i in range(n):

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

        r = dis(a[i], a[j])

        for k in range(r + 1):

            if k ** 2 == r:

                ans += 1

print(ans)

n, d = list(map(int, input().split()))
a = [[int(i) for i in input().split()] for i in range(n)]
ans = 0

def dis(x, y):
    T = []
    for i in range(len(x)):
        T.append((x[i] - y[i]) ** 2)
    return sum(T)

for i in range(n):
    for j in range(i + 1, n):
        r = dis(a[i], a[j])
        for k in range(r + 1):
            if k**2 == r:
                ans += 1
print(ans)

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

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

-            dis = np.array(a[i]) - np.array(a[j])

-            if np.linalg.norm(dis).is_integer():


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 itertools import accumulate

from bisect import *

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

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

acc = sorted(list(accumulate(L)) + [0])

n = bisect_right(acc,X)

print(n)

# optimized version of the same code:

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

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

List = [0]*(N+1)

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

    List[i] = List[i-1] + L[i-1]

A = [i for i in List if i <=X]

print((len(A)))

from itertools import accumulate
from bisect import *

N, X = list(map(int, input().split()))
L = list(tuple(map(int, input().split())))
acc = sorted(list(accumulate(L)) + [0])
n = bisect_right(acc, X)
print(n)

N, X = list(map(int, input().split()))
L = list(map(int, input().split()))
List = [0] * (N + 1)
for i in range(1, N + 1):
    List[i] = List[i - 1] + L[i - 1]
A = [i for i in List if i <= X]
print((len(A)))

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

-acc = sorted(list(accumulate(L)) + [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:

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

cnt = 0

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

    n_s = str(n)

    n_s_rvs = n_s[::-1]

    if n_s == n_s_rvs:

        cnt += 1

print(cnt)

# optimized version of the same code:

A, B = list(map(int, input().split()))
cnt = 0
for n in range(A, B + 1):
    n_s = str(n)
    n_s_rvs = n_s[::-1]
    if n_s == n_s_rvs:
        cnt += 1
print(cnt)


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 numpy import*

N,*A=open(0)

N,A,S,a=int(N),loadtxt(A,int),1,0

while S:B=A//N;S=sum(B);a+=S;A+=S-B*-~N

print(a)

# optimized version of the same code:

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

ans = 0

S = -1

while S:

    S = sum(a // N for a in A)

    ans += S

    A = [a % N + (S - a // N) for a in A]

print(ans)

from numpy import *

N, *A = open(0)
N, A, S, a = int(N), loadtxt(A, int), 1, 0
while S:
    B = A // N
    S = sum(B)
    a += S
    A += S - B * -~N
print(a)

-N, A, S, a = int(N), loadtxt(A, int), 1, 0

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

+    A = [a % N + (S - a // N) for a in 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:

import numpy as np

S=eval(input())

N=len(S)

mod=[0 for i in range(2019)]

mod2=0

ten=1

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

  s=int(S[i])*ten

  mod2+=np.mod(s,2019)

  mod2=np.mod(mod2,2019)

  mod[mod2]+=1

  ten=(ten*10)%2019

ans=0

for i in range(2019):

  k=mod[i]

  if i==0:

    if k>=2:

      ans+=k*(k-1)//2+k

    else:

      ans+=k

  else:

    if k>=2:

      ans+=k*(k-1)//2

print(ans)

# optimized version of the same code:

S=eval(input())

N=len(S)

mod=[0 for i in range(2019)]

s=0

ten=1

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

  s+=int(S[i])*ten

  mod2=s%2019

  mod[mod2]+=1

  ten=(ten*10)%2019

ans=0

for i in range(2019):

  k=mod[i]

  if i==0:

    if k>=2:

      ans+=k*(k-1)//2+k

    else:

      ans+=k

  else:

    if k>=2:

      ans+=k*(k-1)//2

print(ans)

import numpy as np

S = eval(input())
N = len(S)
mod = [0 for i in range(2019)]
mod2 = 0
ten = 1
for i in range(N - 1, -1, -1):
    s = int(S[i]) * ten
    mod2 += np.mod(s, 2019)
    mod2 = np.mod(mod2, 2019)
    mod[mod2] += 1
    ten = (ten * 10) % 2019
ans = 0
for i in range(2019):
    k = mod[i]
    if i == 0:
        if k >= 2:
            ans += k * (k - 1) // 2 + k
        else:
            ans += k
    else:
        if k >= 2:
            ans += k * (k - 1) // 2
print(ans)

S = eval(input())
N = len(S)
mod = [0 for i in range(2019)]
s = 0
ten = 1
for i in range(N - 1, -1, -1):
    s += int(S[i]) * ten
    mod2 = s % 2019
    mod[mod2] += 1
    ten = (ten * 10) % 2019
ans = 0
for i in range(2019):
    k = mod[i]
    if i == 0:
        if k >= 2:
            ans += k * (k - 1) // 2 + k
        else:
            ans += k
    else:
        if k >= 2:
            ans += k * (k - 1) // 2
print(ans)

-import numpy as np
-mod2 = 0
+s = 0
-    s = int(S[i]) * ten
-    mod2 += np.mod(s, 2019)
-    mod2 = np.mod(mod2, 2019)
+    s += int(S[i]) * ten
+    mod2 = s % 2019


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:

#!/usr/bin/env python3

def main():

    import numpy as np

    N = int(eval(input()))

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

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

    dp[0] = happiness[0]

    for i in range(1, N):

        for a, yesterday in enumerate(dp[i - 1]):

            for b, today in enumerate(happiness[i]):

                if a == b:

                    continue

                dp[i][b] = max(dp[i][b], yesterday + today)

    print((max(dp[-1])))

if __name__ == '__main__':

    main()

# optimized version of the same code:

#!/usr/bin/env python3

def main():

    N = int(eval(input()))

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

    dp = [0, 0, 0]

    for a, b, c in happiness:

        dp = [max(dp[1], dp[2]) + a,

              max(dp[0], dp[2]) + b,

              max(dp[0], dp[1]) + c]

    print((max(dp)))

if __name__ == '__main__':

    main()

#!/usr/bin/env python3
def main():
    import numpy as np

    N = int(eval(input()))
    happiness = [list(map(int, input().split())) for _ in range(N)]
    dp = np.zeros((N, 3), dtype=np.int64)
    dp[0] = happiness[0]
    for i in range(1, N):
        for a, yesterday in enumerate(dp[i - 1]):
            for b, today in enumerate(happiness[i]):
                if a == b:
                    continue
                dp[i][b] = max(dp[i][b], yesterday + today)
    print((max(dp[-1])))

if __name__ == "__main__":
    main()

#!/usr/bin/env python3
def main():
    N = int(eval(input()))
    happiness = [list(map(int, input().split())) for _ in range(N)]
    dp = [0, 0, 0]
    for a, b, c in happiness:
        dp = [max(dp[1], dp[2]) + a, max(dp[0], dp[2]) + b, max(dp[0], dp[1]) + c]
    print((max(dp)))

if __name__ == "__main__":
    main()

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

-        for a, yesterday in enumerate(dp[i - 1]):

-            for b, today in enumerate(happiness[i]):

-                dp[i][b] = max(dp[i][b], yesterday + today)


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

queue = []

for i in range(n):

	name,time = input().split()

	queue.append([name, int(time)])

t = 0

i = 0

while queue:

	i %= len(queue)

	p = queue[i]

	t += min(q, p[1])

	if p[1] > q:

		p[1] -= q

		i += 1

	else:

		print((p[0], t))

		queue.pop(i)

# optimized version of the same code:

from collections import deque

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

queue = deque()

for i in range(n):

	name,time = input().split()

	queue.append((name, int(time)))

t = 0

while queue:

	name,time = queue.popleft()

	t += min(q, time)

	if time > q:

		queue.append((name, time-q))

	else:

		print((name,t))

n, q = list(map(int, input().split()))
queue = []
for i in range(n):
    name, time = input().split()
    queue.append([name, int(time)])
t = 0
i = 0
while queue:
    i %= len(queue)
    p = queue[i]
    t += min(q, p[1])
    if p[1] > q:
        p[1] -= q
        i += 1
    else:
        print((p[0], t))
        queue.pop(i)

from collections import deque

n, q = list(map(int, input().split()))
queue = deque()
for i in range(n):
    name, time = input().split()
    queue.append((name, int(time)))
t = 0
while queue:
    name, time = queue.popleft()
    t += min(q, time)
    if time > q:
        queue.append((name, time - q))
    else:
        print((name, t))

+from collections import deque
+
-queue = []
+queue = deque()
-    queue.append([name, int(time)])
+    queue.append((name, int(time)))
-i = 0
-    i %= len(queue)
-    p = queue[i]
-    t += min(q, p[1])
-    if p[1] > q:
-        p[1] -= q
-        i += 1
+    name, time = queue.popleft()
+    t += min(q, time)
+    if time > q:
+        queue.append((name, time - q))
-        print((p[0], t))
-        queue.pop(i)
+        print((name, t))


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)%(10**9+7)))

# optimized version of the same code:

N=int(eval(input()))

power=1

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

    power*=i

    power%=10**9+7

print(power)

import math

N = int(eval(input()))
print((math.factorial(N) % (10**9 + 7)))

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

-print((math.factorial(N) % (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:

# ABC95 C -Half and Half

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

ans = 0

if a+b > 2*c:

    while x != 0.0 and y != 0.0:

        ans += 2*c

        x -= 1.0

        y -= 1.0

        if y == 0.0:

            while x != 0.0:

                if a > 2*c:

                    ans += 2*c

                    x -= 1.0

                else:

                    ans += a

                    x -= 1.0

        if x == 0.0:

            while y != 0.0:

                if b > 2*c:

                    ans += 2*c

                    y -= 1.0

                else:

                    ans += b

                    y -= 1.0

else:

    ans += a*x + b*y

print((int(ans)))

# optimized version of the same code:

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

ans=0

ans1=0

e=max(x,y)

ans1=e*(2*c)

if 2*c<a+b:

    d=min(x,y)

    ans+=c*(2*d)

    x-=d

    y-=d

else:

    ans=a*x+b*y

    x-=x

    y-=y

ans+=x*a

ans+=y*b

print((min(ans,ans1)))

# ABC95 C -Half and Half
a, b, c, x, y = list(map(float, input().split()))
ans = 0
if a + b > 2 * c:
    while x != 0.0 and y != 0.0:
        ans += 2 * c
        x -= 1.0
        y -= 1.0
        if y == 0.0:
            while x != 0.0:
                if a > 2 * c:
                    ans += 2 * c
                    x -= 1.0
                else:
                    ans += a
                    x -= 1.0
        if x == 0.0:
            while y != 0.0:
                if b > 2 * c:
                    ans += 2 * c
                    y -= 1.0
                else:
                    ans += b
                    y -= 1.0
else:
    ans += a * x + b * y
print((int(ans)))

a, b, c, x, y = list(map(int, input().split()))
ans = 0
ans1 = 0
e = max(x, y)
ans1 = e * (2 * c)
if 2 * c < a + b:
    d = min(x, y)
    ans += c * (2 * d)
    x -= d
    y -= d
else:
    ans = a * x + b * y
    x -= x
    y -= y
ans += x * a
ans += y * b
print((min(ans, ans1)))

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

+a, b, c, x, y = 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:

import sys

import numpy as np

h,w = [int(x) for x in sys.stdin.readline().split()]

n = int(eval(input()))

a = [int(x) for x in sys.stdin.readline().split()]

s = h*w

l = []

for i,x in enumerate(a):

	for j in range(x):

		l.append(i+1)

l = np.array(l).reshape((h,w))

for i,x in enumerate(l):

	if i % 2 == 0:

		print((' '.join(map(str, x))))

	else:

		print((' '.join(map(str, reversed(x)))))

# optimized version of the same code:

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

n = int(eval(input()))

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

l = []

for i,x in enumerate(a):

	for j in range(x):

		l.append(i+1)

for i in range(h):

	t = l[i*w:(i+1)*w]

	if i % 2 == 1:

		t.reverse()

	print((' '.join(map(str, t))))

import sys
import numpy as np

h, w = [int(x) for x in sys.stdin.readline().split()]
n = int(eval(input()))
a = [int(x) for x in sys.stdin.readline().split()]
s = h * w
l = []
for i, x in enumerate(a):
    for j in range(x):
        l.append(i + 1)
l = np.array(l).reshape((h, w))
for i, x in enumerate(l):
    if i % 2 == 0:
        print((" ".join(map(str, x))))
    else:
        print((" ".join(map(str, reversed(x)))))

h, w = list(map(int, input().split()))
n = int(eval(input()))
a = list(map(int, input().split()))
l = []
for i, x in enumerate(a):
    for j in range(x):
        l.append(i + 1)
for i in range(h):
    t = l[i * w : (i + 1) * w]
    if i % 2 == 1:
        t.reverse()
    print((" ".join(map(str, t))))

-h, w = [int(x) for x in sys.stdin.readline().split()]

-a = [int(x) for x in sys.stdin.readline().split()]

-        print((" ".join(map(str, reversed(x)))))


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 copy

import numpy as np

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

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

rev = copy.copy(v)

rev.reverse()

lcs = [0]+np.cumsum(v)

rcs = [0]+np.cumsum(rev)

# print(lcs,rcs)

ans = -10**20

for l in range(n+1):

  for r in range(n+1-l):

    able = True

    d = k - ( l + r )

    if d < 0:

      able = False

      break

    # m = lcs[l] + rcs[r]

    t = v[0:l] + rev[0:r]

    m = sum(t)

    # print(t,l,r,m)

    t.sort()

    # print(t)

    d = min(d,l+r)

    for i in range(d):

      if 0 > t[i]:

        m -= t[i]

      else:

        break

    # print(m)

    ans = max(ans,m)

print(ans)

# optimized version of the same code:

# coding: utf-8

import copy

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

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

rev = copy.copy(v)

rev.reverse()

ans = -10**20

for l in range(n+1):

  for r in range(n+1-l):

    able = True

    d = k - ( l + r )

    if d < 0:

      able = False

      break

    t = v[0:l] + rev[0:r]

    m = sum(t)

    t.sort()

    d = min(d,l+r)

    for i in range(d):

      if 0 > t[i]:

        m -= t[i]

      else:

        break

    ans = max(ans,m)

print(ans)

# coding: utf-8
import copy
import numpy as np

n, k = list(map(int, input().split()))
v = list(map(int, input().split()))
rev = copy.copy(v)
rev.reverse()
lcs = [0] + np.cumsum(v)
rcs = [0] + np.cumsum(rev)
# print(lcs,rcs)
ans = -(10**20)
for l in range(n + 1):
    for r in range(n + 1 - l):
        able = True
        d = k - (l + r)
        if d < 0:
            able = False
            break
        # m = lcs[l] + rcs[r]
        t = v[0:l] + rev[0:r]
        m = sum(t)
        # print(t,l,r,m)
        t.sort()
        # print(t)
        d = min(d, l + r)
        for i in range(d):
            if 0 > t[i]:
                m -= t[i]
            else:
                break
        # print(m)
        ans = max(ans, m)
print(ans)

# coding: utf-8
import copy

n, k = list(map(int, input().split()))
v = list(map(int, input().split()))
rev = copy.copy(v)
rev.reverse()
ans = -(10**20)
for l in range(n + 1):
    for r in range(n + 1 - l):
        able = True
        d = k - (l + r)
        if d < 0:
            able = False
            break
        t = v[0:l] + rev[0:r]
        m = sum(t)
        t.sort()
        d = min(d, l + r)
        for i in range(d):
            if 0 > t[i]:
                m -= t[i]
            else:
                break
        ans = max(ans, m)
print(ans)

-import numpy as np
-lcs = [0] + np.cumsum(v)
-rcs = [0] + np.cumsum(rev)
-# print(lcs,rcs)
-        # m = lcs[l] + rcs[r]
-        # print(t,l,r,m)
-        # print(t)
-        # print(m)


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

import numpy as np

N = int(eval(input()))

dp = [[0, 0, 0] for i in range(N+1)]

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

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

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

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

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

print((np.max(dp[-1])))

# optimized version of the same code:

import numpy as np

N = int(eval(input()))
dp = [[0, 0, 0] for i in range(N + 1)]
for i in range(1, N + 1):
    a, b, c = list(map(int, input().split(" ")))
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c
print((np.max(dp[-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, D = list(map(int, input().split()))

cnt = 0

for _ in range(N):

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

    if x ** 2 + y ** 2 <= D ** 2:

        cnt += 1

print(cnt)

# optimized version of the same code:

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

cnt = 0

for _ in range(N):

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

    if x * x + y * y <= D * D:

        cnt += 1

print(cnt)

N, D = list(map(int, input().split()))
cnt = 0
for _ in range(N):
    x, y = list(map(int, input().split()))
    if x**2 + y**2 <= D**2:
        cnt += 1
print(cnt)


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

readlines = sys.stdin.readlines

import numpy as np

def main():

    x = int(eval(input()))

    for i1 in range(-201, 201):

        for i2 in range(-201, 201):

            if i1**5 - i2**5 == x:

                print((i1, i2))

                sys.exit()

if __name__ == '__main__':

    main()

# optimized version of the same code:

import sys

read = sys.stdin.read

readlines = sys.stdin.readlines

import numpy as np

from itertools import product

def main():

    x = int(input())

    n5 = [i**5 for i in range(201)]

    c = product(n5, repeat=2)

    for ce in c:

        if ce[0] + ce[1] == x:

            r = (int(ce[0]**0.2), int(ce[1]**0.2)* -1)

            break

        elif ce[0] - ce[1] == x:

            r = (int(ce[0] ** 0.2), int(ce[1] ** 0.2))

            break

    print(*r, sep=' ')

if __name__ == '__main__':

    main()

import sys

read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np

def main():
    x = int(eval(input()))
    for i1 in range(-201, 201):
        for i2 in range(-201, 201):
            if i1**5 - i2**5 == x:
                print((i1, i2))
                sys.exit()

if __name__ == "__main__":
    main()

import sys

read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
from itertools import product

def main():
    x = int(input())
    n5 = [i**5 for i in range(201)]
    c = product(n5, repeat=2)
    for ce in c:
        if ce[0] + ce[1] == x:
            r = (int(ce[0] ** 0.2), int(ce[1] ** 0.2) * -1)
            break
        elif ce[0] - ce[1] == x:
            r = (int(ce[0] ** 0.2), int(ce[1] ** 0.2))
            break
    print(*r, sep=" ")

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:

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

import sys

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

sys.setrecursionlimit(10 ** 9)

from collections import deque

N = int(eval(input()))

S = eval(input())

ans = deque()

tmp = ''

l = r = 0

for c in S:

    if c == '(':

        l += 1

        tmp += '('

    else:

        if l == 0:

            ans.appendleft('(')

            ans.append(')')

        else:

            r += 1

            tmp += ')'

            if l == r:

                ans.append(tmp)

                tmp = ''

                l = r = 0

if l > r:

    tmp += ')' * (l-r)

    ans.append(tmp)

print((''.join(ans)))

# optimized version of the same code:

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

import sys

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

S = eval(input())

# それぞれ必要な数を確認

lneed = cnt = 0

for s in S:

    if s == ')':

        cnt += 1

        lneed = max(lneed, cnt)

    else:

        cnt -= 1

rneed = cnt = 0

for s in S[::-1]:

    if s == '(':

        cnt += 1

        rneed = max(rneed, cnt)

    else:

        cnt -= 1

# 辞書順最小なので、(は全部左に、)は全部右に付ける

ans = ('(' * lneed) + S + (')' * rneed)

print(ans)

# -*- coding: utf-8 -*-
import sys

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

sys.setrecursionlimit(10**9)
from collections import deque

N = int(eval(input()))
S = eval(input())
ans = deque()
tmp = ""
l = r = 0
for c in S:
    if c == "(":
        l += 1
        tmp += "("
    else:
        if l == 0:
            ans.appendleft("(")
            ans.append(")")
        else:
            r += 1
            tmp += ")"
            if l == r:
                ans.append(tmp)
                tmp = ""
                l = r = 0
if l > r:
    tmp += ")" * (l - r)
    ans.append(tmp)
print(("".join(ans)))

# -*- coding: utf-8 -*-
import sys

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 = INT()
S = eval(input())
# それぞれ必要な数を確認
lneed = cnt = 0
for s in S:
    if s == ")":
        cnt += 1
        lneed = max(lneed, cnt)
    else:
        cnt -= 1
rneed = cnt = 0
for s in S[::-1]:
    if s == "(":
        cnt += 1
        rneed = max(rneed, cnt)
    else:
        cnt -= 1
# 辞書順最小なので、(は全部左に、)は全部右に付ける
ans = ("(" * lneed) + S + (")" * rneed)
print(ans)

+    return [[[d] * c for j in range(b)] for i in range(a)]

+    return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

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

+    return list(MAP()) if N is None else [INT() for i in range(N)]

+# それぞれ必要な数を確認

+# 辞書順最小なので、(は全部左に、)は全部右に付ける


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

from fractions import gcd

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

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

a=list(set(a))

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

def lcm(q):

  x = q[0]

  for i in range(1, len(q)):

    x = (x * q[i]) // gcd(x, q[i])

  return x

lcma=lcm(a)

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

  print((0))

else:

  flg=0

  for i in range(1,len(a)):

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

      print((0))

      flg=1

      break

  if flg==0:

    temp=m//lcma

    print((temp//2 if temp%2==0 else temp//2+1))

# optimized version of the same code:

from math import gcd

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

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

a=list(set(a))

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

def lcm(q):

  x = q[0]

  for i in range(1, len(q)):

    x = (x * q[i]) // gcd(x, q[i])

  return x

lcma=lcm(a)

for i in range(len(a)):

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

    print((0))

    exit()

temp=m//lcma

print((temp//2 if temp%2==0 else temp//2+1))

from fractions import gcd

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a = list(set(a))
a = list([x // 2 for x in a])

def lcm(q):
    x = q[0]
    for i in range(1, len(q)):
        x = (x * q[i]) // gcd(x, q[i])
    return x

lcma = lcm(a)
if (lcma // a[0]) % 2 == 0:
    print((0))
else:
    flg = 0
    for i in range(1, len(a)):
        if (lcma // a[i]) % 2 == 0:
            print((0))
            flg = 1
            break
    if flg == 0:
        temp = m // lcma
        print((temp // 2 if temp % 2 == 0 else temp // 2 + 1))

from math import gcd

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a = list(set(a))
a = list([x // 2 for x in a])

def lcm(q):
    x = q[0]
    for i in range(1, len(q)):
        x = (x * q[i]) // gcd(x, q[i])
    return x

lcma = lcm(a)
for i in range(len(a)):
    if (lcma // a[i]) % 2 == 0:
        print((0))
        exit()
temp = m // lcma
print((temp // 2 if temp % 2 == 0 else temp // 2 + 1))

-        print((temp // 2 if temp % 2 == 0 else temp // 2 + 1))

+print((temp // 2 if temp % 2 == 0 else temp // 2 + 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:

S = int(eval(input()))

a = 0

count = 0

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

while count == 0:

    a += S

    if n <= a and m >= a:

        count = 1

    if a >= 1000:

        break

if count == 0:

    print("NG")

else:

    print("OK")

# optimized version of the same code:

k = int(eval(input()))

n = 0

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

while True:

    n += k

    if n >= a and n <= b:

        print("OK")

        break

    if n > b:

        print("NG")

        break

S = int(eval(input()))
a = 0
count = 0
n, m = list(map(int, input().split()))
while count == 0:
    a += S
    if n <= a and m >= a:
        count = 1
    if a >= 1000:
        break
if count == 0:
    print("NG")
else:
    print("OK")

k = int(eval(input()))
n = 0
a, b = list(map(int, input().split()))
while True:
    n += k
    if n >= a and n <= b:
        print("OK")
        break
    if n > b:
        print("NG")
        break

-S = int(eval(input()))
-a = 0
-count = 0
-n, m = list(map(int, input().split()))
-while count == 0:
-    a += S
-    if n <= a and m >= a:
-        count = 1
-    if a >= 1000:
+k = int(eval(input()))
+n = 0
+a, b = list(map(int, input().split()))
+while True:
+    n += k
+    if n >= a and n <= b:
+        print("OK")
-if count == 0:
-    print("NG")
-else:
-    print("OK")
+    if n > b:
+        print("NG")
+        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:

N = int(eval(input()))

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

n = N % 2

DP = [[0] * (N+1) for _ in range(N+1)]

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

    for i in range(N):

        j = i + w

        if j > N:

            continue

        if (w+n) % 2 == 1:

            DP[i][j] = min(DP[i+1][j] - A[i], DP[i][j-1] - A[j-1])

        else:

            DP[i][j] = max(DP[i+1][j] + A[i], DP[i][j-1] + A[j-1])

print((DP[0][N]))

# optimized version of the same code:

N = int(eval(input()))

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

DP = [[0] * (N+1) for _ in range(N+1)]

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

    for start in range(N):

        end = start + num

        if end > N:

            break

        if num == 1:

            DP[start][end] = A[start]

        else:

            DP[start][end] = max(A[start] - DP[start+1][end], A[end - 1] - DP[start][end - 1])

print((DP[0][N]))

N = int(eval(input()))
A = list(map(int, input().split()))
n = N % 2
DP = [[0] * (N + 1) for _ in range(N + 1)]
for w in range(1, N + 1):
    for i in range(N):
        j = i + w
        if j > N:
            continue
        if (w + n) % 2 == 1:
            DP[i][j] = min(DP[i + 1][j] - A[i], DP[i][j - 1] - A[j - 1])
        else:
            DP[i][j] = max(DP[i + 1][j] + A[i], DP[i][j - 1] + A[j - 1])
print((DP[0][N]))

N = int(eval(input()))
A = list(map(int, input().split()))
DP = [[0] * (N + 1) for _ in range(N + 1)]
for num in range(1, N + 1):
    for start in range(N):
        end = start + num
        if end > N:
            break
        if num == 1:
            DP[start][end] = A[start]
        else:
            DP[start][end] = max(
                A[start] - DP[start + 1][end], A[end - 1] - DP[start][end - 1]
            )
print((DP[0][N]))

+                A[start] - DP[start + 1][end], A[end - 1] - DP[start][end - 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()))

XY = []

for i in range(n):

    a = int(eval(input()))

    xy = []

    for j in range(a):

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

    XY.append(xy)

def check(i, xiyj, HoU):

    # 矛盾したらFalse 正直者と仮定した証言より 正直&正直者と仮定されている / 不親切&不親切と仮定されている True

    if ((i >> xiyj) & 1) ^ HoU:

        return False

    return True

max_honest = 0

for i in range(2 ** len(XY)):

    count = 0

    is_contradiction = True

    for j in range(len(XY)):

        # 正直者と仮定したときだけ採用

        if not ((i >> j) & 1): continue

        for k in range(len(XY[j])):

            xiyj = XY[j][k][0] - 1

            HoU = XY[j][k][1]

            if not check(i, xiyj, HoU):

                is_contradiction = False

                break

        if not is_contradiction:

            break

    if is_contradiction:

        for j in range(len(XY)):

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

        if count > max_honest:

            max_honest =count

print(max_honest)

# optimized version of the same code:

n = int(eval(input()))

XY = []

for i in range(n):

    a = int(eval(input()))

    xy = []

    for j in range(a):

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

    XY.append(xy)

"""

    矛盾したらFalse

    矛盾しなければTrue

    正直者と仮定した者の証言

        正直&正直者と仮定されている

        不親切&不親切と仮定されている

"""

def check(i, xiyj, HoU):

    # XOR

    if HoU ^ ((i >> xiyj) & 1):

        return False

    return True

max_honest = 0

for i in range(2 ** len(XY)):

    count = 0

    is_contradiction = True

    for j in range(len(XY)):

        # 正直者と仮定したときだけ採用

        if not ((i >> j) & 1): continue

        count+=1

        for k in range(len(XY[j])):

            xiyj = XY[j][k][0] - 1

            HoU = XY[j][k][1]

            if not check(i, xiyj, HoU):

                is_contradiction = False

                break # TLE対策

        if not is_contradiction:

            break # TLE対策

    # 矛盾がなく、正直者の数が更新できれば更新

    if is_contradiction and (count > max_honest):

        max_honest =count

print(max_honest)

n = int(eval(input()))
XY = []
for i in range(n):
    a = int(eval(input()))
    xy = []
    for j in range(a):
        xy.append(list(map(int, input().split())))
    XY.append(xy)

def check(i, xiyj, HoU):
    # 矛盾したらFalse 正直者と仮定した証言より 正直&正直者と仮定されている / 不親切&不親切と仮定されている True
    if ((i >> xiyj) & 1) ^ HoU:
        return False
    return True

max_honest = 0
for i in range(2 ** len(XY)):
    count = 0
    is_contradiction = True
    for j in range(len(XY)):
        # 正直者と仮定したときだけ採用
        if not ((i >> j) & 1):
            continue
        for k in range(len(XY[j])):
            xiyj = XY[j][k][0] - 1
            HoU = XY[j][k][1]
            if not check(i, xiyj, HoU):
                is_contradiction = False
                break
        if not is_contradiction:
            break
    if is_contradiction:
        for j in range(len(XY)):
            if (i >> j) & 1:
                count += 1
        if count > max_honest:
            max_honest = count
print(max_honest)

n = int(eval(input()))
XY = []
for i in range(n):
    a = int(eval(input()))
    xy = []
    for j in range(a):
        xy.append(list(map(int, input().split())))
    XY.append(xy)
"""
    矛盾したらFalse
    矛盾しなければTrue
    正直者と仮定した者の証言
        正直&正直者と仮定されている
        不親切&不親切と仮定されている
"""

def check(i, xiyj, HoU):
    # XOR
    if HoU ^ ((i >> xiyj) & 1):
        return False
    return True

max_honest = 0
for i in range(2 ** len(XY)):
    count = 0
    is_contradiction = True
    for j in range(len(XY)):
        # 正直者と仮定したときだけ採用
        if not ((i >> j) & 1):
            continue
        count += 1
        for k in range(len(XY[j])):
            xiyj = XY[j][k][0] - 1
            HoU = XY[j][k][1]
            if not check(i, xiyj, HoU):
                is_contradiction = False
                break  # TLE対策
        if not is_contradiction:
            break  # TLE対策
    # 矛盾がなく、正直者の数が更新できれば更新
    if is_contradiction and (count > max_honest):
        max_honest = count
print(max_honest)

+    矛盾しなければTrue

+    正直者と仮定した者の証言

+        正直&正直者と仮定されている

+        不親切&不親切と仮定されている

-    # 矛盾したらFalse 正直者と仮定した証言より 正直&正直者と仮定されている / 不親切&不親切と仮定されている True

+    # 矛盾がなく、正直者の数が更新できれば更新

+    if is_contradiction and (count > max_honest):


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 as fc

a = int(eval(input()))

print((fc(a)%(10**9+7)))

# optimized version of the same code:

n = int(eval(input()))

m = 10**9+7

ans = 1

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

  ans *= i

  ans %= m

print(ans)

from math import factorial as fc

a = int(eval(input()))
print((fc(a) % (10**9 + 7)))

n = int(eval(input()))
m = 10**9 + 7
ans = 1
for i in range(1, n + 1):
    ans *= i
    ans %= m
print(ans)

-from math import factorial as fc
-a = int(eval(input()))
-print((fc(a) % (10**9 + 7)))
+n = int(eval(input()))
+m = 10**9 + 7
+ans = 1
+for i in range(1, n + 1):
+    ans *= i
+    ans %= m
+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 math import gcd

N = int(eval(input()))

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

c = True

def osa_k(max_num):

  lis = [i for i in range(max_num+1)]

  p = 2

  while p**2 <= max_num:

    if lis[p] == p:

      for q in range(2*p, max_num+1, p):

        if lis[q] == q:

          lis[q] = p

    p += 1

  return lis

hoge = 0

for i in num_lis:

  hoge = gcd(hoge, i)

if hoge > 1:

  print("not coprime")

  exit()

d_lis = osa_k(10**6+10)

tmp = set()

for i in num_lis:

  num = i

  new_tmp = set()

  while num > 1:

    d = d_lis[num]

    new_tmp.add(d)

    num //= d

  for j in new_tmp:

    if j in tmp:

      c = False

      break

    else:

      tmp.add(j)

  else:

    continue

  break

if c:

  print("pairwise coprime")

else:

  print("setwise coprime")

# optimized version of the same code:

from math import gcd

N = int(eval(input()))

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

def osa_k(max_num):

  lis = [i for i in range(max_num+1)]

  p = 2

  while p**2 <= max_num:

    if lis[p] == p:

      for q in range(2*p, max_num+1, p):

        if lis[q] == q:

          lis[q] = p

    p += 1

  return lis

hoge = 0

for i in num_lis:

  hoge = gcd(hoge, i)

if hoge > 1:

  print("not coprime")

  exit()

d_lis = osa_k(max(num_lis))

tmp = set()

for i in num_lis:

  num = i

  new_tmp = set()

  while num > 1:

    d = d_lis[num]

    new_tmp.add(d)

    num //= d

  for j in new_tmp:

    if j in tmp:

      print("setwise coprime")

      exit()

    else:

      tmp.add(j)

print("pairwise coprime")

from math import gcd

N = int(eval(input()))
num_lis = list(map(int, input().split()))
c = True

def osa_k(max_num):
    lis = [i for i in range(max_num + 1)]
    p = 2
    while p**2 <= max_num:
        if lis[p] == p:
            for q in range(2 * p, max_num + 1, p):
                if lis[q] == q:
                    lis[q] = p
        p += 1
    return lis

hoge = 0
for i in num_lis:
    hoge = gcd(hoge, i)
if hoge > 1:
    print("not coprime")
    exit()
d_lis = osa_k(10**6 + 10)
tmp = set()
for i in num_lis:
    num = i
    new_tmp = set()
    while num > 1:
        d = d_lis[num]
        new_tmp.add(d)
        num //= d
    for j in new_tmp:
        if j in tmp:
            c = False
            break
        else:
            tmp.add(j)
    else:
        continue
    break
if c:
    print("pairwise coprime")
else:
    print("setwise coprime")

from math import gcd

N = int(eval(input()))
num_lis = list(map(int, input().split()))

def osa_k(max_num):
    lis = [i for i in range(max_num + 1)]
    p = 2
    while p**2 <= max_num:
        if lis[p] == p:
            for q in range(2 * p, max_num + 1, p):
                if lis[q] == q:
                    lis[q] = p
        p += 1
    return lis

hoge = 0
for i in num_lis:
    hoge = gcd(hoge, i)
if hoge > 1:
    print("not coprime")
    exit()
d_lis = osa_k(max(num_lis))
tmp = set()
for i in num_lis:
    num = i
    new_tmp = set()
    while num > 1:
        d = d_lis[num]
        new_tmp.add(d)
        num //= d
    for j in new_tmp:
        if j in tmp:
            print("setwise coprime")
            exit()
        else:
            tmp.add(j)
print("pairwise coprime")

-c = True
-d_lis = osa_k(10**6 + 10)
+d_lis = osa_k(max(num_lis))
-            c = False
-            break
+            print("setwise coprime")
+            exit()
-    else:
-        continue
-    break
-if c:
-    print("pairwise coprime")
-else:
-    print("setwise coprime")
+print("pairwise coprime")


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

edges = []

for id in range(n-1):

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

    edges.append([a-1, b-1, id])

edges.sort()

used = [0]*(n)

ans = [0]*(n-1)

num = 1

prev = 0

for edge in edges:

    _from, to, id = edge

    if _from != prev:

        num = 1

    if used[_from] == num:

        num += 1

    ans[id] = num

    used[to] = num

    num += 1

    prev = _from

print((max(ans)))

for color in ans:

    print(color)

# optimized version of the same code:

import sys

input = sys.stdin.readline

n = int(eval(input()))

edges = []

for id in range(n-1):

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

    edges.append([a-1, b-1, id])

edges.sort()

used = [0]*(n)

ans = [0]*(n-1)

num = 1

prev = 0

for edge in edges:

    _from, to, id = edge

    if _from != prev:

        num = 1

    if used[_from] == num:

        num += 1

    ans[id] = num

    used[to] = num

    num += 1

    prev = _from

print((max(ans)))

for color in ans:

    print(color)

import sys

input = sys.stdin.readline
n = int(eval(input()))
edges = []
for id in range(n - 1):
    a, b = list(map(int, input().split()))
    edges.append([a - 1, b - 1, id])
edges.sort()
used = [0] * (n)
ans = [0] * (n - 1)
num = 1
prev = 0
for edge in edges:
    _from, to, id = edge
    if _from != prev:
        num = 1
    if used[_from] == num:
        num += 1
    ans[id] = num
    used[to] = num
    num += 1
    prev = _from
print((max(ans)))
for color in ans:
    print(color)

+import sys
+
+input = sys.stdin.readline


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:

for i in range(0, int(eval(input()))):

    sidelen = [int(j) for j in input().split(" ")]

    sidelen.sort(reverse=True)

    if(sidelen[0]**2 == sidelen[1]**2 + sidelen[2]**2):

        print("YES")

    else:

        print("NO")

# optimized version of the same code:

import sys

for i in sys.stdin:

    try:

        sidelen = [int(j) for j in i.split(" ")]

        sidelen.sort(reverse=True)

        if(sidelen[0]**2 == sidelen[1]**2 + sidelen[2]**2):

            print("YES")

        else:

            print("NO")

    except:

        continue

for i in range(0, int(eval(input()))):
    sidelen = [int(j) for j in input().split(" ")]
    sidelen.sort(reverse=True)
    if sidelen[0] ** 2 == sidelen[1] ** 2 + sidelen[2] ** 2:
        print("YES")
    else:
        print("NO")

import sys

for i in sys.stdin:
    try:
        sidelen = [int(j) for j in i.split(" ")]
        sidelen.sort(reverse=True)
        if sidelen[0] ** 2 == sidelen[1] ** 2 + sidelen[2] ** 2:
            print("YES")
        else:
            print("NO")
    except:
        continue

-    sidelen = [int(j) for j in input().split(" ")]

-    if sidelen[0] ** 2 == sidelen[1] ** 2 + sidelen[2] ** 2:

+        sidelen = [int(j) for j in i.split(" ")]

+        if sidelen[0] ** 2 == sidelen[1] ** 2 + sidelen[2] ** 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_1=list(map(int, input().split()))

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

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

N=int(eval(input()))

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

n=np.array([N_1,N_2,N_3])

for a_n in a:

    if a_n in n:

        n[n==a_n]=0

    else:

        pass

i=0

if np.all(n[0:,0]==0)==True:

    i=+1

elif np.all(n[0:,1]==0)==True:

    i+=1

elif np.all(n[0:,2]==0)==True:

    i+=1

elif np.all(n[0,0:]==0)==True:

    i+=1

elif np.all(n[1,0:]==0)==True:

    i+=1

elif np.all(n[2,0:]==0)==True:

    i+=1

elif n[0,0]==0 and n[1,1]==0  and n[2,2] ==0:

    i+=1

elif n[0,2]==0 and n[1,1]==0 and n[2,0] ==0:

    i+=1

if i>0:

    print("Yes")

else:

    print("No")

# optimized version of the same code:

import numpy as np

N_1 = list(map(int, input().split()))
N_2 = list(map(int, input().split()))
N_3 = list(map(int, input().split()))
N = int(eval(input()))
a = [int(eval(input())) for i in range(N)]
n = np.array([N_1, N_2, N_3])
for a_n in a:
    if a_n in n:
        n[n == a_n] = 0
    else:
        pass
i = 0
if np.all(n[0:, 0] == 0) == True:
    i = +1
elif np.all(n[0:, 1] == 0) == True:
    i += 1
elif np.all(n[0:, 2] == 0) == True:
    i += 1
elif np.all(n[0, 0:] == 0) == True:
    i += 1
elif np.all(n[1, 0:] == 0) == True:
    i += 1
elif np.all(n[2, 0:] == 0) == True:
    i += 1
elif n[0, 0] == 0 and n[1, 1] == 0 and n[2, 2] == 0:
    i += 1
elif n[0, 2] == 0 and n[1, 1] == 0 and n[2, 0] == 0:
    i += 1
if i > 0:
    print("Yes")
else:
    print("No")

-a = [int(eval(input())) for i in range(N)]

+b = [int(eval(input())) for _ 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:

n = int(eval(input()))

s = input().split()

s = set(s)

print(('Four' if len(s) == 4 else 'Three'))

# optimized version of the same code:

n = int(eval(input()))

s = input().split()

print(('Four' if len(set(s)) == 4 else 'Three'))

n = int(eval(input()))
s = input().split()
s = set(s)
print(("Four" if len(s) == 4 else "Three"))

n = int(eval(input()))
s = input().split()
print(("Four" if len(set(s)) == 4 else "Three"))

-print(("Four" if len(s) == 4 else "Three"))

+print(("Four" if len(set(s)) == 4 else "Three"))


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

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

B=np.argsort(A[0,:])

for b in B:

  print(b+1, end=' ')

# optimized version of the same code:

N=int(input())

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

B=[-1]*N

for i in range(N):

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

for b in B:

  print(b, end=" ")

import numpy as np

N = int(input())
A = np.array([list(map(int, input().split()))])
B = np.argsort(A[0, :])
for b in B:
    print(b + 1, end=" ")

N = int(input())
A = list(map(int, input().split()))
B = [-1] * N
for i in range(N):
    B[A[i] - 1] = i + 1
for b in B:
    print(b, end=" ")

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

dX = [2,2,2,1,0,-1,-2,-2,-2,-1,0,1]

dY = [-1,0,1,2,2,2,1,0,-1,-2,-2,-2]

def solve(x,y,XY):

	xy = XY[:]

	if len(xy) == 0: return "OK"

	sx,sy = xy.pop(0),xy.pop(0)

	for dx,dy in zip(dX,dY):

		if doa(x+dx,y+dy,sx,sy):

			r = solve(x+dx,y+dy,xy)

			if r: return r

def doa(x,y,sx,sy):

	if not (0 <= x <= 9 and 0 <= y <= 9): return False

	return True if abs(x-sx) < 2 and abs(y-sy) < 2 else False

while 1:

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

	if x == y == 0: break

	n = eval(input())

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

	ans = solve(x,y,xy)

	print(ans if ans else "NA")

# optimized version of the same code:

dX = [2,2,2,1,0,-1,-2,-2,-2,-1,0,1]

dY = [-1,0,1,2,2,2,1,0,-1,-2,-2,-2]

def solve(x,y,XY):

	xy = XY[:]

	if len(xy) == 0: return True

	sx,sy = xy.pop(0),xy.pop(0)

	for dx,dy in zip(dX,dY):

		if doa(x+dx,y+dy,sx,sy):

			r = solve(x+dx,y+dy,xy)

			if r: return r

def doa(x,y,sx,sy):

	if not (0 <= x <= 9 and 0 <= y <= 9): return False

	return True if abs(x-sx) < 2 and abs(y-sy) < 2 else False

while 1:

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

	if x == y == 0: break

	n = eval(input())

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

	print("OK" if solve(x,y,xy) else "NA")

dX = [2, 2, 2, 1, 0, -1, -2, -2, -2, -1, 0, 1]
dY = [-1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2]

def solve(x, y, XY):
    xy = XY[:]
    if len(xy) == 0:
        return "OK"
    sx, sy = xy.pop(0), xy.pop(0)
    for dx, dy in zip(dX, dY):
        if doa(x + dx, y + dy, sx, sy):
            r = solve(x + dx, y + dy, xy)
            if r:
                return r

def doa(x, y, sx, sy):
    if not (0 <= x <= 9 and 0 <= y <= 9):
        return False
    return True if abs(x - sx) < 2 and abs(y - sy) < 2 else False

while 1:
    x, y = list(map(int, input().split()))
    if x == y == 0:
        break
    n = eval(input())
    xy = list(map(int, input().split()))
    ans = solve(x, y, xy)
    print(ans if ans else "NA")

dX = [2, 2, 2, 1, 0, -1, -2, -2, -2, -1, 0, 1]
dY = [-1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2]

def solve(x, y, XY):
    xy = XY[:]
    if len(xy) == 0:
        return True
    sx, sy = xy.pop(0), xy.pop(0)
    for dx, dy in zip(dX, dY):
        if doa(x + dx, y + dy, sx, sy):
            r = solve(x + dx, y + dy, xy)
            if r:
                return r

def doa(x, y, sx, sy):
    if not (0 <= x <= 9 and 0 <= y <= 9):
        return False
    return True if abs(x - sx) < 2 and abs(y - sy) < 2 else False

while 1:
    x, y = list(map(int, input().split()))
    if x == y == 0:
        break
    n = eval(input())
    xy = list(map(int, input().split()))
    print("OK" if solve(x, y, xy) else "NA")

+    print("OK" if solve(x, y, xy) else "NA")


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

sys.setrecursionlimit(1000000)

from collections import deque

def getN():

    return int(eval(input()))

def getList():

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

import math

n = getN()

nums = getList()

# nums.sort(reverse=True)

mx = max(nums)

mn = (mx+1) // 2

mndx = (mx % 2) + 1

from collections import Counter

cnt = Counter(nums)

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

    if cnt[i] < 2:

        print("Impossible")

        sys.exit()

if cnt[mn] != mndx:

    print("Impossible")

else:

    print("Possible")

# optimized version of the same code:

import sys

import math

import copy

from heapq import heappush, heappop, heapify

from functools import cmp_to_key

from bisect import bisect_left, bisect_right

from collections import defaultdict, deque, Counter

# sys.setrecursionlimit(1000000)

# input aliases

input = sys.stdin.readline

getS = lambda: input().strip()

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

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

getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")

MOD = 10**9 + 7

divide = lambda x: pow(x, MOD-2, MOD)

def pim():

    print("Impossible")

    sys.exit()

def pp():

    print("Possible")

    sys.exit()

def solve():

    n = getN()

    nums = getList()

    cnt = Counter(nums)

    mx = max(nums)

    mn = min(nums)

    if cnt[mx] < 2:

        pim()

    if mn < (mx + 1) // 2:

        pim()

    if mx % 2 == 0:

        if cnt[mx//2] != 1:

            pim()

    else:

        if cnt[(mx+1) // 2] != 2:

            pim()

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

        if cnt[i] < 2:

            pim()

    pp()

def main():

    n = getN()

    for _ in range(n):

        solve()

    return

if __name__ == "__main__":

    # main()

    solve()

import sys

input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque

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

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

import math

n = getN()
nums = getList()
# nums.sort(reverse=True)
mx = max(nums)
mn = (mx + 1) // 2
mndx = (mx % 2) + 1
from collections import Counter

cnt = Counter(nums)
for i in range(mn + 1, mx + 1):
    if cnt[i] < 2:
        print("Impossible")
        sys.exit()
if cnt[mn] != mndx:
    print("Impossible")
else:
    print("Possible")

import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter

# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)

def pim():
    print("Impossible")
    sys.exit()

def pp():
    print("Possible")
    sys.exit()

def solve():
    n = getN()
    nums = getList()
    cnt = Counter(nums)
    mx = max(nums)
    mn = min(nums)
    if cnt[mx] < 2:
        pim()
    if mn < (mx + 1) // 2:
        pim()
    if mx % 2 == 0:
        if cnt[mx // 2] != 1:
            pim()
    else:
        if cnt[(mx + 1) // 2] != 2:
            pim()
    for i in range((mx + 1) // 2 + 1, mx + 1):
        if cnt[i] < 2:
            pim()
    pp()

def main():
    n = getN()
    for _ in range(n):
        solve()
    return

if __name__ == "__main__":
    # main()
    solve()

+from heapq import heappush, heappop, heapify

+from bisect import bisect_left, bisect_right

+from collections import defaultdict, deque, Counter

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

+getZList = lambda: [int(x) - 1 for x in input().split()]

+divide = lambda x: pow(x, MOD - 2, MOD)

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

import sys

if __name__ == '__main__':

    import doctest

    doctest.testmod()

    S = int(sys.stdin.read())

    h = S / 3600

    m = (S % 3600) / 60

    s = S % 60

    print("%d:%d:%d" % (h, m, s))

# optimized version of the same code:

#!/usr/bin/env python

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

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

if __name__ == '__main__':

    S = int(input())

    h = S / 3600

    m = (S % 3600) / 60

    s = S % 60

    print("%d:%d:%d" % (h, m, s))

import sys

if __name__ == "__main__":
    import doctest

    doctest.testmod()
    S = int(sys.stdin.read())
    h = S / 3600
    m = (S % 3600) / 60
    s = S % 60
    print("%d:%d:%d" % (h, m, s))

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_D
if __name__ == "__main__":
    S = int(input())
    h = S / 3600
    m = (S % 3600) / 60
    s = S % 60
    print("%d:%d:%d" % (h, m, s))


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

n = int(eval(input()))

s = []

for i in range(1, 10):

  for j in range(1, 10):

    s.append(i*j)

if n in s:

  print("Yes")

else:

  print("No")

# optimized version of the same code:

import sys

n = int(eval(input()))

for i in range(1, 10):

  for j in range(1, 10):

    if i*j == n:

      print("Yes")

      sys.exit()

print("No")

n = int(eval(input()))
s = []
for i in range(1, 10):
    for j in range(1, 10):
        s.append(i * j)
if n in s:
    print("Yes")
else:
    print("No")

import sys

n = int(eval(input()))
for i in range(1, 10):
    for j in range(1, 10):
        if i * j == n:
            print("Yes")
            sys.exit()
print("No")

+import sys
+
-s = []
-        s.append(i * j)
-if n in s:
-    print("Yes")
-else:
-    print("No")
+        if i * j == n:
+            print("Yes")
+            sys.exit()
+print("No")


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

# ABC 155 C

from collections import Counter

import numpy as np

N = int(eval(input()))

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

S = np.array(S)

count = Counter(S)

max_num = max(count.values())

max_list = [i for i,j in list(count.items()) if j==max_num]

max_list.sort()

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

# optimized version of the same code:

import sys

from collections import Counter

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

S = sys.stdin.read().split()

count = Counter(S)

max_num = max(count.values())

max_list = [i for i,j in list(count.items()) if j==max_num]

max_list.sort()

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

# ABC 155 C
from collections import Counter
import numpy as np

N = int(eval(input()))
S = [str(eval(input())) for i in range(N)]
S = np.array(S)
count = Counter(S)
max_num = max(count.values())
max_list = [i for i, j in list(count.items()) if j == max_num]
max_list.sort()
print(("\n".join(max_list)))

import sys
from collections import Counter

N = int(sys.stdin.readline())
S = sys.stdin.read().split()
count = Counter(S)
max_num = max(count.values())
max_list = [i for i, j in list(count.items()) if j == max_num]
max_list.sort()
print(("\n".join(max_list)))

-S = [str(eval(input())) for i in range(N)]


Input:
# slower version:

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

# optimized version of the same code:

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

# slower version:

import math

N=int(eval(input()))

ans=math.factorial(N)

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

# optimized version of the same code:

mod=10**9+7

N=int(eval(input()))

ans=1

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

  ans*=i

  ans%=mod

print(ans)

import math

N = int(eval(input()))
ans = math.factorial(N)
print((ans % (10**9 + 7)))

mod = 10**9 + 7
N = int(eval(input()))
ans = 1
for i in range(1, N + 1):
    ans *= i
    ans %= mod
print(ans)

-import math
+mod = 10**9 + 7
-ans = math.factorial(N)
-print((ans % (10**9 + 7)))
+ans = 1
+for i in range(1, N + 1):
+    ans *= i
+    ans %= mod
+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 numpy as np

n = int(eval(input()))

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

print((*list([x + 1 for x in np.argsort(a)])))

# optimized version of the same code:

n = int(eval(input()))

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

for i, x in enumerate(map(int, input().split())):

  m[i] = (m[i][0], x)

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

print((' '.join([str(x[0]) for x in m])))

n = int(eval(input()))
m = [(x, 0) for x in range(1, n + 1)]
for i, x in enumerate(map(int, input().split())):
    m[i] = (m[i][0], x)
m.sort(key=lambda x: x[1])
print((" ".join([str(x[0]) for x in m])))

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

-print((*list([x + 1 for x in np.argsort(a)])))

+for i, x in enumerate(map(int, input().split())):

+print((" ".join([str(x[0]) for x in m])))