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

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

mod=10**9+7

m=len(bin(max(a)))-2

l=[[0,0] for i in range(m)]

for i in a:

    b=bin(i)[2:].rjust(m,"0")[::-1]

    for j in range(m):

        if b[j]=="0":

            l[j][0]+=1

        else:

            l[j][1]+=1

ans=0

for i in range(m):

    ans+=l[i][0]*l[i][1]*pow(2,i,mod)

    ans=ans%mod

print(ans)

import sys

input=sys.stdin.readline

import numpy as np

n=int(eval(input()))

a=np.array([int(j) for j in input().split()],dtype=np.int64)

ans=0

mod=10**9+7

for i in range(61):

    b=(a>>i)&1

    c=np.count_nonzero(b)

    ans+=(2**i)*c*(n-c)

    ans%=mod

print(ans)

n = int(eval(input()))
a = [int(j) for j in input().split()]
mod = 10**9 + 7
m = len(bin(max(a))) - 2
l = [[0, 0] for i in range(m)]
for i in a:
    b = bin(i)[2:].rjust(m, "0")[::-1]
    for j in range(m):
        if b[j] == "0":
            l[j][0] += 1
        else:
            l[j][1] += 1
ans = 0
for i in range(m):
    ans += l[i][0] * l[i][1] * pow(2, i, mod)
    ans = ans % mod
print(ans)

import sys

input = sys.stdin.readline
import numpy as np

n = int(eval(input()))
a = np.array([int(j) for j in input().split()], dtype=np.int64)
ans = 0
mod = 10**9 + 7
for i in range(61):
    b = (a >> i) & 1
    c = np.count_nonzero(b)
    ans += (2**i) * c * (n - c)
    ans %= mod
print(ans)

+a = np.array([int(j) for j in input().split()], dtype=np.int64)


Input:
string = input().split(' ')

first = string[0]

second = string[1]

if int(first)*int(second)%2 == 0:

    print("Even")

else:

    print("Odd")

s = input().split(" ")

a = int(s[0])

b = int(s[1])

if (a*b)%2 == 0:

 print("Even")

else:

 print("Odd")

string = input().split(" ")
first = string[0]
second = string[1]
if int(first) * int(second) % 2 == 0:
    print("Even")
else:
    print("Odd")

s = input().split(" ")
a = int(s[0])
b = int(s[1])
if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")

-string = input().split(" ")
-first = string[0]
-second = string[1]
-if int(first) * int(second) % 2 == 0:
+s = input().split(" ")
+a = int(s[0])
+b = int(s[1])
+if (a * b) % 2 == 0:


Input:
import sys

input = sys.stdin.readline

def main():

    N = int(eval(input()))

    dic = {}

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

        tmp = str(i)

        s, e = int(tmp[0]), int(tmp[-1])

        if (s, e) in dic:

            dic[(s, e)] += 1

        else:

            dic[(s, e)] = 1

    ans = 0

    for (i, j), count in list(dic.items()):

        tmp = 0

        if i == j:

            tmp = count**2

        else:

            if (j, i) in dic:

                tmp = count * dic[(j, i)]

        ans += tmp

        # print(i, j, count)

    print(ans)

if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline

def main():

    N = int(eval(input()))

    dic = {}

    for i in range(10):

        for j in range(10):

            dic[(i, j)] = 0

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

        tmp = str(i)

        s, e = int(tmp[0]), int(tmp[-1])

        dic[(s, e)] += 1

    ans = 0

    for i in range(10):

        for j in range(10):

            ans += dic[(i, j)] * dic[(j, i)]

    print(ans)

if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline

def main():
    N = int(eval(input()))
    dic = {}
    for i in range(1, N + 1):
        tmp = str(i)
        s, e = int(tmp[0]), int(tmp[-1])
        if (s, e) in dic:
            dic[(s, e)] += 1
        else:
            dic[(s, e)] = 1
    ans = 0
    for (i, j), count in list(dic.items()):
        tmp = 0
        if i == j:
            tmp = count**2
        else:
            if (j, i) in dic:
                tmp = count * dic[(j, i)]
        ans += tmp
        # print(i, j, count)
    print(ans)

if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline

def main():
    N = int(eval(input()))
    dic = {}
    for i in range(10):
        for j in range(10):
            dic[(i, j)] = 0
    for i in range(1, N + 1):
        tmp = str(i)
        s, e = int(tmp[0]), int(tmp[-1])
        dic[(s, e)] += 1
    ans = 0
    for i in range(10):
        for j in range(10):
            ans += dic[(i, j)] * dic[(j, i)]
    print(ans)

if __name__ == "__main__":
    main()

-    for (i, j), count in list(dic.items()):

-                tmp = count * dic[(j, i)]


Input:
import math

n = int(eval(input()))

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

    if math.sqrt(i).is_integer():

        print(i)

        break

n = int(eval(input()))

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

    if i**2 <= n:

        print((i**2))

        break

n = int(eval(input()))
for i in reversed(list(range(1, int(n**0.5) + 1))):
    if i**2 <= n:
        print((i**2))
        break

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


Input:
import math

import itertools

N = int(eval(input()))

lst = []

for i in range(N):

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

routes = list(itertools.permutations(lst))

def distance(a, b):

    return (((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)) ** 0.5

routes = [i for i in routes]

distancies = []

for i, r in enumerate(routes):

    for j, a in enumerate(r):

        if j >= len(r) - 1: break

        b = r[j + 1]

        ab_dist = distance(a, b)

        distancies.append(ab_dist)

print((sum(distancies) / len(routes)))

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())

XY = np.array(read().split(),np.int64)

X = XY[::2]; Y = XY[1::2]

dx = X[:,None] - X[None,:]

dy = Y[:,None] - Y[None,:]

dist_mat = (dx * dx + dy * dy) ** .5

answer = dist_mat.sum() / N

print(answer)

import sys

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

N = int(readline())
XY = np.array(read().split(), np.int64)
X = XY[::2]
Y = XY[1::2]
dx = X[:, None] - X[None, :]
dy = Y[:, None] - Y[None, :]
dist_mat = (dx * dx + dy * dy) ** 0.5
answer = dist_mat.sum() / N
print(answer)

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

+XY = np.array(read().split(), np.int64)


Input:
import bisect, itertools

n = int(eval(input()))

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

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

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

c_num = [0]*n

for i in range(n):

    c_num[i] = n - bisect.bisect_right(C, B[i])

c_accum = [0] + list(itertools.accumulate(c_num))

ans = 0

for i in range(n):

    b_index = bisect.bisect_right(B, A[i])

    ans += (c_accum[-1] - c_accum[b_index])

print(ans)

import bisect

n=int(eval(input()))

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

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

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

ans = 0

for b in B:

    ans += bisect.bisect_left(A,b) * (n - bisect.bisect_right(C,b))

print(ans)

import bisect, itertools

n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
c_num = [0] * n
for i in range(n):
    c_num[i] = n - bisect.bisect_right(C, B[i])
c_accum = [0] + list(itertools.accumulate(c_num))
ans = 0
for i in range(n):
    b_index = bisect.bisect_right(B, A[i])
    ans += c_accum[-1] - c_accum[b_index]
print(ans)

import bisect

n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
print(ans)

-    c_num[i] = n - bisect.bisect_right(C, B[i])

-c_accum = [0] + list(itertools.accumulate(c_num))

-    b_index = bisect.bisect_right(B, A[i])

-    ans += c_accum[-1] - c_accum[b_index]

+    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))


Input:
S = eval(input())

N = len(S)

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

dp[0][0] = 1

mod = 10**9+7

for n in range(N):

    s = S[n]

    if s!='?':

        s = int(s)*pow(10, (N-n-1), 13)%13

        for i in range(13):

            idx = (s+i)%13

            dp[n+1][idx] = dp[n][i]%mod

    else:

        for i in range(10):

            s = i*pow(10, (N-n-1), 13)%13

            for j in range(13):

                idx = (s+j)%13

                dp[n+1][idx] += dp[n][j]%mod

print((dp[-1][5]%mod))

import sys

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

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

sys.setrecursionlimit(10**9)

S = list(eval(input()))[::-1]

leng = len(S)

mod = 10**9+7

old_dp = [0]*13

old_dp[0] = 1

for i in range(leng):

    dp = [0]*13

    if S[i]!='?':

        d = int(S[i])

        d = d*pow(10, i, 13)

        for j in range(13):

            dp[j] += old_dp[(j-d)%13]

            dp[j] %= mod

    else:

        for d in range(10):

            d = d*pow(10, i, 13)

            for j in range(13):

                dp[j] += old_dp[(j-d)%13]

                dp[j] %= mod

    old_dp = dp

print((dp[5]))

import sys

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

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

sys.setrecursionlimit(10**9)
S = list(eval(input()))[::-1]
leng = len(S)
mod = 10**9 + 7
old_dp = [0] * 13
old_dp[0] = 1
for i in range(leng):
    dp = [0] * 13
    if S[i] != "?":
        d = int(S[i])
        d = d * pow(10, i, 13)
        for j in range(13):
            dp[j] += old_dp[(j - d) % 13]
            dp[j] %= mod
    else:
        for d in range(10):
            d = d * pow(10, i, 13)
            for j in range(13):
                dp[j] += old_dp[(j - d) % 13]
                dp[j] %= mod
    old_dp = dp
print((dp[5]))

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

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

-            dp[n + 1][idx] = dp[n][i] % mod


Input:
import sys

# import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random

from collections import deque, defaultdict, Counter; from heapq import heappush, heappop

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

# from bisect import bisect_left, bisect_right, insort_left, insort_right

# from operator import itemgetter as ig

sys.setrecursionlimit(10 ** 7)

inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []; mod = 10 ** 9 + 7

dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]

"""for dx, dy in dd:

        nx = j + dx; ny = i + dy

            if 0 <= nx < w and 0 <= ny < h:"""

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

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

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

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

def s(): return eval(input())

def hi(n): return [i() for _ in range(n)]

def hs(n): return [s() for _ in range(n)]#HeightString

def mi(n): return [wi() for _ in range(n)]#MatrixInt

def mip(n): return [wip() for _ in range(n)]

def ms(n): return [ws() for _ in range(n)]

#if __name__ == '__main__':

h, w = wi()

s = hs(h)

flagli = [[0] * w for i in range(h)]

stack = deque()

black = 0

white = 0

for i in range(h):

    for j in range(w):

        if flagli[i][j] == 0:

            flagli[i][j] = 1

            white = 1 if s[i][j] == "." else 0

            black = 1 if s[i][j] == "#" else 0

            stack.append([i, j])

            while stack != deque():

                p, q = stack.pop()

                k = 0 if s[p][q] == "." else 1

                for dx, dy in dd:

                    nx = q + dx;

                    ny = p + dy

                    if 0 <= nx < w and 0 <= ny < h:

                        if flagli[ny][nx] == 0:

                            if k == 0 and s[ny][nx] == "#":

                                flagli[ny][nx] = 1

                                stack.append([ny, nx])

                                black += 1

                            elif k == 1 and s[ny][nx] == ".":

                                flagli[ny][nx] = 1

                                stack.append([ny, nx])

                                white += 1

            ans += black * white

            black = 0

            white = 0

print(ans)

import sys

# import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random

from collections import deque, defaultdict, Counter; from heapq import heappush, heappop

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

# from bisect import bisect_left, bisect_right, insort_left, insort_right

# from operator import itemgetter as ig

sys.setrecursionlimit(10 ** 7)

inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []; mod = 10 ** 9 + 7

dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]

"""for dx, dy in dd:

        nx = j + dx; ny = i + dy

            if 0 <= nx < w and 0 <= ny < h:"""

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

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

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

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

def s(): return eval(input())

def hi(n): return [i() for _ in range(n)]

def hs(n): return [s() for _ in range(n)]#HeightString

def mi(n): return [wi() for _ in range(n)]#MatrixInt

