Input:
import math

r = float(eval(input()))

print(f'{math.pi*r*r:.12f} {2*math.pi*r:.12f}')

import math

rad = float(eval(input()))

print(("%.10f %.10f"%(rad*rad*math.pi,2.0*math.pi*rad)))

import math

r = float(eval(input()))
print(f"{math.pi*r*r:.12f} {2*math.pi*r:.12f}")

import math

rad = float(eval(input()))
print(("%.10f %.10f" % (rad * rad * math.pi, 2.0 * math.pi * rad)))

+print(("%.10f %.10f" % (rad * rad * math.pi, 2.0 * math.pi * rad)))


Input:
n = int(eval(input()))

s = eval(input())

dup = [s]

ans = 'Yes'

for i in range(n-1):

    next = eval(input())

    if s[-1]!=next[0] or next in dup:

        ans = 'No'

    else:dup.append(next)

    s = next

print(ans)

n = int(eval(input()))

before = ''

said = set([])

f = True

for i in range(n):

    if i==0:

        before = eval(input())

        said.add(before)

        continue

    s = eval(input())

    if before[-1] != s[0] or s in said:

        f = False

    before = s

    said.add(s)

print(('Yes' if f else 'No'))

n = int(eval(input()))
s = eval(input())
dup = [s]
ans = "Yes"
for i in range(n - 1):
    next = eval(input())
    if s[-1] != next[0] or next in dup:
        ans = "No"
    else:
        dup.append(next)
    s = next
print(ans)

n = int(eval(input()))
before = ""
said = set([])
f = True
for i in range(n):
    if i == 0:
        before = eval(input())
        said.add(before)
        continue
    s = eval(input())
    if before[-1] != s[0] or s in said:
        f = False
    before = s
    said.add(s)
print(("Yes" if f else "No"))

-    if s[-1] != next[0] or next in dup:

+    if before[-1] != s[0] or s in said:


Input:
# ABC058 B - ∵∴∵

from collections import deque

si = lambda: eval(input())

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

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

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

O = si()

E = si()

N = len(O) + len(E)

O = [ o for o in O]

E = [ e for e in E]

O = deque(O)

E = deque(E)

ans = ''

for i in range(N):

    if i%2==0:

        ans += O.popleft()

    else:

        ans += E.popleft()

print(ans)

o=eval(input())

e=eval(input())

n=len(o)+len(e)

ans=''

for i in range(n):

    if i%2==0:

        ans+=o[i//2]

    else:

        ans+=e[i//2]

print(ans)

# ABC058 B - ∵∴∵
from collections import deque

si = lambda: eval(input())
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))
O = si()
E = si()
N = len(O) + len(E)
O = [o for o in O]
E = [e for e in E]
O = deque(O)
E = deque(E)
ans = ""
for i in range(N):
    if i % 2 == 0:
        ans += O.popleft()
    else:
        ans += E.popleft()
print(ans)

