Input:
#!/usr/bin/env python3

#ABC137 E

import sys

import math

import bisect

sys.setrecursionlimit(1000000000)

from heapq import heappush, heappop

from collections import defaultdict

from itertools import accumulate

from collections import Counter

from collections import deque

from operator import itemgetter

from itertools import permutations

mod = 10**9 + 7

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

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

def Bellman_Ford(edges,num_v, start):

    #start → iの最短距離

    #start:始点, num_v:頂点数, edges:[辺の始点, 辺の終点, 辺のコスト]

    dist = [-float('inf') for _ in range(num_v)]

    #dist[i] := s→iの最短距離

    dist[start] = 0

    flg = 0

    for i in range(num_v):

        update = False

        for edge in edges:

            e_from, e_to, e_cost = edge

            if e_from != -float('inf') and visited[e_to] and dist[e_to] < dist[e_from] + e_cost:

                dist[e_to] = dist[e_from] + e_cost

                update = True

        if not update:

            flg = 1

            break

    return dist, flg

n,m,p = LI()

edge = []

f = defaultdict(dict)

for _ in range(m):

    a,b,c = LI()

    edge.append([a-1,b-1,c-p])

    f[b-1][a-1] = 1

visited = [False]*n

def dfs(x):

    visited[x] = True

    for t in list(f[x].keys()):

        if not visited[t]:

            dfs(t)

dfs(n-1)

d,f = Bellman_Ford(edge,n,0)

if not f:

    print((-1))

else:

    print((max(0,d[-1])))

#!/usr/bin/env python3

import sys

import math

from bisect import bisect_right as br

from bisect import bisect_left as bl

sys.setrecursionlimit(2147483647)

from heapq import heappush, heappop,heappushpop

from collections import defaultdict

from itertools import accumulate

from collections import Counter

from collections import deque

from operator import itemgetter

from itertools import permutations

mod = 10**9 + 7

inf = float('inf')

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

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

n, m, p = LI()

abc = [LI() for _ in range(m)]

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

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

for a, b, c in abc:

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

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

visited = [False] * n

stack = [n-1]

while stack:

    v = stack.pop()

    visited[v] = True

    for u in inv_edges[v]:

        if visited[u]:

            continue

        stack.append(u)

dp = [-float('inf')] * n

dp[0] = 0

tmp = -1

for _ in range(n+1):

    flag = False

    for v in range(n):

        score = dp[v]

        for u, c in edges[v]:

            if dp[u] < score + c - p and visited[u]:

                dp[u] = score + c - p

                flag = True

if flag:

    print((-1))

else:

    print((max(0, dp[n-1])))

#!/usr/bin/env python3
# ABC137 E
import sys
import math
import bisect

sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations

mod = 10**9 + 7

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

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

def Bellman_Ford(edges, num_v, start):
    # start → iの最短距離
    # start:始点, num_v:頂点数, edges:[辺の始点, 辺の終点, 辺のコスト]
    dist = [-float("inf") for _ in range(num_v)]
    # dist[i] := s→iの最短距離
    dist[start] = 0
    flg = 0
    for i in range(num_v):
        update = False
        for edge in edges:
            e_from, e_to, e_cost = edge
            if (
                e_from != -float("inf")
                and visited[e_to]
                and dist[e_to] < dist[e_from] + e_cost
            ):
                dist[e_to] = dist[e_from] + e_cost
                update = True
        if not update:
            flg = 1
            break
    return dist, flg

n, m, p = LI()
edge = []
f = defaultdict(dict)
for _ in range(m):
    a, b, c = LI()
    edge.append([a - 1, b - 1, c - p])
    f[b - 1][a - 1] = 1
visited = [False] * n

def dfs(x):
    visited[x] = True
    for t in list(f[x].keys()):
        if not visited[t]:
            dfs(t)

dfs(n - 1)
d, f = Bellman_Ford(edge, n, 0)
if not f:
    print((-1))
else:
    print((max(0, d[-1])))

#!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl

sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations

mod = 10**9 + 7
inf = float("inf")

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

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

n, m, p = LI()
abc = [LI() for _ in range(m)]
edges = [[] for _ in range(n)]
inv_edges = [[] for _ in range(n)]
for a, b, c in abc:
    edges[a - 1].append((b - 1, c))
    inv_edges[b - 1].append(a - 1)
visited = [False] * n
stack = [n - 1]
while stack:
    v = stack.pop()
    visited[v] = True
    for u in inv_edges[v]:
        if visited[u]:
            continue
        stack.append(u)
dp = [-float("inf")] * n
dp[0] = 0
tmp = -1
for _ in range(n + 1):
    flag = False
    for v in range(n):
        score = dp[v]
        for u, c in edges[v]:
            if dp[u] < score + c - p and visited[u]:
                dp[u] = score + c - p
                flag = True
if flag:
    print((-1))
else:
    print((max(0, dp[n - 1])))

+from heapq import heappush, heappop, heappushpop

-    # start:始点, num_v:頂点数, edges:[辺の始点, 辺の終点, 辺のコスト]

-    dist = [-float("inf") for _ in range(num_v)]

-            e_from, e_to, e_cost = edge

-                e_from != -float("inf")

-                and dist[e_to] < dist[e_from] + e_cost

-                dist[e_to] = dist[e_from] + e_cost

+            if dp[u] < score + c - p and visited[u]:


Input:
import math

from decimal import Decimal

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

print((math.floor(A*B)))

A,B = input().split()

A = int(A)

B1,B2 = list(map(int,B.split('.')))

ans = A*(B1*100+B2)