def mip(n): return [wip() for _ in range(n)]

def ms(n): return [ws() for _ in range(n)]

if __name__ == '__main__':

    h, w = wi()

    s = hs(h)

    flagli = [[0] * w for i in range(h)]

    stack = deque()

    black = 0

    white = 0

    for i in range(h):

        for j in range(w):

            if flagli[i][j] == 0:

                flagli[i][j] = 1

                white = 1 if s[i][j] == "." else 0

                black = 1 if s[i][j] == "#" else 0

                stack.append([i, j])

                while stack != deque():

                    p, q = stack.pop()

                    k = 0 if s[p][q] == "." else 1

                    for dx, dy in dd:

                        nx = q + dx;

                        ny = p + dy

                        if 0 <= nx < w and 0 <= ny < h:

                            if flagli[ny][nx] == 0:

                                if k == 0 and s[ny][nx] == "#":

                                    flagli[ny][nx] = 1

                                    stack.append([ny, nx])

                                    black += 1

                                elif k == 1 and s[ny][nx] == ".":

                                    flagli[ny][nx] = 1

                                    stack.append([ny, nx])

                                    white += 1

                ans += black * white

                black = 0

                white = 0

    print(ans)

import sys

# import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop

# from itertools import permutations, combinations, product, accumulate, groupby
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from operator import itemgetter as ig
sys.setrecursionlimit(10**7)
inf = 10**20
INF = float("INF")
ans = 0
tmp = 0
ansli = []
tmpli = []
candili = []
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

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

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

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

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

def s():
    return eval(input())

def hi(n):
    return [i() for _ in range(n)]

def hs(n):
    return [s() for _ in range(n)]  # HeightString

def mi(n):
    return [wi() for _ in range(n)]  # MatrixInt

def mip(n):
    return [wip() for _ in range(n)]

def ms(n):
    return [ws() for _ in range(n)]

# if __name__ == '__main__':
h, w = wi()
s = hs(h)
flagli = [[0] * w for i in range(h)]
stack = deque()
black = 0
white = 0
for i in range(h):
    for j in range(w):
        if flagli[i][j] == 0:
            flagli[i][j] = 1
            white = 1 if s[i][j] == "." else 0
            black = 1 if s[i][j] == "#" else 0
            stack.append([i, j])
            while stack != deque():
                p, q = stack.pop()
                k = 0 if s[p][q] == "." else 1
                for dx, dy in dd:
                    nx = q + dx
                    ny = p + dy
                    if 0 <= nx < w and 0 <= ny < h:
                        if flagli[ny][nx] == 0:
                            if k == 0 and s[ny][nx] == "#":
                                flagli[ny][nx] = 1
                                stack.append([ny, nx])
                                black += 1
                            elif k == 1 and s[ny][nx] == ".":
                                flagli[ny][nx] = 1
                                stack.append([ny, nx])
                                white += 1
            ans += black * white
            black = 0
            white = 0
print(ans)

import sys

# import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop

# from itertools import permutations, combinations, product, accumulate, groupby
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from operator import itemgetter as ig
sys.setrecursionlimit(10**7)
inf = 10**20
INF = float("INF")
ans = 0
tmp = 0
ansli = []
tmpli = []
candili = []
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

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

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

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

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

def s():
    return eval(input())

def hi(n):
    return [i() for _ in range(n)]

def hs(n):
    return [s() for _ in range(n)]  # HeightString

def mi(n):
    return [wi() for _ in range(n)]  # MatrixInt

def mip(n):
    return [wip() for _ in range(n)]

def ms(n):
    return [ws() for _ in range(n)]

if __name__ == "__main__":
    h, w = wi()
    s = hs(h)
    flagli = [[0] * w for i in range(h)]
    stack = deque()
    black = 0
    white = 0
    for i in range(h):
        for j in range(w):
            if flagli[i][j] == 0:
                flagli[i][j] = 1
                white = 1 if s[i][j] == "." else 0
                black = 1 if s[i][j] == "#" else 0
                stack.append([i, j])
                while stack != deque():
                    p, q = stack.pop()
                    k = 0 if s[p][q] == "." else 1
                    for dx, dy in dd:
                        nx = q + dx
                        ny = p + dy
                        if 0 <= nx < w and 0 <= ny < h:
                            if flagli[ny][nx] == 0:
                                if k == 0 and s[ny][nx] == "#":
                                    flagli[ny][nx] = 1
                                    stack.append([ny, nx])
                                    black += 1
                                elif k == 1 and s[ny][nx] == ".":
                                    flagli[ny][nx] = 1
                                    stack.append([ny, nx])
                                    white += 1
                ans += black * white
                black = 0
                white = 0
    print(ans)

-            white = 1 if s[i][j] == "." else 0

-            black = 1 if s[i][j] == "#" else 0

-                    if 0 <= nx < w and 0 <= ny < h:

-                        if flagli[ny][nx] == 0:

-                                flagli[ny][nx] = 1

-                                stack.append([ny, nx])

-                                black += 1

-                                flagli[ny][nx] = 1

-                                stack.append([ny, nx])

-                                white += 1

+    flagli = [[0] * w for i in range(h)]

+                white = 1 if s[i][j] == "." else 0

+                black = 1 if s[i][j] == "#" else 0

+                while stack != deque():

+                        if 0 <= nx < w and 0 <= ny < h:

+                            if flagli[ny][nx] == 0:

+                                    flagli[ny][nx] = 1

+                                    stack.append([ny, nx])

+                                    black += 1

+                                    flagli[ny][nx] = 1

+                                    stack.append([ny, nx])

+                                    white += 1


Input:
import itertools

import math

def dis(X,Y):

    return ((X[0]-Y[0])**2+(X[1]-Y[1])**2)**.5

def main():

    n=int(eval(input()))

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

    S=itertools.permutations([i for i in range(1,n+1)])

    ans=0

    for s in S:

        for i in range(n-1):

            a = s[i] - 1

            b = s[i+1] - 1

            ans += dis(L[a],L[b])

    ans /= math.factorial(n)

    print(ans)

main()

n = int(eval(input()))

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

ans = 0

# (edgesの長さの総和)/(edgeの本数)*(1つのpathを構成するedgesの数)

# = (edgesの長さの総和)/ (n*(n-1)) * (n-1)

for x1, y1 in L:

    for x2, y2 in L:

        ans += ((x1 - x2)**2 + (y1 - y2)**2)**.5

print((ans/n))

import itertools
import math

def dis(X, Y):
    return ((X[0] - Y[0]) ** 2 + (X[1] - Y[1]) ** 2) ** 0.5

def main():
    n = int(eval(input()))
    L = [list(map(int, input().split())) for _ in range(n)]
    S = itertools.permutations([i for i in range(1, n + 1)])
    ans = 0
    for s in S:
        for i in range(n - 1):
            a = s[i] - 1
            b = s[i + 1] - 1
            ans += dis(L[a], L[b])
    ans /= math.factorial(n)
    print(ans)

main()

n = int(eval(input()))
L = [list(map(int, input().split())) for _ in range(n)]
ans = 0
# (edgesの長さの総和)/(edgeの本数)*(1つのpathを構成するedgesの数)
# = (edgesの長さの総和)/ (n*(n-1)) * (n-1)
for x1, y1 in L:
    for x2, y2 in L:
        ans += ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
print((ans / n))

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

-    S = itertools.permutations([i for i in range(1, n + 1)])

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

+# (edgesの長さの総和)/(edgeの本数)*(1つのpathを構成するedgesの数)


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

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

    if i ** 0.5 == int(i ** 0.5):

        print(i)

        exit()

N = int(eval(input()))

i = 1

while i * i <= N:

    i += 1

print(((i - 1) ** 2))

N = int(eval(input()))
for i in range(N, 0, -1):
    if i**0.5 == int(i**0.5):
        print(i)
        exit()


Input:
S = eval(input())

T = eval(input())

cnt = len(S)-len(T)+1

res = []

for i in range(cnt):

    res2 = 0

    for j in range(len(T)):

        if S[i+j] != T[j]:

            res2 += 1

    res.append(res2)

print((min(res)))

S = eval(input())

T = eval(input())

cnt = []

for i in range(len(S)-len(T)+1):

    cnt2 = 0

    for j in range(len(T)):

        if S[i+j] != T[j]:

            cnt2 += 1

    cnt.append(cnt2)

print((min(cnt)))

S = eval(input())
T = eval(input())
cnt = len(S) - len(T) + 1
res = []
for i in range(cnt):
    res2 = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            res2 += 1
    res.append(res2)
print((min(res)))

S = eval(input())
T = eval(input())
cnt = []
for i in range(len(S) - len(T) + 1):
    cnt2 = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            cnt2 += 1
    cnt.append(cnt2)
print((min(cnt)))

-cnt = len(S) - len(T) + 1
-res = []
-for i in range(cnt):
-    res2 = 0
+cnt = []
+for i in range(len(S) - len(T) + 1):
+    cnt2 = 0
-            res2 += 1
-    res.append(res2)
-print((min(res)))
+            cnt2 += 1
+    cnt.append(cnt2)
+print((min(cnt)))


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

print(('bust' if a+b+c>=22 else 'win'))

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

print(("bust" if sum(A) >= 22 else "win"))

a, b, c = list(map(int, input().split()))
print(("bust" if a + b + c >= 22 else "win"))

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

-print(("bust" if a + b + c >= 22 else "win"))

+print(("bust" if sum(A) >= 22 else "win"))


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

for i in range(1, 100000):

    if a*i % b == c:

        print("YES")

        exit()

print("NO")

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

for i in range(1, 100):

    if a*i % b == c:

        print("YES")

        exit()

print("NO")

a, b, c = list(map(int, input().split()))
for i in range(1, 100000):
    if a * i % b == c:
        print("YES")
        exit()
print("NO")

a, b, c = list(map(int, input().split()))
for i in range(1, 100):
    if a * i % b == c:
        print("YES")
        exit()
print("NO")

-for i in range(1, 100000):
+for i in range(1, 100):


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

print((max(c-(a-b),0)))

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

print((max(0,c-(a-b))))

a, b, c = list(map(int, input().split()))
print((max(c - (a - b), 0)))

a, b, c = list(map(int, input().split()))
print((max(0, c - (a - b))))


Input:
n,*a=list(map(int,open(0)))

b,c=1,0

for i in a:

  if i>b:

    c+=(i-1)//b

    b+=b<2

  elif i==b:

    b+=1

print(c)

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

b,c=1,0

for i in a:

  c+=~-i//b*(i>b)

  b+=b<2or i==b

print(c)

n, *a = list(map(int, open(0)))
b, c = 1, 0
for i in a:
    if i > b:
        c += (i - 1) // b
        b += b < 2
    elif i == b:
        b += 1
print(c)

n, *a = list(map(int, open(0)))
b, c = 1, 0
for i in a:
    c += ~-i // b * (i > b)
    b += b < 2 or i == b
print(c)


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

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

total = sum(stick)

mid = total // 2

cum = 0

midi = 0

for i, block in enumerate(stick):

    cum += block

    if cum >= mid:

        midi = i

        break

l1 = sum(stick[:midi])

r1 = sum(stick[midi:])

diff1 = abs(l1 - r1)

l2 = l1 + stick[midi]

r2 = r1 - stick[midi]

diff2 = abs(l2 - r2)

print((min(diff1, diff2)))

import sys

input = sys.stdin.readline

def main():

    n = int(eval(input()))

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

    total = sum(stick)

    mid = total // 2

    cum = 0

    midi = 0

    for i, block in enumerate(stick):

        cum += block

        if cum >= mid:

            midi = i

            break

    l1 = sum(stick[:midi])

    r1 = sum(stick[midi:])

    diff1 = abs(l1 - r1)

    l2 = l1 + stick[midi]

    r2 = r1 - stick[midi]

    diff2 = abs(l2 - r2)

    print((min(diff1, diff2)))