o = eval(input())
e = eval(input())
n = len(o) + len(e)
ans = ""
for i in range(n):
    if i % 2 == 0:
        ans += o[i // 2]
    else:
        ans += e[i // 2]
print(ans)

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

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


Input:
import sys

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

MOD = 10 ** 9 + 7

INV2 = (MOD + 1) // 2

lines = sys.stdin.readlines()

aaa = list(map(int, lines[:n]))

mat = [[0] * n for _ in [0] * n]

for i in range(n):

    for j in range(n):

        mat[i][j] = int(aaa[i] < aaa[j])

# print(*mat, sep='\n')

for line in lines[n:]:

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

    x -= 1

    y -= 1

    mat[x][y] = mat[y][x] = (mat[x][y] + mat[y][x]) * INV2 % MOD

    for i in range(n):

        if i == x or i == y:

            continue

        mat[x][i] = mat[y][i] = (mat[x][i] + mat[y][i]) * INV2 % MOD

        mat[i][x] = mat[i][y] = (mat[i][x] + mat[i][y]) * INV2 % MOD

    # print(x, y)

    # print(*mat, sep='\n')

ans = sum(sum(row[:i]) for i, row in enumerate(mat)) % MOD

ans = (ans << q) % MOD

print(ans)

import sys

import numpy as np

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

MOD = 10 ** 9 + 7

INV2 = (MOD + 1) // 2

lines = sys.stdin.readlines()

aaa = np.fromiter(list(map(int, lines[:n])), dtype=np.int)

mat = (aaa.reshape(1, -1) < aaa.reshape(-1, 1)).astype(np.int64)

# print(mat)

for line in lines[n:]:

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

    x -= 1

    y -= 1

    tmp = (mat[x, y] + mat[y, x]) * INV2 % MOD

    mat[x] = mat[y] = (mat[x] + mat[y]) * INV2 % MOD

    mat[:, x] = mat[:, y] = (mat[:, x] + mat[:, y]) * INV2 % MOD

    mat[x, x] = mat[y, y] = 0

    mat[x, y] = mat[y, x] = tmp

ans = int(np.triu(mat).sum() % MOD)

ans = (ans << q) % MOD

print(ans)

import sys

n, q = list(map(int, input().split()))
MOD = 10**9 + 7
INV2 = (MOD + 1) // 2
lines = sys.stdin.readlines()
aaa = list(map(int, lines[:n]))
mat = [[0] * n for _ in [0] * n]
for i in range(n):
    for j in range(n):
        mat[i][j] = int(aaa[i] < aaa[j])
# print(*mat, sep='\n')
for line in lines[n:]:
    x, y = list(map(int, line.split()))
    x -= 1
    y -= 1
    mat[x][y] = mat[y][x] = (mat[x][y] + mat[y][x]) * INV2 % MOD
    for i in range(n):
        if i == x or i == y:
            continue
        mat[x][i] = mat[y][i] = (mat[x][i] + mat[y][i]) * INV2 % MOD
        mat[i][x] = mat[i][y] = (mat[i][x] + mat[i][y]) * INV2 % MOD
    # print(x, y)
    # print(*mat, sep='\n')
ans = sum(sum(row[:i]) for i, row in enumerate(mat)) % MOD
ans = (ans << q) % MOD
print(ans)

import sys
import numpy as np

n, q = list(map(int, input().split()))
MOD = 10**9 + 7
INV2 = (MOD + 1) // 2
lines = sys.stdin.readlines()
aaa = np.fromiter(list(map(int, lines[:n])), dtype=np.int)
mat = (aaa.reshape(1, -1) < aaa.reshape(-1, 1)).astype(np.int64)
# print(mat)
for line in lines[n:]:
    x, y = list(map(int, line.split()))
    x -= 1
    y -= 1
    tmp = (mat[x, y] + mat[y, x]) * INV2 % MOD
    mat[x] = mat[y] = (mat[x] + mat[y]) * INV2 % MOD
    mat[:, x] = mat[:, y] = (mat[:, x] + mat[:, y]) * INV2 % MOD
    mat[x, x] = mat[y, y] = 0
    mat[x, y] = mat[y, x] = tmp
ans = int(np.triu(mat).sum() % MOD)
ans = (ans << q) % MOD
print(ans)

-        mat[i][j] = int(aaa[i] < aaa[j])

+aaa = np.fromiter(list(map(int, lines[:n])), dtype=np.int)

+mat = (aaa.reshape(1, -1) < aaa.reshape(-1, 1)).astype(np.int64)

-    mat[x][y] = mat[y][x] = (mat[x][y] + mat[y][x]) * INV2 % MOD

-        mat[x][i] = mat[y][i] = (mat[x][i] + mat[y][i]) * INV2 % MOD

-        mat[i][x] = mat[i][y] = (mat[i][x] + mat[i][y]) * INV2 % MOD

-ans = sum(sum(row[:i]) for i, row in enumerate(mat)) % MOD

+    tmp = (mat[x, y] + mat[y, x]) * INV2 % MOD

+    mat[x] = mat[y] = (mat[x] + mat[y]) * INV2 % MOD


Input:
s=eval(input())

#Aのインデックス

num_a=s.index("A")

#Zのインデックス

num_z=len(s)-1-s[::-1].index("Z")

print((num_z-num_a+1))

s=eval(input())

r_s=s[::-1]

c_a=s.find("A")

c_rz=r_s.find("Z")

c_z=len(s)-1-c_rz

print((c_z-c_a+1))

s = eval(input())
# Aのインデックス
num_a = s.index("A")
# Zのインデックス
num_z = len(s) - 1 - s[::-1].index("Z")
print((num_z - num_a + 1))

s = eval(input())
r_s = s[::-1]
c_a = s.find("A")
c_rz = r_s.find("Z")
c_z = len(s) - 1 - c_rz
print((c_z - c_a + 1))


Input:
from decimal import Decimal

t, x = input().split()

print((Decimal(t)/Decimal(x)))

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

print((t / x))

from decimal import Decimal

t, x = input().split()
print((Decimal(t) / Decimal(x)))

-from decimal import Decimal
-t, x = input().split()
-print((Decimal(t) / Decimal(x)))
+t, x = list(map(int, input().split()))
+print((t / x))


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

b = b/0.1

b_list = [i+b for i in range(10)]

for i in b_list:

    if int(i*0.08) == a:

        print((int(i)))

        exit()

print("-1")

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

for i in range(1,1009):

    if int(i*0.08) == a and int(i*0.1) == b:

        print((int(i)))

        exit()

print("-1")

a, b = list(map(int, input().split()))
b = b / 0.1
b_list = [i + b for i in range(10)]
for i in b_list:
    if int(i * 0.08) == a:
        print((int(i)))
        exit()
print("-1")

a, b = list(map(int, input().split()))
for i in range(1, 1009):
    if int(i * 0.08) == a and int(i * 0.1) == b:
        print((int(i)))
        exit()
print("-1")


Input:
from collections import defaultdict

def main():

    N = int(eval(input()))

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

    ans = 0

    for i in range(N):

        ans += A[i] // 2

        if A[i] % 2 == 1:

            if A[i+1] >= 1:

                ans += 1

                A[i+1] -= 1

    print(ans)

if __name__ == "__main__":

    main()

def main():

    N = int(eval(input()))

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

    cnt = 0

    for i in range(N):

        if i == N-1:

            cnt += A[i] // 2

            break

        cnt += A[i] // 2

        mod = A[i] % 2

        if A[i+1] >= mod:

            cnt += mod

            A[i+1] -= mod

    print(cnt)

if __name__ == "__main__":

    main()

from collections import defaultdict

def main():
    N = int(eval(input()))
    A = [int(eval(input())) for _ in range(N)] + [0]
    ans = 0
    for i in range(N):
        ans += A[i] // 2
        if A[i] % 2 == 1:
            if A[i + 1] >= 1:
                ans += 1
                A[i + 1] -= 1
    print(ans)

if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    A = list(int(eval(input())) for _ in range(N))
    cnt = 0
    for i in range(N):
        if i == N - 1:
            cnt += A[i] // 2
            break
        cnt += A[i] // 2
        mod = A[i] % 2
        if A[i + 1] >= mod:
            cnt += mod
            A[i + 1] -= mod
    print(cnt)

if __name__ == "__main__":
    main()

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

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


Input:
n=eval(input())

arare=list(map(str,input().split()))

if "Y" in arare:

  print("Four")

else:

  print("Three")

n,*s=list(map(str,open(0).read().split()))

if "Y" in s:

  print("Four")

else:

  print("Three")

n = eval(input())
arare = list(map(str, input().split()))
if "Y" in arare:
    print("Four")
else:
    print("Three")

n, *s = list(map(str, open(0).read().split()))
if "Y" in s:
    print("Four")
else:
    print("Three")

-arare = list(map(str, input().split()))

+n, *s = list(map(str, open(0).read().split()))


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

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

ans = 0

if A[0] > X:

    ans += A[0] - X

    A[0] = X

for i in range(N-1):

    if A[i] + A[i+1] > X:

        ans -= X - (A[i] + A[i + 1])

        A[i+1] += X - (A[i] + A[i+1])

print(ans)

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

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

v=sum(a)

if k<a[0]:

    a[0]=k

for i in range(n-1):

    if k<a[i]+a[i+1]:

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

print((v-sum(a)))

N, X = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = 0
if A[0] > X:
    ans += A[0] - X
    A[0] = X
for i in range(N - 1):
    if A[i] + A[i + 1] > X:
        ans -= X - (A[i] + A[i + 1])
        A[i + 1] += X - (A[i] + A[i + 1])
print(ans)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
v = sum(a)
if k < a[0]:
    a[0] = k
for i in range(n - 1):
    if k < a[i] + a[i + 1]:
        a[i + 1] = k - a[i]
print((v - sum(a)))


Input:
from itertools import zip_longest

abcd = eval(input())

for i in range(0, 8):

	signs = bin(i)[2:].zfill(3).replace("1", "+").replace("0", "-")

	formula = "".join("".join(s) for s in zip_longest(abcd, signs, fillvalue=""))

	if eval(formula) == 7:

		print((formula+"=7"))

		exit()

abcd = eval(input())

for i in range(1<<3):

	formula = abcd[0]

	for j in range(3):

		formula += "+-"[(i>>j)%2]

		formula += abcd[j+1]

	if eval(formula) == 7:

		print((formula + "=7"))

		exit()

from itertools import zip_longest

abcd = eval(input())
for i in range(0, 8):
    signs = bin(i)[2:].zfill(3).replace("1", "+").replace("0", "-")
    formula = "".join("".join(s) for s in zip_longest(abcd, signs, fillvalue=""))
    if eval(formula) == 7:
        print((formula + "=7"))
        exit()

abcd = eval(input())
for i in range(1 << 3):
    formula = abcd[0]
    for j in range(3):
        formula += "+-"[(i >> j) % 2]
        formula += abcd[j + 1]
    if eval(formula) == 7:
        print((formula + "=7"))
        exit()

-    formula = "".join("".join(s) for s in zip_longest(abcd, signs, fillvalue=""))


Input:
from bisect import bisect_right

def main():

    N = int(eval(input()))

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

    INF = 10 ** 18

    last_max = A[0]

    last_min = A[0]

    money = 1000

    stock = 0

    old_trend = 0

    trend = A[1] - A[0]

    buy_point = []

    bought_point = []

    for i in range(N-1):

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

        if trend * old_trend > 0 or trend == 0:

            continue

        else:

            if trend > 0:

                buy_point.append(i)

            if trend < 0:

                bought_point.append(i)

        old_trend = trend

    if len(buy_point) > len(bought_point):

        bought_point.append(N-1)

    for i in range(N):

        if i in buy_point:

            buy = money//A[i]

            stock += buy

            money -= buy*A[i]

            nx_bought_idx = bisect_right(bought_point,i)

            bought_value = A[nx_bought_idx]

            j = i - 1

            while j >= 0 and money >= 100:

                if A[j] < bought_value and money >= A[i]:

                    money -= A[j]

                    stock += 1

                    break

                j -= 1

        if i in bought_point:

            bought = stock

            stock = 0

            money += bought * A[i]

    print(money)

if __name__ == "__main__":

    main()

from bisect import bisect_right

def main():

    N = int(eval(input()))

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

    money = 1000

    stock = 0

    old_trend = 0

    trend = A[1] - A[0]

    buy_point = []

    bought_point = []

    for i in range(N-1):

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

        if trend * old_trend > 0 or trend == 0:

            continue

        else:

            if trend > 0:

                buy_point.append(i)

            if trend < 0:

                bought_point.append(i)

        old_trend = trend

    if len(buy_point) > len(bought_point):

        bought_point.append(N-1)

    for i in range(N):

        if i in buy_point:

            buy = money//A[i]

            stock += buy

            money -= buy*A[i]

        if i in bought_point:

            bought = stock

            stock = 0

            money += bought * A[i]

    print(money)

if __name__ == "__main__":

    main()

from bisect import bisect_right

def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    INF = 10**18
    last_max = A[0]
    last_min = A[0]
    money = 1000
    stock = 0
    old_trend = 0
    trend = A[1] - A[0]
    buy_point = []
    bought_point = []
    for i in range(N - 1):
        trend = A[i + 1] - A[i]
        if trend * old_trend > 0 or trend == 0:
            continue
        else:
            if trend > 0:
                buy_point.append(i)
            if trend < 0:
                bought_point.append(i)
        old_trend = trend
    if len(buy_point) > len(bought_point):
        bought_point.append(N - 1)
    for i in range(N):
        if i in buy_point:
            buy = money // A[i]
            stock += buy
            money -= buy * A[i]
            nx_bought_idx = bisect_right(bought_point, i)
            bought_value = A[nx_bought_idx]
            j = i - 1
            while j >= 0 and money >= 100:
                if A[j] < bought_value and money >= A[i]:
                    money -= A[j]
                    stock += 1
                    break
                j -= 1
        if i in bought_point:
            bought = stock
            stock = 0
            money += bought * A[i]
    print(money)

if __name__ == "__main__":
    main()

from bisect import bisect_right

def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    money = 1000
    stock = 0
    old_trend = 0
    trend = A[1] - A[0]
    buy_point = []
    bought_point = []
    for i in range(N - 1):
        trend = A[i + 1] - A[i]
        if trend * old_trend > 0 or trend == 0:
            continue
        else:
            if trend > 0:
                buy_point.append(i)
            if trend < 0:
                bought_point.append(i)
        old_trend = trend
    if len(buy_point) > len(bought_point):
        bought_point.append(N - 1)
    for i in range(N):
        if i in buy_point:
            buy = money // A[i]
            stock += buy
            money -= buy * A[i]
        if i in bought_point:
            bought = stock
            stock = 0
            money += bought * A[i]
    print(money)

if __name__ == "__main__":
    main()

-            nx_bought_idx = bisect_right(bought_point, i)

-            bought_value = A[nx_bought_idx]

-            while j >= 0 and money >= 100:

-                if A[j] < bought_value and money >= A[i]:


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

area = []

for i in range(h):

    array = eval(input())

    area.append(array)

def check(i, j):

    x_1 = max(0, j-1)

    x_2 = min(j+1, w-1)

    y_1 = max(0, i-1)

    y_2 = min(i+1, h-1)

    if area[y_1][j] == '#' or area[y_2][j] == '#' or area[i][x_1] == '#' or area[i][x_2] == '#':

        a = 0

    else:

        print('No')

        exit()

for i in range(h):

    for j in range(w):

        if area[i][j] == '#':

            check(i, j)

print('Yes')

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

area = []

for i in range(h+2):

    if i == 0 or i == h+1:

        array = '.' * (w+2)

    else:

        array = eval(input())

        array = '.' + array + '.'

    area.append(array)

def check(i, j):

    if area[i][j-1] == '#' or area[i][j+1] == '#' or area[i-1][j] == '#' or area[i+1][j] == '#':

        return True

    else:

        return False

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

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

        if area[i][j] == '#':

            if not check(i, j):

                print('No')

                exit()

print('Yes')

h, w = list(map(int, input().split()))
area = []
for i in range(h):
    array = eval(input())
    area.append(array)

def check(i, j):
    x_1 = max(0, j - 1)
    x_2 = min(j + 1, w - 1)
    y_1 = max(0, i - 1)
    y_2 = min(i + 1, h - 1)
    if (
        area[y_1][j] == "#"
        or area[y_2][j] == "#"
        or area[i][x_1] == "#"
        or area[i][x_2] == "#"
    ):
        a = 0
    else:
        print("No")
        exit()

for i in range(h):
    for j in range(w):
        if area[i][j] == "#":
            check(i, j)
print("Yes")

h, w = list(map(int, input().split()))
area = []
for i in range(h + 2):
    if i == 0 or i == h + 1:
        array = "." * (w + 2)
    else:
        array = eval(input())
        array = "." + array + "."
    area.append(array)

def check(i, j):
    if (
        area[i][j - 1] == "#"
        or area[i][j + 1] == "#"
        or area[i - 1][j] == "#"
        or area[i + 1][j] == "#"
    ):
        return True
    else:
        return False

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if area[i][j] == "#":
            if not check(i, j):
                print("No")
                exit()
print("Yes")

-for i in range(h):
-    array = eval(input())
+for i in range(h + 2):
+    if i == 0 or i == h + 1:
+        array = "." * (w + 2)
+    else:
+        array = eval(input())
+        array = "." + array + "."
-    x_1 = max(0, j - 1)
-    x_2 = min(j + 1, w - 1)
-    y_1 = max(0, i - 1)
-    y_2 = min(i + 1, h - 1)
-        area[y_1][j] == "#"
-        or area[y_2][j] == "#"
-        or area[i][x_1] == "#"
-        or area[i][x_2] == "#"
+        area[i][j - 1] == "#"
+        or area[i][j + 1] == "#"
+        or area[i - 1][j] == "#"
+        or area[i + 1][j] == "#"
-        a = 0
+        return True
-        print("No")
-        exit()
+        return False
-for i in range(h):
-    for j in range(w):
+for i in range(1, h + 1):
+    for j in range(1, w + 1):
-            check(i, j)
+            if not check(i, j):
+                print("No")
+                exit()


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

ans = 0

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

    ns = str(i)

    t = 0

    for j in ns:

        t+= int(j)

    if t >= a and t <= b:

        ans+=i

print(ans)

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

ans = 0

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

    ti = 0

    tmp = i

    while tmp!=0:

        ti += tmp%10

        tmp = tmp//10

    if ti>=a and ti<=b:

        ans+=i

print(ans)

n, a, b = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
    ns = str(i)
    t = 0
    for j in ns:
        t += int(j)
    if t >= a and t <= b:
        ans += i
print(ans)

n, a, b = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
    ti = 0
    tmp = i
    while tmp != 0:
        ti += tmp % 10
        tmp = tmp // 10
    if ti >= a and ti <= b:
        ans += i
print(ans)

-    ns = str(i)
-    t = 0
-    for j in ns:
-        t += int(j)
-    if t >= a and t <= b:
+    ti = 0
+    tmp = i
+    while tmp != 0:
+        ti += tmp % 10
+        tmp = tmp // 10
+    if ti >= a and ti <= b:


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

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

def gcd(x, y):

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

D = []

for a in A:

  D.append(abs(X - a))

answer = 0

for d in D:

  answer = gcd(answer, d)

print(answer)

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

A = list([abs(X - int(x)) for x in input().split()])

def gcd(x, y):

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

answer = 0

for a in A:

  answer = gcd(answer, a)

print(answer)

+A = list([abs(X - int(x)) for x in input().split()])


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

# 標準入力を取得

X = int(eval(input()))

# 求解処理

ans = str()

if X >= 30:

    ans = "Yes"

else:

    ans = "No"

# 結果出力

print(ans)

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

def get_input() -> int:

    """

    標準入力を取得する.

    Returns:\n

        int: 室温

    """

    X = int(eval(input()))

    return X

def main(X: int) -> None:

    """

    メイン処理.

    Args:\n

        X (int): 室温（-40 <= X <= 40, 整数）

    """

    # 求解処理

    ans = str()

    if X >= 30:

        ans = "Yes"

    else:

        ans = "No"

    # 結果出力

    print(ans)

if __name__ == "__main__":

    # 標準入力を取得

    X = get_input()

    # メイン処理

    main(X)

+    標準入力を取得する.

+    # 標準入力を取得

+    # メイン処理


Input:
import re

def revPolish(f):

    f = re.sub(r'(\-?\d+\.?\d*)\s(\-?\d+\.?\d*)\s([\+\-\*/])(?!\d)',

        lambda m: str(eval(m.group(1) + m.group(3) + m.group(2))),

        f)

    if f[-1] in ('+','-','*','/'):

        return revPolish(f)

    else:

        return f

if __name__=='__main__':

    print((revPolish(eval(input()))))

import re

pat = re.compile(r'(\-?\d+\.?\d*)\s(\-?\d+\.?\d*)\s([\+\-\*/])(?!\d)')

def revPolish(f):

    global pat

    f = pat.sub(lambda m: str(eval(m.group(1) + m.group(3) + m.group(2))),f)

    if f[-1] in '+-*/':

        return revPolish(f)

    else:

        return f

print((revPolish(eval(input()))))

import re

def revPolish(f):
    f = re.sub(
        r"(\-?\d+\.?\d*)\s(\-?\d+\.?\d*)\s([\+\-\*/])(?!\d)",
        lambda m: str(eval(m.group(1) + m.group(3) + m.group(2))),
        f,
    )
    if f[-1] in ("+", "-", "*", "/"):
        return revPolish(f)
    else:
        return f

if __name__ == "__main__":
    print((revPolish(eval(input()))))

import re

pat = re.compile(r"(\-?\d+\.?\d*)\s(\-?\d+\.?\d*)\s([\+\-\*/])(?!\d)")

def revPolish(f):
    global pat
    f = pat.sub(lambda m: str(eval(m.group(1) + m.group(3) + m.group(2))), f)
    if f[-1] in "+-*/":
        return revPolish(f)
    else:
        return f

print((revPolish(eval(input()))))

-        lambda m: str(eval(m.group(1) + m.group(3) + m.group(2))),

+    f = pat.sub(lambda m: str(eval(m.group(1) + m.group(3) + m.group(2))), f)


Input:
n=int(eval(input()));

ans=0;

p=[0]*22222;

for w,s,v in sorted([list(map(int,input().split()))for _ in[0]*n],key=lambda a:a[0]+a[1]):

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

  p[j+w]=max(p[j+w],p[j]+v);

  ans=max(ans,p[j+w]);

print(ans)

p=[0]*6**6

for w,s,v in sorted([list(map(int,input().split()))for _ in[0]*int(eval(input()))],key=lambda a:a[0]+a[1]):

 for j in range(s,-1,-1):p[j+w]=max(p[j+w],p[j]+v)

print((max(p)))

n = int(eval(input()))
ans = 0
p = [0] * 22222
for w, s, v in sorted(
    [list(map(int, input().split())) for _ in [0] * n], key=lambda a: a[0] + a[1]
):
    for j in range(s, -1, -1):
        p[j + w] = max(p[j + w], p[j] + v)
        ans = max(ans, p[j + w])
print(ans)

p = [0] * 6**6
for w, s, v in sorted(
    [list(map(int, input().split())) for _ in [0] * int(eval(input()))],
    key=lambda a: a[0] + a[1],
):
    for j in range(s, -1, -1):
        p[j + w] = max(p[j + w], p[j] + v)
print((max(p)))

-    [list(map(int, input().split())) for _ in [0] * n], key=lambda a: a[0] + a[1]

+    [list(map(int, input().split())) for _ in [0] * int(eval(input()))],


Input:
import sys

sys.setrecursionlimit(4000)

n = int(eval(input()))

p = [float(x) for x in input().split()]

dp = [[0]*(n+1) for i in range(n)]

dp[0][0] = 1-p[0]

dp[0][1] = p[0]

for i in range(n-1):

  for j in range(i+2):

    dp[i+1][j] += dp[i][j]*(1-p[i+1])

    dp[i+1][j+1] += dp[i][j]*p[i+1]

ans = 0

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

  ans += dp[n-1][i]

print(ans)

n = int(eval(input()))

p = [float(x) for x in input().split()]

dp = [[0]*(i+2) for i in range(n)]

dp[0][0] = 1-p[0]

dp[0][1] = p[0]

for i in range(1, n):

  for j in range(i+2):

    if j == 0:

      dp[i][j] = dp[i-1][j]*(1-p[i])

      continue

    if j == i+1:

      dp[i][j] = dp[i-1][j-1]*p[i]

      continue

    dp[i][j] = dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i])