print((int(ans//100)))

import math
from decimal import Decimal

A, B = list(map(Decimal, input().split()))
print((math.floor(A * B)))

A, B = input().split()
A = int(A)
B1, B2 = list(map(int, B.split(".")))
ans = A * (B1 * 100 + B2)
print((int(ans // 100)))

-A, B = list(map(Decimal, input().split()))


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

def primes(n):

    is_prime = [True] * (n+1)

    is_prime[0] = False

    is_prime[1] = False

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

        # 既にfalseになってたらスキップ

        if not is_prime[i]:

            continue

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

            is_prime[j] = False

    return is_prime

prime_ls = primes(10**5)

csum = [0] * (10**5)

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

    if prime_ls[i]:

        if prime_ls[(i+1) // 2]:

            csum[i] = csum[i-1] + 1

        else:

            csum[i] = csum[i-1]

    else:

        csum[i] = csum[i-1]

ans_ls = [0] * q

for i in range(q):

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

    ans_ls[i] = csum[r] - csum[l-1]

for ans in ans_ls:

    print(ans)

q = int(eval(input()))

Q = 10**5+1

is_prime = [1] * (Q+1)

is_prime[0],is_prime[1] = 0,0

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

    if is_prime[i]:

        product = i*2

        while product <= Q:

            is_prime[product] = 0

            product += i

is_2017_like = [0] * (Q+1)

is_2017_like_csum = [0] * (Q+1)

now = 0

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

    if is_prime[i] and is_prime[(i+1)//2]:

        is_2017_like[i] = 1

        now += 1

    is_2017_like_csum[i] = now

ans_ls = [0] * q

for i in range(q):

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

    if l >= 1:

        ans_ls[i] = is_2017_like_csum[r] - is_2017_like_csum[l-1]

    else:

        ans_ls[i] = is_2017_like_csum[r]

for i in range(q):

    print((ans_ls[i]))

q = int(eval(input()))

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        # 既にfalseになってたらスキップ
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return is_prime

prime_ls = primes(10**5)
csum = [0] * (10**5)
for i in range(1, 10**5):
    if prime_ls[i]:
        if prime_ls[(i + 1) // 2]:
            csum[i] = csum[i - 1] + 1
        else:
            csum[i] = csum[i - 1]
    else:
        csum[i] = csum[i - 1]
ans_ls = [0] * q
for i in range(q):
    l, r = list(map(int, input().split()))
    ans_ls[i] = csum[r] - csum[l - 1]
for ans in ans_ls:
    print(ans)

q = int(eval(input()))
Q = 10**5 + 1
is_prime = [1] * (Q + 1)
is_prime[0], is_prime[1] = 0, 0
for i in range(2, int(Q * 0.5) + 1):
    if is_prime[i]:
        product = i * 2
        while product <= Q:
            is_prime[product] = 0
            product += i
is_2017_like = [0] * (Q + 1)
is_2017_like_csum = [0] * (Q + 1)
now = 0
for i in range(2, Q + 1):
    if is_prime[i] and is_prime[(i + 1) // 2]:
        is_2017_like[i] = 1
        now += 1
    is_2017_like_csum[i] = now
ans_ls = [0] * q
for i in range(q):
    l, r = list(map(int, input().split()))
    if l >= 1:
        ans_ls[i] = is_2017_like_csum[r] - is_2017_like_csum[l - 1]
    else:
        ans_ls[i] = is_2017_like_csum[r]
for i in range(q):
    print((ans_ls[i]))

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

-        # 既にfalseになってたらスキップ

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

+    if is_prime[i] and is_prime[(i + 1) // 2]:

+        ans_ls[i] = is_2017_like_csum[r] - is_2017_like_csum[l - 1]

+        ans_ls[i] = is_2017_like_csum[r]


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

if N % 2 == 1:

    print((0))

    exit()

ans = 0

mod = 10

while (mod <= N):

    ans += N // mod

    mod *= 5

print(ans)

N = int(eval(input()))

ans = 0

if N % 2 == 0:

    mod = 10

    while N >= mod:

        ans += N // mod

        mod *= 5

print(ans)

N = int(eval(input()))
if N % 2 == 1:
    print((0))
    exit()
ans = 0
mod = 10
while mod <= N:
    ans += N // mod
    mod *= 5
print(ans)

-if N % 2 == 1:
-    print((0))
-    exit()
-mod = 10
-while mod <= N:
-    ans += N // mod
-    mod *= 5
+if N % 2 == 0:
+    mod = 10
+    while N >= mod:
+        ans += N // mod
+        mod *= 5


Input:
lista=[3,5,7]

count=0

lim=int(eval(input()))

while True:

    t=lista.pop(0)

    if t>lim:

        break

    c=list(str(t))

    if c.count("3") and c.count("5") and c.count("7"):

        count+=1

    lista.append(10*t+3)

    lista.append(10*t+5)

    lista.append(10*t+7)

print(count)

from collections import deque

lista=deque([3,5,7])

count=0

lim=int(eval(input()))

while True:

    t=lista.popleft()

    if t>lim:

        break

    c=list(str(t))

    if c.count("3") and c.count("5") and c.count("7"):

        count+=1

    lista.append(10*t+3)

    lista.append(10*t+5)

    lista.append(10*t+7)

print(count)

lista = [3, 5, 7]
count = 0
lim = int(eval(input()))
while True:
    t = lista.pop(0)
    if t > lim:
        break
    c = list(str(t))
    if c.count("3") and c.count("5") and c.count("7"):
        count += 1
    lista.append(10 * t + 3)
    lista.append(10 * t + 5)
    lista.append(10 * t + 7)
print(count)

from collections import deque

lista = deque([3, 5, 7])
count = 0
lim = int(eval(input()))
while True:
    t = lista.popleft()
    if t > lim:
        break
    c = list(str(t))
    if c.count("3") and c.count("5") and c.count("7"):
        count += 1
    lista.append(10 * t + 3)
    lista.append(10 * t + 5)
    lista.append(10 * t + 7)
print(count)

-lista = [3, 5, 7]
+from collections import deque
+
+lista = deque([3, 5, 7])
-    t = lista.pop(0)
+    t = lista.popleft()


Input:
import sys

def solve():

    readline = sys.stdin.buffer.readline

    mod = 10 ** 9 + 7

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

    if a == b == c:

        if a == b == c == 1:

            print((0))

        else:

            print((-1))

    else:

        cnt = 0

        while True:

            if a % 2 == b % 2 == c % 2 == 0:

                cnt += 1

                a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2

            else:

                print(cnt)

                exit()

if __name__ == '__main__':

    solve()

import sys

def solve():

    input = sys.stdin.readline

    mod = 10 ** 9 + 7

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

    if a == b == c:

        if a == b == c == 1:

            print((0))

        else:

            print((-1))

    else:

        if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:

            cnt = 0

            while True:

                if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:

                    cnt += 1

                    a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2

                else:

                    break

            print(cnt)

        else:

            print((0))

if __name__ == '__main__':

    solve()

import sys

def solve():
    readline = sys.stdin.buffer.readline
    mod = 10**9 + 7
    a, b, c = list(map(int, readline().split()))
    if a == b == c:
        if a == b == c == 1:
            print((0))
        else:
            print((-1))
    else:
        cnt = 0
        while True:
            if a % 2 == b % 2 == c % 2 == 0:
                cnt += 1
                a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
            else:
                print(cnt)
                exit()

if __name__ == "__main__":
    solve()

import sys

def solve():
    input = sys.stdin.readline
    mod = 10**9 + 7
    a, b, c = list(map(int, input().rstrip("\n").split()))
    if a == b == c:
        if a == b == c == 1:
            print((0))
        else:
            print((-1))
    else:
        if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
            cnt = 0
            while True:
                if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
                    cnt += 1
                    a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
                else:
                    break
            print(cnt)
        else:
            print((0))

if __name__ == "__main__":
    solve()

-    readline = sys.stdin.buffer.readline

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

+    a, b, c = list(map(int, input().rstrip("\n").split()))


Input:
#!/usr/bin/env python3

import sys, math

input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')

sys.setrecursionlimit(10**8)

inf = float('inf')

ans=count=0

S=eval(input())

for i in range(3):

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

        print("Bad")

        exit()

print("Good")

#!/usr/bin/env python3

import sys, math, itertools, heapq, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')

sys.setrecursionlimit(10**8)

inf = float('inf')

ans = count = 0

s=eval(input())

for i in range(3):

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

        print("Bad")

        exit()

print("Good")

#!/usr/bin/env python3
import sys, math

input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
sys.setrecursionlimit(10**8)
inf = float("inf")
ans = count = 0
S = eval(input())
for i in range(3):
    if S[i] == S[i + 1]:
        print("Bad")
        exit()
print("Good")

#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
sys.setrecursionlimit(10**8)
inf = float("inf")
ans = count = 0
s = eval(input())
for i in range(3):
    if s[i] == s[i + 1]:
        print("Bad")
        exit()
print("Good")

+import sys, math, itertools, heapq, collections, bisect


Input:
class Dice:

    def __init__(self):

        self.faces=[]

    def rotate(self, direction):

        tmp = self.faces.copy()

        if direction =="N":

            self.faces[5-1] = tmp[1-1]

            self.faces[1-1] = tmp[2-1]

            self.faces[2-1] = tmp[6-1]

            self.faces[6-1] = tmp[5-1]

        if direction =="S":

            self.faces[5-1] = tmp[6-1]

            self.faces[1-1] = tmp[5-1]

            self.faces[2-1] = tmp[1-1]

            self.faces[6-1] = tmp[2-1]

        if direction =="W":

            self.faces[4-1] = tmp[1-1]

            self.faces[1-1] = tmp[3-1]

            self.faces[3-1] = tmp[6-1]

            self.faces[6-1] = tmp[4-1]

        if direction =="E":

            self.faces[3-1] = tmp[1-1]

            self.faces[1-1] = tmp[4-1]

            self.faces[4-1] = tmp[6-1]

            self.faces[6-1] = tmp[3-1]

        return 0

    def spin(self):

        self.faces[4-1], self.faces[2-1],self.faces[5-1],self.faces[3-1] =\

        self.faces[2-1], self.faces[3-1],self.faces[4-1],self.faces[5-1]

        return 0

dices = []

lines = int(input())

for i in range(lines):

    dices.append(Dice())

    dices[i].faces=[int(x) for x in input().split(" ")]

for i, d1 in enumerate(dices):

    for d2 in dices[i+1 :]:

        for _ in range(3):

            for _ in range(4):

                for ___ in range(4):

                    #print("d1: {}".format(d1.faces))

                    #print("d2: {}".format(d2.faces))

                    if d1.faces == d2.faces:

                        print("No")

                        exit()

                    d2.spin()

                d2.rotate("W")

            d2.rotate("N")

print("Yes")

def roll(l, command):

    '''

    return rolled list

    l : string list

    command: string

    '''

    res = []

    i = -1

    if command =='N':

        res = [l[i+2], l[i+6], l[i+3], l[i+4], l[i+1], l[i+5]]

    if command =='S':

        res = [l[i+5], l[i+1], l[i+3], l[i+4], l[i+6], l[i+2]]

    if command =='E':

        res = [l[i+4], l[i+2], l[i+1], l[i+6], l[i+5], l[i+3]]

    if command =='W':

        res = [l[i+3], l[i+2], l[i+6], l[i+1], l[i+5], l[i+4]]

    return res

def spin(l):

    '''

    return right sppined list

    l : string list

    '''

    i = -1

    res = [l[i+1], l[i+3], l[i+5], l[i+2], l[i+4], l[i+6]]

    return res

def has_same_faces(a, b):

    '''

    check if all elements of a are equel to those of b.

    a : string list

    b : string list

    '''

    return set(a) == set(b)

def is_identical_lists(a, b):

    for x, y in zip(a, b):

        if x != y:

            return False

    return True

def check_two_dice(a, b):

    if not has_same_faces(a, b):

        return False

    orig_a = a[:]

    #roll and spin to check

    for i in range(6):

        if 1 <= i <= 3:

            a = roll(a, "N")

        elif i == 4:

            pass

            a = orig_a[:]

            a = roll(a, "W")

        elif i == 5:

            a = orig_a[:]

            a = roll(a, "E")

        # spin 4 times

        for _ in range(4): #spin 3 times

            a = spin(a)

            if is_identical_lists(a, b):

                return True

    return False

def check_all_different(dice):

    '''

    if all dice are different, return True

    dice : string list

    '''

    for i in range(len(dice)):

        if i == 0:

            continue

        for j in range(i):

            res = check_two_dice(dice[i], dice[j])

            if res:

                return False

    return True

if __name__ == "__main__":

    res = False

    n = int(input())

    dice = []

    for _ in range(n):

        dice.append(input().split())

    res = check_all_different(dice)

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

class Dice:
    def __init__(self):
        self.faces = []

    def rotate(self, direction):
        tmp = self.faces.copy()
        if direction == "N":
            self.faces[5 - 1] = tmp[1 - 1]
            self.faces[1 - 1] = tmp[2 - 1]
            self.faces[2 - 1] = tmp[6 - 1]
            self.faces[6 - 1] = tmp[5 - 1]
        if direction == "S":
            self.faces[5 - 1] = tmp[6 - 1]
            self.faces[1 - 1] = tmp[5 - 1]
            self.faces[2 - 1] = tmp[1 - 1]
            self.faces[6 - 1] = tmp[2 - 1]
        if direction == "W":
            self.faces[4 - 1] = tmp[1 - 1]
            self.faces[1 - 1] = tmp[3 - 1]
            self.faces[3 - 1] = tmp[6 - 1]
            self.faces[6 - 1] = tmp[4 - 1]
        if direction == "E":
            self.faces[3 - 1] = tmp[1 - 1]
            self.faces[1 - 1] = tmp[4 - 1]
            self.faces[4 - 1] = tmp[6 - 1]
            self.faces[6 - 1] = tmp[3 - 1]
        return 0

    def spin(self):
        self.faces[4 - 1], self.faces[2 - 1], self.faces[5 - 1], self.faces[3 - 1] = (
            self.faces[2 - 1],
            self.faces[3 - 1],
            self.faces[4 - 1],
            self.faces[5 - 1],
        )
        return 0

dices = []
lines = int(input())
for i in range(lines):
    dices.append(Dice())
    dices[i].faces = [int(x) for x in input().split(" ")]
for i, d1 in enumerate(dices):
    for d2 in dices[i + 1 :]:
        for _ in range(3):
            for _ in range(4):
                for ___ in range(4):
                    # print("d1: {}".format(d1.faces))
                    # print("d2: {}".format(d2.faces))
                    if d1.faces == d2.faces:
                        print("No")
                        exit()
                    d2.spin()
                d2.rotate("W")
            d2.rotate("N")
print("Yes")

def roll(l, command):
    """
    return rolled list
    l : string list
    command: string
    """
    res = []
    i = -1
    if command == "N":
        res = [l[i + 2], l[i + 6], l[i + 3], l[i + 4], l[i + 1], l[i + 5]]
    if command == "S":
        res = [l[i + 5], l[i + 1], l[i + 3], l[i + 4], l[i + 6], l[i + 2]]
    if command == "E":
        res = [l[i + 4], l[i + 2], l[i + 1], l[i + 6], l[i + 5], l[i + 3]]
    if command == "W":
        res = [l[i + 3], l[i + 2], l[i + 6], l[i + 1], l[i + 5], l[i + 4]]
    return res

def spin(l):
    """
    return right sppined list
    l : string list
    """
    i = -1
    res = [l[i + 1], l[i + 3], l[i + 5], l[i + 2], l[i + 4], l[i + 6]]
    return res

def has_same_faces(a, b):
    """
    check if all elements of a are equel to those of b.
    a : string list
    b : string list
    """
    return set(a) == set(b)

def is_identical_lists(a, b):
    for x, y in zip(a, b):
        if x != y:
            return False
    return True

def check_two_dice(a, b):
    if not has_same_faces(a, b):
        return False
    orig_a = a[:]
    # roll and spin to check
    for i in range(6):
        if 1 <= i <= 3:
            a = roll(a, "N")
        elif i == 4:
            pass
            a = orig_a[:]
            a = roll(a, "W")
        elif i == 5:
            a = orig_a[:]
            a = roll(a, "E")
        # spin 4 times
        for _ in range(4):  # spin 3 times
            a = spin(a)
            if is_identical_lists(a, b):
                return True
    return False

def check_all_different(dice):
    """
    if all dice are different, return True
    dice : string list
    """
    for i in range(len(dice)):
        if i == 0:
            continue
        for j in range(i):
            res = check_two_dice(dice[i], dice[j])
            if res:
                return False
    return True

if __name__ == "__main__":
    res = False
    n = int(input())
    dice = []
    for _ in range(n):
        dice.append(input().split())
    res = check_all_different(dice)
    print("Yes") if res else print("No")

-        self.faces[4 - 1], self.faces[2 - 1], self.faces[5 - 1], self.faces[3 - 1] = (

-    dices[i].faces = [int(x) for x in input().split(" ")]

-                    # print("d1: {}".format(d1.faces))

-                    # print("d2: {}".format(d2.faces))

-                    if d1.faces == d2.faces:

+    check if all elements of a are equel to those of b.

+        for _ in range(4):  # spin 3 times

+            if is_identical_lists(a, b):

+    if all dice are different, return True

+            res = check_two_dice(dice[i], dice[j])

+    print("Yes") if res else print("No")


Input:
#前・左につける変数、後ろ・右につける変数を用意して最後に足す

#前・左は最後にひっくり返す（abc ⇒cba)

#初期入力

import sys

input = sys.stdin.readline

S = input()

S=S.strip("\n")

Q = int(input())

FQ_dic={}

for i in range(Q):

    FQ_dic[i] =input().split()

rev =0

front =""

back =""

for i in range(Q):

   # print(S)

    if FQ_dic[i][0] =="1": #逆転する

                rev +=1

    else:                   #逆転なし

        if FQ_dic[i][1]=="1":     #前=左につける

            if rev %2 ==0:

                front += FQ_dic[i][2]

            else:

                back  += FQ_dic[i][2]

        else: #                      #後ろ=右につける

            if rev %2 ==0:

                back  += FQ_dic[i][2]

            else:

                front += FQ_dic[i][2]

front =front[::-1]

S =front + S + back

if rev %2 ==0:

    print(*S,sep="")

else:

    print(*S[::-1],sep="")

# deque で高速に文字を先頭でもたせる

#初期入力

from collections import deque

import sys

input = sys.stdin.readline

S = input().strip()

Q = int(eval(input()))

FQ_dic={}

for i in range(Q):

    FQ_dic[i] =input().split()

rev =0 #反転Flag

dq =deque(S)

for i in range(Q):

    if FQ_dic[i][0] =="1":

        rev +=1

    else:

        a,b,c =FQ_dic[i]

        if rev %2 ==0 and b =="1"  :

            dq.appendleft(c)

        elif rev %2 ==0 and b =="2":

            dq.append(c)

        elif rev %2 ==1 and b =="1":

            dq.append(c)

        elif rev %2 ==1 and b =="2":

            dq.appendleft(c)

if rev %2 ==1:

    dq.reverse()

ans ="".join(dq)

print(ans)

# 前・左につける変数、後ろ・右につける変数を用意して最後に足す
# 前・左は最後にひっくり返す（abc ⇒cba)
# 初期入力
import sys

input = sys.stdin.readline
S = input()
S = S.strip("\n")
Q = int(input())
FQ_dic = {}
for i in range(Q):
    FQ_dic[i] = input().split()
rev = 0
front = ""
back = ""
for i in range(Q):
    # print(S)
    if FQ_dic[i][0] == "1":  # 逆転する
        rev += 1
    else:  # 逆転なし
        if FQ_dic[i][1] == "1":  # 前=左につける
            if rev % 2 == 0:
                front += FQ_dic[i][2]
            else:
                back += FQ_dic[i][2]
        else:  #                      #後ろ=右につける
            if rev % 2 == 0:
                back += FQ_dic[i][2]
            else:
                front += FQ_dic[i][2]
front = front[::-1]
S = front + S + back
if rev % 2 == 0:
    print(*S, sep="")
else:
    print(*S[::-1], sep="")

# deque で高速に文字を先頭でもたせる
# 初期入力
from collections import deque
import sys

input = sys.stdin.readline
S = input().strip()
Q = int(eval(input()))
FQ_dic = {}
for i in range(Q):
    FQ_dic[i] = input().split()
rev = 0  # 反転Flag
dq = deque(S)
for i in range(Q):
    if FQ_dic[i][0] == "1":
        rev += 1
    else:
        a, b, c = FQ_dic[i]
        if rev % 2 == 0 and b == "1":
            dq.appendleft(c)
        elif rev % 2 == 0 and b == "2":
            dq.append(c)
        elif rev % 2 == 1 and b == "1":
            dq.append(c)
        elif rev % 2 == 1 and b == "2":
            dq.appendleft(c)
if rev % 2 == 1:
    dq.reverse()
ans = "".join(dq)
print(ans)

-# 前・左につける変数、後ろ・右につける変数を用意して最後に足す

-# 前・左は最後にひっくり返す（abc ⇒cba)

+# deque で高速に文字を先頭でもたせる

-        else:  #                      #後ろ=右につける


Input:
ans=0

def dfs(x,len_x,i=0):

        global ans

        if i < len_x:

                dfs(x,len_x,i=i+1)

        if i < len_x:

                x=x[:i+1] + "+" + x[i+1:]

                dfs(x,len_x + 1,i=i+2)

                ans+=sum([int(k) for k in x.split("+")])

s = eval(input())

dfs(s,len(s)-1)

print((ans+int(s)))

s = eval(input())

len_s = len(s)

ans=0

def dfs(x,len_x,i=0):

        global ans

        if i < len_x:

                dfs(x,len_x,i=i+1)

                x=x[:i+1] + "+" + x[i+1:]

                dfs(x,len_x + 1,i=i+2)

                ans+=sum([int(k) for k in x.split("+")])

dfs(s,len_s-1)

print((ans+int(s)))

ans = 0

def dfs(x, len_x, i=0):
    global ans
    if i < len_x:
        dfs(x, len_x, i=i + 1)
    if i < len_x:
        x = x[: i + 1] + "+" + x[i + 1 :]
        dfs(x, len_x + 1, i=i + 2)
        ans += sum([int(k) for k in x.split("+")])

s = eval(input())
dfs(s, len(s) - 1)
print((ans + int(s)))

s = eval(input())
len_s = len(s)
ans = 0

def dfs(x, len_x, i=0):
    global ans
    if i < len_x:
        dfs(x, len_x, i=i + 1)
        x = x[: i + 1] + "+" + x[i + 1 :]
        dfs(x, len_x + 1, i=i + 2)
        ans += sum([int(k) for k in x.split("+")])

dfs(s, len_s - 1)
print((ans + int(s)))

+s = eval(input())
+len_s = len(s)
-    if i < len_x:
-s = eval(input())
-dfs(s, len(s) - 1)
+dfs(s, len_s - 1)


Input:
import sys

def input():

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

N = int(eval(input()))

sentences = [None]*N

dp = {}

for i in range(N):

     k = list(map(str,eval(input())))

     k.sort()

     sentences[i] = k

def addTree(tree, sentence,org):

    l = len(sentence)

    if l==0:

        return None

    st = sentence[0]

    if st not in tree:

        tree[st] = {}

    else:

        if l==1:

            org = ''.join(org)

            if org in dp:

                dp[org] += 1

            else:

                dp[org] = 2

    tree[sentence[0]] = addTree(tree[st], sentence[1:],org)

    return tree

def createTree(sentences):

    tree = {}

    for sentence in sentences:

        tree = addTree(tree, sentence, sentence)

    return tree

tree = createTree(sentences)

ans = 0

for i in list(dp.values()):

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

print((int(ans)))

import sys

def input():

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

N = int(eval(input()))

sentences = [None]*N

dp = {}

for i in range(N):

     k = list(map(str,eval(input())))

     k.sort()

     k = ''.join(k)

     if k in dp:

         dp[k] += 1

     else:

         dp[k] = 1

ans = 0

for i in list(dp.values()):

    if not i==1:

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

print((int(ans)))

import sys

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

N = int(eval(input()))
sentences = [None] * N
dp = {}
for i in range(N):
    k = list(map(str, eval(input())))
    k.sort()
    sentences[i] = k

def addTree(tree, sentence, org):
    l = len(sentence)
    if l == 0:
        return None
    st = sentence[0]
    if st not in tree:
        tree[st] = {}
    else:
        if l == 1:
            org = "".join(org)
            if org in dp:
                dp[org] += 1
            else:
                dp[org] = 2
    tree[sentence[0]] = addTree(tree[st], sentence[1:], org)
    return tree

def createTree(sentences):
    tree = {}
    for sentence in sentences:
        tree = addTree(tree, sentence, sentence)
    return tree

tree = createTree(sentences)
ans = 0
for i in list(dp.values()):
    ans += i * (i - 1) / 2
print((int(ans)))

import sys

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

N = int(eval(input()))
sentences = [None] * N
dp = {}
for i in range(N):
    k = list(map(str, eval(input())))
    k.sort()
    k = "".join(k)
    if k in dp:
        dp[k] += 1
    else:
        dp[k] = 1
ans = 0
for i in list(dp.values()):
    if not i == 1:
        ans += i * (i - 1) / 2
print((int(ans)))

-    tree[sentence[0]] = addTree(tree[st], sentence[1:], org)

-        tree = addTree(tree, sentence, sentence)


Input:
import sys

def input():

    return sys.stdin.readline().rstrip()

def main():

    N = int(input())

    dp = [0] * (N + 1)

    rt = int(N ** 0.5) + 1

    for i in range(1, rt):

        ii = i ** 2

        for j in range(1, rt):

            iji = ii + j **2 + i * j

            if iji + 1 + i + j > N:

                break

            for k in range(1, rt):

                case = iji + k**2 + i * k + j * k

                if case <= N:

                    dp[case] += 1

                else:

                    break

    print(*dp[1:N + 1], sep="\n")

if __name__ == "__main__":

    main()

import sys

def input():

    return sys.stdin.readline().rstrip()

def main():

    N = int(input())

    dp = [0] * (N + 1)

    rt = int(N ** 0.5) + 1

    for i in range(1, rt):

        ii = i ** 2

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

            iji = ii + j **2 + i * j

            if iji + 1 + i + j > N:

                break

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

                case = iji + k**2 + i * k + j * k

                l =6

                if i == j or j == k:

                    l = 3

                    if i == k:

                        l = 1

                if case <= N:

                    dp[case] += l

                else:

                    break

    print(*dp[1:N + 1], sep="\n")

if __name__ == "__main__":

    main()

import sys

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

def main():
    N = int(input())
    dp = [0] * (N + 1)
    rt = int(N**0.5) + 1
    for i in range(1, rt):
        ii = i**2
        for j in range(1, rt):
            iji = ii + j**2 + i * j
            if iji + 1 + i + j > N:
                break
            for k in range(1, rt):
                case = iji + k**2 + i * k + j * k
                if case <= N:
                    dp[case] += 1
                else:
                    break
    print(*dp[1 : N + 1], sep="\n")

if __name__ == "__main__":
    main()

import sys

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

def main():
    N = int(input())
    dp = [0] * (N + 1)
    rt = int(N**0.5) + 1
    for i in range(1, rt):
        ii = i**2
        for j in range(1, i + 1):
            iji = ii + j**2 + i * j
            if iji + 1 + i + j > N:
                break
            for k in range(1, j + 1):
                case = iji + k**2 + i * k + j * k
                l = 6
                if i == j or j == k:
                    l = 3
                    if i == k:
                        l = 1
                if case <= N:
                    dp[case] += l
                else:
                    break
    print(*dp[1 : N + 1], sep="\n")

if __name__ == "__main__":
    main()

-        for j in range(1, rt):
+        for j in range(1, i + 1):
-            for k in range(1, rt):
+            for k in range(1, j + 1):
+                l = 6
+                if i == j or j == k:
+                    l = 3
+                    if i == k:
+                        l = 1
-                    dp[case] += 1
+                    dp[case] += l


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

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

l.sort(reverse = True)

ans =0

for j in range(k):

  ans += l[j]

print(ans)

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

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

l.sort(reverse=True)

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

n, k = list(map(int, input().split()))
l = [int(i) for i in input().split()]
l.sort(reverse=True)
ans = 0
for j in range(k):
    ans += l[j]
print(ans)

n, k = list(map(int, input().split()))
l = [int(_) for _ in input().split()]
l.sort(reverse=True)
print((sum(l[:k])))

-l = [int(i) for i in input().split()]
+l = [int(_) for _ in input().split()]
-ans = 0
-for j in range(k):
-    ans += l[j]
-print(ans)
+print((sum(l[:k])))


Input:
import sys

read = sys.stdin.read

readlines = sys.stdin.readlines

import numpy as np

def main():

    a = np.array(read().split(), np.int32)[1:]

    count = np.zeros(10**6+1, np.int32)

    for ae in a:

        if count[ae] <= 1:

            count[::ae] += 1

    r = 0

    for ae in a:

        r += count[ae] == 1

    print(r)

if __name__ == '__main__':

    main()

import sys

read = sys.stdin.read

readlines = sys.stdin.readlines

import numpy as np

from numba import njit

def main():

    @njit

    def solve(a):

        count = np.zeros(10 ** 6 + 1, np.int32)

        for ae in a:

            if count[ae] <= 1:

                count[::ae] += 1

        r = 0

        for ae in a:

            r += count[ae] == 1

        return r

    a = np.array(read().split(), np.int32)[1:]

    print((solve(a)))

if __name__ == '__main__':

    main()

import sys

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

def main():
    a = np.array(read().split(), np.int32)[1:]
    count = np.zeros(10**6 + 1, np.int32)
    for ae in a:
        if count[ae] <= 1:
            count[::ae] += 1
    r = 0
    for ae in a:
        r += count[ae] == 1
    print(r)

if __name__ == "__main__":
    main()

import sys

read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
from numba import njit

def main():
    @njit
    def solve(a):
        count = np.zeros(10**6 + 1, np.int32)
        for ae in a:
            if count[ae] <= 1:
                count[::ae] += 1
        r = 0
        for ae in a:
            r += count[ae] == 1
        return r

    a = np.array(read().split(), np.int32)[1:]
    print((solve(a)))

if __name__ == "__main__":
    main()

+        count = np.zeros(10**6 + 1, np.int32)

-    count = np.zeros(10**6 + 1, np.int32)


Input:
A,B,C,K=list(map(int,input().split()))

if A>=K:

    print(K)

elif A+B>=K:

    print(A)

else:

    print((A-(K-(A+B))))

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

xa=min(a,k)

k-=xa

xb=min(b,k)

k-=xb

xc=min(c,k)

print((xa-xc))

A, B, C, K = list(map(int, input().split()))
if A >= K:
    print(K)
elif A + B >= K:
    print(A)
else:
    print((A - (K - (A + B))))

a, b, c, k = list(map(int, input().split()))
xa = min(a, k)
k -= xa
xb = min(b, k)
k -= xb
xc = min(c, k)
print((xa - xc))

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

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


Input:
from collections import deque

s=eval(input())

n=int(eval(input()))

q=deque()

q.append(s)

f=1

for i in range(n):

    t=list(input().split())

    if int(t[0])==1:

        f*=-1

    else:

        if f==1:

            if t[1]=='1' :

                q.appendleft(t[2])

            else:

                q.append(t[2])

        else:

            if t[1]=='2':

                q.appendleft(t[2])

            else:

                q.append(t[2])

ans=''.join(q)

if f==-1:

    ans=ans[::-1]

print(ans)

from collections import deque

s = eval(input())

Q = int(eval(input()))

l = deque()

l.append(s)

rev = True

for i in range(Q):

    q = list(input().split())

    if q[0] == "1":

        rev = not rev

    else:

        if rev:

            if q[1] == "1":

                l.appendleft(q[2])

            else:

                l.append(q[2])

        else:

            if q[1] == "1":

                l.append(q[2])

            else:

                l.appendleft(q[2])

ans = ""

for i in l:

    ans += i

if not rev:

    print((ans[::-1]))

else:

    print(ans)

from collections import deque

s = eval(input())
n = int(eval(input()))
q = deque()
q.append(s)
f = 1
for i in range(n):
    t = list(input().split())
    if int(t[0]) == 1:
        f *= -1
    else:
        if f == 1:
            if t[1] == "1":
                q.appendleft(t[2])
            else:
                q.append(t[2])
        else:
            if t[1] == "2":
                q.appendleft(t[2])
            else:
                q.append(t[2])
ans = "".join(q)
if f == -1:
    ans = ans[::-1]
print(ans)

-n = int(eval(input()))
-q = deque()
-q.append(s)
-f = 1
-for i in range(n):
-    t = list(input().split())
-    if int(t[0]) == 1:
-        f *= -1
+Q = int(eval(input()))
+l = deque()
+l.append(s)
+rev = True
+for i in range(Q):
+    q = list(input().split())
+    if q[0] == "1":
+        rev = not rev
-        if f == 1:
-            if t[1] == "1":
-                q.appendleft(t[2])
+        if rev:
+            if q[1] == "1":
+                l.appendleft(q[2])
-                q.append(t[2])
+                l.append(q[2])
-            if t[1] == "2":
-                q.appendleft(t[2])
+            if q[1] == "1":
+                l.append(q[2])
-                q.append(t[2])
-ans = "".join(q)
-if f == -1:
-    ans = ans[::-1]
-print(ans)
+                l.appendleft(q[2])
+ans = ""
+for i in l:
+    ans += i
+if not rev:
+    print((ans[::-1]))
+else:
+    print(ans)


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

#Nが奇数の時は末尾に０はない（因数に２をもたないから）

if N%2!=0:

    print((0))

    exit()

#Nまでの数を書き出して、いつ5の因数を持つか実験して法則性をつかめばいい

#この時i=5にしないこと！（Nから2つとびで減ってるため！）

ans=0

i=10

while(i<=N):

    ans+=N//i

    i*=5

print(ans)

def main():

    N=int(eval(input()))

    if N%2!=0:

        print((0))

        exit()

    k=10

    ans=0

    while(k<=N):

        ans+=N//k

        k*=5

    print(ans)

if __name__=="__main__":

    main()

N = int(eval(input()))
# Nが奇数の時は末尾に０はない（因数に２をもたないから）
if N % 2 != 0:
    print((0))
    exit()
# Nまでの数を書き出して、いつ5の因数を持つか実験して法則性をつかめばいい
# この時i=5にしないこと！（Nから2つとびで減ってるため！）
ans = 0
i = 10
while i <= N:
    ans += N // i
    i *= 5
print(ans)

def main():
    N = int(eval(input()))
    if N % 2 != 0:
        print((0))
        exit()
    k = 10
    ans = 0
    while k <= N:
        ans += N // k
        k *= 5
    print(ans)

if __name__ == "__main__":
    main()

-N = int(eval(input()))
-# Nが奇数の時は末尾に０はない（因数に２をもたないから）
-if N % 2 != 0:
-    print((0))
-    exit()
-# Nまでの数を書き出して、いつ5の因数を持つか実験して法則性をつかめばいい
-# この時i=5にしないこと！（Nから2つとびで減ってるため！）
-ans = 0
-i = 10
-while i <= N:
-    ans += N // i
-    i *= 5
-print(ans)
+def main():
+    N = int(eval(input()))
+    if N % 2 != 0:
+        print((0))
+        exit()
+    k = 10
+    ans = 0
+    while k <= N:
+        ans += N // k
+        k *= 5
+    print(ans)
+
+
+if __name__ == "__main__":
+    main()


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

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

AB.sort(key=lambda x:(x[1],x[0]))

time=0

for a,b in AB:

  if time+a>b:

    print('No')

    exit()

  time+=a

print('Yes')

import sys

input = sys.stdin.readline

n=int(eval(input()))

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

AB.sort(key=lambda x:(x[1],x[0]))

time=0

for a,b in AB:

  if time+a>b:

    print('No')

    exit()

  time+=a

print('Yes')

import sys

input = sys.stdin.readline
n = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort(key=lambda x: (x[1], x[0]))
time = 0
for a, b in AB:
    if time + a > b:
        print("No")
        exit()
    time += a
print("Yes")

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


Input:
A1,A2,A3 = sorted(list(map(int,input().split())))

print((A3-A1))

A1,A2,A3 = sorted(map(int,input().split()))

print((A3-A1))

A1, A2, A3 = sorted(list(map(int, input().split())))
print((A3 - A1))

A1, A2, A3 = sorted(map(int, input().split()))
print((A3 - A1))

-A1, A2, A3 = sorted(list(map(int, input().split())))

+A1, A2, A3 = sorted(map(int, input().split()))


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

P = list([int(x) + 1 for x in input().split()])

s = [0] * (n+1)

for i in range(n):

    s[i+1] = s[i] + P[i]

res = 0

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

    res = max(res, s[i+k] - s[i])

print((res/2))

#from statistics import median

#import collections

#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]

from fractions import gcd

from itertools import combinations,permutations,accumulate # (string,3) 3回

#from collections import deque

from collections import deque,defaultdict,Counter

import decimal

import re

#import bisect

#

#    d = m - k[i] - k[j]

#    if kk[bisect.bisect_right(kk,d) - 1] == d:

#

#

#

# pythonで無理なときは、pypyでやると正解するかも！！

#

#

import sys

sys.setrecursionlimit(10000000)

mod = 10**9 + 7

#mod = 9982443453

def readInts():

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

def I():

  return int(eval(input()))

n,k = readInts()

p = [0] + list([int (x) + 1 for x in input().split()])

cum = list(accumulate(p))

res = 0

for i in range(len(p)-k):

    res = max(res, cum[i+k] - cum[i])

print((res / 2))

n, k = list(map(int, input().split()))
P = list([int(x) + 1 for x in input().split()])
s = [0] * (n + 1)
for i in range(n):
    s[i + 1] = s[i] + P[i]
res = 0
for i in range(n - k + 1):
    res = max(res, s[i + k] - s[i])
print((res / 2))

# from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations, permutations, accumulate  # (string,3) 3回

# from collections import deque
from collections import deque, defaultdict, Counter
import decimal
import re

# import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
import sys

sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
def readInts():
    return list(map(int, input().split()))

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

n, k = readInts()
p = [0] + list([int(x) + 1 for x in input().split()])
cum = list(accumulate(p))
res = 0
for i in range(len(p) - k):
    res = max(res, cum[i + k] - cum[i])
print((res / 2))

-P = list([int(x) + 1 for x in input().split()])

+# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]

+from itertools import combinations, permutations, accumulate  # (string,3) 3回

+from collections import deque, defaultdict, Counter

+#    if kk[bisect.bisect_right(kk,d) - 1] == d:

+# pythonで無理なときは、pypyでやると正解するかも！！

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

+p = [0] + list([int(x) + 1 for x in input().split()])

+    res = max(res, cum[i + k] - cum[i])


Input:
BASE = 9973

MOD = 2 ** 61 - 1

class RollingHash:

    # 文字列Sのローリングハッシュを構築

    # 計算量: O(N)

    def __init__(self, S):

        # acc[i]はS[0:i]のハッシュ値となる

        self.acc = [0]

        a = 0

        # 累積和を計算するイメージ

        for i, c in enumerate(S):

            h = ord(c) - ord("a") + 1

            offset = pow(BASE, i, MOD)

            a = (a + (h * offset)) % MOD

            self.acc.append(a)

    # S[i:j]のハッシュ値を返す

    # 計算量: O(1)

    def hash(self, i, j):

        # 累積和を用いて部分区間の和を計算するイメージ

        # 注意: 基数によるオフセットをキャンセルする必要がある

        offset = pow(BASE, i, MOD)

        # 素数MODを法とする剰余類における除算は逆元を乗算することで計算できる

        # 素数MODを法とする剰余類におけるxの逆元はx^(MOD - 2)に等しい

        offset_inv = pow(offset, MOD - 2, MOD)

        return ((self.acc[j] - self.acc[i]) * offset_inv) % MOD

N = int(eval(input()))

S = eval(input())

# Sのローリングハッシュを計算しておく

rolling = RollingHash(S)

# 長さmのダジャレがSに含まれるならば、長さm-1のダジャレも含まれる

# つまり、長さmのダジャレがSに含まれるならば真となる述語をP(m)とすると、以下を満たす整数cが存在する:

#   - 0以上c以下の整数mについてP(m)は真

#   - cより大きい整数mについてP(m)は偽

# ※ Pは単調関数ということ

# このcを二分探索で発見すれば高速化できる！

# P(ok)は真

ok = 0

# P(ng)は偽

ng = N

while ng - ok > 1:

    # 区間[ok, ng)の中央値をmとする

    m = (ok + ng) // 2

    # 長さmのダジャレが存在するか判定する

    # 長さmのformerのハッシュ値のキャッシュ

    former_cache = set()

    p = False

    # latterに着目してループを回す

    for i in range(m, N):

        # ダジャレ長を決め打ちしているのでjを直接計算できる

        j = i + m

        # S[i:j]がSをはみ出したらループ終了

        if j > N:

            break

        # formerのハッシュ値をキャッシュする

        former_cache.add(rolling.hash(i - m, i))

        # キャッシャに同一のハッシュ値が存在する場合（ハッシュ値が衝突した場合）、ダジャレになっていると判定できる

        if rolling.hash(i, j) in former_cache:

            p = True

        # ハッシュ値の計算、キャッシュ存在判定は共にO(1)で処理できる！

    # 区間[ok, ng) を更新

    if p:

        ok = m

    else:

        ng = m

# whileループを抜けると区間[ok, ng)は[c, c + 1) になっている

ans = ok

print(ans)

BASE = 9973

MOD1 = 10 ** 9 + 7

MOD2 = 998244353

class RollingHash:

    # 文字列Sのローリングハッシュを構築

    # 計算量: O(N)

    def __init__(self, S, MOD):

        self.MOD = MOD

        # acc[i]はS[0:i]のハッシュ値となる

        self.acc = [0]

        a = 0

        # 累積和を計算するイメージ

        for i, c in enumerate(S):

            h = ord(c) - ord("a") + 1

            offset = pow(BASE, i, MOD)

            a = (a + (h * offset)) % MOD

            self.acc.append(a)

    # S[i:j]のハッシュ値を返す

    # 計算量: O(1)

    def hash(self, i, j):

        # 累積和を用いて部分区間の和を計算するイメージ

        # 注意: 基数によるオフセットをキャンセルする必要がある

        offset = pow(BASE, i, self.MOD)

        # 素数MODを法とする剰余類における除算は逆元を乗算することで計算できる

        # 素数MODを法とする剰余類におけるxの逆元はx^(MOD - 2)に等しい

        offset_inv = pow(offset, self.MOD - 2, self.MOD)

        return ((self.acc[j] - self.acc[i]) * offset_inv) % self.MOD

N = int(eval(input()))

S = eval(input())

# Sのローリングハッシュを計算しておく

rolling1 = RollingHash(S, MOD1)

rolling2 = RollingHash(S, MOD2)

# 長さmのダジャレがSに含まれるならば、長さm-1のダジャレも含まれる

# つまり、長さmのダジャレがSに含まれるならば真となる述語をP(m)とすると、以下を満たす整数cが存在する:

#   - 0以上c以下の整数mについてP(m)は真

#   - cより大きい整数mについてP(m)は偽

# ※ Pは単調関数ということ

# このcを二分探索で発見すれば高速化できる！

# P(ok)は真

ok = 0

# P(ng)は偽

ng = N

while ng - ok > 1:

    # 区間[ok, ng)の中央値をmとする

    m = (ok + ng) // 2

    # 長さmのダジャレが存在するか判定する

    # 長さmのformerのハッシュ値のキャッシュ

    former_cache1 = set()

    former_cache2 = set()

    p = False

    # latterに着目してループを回す

    for i in range(m, N):

        # ダジャレ長を決め打ちしているのでjを直接計算できる

        j = i + m

        # S[i:j]がSをはみ出したらループ終了

        if j > N:

            break

        # formerのハッシュ値をキャッシュする

        former_cache1.add(rolling1.hash(i - m, i))

        former_cache2.add(rolling2.hash(i - m, i))

        # キャッシャに同一のハッシュ値が存在する場合（ハッシュ値が衝突した場合）、ダジャレになっていると判定できる

        # ハッシュ値の計算、キャッシュ存在判定は共にO(1)で処理できる！

        if (

            rolling1.hash(i, j) in former_cache1

            and rolling2.hash(i, j) in former_cache2

        ):

            p = True

    # 区間[ok, ng) を更新

    if p:

        ok = m

    else:

        ng = m

# whileループを抜けると区間[ok, ng)は[c, c + 1) になっている

ans = ok

print(ans)

BASE = 9973
MOD = 2**61 - 1

class RollingHash:
    # 文字列Sのローリングハッシュを構築
    # 計算量: O(N)
    def __init__(self, S):
        # acc[i]はS[0:i]のハッシュ値となる
        self.acc = [0]
        a = 0
        # 累積和を計算するイメージ
        for i, c in enumerate(S):
            h = ord(c) - ord("a") + 1
            offset = pow(BASE, i, MOD)
            a = (a + (h * offset)) % MOD
            self.acc.append(a)

    # S[i:j]のハッシュ値を返す
    # 計算量: O(1)
    def hash(self, i, j):
        # 累積和を用いて部分区間の和を計算するイメージ
        # 注意: 基数によるオフセットをキャンセルする必要がある
        offset = pow(BASE, i, MOD)
        # 素数MODを法とする剰余類における除算は逆元を乗算することで計算できる
        # 素数MODを法とする剰余類におけるxの逆元はx^(MOD - 2)に等しい
        offset_inv = pow(offset, MOD - 2, MOD)
        return ((self.acc[j] - self.acc[i]) * offset_inv) % MOD

N = int(eval(input()))
S = eval(input())
# Sのローリングハッシュを計算しておく
rolling = RollingHash(S)
# 長さmのダジャレがSに含まれるならば、長さm-1のダジャレも含まれる
# つまり、長さmのダジャレがSに含まれるならば真となる述語をP(m)とすると、以下を満たす整数cが存在する:
#   - 0以上c以下の整数mについてP(m)は真
#   - cより大きい整数mについてP(m)は偽
# ※ Pは単調関数ということ
# このcを二分探索で発見すれば高速化できる！
# P(ok)は真
ok = 0
# P(ng)は偽
ng = N
while ng - ok > 1:
    # 区間[ok, ng)の中央値をmとする
    m = (ok + ng) // 2
    # 長さmのダジャレが存在するか判定する
    # 長さmのformerのハッシュ値のキャッシュ
    former_cache = set()
    p = False
    # latterに着目してループを回す
    for i in range(m, N):
        # ダジャレ長を決め打ちしているのでjを直接計算できる
        j = i + m
        # S[i:j]がSをはみ出したらループ終了
        if j > N:
            break
        # formerのハッシュ値をキャッシュする
        former_cache.add(rolling.hash(i - m, i))
        # キャッシャに同一のハッシュ値が存在する場合（ハッシュ値が衝突した場合）、ダジャレになっていると判定できる
        if rolling.hash(i, j) in former_cache:
            p = True
        # ハッシュ値の計算、キャッシュ存在判定は共にO(1)で処理できる！
    # 区間[ok, ng) を更新
    if p:
        ok = m
    else:
        ng = m
# whileループを抜けると区間[ok, ng)は[c, c + 1) になっている
ans = ok
print(ans)

BASE = 9973
MOD1 = 10**9 + 7
MOD2 = 998244353

class RollingHash:
    # 文字列Sのローリングハッシュを構築
    # 計算量: O(N)
    def __init__(self, S, MOD):
        self.MOD = MOD
        # acc[i]はS[0:i]のハッシュ値となる
        self.acc = [0]
        a = 0
        # 累積和を計算するイメージ
        for i, c in enumerate(S):
            h = ord(c) - ord("a") + 1
            offset = pow(BASE, i, MOD)
            a = (a + (h * offset)) % MOD
            self.acc.append(a)

    # S[i:j]のハッシュ値を返す
    # 計算量: O(1)
    def hash(self, i, j):
        # 累積和を用いて部分区間の和を計算するイメージ
        # 注意: 基数によるオフセットをキャンセルする必要がある
        offset = pow(BASE, i, self.MOD)
        # 素数MODを法とする剰余類における除算は逆元を乗算することで計算できる
        # 素数MODを法とする剰余類におけるxの逆元はx^(MOD - 2)に等しい
        offset_inv = pow(offset, self.MOD - 2, self.MOD)
        return ((self.acc[j] - self.acc[i]) * offset_inv) % self.MOD

N = int(eval(input()))
S = eval(input())
# Sのローリングハッシュを計算しておく
rolling1 = RollingHash(S, MOD1)
rolling2 = RollingHash(S, MOD2)
# 長さmのダジャレがSに含まれるならば、長さm-1のダジャレも含まれる
# つまり、長さmのダジャレがSに含まれるならば真となる述語をP(m)とすると、以下を満たす整数cが存在する:
#   - 0以上c以下の整数mについてP(m)は真
#   - cより大きい整数mについてP(m)は偽
# ※ Pは単調関数ということ
# このcを二分探索で発見すれば高速化できる！
# P(ok)は真
ok = 0
# P(ng)は偽
ng = N
while ng - ok > 1:
    # 区間[ok, ng)の中央値をmとする
    m = (ok + ng) // 2
    # 長さmのダジャレが存在するか判定する
    # 長さmのformerのハッシュ値のキャッシュ
    former_cache1 = set()
    former_cache2 = set()
    p = False
    # latterに着目してループを回す
    for i in range(m, N):
        # ダジャレ長を決め打ちしているのでjを直接計算できる
        j = i + m
        # S[i:j]がSをはみ出したらループ終了
        if j > N:
            break
        # formerのハッシュ値をキャッシュする
        former_cache1.add(rolling1.hash(i - m, i))
        former_cache2.add(rolling2.hash(i - m, i))
        # キャッシャに同一のハッシュ値が存在する場合（ハッシュ値が衝突した場合）、ダジャレになっていると判定できる
        # ハッシュ値の計算、キャッシュ存在判定は共にO(1)で処理できる！
        if (
            rolling1.hash(i, j) in former_cache1
            and rolling2.hash(i, j) in former_cache2
        ):
            p = True
    # 区間[ok, ng) を更新
    if p:
        ok = m
    else:
        ng = m
# whileループを抜けると区間[ok, ng)は[c, c + 1) になっている
ans = ok
print(ans)

+        offset = pow(BASE, i, self.MOD)

-        offset_inv = pow(offset, MOD - 2, MOD)

-        return ((self.acc[j] - self.acc[i]) * offset_inv) % MOD

+        offset_inv = pow(offset, self.MOD - 2, self.MOD)

+        return ((self.acc[j] - self.acc[i]) * offset_inv) % self.MOD

-        former_cache.add(rolling.hash(i - m, i))

+        former_cache1.add(rolling1.hash(i - m, i))

+        former_cache2.add(rolling2.hash(i - m, i))

-        if rolling.hash(i, j) in former_cache:

+        # ハッシュ値の計算、キャッシュ存在判定は共にO(1)で処理できる！

+            rolling1.hash(i, j) in former_cache1

+            and rolling2.hash(i, j) in former_cache2

-        # ハッシュ値の計算、キャッシュ存在判定は共にO(1)で処理できる！


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

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

dic={}

for a in A:

  if a in dic:

    dic[a]+=1

  else:

    dic[a]=1

c=0

for i in list(dic.values()):

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

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

  d=c-dic[A[j-1]]+1

  print((int(d)))

n=int(eval(input()))

cnt=[0]*(n+1)

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

for i in range(n):

  cnt[a[i]]+=1

ans=0

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

  if cnt[i]>=1:

    ans+=cnt[i]*(cnt[i]-1)//2

for i in range(n):

  print((ans-cnt[a[i]]+1))

N = int(eval(input()))
A = list(map(int, input().split()))
dic = {}
for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1
c = 0
for i in list(dic.values()):
    c += i * (i - 1) / 2
for j in range(1, N + 1):
    d = c - dic[A[j - 1]] + 1
    print((int(d)))

n = int(eval(input()))
cnt = [0] * (n + 1)
a = list(map(int, input().split()))
for i in range(n):
    cnt[a[i]] += 1
ans = 0
for i in range(1, n + 1):
    if cnt[i] >= 1:
        ans += cnt[i] * (cnt[i] - 1) // 2
for i in range(n):
    print((ans - cnt[a[i]] + 1))


Input:
S = eval(input())

def f():

    if S == "keyence":

        print("YES")

    else:

        n = len(S)

        for i in range(n):

            for j in range(i, n):

                T = ""

                for k in range(n):

                    if i <= k <= j:

                        continue

                    else:

                        T += S[k]

                if T == "keyence":

                    print("YES")

                    return

        else:

            print("NO")

f()

S = eval(input())

def f():

    for i in range(len(S)):

        for j in range(len(S)):

            if S[:i] + S[j:] == "keyence":

                print("YES")

                return

    else:

        print("NO")

f()

+            if S[:i] + S[j:] == "keyence":


Input:
import sys

import numpy as np

import numba

from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

@njit((i8, i8, i8, i8[:]), cache=True)

def solve(R,C,K,XYV):

  item = np.zeros((R + 1, C + 1), dtype=np.int64)

  for i in range(0, 3 * K, 3):

    x, y, v = XYV[i:i + 3]

    item[x - 1, y - 1] = v

  dp = np.zeros((C+1,4), dtype=np.int64)

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

    new_dp = np.zeros((C+1,4), dtype=np.int64)

    #上から移動

    for k in range(4):

      new_dp[:,0] = np.maximum(new_dp[:,0], dp[:,k])

    dp = new_dp

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

      #横から移動

      new_dp[j] = np.maximum(new_dp[j],new_dp[j-1])

      #アイテムを取る

      for k in range(2,-1,-1):

        dp[j,k+1] = np.maximum(dp[j,k+1],dp[j,k]+item[i-1,j-1])

  ans = dp[-1].max()

  return ans

R, C, K = list(map(int, readline().split()))

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

print((solve(R,C,K,XYV)))

import sys

import numpy as np

import numba

from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

@njit((i8, i8, i8, i8[:]), cache=True)

def solve(R,C,K,XYV):

  item = np.zeros((R + 1, C + 1), dtype=np.int64)

  for i in range(0, 3 * K, 3):

    x, y, v = XYV[i:i + 3]

    item[x - 1, y - 1] = v

  dp = np.zeros((C+1,4), dtype=np.int64)

  for i in range(R):

    new_dp = np.zeros((C+1,4), dtype=np.int64)

    #上から移動

    for k in range(4):

      new_dp[:,0] = np.maximum(new_dp[:,0], dp[:,k])

    dp = new_dp

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

      #横から移動

      for k in range(4):

        new_dp[j,k] = np.maximum(new_dp[j,k],new_dp[j-1,k])

      #アイテムを取る

      for k in range(2,-1,-1):

        dp[j,k+1] = np.maximum(dp[j,k+1],dp[j,k]+item[i,j-1])

  ans = dp[-1].max()

  return ans

R, C, K = list(map(int, readline().split()))

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

print((solve(R,C,K,XYV)))

import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

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

@njit((i8, i8, i8, i8[:]), cache=True)
def solve(R, C, K, XYV):
    item = np.zeros((R + 1, C + 1), dtype=np.int64)
    for i in range(0, 3 * K, 3):
        x, y, v = XYV[i : i + 3]
        item[x - 1, y - 1] = v
    dp = np.zeros((C + 1, 4), dtype=np.int64)
    for i in range(1, R + 1):
        new_dp = np.zeros((C + 1, 4), dtype=np.int64)
        # 上から移動
        for k in range(4):
            new_dp[:, 0] = np.maximum(new_dp[:, 0], dp[:, k])
        dp = new_dp
        for j in range(1, C + 1):
            # 横から移動
            new_dp[j] = np.maximum(new_dp[j], new_dp[j - 1])
            # アイテムを取る
            for k in range(2, -1, -1):
                dp[j, k + 1] = np.maximum(dp[j, k + 1], dp[j, k] + item[i - 1, j - 1])
    ans = dp[-1].max()
    return ans

R, C, K = list(map(int, readline().split()))
XYV = np.array(read().split(), np.int64)
print((solve(R, C, K, XYV)))

import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

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

@njit((i8, i8, i8, i8[:]), cache=True)
def solve(R, C, K, XYV):
    item = np.zeros((R + 1, C + 1), dtype=np.int64)
    for i in range(0, 3 * K, 3):
        x, y, v = XYV[i : i + 3]
        item[x - 1, y - 1] = v
    dp = np.zeros((C + 1, 4), dtype=np.int64)
    for i in range(R):
        new_dp = np.zeros((C + 1, 4), dtype=np.int64)
        # 上から移動
        for k in range(4):
            new_dp[:, 0] = np.maximum(new_dp[:, 0], dp[:, k])
        dp = new_dp
        for j in range(1, C + 1):
            # 横から移動
            for k in range(4):
                new_dp[j, k] = np.maximum(new_dp[j, k], new_dp[j - 1, k])
            # アイテムを取る
            for k in range(2, -1, -1):
                dp[j, k + 1] = np.maximum(dp[j, k + 1], dp[j, k] + item[i, j - 1])
    ans = dp[-1].max()
    return ans

R, C, K = list(map(int, readline().split()))
XYV = np.array(read().split(), np.int64)
print((solve(R, C, K, XYV)))

-            new_dp[j] = np.maximum(new_dp[j], new_dp[j - 1])

+                new_dp[j, k] = np.maximum(new_dp[j, k], new_dp[j - 1, k])

-                dp[j, k + 1] = np.maximum(dp[j, k + 1], dp[j, k] + item[i - 1, j - 1])

+                dp[j, k + 1] = np.maximum(dp[j, k + 1], dp[j, k] + item[i, j - 1])


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

ans=0

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

  tmp=i

  cnt=0

  while k>tmp:

    tmp=tmp*2

    cnt+=1

  ans+=(1/n)*pow(1/2,cnt)

print(ans)

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

ans=0

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

  tmp=i

  div=1

  while k>tmp:

    tmp=tmp*2

    div*=1/2

  ans+=(1/n)*div

print(ans)

n, k = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
    tmp = i
    cnt = 0
    while k > tmp:
        tmp = tmp * 2
        cnt += 1
    ans += (1 / n) * pow(1 / 2, cnt)
print(ans)

n, k = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
    tmp = i
    div = 1
    while k > tmp:
        tmp = tmp * 2
        div *= 1 / 2
    ans += (1 / n) * div
print(ans)


Input:
n = eval(input())

d_len = len(n)

def dfs(d):

    ret = 0

    if int(d) > int(n):

        return 0

    if all(i in d for i in ('357')):

        ret += 1

    for j in '357':

        ret += dfs(d + j)

    return ret

print((dfs('0')))

from collections import defaultdict, deque, Counter

from heapq import heappush, heappop, heapify

import math

import bisect

import random

from itertools import permutations, accumulate, combinations, product

import sys

import string

from bisect import bisect_left, bisect_right

from math import factorial, ceil, floor

from operator import mul

from functools import reduce

sys.setrecursionlimit(2147483647)

INF = 10 ** 20

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

def I(): return int(sys.stdin.buffer.readline())

def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

def IR(n): return [I() for i in range(n)]

def LIR(n): return [LI() for i in range(n)]

def SR(n): return [S() for i in range(n)]

def LSR(n): return [LS() for i in range(n)]

def SRL(n): return [list(S()) for i in range(n)]

def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

mod = 1000000007

n = I()

ret = 0

for l in range(1, len(str(n)) + 1):

    for i in product(*[('3', '5', '7') for _ in range(l)]):

        num = ''.join(i)

        if '3' not in num or '5' not in num or '7' not in num or int(num) > n:

            continue

        ret += 1

print(ret)

n = eval(input())
d_len = len(n)

def dfs(d):
    ret = 0
    if int(d) > int(n):
        return 0
    if all(i in d for i in ("357")):
        ret += 1
    for j in "357":
        ret += dfs(d + j)
    return ret

print((dfs("0")))

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce

sys.setrecursionlimit(2147483647)
INF = 10**20

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

def I():
    return int(sys.stdin.buffer.readline())

def LS():
    return sys.stdin.buffer.readline().rstrip().decode("utf-8").split()

def S():
    return sys.stdin.buffer.readline().rstrip().decode("utf-8")

def IR(n):
    return [I() for i in range(n)]

def LIR(n):
    return [LI() for i in range(n)]

def SR(n):
    return [S() for i in range(n)]

def LSR(n):
    return [LS() for i in range(n)]

def SRL(n):
    return [list(S()) for i in range(n)]

def MSRL(n):
    return [[int(j) for j in list(S())] for i in range(n)]

mod = 1000000007
n = I()
ret = 0
for l in range(1, len(str(n)) + 1):
    for i in product(*[("3", "5", "7") for _ in range(l)]):
        num = "".join(i)
        if "3" not in num or "5" not in num or "7" not in num or int(num) > n:
            continue
        ret += 1
print(ret)

+from collections import defaultdict, deque, Counter

+from heapq import heappush, heappop, heapify

+from itertools import permutations, accumulate, combinations, product

+from bisect import bisect_left, bisect_right

+from math import factorial, ceil, floor

+    return list(map(int, sys.stdin.buffer.readline().split()))

+    return int(sys.stdin.buffer.readline())

+    return sys.stdin.buffer.readline().rstrip().decode("utf-8").split()

+    return [list(S()) for i in range(n)]

+    return [[int(j) for j in list(S())] for i in range(n)]

+    for i in product(*[("3", "5", "7") for _ in range(l)]):

+        if "3" not in num or "5" not in num or "7" not in num or int(num) > n:


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

if b - a < k*2:

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

        print(j)

else:

    for j in [i for i in range(a, a+k)]:

        print(j)

    for j in [i for i in range(b-k+1, b+1)]:

        print(j)

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

L = []

s = [i for i in range(A, min(A+K, B+1))]

l = [j for j in range(B, max(A-1, B-K), -1)]

L += s + l

L = list(set(L))

L.sort()

for i in L:

    print(i)

a, b, k = list(map(int, input().split()))
if b - a < k * 2:
    for j in [i for i in range(a, b + 1)]:
        print(j)
else:
    for j in [i for i in range(a, a + k)]:
        print(j)
    for j in [i for i in range(b - k + 1, b + 1)]:
        print(j)

A, B, K = list(map(int, input().split()))
L = []
s = [i for i in range(A, min(A + K, B + 1))]
l = [j for j in range(B, max(A - 1, B - K), -1)]
L += s + l
L = list(set(L))
L.sort()
for i in L:
    print(i)

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

-    for j in [i for i in range(a, b + 1)]:

-    for j in [i for i in range(a, a + k)]:

-    for j in [i for i in range(b - k + 1, b + 1)]:

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

+s = [i for i in range(A, min(A + K, B + 1))]

+l = [j for j in range(B, max(A - 1, B - K), -1)]


Input:
s = eval(input())

stock_bc = 0

state = 0

ans = 0

for i in range(len(s)):

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

        if state == 1:

            stock_bc = 0

        state = 1

    elif s[-1-i] == "B":

        if state == 0:

            stock_bc = 0

        elif state == 1:

            stock_bc += 1

        state = 0

    elif s[-1-i] == "A":

        if state == 0:

            ans += stock_bc

        else:

            stock_bc = 0

            state = 2

print(ans)

s = eval(input())

s2 = s.replace("BC", "D")

A, ans = 0, 0

for i in s2:

    if i == "A":

        A += 1

    elif i == "D":

        ans += A

    else:

        A = 0

print(ans)

s = eval(input())
stock_bc = 0
state = 0
ans = 0
for i in range(len(s)):
    if s[-1 - i] == "C":
        if state == 1:
            stock_bc = 0
        state = 1
    elif s[-1 - i] == "B":
        if state == 0:
            stock_bc = 0
        elif state == 1:
            stock_bc += 1
        state = 0
    elif s[-1 - i] == "A":
        if state == 0:
            ans += stock_bc
        else:
            stock_bc = 0
            state = 2
print(ans)

-stock_bc = 0
-state = 0
-ans = 0
-for i in range(len(s)):
-    if s[-1 - i] == "C":
-        if state == 1:
-            stock_bc = 0
-        state = 1
-    elif s[-1 - i] == "B":
-        if state == 0:
-            stock_bc = 0
-        elif state == 1:
-            stock_bc += 1
-        state = 0
-    elif s[-1 - i] == "A":
-        if state == 0:
-            ans += stock_bc
-        else:
-            stock_bc = 0
-            state = 2
+s2 = s.replace("BC", "D")
+A, ans = 0, 0
+for i in s2:
+    if i == "A":
+        A += 1
+    elif i == "D":
+        ans += A
+    else:
+        A = 0


Input:
from fractions import Fraction

A,B = input().split()

#A = int(A)

#B = float(B)

from decimal import *

a = Decimal(A)

b = Decimal(B)

getcontext().prec = 28

ans = a * b

print((int(ans)))

import sys

readline = sys.stdin.readline

A,B = readline().split()

A = int(A)

B = int(float(B) * 100 + 0.5)

print((A * B // 100))

from fractions import Fraction

A, B = input().split()
# A = int(A)
# B = float(B)
from decimal import *

a = Decimal(A)
b = Decimal(B)
getcontext().prec = 28
ans = a * b
print((int(ans)))

import sys

readline = sys.stdin.readline
A, B = readline().split()
A = int(A)
B = int(float(B) * 100 + 0.5)
print((A * B // 100))

-from fractions import Fraction
+import sys
-A, B = input().split()
-# A = int(A)
-# B = float(B)
-from decimal import *
-a = Decimal(A)
-b = Decimal(B)
-getcontext().prec = 28
-ans = a * b
-print((int(ans)))
+readline = sys.stdin.readline
+A, B = readline().split()
+A = int(A)
+B = int(float(B) * 100 + 0.5)
+print((A * B // 100))


Input:
def getKth(x, a, k):

    if(k < a):

        return k

    return k + 1

def getRKth(x, a, k):

    if(x < a):

        return x - k + 1

    if(k < (x - a)):

        return x - k + 1

    return x - k

def NB(x, b):

    if(x < b):

        return x

    return x + 1

def f(x, a, b):

    half = (x + 1) / 2

    rep = 0

    for delta in range(-50, 51):

        if(half + delta >= 1 and half + delta <= x):

            rep = max(rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta))

    half = b - a

    for delta in range(-50, 51):

        if(half + delta >= 1 and half + delta <= x):

            rep = max(rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta))

    half = NB(x, b) - b

    for delta in range(-50, 51):

        if(half + delta >= 1 and half + delta <= x):

            rep = max(rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta))

    return rep

q = int(input())

while(q > 0):

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

    if(a > b):

        a, b = b, a

    lo = 1

    hi = 10**19

    res = 0

    # print f(1, a, b)

    # print f(2, a, b)

    # print f(3, a, b)

    # print getKth(2, a, 1), getRKth(NB(2, b), b, 1)

    # print getKth(2, a, 2), getRKth(NB(2, b), b, 2)

    while(lo <= hi):

        mid = (lo + hi)/2

        if(f(mid, a, b) < a * b):

            lo = mid + 1

            res = mid

        else:

            hi = mid - 1

    print(res)

    q -= 1

def getKth(x, a, k):

    if(k < a):

        return k

    return k + 1

def getRKth(x, a, k):

    if(x < a):

        return x - k + 1

    if(k < (x - a)):

        return x - k + 1

    return x - k

def NB(x, b):

    if(x < b):

        return x

    return x + 1

def f(x, a, b):

    mv = 25

    half = (x + 1) / 2

    rep = 0

    for delta in range(-mv, mv + 1):

        if(half + delta >= 1 and half + delta <= x):

            rep = max(rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta))

    half = b - a

    for delta in range(-mv, mv + 1):

        if(half + delta >= 1 and half + delta <= x):

            rep = max(rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta))

    half = NB(x, b) - b

    for delta in range(-mv, mv + 1):

        if(half + delta >= 1 and half + delta <= x):

            rep = max(rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta))

    return rep

q = int(input())

while(q > 0):

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

    if(a > b):

        a, b = b, a

    lo = 1

    hi = 10**19

    res = 0

    # print f(1, a, b)

    # print f(2, a, b)

    # print f(3, a, b)

    # print getKth(2, a, 1), getRKth(NB(2, b), b, 1)

    # print getKth(2, a, 2), getRKth(NB(2, b), b, 2)

    while(lo <= hi):

        mid = (lo + hi)/2

        if(f(mid, a, b) < a * b):

            lo = mid + 1

            res = mid

        else:

            hi = mid - 1

    print(res)

    q -= 1

def getKth(x, a, k):
    if k < a:
        return k
    return k + 1

def getRKth(x, a, k):
    if x < a:
        return x - k + 1
    if k < (x - a):
        return x - k + 1
    return x - k

def NB(x, b):
    if x < b:
        return x
    return x + 1

def f(x, a, b):
    half = (x + 1) / 2
    rep = 0
    for delta in range(-50, 51):
        if half + delta >= 1 and half + delta <= x:
            rep = max(
                rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta)
            )
    half = b - a
    for delta in range(-50, 51):
        if half + delta >= 1 and half + delta <= x:
            rep = max(
                rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta)
            )
    half = NB(x, b) - b
    for delta in range(-50, 51):
        if half + delta >= 1 and half + delta <= x:
            rep = max(
                rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta)
            )
    return rep

q = int(input())
while q > 0:
    a, b = list(map(int, input().split()))
    if a > b:
        a, b = b, a
    lo = 1
    hi = 10**19
    res = 0
    # print f(1, a, b)
    # print f(2, a, b)
    # print f(3, a, b)
    # print getKth(2, a, 1), getRKth(NB(2, b), b, 1)
    # print getKth(2, a, 2), getRKth(NB(2, b), b, 2)
    while lo <= hi:
        mid = (lo + hi) / 2
        if f(mid, a, b) < a * b:
            lo = mid + 1
            res = mid
        else:
            hi = mid - 1
    print(res)
    q -= 1

def getKth(x, a, k):
    if k < a:
        return k
    return k + 1

def getRKth(x, a, k):
    if x < a:
        return x - k + 1
    if k < (x - a):
        return x - k + 1
    return x - k

def NB(x, b):
    if x < b:
        return x
    return x + 1

def f(x, a, b):
    mv = 25
    half = (x + 1) / 2
    rep = 0
    for delta in range(-mv, mv + 1):
        if half + delta >= 1 and half + delta <= x:
            rep = max(
                rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta)
            )
    half = b - a
    for delta in range(-mv, mv + 1):
        if half + delta >= 1 and half + delta <= x:
            rep = max(
                rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta)
            )
    half = NB(x, b) - b
    for delta in range(-mv, mv + 1):
        if half + delta >= 1 and half + delta <= x:
            rep = max(
                rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta)
            )
    return rep

q = int(input())
while q > 0:
    a, b = list(map(int, input().split()))
    if a > b:
        a, b = b, a
    lo = 1
    hi = 10**19
    res = 0
    # print f(1, a, b)
    # print f(2, a, b)
    # print f(3, a, b)
    # print getKth(2, a, 1), getRKth(NB(2, b), b, 1)
    # print getKth(2, a, 2), getRKth(NB(2, b), b, 2)
    while lo <= hi:
        mid = (lo + hi) / 2
        if f(mid, a, b) < a * b:
            lo = mid + 1
            res = mid
        else:
            hi = mid - 1
    print(res)
    q -= 1

+    mv = 25
-    for delta in range(-50, 51):
+    for delta in range(-mv, mv + 1):
-    for delta in range(-50, 51):
+    for delta in range(-mv, mv + 1):
-    for delta in range(-50, 51):
+    for delta in range(-mv, mv + 1):


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

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

B = [abs(a) for a in A]

for i in range(N):

    if A[i] > 0:

        po = i

        break

else:

    po = -1

for i in range(N):

    if A[i] < 0:

        ne = i

        break

else:

    ne = -1

mi = min(B)

for i in range(N):

    if B[i] == mi:

        mii = i

        break

else:

    mii = -1

if po >= 0 and ne >= 0:

    print((sum(B)))

    t1, t2 = A[po], A[ne]

    if po > ne:

        po, ne = ne, po

    # print("pone =", po, ne)

    if po == ne:

        del A[ne]

        A = [0] + A

    else:

        del A[ne]

        del A[po]

        A = [t1, t2] + A

else:

    print((sum(B) - 2 * mi))

    t = A[mii]

    del A[mii]

    A = [t] + A

# print(A)

prev = A[0]

for i in range(1, N):

    a, b = max(prev, A[i]), min(prev, A[i])

    if i == N-1 or A[i+1] < 0:

        print((a, b))

        prev = a - b

    else:

        print((b, a))

        prev = b - a

N = int(eval(input()))

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

print((A[-1]-A[0]+sum([abs(a) for a in A[1:-1]])))

p = A[-1]

for i in range(N-1):

    a, b = max(p, A[i]), min(p, A[i])

    if i == N-2 or A[i+1] < 0:

        print((a, b))

        p = a - b

    else:

        print((b, a))

        p = b - a

N = int(eval(input()))
A = [int(a) for a in input().split()]
B = [abs(a) for a in A]
for i in range(N):
    if A[i] > 0:
        po = i
        break
else:
    po = -1
for i in range(N):
    if A[i] < 0:
        ne = i
        break
else:
    ne = -1
mi = min(B)
for i in range(N):
    if B[i] == mi:
        mii = i
        break
else:
    mii = -1
if po >= 0 and ne >= 0:
    print((sum(B)))
    t1, t2 = A[po], A[ne]
    if po > ne:
        po, ne = ne, po
    # print("pone =", po, ne)
    if po == ne:
        del A[ne]
        A = [0] + A
    else:
        del A[ne]
        del A[po]
        A = [t1, t2] + A
else:
    print((sum(B) - 2 * mi))
    t = A[mii]
    del A[mii]
    A = [t] + A
# print(A)
prev = A[0]
for i in range(1, N):
    a, b = max(prev, A[i]), min(prev, A[i])
    if i == N - 1 or A[i + 1] < 0:
        print((a, b))
        prev = a - b
    else:
        print((b, a))
        prev = b - a

N = int(eval(input()))
A = sorted([int(a) for a in input().split()])
print((A[-1] - A[0] + sum([abs(a) for a in A[1:-1]])))
p = A[-1]
for i in range(N - 1):
    a, b = max(p, A[i]), min(p, A[i])
    if i == N - 2 or A[i + 1] < 0:
        print((a, b))
        p = a - b
    else:
        print((b, a))
        p = b - a

-    a, b = max(prev, A[i]), min(prev, A[i])

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


Input:
import itertools

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

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

ans = 0

for A in itertools.combinations_with_replacement(list(range(1, M+1)), N):

    score = 0

    for a, b, c, d in buff:

        if A[b-1] - A[a-1] == c:

            score += d

    ans = max(ans, score)

print(ans)

# coding: utf-8

import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)

def dfs(A):

    # 再代入のため、グローバル宣言

    global ans

    # N桁なら計算

    if len(A) == N:

        score = 0

        for a, b, c, d in buff:

            if A[b-1] - A[a-1] == c:

                score += d

        ans = max(ans, score)

        return

    A.append(A[-1])

    # 再帰

    while A[-1] <= M:

        # コピーを渡す

        dfs(A[:])

        A[-1] += 1

# main

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

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

ans = 0

dfs([1])

print(ans)

import itertools

N, M, Q = list(map(int, input().split()))
buff = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
for A in itertools.combinations_with_replacement(list(range(1, M + 1)), N):
    score = 0
    for a, b, c, d in buff:
        if A[b - 1] - A[a - 1] == c:
            score += d
    ans = max(ans, score)
print(ans)

# coding: utf-8
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)

def dfs(A):
    # 再代入のため、グローバル宣言
    global ans
    # N桁なら計算
    if len(A) == N:
        score = 0
        for a, b, c, d in buff:
            if A[b - 1] - A[a - 1] == c:
                score += d
        ans = max(ans, score)
        return
    A.append(A[-1])
    # 再帰
    while A[-1] <= M:
        # コピーを渡す
        dfs(A[:])
        A[-1] += 1

# main
N, M, Q = list(map(int, input().split()))
buff = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
dfs([1])
print(ans)

+    # 再代入のため、グローバル宣言

+    # N桁なら計算

+        # コピーを渡す

-for A in itertools.combinations_with_replacement(list(range(1, M + 1)), N):


Input:
from collections import Counter

N = int(eval(input()))

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

C = Counter(List)

for i in range(1,N):

  if i in list(C.keys()):

    print((C[i]))

  else:

    print((0))

print((0))

N = int(eval(input()))

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

cnt = [0] * (N+1)

for i in range(N-1):

    cnt[ls[i]] += 1

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

    print((cnt[i]))

from collections import Counter

N = int(eval(input()))
List = list(map(int, input().split()))
C = Counter(List)
for i in range(1, N):
    if i in list(C.keys()):
        print((C[i]))
    else:
        print((0))
print((0))

N = int(eval(input()))
ls = list(map(int, input().split()))
cnt = [0] * (N + 1)
for i in range(N - 1):
    cnt[ls[i]] += 1
for i in range(1, N + 1):
    print((cnt[i]))

-from collections import Counter
-List = list(map(int, input().split()))
-C = Counter(List)
-for i in range(1, N):
-    if i in list(C.keys()):
-        print((C[i]))
-    else:
-        print((0))
-print((0))
+ls = list(map(int, input().split()))
+cnt = [0] * (N + 1)
+for i in range(N - 1):
+    cnt[ls[i]] += 1
+for i in range(1, N + 1):
+    print((cnt[i]))


Input:
def GCD(a, b):

    return a if b == 0 else GCD(b, a % b)

k = int(eval(input()))

ans = 0

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

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

        ab = GCD(a, b)

        if ab == 1:

            ans += k

            continue

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

            ans += GCD(ab, c)

print(ans)

from math import gcd

k = int(eval(input()))

ans = 0

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

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

        ab = gcd(a, b)

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

            ans += gcd(ab, c)

print(ans)

-    return a if b == 0 else GCD(b, a % b)


Input:
l = [int(i) for i in input().split(" ")]

h = l[0]

w = l[1]

m = []

m_t = []

m_tt = []

# .のみの行を取り除く

for i in range(h):

    row = list(eval(input()))

    if "#" not in row:

        pass

    else:

        m.append(row)

# 転置して.のみの行を取り除く

for i in range(w):

    row = []

    for j in range(len(m)):

        row.append(m[j][i])

    if "#" not in row:

        pass

    else:

        m_t.append(row)

# 再び転置する

for i in range(len(m)):

    row = []

    for j in range(len(m_t)):

        row.append(m_t[j][i])

    m_tt.append(row)

for row in m_tt:

    print(("".join(row)))

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

h = l[0]

w = l[1]

m = []

def trans(matrix):

    t_matrix = []

    h = len(matrix)

    w = len(matrix[0])

    for i in range(w):

        row = []

        for j in range(h):

            row.append(matrix[j][i])

        t_matrix.append(row)

    return t_matrix

def remove_dot(matrix):

    new_matrix = []

    for row in matrix:

        if "#" not in row:

            pass

        else:

            new_matrix.append(row)

    return new_matrix

for i in range(h):

    m.append(list(eval(input())))

for i in range(2):

    m = remove_dot(m)

    m = trans(m)

for row in m:

    print(("".join(row)))

-m_t = []
-m_tt = []
-# .のみの行を取り除く
+
+
+def trans(matrix):
+    t_matrix = []
+    h = len(matrix)
+    w = len(matrix[0])
+    for i in range(w):
+        row = []
+        for j in range(h):
+            row.append(matrix[j][i])
+        t_matrix.append(row)
+    return t_matrix
+
+
+def remove_dot(matrix):
+    new_matrix = []
+    for row in matrix:
+        if "#" not in row:
+            pass
+        else:
+            new_matrix.append(row)
+    return new_matrix
+
+
-    row = list(eval(input()))
-    if "#" not in row:
-        pass
-    else:
-        m.append(row)
-# 転置して.のみの行を取り除く
-for i in range(w):
-    row = []
-    for j in range(len(m)):
-        row.append(m[j][i])
-    if "#" not in row:
-        pass
-    else:
-        m_t.append(row)
-# 再び転置する
-for i in range(len(m)):
-    row = []
-    for j in range(len(m_t)):
-        row.append(m_t[j][i])
-    m_tt.append(row)
-for row in m_tt:
+    m.append(list(eval(input())))
+for i in range(2):
+    m = remove_dot(m)
+    m = trans(m)
+for row in m:


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

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

m = int(eval(input()))

T = [str(eval(input())) for _ in range(m)]

from collections import Counter

CS = Counter(S)

CT = Counter(T)

ans = 0

for k in list(CS.keys()):

    if k not in CT:

        ans = max(CS[k], ans)

    else:

        ans = max(ans, max(0, CS[k]-CT[k]))

print(ans)

n = int(eval(input()))

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

m = int(eval(input()))

T = [str(eval(input())) for _ in range(m)]

from collections import Counter

cs = Counter(S)

ct = Counter(T)

ans = -10**18

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

    if k in ct:

        temp = v - ct[k]

    else:

        temp = v

    ans = max(ans, temp)

print((max(ans, 0)))

n = int(eval(input()))
S = [str(eval(input())) for _ in range(n)]
m = int(eval(input()))
T = [str(eval(input())) for _ in range(m)]
from collections import Counter

CS = Counter(S)
CT = Counter(T)
ans = 0
for k in list(CS.keys()):
    if k not in CT:
        ans = max(CS[k], ans)
    else:
        ans = max(ans, max(0, CS[k] - CT[k]))
print(ans)

n = int(eval(input()))
S = [str(eval(input())) for _ in range(n)]
m = int(eval(input()))
T = [str(eval(input())) for _ in range(m)]
from collections import Counter

cs = Counter(S)
ct = Counter(T)
ans = -(10**18)
for k, v in list(cs.items()):
    if k in ct:
        temp = v - ct[k]
    else:
        temp = v
    ans = max(ans, temp)
print((max(ans, 0)))

-        ans = max(ans, max(0, CS[k] - CT[k]))


Input:
from collections import deque

INF = 10 ** 9 + 7

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

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

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

for x, y in X:

    edges[x - 1].append(y - 1)

    edges[y - 1].append(x - 1)

def bfs(s):

    d = [INF] * N

    d[s] = 0

    visited = [False] * N

    visited[s] = True

    q = deque()

    q.append(s)

    while q:

        u = q.popleft()

        for v in edges[u]:

            if visited[v]:

                continue

            visited[v] = True

            d[v] = d[u] + 1

            q.append(v)

    return d

ans = 0

for x, y in zip(bfs(u - 1), bfs(v - 1)):

    if x <= y:

        ans = max(ans, y - 1)

print(ans)

from collections import deque

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

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

tree = [[] for _ in range(N + 1)]

for a, b in X:

    tree[a].append(b)

    tree[b].append(a)

def find_dist(s):

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

    dist[s] = 0

    q = deque()

    q.append(s)

    while q:

        u = q.popleft()

        for v in tree[u]:

            if dist[v] >= 0:

                continue

            dist[v] = dist[u] + 1

            q.append(v)

    return dist

dist_u = find_dist(U)

dist_v = find_dist(V)

ans = 0

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

    if dist_u[i] <= dist_v[i]:

        ans = max(ans, dist_v[i] - 1)

print(ans)

from collections import deque

INF = 10**9 + 7
N, u, v = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N - 1)]
edges = [[] for _ in range(N)]
for x, y in X:
    edges[x - 1].append(y - 1)
    edges[y - 1].append(x - 1)

def bfs(s):
    d = [INF] * N
    d[s] = 0
    visited = [False] * N
    visited[s] = True
    q = deque()
    q.append(s)
    while q:
        u = q.popleft()
        for v in edges[u]:
            if visited[v]:
                continue
            visited[v] = True
            d[v] = d[u] + 1
            q.append(v)
    return d

ans = 0
for x, y in zip(bfs(u - 1), bfs(v - 1)):
    if x <= y:
        ans = max(ans, y - 1)
print(ans)

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

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

-for x, y in zip(bfs(u - 1), bfs(v - 1)):


Input:
import sys, math, itertools, bisect, copy, re

from collections import Counter, deque, defaultdict

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

# from functools import reduce

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

# from pprint import pprint

INF = float('inf')

MOD = 10 ** 9 + 7

EPS = 10 ** -7

sys.setrecursionlimit(1000000)

# N = int(input())

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

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

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

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

# DP = defaultdict(lambda: float('inf'))

S = eval(input())

N = len(S)

i = 0

ANS = []

while i < N :

    # print(S[i:i + 2])

    if S[i:i + 2] == 'RL':

        li = i

        while li > 0 and S[li] == 'R':

            li -= 1

        if li != 0:

            li += 1

        ri = i + 1

        while ri < N and S[ri] == 'L':

            ri += 1

        ri -= 1

        # print([li, i, ri])

        cnt = ri - li + 1

        if cnt % 2 == 0:

            ANS.append(cnt // 2)

            ANS.append(cnt // 2)

        else:

            if ri % 2 == i % 2:

                ANS.append(cnt // 2 + 1)

                ANS.append(cnt // 2)

            else:

                ANS.append(cnt // 2)

                ANS.append(cnt // 2 + 1)

        i += 2

    else:

        ANS.append(0)

        i += 1

print((" ".join([str(s) for s in ANS])))

import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint
INF = float("inf")
MOD = 10**9 + 7
EPS = 10**-7
sys.setrecursionlimit(1000000)
# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))
S = eval(input())
N = len(S)
i = 0
ANS = []
while i < N:
    # print(S[i:i + 2])
    if S[i : i + 2] == "RL":
        li = i
        while li > 0 and S[li] == "R":
            li -= 1
        if li != 0:
            li += 1
        ri = i + 1
        while ri < N and S[ri] == "L":
            ri += 1
        ri -= 1
        # print([li, i, ri])
        cnt = ri - li + 1
        if cnt % 2 == 0:
            ANS.append(cnt // 2)
            ANS.append(cnt // 2)
        else:
            if ri % 2 == i % 2:
                ANS.append(cnt // 2 + 1)
                ANS.append(cnt // 2)
            else:
                ANS.append(cnt // 2)
                ANS.append(cnt // 2 + 1)
        i += 2
    else:
        ANS.append(0)
        i += 1
print((" ".join([str(s) for s in ANS])))

-import sys, math, itertools, bisect, copy, re

-from collections import Counter, deque, defaultdict

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

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

-# N,M = [int(x) for x in input().split()]

-# DP = defaultdict(lambda: float('inf'))

-                ANS.append(cnt // 2 + 1)

-                ANS.append(cnt // 2 + 1)

-print((" ".join([str(s) for s in ANS])))

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


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

ans = 10**N - 2*9**N + 8**N

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

N = int(eval(input()))

MOD = 10**9+7

ans = (pow(10, N, MOD) - 2* pow(9, N, MOD) + pow(8, N, MOD))%MOD

print(ans)

N = int(eval(input()))
MOD = 10**9 + 7
ans = (pow(10, N, MOD) - 2 * pow(9, N, MOD) + pow(8, N, MOD)) % MOD
print(ans)

+ans = (pow(10, N, MOD) - 2 * pow(9, N, MOD) + pow(8, N, MOD)) % MOD


Input: from itertools import*;s,*_=list(zip(*open(0).readlines()));c=s.count;print((sum(c(p)*c(q)*c(r)for p,q,r in combinations('MARCH',3))))

from itertools import*;s,*_=list(zip(*open(0).readlines()));print((sum(p*q*r for p,q,r in combinations(list(map(s.count,'MARCH')),3))))

from itertools import *

s, *_ = list(zip(*open(0).readlines()))
c = s.count
print((sum(c(p) * c(q) * c(r) for p, q, r in combinations("MARCH", 3))))

from itertools import *

s, *_ = list(zip(*open(0).readlines()))
print((sum(p * q * r for p, q, r in combinations(list(map(s.count, "MARCH")), 3))))

-print((sum(c(p) * c(q) * c(r) for p, q, r in combinations("MARCH", 3))))

+print((sum(p * q * r for p, q, r in combinations(list(map(s.count, "MARCH")), 3))))


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

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

from itertools import accumulate

tot=sum(l)

ans=2020202020*100000

for i in list(accumulate(l)):

    ans=min(ans, abs(tot-(i*2)))

for i in list(accumulate(l[::-1])):

    ans=min(ans, abs(tot--(i*2)))

print(ans)

n = int(eval(input()))

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

from itertools import accumulate

cum=list(accumulate(l))

tot=sum(l)

ans=2020202020*100000

for i in cum:

    ans=min(ans, abs(tot-i*2))

print(ans)

n = int(eval(input()))
l = list(map(int, input().split()))
from itertools import accumulate

tot = sum(l)
ans = 2020202020 * 100000
for i in list(accumulate(l)):
    ans = min(ans, abs(tot - (i * 2)))
for i in list(accumulate(l[::-1])):
    ans = min(ans, abs(tot - -(i * 2)))
print(ans)

n = int(eval(input()))
l = list(map(int, input().split()))
from itertools import accumulate

cum = list(accumulate(l))
tot = sum(l)
ans = 2020202020 * 100000
for i in cum:
    ans = min(ans, abs(tot - i * 2))
print(ans)

-    ans = min(ans, abs(tot - -(i * 2)))


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

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

def main():

    l = [1 if a[0] >= j else 0 for j in range(K+1)]

    lt= [0] * (K+1)

    s = a[0]

    for i in range(1,N):

        lt, l = l, lt

        s += a[i]

        l[0] = 1

        t = 1

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

                t += lt[j]

                l[j] = t

        for j in range(a[i]+1, min(K+1, s+1)):

                t += (lt[j] - lt[j - a[i] - 1])

                l[j] = t

    return l[-1] % (10 ** 9 + 7)

print((main()))

def main():

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

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

    l = [1 if a[0] >= j else 0 for j in range(K+1)]

    lt= [1 if a[0] >= j else 0 for j in range(K+1)]

    s = a[0]

    for i in a[1:]:

        lt, l = l, lt

        s += i

        l[0] = 1

        t = 1

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

                t += lt[j]

                l[j] = t

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

                t += (lt[j] - lt[j - i - 1])

                l[j] = t

    return l[-1] % (10 ** 9 + 7)

print((main()))

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

def main():
    l = [1 if a[0] >= j else 0 for j in range(K + 1)]
    lt = [0] * (K + 1)
    s = a[0]
    for i in range(1, N):
        lt, l = l, lt
        s += a[i]
        l[0] = 1
        t = 1
        for j in range(1, a[i] + 1):
            t += lt[j]
            l[j] = t
        for j in range(a[i] + 1, min(K + 1, s + 1)):
            t += lt[j] - lt[j - a[i] - 1]
            l[j] = t
    return l[-1] % (10**9 + 7)

print((main()))

def main():
    N, K = list(map(int, input().split()))
    a = tuple(map(int, input().split()))
    l = [1 if a[0] >= j else 0 for j in range(K + 1)]
    lt = [1 if a[0] >= j else 0 for j in range(K + 1)]
    s = a[0]
    for i in a[1:]:
        lt, l = l, lt
        s += i
        l[0] = 1
        t = 1
        for j in range(1, i + 1):
            t += lt[j]
            l[j] = t
        for j in range(i + 1, min(K + 1, s + 1)):
            t += lt[j] - lt[j - i - 1]
            l[j] = t
    return l[-1] % (10**9 + 7)

print((main()))

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

+    a = tuple(map(int, input().split()))

+    lt = [1 if a[0] >= j else 0 for j in range(K + 1)]

-        for j in range(a[i] + 1, min(K + 1, s + 1)):

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


Input:
import sys, re, os

from collections import deque, defaultdict, Counter

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

from itertools import permutations, combinations, product, accumulate

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from fractions import gcd

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

def STR(): return eval(input())

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

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

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

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

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

sys.setrecursionlimit(10 ** 9)

inf = sys.maxsize

mod = 10 ** 9 + 7

s = STR()

print((min(s.count('0'), s.count('1')) * 2))

import sys, re, os

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10

from itertools import permutations, combinations, product, accumulate

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from fractions import gcd

def debug(*args):

    if debugmode:

        print((*args))

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

def STR(): return eval(input())

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

def FLOAT(): return float(eval(input()))

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

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

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

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

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

sys.setrecursionlimit(10 ** 9)

inf = sys.maxsize

mod = 10 ** 9 + 7

dx = [0, 0, 1, -1, 1, -1, -1, 1]

dy = [1, -1, 0, 0, 1, -1, 1, -1]

debugmode = True

s = STR()

t = Counter(s)

print((min(t['0'], t['1']) * 2))

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

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

def STR():
    return eval(input())

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

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

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

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

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

sys.setrecursionlimit(10**9)
inf = sys.maxsize
mod = 10**9 + 7
s = STR()
print((min(s.count("0"), s.count("1")) * 2))

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

def debug(*args):
    if debugmode:
        print((*args))

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

def STR():
    return eval(input())

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

def FLOAT():
    return float(eval(input()))

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

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

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

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

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

sys.setrecursionlimit(10**9)
inf = sys.maxsize
mod = 10**9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True
s = STR()
t = Counter(s)
print((min(t["0"], t["1"]) * 2))

-from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin


Input:
import math

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

ans=0

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

    ans+=(1/2)**math.ceil(max(math.log2(k/i),0))

print((ans/n))

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

ans=0

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

	tmp=1/n

	cnt=i

	while cnt<k:

		cnt*=2

		tmp/=2

	ans+=tmp

print(ans)

# x

import math

n, k = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
    ans += (1 / 2) ** math.ceil(max(math.log2(k / i), 0))
print((ans / n))

n, k = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
    tmp = 1 / n
    cnt = i
    while cnt < k:
        cnt *= 2
        tmp /= 2
    ans += tmp
print(ans)
# x

-    ans += (1 / 2) ** math.ceil(max(math.log2(k / i), 0))