main()

-stick = list(map(int, input().split()))

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


Input: a,b=input().split();print((int(a)*int(b[:-3]+b[-2:])//100))

a,b=input().split()

a=int(a)

b=int("".join(b.split(".")))

print(((a*b)//100))

a, b = input().split()
a = int(a)
b = int("".join(b.split(".")))
print(((a * b) // 100))


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

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

acc = [0] * (n + 1)

for i in range(n):

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

acc.sort()

from collections import Counter

cnt = 0

cacc = Counter(acc)

for k, v in list(cacc.items()):

    if v > 1:

        cnt += v * (v - 1) // 2

print(cnt)

n = int(eval(input()))

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

acc = [0] * (n + 1)

for i in range(n):

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

from collections import Counter

cnt = 0

cacc = Counter(acc)

for k, v in list(cacc.items()):

    if v > 1:

        cnt += v * (v - 1) // 2

print(cnt)


Input:
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

class SegmentTree:

    def __init__(self, N, func, I):

        self.func = func

        self.I = I

        self.N = N

        self.sz = 2**(N-1).bit_length()

        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):

        self.seg[k + self.sz] = x

    def build(self):

        for i in reversed(list(range(1,self.sz))):

            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):

        k += self.sz

        self.seg[k] = x

        while k > 1:

            k >>= 1

            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):

        L = self.I

        R = self.I

        a += self.sz

        b += self.sz

        while a < b:

            if a & 1:

                L = self.func(L, self.seg[a])

                a += 1

            if b & 1:

                b -= 1

                R = self.func(self.seg[b], R)

            a >>= 1

            b >>= 1

        return self.func(L, R)

def main():

    def gcd(a, b):

        while b:

            a, b = b, a % b

        return a

    N = int(readline())

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

    seg = SegmentTree(N , gcd , 0)

    for i,n in enumerate(L):

        seg.assign(i , n)

    seg.build()

    ans = 1

    for i in range(N):

        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))

    print(ans)

main()

import sys

readline = sys.stdin.buffer.readline

class SegmentTree:

    def __init__(self, N, func, I):

        self.N = N

        self.sz = 2**(N-1).bit_length()

        self.func = func

        self.I = I

        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):

        self.seg[k + self.sz] = x

    def build(self):

        for i in reversed(list(range(1, self.sz))):

            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):

        k += self.sz

        self.seg[k] = x

        while k > 1:

            k >>= 1

            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):

        L = self.I

        R = self.I

        a += self.sz

        if b == self.N:

            b = self.sz

        b += self.sz

        while a < b:

            if a & 1:

                L = self.func(L, self.seg[a])

                a += 1

            if b & 1:

                b -= 1

                R = self.func(self.seg[b], R)

            a >>= 1

            b >>= 1

        return self.func(L, R)

def main():

    def gcd(a, b):

        while b:

            a, b = b, a % b

        return a

    N = int(readline())

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

    seg = SegmentTree(N, gcd, 0)

    for i, n in enumerate(L):

        seg.assign(i, n)

    seg.build()

    ans = 1

    for i in range(N):

        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))

    print(ans)

main()

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

class SegmentTree:
    def __init__(self, N, func, I):
        self.func = func
        self.I = I
        self.N = N
        self.sz = 2 ** (N - 1).bit_length()
        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):
        self.seg[k + self.sz] = x

    def build(self):
        for i in reversed(list(range(1, self.sz))):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a

    N = int(readline())
    L = list(map(int, readline().split()))
    seg = SegmentTree(N, gcd, 0)
    for i, n in enumerate(L):
        seg.assign(i, n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N)))
    print(ans)

main()

import sys

readline = sys.stdin.buffer.readline

class SegmentTree:
    def __init__(self, N, func, I):
        self.N = N
        self.sz = 2 ** (N - 1).bit_length()
        self.func = func
        self.I = I
        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):
        self.seg[k + self.sz] = x

    def build(self):
        for i in reversed(list(range(1, self.sz))):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        if b == self.N:
            b = self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a

    N = int(readline())
    L = list(map(int, readline().split()))
    seg = SegmentTree(N, gcd, 0)
    for i, n in enumerate(L):
        seg.assign(i, n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N)))
    print(ans)

main()

+        self.sz = 2 ** (N - 1).bit_length()

-        self.sz = 2 ** (N - 1).bit_length()


Input:
import sys

from numpy import *

n, *a = list(map(int, sys.stdin.read().split()))

a = int_(bincount(a, [1] * n, n))