ans = 0

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

  ans += dp[n-1][i]

print(ans)

import sys

sys.setrecursionlimit(4000)
n = int(eval(input()))
p = [float(x) for x in input().split()]
dp = [[0] * (n + 1) for i in range(n)]
dp[0][0] = 1 - p[0]
dp[0][1] = p[0]
for i in range(n - 1):
    for j in range(i + 2):
        dp[i + 1][j] += dp[i][j] * (1 - p[i + 1])
        dp[i + 1][j + 1] += dp[i][j] * p[i + 1]
ans = 0
for i in range(n // 2 + 1, n + 1):
    ans += dp[n - 1][i]
print(ans)

n = int(eval(input()))
p = [float(x) for x in input().split()]
dp = [[0] * (i + 2) for i in range(n)]
dp[0][0] = 1 - p[0]
dp[0][1] = p[0]
for i in range(1, n):
    for j in range(i + 2):
        if j == 0:
            dp[i][j] = dp[i - 1][j] * (1 - p[i])
            continue
        if j == i + 1:
            dp[i][j] = dp[i - 1][j - 1] * p[i]
            continue
        dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i])
ans = 0
for i in range(n // 2 + 1, n + 1):
    ans += dp[n - 1][i]
print(ans)


Input:
N = int(eval(input()))

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

visited = [0]*N

visited[0],visited[N-1] = 1,1

visited_all = [1]*N

for i in range(N-1):

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

    G[a-1].append(b-1)

    G[b-1].append(a-1)

nextA,nextB = G[0],G[N-1]

scoreA,scoreB = 1,1

while visited != visited_all:

    l = []

    for a in nextA:

        if visited[a] == 0:

            visited[a] = 1

            scoreA += 1

            for x in G[a]:

                l.append(x)

    nextA = l

    l = []

    for b in nextB:

        if visited[b] == 0:

            visited[b] = 1

            scoreB += 1

            for x in G[b]:

                l.append(x)

    nextB = l

print(("Fennec" if scoreA > scoreB else "Snuke"))

N = int(eval(input()))

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

for i in range(N-1):

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

    A[a-1].append(b-1)

    A[b-1].append(a-1)

B = [False]*N

visited = [True]*N

Fp,Sp = 0,0

Fi,Si = [0],[N-1]

while B != visited:

    # Fennec

    nextXi = []

    for i in Fi:

        if not B[i]:

            B[i] = True

            Fp += 1

            nextXi.extend(A[i])

    Fi = nextXi

    # Snuke

    nextXi = []

    for i in Si:

        if not B[i]:

            B[i] = True

            Sp += 1

            nextXi.extend(A[i])

    Si = nextXi

print(("Fennec" if Fp>Sp else "Snuke"))

N = int(eval(input()))
G = [[] for _ in range(N)]
visited = [0] * N
visited[0], visited[N - 1] = 1, 1
visited_all = [1] * N
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
nextA, nextB = G[0], G[N - 1]
scoreA, scoreB = 1, 1
while visited != visited_all:
    l = []
    for a in nextA:
        if visited[a] == 0:
            visited[a] = 1
            scoreA += 1
            for x in G[a]:
                l.append(x)
    nextA = l
    l = []
    for b in nextB:
        if visited[b] == 0:
            visited[b] = 1
            scoreB += 1
            for x in G[b]:
                l.append(x)
    nextB = l
print(("Fennec" if scoreA > scoreB else "Snuke"))

N = int(eval(input()))
A = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    A[a - 1].append(b - 1)
    A[b - 1].append(a - 1)
B = [False] * N
visited = [True] * N
Fp, Sp = 0, 0
Fi, Si = [0], [N - 1]
while B != visited:
    # Fennec
    nextXi = []
    for i in Fi:
        if not B[i]:
            B[i] = True
            Fp += 1
            nextXi.extend(A[i])
    Fi = nextXi
    # Snuke
    nextXi = []
    for i in Si:
        if not B[i]:
            B[i] = True
            Sp += 1
            nextXi.extend(A[i])
    Si = nextXi
print(("Fennec" if Fp > Sp else "Snuke"))

-print(("Fennec" if scoreA > scoreB else "Snuke"))

+print(("Fennec" if Fp > Sp else "Snuke"))


Input:
import sys

def input():

    return sys.stdin.readline()[:-1]

x=int(eval(input()))

while 1:

    flag=0

    for i in range(2,int(x**(1/2))):

        if x%i==0:

            flag=1

            break

    if flag==0:

        break

    x+=1

print(x)

import bisect, copy, heapq, math, sys

from collections import *

from functools import lru_cache

from itertools import accumulate, combinations, permutations, product

def input():

    return sys.stdin.readline()[:-1]

def ruiseki(lst):

    return [0]+list(accumulate(lst))

def celi(a,b):

    return -(-a//b)

sys.setrecursionlimit(5000000)

mod=pow(10,9)+7

al=[chr(ord('a') + i) for i in range(26)]

direction=[[1,0],[0,1],[-1,0],[0,-1]]

x=int(eval(input()))

def is_prime(n):

    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):

        if n % k == 0:

            return False

    return True

ans=x

while not is_prime(ans):

    ans+=1

print(ans)

import sys

def input():
    return sys.stdin.readline()[:-1]

x = int(eval(input()))
while 1:
    flag = 0
    for i in range(2, int(x ** (1 / 2))):
        if x % i == 0:
            flag = 1
            break
    if flag == 0:
        break
    x += 1
print(x)

import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product

def input():
    return sys.stdin.readline()[:-1]

def ruiseki(lst):
    return [0] + list(accumulate(lst))

def celi(a, b):
    return -(-a // b)

sys.setrecursionlimit(5000000)
mod = pow(10, 9) + 7
al = [chr(ord("a") + i) for i in range(26)]
direction = [[1, 0], [0, 1], [-1, 0], [0, -1]]
x = int(eval(input()))

def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

ans = x
while not is_prime(ans):
    ans += 1
print(ans)

+from itertools import accumulate, combinations, permutations, product

+al = [chr(ord("a") + i) for i in range(26)]

-    for i in range(2, int(x ** (1 / 2))):

+    for k in range(2, int(math.sqrt(n)) + 1):


Input:
import numpy as np

def count(n,s):

    if s == 0:

        return 3**n - 3*(2**n) + 3

    elif s == 1:

        return 3**n - 2**(n+1) + 1

    elif s == 2:

        return 3**n - 2**n

    else:

        return 3**n

def num753(Nlist, appeared):

    n = len(Nlist)

    if n == 0:

        if appeared == 7:

            return 1

        else:

            return 0

    top = Nlist[-1]

    ap3 = appeared|1

    s3 = ap3 % 2 + (ap3 % 4)//2 + ap3 // 4

    ap5 = appeared|2

    s5 = ap5 % 2 + (ap5 % 4)//2 + ap5 // 4

    ap7 = appeared|4

    s7 = ap7 % 2 + (ap7 % 4)//2 + ap7 // 4

    if appeared == 0:

        ans = sum([count(i,0) for i in range(3,n)])

    else:

        ans = 0

    if top < 3:

        pass

    elif top == 3:

        ans = ans + num753(Nlist[:-1],ap3)

    elif top == 4:

        ans = ans + count(n-1,s3)

    elif top == 5:

        ans = ans + count(n-1,s3) + num753(Nlist[:-1],ap5)

    elif top == 6:

        ans = ans + count(n-1,s3) + count(n-1,s5)

    elif top == 7:

        ans = ans + count(n-1,s3) + count(n-1,s5) + num753(Nlist[:-1],ap7)

    else: # top == 8,9

        ans = ans + count(n-1,s3) + count(n-1,s5) + count(n-1,s7)

    return ans

N = int(eval(input()))

Nlist=[]

while N > 0:

    Nlist.append(N % 10)

    N = N // 10

Nlist = np.array(Nlist,dtype=np.int)

print((num753(Nlist,0)))

import numpy as np

def list753(n):

    if n == 1:

        return np.array([3,5,7],dtype=np.int)

    else:

        prev = list753(n-1)

        return np.concatenate((10*prev+3,10*prev+5,10*prev+7))

def all_list753(n):

    return np.concatenate(tuple([list753(i) for i in range(1,n+1)]))

Nstr = eval(input())

N = int(Nstr)

Nlen = len(Nstr)

candidates = all_list753(Nlen)

ans = 0

for c in candidates:

    if c > N:

        continue

    cstr = str(c)

    if '3' in cstr and '5' in cstr and '7' in cstr:

        ans += 1

print(ans)

import numpy as np

def count(n, s):
    if s == 0:
        return 3**n - 3 * (2**n) + 3
    elif s == 1:
        return 3**n - 2 ** (n + 1) + 1
    elif s == 2:
        return 3**n - 2**n
    else:
        return 3**n

def num753(Nlist, appeared):
    n = len(Nlist)
    if n == 0:
        if appeared == 7:
            return 1
        else:
            return 0
    top = Nlist[-1]
    ap3 = appeared | 1
    s3 = ap3 % 2 + (ap3 % 4) // 2 + ap3 // 4
    ap5 = appeared | 2
    s5 = ap5 % 2 + (ap5 % 4) // 2 + ap5 // 4
    ap7 = appeared | 4
    s7 = ap7 % 2 + (ap7 % 4) // 2 + ap7 // 4
    if appeared == 0:
        ans = sum([count(i, 0) for i in range(3, n)])
    else:
        ans = 0
    if top < 3:
        pass
    elif top == 3:
        ans = ans + num753(Nlist[:-1], ap3)
    elif top == 4:
        ans = ans + count(n - 1, s3)
    elif top == 5:
        ans = ans + count(n - 1, s3) + num753(Nlist[:-1], ap5)
    elif top == 6:
        ans = ans + count(n - 1, s3) + count(n - 1, s5)
    elif top == 7:
        ans = ans + count(n - 1, s3) + count(n - 1, s5) + num753(Nlist[:-1], ap7)
    else:  # top == 8,9
        ans = ans + count(n - 1, s3) + count(n - 1, s5) + count(n - 1, s7)
    return ans

N = int(eval(input()))
Nlist = []
while N > 0:
    Nlist.append(N % 10)
    N = N // 10
Nlist = np.array(Nlist, dtype=np.int)
print((num753(Nlist, 0)))

import numpy as np

def list753(n):
    if n == 1:
        return np.array([3, 5, 7], dtype=np.int)
    else:
        prev = list753(n - 1)
        return np.concatenate((10 * prev + 3, 10 * prev + 5, 10 * prev + 7))

def all_list753(n):
    return np.concatenate(tuple([list753(i) for i in range(1, n + 1)]))

Nstr = eval(input())
N = int(Nstr)
Nlen = len(Nstr)
candidates = all_list753(Nlen)
ans = 0
for c in candidates:
    if c > N:
        continue
    cstr = str(c)
    if "3" in cstr and "5" in cstr and "7" in cstr:
        ans += 1
print(ans)

+        return np.array([3, 5, 7], dtype=np.int)

+        return np.concatenate((10 * prev + 3, 10 * prev + 5, 10 * prev + 7))

-        ans = sum([count(i, 0) for i in range(3, n)])

-        ans = ans + num753(Nlist[:-1], ap3)

-        ans = ans + count(n - 1, s3) + num753(Nlist[:-1], ap5)

-        ans = ans + count(n - 1, s3) + count(n - 1, s5) + num753(Nlist[:-1], ap7)

-        ans = ans + count(n - 1, s3) + count(n - 1, s5) + count(n - 1, s7)

+    return np.concatenate(tuple([list753(i) for i in range(1, n + 1)]))

+    if "3" in cstr and "5" in cstr and "7" in cstr:


Input:
N = int(eval(input()))

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

a = list(p)

b = list(p)

c = 0

for i in range(N):

    if i+1 == a[i] and i == N-1:

        c += 1

    elif i+1 == a[i]:

        a[i], a[i+1] = a[i+1], a[i]

        c += 1

cc = 0

for i in range(N)[::-1]:

    if i+1 == b[i] and i == 0:

        cc += 1

    if i+1 == b[i]:

        b[i], b[i-1] = b[i-1], b[i]

        cc += 1

print((min(c,cc)))

N = int(eval(input()))

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

a = list(p)

b = list(p)

c = 0

for i in range(N):

    if i+1 == a[i] and i == N-1:

        c += 1

    elif i+1 == a[i]:

        a[i], a[i+1] = a[i+1], a[i]

        c += 1

cc = 0

for i in range(N)[::-1]:

    if i+1 == b[i] and i == 0:

        cc += 1

    elif i+1 == b[i]:

        b[i], b[i-1] = b[i-1], b[i]

        cc += 1

print((min(c,cc)))

N = int(eval(input()))
p = tuple(map(int, input().split()))
a = list(p)
b = list(p)
c = 0
for i in range(N):
    if i + 1 == a[i] and i == N - 1:
        c += 1
    elif i + 1 == a[i]:
        a[i], a[i + 1] = a[i + 1], a[i]
        c += 1
cc = 0
for i in range(N)[::-1]:
    if i + 1 == b[i] and i == 0:
        cc += 1
    if i + 1 == b[i]:
        b[i], b[i - 1] = b[i - 1], b[i]
        cc += 1
print((min(c, cc)))

N = int(eval(input()))
p = tuple(map(int, input().split()))
a = list(p)
b = list(p)
c = 0
for i in range(N):
    if i + 1 == a[i] and i == N - 1:
        c += 1
    elif i + 1 == a[i]:
        a[i], a[i + 1] = a[i + 1], a[i]
        c += 1
cc = 0
for i in range(N)[::-1]:
    if i + 1 == b[i] and i == 0:
        cc += 1
    elif i + 1 == b[i]:
        b[i], b[i - 1] = b[i - 1], b[i]
        cc += 1
print((min(c, cc)))


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

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

t = str(eval(input()))

ans = 0

te = ["" for _ in range(n)]

for i in range(n):

	if t[i] == "r" and te[i - k] != "p":

		ans += p

		te[i] = "p"

	elif t[i] == "s" and te[i - k] != "r":

		ans += r

		te[i] = "r"

	elif t[i] == "p" and te[i - k] != "s":

		ans += s

		te[i] = "s"

print(ans)

import sys

sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7

def resolve():

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

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

    t = list(eval(input()))

    res = 0

    for i in range(n):

        if i < k:

            res += p if t[i] == "r" else r if t[i] == "s" else s

        else:

            if t[i - k] != t[i]:

                res += p if t[i] == "r" else r if t[i] == "s" else s

            else:

                t[i] = "e"

    print(res)

if __name__ == '__main__':

    resolve()

import sys

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

def resolve():
    n, k = list(map(int, input().split()))
    r, s, p = list(map(int, input().split()))
    t = list(eval(input()))
    res = 0
    for i in range(n):
        if i < k:
            res += p if t[i] == "r" else r if t[i] == "s" else s
        else:
            if t[i - k] != t[i]:
                res += p if t[i] == "r" else r if t[i] == "s" else s
            else:
                t[i] = "e"
    print(res)

if __name__ == "__main__":
    resolve()

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

-    elif t[i] == "s" and te[i - k] != "r":

-    elif t[i] == "p" and te[i - k] != "s":

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

+    r, s, p = list(map(int, input().split()))

+            res += p if t[i] == "r" else r if t[i] == "s" else s


Input:
# https://atcoder.jp/contests/abc052/tasks/arc067_b

# 歩いたほうが良いのかテレポートしたほうが良いのか貪欲に選択していくだけでは？

import sys

read = sys.stdin.readline

def read_ints():

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

import numpy as np

N, A, B = read_ints()

X = read_ints()

# 面倒なのでnumpy芸してええか？

X_diff = np.diff(X)

ans = 0

for d in X_diff:

    ans += min(B, d * A)

print(ans)

# https://atcoder.jp/contests/abc052/tasks/arc067_b

# 歩いたほうが良いのかテレポートしたほうが良いのか貪欲に選択していくだけでは？

import sys

read = sys.stdin.readline

def read_ints():

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

N, A, B = read_ints()

X = read_ints()

# 面倒なのでnumpy芸してええか？

X_diff = [x-y for x,y in zip(X[1:],X[:-1])]

ans = 0

for d in X_diff:

    ans += min(B, d * A)

print(ans)

# https://atcoder.jp/contests/abc052/tasks/arc067_b
# 歩いたほうが良いのかテレポートしたほうが良いのか貪欲に選択していくだけでは？
import sys

read = sys.stdin.readline

def read_ints():
    return list(map(int, read().split()))

N, A, B = read_ints()
X = read_ints()
# 面倒なのでnumpy芸してええか？
X_diff = [x - y for x, y in zip(X[1:], X[:-1])]
ans = 0
for d in X_diff:
    ans += min(B, d * A)
print(ans)

+X_diff = [x - y for x, y in zip(X[1:], X[:-1])]


Input:
# ABC099C - Minimization

from math import ceil

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

_ = list(map(int, input().rstrip().split()))

print((1 + ceil((N - K) / (K - 1))))

# ARC099C - Minimization

from math import ceil

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

print((1 + ceil((N - K) / (K - 1))))

-_ = list(map(int, input().rstrip().split()))


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

ans = 0

for i in range(n+1):

    keta_wa = 0

    x = i

    while x != 0:

        keta_wa += int(x % 10)

        x /= 10

        #print(keta_wa,x)

    if a <= keta_wa <= b:

        ans += i

print(ans)

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

ans = 0

for i in range(n+1):

    keta_wa = 0

    x = i

    while x != 0:

        keta_wa += int(x % 10)

        x = int(x /10)

        #print(keta_wa,x)

    if a <= keta_wa <= b:

        ans += i

print(ans)

n, a, b = list(map(int, input().split()))
ans = 0
for i in range(n + 1):
    keta_wa = 0
    x = i
    while x != 0:
        keta_wa += int(x % 10)
        x /= 10
        # print(keta_wa,x)
    if a <= keta_wa <= b:
        ans += i
print(ans)

n, a, b = list(map(int, input().split()))
ans = 0
for i in range(n + 1):
    keta_wa = 0
    x = i
    while x != 0:
        keta_wa += int(x % 10)
        x = int(x / 10)
        # print(keta_wa,x)
    if a <= keta_wa <= b:
        ans += i
print(ans)


Input:
n = int(eval(input()))

D = set(int(eval(input())) for _ in range(n))

print((len(D)))

n = int(eval(input()))

print((len(set(eval(input()) for _ in range(n)))))

-D = set(int(eval(input())) for _ in range(n))

+print((len(set(eval(input()) for _ in range(n)))))


Input:
import numpy as np

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

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

dp = np.full(N,10**10)

dp[0] = 0

for i in range(1,N):

    start = max(0,i-K)

    dp[i] = np.min(dp[start:i]+np.abs(h[i]-h[start:i]))

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

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

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

INF = float('inf')

dp = [INF] * (N)

dp[0] = 0

for i in range(1,N):

    cost = INF

    for j in range(max(0,i-K),i):

        # print(h[j],':',h[i])

        dp[i] = min(dp[i], dp[j]+abs(h[j]-h[i]))

    # print(dp)

print((dp[-1]))

import numpy as np

N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split())))
dp = np.full(N, 10**10)
dp[0] = 0
for i in range(1, N):
    start = max(0, i - K)
    dp[i] = np.min(dp[start:i] + np.abs(h[i] - h[start:i]))
print((int(dp[-1])))

N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
INF = float("inf")
dp = [INF] * (N)
dp[0] = 0
for i in range(1, N):
    cost = INF
    for j in range(max(0, i - K), i):
        # print(h[j],':',h[i])
        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]))
    # print(dp)
print((dp[-1]))

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

-    dp[i] = np.min(dp[start:i] + np.abs(h[i] - h[start:i]))

+        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]))


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

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

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

for x in alis:

    lis.append([1,x])

lis.sort(reverse=True,key=lambda x:x[1])

ans = 0

for x in lis:

    (number,point) = x

    if number >= n:

        number = n

        ans += number * point

        #print(n)

        #print(ans,'+=',number,'*',point)

        break

    ans += number * point

    n -= number

    #print(n)

    #print(ans,'+=',number,'*',point)

print(ans)

#print(lis)

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

alis = sorted(list(map(int,input().split())))

BC = []

clis = []

for x in range(m):

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

    BC.append((b,c))

BC = sorted(BC,reverse=True,key=lambda x:x[1])

bk_flg = 1

for b,c in BC:

    for x in range(b):

        if len(clis) > n:

            bk_flg = 0

            break

        clis.append(c)

    if bk_flg == 0:break;

for i in range(min(len(clis),n)):

    if alis[i] < clis[i]:

        alis[i] = clis[i]

print((sum(alis)))

n, m = list(map(int, input().split()))
alis = list(map(int, input().split()))
lis = [list(map(int, input().split())) for x in range(m)]
for x in alis:
    lis.append([1, x])
lis.sort(reverse=True, key=lambda x: x[1])
ans = 0
for x in lis:
    (number, point) = x
    if number >= n:
        number = n
        ans += number * point
        # print(n)
        # print(ans,'+=',number,'*',point)
        break
    ans += number * point
    n -= number
    # print(n)
    # print(ans,'+=',number,'*',point)
print(ans)
# print(lis)

n, m = list(map(int, input().split()))
alis = sorted(list(map(int, input().split())))
BC = []
clis = []
for x in range(m):
    b, c = list(map(int, input().split()))
    BC.append((b, c))
BC = sorted(BC, reverse=True, key=lambda x: x[1])
bk_flg = 1
for b, c in BC:
    for x in range(b):
        if len(clis) > n:
            bk_flg = 0
            break
        clis.append(c)
    if bk_flg == 0:
        break
for i in range(min(len(clis), n)):
    if alis[i] < clis[i]:
        alis[i] = clis[i]
print((sum(alis)))

-lis = [list(map(int, input().split())) for x in range(m)]

-lis.sort(reverse=True, key=lambda x: x[1])

-        # print(ans,'+=',number,'*',point)

+alis = sorted(list(map(int, input().split())))

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

+BC = sorted(BC, reverse=True, key=lambda x: x[1])


Input:
import bisect

N = int(eval(input()))

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

L = [A[0]]

for a in A[1:]:

    if L[-1] < a:

        L.append(a)

    else:

        L[bisect.bisect_left(L, a)] = a

print((len(L)))

import bisect

a = int(eval(input()))

b = [int(eval(input())) for d in range(a)]

c = [b[0]]

for i in b[1:]:

    if c[-1] < i:

        c.append(i)

    else:

        c[bisect.bisect_left(c,i)] = i

print((len(c)))

import bisect

a = int(eval(input()))
b = [int(eval(input())) for d in range(a)]
c = [b[0]]
for i in b[1:]:
    if c[-1] < i:
        c.append(i)
    else:
        c[bisect.bisect_left(c, i)] = i
print((len(c)))

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

+b = [int(eval(input())) for d in range(a)]

-        L[bisect.bisect_left(L, a)] = a

+        c[bisect.bisect_left(c, i)] = i


Input:
# UnionFindでつなげていく

# [所属する木の頂点数]-[1（自分）]-[自分とブロック関係にある人の数]

# UnionFind

class UnionFind():

    def __init__(self, n):

        self.n = n

        self.parents = [-1] * n

    def find(self, x):

        if self.parents[x] < 0:

            return x

        else:

            self.parents[x] = self.find(self.parents[x])

            return self.parents[x]

    def union(self, x, y):

        x = self.find(x)

        y = self.find(y)

        if x == y:

            return

        if self.parents[x] > self.parents[y]:

            x, y = y, x

        self.parents[x] += self.parents[y]

        self.parents[y] = x

    def size(self, x):

        return -self.parents[self.find(x)]

    def same(self, x, y):

        return self.find(x) == self.find(y)

    def members(self, x):

        root = self.find(x)

        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):

        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):

        return len(self.roots())

    def all_group_members(self):

        return {r: self.members(r) for r in self.roots()}

    def __str__(self):

        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def show_parents(self):

      print((self.parents))