print((pow(2, n // 2, 10 ** 9 + 7) if not a[0] > (n & 1) and all([x == 2 or x == 0 for x in a[1:]]) else 0))

mod = int(1e9) + 7

n = int(eval(input()))

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

lis = [0] * n

for i in a:

    lis[i] += 1

for i in range(1,n):

    if lis[i] % 2 == 1:

        print((0))

        exit()

print((pow(2, n//2, mod)))

import sys
from numpy import *

n, *a = list(map(int, sys.stdin.read().split()))
a = int_(bincount(a, [1] * n, n))
print(
    (
        pow(2, n // 2, 10**9 + 7)
        if not a[0] > (n & 1) and all([x == 2 or x == 0 for x in a[1:]])
        else 0
    )
)

mod = int(1e9) + 7
n = int(eval(input()))
a = list(map(int, input().split()))
lis = [0] * n
for i in a:
    lis[i] += 1
for i in range(1, n):
    if lis[i] % 2 == 1:
        print((0))
        exit()
print((pow(2, n // 2, mod)))

-n, *a = list(map(int, sys.stdin.read().split()))

-        if not a[0] > (n & 1) and all([x == 2 or x == 0 for x in a[1:]])


Input:
#UnionFindクラス

class UnionFind(object):

  def __init__(self, n=1):

    self.par = [i for i in range(n)]

    self.rank = [0 for _ in range(n)]

  def find(self, x):

        if self.par[x] == x:

            return x

        else:

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

            return self.par[x]

  # xとyの根を結合させる

  def union(self, x, y):

    x = self.find(x)

    y = self.find(y)

    if x != y:

      if self.rank[x] < self.rank[y]:

        x, y = y, x

      if self.rank[x] == self.rank[y]:

        self.rank[x] += 1

      self.par[y] = x

  # x,yの根が同じかどうかを返す（根が同じ:True、根が異なる:False）

  def is_same(self, x, y):

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

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

uf_road = UnionFind(n)

uf_rail = UnionFind(n)

for i in range(k):

  tmp1,tmp2 = list(map(int,input().split()))

  uf_road.union(tmp1-1,tmp2-1)

for i in range(l):

  tmp1,tmp2 = list(map(int,input().split()))

  uf_rail.union(tmp1-1,tmp2-1)

memo = {}

for i in range(n):

  if str(uf_rail.find(i))+" "+str(uf_road.find(i)) not in memo:

    memo[str(uf_rail.find(i))+" "+str(uf_road.find(i))] = 1

  else:

    memo[str(uf_rail.find(i))+" "+str(uf_road.find(i))] += 1

for i in range(n):

  print((memo[str(uf_rail.find(i))+" "+str(uf_road.find(i))]))

class UnionFind:

    """素集合を木構造として管理する"""

    def __init__(self, n):

        self.parent = [-1] * n

        self.cnt = n

    def root(self, x):

        """要素xの根を求める"""

        if self.parent[x] < 0:

            return x

        else:

            self.parent[x] = self.root(self.parent[x])

            return self.parent[x]

    def merge(self, x, y):

        """要素xを含む集合と要素yを含む集合を統合する"""

        x = self.root(x)

        y = self.root(y)

        if x == y:

            return

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

            x, y = y, x

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

        self.parent[y] = x

        self.cnt -= 1

    def is_same(self, x, y):

        """要素x, yが同じ集合に属するかどうかを求める"""

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

    def get_size(self, x):

        """要素xを含む集合の要素数を求める"""

        return -self.parent[self.root(x)]

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

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

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

ufk = UnionFind(n)

ufl = UnionFind(n)

uf_total = UnionFind(n)

for a, b in info_k:

    a -= 1

    b -= 1

    ufk.merge(a, b)

for a, b in info_l:

    a -= 1

    b -= 1

    ufl.merge(a, b)

pair_cnt = {}

for i in range(n):

    if (ufk.root(i), ufl.root(i)) not in pair_cnt:

        pair_cnt[ufk.root(i), ufl.root(i)] = 1

    else:

        pair_cnt[ufk.root(i), ufl.root(i)] += 1

ans = [pair_cnt[ufk.root(i), ufl.root(i)] for i in range(n)]

print((*ans))

# UnionFindクラス
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # xとyの根を結合させる
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    # x,yの根が同じかどうかを返す（根が同じ:True、根が異なる:False）
    def is_same(self, x, y):
        return self.find(x) == self.find(y)

n, k, l = list(map(int, input().split()))
uf_road = UnionFind(n)
uf_rail = UnionFind(n)
for i in range(k):
    tmp1, tmp2 = list(map(int, input().split()))
    uf_road.union(tmp1 - 1, tmp2 - 1)
for i in range(l):
    tmp1, tmp2 = list(map(int, input().split()))
    uf_rail.union(tmp1 - 1, tmp2 - 1)
memo = {}
for i in range(n):
    if str(uf_rail.find(i)) + " " + str(uf_road.find(i)) not in memo:
        memo[str(uf_rail.find(i)) + " " + str(uf_road.find(i))] = 1
    else:
        memo[str(uf_rail.find(i)) + " " + str(uf_road.find(i))] += 1
for i in range(n):
    print((memo[str(uf_rail.find(i)) + " " + str(uf_road.find(i))]))

-        self.par = [i for i in range(n)]

-        self.rank = [0 for _ in range(n)]

+    """素集合を木構造として管理する"""

+        """要素xの根を求める"""

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

+            self.parent[x] = self.root(self.parent[x])

-    # xとyの根を結合させる

-            if self.rank[x] < self.rank[y]:

-            if self.rank[x] == self.rank[y]:

+        """要素xを含む集合と要素yを含む集合を統合する"""

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

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

-    # x,yの根が同じかどうかを返す（根が同じ:True、根が異なる:False）

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

+        """要素x, yが同じ集合に属するかどうかを求める"""

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

+        """要素xを含む集合の要素数を求める"""

+        return -self.parent[self.root(x)]

-    tmp1, tmp2 = list(map(int, input().split()))

+info_k = [list(map(int, input().split())) for i in range(k)]

+info_l = [list(map(int, input().split())) for i in range(l)]

-    if str(uf_rail.find(i)) + " " + str(uf_road.find(i)) not in memo:

-        memo[str(uf_rail.find(i)) + " " + str(uf_road.find(i))] = 1

+    if (ufk.root(i), ufl.root(i)) not in pair_cnt:

+        pair_cnt[ufk.root(i), ufl.root(i)] = 1

-        memo[str(uf_rail.find(i)) + " " + str(uf_road.find(i))] += 1

-    print((memo[str(uf_rail.find(i)) + " " + str(uf_road.find(i))]))

+        pair_cnt[ufk.root(i), ufl.root(i)] += 1

+ans = [pair_cnt[ufk.root(i), ufl.root(i)] for i in range(n)]


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

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

ans = [[] for _ in range(8)]

for x,y,z in xyz:

    for i in range(8):

        ans[i].append(x*((-1)**i)+y*((-1)**(i//2))+z*((-1)**(i//4)))

out = []

for i in range(8):

    ans[i].sort(reverse=True)

    out.append(sum(ans[i][:M]))

print((max(out)))

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

XYZ = [list(map(int,input().split())) for _ in [0]*N]

W = [[0]*N for _ in [0]*4]

for i,xyz in enumerate(XYZ):

    x,y,z = xyz

    W[0][i] = x+y+z

    W[1][i] = x+y-z

    W[2][i] = x-y+z

    W[3][i] = x-y-z

ans = 0

for i in range(4):

    W[i].sort()

    ans = max(ans,

             abs(sum(W[i][:M])),

             abs(sum(W[i][-M:])))

if M==0:ans=0

print(ans)

N, M = list(map(int, input().split()))
xyz = [list(map(int, input().split())) for _ in range(N)]
ans = [[] for _ in range(8)]
for x, y, z in xyz:
    for i in range(8):
        ans[i].append(x * ((-1) ** i) + y * ((-1) ** (i // 2)) + z * ((-1) ** (i // 4)))
out = []
for i in range(8):
    ans[i].sort(reverse=True)
    out.append(sum(ans[i][:M]))
print((max(out)))

N, M = list(map(int, input().split()))
XYZ = [list(map(int, input().split())) for _ in [0] * N]
W = [[0] * N for _ in [0] * 4]
for i, xyz in enumerate(XYZ):
    x, y, z = xyz
    W[0][i] = x + y + z
    W[1][i] = x + y - z
    W[2][i] = x - y + z
    W[3][i] = x - y - z
ans = 0
for i in range(4):
    W[i].sort()
    ans = max(ans, abs(sum(W[i][:M])), abs(sum(W[i][-M:])))
if M == 0:
    ans = 0
print(ans)

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

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

+    ans = max(ans, abs(sum(W[i][:M])), abs(sum(W[i][-M:])))


Input:
s=eval(input())

for i in range(len(s)):

    if s[i]=="A":

        a=i

        break

for i in range(len(s)):

    if s[-i-1]=="Z":

        print((len(s)-i-a))

        break

s=eval(input())

l=len(s)

a,b=0,l-1

for i in range(l):

    if s[i]=="A":

        a=i

        break

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

    if s[i]=="Z":

        b=i

        break

print((b-a+1))

s = eval(input())
for i in range(len(s)):
    if s[i] == "A":
        a = i
        break
for i in range(len(s)):
    if s[-i - 1] == "Z":
        print((len(s) - i - a))
        break

s = eval(input())
l = len(s)
a, b = 0, l - 1
for i in range(l):
    if s[i] == "A":
        a = i
        break
for i in range(l - 1, -1, -1):
    if s[i] == "Z":
        b = i
        break
print((b - a + 1))

-for i in range(len(s)):
+l = len(s)
+a, b = 0, l - 1
+for i in range(l):
-for i in range(len(s)):
-    if s[-i - 1] == "Z":
-        print((len(s) - i - a))
+for i in range(l - 1, -1, -1):
+    if s[i] == "Z":
+        b = i
+print((b - a + 1))


Input:
import sys

n=int(eval(input()))

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

l=[]

free=0

for i in range(n):

    if 1<=a[i]<=399:

        l.append(1)

    elif 400<=a[i]<=799:

        l.append(2)

    elif 800<=a[i]<=1199:

        l.append(3)

    elif 1200<=a[i]<=1599:

        l.append(4)

    elif 1600<=a[i]<=1999:

        l.append(5)

    elif 2000<=a[i]<=2399:

        l.append(6)

    elif 2400<=a[i]<=2799:

        l.append(7)

    elif 2800<=a[i]<=3199:

        l.append(8)

    else:

        free+=1

if len(set(l))==0:

    print((1,free))

    sys.exit()

print((len(set(l)),len(set(l))+free))

n=int(eval(input()))

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

B=[]

C=[]

for i in range(n):

    for j in range(8):

        if (j*400)<=A[i]<((j+1)*400):

            B.append(j)

    if 3200<=A[i]:

        C.append(i)

print((max(len(set(B)),1),len(set(B))+len(C)))

import sys

n = int(eval(input()))
a = list(map(int, input().split()))
l = []
free = 0
for i in range(n):
    if 1 <= a[i] <= 399:
        l.append(1)
    elif 400 <= a[i] <= 799:
        l.append(2)
    elif 800 <= a[i] <= 1199:
        l.append(3)
    elif 1200 <= a[i] <= 1599:
        l.append(4)
    elif 1600 <= a[i] <= 1999:
        l.append(5)
    elif 2000 <= a[i] <= 2399:
        l.append(6)
    elif 2400 <= a[i] <= 2799:
        l.append(7)
    elif 2800 <= a[i] <= 3199:
        l.append(8)
    else:
        free += 1
if len(set(l)) == 0:
    print((1, free))
    sys.exit()
print((len(set(l)), len(set(l)) + free))

n = int(eval(input()))
A = list(map(int, input().split()))
B = []
C = []
for i in range(n):
    for j in range(8):
        if (j * 400) <= A[i] < ((j + 1) * 400):
            B.append(j)
    if 3200 <= A[i]:
        C.append(i)
print((max(len(set(B)), 1), len(set(B)) + len(C)))

-print((len(set(l)), len(set(l)) + free))

+print((max(len(set(B)), 1), len(set(B)) + len(C)))


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

cnt = 0

for i in range(K+1):

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

    if 0 <= S - i - j <= K:

      if i == j:

        cnt += 1

      else:

        cnt += 2

print(cnt)

K, S = list(map(int, input().split()))
cnt = 0
for i in range(K + 1):
    for j in range(i, K + 1):
        if 0 <= S - i - j <= K:
            if i == j:
                cnt += 1
            else:
                cnt += 2
print(cnt)


Input:
import sys

input = sys.stdin.readline

def main():

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

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

    INF = float("inf")

    M = [INF] * N

    P = [INF] * N

    i_m, i_p = 0, 0

    for x in X:

        if x == 0:

            K -= 1

        elif x > 0:

            P[i_p] = x

            i_p += 1

        else:

            M[i_m] = -x

            i_m += 1

    if K <= 0:

        print((0))

        exit()

    M.sort()

    P.sort()

    ans = min(M[K - 1], P[K - 1])

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

        dist = 2 * M[n_M - 1] + P[K - n_M - 1]

        if ans > dist:

            ans = dist

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

        dist = 2 * P[n_P - 1] + M[K - n_P - 1]

        if ans > dist:

            ans = dist

    print(ans)

if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline

def main():

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

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

    X.sort()

    ans = float("inf")

    for l in range(N - K + 1):

        r = l + K - 1

        l2r = abs(X[l]) + abs(X[l] - X[r])

        r2l = abs(X[r]) + abs(X[r] - X[l])

        ans = min(ans, l2r, r2l)

    print(ans)

if __name__ == "__main__":

    main()


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

LR = [[int(i) for i in input().split()] for _ in range(N)]

# 区間を右端の小さい順にソート

LR = sorted([(x-l, x+l) for x,l in LR],key=lambda x: x[1])

ans = 0

# 現在選んでいる区間の内、最も右にある区間の右端

cur_R = -float("inf")

for i in range(N):

    # 区間が被るとき

    if cur_R > LR[i][0]:

        continue

    ans += 1

    cur_R = LR[i][1]

print(ans)

import sys

input = sys.stdin.readline

def main():

    N = int(eval(input()))

    LR = [[int(i) for i in input().split()] for _ in range(N)]

    # 区間を右端の小さい順にソート

    LR = sorted([(x-l, x+l) for x,l in LR],key=lambda x: x[1])

    ans = 0

    # 現在選んでいる区間の内、最も右にある区間の右端

    cur_R = -float("inf")

    for i in range(N):

        # 区間が被るとき

        if cur_R > LR[i][0]:

            continue

        ans += 1

        cur_R = LR[i][1]

    print(ans)

if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline

def main():
    N = int(eval(input()))
    LR = [[int(i) for i in input().split()] for _ in range(N)]
    # 区間を右端の小さい順にソート
    LR = sorted([(x - l, x + l) for x, l in LR], key=lambda x: x[1])
    ans = 0
    # 現在選んでいる区間の内、最も右にある区間の右端
    cur_R = -float("inf")
    for i in range(N):
        # 区間が被るとき
        if cur_R > LR[i][0]:
            continue
        ans += 1
        cur_R = LR[i][1]
    print(ans)

if __name__ == "__main__":
    main()

-LR = [[int(i) for i in input().split()] for _ in range(N)]

-# 区間を右端の小さい順にソート

-LR = sorted([(x - l, x + l) for x, l in LR], key=lambda x: x[1])

-# 現在選んでいる区間の内、最も右にある区間の右端

-    # 区間が被るとき

+    LR = [[int(i) for i in input().split()] for _ in range(N)]

+    # 区間を右端の小さい順にソート

+    LR = sorted([(x - l, x + l) for x, l in LR], key=lambda x: x[1])

+    # 現在選んでいる区間の内、最も右にある区間の右端

+        # 区間が被るとき


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

r=2018

for i in range(L,min(R,L+2019)):

    for j in range(L+1,min(R+1,L+2020)):

        r=min(r,(i*j)%2019)

print(r)

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

if R-L>2018:

    print((0))

else:

    r=2018

    for i in range(L,min(R,L+2019)):

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

            r=min(r,(i*j)%2019)

    print(r)

L, R = list(map(int, input().split()))
r = 2018
for i in range(L, min(R, L + 2019)):
    for j in range(L + 1, min(R + 1, L + 2020)):
        r = min(r, (i * j) % 2019)
print(r)

L, R = list(map(int, input().split()))
if R - L > 2018:
    print((0))
else:
    r = 2018
    for i in range(L, min(R, L + 2019)):
        for j in range(i + 1, min(R + 1, L + 2020)):
            r = min(r, (i * j) % 2019)
    print(r)

-    for j in range(L + 1, min(R + 1, L + 2020)):

+    for i in range(L, min(R, L + 2019)):

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


Input:
import sys

input = sys.stdin.readline

from collections import *

def compress(l):

    l = list(set(l))

    l.sort()

    idx = defaultdict(int)

    for i in range(len(l)):

        idx[l[i]] = i

    return idx

class BIT:

    def __init__(self, n):

        self.n = n

        self.bit = [0]*(n+1)

    def add(self, i, x):

        i += 1

        while i<=self.n:

            self.bit[i] += x

            i += i&(-i)

    def acc(self, i):

        s = 0

        while i>0:

            s += self.bit[i]

            i -= i&(-i)

        return s

N = int(eval(input()))

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

xy.sort(key=lambda t: t[0])

idx = compress([xy_i[1] for xy_i in xy])

lbit = BIT(N)

rbit = BIT(N)

for i in range(N):

    rbit.add(i, 1)

ans = 0

MOD = 998244353

for i in range(N):

    y = xy[i][1]

    rbit.add(idx[y], -1)

    a = i-lbit.acc(idx[y])

    b = lbit.acc(idx[y])

    c = rbit.acc(idx[y])

    d = N-1-i-rbit.acc(idx[y])

    add = 2*pow(2, N-1, MOD)-1

    add = (add-(pow(2, a, MOD)-1))%MOD

    add = (add-(pow(2, b, MOD)-1))%MOD

    add = (add-(pow(2, c, MOD)-1))%MOD

    add = (add-(pow(2, d, MOD)-1))%MOD

    add = (add-(pow(2, a+b, MOD)-pow(2, a, MOD)-pow(2, b, MOD)+1))%MOD

    add = (add-(pow(2, b+c, MOD)-pow(2, b, MOD)-pow(2, c, MOD)+1))%MOD

    add = (add-(pow(2, c+d, MOD)-pow(2, c, MOD)-pow(2, d, MOD)+1))%MOD

    add = (add-(pow(2, d+a, MOD)-pow(2, d, MOD)-pow(2, a, MOD)+1))%MOD

    ans += add

    ans %= MOD

    lbit.add(idx[y], 1)

print(ans)

import sys

input = sys.stdin.readline

from collections import *

def compress(l):

    l = list(set(l))

    l.sort()

    idx = defaultdict(int)

    for i in range(len(l)):

        idx[l[i]] = i

    return idx

class BIT:

    def __init__(self, n):

        self.n = n

        self.bit = [0]*(n+1)

    def add(self, i, x):

        i += 1

        while i<=self.n:

            self.bit[i] += x

            i += i&(-i)

    def acc(self, i):

        s = 0

        while i>0:

            s += self.bit[i]

            i -= i&(-i)

        return s

N = int(eval(input()))

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

xy.sort(key=lambda t: t[0])

idx = compress([xy_i[1] for xy_i in xy])

lbit = BIT(N)

rbit = BIT(N)

for i in range(N):

    rbit.add(i, 1)

ans = 0

MOD = 998244353

for i in range(N):

    y = xy[i][1]

    rbit.add(idx[y], -1)

    a = i-lbit.acc(idx[y])

    b = lbit.acc(idx[y])

    c = rbit.acc(idx[y])

    d = N-1-i-rbit.acc(idx[y])

    add = 2*pow(2, N-1, MOD)-1

    pa = pow(2, a, MOD)

    pb = pow(2, b, MOD)

    pc = pow(2, c, MOD)

    pd = pow(2, d, MOD)

    add = (add-(pa-1))%MOD

    add = (add-(pb-1))%MOD

    add = (add-(pc-1))%MOD

    add = (add-(pd-1))%MOD

    add = (add-(pa*pb-pa-pb+1))%MOD

    add = (add-(pb*pc-pb-pc+1))%MOD

    add = (add-(pc*pd-pc-pd+1))%MOD

    add = (add-(pd*pa-pd-pa+1))%MOD

    ans += add

    ans %= MOD

    lbit.add(idx[y], 1)

print(ans)

import sys

input = sys.stdin.readline
from collections import *

def compress(l):
    l = list(set(l))
    l.sort()
    idx = defaultdict(int)
    for i in range(len(l)):
        idx[l[i]] = i
    return idx

class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def add(self, i, x):
        i += 1
        while i <= self.n:
            self.bit[i] += x
            i += i & (-i)

    def acc(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & (-i)
        return s

N = int(eval(input()))
xy = [tuple(map(int, input().split())) for _ in range(N)]
xy.sort(key=lambda t: t[0])
idx = compress([xy_i[1] for xy_i in xy])
lbit = BIT(N)
rbit = BIT(N)
for i in range(N):
    rbit.add(i, 1)
ans = 0
MOD = 998244353
for i in range(N):
    y = xy[i][1]
    rbit.add(idx[y], -1)
    a = i - lbit.acc(idx[y])
    b = lbit.acc(idx[y])
    c = rbit.acc(idx[y])
    d = N - 1 - i - rbit.acc(idx[y])
    add = 2 * pow(2, N - 1, MOD) - 1
    add = (add - (pow(2, a, MOD) - 1)) % MOD
    add = (add - (pow(2, b, MOD) - 1)) % MOD
    add = (add - (pow(2, c, MOD) - 1)) % MOD
    add = (add - (pow(2, d, MOD) - 1)) % MOD
    add = (add - (pow(2, a + b, MOD) - pow(2, a, MOD) - pow(2, b, MOD) + 1)) % MOD
    add = (add - (pow(2, b + c, MOD) - pow(2, b, MOD) - pow(2, c, MOD) + 1)) % MOD
    add = (add - (pow(2, c + d, MOD) - pow(2, c, MOD) - pow(2, d, MOD) + 1)) % MOD
    add = (add - (pow(2, d + a, MOD) - pow(2, d, MOD) - pow(2, a, MOD) + 1)) % MOD
    ans += add
    ans %= MOD
    lbit.add(idx[y], 1)
print(ans)

import sys

input = sys.stdin.readline
from collections import *

def compress(l):
    l = list(set(l))
    l.sort()
    idx = defaultdict(int)
    for i in range(len(l)):
        idx[l[i]] = i
    return idx

class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def add(self, i, x):
        i += 1
        while i <= self.n:
            self.bit[i] += x
            i += i & (-i)

    def acc(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & (-i)
        return s

N = int(eval(input()))
xy = [tuple(map(int, input().split())) for _ in range(N)]
xy.sort(key=lambda t: t[0])
idx = compress([xy_i[1] for xy_i in xy])
lbit = BIT(N)
rbit = BIT(N)
for i in range(N):
    rbit.add(i, 1)
ans = 0
MOD = 998244353
for i in range(N):
    y = xy[i][1]
    rbit.add(idx[y], -1)
    a = i - lbit.acc(idx[y])
    b = lbit.acc(idx[y])
    c = rbit.acc(idx[y])
    d = N - 1 - i - rbit.acc(idx[y])
    add = 2 * pow(2, N - 1, MOD) - 1
    pa = pow(2, a, MOD)
    pb = pow(2, b, MOD)
    pc = pow(2, c, MOD)
    pd = pow(2, d, MOD)
    add = (add - (pa - 1)) % MOD
    add = (add - (pb - 1)) % MOD
    add = (add - (pc - 1)) % MOD
    add = (add - (pd - 1)) % MOD
    add = (add - (pa * pb - pa - pb + 1)) % MOD
    add = (add - (pb * pc - pb - pc + 1)) % MOD
    add = (add - (pc * pd - pc - pd + 1)) % MOD
    add = (add - (pd * pa - pd - pa + 1)) % MOD
    ans += add
    ans %= MOD
    lbit.add(idx[y], 1)
print(ans)

-    add = (add - (pow(2, a, MOD) - 1)) % MOD

-    add = (add - (pow(2, b, MOD) - 1)) % MOD

-    add = (add - (pow(2, c, MOD) - 1)) % MOD

-    add = (add - (pow(2, d, MOD) - 1)) % MOD

-    add = (add - (pow(2, a + b, MOD) - pow(2, a, MOD) - pow(2, b, MOD) + 1)) % MOD

-    add = (add - (pow(2, b + c, MOD) - pow(2, b, MOD) - pow(2, c, MOD) + 1)) % MOD

-    add = (add - (pow(2, c + d, MOD) - pow(2, c, MOD) - pow(2, d, MOD) + 1)) % MOD

-    add = (add - (pow(2, d + a, MOD) - pow(2, d, MOD) - pow(2, a, MOD) + 1)) % MOD

+    add = (add - (pa * pb - pa - pb + 1)) % MOD

+    add = (add - (pb * pc - pb - pc + 1)) % MOD

+    add = (add - (pc * pd - pc - pd + 1)) % MOD

+    add = (add - (pd * pa - pd - pa + 1)) % MOD


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

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

isBalls = [0] * (N+1)

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

    num = sum([isBalls[k*i] for i in range(1, N//k+1)])

    if num % 2 != As[k-1]:

        isBalls[k] = 1

M = sum(isBalls)

anss = [i for i in range(1, N+1) if isBalls[i] > 0]

print(M)

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

N = int(eval(input()))

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

Bs = [0] * (N+1)

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

    parity = sum(Bs[i::i]) % 2

    if parity != As[i-1]:

        Bs[i] = 1

anss = [i for i in range(1, N+1) if Bs[i]]

print((len(anss)))

if anss:

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

N = int(eval(input()))
As = list(map(int, input().split()))
isBalls = [0] * (N + 1)
for k in reversed(list(range(1, N + 1))):
    num = sum([isBalls[k * i] for i in range(1, N // k + 1)])
    if num % 2 != As[k - 1]:
        isBalls[k] = 1
M = sum(isBalls)
anss = [i for i in range(1, N + 1) if isBalls[i] > 0]
print(M)
print((" ".join(map(str, anss))))

N = int(eval(input()))
As = list(map(int, input().split()))
Bs = [0] * (N + 1)
for i in reversed(list(range(1, N + 1))):
    parity = sum(Bs[i::i]) % 2
    if parity != As[i - 1]:
        Bs[i] = 1
anss = [i for i in range(1, N + 1) if Bs[i]]
print((len(anss)))
if anss:
    print((" ".join(map(str, anss))))

-for k in reversed(list(range(1, N + 1))):

-    num = sum([isBalls[k * i] for i in range(1, N // k + 1)])

-anss = [i for i in range(1, N + 1) if isBalls[i] > 0]

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

+anss = [i for i in range(1, N + 1) if Bs[i]]


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

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

q = int(eval(input()))

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

from scipy.sparse.csgraph import floyd_warshall

for i in range(m):  # ノード番号が1始まりで与えられている場合

    for j in range(2):

        A[i][j] -= 1

for i in range(q):  # ノード番号が1始まりで与えられている場合

    for j in range(2):

        S[i][j] -= 1

M = [[float("inf")] * n for i in range(n)]

for i in range(n):

    M[i][i] = 0

for i in range(m):

    M[A[i][0]][A[i][1]] = A[i][2]

    M[A[i][1]][A[i][0]] = A[i][2]

# for k in range(n):

#     for i in range(n):

#         for j in range(n):

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

M = floyd_warshall(M)

for i in range(n):

    for j in range(n):

        M[i][j] = 1 if M[i][j] <= l else float("inf")

for i in range(n):

    M[i][i] = 0

# for k in range(n):

#     for i in range(n):

#         for j in range(n):

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

M = floyd_warshall(M)

for i in range(q):

    ans = M[S[i][0]][S[i][1]]-1

    if ans == float("inf"):

        ans = -1

    print((int(ans)))

import sys

input = sys.stdin.readline

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

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

q = int(eval(input()))

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

from scipy.sparse.csgraph import floyd_warshall

for i in range(m):  # ノード番号が1始まりで与えられている場合

    for j in range(2):

        A[i][j] -= 1

for i in range(q):  # ノード番号が1始まりで与えられている場合

    for j in range(2):

        S[i][j] -= 1

M = [[float("inf")] * n for i in range(n)]

for i in range(n):

    M[i][i] = 0

for i in range(m):

    M[A[i][0]][A[i][1]] = A[i][2]

    M[A[i][1]][A[i][0]] = A[i][2]

# for k in range(n):

#     for i in range(n):

#         for j in range(n):

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

M = floyd_warshall(M)

for i in range(n):

    for j in range(n):

        M[i][j] = 1 if M[i][j] <= l else float("inf")

for i in range(n):

    M[i][i] = 0

# for k in range(n):

#     for i in range(n):

#         for j in range(n):

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

M = floyd_warshall(M)

for i in range(q):

    ans = M[S[i][0]][S[i][1]]-1

    if ans == float("inf"):

        ans = -1

    print((int(ans)))

import sys

input = sys.stdin.readline
n, m, l = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(m)]
q = int(eval(input()))
S = [list(map(int, input().split())) for i in range(q)]
from scipy.sparse.csgraph import floyd_warshall

for i in range(m):  # ノード番号が1始まりで与えられている場合
    for j in range(2):
        A[i][j] -= 1
for i in range(q):  # ノード番号が1始まりで与えられている場合
    for j in range(2):
        S[i][j] -= 1
M = [[float("inf")] * n for i in range(n)]
for i in range(n):
    M[i][i] = 0
for i in range(m):
    M[A[i][0]][A[i][1]] = A[i][2]
    M[A[i][1]][A[i][0]] = A[i][2]
# for k in range(n):
#     for i in range(n):
#         for j in range(n):
#             M[i][j] = min(M[i][j], M[i][k] + M[k][j])
M = floyd_warshall(M)
for i in range(n):
    for j in range(n):
        M[i][j] = 1 if M[i][j] <= l else float("inf")
for i in range(n):
    M[i][i] = 0
# for k in range(n):
#     for i in range(n):
#         for j in range(n):
#             M[i][j] = min(M[i][j], M[i][k] + M[k][j])
M = floyd_warshall(M)
for i in range(q):
    ans = M[S[i][0]][S[i][1]] - 1
    if ans == float("inf"):
        ans = -1
    print((int(ans)))

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


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

"""

D - Cake 123

https://atcoder.jp/contests/abc123/tasks/abc123_d

"""

import sys

from itertools import product

def solve(X, Y, Z, K, A, B, C):

    # TLE

    res_AB = sorted([sum(p) for p in product(A, B)], reverse=True)[:K]

    return sorted([sum(p) for p in product(res_AB, C)], reverse=True)[:K]

def main(args):

    X, Y, Z, K = map(int, input().split())

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

    B = [int(b) for b in input().split()]

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

    ans = solve(X, Y, Z, K, A, B, C)

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

if __name__ == '__main__':

    main(sys.argv[1:])

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

"""

D - Cake 123

https://atcoder.jp/contests/abc123/tasks/abc123_d

AC

"""

import sys

from itertools import product

def solve(X, Y, Z, K, A, B, C):

    # 解説の解法#2

    A.sort(reverse=True)

    B.sort(reverse=True)

    C.sort(reverse=True)

    res = []

    for i, a in enumerate(A, start=1):

        for j, b in enumerate(B, start=1):

            for k, c in enumerate(C, start=1):

                if i*j*k > K:

                    break

                res.append(a+b+c)

    return sorted(res, reverse=True)[:K]

def main(args):

    X, Y, Z, K = map(int, input().split())

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

    B = [int(b) for b in input().split()]

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

    ans = solve(X, Y, Z, K, A, B, C)

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

if __name__ == '__main__':

    main(sys.argv[1:])

# -*- coding: utf-8 -*-
"""
D - Cake 123
https://atcoder.jp/contests/abc123/tasks/abc123_d
"""
import sys
from itertools import product

def solve(X, Y, Z, K, A, B, C):
    # TLE
    res_AB = sorted([sum(p) for p in product(A, B)], reverse=True)[:K]
    return sorted([sum(p) for p in product(res_AB, C)], reverse=True)[:K]

def main(args):
    X, Y, Z, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    C = [int(c) for c in input().split()]
    ans = solve(X, Y, Z, K, A, B, C)
    print(*ans, sep="\n")

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

# -*- coding: utf-8 -*-
"""
D - Cake 123
https://atcoder.jp/contests/abc123/tasks/abc123_d
AC
"""
import sys
from itertools import product

def solve(X, Y, Z, K, A, B, C):
    # 解説の解法#2
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    res = []
    for i, a in enumerate(A, start=1):
        for j, b in enumerate(B, start=1):
            for k, c in enumerate(C, start=1):
                if i * j * k > K:
                    break
                res.append(a + b + c)
    return sorted(res, reverse=True)[:K]

def main(args):
    X, Y, Z, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    C = [int(c) for c in input().split()]
    ans = solve(X, Y, Z, K, A, B, C)
    print(*ans, sep="\n")

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

-    res_AB = sorted([sum(p) for p in product(A, B)], reverse=True)[:K]

-    return sorted([sum(p) for p in product(res_AB, C)], reverse=True)[:K]

+    # 解説の解法#2

+        for j, b in enumerate(B, start=1):

+            for k, c in enumerate(C, start=1):

+    return sorted(res, reverse=True)[:K]


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

s = eval(input())

w = [0] + []

e = [] + [0]

w_cnt = 0

e_cnt = 0

for i in range(n):

    if s[i] == "W":

        w_cnt += 1

    if s[n - i - 1] == "E":

        e_cnt += 1

    w.append(w_cnt)

    e.append(e_cnt)

e = e[::-1]

ans = 10 ** 9

for i in range(n):

    ans = min(ans, w[i]+e[i+1])

print(ans)

n = int(eval(input()))

s = eval(input())

w = [0]

e = [0]

w_cnt = 0

e_cnt = 0

for i in range(n):

    if s[i] == "W":

        w_cnt += 1

    else:

        e_cnt += 1

    w.append(w_cnt)

    e.append(e_cnt)

ans = 10 ** 9

for i in range(n):

    ans = min(ans, w[i]+(e[-1] - e[i+1]))

print(ans)

n = int(eval(input()))
s = eval(input())
w = [0] + []
e = [] + [0]
w_cnt = 0
e_cnt = 0
for i in range(n):
    if s[i] == "W":
        w_cnt += 1
    if s[n - i - 1] == "E":
        e_cnt += 1
    w.append(w_cnt)
    e.append(e_cnt)
e = e[::-1]
ans = 10**9
for i in range(n):
    ans = min(ans, w[i] + e[i + 1])
print(ans)

n = int(eval(input()))
s = eval(input())
w = [0]
e = [0]
w_cnt = 0
e_cnt = 0
for i in range(n):
    if s[i] == "W":
        w_cnt += 1
    else:
        e_cnt += 1
    w.append(w_cnt)
    e.append(e_cnt)
ans = 10**9
for i in range(n):
    ans = min(ans, w[i] + (e[-1] - e[i + 1]))
print(ans)


Input:
"""

author : halo2halo

date : 29, Jan, 2020

"""

import sys

# import itertools

import numpy as np

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)

def Hershad(n):

    if n == 0:

        return 0

    return n % 10 + Hershad(n // 10)

N = int(readline())

print(('Yes' if N % Hershad(N) == 0 else 'No'))

"""

author : halo2halo

date : 29, Jan, 2020

"""

import sys

# import itertools

# import numpy as np

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)

def Hershad(n):

    if n == 0:

        return 0

    return n % 10 + Hershad(n // 10)

N = int(readline())

print(('Yes' if N % Hershad(N) == 0 else 'No'))

"""
author : halo2halo
date : 29, Jan, 2020
"""
import sys

# import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)

def Hershad(n):
    if n == 0:
        return 0
    return n % 10 + Hershad(n // 10)

N = int(readline())
print(("Yes" if N % Hershad(N) == 0 else "No"))

"""
author : halo2halo
date : 29, Jan, 2020
"""
import sys

# import itertools
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)

def Hershad(n):
    if n == 0:
        return 0
    return n % 10 + Hershad(n // 10)

N = int(readline())
print(("Yes" if N % Hershad(N) == 0 else "No"))

-import numpy as np
+# import numpy as np


Input:
import itertools

n=eval(input())

c=[]

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

    c += list(itertools.product([3,5,7], repeat=i))

m=int(n)

ans=0

for i in range(len(c)):

    if 3 in c[i] and 5 in c[i] and 7 in c[i]:

        search=""

        for g in range(len(c[i])):

            search+=str(c[i][g])

        if m>=int(search):

            ans+=1

print(ans)

import bisect

def dfs(cnt, s, three, five, seven):

    if cnt == 10:

        return

    if s != "" and min(three, five, seven) > 0:

        v.append(int(s))

    dfs(cnt+1, "3"+s, three+1, five, seven)

    dfs(cnt+1, "5"+s, three, five+1, seven)

    dfs(cnt+1, "7"+s, three, five, seven+1)

v = []

dfs(0, "", 0, 0, 0)

v.sort()

n = int(eval(input()))

print((bisect.bisect_right(v, n)))

import itertools

n = eval(input())
c = []
for i in range(3, len(n) + 1):
    c += list(itertools.product([3, 5, 7], repeat=i))
m = int(n)
ans = 0
for i in range(len(c)):
    if 3 in c[i] and 5 in c[i] and 7 in c[i]:
        search = ""
        for g in range(len(c[i])):
            search += str(c[i][g])
        if m >= int(search):
            ans += 1
print(ans)

import bisect

def dfs(cnt, s, three, five, seven):
    if cnt == 10:
        return
    if s != "" and min(three, five, seven) > 0:
        v.append(int(s))
    dfs(cnt + 1, "3" + s, three + 1, five, seven)
    dfs(cnt + 1, "5" + s, three, five + 1, seven)
    dfs(cnt + 1, "7" + s, three, five, seven + 1)

v = []
dfs(0, "", 0, 0, 0)
v.sort()
n = int(eval(input()))
print((bisect.bisect_right(v, n)))

-    c += list(itertools.product([3, 5, 7], repeat=i))

-    if 3 in c[i] and 5 in c[i] and 7 in c[i]:

+    if s != "" and min(three, five, seven) > 0:

+    dfs(cnt + 1, "3" + s, three + 1, five, seven)

+    dfs(cnt + 1, "5" + s, three, five + 1, seven)

+    dfs(cnt + 1, "7" + s, three, five, seven + 1)


Input:
def make_divisors(n):

    divisors = []

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

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n//i)

    # divisors.sort()

    return divisors

n = int(eval(input()))

i = 2

cnt = 1

check = 0

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

#     m = n

#     while m % i == 0:

#         m //= i

#     m %= i

#     if m == 1:

#         print(i)

#         cnt += 1

# print(cnt)

# print()

# print()

out = [n]

while i < n: #割ってひく

    m = n

    if i - m / i > 2:

        break

    while m % i == 0:

        check = 1

        m //= i

    if (m % i == 1 and check):

        out.append(i)

        cnt += 1

    i += 1

i = 2

while i * i <= n: #割ってひく

    m = n

    while m % i == 0:

        m //= i

    if m == 1:

        out.append(i)

    i += 1

out += make_divisors(n - 1)

print((len(set(out)) - 1))

def make_divisors(n):

    divisors = []

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

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n//i)

    # divisors.sort()

    return divisors

n = int(eval(input()))

out = make_divisors(n)

ans = []

for i in out:

    if i == 1:

        continue

    m = n

    while m % i == 0:

        m //= i

    if m == 1 or m % i == 1:

        ans.append(i)

ans += make_divisors(n - 1)

# print(set(out))

print((len(set(ans)) - 1))

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

n = int(eval(input()))
i = 2
cnt = 1
check = 0
# for i in range(2, n + 1):
#     m = n
#     while m % i == 0:
#         m //= i
#     m %= i
#     if m == 1:
#         print(i)
#         cnt += 1
# print(cnt)
# print()
# print()
out = [n]
while i < n:  # 割ってひく
    m = n
    if i - m / i > 2:
        break
    while m % i == 0:
        check = 1
        m //= i
    if m % i == 1 and check:
        out.append(i)
        cnt += 1
    i += 1
i = 2
while i * i <= n:  # 割ってひく
    m = n
    while m % i == 0:
        m //= i
    if m == 1:
        out.append(i)
    i += 1
out += make_divisors(n - 1)
print((len(set(out)) - 1))

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

n = int(eval(input()))
out = make_divisors(n)
ans = []
for i in out:
    if i == 1:
        continue
    m = n
    while m % i == 0:
        m //= i
    if m == 1 or m % i == 1:
        ans.append(i)
ans += make_divisors(n - 1)
# print(set(out))
print((len(set(ans)) - 1))

-i = 2
-cnt = 1
-check = 0
-# for i in range(2, n + 1):
-#     m = n
-#     while m % i == 0:
-#         m //= i
-#     m %= i
-#     if m == 1:
-#         print(i)
-#         cnt += 1
-# print(cnt)
-# print()
-# print()
-out = [n]
-while i < n:  # 割ってひく
-    m = n
-    if i - m / i > 2:
-        break
-    while m % i == 0:
-        check = 1
-        m //= i
-    if m % i == 1 and check:
-        out.append(i)
-        cnt += 1
-    i += 1
-i = 2
-while i * i <= n:  # 割ってひく
+out = make_divisors(n)
+ans = []
+for i in out:
+    if i == 1:
+        continue
-    if m == 1:
-        out.append(i)
-    i += 1
-out += make_divisors(n - 1)
-print((len(set(out)) - 1))
+    if m == 1 or m % i == 1:
+        ans.append(i)
+ans += make_divisors(n - 1)
+# print(set(out))
+print((len(set(ans)) - 1))


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

if a + b < c:

  print("No")

else:

  print("Yes")

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

print(("No" if a + b < c else "Yes"))

-if a + b < c:
-    print("No")
-else:
-    print("Yes")
+print(("No" if a + b < c else "Yes"))


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

MAX_V = N * (10 ** 3)

w, v = [], []

for _ in range(N):

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

    w.append(a)

    v.append(b)

dp = [[10**9+7 for _ in range(MAX_V + 1)] for _ in range(N + 1)]

dp[0][0] = 0

for i in range(N):

    for j in range(MAX_V + 1):

        if j - v[i] >= 0:

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

        else:

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

mv = 0

for i in range(MAX_V + 1):

    if dp[N][i] <= W:

        mv = i

print(mv)

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

MAX_V = N * (10 ** 3)

w, v = [], []

for _ in range(N):

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

    w.append(a)

    v.append(b)

dp = [10**9+7 for _ in range(MAX_V + 1)]

dp[0] = 0

for i in range(N):

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

        if j - v[i] >= 0:

            dp[j] = min(dp[j],dp[j - v[i]] + w[i])

        else:

            dp[j] = dp[j]

mv = 0

for i in range(MAX_V + 1):

    if dp[i] <= W:

        mv = i

print(mv)

N, W = list(map(int, input().split()))
MAX_V = N * (10**3)
w, v = [], []
for _ in range(N):
    a, b = list(map(int, input().split()))
    w.append(a)
    v.append(b)
dp = [[10**9 + 7 for _ in range(MAX_V + 1)] for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for j in range(MAX_V + 1):
        if j - v[i] >= 0:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = dp[i][j]
mv = 0
for i in range(MAX_V + 1):
    if dp[N][i] <= W:
        mv = i
print(mv)

N, W = list(map(int, input().split()))
MAX_V = N * (10**3)
w, v = [], []
for _ in range(N):
    a, b = list(map(int, input().split()))
    w.append(a)
    v.append(b)
dp = [10**9 + 7 for _ in range(MAX_V + 1)]
dp[0] = 0
for i in range(N):
    for j in range(MAX_V, -1, -1):
        if j - v[i] >= 0:
            dp[j] = min(dp[j], dp[j - v[i]] + w[i])
        else:
            dp[j] = dp[j]
mv = 0
for i in range(MAX_V + 1):
    if dp[i] <= W:
        mv = i
print(mv)

-dp = [[10**9 + 7 for _ in range(MAX_V + 1)] for _ in range(N + 1)]


Input:
import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)

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

E = []

for i in range(M):

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

    E.append([L-1, R-1, C])

E = sorted(E, key=lambda X: X[1])

# N_はN以上の2べき数

N_ = 2**(len(bin(N))-2)

INF = 10**15 # 10**10

seg = [INF] * (2*N_-1)

# k番目(0index)をaに更新

def update(k, a):

    k += N_-1

    seg[k] = a

    while k > 0:

        k = (k-1)//2

        seg[k] = min(seg[k*2+1], seg[k*2+2])

# 開区間！！！[a, b)の最小値を求める

def query(a, b, k, l, r):

    if r <= a or b <= l:

        return INF

    if a <= l and r <= b:

        return seg[k]

    else:

        vl = query(a, b, k*2+1, l, (l+r)//2)

        vr = query(a, b, k*2+2, (l+r)//2, r)

        return min(vl, vr)

# 初期化

update(0, 0)

for i in range(M):

    new = query(E[i][0], E[i][1], 0, 0, N_) + E[i][2]

    if new < seg[E[i][1] + N_-1]:

        update(E[i][1], new)

if seg[N-1+N_-1] == INF:

    print((-1))

else:

    print((seg[N-1+N_-1]))

import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)

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

E = []

for i in range(M):

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

    E.append([L-1, R-1, C])

E = sorted(E)

# N_はN以上の2べき数

N_ = 2**(len(bin(N))-2)

INF = 10**15 # 10**10

seg = [INF] * (2*N_-1)

# k番目(0index)をaに更新

def update(k, a):

    k += N_-1

    seg[k] = a

    while k > 0:

        k = (k-1)//2

        seg[k] = min(seg[k*2+1], seg[k*2+2])

# 開区間！！！[a, b)の最小値を求める

def query(a, b, k, l, r):

    if r <= a or b <= l:

        return INF

    if a <= l and r <= b:

        return seg[k]

    else:

        vl = query(a, b, k*2+1, l, (l+r)//2)

        vr = query(a, b, k*2+2, (l+r)//2, r)

        return min(vl, vr)

# 初期化

update(0, 0)

for i in range(M):

    new = query(E[i][0], E[i][1], 0, 0, N_) + E[i][2]

    if new < seg[E[i][1] + N_-1]:

        update(E[i][1], new)

if seg[N-1+N_-1] == INF:

    print((-1))

else:

    print((seg[N-1+N_-1]))

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N, M = list(map(int, input().split()))
E = []
for i in range(M):
    L, R, C = list(map(int, input().split()))
    E.append([L - 1, R - 1, C])
E = sorted(E, key=lambda X: X[1])
# N_はN以上の2べき数
N_ = 2 ** (len(bin(N)) - 2)
INF = 10**15  # 10**10
seg = [INF] * (2 * N_ - 1)
# k番目(0index)をaに更新
def update(k, a):
    k += N_ - 1
    seg[k] = a
    while k > 0:
        k = (k - 1) // 2
        seg[k] = min(seg[k * 2 + 1], seg[k * 2 + 2])

# 開区間！！！[a, b)の最小値を求める
def query(a, b, k, l, r):
    if r <= a or b <= l:
        return INF
    if a <= l and r <= b:
        return seg[k]
    else:
        vl = query(a, b, k * 2 + 1, l, (l + r) // 2)
        vr = query(a, b, k * 2 + 2, (l + r) // 2, r)
        return min(vl, vr)

# 初期化
update(0, 0)
for i in range(M):
    new = query(E[i][0], E[i][1], 0, 0, N_) + E[i][2]
    if new < seg[E[i][1] + N_ - 1]:
        update(E[i][1], new)
if seg[N - 1 + N_ - 1] == INF:
    print((-1))
else:
    print((seg[N - 1 + N_ - 1]))

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N, M = list(map(int, input().split()))
E = []
for i in range(M):
    L, R, C = list(map(int, input().split()))
    E.append([L - 1, R - 1, C])
E = sorted(E)
# N_はN以上の2べき数
N_ = 2 ** (len(bin(N)) - 2)
INF = 10**15  # 10**10
seg = [INF] * (2 * N_ - 1)
# k番目(0index)をaに更新
def update(k, a):
    k += N_ - 1
    seg[k] = a
    while k > 0:
        k = (k - 1) // 2
        seg[k] = min(seg[k * 2 + 1], seg[k * 2 + 2])

# 開区間！！！[a, b)の最小値を求める
def query(a, b, k, l, r):
    if r <= a or b <= l:
        return INF
    if a <= l and r <= b:
        return seg[k]
    else:
        vl = query(a, b, k * 2 + 1, l, (l + r) // 2)
        vr = query(a, b, k * 2 + 2, (l + r) // 2, r)
        return min(vl, vr)

# 初期化
update(0, 0)
for i in range(M):
    new = query(E[i][0], E[i][1], 0, 0, N_) + E[i][2]
    if new < seg[E[i][1] + N_ - 1]:
        update(E[i][1], new)
if seg[N - 1 + N_ - 1] == INF:
    print((-1))
else:
    print((seg[N - 1 + N_ - 1]))

-E = sorted(E, key=lambda X: X[1])
+E = sorted(E)


Input:
heights = sorted([int(eval(input())) for n in range(10)])

for idx in range(-1, -4, -1):

    print(heights[idx])

l = sorted([eval(input()) for x in range(10)], reverse=True)

for h in l[:3]:

    print(h)

-heights = sorted([int(eval(input())) for n in range(10)])

+l = sorted([eval(input()) for x in range(10)], reverse=True)


Input:
s = eval(input())

t = input()[:-1]

if s == t:

    print("Yes")

else:

    print("No")

S = eval(input())

T = eval(input())

if S == T[:-1]:

    print("Yes")

else:

    print("No")

-s = eval(input())
-t = input()[:-1]
-if s == t:
+S = eval(input())
+T = eval(input())
+if S == T[:-1]:


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

dp=[0,abs(h[1]-h[0])]+[0]*(n-2)

for i in range(2,n):dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print((dp[n-1]))

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

dp=[0]*n

dp[1]=abs(h[1]-h[0])

for i in range(2,n):dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]))

print((dp[n-1]))

n, h = int(eval(input())), list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i]))
print((dp[n - 1]))


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

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

a=0

z=10**5

for i in range(m):

    a=max(a,l[i][0])

    z=min(z,l[i][1])

if a<=z:

    print((z-a+1))

else:

    print((0))

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

a=1

z=n

for _ in range(m):

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

    a=max(a,l)

    z=min(z,m)

print((max(0,z-a+1)))

n, m = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(m)]
a = 0
z = 10**5
for i in range(m):
    a = max(a, l[i][0])
    z = min(z, l[i][1])
if a <= z:
    print((z - a + 1))
else:
    print((0))

n, m = list(map(int, input().split()))
a = 1
z = n
for _ in range(m):
    l, m = list(map(int, input().split()))
    a = max(a, l)
    z = min(z, m)
print((max(0, z - a + 1)))

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

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


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

#n,p=map(int,input().split())

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

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

#素因数分解した結果を2次元配列にして返す

mx=hl[0]

ans="Yes"

for i in range(n):

    mx=max(mx,hl[i])

    if hl[i]>=mx-1:

        pass

    else:

        ans="No"

        break

print(ans)

n=int(eval(input()))

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

#t=int(input())

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

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

flag="Yes"

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

    righth=hl[i+1]

    cur=hl[i]

    if cur<=righth:

        pass

    elif cur==righth+1:

        hl[i]=cur-1

    else:

        flag="No"

        break

print(flag)

n = int(eval(input()))
# n,p=map(int,input().split())
hl = list(map(int, input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
# 素因数分解した結果を2次元配列にして返す
mx = hl[0]
ans = "Yes"
for i in range(n):
    mx = max(mx, hl[i])
    if hl[i] >= mx - 1:
        pass
    else:
        ans = "No"
        break
print(ans)

n = int(eval(input()))
# n,m=map(int,input().split())
# t=int(input())
hl = list(map(int, input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
flag = "Yes"
for i in range(n - 2, -1, -1):
    righth = hl[i + 1]
    cur = hl[i]
    if cur <= righth:
        pass
    elif cur == righth + 1:
        hl[i] = cur - 1
    else:
        flag = "No"
        break
print(flag)

-# n,p=map(int,input().split())
+# n,m=map(int,input().split())
+# t=int(input())
-# 素因数分解した結果を2次元配列にして返す
-mx = hl[0]
-ans = "Yes"
-for i in range(n):
-    mx = max(mx, hl[i])
-    if hl[i] >= mx - 1:
+flag = "Yes"
+for i in range(n - 2, -1, -1):
+    righth = hl[i + 1]
+    cur = hl[i]
+    if cur <= righth:
+    elif cur == righth + 1:
+        hl[i] = cur - 1
-        ans = "No"
+        flag = "No"
-print(ans)
+print(flag)


Input:
# https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2017/1216_arc087

# https://pitsbuffersolution.com/compro/atcoder/arc087d.php

# 最初の移動以外は、どんな操作手順後であっても、正負いずれの方向にも動けるのがミソ

def solve(s, x, y):

    X = 0

    Y = 1

    def update(move):

        st = set()

        for p in reachable[st_ind]:

            st.add(p + move)

            st.add(abs(p - move))

        reachable[st_ind] = st

        # 絶対値の等しい正負の値を取りうるので、正だけ扱う

    n = len(s)

    spl = list(map(len, s.split('T')))

    x -= next(spl)

    # ここでxを減らすと、

    # 個々のmove後のx,yは、原点対象になるので、正の座標の到達点だけ扱えばよくなる

    reachable = [{0}, {0}]

    st_ind = 1

    for move in spl:

        update(move)

        st_ind ^= 1

    return (abs(x) in reachable[X]) and (abs(y) in reachable[Y])

    # x,yが負であっても、それに対応した正の値が集合に含まれていれば、到達可能

if __name__ == '__main__':

    s = eval(input())

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

    print(('Yes' if solve(s, x, y) else 'No'))

def main():

    SFT = 8000

    CMDs = list(map(len, input().split('T')))

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

    # [-SFT,SFT] -> [0,SFT*2]

    axis = 0

    curr = [1 << (next(CMDs) + SFT), 1 << SFT]

    for d in CMDs:

        axis ^= 1

        curr[axis] = (curr[axis] >> d) | (curr[axis] << d)

    cond = (curr[0] >> (SFT + X)) & 1 and (curr[1] >> (SFT + Y)) & 1

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

if __name__ == '__main__':

    main()

# https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2017/1216_arc087
# https://pitsbuffersolution.com/compro/atcoder/arc087d.php
# 最初の移動以外は、どんな操作手順後であっても、正負いずれの方向にも動けるのがミソ
def solve(s, x, y):
    X = 0
    Y = 1

    def update(move):
        st = set()
        for p in reachable[st_ind]:
            st.add(p + move)
            st.add(abs(p - move))
        reachable[st_ind] = st
        # 絶対値の等しい正負の値を取りうるので、正だけ扱う

    n = len(s)
    spl = list(map(len, s.split("T")))
    x -= next(spl)
    # ここでxを減らすと、
    # 個々のmove後のx,yは、原点対象になるので、正の座標の到達点だけ扱えばよくなる
    reachable = [{0}, {0}]
    st_ind = 1
    for move in spl:
        update(move)
        st_ind ^= 1
    return (abs(x) in reachable[X]) and (abs(y) in reachable[Y])
    # x,yが負であっても、それに対応した正の値が集合に含まれていれば、到達可能

if __name__ == "__main__":
    s = eval(input())
    x, y = list(map(int, input().split()))
    print(("Yes" if solve(s, x, y) else "No"))

def main():
    SFT = 8000
    CMDs = list(map(len, input().split("T")))
    X, Y = list(map(int, input().split()))
    # [-SFT,SFT] -> [0,SFT*2]
    axis = 0
    curr = [1 << (next(CMDs) + SFT), 1 << SFT]
    for d in CMDs:
        axis ^= 1
        curr[axis] = (curr[axis] >> d) | (curr[axis] << d)
    cond = (curr[0] >> (SFT + X)) & 1 and (curr[1] >> (SFT + Y)) & 1
    print(("Yes" if cond else "No"))

if __name__ == "__main__":
    main()

-# 最初の移動以外は、どんな操作手順後であっても、正負いずれの方向にも動けるのがミソ

-        # 絶対値の等しい正負の値を取りうるので、正だけ扱う

-    # ここでxを減らすと、

-    # 個々のmove後のx,yは、原点対象になるので、正の座標の到達点だけ扱えばよくなる

-    return (abs(x) in reachable[X]) and (abs(y) in reachable[Y])

-    # x,yが負であっても、それに対応した正の値が集合に含まれていれば、到達可能

+    CMDs = list(map(len, input().split("T")))

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

+    curr = [1 << (next(CMDs) + SFT), 1 << SFT]

+        curr[axis] = (curr[axis] >> d) | (curr[axis] << d)

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

-    print(("Yes" if solve(s, x, y) else "No"))


Input:
import collections

import itertools as it

import math

#import numpy as np

#  = input()

#  = int(input())

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

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

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

#

# c = collections.Counter()

if h%a==0:

	print((int(h/a)))

else:

  	print((h//a+1))

#import collections

#import itertools as it

#import math

#import numpy as np

#import sys

#sys.exit()

#  = input()

#  = int(input())

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

'''

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

'''

'''

n = input()

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

'''

'''

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

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

'''

# c = collections.Counter()

#-------------------------------#

if h%a==0:

	print((int(h/a)))

else:

  	print((h//a+1))

import collections
import itertools as it
import math

# import numpy as np
#  = input()
#  = int(input())
h, a = list(map(int, input().split()))
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()
if h % a == 0:
    print((int(h / a)))
else:
    print((h // a + 1))

# import collections
# import itertools as it
# import math
# import numpy as np
# import sys
# sys.exit()
#  = input()
#  = int(input())
h, a = list(map(int, input().split()))
"""
#  = list(map(int, input().split()))
"""
"""
n = input()
a = [int(input()) for i in range(n)]
"""
"""
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
"""
# c = collections.Counter()
# -------------------------------#
if h % a == 0:
    print((int(h / a)))
else:
    print((h // a + 1))

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


Input:
import sys

import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)

n, G = I[:2]

G //= 100

p, c = I[2:].reshape(-1, 2).T

c //= 100

def main():

    v = np.arange(1, n+1)

    t = v * p + c

    combs = np.arange(2 ** n - 1)[:, None] >> np.arange(n) & 1

    res = p.sum()

    for comb in combs:

        s = t[comb == 1].sum()

        cnt = p[comb == 1].sum()

        if s - G < 0:

            m = np.amax(v[comb == 0])

            tmp = (G - s + m - 1) // m

            if tmp < p[m-1]:

                cnt += tmp

            else:

                continue

        res = min(res, cnt)

    return res

if __name__ == '__main__':

    ans = main()

    print(ans)

import sys

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

G //= 100

p = []

t = []

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

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

    p.append(pi)

    t.append(i * pi + ci // 100)

def main():

    res = sum(p)

    for i in range(2 ** n - 1):

        s = 0

        cnt = 0

        for j in range(n):

            if i >> j & 1:

                s += t[j]

                cnt += p[j]

            else:

                m = j + 1

        if s < G:

            tmp = (G - s + m - 1) // m

            if tmp < p[m-1]:

                cnt += tmp

            else:

                continue

        res = min(res, cnt)

    return res

if __name__ == '__main__':

    ans = main()

    print(ans)

import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, G = I[:2]
G //= 100
p, c = I[2:].reshape(-1, 2).T
c //= 100

def main():
    v = np.arange(1, n + 1)
    t = v * p + c
    combs = np.arange(2**n - 1)[:, None] >> np.arange(n) & 1
    res = p.sum()
    for comb in combs:
        s = t[comb == 1].sum()
        cnt = p[comb == 1].sum()
        if s - G < 0:
            m = np.amax(v[comb == 0])
            tmp = (G - s + m - 1) // m
            if tmp < p[m - 1]:
                cnt += tmp
            else:
                continue
        res = min(res, cnt)
    return res

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

import sys

n, G = list(map(int, sys.stdin.readline().split()))
G //= 100
p = []
t = []
for i in range(1, n + 1):
    pi, ci = list(map(int, sys.stdin.readline().split()))
    p.append(pi)
    t.append(i * pi + ci // 100)

def main():
    res = sum(p)
    for i in range(2**n - 1):
        s = 0
        cnt = 0
        for j in range(n):
            if i >> j & 1:
                s += t[j]
                cnt += p[j]
            else:
                m = j + 1
        if s < G:
            tmp = (G - s + m - 1) // m
            if tmp < p[m - 1]:
                cnt += tmp
            else:
                continue
        res = min(res, cnt)
    return res

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

-I = np.array(sys.stdin.read().split(), dtype=np.int64)

+n, G = list(map(int, sys.stdin.readline().split()))

+    pi, ci = list(map(int, sys.stdin.readline().split()))

-    combs = np.arange(2**n - 1)[:, None] >> np.arange(n) & 1


Input:
N, *XL = list(map(int, open(0).read().split()))

A = sorted((x + l, x - l) for x, l in zip(*[iter(XL)] * 2))

ans = 0

cur = -10 ** 9

for t, s in A:

    if cur <= s:

        cur = t

        ans += 1

print(ans)

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

A = sorted(((x + l, x - l) for x, l in zip(*[iter(XL)] * 2)), key=lambda x: x[0])

ans = 0

cur = -10 ** 9

for t, s in A:

    if cur <= s:

        cur = t

        ans += 1

print(ans)

N, *XL = list(map(int, open(0).read().split()))
A = sorted((x + l, x - l) for x, l in zip(*[iter(XL)] * 2))
ans = 0
cur = -(10**9)
for t, s in A:
    if cur <= s:
        cur = t
        ans += 1
print(ans)

N, *XL = list(map(int, open(0).read().split()))
A = sorted(((x + l, x - l) for x, l in zip(*[iter(XL)] * 2)), key=lambda x: x[0])
ans = 0
cur = -(10**9)
for t, s in A:
    if cur <= s:
        cur = t
        ans += 1
print(ans)

-A = sorted((x + l, x - l) for x, l in zip(*[iter(XL)] * 2))

+A = sorted(((x + l, x - l) for x, l in zip(*[iter(XL)] * 2)), key=lambda x: x[0])


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

P =[]

s = 0

for i in range(n):P.append(input().split())

P.append(P[0])

for i in range(n):s += int(P[i][0])*int(P[i+1][1]) - int(P[i][1])*int(P[i+1][0])

print((abs(s)*0.5))

n = int(eval(input()))

P =[]

s = 0

for i in range(n):P.append([int(i) for i in input().split()])

P.append(P[0])

for i in range(n):s += (P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0])

print((abs(s)*0.5))

n = int(eval(input()))
P = []
s = 0
for i in range(n):
    P.append(input().split())
P.append(P[0])
for i in range(n):
    s += int(P[i][0]) * int(P[i + 1][1]) - int(P[i][1]) * int(P[i + 1][0])
print((abs(s) * 0.5))

n = int(eval(input()))
P = []
s = 0
for i in range(n):
    P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):
    s += P[i][0] * P[i + 1][1] - P[i][1] * P[i + 1][0]
print((abs(s) * 0.5))

+    P.append([int(i) for i in input().split()])


Input:
from decimal import Decimal

import math

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

a=int(a)

b=Decimal(b)

x = math.floor(a*b)

print((int(x)))

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

a=int(a)

b=int(float(b)*1000)

print((a*b//1000))

from decimal import Decimal
import math

a, b = list(map(str, input().split()))
a = int(a)
b = Decimal(b)
x = math.floor(a * b)
print((int(x)))

a, b = list(map(str, input().split()))
a = int(a)
b = int(float(b) * 1000)
print((a * b // 1000))

-from decimal import Decimal
-import math
-b = Decimal(b)
-x = math.floor(a * b)
-print((int(x)))
+b = int(float(b) * 1000)
+print((a * b // 1000))


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

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

while len(A) > 1:

  A.sort()

  #print(A)

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

    #print(A[i],A[0])

    A[i] = A[i] % A[0]

  A = list([x for x in A if x != 0])

print((A[0]))

# GCD: greatest common divisor

from fractions import gcd

N = int(eval(input()))

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

ans = gcd(A[0],A[1])

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

  ans = gcd(ans,A[i+1])

print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
while len(A) > 1:
    A.sort()
    # print(A)
    for i in range(1, len(A)):
        # print(A[i],A[0])
        A[i] = A[i] % A[0]
    A = list([x for x in A if x != 0])
print((A[0]))

# GCD: greatest common divisor
from fractions import gcd

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

+# GCD: greatest common divisor
+from fractions import gcd
+
-while len(A) > 1:
-    A.sort()
-    # print(A)
-    for i in range(1, len(A)):
-        # print(A[i],A[0])
-        A[i] = A[i] % A[0]
-    A = list([x for x in A if x != 0])
-print((A[0]))
+ans = gcd(A[0], A[1])
+for i in range(1, N - 1):
+    ans = gcd(ans, A[i + 1])
+print(ans)


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

if sum(a) >= 22:

    print('bust')

else:

    print('win')

a1, a2, a3 = list(map(int, input().split()))

if a1+a2+a3 >= 22:

    print('bust')

else:

    print('win')

a = list(map(int, input().split()))
if sum(a) >= 22:
    print("bust")
else:
    print("win")

a1, a2, a3 = list(map(int, input().split()))
if a1 + a2 + a3 >= 22:
    print("bust")
else:
    print("win")

+a1, a2, a3 = list(map(int, input().split()))