# ここまでUnionFind

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

UF=UnionFind(N)

from collections import defaultdict

dic=defaultdict(set)

friends=[0]*N

for i in range(M):

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

  UF.union(a-1,b-1)

  friends[a-1]+=1

  friends[b-1]+=1

for i in range(N):

  dic[UF.find(i)].add(i)

block=defaultdict(set)

for i in range(K):

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

  block[c-1].add(d-1)

  block[d-1].add(c-1)

# UF.show_parents()

# 同じ木に所属する人数のうち、ブロック関係にない人数

ans=[0]*N

for i in range(N):

  candi=dic[UF.find(i)]

  #print("i",candi,"block",block[i])

  ans[i]=len(candi)-friends[i]-1

  for b in block[i]:

    if UF.same(i,b):

      ans[i]-=1

  if ans[i]<0:

    ans[i]=0

print((*ans))

import sys

read=sys.stdin.buffer.read

readline=sys.stdin.readline

readlines=sys.stdin.buffer.readlines

# 0-indexed

class UnionFind:

  N=0

  parent=None

  size=None

  def __init__(self,N):

    self.N=N

    self.parent=[i for i in range(self.N)]

    self.size=[1]*self.N

  def root(self,x):

    while x!=self.parent[x]:

      self.parent[x]=self.parent[self.parent[x]]

      x=self.parent[x]

    return x

  def same(self,x,y):

    return self.root(x)==self.root(y)

  def unite(self,x,y):

    x=self.root(x)

    y=self.root(y)

    if x==y:

      return

    if self.size[x]>self.size[y]:

      # 大きい方にくっつける

      self.parent[y]=x

      self.size[x]+=self.size[y]

    else:

      self.parent[x]=y

      self.size[y]+=self.size[x]

  def get_group_size(self,x):

    return self.size[self.root(x)]

  def get_roots(self):

    r=set()

    for i in range(self.N):

      r.add(root(i))

    return r

  def show_parent(self):

    print((self.parent))

  def show_size(self):

    print((self.size))

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

UF=UnionFind(N)

friends=[0]*N

for i in range(M):

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

  UF.unite(a-1,b-1)

  friends[a-1]+=1

  friends[b-1]+=1

from collections import defaultdict

block=defaultdict(set)

for i in range(K):

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

  block[c-1].add(d-1)

  block[d-1].add(c-1)

ans=[0]*N

for i in range(N):

  ans[i]=UF.get_group_size(i)-friends[i]-1

  for b in block[i]:

    if UF.same(i,b):

      ans[i]-=1

  if ans[i]<0:

    ans[i]=0

print((*ans))

# UnionFindでつなげていく
# [所属する木の頂点数]-[1（自分）]-[自分とブロック関係にある人の数]
# UnionFind
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())

    def show_parents(self):
        print((self.parents))

# ここまでUnionFind
N, M, K = list(map(int, input().split()))
UF = UnionFind(N)
from collections import defaultdict

dic = defaultdict(set)
friends = [0] * N
for i in range(M):
    a, b = list(map(int, input().split()))
    UF.union(a - 1, b - 1)
    friends[a - 1] += 1
    friends[b - 1] += 1
for i in range(N):
    dic[UF.find(i)].add(i)
block = defaultdict(set)
for i in range(K):
    c, d = list(map(int, input().split()))
    block[c - 1].add(d - 1)
    block[d - 1].add(c - 1)
# UF.show_parents()
# 同じ木に所属する人数のうち、ブロック関係にない人数
ans = [0] * N
for i in range(N):
    candi = dic[UF.find(i)]
    # print("i",candi,"block",block[i])
    ans[i] = len(candi) - friends[i] - 1
    for b in block[i]:
        if UF.same(i, b):
            ans[i] -= 1
    if ans[i] < 0:
        ans[i] = 0
print((*ans))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
# 0-indexed
class UnionFind:
    N = 0
    parent = None
    size = None

    def __init__(self, N):
        self.N = N
        self.parent = [i for i in range(self.N)]
        self.size = [1] * self.N

    def root(self, x):
        while x != self.parent[x]:
            self.parent[x] = self.parent[self.parent[x]]
            x = self.parent[x]
        return x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.size[x] > self.size[y]:
            # 大きい方にくっつける
            self.parent[y] = x
            self.size[x] += self.size[y]
        else:
            self.parent[x] = y
            self.size[y] += self.size[x]

    def get_group_size(self, x):
        return self.size[self.root(x)]

    def get_roots(self):
        r = set()
        for i in range(self.N):
            r.add(root(i))
        return r

    def show_parent(self):
        print((self.parent))

    def show_size(self):
        print((self.size))

N, M, K = list(map(int, readline().split()))
UF = UnionFind(N)
friends = [0] * N
for i in range(M):
    a, b = list(map(int, readline().split()))
    UF.unite(a - 1, b - 1)
    friends[a - 1] += 1
    friends[b - 1] += 1
from collections import defaultdict

block = defaultdict(set)
for i in range(K):
    c, d = list(map(int, readline().split()))
    block[c - 1].add(d - 1)
    block[d - 1].add(c - 1)
ans = [0] * N
for i in range(N):
    ans[i] = UF.get_group_size(i) - friends[i] - 1
    for b in block[i]:
        if UF.same(i, b):
            ans[i] -= 1
    if ans[i] < 0:
        ans[i] = 0
print((*ans))

-# [所属する木の頂点数]-[1（自分）]-[自分とブロック関係にある人の数]

-            self.parents[x] = self.find(self.parents[x])

+        self.parent = [i for i in range(self.N)]

+            self.parent[x] = self.parent[self.parent[x]]

+        return self.root(x) == self.root(y)

-        if self.parents[x] > self.parents[y]:

-        self.parents[x] += self.parents[y]

+        if self.size[x] > self.size[y]:

+            # 大きい方にくっつける

+            self.size[x] += self.size[y]

+            self.size[y] += self.size[x]

-        return -self.parents[self.find(x)]

-        return self.find(x) == self.find(y)

-        return [i for i in range(self.n) if self.find(i) == root]

-        return [i for i, x in enumerate(self.parents) if x < 0]

-        return {r: self.members(r) for r in self.roots()}

-        return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())

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

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

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

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

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

+    c, d = list(map(int, readline().split()))

-# 同じ木に所属する人数のうち、ブロック関係にない人数

-    # print("i",candi,"block",block[i])

-    ans[i] = len(candi) - friends[i] - 1

+    ans[i] = UF.get_group_size(i) - friends[i] - 1


Input:
n=int(eval(input()))

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

dp=[[float("inf")]*(n+1) for _ in range(n)]

z=0

for l in range(n):

    dp[l][l]=0

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

    for i in range(n):

        j=i+k

        if 0<=i<=n-2 and 1<=j<=n:

            if (n-(i+j))%2==0: #先手

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

            else:

                dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1])

        elif 0<=i<=n-2 and 0<=j<=n:

            dp[i][j]=dp[i+1][j]+a[i]

        elif 0<=i<=n-1 and 1<=j<=n:

            dp[i][j]=dp[i][j-1]+a[j-1]

        else:

            z=1

print((dp[0][n]))

n=int(eval(input()))

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

dp=[[float("inf")]*(n+1) for _ in range(n)]

z=0

for l in range(n):

    dp[l][l]=0

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

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

        j=i+k

        if 0<=i<=n-2 and 1<=j<=n:

            if (n-(i+j))%2==0: #先手

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

            else:

                dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1])

        else:

            dp[i][j]=dp[i][j-1]+a[j-1]

print((dp[0][n]))

n = int(eval(input()))
a = list(map(int, input().split()))
dp = [[float("inf")] * (n + 1) for _ in range(n)]
z = 0
for l in range(n):
    dp[l][l] = 0
for k in range(1, n + 1):
    for i in range(n):
        j = i + k
        if 0 <= i <= n - 2 and 1 <= j <= n:
            if (n - (i + j)) % 2 == 0:  # 先手
                dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1])
            else:
                dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1])
        elif 0 <= i <= n - 2 and 0 <= j <= n:
            dp[i][j] = dp[i + 1][j] + a[i]
        elif 0 <= i <= n - 1 and 1 <= j <= n:
            dp[i][j] = dp[i][j - 1] + a[j - 1]
        else:
            z = 1
print((dp[0][n]))

n = int(eval(input()))
a = list(map(int, input().split()))
dp = [[float("inf")] * (n + 1) for _ in range(n)]
z = 0
for l in range(n):
    dp[l][l] = 0
for k in range(1, n + 1):
    for i in range(n - k + 1):
        j = i + k
        if 0 <= i <= n - 2 and 1 <= j <= n:
            if (n - (i + j)) % 2 == 0:  # 先手
                dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1])
            else:
                dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1])
        else:
            dp[i][j] = dp[i][j - 1] + a[j - 1]
print((dp[0][n]))


Input:
ch = eval(input())

print(('A' if 65<=ord(ch)<=91 else 'a'))

print(('A' if 65<=ord(eval(input()))<=91 else 'a'))

ch = eval(input())
print(("A" if 65 <= ord(ch) <= 91 else "a"))

+print(("A" if 65 <= ord(eval(input())) <= 91 else "a"))


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

anser = a * b

print(anser)

# 入力をプログラムで扱えるように受け取ること

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

# print(a, b)

# 受け取った入力値を使い、適切に処理（計算）する

answer = a * b

# 計算した結果を出力する

print(answer)

+# 入力をプログラムで扱えるように受け取ること
-anser = a * b
-print(anser)
+# print(a, b)
+# 受け取った入力値を使い、適切に処理（計算）する
+answer = a * b
+# 計算した結果を出力する
+print(answer)


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

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

print((sum(n[:y])))

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

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

a.sort()

print((sum(a[:k])))

x, y = list(map(int, input().split()))
n = sorted(list(map(int, input().split())))
print((sum(n[:y])))

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
print((sum(a[:k])))

-n = sorted(list(map(int, input().split())))


Input:
def io_tmp():

    global input

    import io, sys

    f = io.StringIO(open(0).read())

    input = f.readline

io_tmp()

from scipy.sparse.csgraph import floyd_warshall

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

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

for _ in range(M):

    s, t, w = list(map(int, input().split()))

    graph[s-1][t-1] = graph[t-1][s-1] = w

dist = floyd_warshall(graph, directed=False)

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

for i in range(N):

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

        if dist[i][j] <= L:

            graph[i][j] = graph[i][j] = 1

dist = floyd_warshall(graph, directed=False)

Q = int(eval(input()))

for _ in range(Q):

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

    ans = dist[s-1][t-1]

    if ans == float("inf"):

        print((-1))

    else:

        print((int(ans - 1)))

def io_tmp():

    global input

    import io

    f = io.StringIO(open(0).read())

    input = f.readline

io_tmp()

from scipy.sparse.csgraph import floyd_warshall

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

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

for _ in range(M):

    s, t, w = map(int, input().split())

    graph[s-1][t-1] = graph[t-1][s-1] = w

dist = floyd_warshall(graph, directed=False)

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

for i in range(N):

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

        if dist[i][j] <= L:

            graph[i][j] = graph[i][j] = 1

dist = floyd_warshall(graph, directed=False)

Q = int(input())

ans = []

for _ in range(Q):

    s, t = map(int, input().split())

    d = dist[s-1][t-1]

    if d == float("inf"):

        ans.append(-1)

    else:

        ans.append(int(d - 1))

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

def io_tmp():
    global input
    import io, sys

    f = io.StringIO(open(0).read())
    input = f.readline

io_tmp()
from scipy.sparse.csgraph import floyd_warshall

N, M, L = list(map(int, input().split()))
graph = [[0] * N for _ in range(N)]
for _ in range(M):
    s, t, w = list(map(int, input().split()))
    graph[s - 1][t - 1] = graph[t - 1][s - 1] = w
dist = floyd_warshall(graph, directed=False)
graph = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(i + 1, N):
        if dist[i][j] <= L:
            graph[i][j] = graph[i][j] = 1
dist = floyd_warshall(graph, directed=False)
Q = int(eval(input()))
for _ in range(Q):
    s, t = list(map(int, input().split()))
    ans = dist[s - 1][t - 1]
    if ans == float("inf"):
        print((-1))
    else:
        print((int(ans - 1)))

def io_tmp():
    global input
    import io

    f = io.StringIO(open(0).read())
    input = f.readline

io_tmp()
from scipy.sparse.csgraph import floyd_warshall

N, M, L = map(int, input().split())
graph = [[0] * N for _ in range(N)]
for _ in range(M):
    s, t, w = map(int, input().split())
    graph[s - 1][t - 1] = graph[t - 1][s - 1] = w
dist = floyd_warshall(graph, directed=False)
graph = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(i + 1, N):
        if dist[i][j] <= L:
            graph[i][j] = graph[i][j] = 1
dist = floyd_warshall(graph, directed=False)
Q = int(input())
ans = []
for _ in range(Q):
    s, t = map(int, input().split())
    d = dist[s - 1][t - 1]
    if d == float("inf"):
        ans.append(-1)
    else:
        ans.append(int(d - 1))
print(*ans, sep="\n")

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

-    s, t, w = list(map(int, input().split()))

+    s, t, w = map(int, input().split())

-    s, t = list(map(int, input().split()))


Input: a=eval('int(input()),'*5);print((min(~-i%10for i in a)-sum(-i//10*10for i in a)-9))

*a,=list(map(int,open(0)));print((min(~-i%10for i in a)-sum(-i//10*10for i in a)-9))

a = eval("int(input())," * 5)
print((min(~-i % 10 for i in a) - sum(-i // 10 * 10 for i in a) - 9))

(*a,) = list(map(int, open(0)))
print((min(~-i % 10 for i in a) - sum(-i // 10 * 10 for i in a) - 9))

-a = eval("int(input())," * 5)
+(*a,) = list(map(int, open(0)))


Input:
import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**6)

##############################

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

A = [0] * M

dp = [-1] * (N+1)

for i in range(M):

    a = int(eval(input()))

    dp[a] = 0

dp[0] = 1

if dp[1] != 0:

    dp[1] = 1

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

    if dp[i] != 0:

        dp[i] = dp[i-1] + dp[i-2]

print((dp[N] % 1000000007))

import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**6)

##############################

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

A = [0] * M

dp = [-1] * (N+1)

for i in range(M):

    a = int(eval(input()))

    dp[a] = 0

dp[0] = 1

if dp[1] != 0:

    dp[1] = 1

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

    if dp[i] != 0:

        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print((dp[N]))

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################
N, M = list(map(int, input().split()))
A = [0] * M
dp = [-1] * (N + 1)
for i in range(M):
    a = int(eval(input()))
    dp[a] = 0
dp[0] = 1
if dp[1] != 0:
    dp[1] = 1
for i in range(2, N + 1):
    if dp[i] != 0:
        dp[i] = dp[i - 1] + dp[i - 2]
print((dp[N] % 1000000007))

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################
N, M = list(map(int, input().split()))
A = [0] * M
dp = [-1] * (N + 1)
for i in range(M):
    a = int(eval(input()))
    dp[a] = 0
dp[0] = 1
if dp[1] != 0:
    dp[1] = 1
for i in range(2, N + 1):
    if dp[i] != 0:
        dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print((dp[N]))


Input:
import bisect

n=int(eval(input()))

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

a=[-x[0]]

l=1

for i in range(1,n):

  b=-x[i]

  if a[-1]>b:

    if a[0]>b:a[0]=b;continue

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

  else:a.append(b);l+=1

print(l)

import bisect;n,a,l=int(eval(input())),[-int(eval(input()))],1

for i in range(n-1):

  b=-int(eval(input()))

  if a[-1]>b:a[bisect.bisect_right(a,b)]=b

  else:a.append(b);l+=1

print(l)

import bisect

n = int(eval(input()))
x = [int(eval(input())) for _ in range(n)]
a = [-x[0]]
l = 1
for i in range(1, n):
    b = -x[i]
    if a[-1] > b:
        if a[0] > b:
            a[0] = b
            continue
        a[bisect.bisect_right(a, b)] = b
    else:
        a.append(b)
        l += 1
print(l)

import bisect

n, a, l = int(eval(input())), [-int(eval(input()))], 1
for i in range(n - 1):
    b = -int(eval(input()))
    if a[-1] > b:
        a[bisect.bisect_right(a, b)] = b
    else:
        a.append(b)
        l += 1
print(l)

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

+n, a, l = int(eval(input())), [-int(eval(input()))], 1


Input:
import sys, re, os

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import permutations, combinations, product, accumulate

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from fractions import gcd

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

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

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

def S_MAP(): return list(map(str, input().split()))

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

def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

mod = 10 ** 9 + 7

n = INT()

s = []

for i in range(n):

    m = list(eval(input()))

    m.sort()

    s.append(m)

s.sort()

# print(s)

# print(s)

count = 0

ren = 1

r = []

rsum = [0] * n

for i in range(n-1):

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

        count += 1

        ren += 1

        # print(ren)

        rsum[i+1] +=rsum[i]+1

    else:

        r.append(ren)

        ren = 1

        # print(ren)

r.append(ren)

for i in range(n):

    rsum[i] = rsum[i] + 1

def P(n, r):

    return factorial(n)//factorial(n-r)

def C(n, r):

    return P(n, r)//factorial(r)

# print(r)

# print(count)

# print("rsum:", rsum)

b = []

rsum.append(1)

for i in range(n):

    if rsum[i]>rsum[i+1]:

        b.append(rsum[i])

    #     continue

    # else:

    #     print(rsum[i+1])

    #     b.append(rsum[i+1])

# print("b", b)

count2 = 0

for i in b:

    # print(i)

    # print(C(i,2))

    count2 += C(i, 2)

print(count2)

    # if b[i]>=3:

# for i in range(n):

#     for j in range(n):

#         # if i != j:

#         if i < j:

#         #     print(s[i])

#         # print(s[j])

#             if s[i] == s[j]:

#                 count += 1

# # for i in range(n):

# print(count)

import sys, re, os

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import permutations, combinations, product, accumulate

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from heapq import heapify, heappop, heappush

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

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

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

def S_MAP(): return list(map(str, input().split()))

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

def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

mod = 10 ** 9 + 7

N = INT()

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

memo = defaultdict(int)

L = []

for i in range(N):

    l = list(S[i])

    l.sort()

    l = "".join(l)

    memo[str(l)] += 1

# print(memo)

ans = 0

for m in list(memo.values()):

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

print(ans)

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

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

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

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

def S_MAP():
    return list(map(str, input().split()))

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

def S_LIST():
    return list(map(str, input().split()))

sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
n = INT()
s = []
for i in range(n):
    m = list(eval(input()))
    m.sort()
    s.append(m)
s.sort()
# print(s)
# print(s)
count = 0
ren = 1
r = []
rsum = [0] * n
for i in range(n - 1):
    if s[i] == s[i + 1]:
        count += 1
        ren += 1
        # print(ren)
        rsum[i + 1] += rsum[i] + 1
    else:
        r.append(ren)
        ren = 1
        # print(ren)
r.append(ren)
for i in range(n):
    rsum[i] = rsum[i] + 1

def P(n, r):
    return factorial(n) // factorial(n - r)

def C(n, r):
    return P(n, r) // factorial(r)

# print(r)
# print(count)
# print("rsum:", rsum)
b = []
rsum.append(1)
for i in range(n):
    if rsum[i] > rsum[i + 1]:
        b.append(rsum[i])
    #     continue
    # else:
    #     print(rsum[i+1])
    #     b.append(rsum[i+1])
# print("b", b)
count2 = 0
for i in b:
    # print(i)
    # print(C(i,2))
    count2 += C(i, 2)
print(count2)
# if b[i]>=3:
# for i in range(n):
#     for j in range(n):
#         # if i != j:
#         if i < j:
#         #     print(s[i])
#         # print(s[j])
#             if s[i] == s[j]:
#                 count += 1
# # for i in range(n):
# print(count)

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

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

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

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

def S_MAP():
    return list(map(str, input().split()))

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

def S_LIST():
    return list(map(str, input().split()))

sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
S = [eval(input()) for i in range(N)]
memo = defaultdict(int)
L = []
for i in range(N):
    l = list(S[i])
    l.sort()
    l = "".join(l)
    memo[str(l)] += 1
# print(memo)
ans = 0
for m in list(memo.values()):
    ans += m * (m - 1) // 2
print(ans)

+from heapq import heapify, heappop, heappush

-    return factorial(n) // factorial(n - r)


Input:
# coding = SJIS

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

ans = 0

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

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

        z = s - x - y

        if 0 <= z and z <= k:

            ans += 1

print(ans)


Input:
import sys

input=sys.stdin.readline

sys.setrecursionlimit(10000000)

def find_negative_loop(n,e):

  d=n*[10**20];d[0]=0

  for h in range(n):

    for i,j,k in e:

      if d[j]>d[i]+k:

        d[j]=d[i]+k

        if h==n-1:return -1

  return max(-d[n-1],0)

from collections import deque

def find_loop(n,e,flag):

  x=[0]*n

  d=deque()

  t=[]

  c=0

  for i in range(n):

    for j in e[i]:x[j]+=1

  for i in range(n):

    if x[i]==0:

      d.append(i)

      t.append(i)

      c+=1

  while d:

    i=d.popleft()

    for j in e[i]:

      x[j]-=1

      if x[j]==0:

        d.append(j)

        t.append(j)

        c+=1

  if flag==0:return c==n

  else:return t

def glaph_bfs(s,n,e):

  ans=[0]*n

  Q=[s]

  visited={s}

  while Q:

    P=[]

    for i in Q:

      ans[i]=1

      for j in e[i]:

        if j in visited:continue

        visited.add(j)

        P.append(j)

    Q=P

  return ans

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

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

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

e=[]

for _ in range(m):

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

  a-=1

  b-=1

  c-=p

  ef[a].append(b)

  ee[b].append(a)

  e.append((a,b,c))

eff=glaph_bfs(0,n,ef)

eef=glaph_bfs(n-1,n,ee)

ee=[]

for a,b,c in e:

  if eff[a]==1 and eef[a]==1 and eff[b]==1 and eef[b]==1:

    ee.append((a,b,-c))

print((find_negative_loop(n,ee)))

#グラフ上でのBFS

#s=始点 n=頂点数 e=隣接リスト

def glaph_bfs(s,n,e):

  Q=[s]

  visited={s}

  while Q:

    P=[]

    for i in Q:

      for j,_ in e[i]:

        if j in visited:continue

        visited.add(j)

        P.append(j)

    Q=P

  return visited

#負の閉路検出

#n=頂点数 e=[[a,b,c],[]...](a~bの距離がc)

def find_negative_loop(n,e):

	d=n*[10**20];d[0]=0

	for h in range(n):

		for i,j,k in e:

			if d[j]>d[i]+k:

				d[j]=d[i]+k

				if h==n-1:return True

	return False

#ベルマンフォード(d[i]=頂点sから頂点iの最短距離)

#単一始点最短経路(負の辺対応)

#s=始点 n=頂点数 e=[[a,b,c],[]...](a~bの距離がc)

def bellman_ford(s,n,e):

  inf=10**20;d=[inf]*n;d[s]=0

  while 1:

    f=True

    for i,j,k in e:

      if d[i]!=inf and d[j]>d[i]+k:d[j]=d[i]+k;f=False

    if f:break

  return d

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

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

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

for _ in range(m):

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

  c-=p

  a-=1

  b-=1

  edge[a].append((b,c))

  edger[b].append((a,c))

visited=glaph_bfs(0,n,edge)

visitedr=glaph_bfs(n-1,n,edger)

for i in range(n):

  if not(i in visited and i in visitedr):edge[i]=[]

e=[]

for i in range(n):

  for j in range(len(edge[i])):e.append((i,edge[i][j][0],-edge[i][j][1]))

if find_negative_loop(n,e):print((-1));exit()

print((max(-bellman_ford(0,n,e)[n-1],0)))

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10000000)

def find_negative_loop(n, e):
    d = n * [10**20]
    d[0] = 0
    for h in range(n):
        for i, j, k in e:
            if d[j] > d[i] + k:
                d[j] = d[i] + k
                if h == n - 1:
                    return -1
    return max(-d[n - 1], 0)

from collections import deque

def find_loop(n, e, flag):
    x = [0] * n
    d = deque()
    t = []
    c = 0
    for i in range(n):
        for j in e[i]:
            x[j] += 1
    for i in range(n):
        if x[i] == 0:
            d.append(i)
            t.append(i)
            c += 1
    while d:
        i = d.popleft()
        for j in e[i]:
            x[j] -= 1
            if x[j] == 0:
                d.append(j)
                t.append(j)
                c += 1
    if flag == 0:
        return c == n
    else:
        return t

def glaph_bfs(s, n, e):
    ans = [0] * n
    Q = [s]
    visited = {s}
    while Q:
        P = []
        for i in Q:
            ans[i] = 1
            for j in e[i]:
                if j in visited:
                    continue
                visited.add(j)
                P.append(j)
        Q = P
    return ans

n, m, p = list(map(int, input().split()))
ef = [[] for _ in range(n)]
ee = [[] for _ in range(n)]
e = []
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    a -= 1
    b -= 1
    c -= p
    ef[a].append(b)
    ee[b].append(a)
    e.append((a, b, c))
eff = glaph_bfs(0, n, ef)
eef = glaph_bfs(n - 1, n, ee)
ee = []
for a, b, c in e:
    if eff[a] == 1 and eef[a] == 1 and eff[b] == 1 and eef[b] == 1:
        ee.append((a, b, -c))
print((find_negative_loop(n, ee)))

# グラフ上でのBFS
# s=始点 n=頂点数 e=隣接リスト
def glaph_bfs(s, n, e):
    Q = [s]
    visited = {s}
    while Q:
        P = []
        for i in Q:
            for j, _ in e[i]:
                if j in visited:
                    continue
                visited.add(j)
                P.append(j)
        Q = P
    return visited

# 負の閉路検出
# n=頂点数 e=[[a,b,c],[]...](a~bの距離がc)
def find_negative_loop(n, e):
    d = n * [10**20]
    d[0] = 0
    for h in range(n):
        for i, j, k in e:
            if d[j] > d[i] + k:
                d[j] = d[i] + k
                if h == n - 1:
                    return True
    return False

# ベルマンフォード(d[i]=頂点sから頂点iの最短距離)
# 単一始点最短経路(負の辺対応)
# s=始点 n=頂点数 e=[[a,b,c],[]...](a~bの距離がc)
def bellman_ford(s, n, e):
    inf = 10**20
    d = [inf] * n
    d[s] = 0
    while 1:
        f = True
        for i, j, k in e:
            if d[i] != inf and d[j] > d[i] + k:
                d[j] = d[i] + k
                f = False
        if f:
            break
    return d

n, m, p = list(map(int, input().split()))
edge = [[] for _ in range(n)]
edger = [[] for _ in range(n)]
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    c -= p
    a -= 1
    b -= 1
    edge[a].append((b, c))
    edger[b].append((a, c))
visited = glaph_bfs(0, n, edge)
visitedr = glaph_bfs(n - 1, n, edger)
for i in range(n):
    if not (i in visited and i in visitedr):
        edge[i] = []
e = []
for i in range(n):
    for j in range(len(edge[i])):
        e.append((i, edge[i][j][0], -edge[i][j][1]))
if find_negative_loop(n, e):
    print((-1))
    exit()
print((max(-bellman_ford(0, n, e)[n - 1], 0)))

+# グラフ上でのBFS

+# s=始点 n=頂点数 e=隣接リスト

+# ベルマンフォード(d[i]=頂点sから頂点iの最短距離)

+# 単一始点最短経路(負の辺対応)

+            if d[i] != inf and d[j] > d[i] + k:

-    if eff[a] == 1 and eef[a] == 1 and eff[b] == 1 and eef[b] == 1:

+    if not (i in visited and i in visitedr):

+print((max(-bellman_ford(0, n, e)[n - 1], 0)))


Input:
# coding:utf-8

import sys

input = sys.stdin.readline

INF = float('inf')

MOD = 10 ** 9 + 7

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

H, W, D = inpl()

num_coordinate = {}

for i in range(H):

    w = inpl()

    for j in range(W):

        num_coordinate[w[j]] = (i, j)

c_sum = {}

for d in range(1, D + 1):

    c_sum[d] = [0]

for d in range(1, D + 1):

    for n in range(d + D, H * W + 1, D):

        c_sum[d].append(c_sum[d][-1] + abs(num_coordinate[n][0] - num_coordinate[n - D][0])

                        + abs(num_coordinate[n][1] - num_coordinate[n - D][1]))

Q = int(eval(input()))

for _ in range(Q):

    l, r = inpl()

    index = (l - 1) % D + 1

    index_l, index_r = (l - 1) // D, (r - 1) // D

    print((c_sum[index][index_r] - c_sum[index][index_l]))

# coding:utf-8

import sys

INF = float('inf')

MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]

def LS(): return sys.stdin.readline().split()

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

def SI(): return eval(input())

h, w, d = LI()

coord = [0] * (h * w)

for y in range(h):

    for x, n in enumerate(LI_()):

        coord[n] = (y, x)

C = [[0] for _ in range(d)]

for i in range(d, h * w):

    diff = abs(coord[i][0] - coord[i - d][0]) + abs(coord[i][1] - coord[i - d][1])

    C[i % d].append(C[i % d][-1] + diff)

q = II()

for _ in range(q):

    l, r = LI_()

    n = l % d

    print((C[n][r // d] - C[n][l // d]))

# coding:utf-8
import sys

input = sys.stdin.readline
INF = float("inf")
MOD = 10**9 + 7

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

H, W, D = inpl()
num_coordinate = {}
for i in range(H):
    w = inpl()
    for j in range(W):
        num_coordinate[w[j]] = (i, j)
c_sum = {}
for d in range(1, D + 1):
    c_sum[d] = [0]
for d in range(1, D + 1):
    for n in range(d + D, H * W + 1, D):
        c_sum[d].append(
            c_sum[d][-1]
            + abs(num_coordinate[n][0] - num_coordinate[n - D][0])
            + abs(num_coordinate[n][1] - num_coordinate[n - D][1])
        )
Q = int(eval(input()))
for _ in range(Q):
    l, r = inpl()
    index = (l - 1) % D + 1
    index_l, index_r = (l - 1) // D, (r - 1) // D
    print((c_sum[index][index_r] - c_sum[index][index_l]))

# coding:utf-8
import sys

INF = float("inf")
MOD = 10**9 + 7

def LI():
    return [int(x) for x in sys.stdin.readline().split()]

def LI_():
    return [int(x) - 1 for x in sys.stdin.readline().split()]

def LS():
    return sys.stdin.readline().split()

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

def SI():
    return eval(input())

h, w, d = LI()
coord = [0] * (h * w)
for y in range(h):
    for x, n in enumerate(LI_()):
        coord[n] = (y, x)
C = [[0] for _ in range(d)]
for i in range(d, h * w):
    diff = abs(coord[i][0] - coord[i - d][0]) + abs(coord[i][1] - coord[i - d][1])
    C[i % d].append(C[i % d][-1] + diff)
q = II()
for _ in range(q):
    l, r = LI_()
    n = l % d
    print((C[n][r // d] - C[n][l // d]))

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

+    return [int(x) for x in sys.stdin.readline().split()]

-    for n in range(d + D, H * W + 1, D):

-            + abs(num_coordinate[n][0] - num_coordinate[n - D][0])

-            + abs(num_coordinate[n][1] - num_coordinate[n - D][1])

-    print((c_sum[index][index_r] - c_sum[index][index_l]))

+    return [int(x) - 1 for x in sys.stdin.readline().split()]

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

+    diff = abs(coord[i][0] - coord[i - d][0]) + abs(coord[i][1] - coord[i - d][1])

+    C[i % d].append(C[i % d][-1] + diff)


Input:
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

from bisect import bisect_left

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

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

b = [0]*(n+1)

a.sort()

for i in range(n):

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

def is_ok(arg):

    c = 0

    f = False

    for i in a:

      if c >= m:

        break

      c += (n-bisect_left(a,arg-i))

    if c >= m:

      f = True

    return f

def bisect_ok(ng, ok):

    while (abs(ok - ng) > 1):

        mid = (ok + ng) // 2

        if is_ok(mid):

            ok = mid

        else:

            ng = mid

    return ok

x = bisect_ok(2*a[-1]+1,1)

ans = 0

cnt = 0

for i in a:

  ind = n-bisect_left(a,x-i)

  cnt += ind

  ans += i*ind+(b[-1]-b[n-ind])

if cnt > m:

  ans -= x*(cnt-m)

print(ans)

import sys

input = sys.stdin.readline

mm = 10**10

k = mm.bit_length()

K = 1<<k

nu = lambda L: int("".join([bin(K+a)[-k:] for a in L[::-1]]), 2)

st = lambda n: bin(n)[2:] + "0"

li = lambda s: [int(a, 2) if len(a) else 0 for a in [s[-(i+1)*k-1:-i*k-1] for i in range(200001)]]

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

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

b = [0]*100001

for i in a:

    b[i] += 1

c = li(st(nu(b)*nu(b)))

ans = 0

for i in range(200001)[::-1]:

    if c[i] > 0:

      p = min(m,c[i])

      m -= p

      ans += i*p

      if m == 0:

        break

print(ans)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from bisect import bisect_left

n, m = list(map(int, readline().split()))
a = list(map(int, readline().split()))
b = [0] * (n + 1)
a.sort()
for i in range(n):
    b[i + 1] = b[i] + a[i]

def is_ok(arg):
    c = 0
    f = False
    for i in a:
        if c >= m:
            break
        c += n - bisect_left(a, arg - i)
    if c >= m:
        f = True
    return f

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

x = bisect_ok(2 * a[-1] + 1, 1)
ans = 0
cnt = 0
for i in a:
    ind = n - bisect_left(a, x - i)
    cnt += ind
    ans += i * ind + (b[-1] - b[n - ind])
if cnt > m:
    ans -= x * (cnt - m)
print(ans)

import sys

input = sys.stdin.readline
mm = 10**10
k = mm.bit_length()
K = 1 << k
nu = lambda L: int("".join([bin(K + a)[-k:] for a in L[::-1]]), 2)
st = lambda n: bin(n)[2:] + "0"
li = lambda s: [
    int(a, 2) if len(a) else 0
    for a in [s[-(i + 1) * k - 1 : -i * k - 1] for i in range(200001)]
]
n, m = list(map(int, input().split()))
a = [int(i) for i in input().split()]
b = [0] * 100001
for i in a:
    b[i] += 1
c = li(st(nu(b) * nu(b)))
ans = 0
for i in range(200001)[::-1]:
    if c[i] > 0:
        p = min(m, c[i])
        m -= p
        ans += i * p
        if m == 0:
            break
print(ans)

-n, m = list(map(int, readline().split()))

+nu = lambda L: int("".join([bin(K + a)[-k:] for a in L[::-1]]), 2)

-        c += n - bisect_left(a, arg - i)


Input:
import sys

sys.setrecursionlimit(10**9)

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

root=[-1]*(n+1)

def r(x):

    if root[x]<0:

        return x

    else:

        root[x]=r(root[x])

        return root[x]

def unite(x,y):

    x=r(x)

    y=r(y)

    if x==y:

        return

    root[x]+=root[y]

    root[y]=x

def size(x):

    x=r(x)

    return -root[x]

for i in range(m):

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

    unite(x,y)

ans=0

for i in range(n):

    ans=max(ans,size(i+1))

print(ans)

import sys

sys.setrecursionlimit(10**9)

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

root=[-1]*(n+1)

def r(x):

    if root[x]<0:

        return x

    else:

        root[x]=r(root[x])

        return root[x]

def unite(x,y):

    x=r(x)

    y=r(y)

    if x==y:

        return

    if root[x]>root[y]:

        x,y=y,x

    root[x]+=root[y]

    root[y]=x

def size(x):

    x=r(x)

    return -root[x]

for i in range(m):

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

    unite(x,y)

ans=0

for i in range(n):

    ans=max(ans,size(i+1))

print(ans)

import sys

sys.setrecursionlimit(10**9)
n, m = list(map(int, input().split()))
root = [-1] * (n + 1)

def r(x):
    if root[x] < 0:
        return x
    else:
        root[x] = r(root[x])
        return root[x]

def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

def size(x):
    x = r(x)
    return -root[x]

for i in range(m):
    x, y = list(map(int, input().split()))
    unite(x, y)
ans = 0
for i in range(n):
    ans = max(ans, size(i + 1))
print(ans)

import sys

sys.setrecursionlimit(10**9)
n, m = list(map(int, input().split()))
root = [-1] * (n + 1)

def r(x):
    if root[x] < 0:
        return x
    else:
        root[x] = r(root[x])
        return root[x]

def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    if root[x] > root[y]:
        x, y = y, x
    root[x] += root[y]
    root[y] = x

def size(x):
    x = r(x)
    return -root[x]

for i in range(m):
    x, y = list(map(int, input().split()))
    unite(x, y)
ans = 0
for i in range(n):
    ans = max(ans, size(i + 1))
print(ans)

+    if root[x] > root[y]:
+        x, y = y, x


Input:
from decimal import *

getcontext().prec = 20      # デフォルト28桁のところを20桁にする

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

A = Decimal(a).sqrt()

B = Decimal(b).sqrt()

C = Decimal(c).sqrt()

if A+B < C:

    print("Yes")

else:

    print("No")

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

if c - a - b >= 0 and 4*(a*b) < (c - a - b)**2:

    print("Yes")

else:

    print("No")

from decimal import *

getcontext().prec = 20  # デフォルト28桁のところを20桁にする
a, b, c = list(map(int, input().split()))
A = Decimal(a).sqrt()
B = Decimal(b).sqrt()
C = Decimal(c).sqrt()
if A + B < C:
    print("Yes")
else:
    print("No")

a, b, c = list(map(int, input().split()))
if c - a - b >= 0 and 4 * (a * b) < (c - a - b) ** 2:
    print("Yes")
else:
    print("No")

-getcontext().prec = 20  # デフォルト28桁のところを20桁にする


Input:
while True:

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

    if(num[0] == 0 and num[1] == 0): break

    c = 0

    for i in range(1,num[0] - 1):

        for j in range(i+1,num[0]):

            for k in range(j+1,num[0]+1):

                if(i+j+k == num[1]): c += 1

    print(c)

while True:

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

    if(num[0] == 0 and num[1] == 0): break

    c = 0

    for i in range(1,num[0]+1):

        for j in range(i+1,num[0]+1):

            if j <= i:

                continue

            k = num[1]-(i+j)

            if k > j and k <= num[0]:

                c+= 1

    print(c)

while True:
    num = list(map(int, input().split()))
    if num[0] == 0 and num[1] == 0:
        break
    c = 0
    for i in range(1, num[0] - 1):
        for j in range(i + 1, num[0]):
            for k in range(j + 1, num[0] + 1):
                if i + j + k == num[1]:
                    c += 1
    print(c)

while True:
    num = list(map(int, input().split()))
    if num[0] == 0 and num[1] == 0:
        break
    c = 0
    for i in range(1, num[0] + 1):
        for j in range(i + 1, num[0] + 1):
            if j <= i:
                continue
            k = num[1] - (i + j)
            if k > j and k <= num[0]:
                c += 1
    print(c)

-            for k in range(j + 1, num[0] + 1):

+        for j in range(i + 1, num[0] + 1):


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

ans=0

for i in range(n):

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

  if a>=h and b>=w:

    ans+=1

print(ans)

import sys

readline = sys.stdin.readline

N,H,W = list(map(int,readline().split()))

ans = 0

for i in range(N):

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

  if a >= H and b >= W:

    ans += 1

print(ans)

n, h, w = list(map(int, input().split()))
ans = 0
for i in range(n):
    a, b = list(map(int, input().split()))
    if a >= h and b >= w:
        ans += 1
print(ans)

import sys

readline = sys.stdin.readline
N, H, W = list(map(int, readline().split()))
ans = 0
for i in range(N):
    a, b = list(map(int, readline().split()))
    if a >= H and b >= W:
        ans += 1
print(ans)

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

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

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

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


Input:
N = int(eval(input()))

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

ans = []

import numpy as np

for i in range(len(A)-1):

    for k in range(i+1,len(A)):

        ans.append(np.sqrt(((A[i][0]-A[k][0])**2)+(A[i][1]-A[k][1])**2))

print((sum(ans)*2/N))

N = int(eval(input()))

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

ans = []

for i in range(len(A)-1):

    for k in range(i+1,len(A)):

        ans.append((((A[i][0]-A[k][0])**2)+(A[i][1]-A[k][1])**2)**0.5)

print((sum(ans)*2/N))

N = int(eval(input()))
A = [tuple(map(int, input().split())) for _ in range(N)]
ans = []
import numpy as np

for i in range(len(A) - 1):
    for k in range(i + 1, len(A)):
        ans.append(np.sqrt(((A[i][0] - A[k][0]) ** 2) + (A[i][1] - A[k][1]) ** 2))
print((sum(ans) * 2 / N))

N = int(eval(input()))
A = [tuple(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(len(A) - 1):
    for k in range(i + 1, len(A)):
        ans.append((((A[i][0] - A[k][0]) ** 2) + (A[i][1] - A[k][1]) ** 2) ** 0.5)
print((sum(ans) * 2 / N))


Input:
import sys

input=sys.stdin.readline

class list2D:

    def __init__(self, H, W, num):

        self.__H = H

        self.__W = W

        self.__dat = [num] * (H * W)

    def __getitem__(self, a):

        return self.__dat[a[0]*self.__W+a[1]]

    def __setitem__(self, a, b):

        self.__dat[a[0]*self.__W+a[1]] = b

    def debug(self):

        print(self.__dat)

class list3D:

    def __init__(self, H, W, D, num):

        self.__H = H

        self.__W = W

        self.__D = D

        self.__X = W * D

        self.__dat = [num] * (H * W * D)

    def __getitem__(self, a):

        return self.__dat[a[0]*self.__X+a[1]*self.__D + a[2]]

    def __setitem__(self, a, b):

        self.__dat[a[0]*self.__X+a[1]*self.__D + a[2]] = b

    def debug(self):

        print(self.__dat)

def main():

    r,c,k=map(int,input().split())

    v = list2D(r, c, 0)

    for _ in range(k):

        ri,ci,a=map(int,input().split())

        v[ri-1, ci-1] = a

    dp = list3D(r, c, 4, 0)

    #print(dp)

    if v[0, 0]>0: dp[0, 0, 1]=v[0, 0]

    for i in range(r):

        for j in range(c):

            val = v[i, j]

            if i>0:

                x = max(dp[i-1, j, 0], dp[i-1, j, 1], dp[i-1, j, 2], dp[i-1, j, 3])

                dp[i, j, 1]=max(dp[i, j, 1],x+val)

                dp[i, j, 0]=max(dp[i, j, 0],x)

            if j>0:

                X = dp[i, j-1, 0]

                Y = dp[i, j-1, 1]

                V = dp[i, j-1, 2]

                Z = dp[i, j-1, 3]

                dp[i, j, 0]=max(dp[i, j, 0],X)

                dp[i, j, 1]=max(dp[i, j, 1],X+val,Y)

                dp[i, j, 2]=max(dp[i, j, 2],Y+val,V)

                dp[i, j, 3]=max(dp[i, j, 3],V+val,Z)

    #print(dp)

    ans=0

    for i in range(4): ans=max(dp[r-1, c-1, i],ans)

    return print(ans)

if __name__=="__main__":

    main()

import sys

input=sys.stdin.readline

class list2D:

    def __init__(self, H, W, num):

        self.__H = H

        self.__W = W

        self.__dat = [num] * (H * W)

    def __getitem__(self, a):

        return self.__dat[a[0]*self.__W+a[1]]

    def __setitem__(self, a, b):

        self.__dat[a[0]*self.__W+a[1]] = b

    def debug(self):

        print(self.__dat)

class list3D:

    def __init__(self, H, W, D, num):

        self.__H = H

        self.__W = W

        self.__D = D

        self.__X = W * D

        self.__dat = [num] * (H * W * D)

    def __getitem__(self, a):

        return self.__dat[a[0]*self.__X+a[1]*self.__D + a[2]]

    def __setitem__(self, a, b):

        self.__dat[a[0]*self.__X+a[1]*self.__D + a[2]] = b

    def debug(self):

        print(self.__dat)

def main():

    r,c,k=map(int,input().split())

    v = list2D(r, c, 0)

    for _ in range(k):

        ri,ci,a=map(int,input().split())

        v[ri-1, ci-1] = a

    dp = list3D(r, c, 4, 0)

    #print(dp)

    if v[0, 0]>0: dp[0, 0, 1] = v[0, 0]

    for i in range(r):

        for j in range(c):

            val = v[i, j]

            if i>0:

                x = max(dp[i-1, j, 0], dp[i-1, j, 1], dp[i-1, j, 2], dp[i-1, j, 3])

                dp[i, j, 1]=x+val

                dp[i, j, 0]=x

            if j>0:

                X = dp[i, j-1, 0]

                Y = dp[i, j-1, 1]

                V = dp[i, j-1, 2]

                Z = dp[i, j-1, 3]

                dp[i, j, 0]=max(dp[i, j, 0],X)

                dp[i, j, 1]=max(dp[i, j, 1],X+val,Y)

                dp[i, j, 2]=max(Y+val,V)

                dp[i, j, 3]=max(V+val,Z)

    #print(dp)

    ans=0

    for i in range(4): ans=max(dp[r-1, c-1, i],ans)

    return print(ans)

if __name__=="__main__":

    main()

import sys

input = sys.stdin.readline

class list2D:
    def __init__(self, H, W, num):
        self.__H = H
        self.__W = W
        self.__dat = [num] * (H * W)

    def __getitem__(self, a):
        return self.__dat[a[0] * self.__W + a[1]]

    def __setitem__(self, a, b):
        self.__dat[a[0] * self.__W + a[1]] = b

    def debug(self):
        print(self.__dat)

class list3D:
    def __init__(self, H, W, D, num):
        self.__H = H
        self.__W = W
        self.__D = D
        self.__X = W * D
        self.__dat = [num] * (H * W * D)

    def __getitem__(self, a):
        return self.__dat[a[0] * self.__X + a[1] * self.__D + a[2]]

    def __setitem__(self, a, b):
        self.__dat[a[0] * self.__X + a[1] * self.__D + a[2]] = b

    def debug(self):
        print(self.__dat)

def main():
    r, c, k = map(int, input().split())
    v = list2D(r, c, 0)
    for _ in range(k):
        ri, ci, a = map(int, input().split())
        v[ri - 1, ci - 1] = a
    dp = list3D(r, c, 4, 0)
    # print(dp)
    if v[0, 0] > 0:
        dp[0, 0, 1] = v[0, 0]
    for i in range(r):
        for j in range(c):
            val = v[i, j]
            if i > 0:
                x = max(
                    dp[i - 1, j, 0], dp[i - 1, j, 1], dp[i - 1, j, 2], dp[i - 1, j, 3]
                )
                dp[i, j, 1] = max(dp[i, j, 1], x + val)
                dp[i, j, 0] = max(dp[i, j, 0], x)
            if j > 0:
                X = dp[i, j - 1, 0]
                Y = dp[i, j - 1, 1]
                V = dp[i, j - 1, 2]
                Z = dp[i, j - 1, 3]
                dp[i, j, 0] = max(dp[i, j, 0], X)
                dp[i, j, 1] = max(dp[i, j, 1], X + val, Y)
                dp[i, j, 2] = max(dp[i, j, 2], Y + val, V)
                dp[i, j, 3] = max(dp[i, j, 3], V + val, Z)
    # print(dp)
    ans = 0
    for i in range(4):
        ans = max(dp[r - 1, c - 1, i], ans)
    return print(ans)

if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline

class list2D:
    def __init__(self, H, W, num):
        self.__H = H
        self.__W = W
        self.__dat = [num] * (H * W)

    def __getitem__(self, a):
        return self.__dat[a[0] * self.__W + a[1]]

    def __setitem__(self, a, b):
        self.__dat[a[0] * self.__W + a[1]] = b

    def debug(self):
        print(self.__dat)

class list3D:
    def __init__(self, H, W, D, num):
        self.__H = H
        self.__W = W
        self.__D = D
        self.__X = W * D
        self.__dat = [num] * (H * W * D)

    def __getitem__(self, a):
        return self.__dat[a[0] * self.__X + a[1] * self.__D + a[2]]

    def __setitem__(self, a, b):
        self.__dat[a[0] * self.__X + a[1] * self.__D + a[2]] = b

    def debug(self):
        print(self.__dat)

def main():
    r, c, k = map(int, input().split())
    v = list2D(r, c, 0)
    for _ in range(k):
        ri, ci, a = map(int, input().split())
        v[ri - 1, ci - 1] = a
    dp = list3D(r, c, 4, 0)
    # print(dp)
    if v[0, 0] > 0:
        dp[0, 0, 1] = v[0, 0]
    for i in range(r):
        for j in range(c):
            val = v[i, j]
            if i > 0:
                x = max(
                    dp[i - 1, j, 0], dp[i - 1, j, 1], dp[i - 1, j, 2], dp[i - 1, j, 3]
                )
                dp[i, j, 1] = x + val
                dp[i, j, 0] = x
            if j > 0:
                X = dp[i, j - 1, 0]
                Y = dp[i, j - 1, 1]
                V = dp[i, j - 1, 2]
                Z = dp[i, j - 1, 3]
                dp[i, j, 0] = max(dp[i, j, 0], X)
                dp[i, j, 1] = max(dp[i, j, 1], X + val, Y)
                dp[i, j, 2] = max(Y + val, V)
                dp[i, j, 3] = max(V + val, Z)
    # print(dp)
    ans = 0
    for i in range(4):
        ans = max(dp[r - 1, c - 1, i], ans)
    return print(ans)

if __name__ == "__main__":
    main()

+                dp[i, j, 2] = max(Y + val, V)

+                dp[i, j, 3] = max(V + val, Z)


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

count=0

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

    if list(str(i)) == list(reversed(str(i))):

        count+=1

print(count)

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

count=0

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

    if str(i) == ''.join(reversed(str(i))):

        count+=1

print(count)

A, B = list(map(int, input().split()))
count = 0
for i in range(A, B + 1):
    if list(str(i)) == list(reversed(str(i))):
        count += 1
print(count)

A, B = list(map(int, input().split()))
count = 0
for i in range(A, B + 1):
    if str(i) == "".join(reversed(str(i))):
        count += 1
print(count)

-    if list(str(i)) == list(reversed(str(i))):

+    if str(i) == "".join(reversed(str(i))):