Input:
def s0():return eval(input())

def s1():return input().split()

def s2(n):return [eval(input()) for x in range(n)]

def s3(n):return [input().split() for _ in range(n)]

def s4(n): return [[x for x in s] for s in s2(n)]

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

def n1():return [int(x) for x in input().split()]

def n2(n):return [int(eval(input())) for _ in range(n)]

def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]

def p0(b,yes="Yes",no="No"): print((yes if b else no))

# from sys import setrecursionlimit

# setrecursionlimit(1000000)

# from collections import Counter,deque,defaultdict

# import itertools

# import math

# import networkx

# from bisect import bisect_left,bisect_right

# from heapq import heapify,heappush,heappop

n=n0()

a=n2(n)

b=sorted(a)

m1=b[-1]

m2=b[-2]

for i in a:

    p0(i==m1,m2,m1)

def s0():return input()

def s1():return input().split()

def s2(n):return [input() for x in range(n)]

def s3(n):return [input().split() for _ in range(n)]

def s4(n): return [[x for x in s] for s in s2(n)]

def n0():return int(input())

def n1():return [int(x) for x in input().split()]

def n2(n):return [int(input()) for _ in range(n)]

def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]

def p0(b,yes="Yes",no="No"): print(yes if b else no)

# from sys import setrecursionlimit

# setrecursionlimit(1000000)

# from collections import Counter,deque,defaultdict

# import itertools

# import math

# import networkx

# from bisect import bisect_left,bisect_right

# from heapq import heapify,heappush,heappop

n=n0()

a=n2(n)

b=sorted(a)

m1=b[-1]

m2=b[-2]

c=[]

for i in a:

    if i==m1:

        c.append(m2)

    else:

        c.append(m1)

print(*c,sep="\n")

def s0():
    return eval(input())

def s1():
    return input().split()

def s2(n):
    return [eval(input()) for x in range(n)]

def s3(n):
    return [input().split() for _ in range(n)]

def s4(n):
    return [[x for x in s] for s in s2(n)]

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

def n1():
    return [int(x) for x in input().split()]

def n2(n):
    return [int(eval(input())) for _ in range(n)]

def n3(n):
    return [[int(x) for x in input().split()] for _ in range(n)]

def t3(n):
    return [tuple(int(x) for x in input().split()) for _ in range(n)]

def p0(b, yes="Yes", no="No"):
    print((yes if b else no))

# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n = n0()
a = n2(n)
b = sorted(a)
m1 = b[-1]
m2 = b[-2]
for i in a:
    p0(i == m1, m2, m1)

def s0():
    return input()

def s1():
    return input().split()

def s2(n):
    return [input() for x in range(n)]

def s3(n):
    return [input().split() for _ in range(n)]

def s4(n):
    return [[x for x in s] for s in s2(n)]

def n0():
    return int(input())

def n1():
    return [int(x) for x in input().split()]

def n2(n):
    return [int(input()) for _ in range(n)]

def n3(n):
    return [[int(x) for x in input().split()] for _ in range(n)]

def t3(n):
    return [tuple(int(x) for x in input().split()) for _ in range(n)]

def p0(b, yes="Yes", no="No"):
    print(yes if b else no)

# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n = n0()
a = n2(n)
b = sorted(a)
m1 = b[-1]
m2 = b[-2]
c = []
for i in a:
    if i == m1:
        c.append(m2)
    else:
        c.append(m1)
print(*c, sep="\n")

-    return [eval(input()) for x in range(n)]

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

+    return [int(input()) for _ in range(n)]


Input:
from collections import deque,defaultdict

n=int(input())

routes=[tuple(map(int,input().split())) for i in range(n-1)]

edges=defaultdict(list)

for v1,v2,dist in routes:

  edges[v1-1].append([v2-1,dist])

  edges[v2-1].append([v1-1,dist])

#print(edges)

ans=[0]*n

q=deque([0])

while q:

  v=q.popleft()

  #print(v)

  if ans[v]==0:

    color=[1,0]

  else:

    color=[0,1]

  #print(edges)

  for edge in edges[v]:

    v2=edge[0]

    dist=edge[1]

    edges[v2].remove([v,dist])

    q.append(v2)

    if dist%2==1:

      ans[v2]=color[0]

    else:

      ans[v2]=color[1]

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

import sys

sys.setrecursionlimit(10000000)

MOD = 10 ** 9 + 7

INF = 10 ** 15

def main():

    N = int(eval(input()))

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

    for _ in range(N - 1):

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

        a -= 1

        b -= 1

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

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

    color = [0] * N

    dist = [-1] * N

    stack = [0]

    dist[0] = 0

    while stack:

        v = stack.pop()

        for e,c in G[v]:

            if dist[e] >= 0:

                continue

            dist[e] = dist[v] + c

            color[e] = dist[e]%2

            stack.append(e)

    print(('\n'.join(map(str,color))))

if __name__ == '__main__':

    main()

from collections import deque, defaultdict

n = int(input())
routes = [tuple(map(int, input().split())) for i in range(n - 1)]
edges = defaultdict(list)
for v1, v2, dist in routes:
    edges[v1 - 1].append([v2 - 1, dist])
    edges[v2 - 1].append([v1 - 1, dist])
# print(edges)
ans = [0] * n
q = deque([0])
while q:
    v = q.popleft()
    # print(v)
    if ans[v] == 0:
        color = [1, 0]
    else:
        color = [0, 1]
    # print(edges)
    for edge in edges[v]:
        v2 = edge[0]
        dist = edge[1]
        edges[v2].remove([v, dist])
        q.append(v2)
        if dist % 2 == 1:
            ans[v2] = color[0]
        else:
            ans[v2] = color[1]
print(*ans, sep="\n")

import sys

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

def main():
    N = int(eval(input()))
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b, c = list(map(int, input().split()))
        a -= 1
        b -= 1
        G[a].append((b, c))
        G[b].append((a, c))
    color = [0] * N
    dist = [-1] * N
    stack = [0]
    dist[0] = 0
    while stack:
        v = stack.pop()
        for e, c in G[v]:
            if dist[e] >= 0:
                continue
            dist[e] = dist[v] + c
            color[e] = dist[e] % 2
            stack.append(e)
    print(("\n".join(map(str, color))))

if __name__ == "__main__":
    main()

-from collections import deque, defaultdict

-routes = [tuple(map(int, input().split())) for i in range(n - 1)]

-    edges[v1 - 1].append([v2 - 1, dist])

-    edges[v2 - 1].append([v1 - 1, dist])

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

+    print(("\n".join(map(str, color))))


Input:
def cmb(n, r, mod):

    if ( r<0 or r>n ):

        return 0

    r = min(r, n-r)

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

mod = 10**9+7 #出力の制限

N = 10**6 + 10

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

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

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

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

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

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

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

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

n = (2 * x - y) / 3

m = (2 * y - x) / 3

mod = 10 ** 9 + 7

if int(n) == n and int(m) == m:

    n = int(n)

    m = int(m)

    ans = cmb(n + m, n, mod)

    ans %= mod

    print(ans)

else:

    print((0))

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

mod = 10 ** 9 + 7

cnt1 = cnt2 = 0

for i in range(x + 1):

    x_left = x - i

    y_left = y - 2 * i

    if x_left == y_left * 2:

        cnt1 = i

        cnt2 = y_left

if cnt1 == cnt2 == 0:

    ans = 0

else:

    ans = 1

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

        ans *= (cnt1 + cnt2 - i + 1)

        ans %= mod

        ans *= pow(i, mod - 2, mod)

        ans %= mod

print(ans)

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

mod = 10**9 + 7  # 出力の制限
N = 10**6 + 10
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
x, y = list(map(int, input().split()))
n = (2 * x - y) / 3
m = (2 * y - x) / 3
mod = 10**9 + 7
if int(n) == n and int(m) == m:
    n = int(n)
    m = int(m)
    ans = cmb(n + m, n, mod)
    ans %= mod
    print(ans)
else:
    print((0))

x, y = list(map(int, input().split()))
mod = 10**9 + 7
cnt1 = cnt2 = 0
for i in range(x + 1):
    x_left = x - i
    y_left = y - 2 * i
    if x_left == y_left * 2:
        cnt1 = i
        cnt2 = y_left
if cnt1 == cnt2 == 0:
    ans = 0
else:
    ans = 1
    for i in range(1, cnt1 + 1):
        ans *= cnt1 + cnt2 - i + 1
        ans %= mod
        ans *= pow(i, mod - 2, mod)
        ans %= mod
print(ans)

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

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

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


Input:
import sys

sys.setrecursionlimit(10**8)

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

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

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

def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

def dp2(ini, i, j): return [[ini]*i for _ in range(j)]

#import bisect #bisect.bisect_left(B, a)

#from collections import defaultdict #d = defaultdict(int) d[key] += value

#from collections import Counter # a = Counter(A).most_common()

from itertools import accumulate #list(accumulate(A))

def segfunc(a,b):

    return a+b

def init(init_val):

    #set_val

    for i in range(n):

        seg[i+num-1]=init_val[i]

    #built

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

        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x):

    k += num-1

    seg[k] = x

    while k:

        k = (k-1)//2

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

def query(p,q):

    if q<=p:

        return ide_ele

    p += num-1

    q += num-2

    res=ide_ele

    while q-p>1:

        if p&1 == 0:

            res = segfunc(res,seg[p])

        if q&1 == 1:

            res = segfunc(res,seg[q])

            q -= 1

        p = p//2

        q = (q-1)//2

    if p == q:

        res = segfunc(res,seg[p])

    else:

        res = segfunc(segfunc(res,seg[p]),seg[q])

    return res

n, M, Q = mi()

#####単位元######

ide_ele = 0

#num:n以上の最小の2のべき乗

num =2**(n-1).bit_length()

seg=[ide_ele]*2*num

L = [0]*n

init(L)

lrpq = dp2(0, 3, M+Q)

for i in range(M):

    l, r = mi()

    lrpq[i][1] = l-1

    lrpq[i][2] = r-1

for i in range(M, M+Q):

    p, q = mi()

    lrpq[i][0] = i

    lrpq[i][1] = p-1

    lrpq[i][2] = q-1

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

ans = [0]*(Q)

for i in range(M+Q):

    if lrpq[i][0] == 0:

        #L[lrpq[i][1]] += 1

        update(lrpq[i][1], seg[lrpq[i][1]+num-1]+1)

    else:

        ans[lrpq[i][0]-M] = query(lrpq[i][1], lrpq[i][2]+1)

for num in ans:

    print(num)

import sys

sys.setrecursionlimit(10**8)

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

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

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

def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

def dp2(ini, i, j): return [[ini]*i for _ in range(j)]

#import bisect #bisect.bisect_left(B, a)

#from collections import defaultdict #d = defaultdict(int) d[key] += value

#from collections import Counter # a = Counter(A).most_common()

from itertools import accumulate #list(accumulate(A))

# セグ木

def segfunc(a,b):

    return a+b

def init(init_val):

    #set_val

    for i in range(n):

        seg[i+num-1]=init_val[i]

    #built

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

        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x):

    k += num-1

    seg[k] = x

    while k:

        k = (k-1)//2

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

def query(p,q):

    if q<=p:

        return ide_ele

    p += num-1

    q += num-2

    res=ide_ele

    while q-p>1:

        if p&1 == 0:

            res = segfunc(res,seg[p])

        if q&1 == 1:

            res = segfunc(res,seg[q])

            q -= 1

        p = p//2

        q = (q-1)//2

    if p == q:

        res = segfunc(res,seg[p])

    else:

        res = segfunc(segfunc(res,seg[p]),seg[q])

    return res

n, M, Q = mi()

#####単位元######

ide_ele = 0

#num:n以上の最小の2のべき乗

num =2**(n-1).bit_length()

seg=[ide_ele]*2*num

L = [0]*n

init(L)

lrpq = dp2(0, 3, M+Q)

for i in range(M):

    l, r = mi()

    lrpq[i][1] = l-1

    lrpq[i][2] = r-1

for i in range(M, M+Q):

    p, q = mi()

    lrpq[i][0] = i

    lrpq[i][1] = p-1

    lrpq[i][2] = q-1

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

ans = [0]*(Q)

for i in range(M+Q):

    if lrpq[i][0] == 0:

        #L[lrpq[i][1]] += 1

        update(lrpq[i][1], seg[lrpq[i][1]+num-1]+1)

    else:

        ans[lrpq[i][0]-M] = query(lrpq[i][1], lrpq[i][2]+1)

for num in ans:

    print(num)

import sys

sys.setrecursionlimit(10**8)

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

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

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

def li2(N):
    return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

def dp2(ini, i, j):
    return [[ini] * i for _ in range(j)]

# import bisect #bisect.bisect_left(B, a)
# from collections import defaultdict #d = defaultdict(int) d[key] += value
# from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate  # list(accumulate(A))

def segfunc(a, b):
    return a + b

def init(init_val):
    # set_val
    for i in range(n):
        seg[i + num - 1] = init_val[i]
    # built
    for i in range(num - 2, -1, -1):
        seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])

def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])

def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

n, M, Q = mi()
#####単位元######
ide_ele = 0
# num:n以上の最小の2のべき乗
num = 2 ** (n - 1).bit_length()
seg = [ide_ele] * 2 * num
L = [0] * n
init(L)
lrpq = dp2(0, 3, M + Q)
for i in range(M):
    l, r = mi()
    lrpq[i][1] = l - 1
    lrpq[i][2] = r - 1
for i in range(M, M + Q):
    p, q = mi()
    lrpq[i][0] = i
    lrpq[i][1] = p - 1
    lrpq[i][2] = q - 1
lrpq = sorted(lrpq, key=lambda x: (x[2], x[0]))
ans = [0] * (Q)
for i in range(M + Q):
    if lrpq[i][0] == 0:
        # L[lrpq[i][1]] += 1
        update(lrpq[i][1], seg[lrpq[i][1] + num - 1] + 1)
    else:
        ans[lrpq[i][0] - M] = query(lrpq[i][1], lrpq[i][2] + 1)
for num in ans:
    print(num)

import sys

sys.setrecursionlimit(10**8)

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

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

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

def li2(N):
    return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

def dp2(ini, i, j):
    return [[ini] * i for _ in range(j)]

# import bisect #bisect.bisect_left(B, a)
# from collections import defaultdict #d = defaultdict(int) d[key] += value
# from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate  # list(accumulate(A))

# セグ木
def segfunc(a, b):
    return a + b

def init(init_val):
    # set_val
    for i in range(n):
        seg[i + num - 1] = init_val[i]
    # built
    for i in range(num - 2, -1, -1):
        seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])

def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])

def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

n, M, Q = mi()
#####単位元######
ide_ele = 0
# num:n以上の最小の2のべき乗
num = 2 ** (n - 1).bit_length()
seg = [ide_ele] * 2 * num
L = [0] * n
init(L)
lrpq = dp2(0, 3, M + Q)
for i in range(M):
    l, r = mi()
    lrpq[i][1] = l - 1
    lrpq[i][2] = r - 1
for i in range(M, M + Q):
    p, q = mi()
    lrpq[i][0] = i
    lrpq[i][1] = p - 1
    lrpq[i][2] = q - 1
lrpq = sorted(lrpq, key=lambda x: (x[2], x[0]))
ans = [0] * (Q)
for i in range(M + Q):
    if lrpq[i][0] == 0:
        # L[lrpq[i][1]] += 1
        update(lrpq[i][1], seg[lrpq[i][1] + num - 1] + 1)
    else:
        ans[lrpq[i][0] - M] = query(lrpq[i][1], lrpq[i][2] + 1)
for num in ans:
    print(num)


Input:
from operator import itemgetter

N = int(eval(input()))

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

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

A.sort()

B.sort()

num = 0

for i in range(N):

    K = [A[k] for k in range(len(A)) if (A[k][0] <B[i][0]) and (A[k][1] < B[i][1])]

    if K:

        num += 1

        t = sorted(K, key=itemgetter(1))[-1]

        A.remove(t)

print(num)

from operator import itemgetter

n=int(eval(input()))

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

B=[tuple(map(int,input().split())) for j in range(n)]

A.sort()

B.sort()

count=0

for i in range(n):

    box=[A[j] for j in range(len(A)) if (A[j][0]<B[i][0]) and (A[j][1]<B[i][1])]

    if any(box):

        box=sorted(box, key=itemgetter(1))

        A.remove(box[-1])

        count +=1

print(count)

from operator import itemgetter

N = int(eval(input()))
A = [tuple(map(int, input().split())) for i in range(N)]
B = [tuple(map(int, input().split())) for i in range(N)]
A.sort()
B.sort()
num = 0
for i in range(N):
    K = [A[k] for k in range(len(A)) if (A[k][0] < B[i][0]) and (A[k][1] < B[i][1])]
    if K:
        num += 1
        t = sorted(K, key=itemgetter(1))[-1]
        A.remove(t)
print(num)

from operator import itemgetter

n = int(eval(input()))
A = [tuple(map(int, input().split())) for i in range(n)]
B = [tuple(map(int, input().split())) for j in range(n)]
A.sort()
B.sort()
count = 0
for i in range(n):
    box = [A[j] for j in range(len(A)) if (A[j][0] < B[i][0]) and (A[j][1] < B[i][1])]
    if any(box):
        box = sorted(box, key=itemgetter(1))
        A.remove(box[-1])
        count += 1
print(count)

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

-B = [tuple(map(int, input().split())) for i in range(N)]

+A = [tuple(map(int, input().split())) for i in range(n)]

+B = [tuple(map(int, input().split())) for j in range(n)]

-        t = sorted(K, key=itemgetter(1))[-1]

+        box = sorted(box, key=itemgetter(1))


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

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

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

ans = []

for u in range(N):

    v = P[u] - 1

    cnt = C[v]

    val = cnt

    jump = 1

    # Jump to limit or loop

    while v != u and jump < K:

        v = P[v] - 1

        cnt += C[v]

        val = max(val, cnt)

        jump += 1

    # Reduce residual to < K

    if jump < K:

        res = max(0, K // jump - 2)

        cnt += cnt * res

        val = max(val, cnt)

        jump += jump * res

    # Residual steps

    while jump < K:

        v = P[v] - 1

        cnt += C[v]

        val = max(val, cnt)

        jump += 1

    ans.append(val)

print((max(ans)))

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

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

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

lim = 60

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

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

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

for i in range(N):

    nex[0][i] = P[i] - 1

    val[0][i] = C[i]

    cnd[0][i] = C[i]

for d in range(lim - 1):

    for i in range(N):

        nex[d + 1][i] = nex[d][nex[d][i]]

        val[d + 1][i] = val[d][i] + val[d][nex[d][i]]

        cnd[d + 1][i] = max(cnd[d][i], val[d][i] + cnd[d][nex[d][i]])

res = -10 ** 9

for i in range(N):

    sum_ = 0

    offset = i

    for d in reversed(list(range(lim))):

        if K & 1 << d:

            res = max(res, sum_ + cnd[d][offset])

            sum_ += val[d][offset]

            offset = nex[d][offset]

print(res)

N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
C = list(map(int, input().split()))
lim = 60
nex = [[0] * N for _ in range(lim)]
val = [[0] * N for _ in range(lim)]
cnd = [[0] * N for _ in range(lim)]
for i in range(N):
    nex[0][i] = P[i] - 1
    val[0][i] = C[i]
    cnd[0][i] = C[i]
for d in range(lim - 1):
    for i in range(N):
        nex[d + 1][i] = nex[d][nex[d][i]]
        val[d + 1][i] = val[d][i] + val[d][nex[d][i]]
        cnd[d + 1][i] = max(cnd[d][i], val[d][i] + cnd[d][nex[d][i]])
res = -(10**9)
for i in range(N):
    sum_ = 0
    offset = i
    for d in reversed(list(range(lim))):
        if K & 1 << d:
            res = max(res, sum_ + cnd[d][offset])
            sum_ += val[d][offset]
            offset = nex[d][offset]
print(res)

+    for d in reversed(list(range(lim))):

+            res = max(res, sum_ + cnd[d][offset])


Input:
def main():

    N = int(eval(input()))

    ans = []

    for i in range(N):

        s = eval(input())

        if s[0] in ["M", "A", "R", "C", "H"]:

            ans.append(s[0])

    from collections import Counter

    c = Counter(ans)

    ret = 0

    from itertools import combinations

    for com in combinations(list(c.values()), 3):

        ret += com[0]*com[1]*com[2]

    print(ret)

if __name__ == '__main__':

    main()

def main():

    N = int(eval(input()))

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

    from itertools import combinations

    S = {"M": 0, "A": 1, "R": 2, "C": 3, "H": 4}

    ans = 0

    cnt = [0]*5

    for a in A:

        c = a[0]

        if c in list(S.keys()):

            cnt[S[c]] += 1

    for comb in combinations(list(range(5)), 3):

        ans += cnt[comb[0]]*cnt[comb[1]]*cnt[comb[2]]

    print(ans)

if __name__ == '__main__':

    main()

def main():
    N = int(eval(input()))
    ans = []
    for i in range(N):
        s = eval(input())
        if s[0] in ["M", "A", "R", "C", "H"]:
            ans.append(s[0])
    from collections import Counter

    c = Counter(ans)
    ret = 0
    from itertools import combinations

    for com in combinations(list(c.values()), 3):
        ret += com[0] * com[1] * com[2]
    print(ret)

if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    A = [eval(input()) for i in range(N)]
    from itertools import combinations

    S = {"M": 0, "A": 1, "R": 2, "C": 3, "H": 4}
    ans = 0
    cnt = [0] * 5
    for a in A:
        c = a[0]
        if c in list(S.keys()):
            cnt[S[c]] += 1
    for comb in combinations(list(range(5)), 3):
        ans += cnt[comb[0]] * cnt[comb[1]] * cnt[comb[2]]
    print(ans)

if __name__ == "__main__":
    main()

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

-    for com in combinations(list(c.values()), 3):

+    for comb in combinations(list(range(5)), 3):

+        ans += cnt[comb[0]] * cnt[comb[1]] * cnt[comb[2]]


Input:
def main():

    N = int(eval(input()))

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

    A, count = bubbleSort(A, N)

    print((' '.join([str(a) for a in A])))

    print(count)

def bubbleSort(A, N):

    flag = True

    count = 0

    while flag:

        flag = False

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

            if A[j] < A[j-1]:

                A[j], A[j-1] = A[j-1], A[j]

                count += 1

                flag = True

    return A, count

if __name__ == '__main__':

    main()

def bubble_sort(nums, n):

    c = 0

    loop = True

    while loop:

        loop = False

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

            if nums[j] < nums[j-1]:

                nums[j], nums[j-1] = nums[j-1], nums[j]

                loop = True

                c += 1

    return (c, nums)

def main():

    n = int(eval(input()))

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

    c, nums = bubble_sort(nums, n)

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

    print(c)

if __name__ == '__main__':

    main()

def main():
    N = int(eval(input()))
    A = list(map(int, input().split(" ")))
    A, count = bubbleSort(A, N)
    print((" ".join([str(a) for a in A])))
    print(count)

def bubbleSort(A, N):
    flag = True
    count = 0
    while flag:
        flag = False
        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                count += 1
                flag = True
    return A, count

if __name__ == "__main__":
    main()

def bubble_sort(nums, n):
    c = 0
    loop = True
    while loop:
        loop = False
        for j in range(n - 1, 0, -1):
            if nums[j] < nums[j - 1]:
                nums[j], nums[j - 1] = nums[j - 1], nums[j]
                loop = True
                c += 1
    return (c, nums)

def main():
    n = int(eval(input()))
    nums = [int(x) for x in input().split()]
    c, nums = bubble_sort(nums, n)
    print((" ".join([str(x) for x in nums])))
    print(c)

if __name__ == "__main__":
    main()

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

-    print((" ".join([str(a) for a in A])))

+                nums[j], nums[j - 1] = nums[j - 1], nums[j]

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

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


Input:
import sys

input = sys.stdin.readline

def main():

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

    A = []

    B = [''] * m

    for i in range(m):

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

        A += [[p, y, i]]

    A.sort()

    count = 0

    i, x = 1, 1

    for a in A:

        if a[0] == i:

            B[a[2]] = '{:06}{:06}'.format(a[0], x)

        else:

            i, x = a[0], 1

            B[a[2]] = '{:06}{:06}'.format(a[0], x)

        x += 1

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

if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline

def main():

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

    A = []

    B = [''] * m

    for i in range(m):

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

        A.append((p, y, i))

    A.sort()

    count = 0

    i, x = 1, 1

    for a in A:

        if a[0] == i:

            B[a[2]] = '{:06}{:06}'.format(a[0], x)

        else:

            i, x = a[0], 1

            B[a[2]] = '{:06}{:06}'.format(a[0], x)

        x += 1

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

if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline

def main():
    n, m = list(map(int, input().split()))
    A = []
    B = [""] * m
    for i in range(m):
        p, y = list(map(int, input().split()))
        A += [[p, y, i]]
    A.sort()
    count = 0
    i, x = 1, 1
    for a in A:
        if a[0] == i:
            B[a[2]] = "{:06}{:06}".format(a[0], x)
        else:
            i, x = a[0], 1
            B[a[2]] = "{:06}{:06}".format(a[0], x)
        x += 1
    print(("\n".join(B)))

if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline

def main():
    n, m = list(map(int, input().split()))
    A = []
    B = [""] * m
    for i in range(m):
        p, y = list(map(int, input().split()))
        A.append((p, y, i))
    A.sort()
    count = 0
    i, x = 1, 1
    for a in A:
        if a[0] == i:
            B[a[2]] = "{:06}{:06}".format(a[0], x)
        else:
            i, x = a[0], 1
            B[a[2]] = "{:06}{:06}".format(a[0], x)
        x += 1
    print(("\n".join(B)))

if __name__ == "__main__":
    main()


Input:
import sys

sys.setrecursionlimit(1 << 25)

readline = sys.stdin.buffer.readline

read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np

from functools import partial

array = partial(np.array, dtype=np.int64)

zeros = partial(np.zeros, dtype=np.int64)

full = partial(np.full, dtype=np.int64)

def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)

def read_matrix(H, W)->np.ndarray:

    '''return np.ndarray shape=(H,W) matrix'''

    lines = []

    for _ in range(H):

        lines.append(read())

    lines = ' '.join(lines)  # byte同士の結合ができないのでreadlineでなくreadで

    return np.fromstring(lines, sep=' ', dtype=np.int64).reshape(H, W)

MOD = 10**9 + 7

INF = 2**31  # 2147483648 > 10**9

# default import

N, K = ints()

A = read_matrix(N, N)

# from numba import njit

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

def matmul_mod(X: np.ndarray, Y: np.ndarray)->np.ndarray:

    MOD = 10**9 + 7

    # return X @ Y

    ret = np.empty((X.shape[0], Y.shape[1]), dtype=np.int64)

    for i in range(X.shape[0]):  # Xの行

        for j in range(Y.shape[1]):  # Yの列

            tmp = (X[i, :] * Y[:, j]) % MOD

            ret[i, j] = tmp.sum() % MOD

    return ret

def matmul_mod_try(X: np.ndarray, Y: np.ndarray)->np.ndarray:

    MOD = 10**9 + 7

    # return X @ Y

    ret = np.empty((X.shape[0], Y.shape[1]), dtype=np.int64)

    YT = Y.T

    for i in range(X.shape[0]):  # Xの行

        Xi = X[i, :]

        tmp = (YT * Xi) % MOD

        ret[i, :] = tmp.sum(1) % MOD

    return ret

def matmul_mod_fast(X: np.ndarray, Y: np.ndarray)->np.ndarray:

    MOD = 10**9 + 7

    X3d = X[:, :, np.newaxis].transpose(0, 2, 1)

    Y3d = Y[:, :, np.newaxis].transpose(2, 1, 0)

    return ((X3d * Y3d) % MOD).sum(2) % MOD

A_double = np.asanyarray(A, dtype=np.int64)

ans = np.eye(N, dtype=np.int64)

for j in range(int(K).bit_length()):

    if (K >> j) & 1:

        ans = matmul_mod_fast(ans, A_double)

    A_double = matmul_mod_fast(A_double, A_double)

print((ans.sum() % MOD))

import sys

sys.setrecursionlimit(1 << 25)

readline = sys.stdin.buffer.readline

read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np

from functools import partial

array = partial(np.array, dtype=np.int64)

zeros = partial(np.zeros, dtype=np.int64)

full = partial(np.full, dtype=np.int64)

def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)

def read_matrix(H, W)->np.ndarray:

    '''return np.ndarray shape=(H,W) matrix'''

    lines = []

    for _ in range(H):

        lines.append(read())

    lines = ' '.join(lines)  # byte同士の結合ができないのでreadlineでなくreadで

    return np.fromstring(lines, sep=' ', dtype=np.int64).reshape(H, W)

MOD = 10**9 + 7

INF = 2**31  # 2147483648 > 10**9

# default import

N, K = ints()

A = read_matrix(N, N)

# from numba import njit

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

# def matmul_mod(X: np.ndarray, Y: np.ndarray)->np.ndarray:

#     MOD = 10**9 + 7

#     # return X @ Y

#     ret = np.empty((X.shape[0], Y.shape[1]), dtype=np.int64)

#     for i in range(X.shape[0]):  # Xの行

#         for j in range(Y.shape[1]):  # Yの列

#             tmp = (X[i, :] * Y[:, j]) % MOD

#             ret[i, j] = tmp.sum() % MOD

#     return ret

def matmul_mod(X: np.ndarray, Y: np.ndarray, MOD: int=10**9 + 7)->np.ndarray:

    # return X@Y %MOD

    ret = np.empty((X.shape[0], Y.shape[1]), dtype=np.int64)

    YT = Y.T

    for i in range(X.shape[0]):  # Xの行

        tmp = (YT * X[i, :]) % MOD

        ret[i, :] = tmp.sum(1) % MOD

    return ret

# def matmul_mod(X: np.ndarray, Y: np.ndarray, MOD: int=10**9 + 7)->np.ndarray:

#     # return X@Y %MOD

#     MOD = 10**9 + 7

#     X3d = X[:, :, np.newaxis].transpose(0, 2, 1)

#     Y3d = Y[:, :, np.newaxis].transpose(2, 1, 0)

#     return ((X3d * Y3d) % MOD).sum(2) % MOD

A_double = np.asanyarray(A, dtype=np.int64)

ans = np.eye(N, dtype=np.int64)

for j in range(int(K).bit_length()):

    if (K >> j) & 1:

        ans = matmul_mod(ans, A_double)

    A_double = matmul_mod(A_double, A_double)

print((ans.sum() % MOD))

import sys

sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
import numpy as np
from functools import partial

array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)

def ints():
    return np.fromstring(readline(), sep=" ", dtype=np.int64)

def read_matrix(H, W) -> np.ndarray:
    """return np.ndarray shape=(H,W) matrix"""
    lines = []
    for _ in range(H):
        lines.append(read())
    lines = " ".join(lines)  # byte同士の結合ができないのでreadlineでなくreadで
    return np.fromstring(lines, sep=" ", dtype=np.int64).reshape(H, W)

MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
N, K = ints()
A = read_matrix(N, N)
# from numba import njit
# @njit('i8[:,:](i8[:,:],i8[:,:])', cache=True)
def matmul_mod(X: np.ndarray, Y: np.ndarray) -> np.ndarray:
    MOD = 10**9 + 7
    # return X @ Y
    ret = np.empty((X.shape[0], Y.shape[1]), dtype=np.int64)
    for i in range(X.shape[0]):  # Xの行
        for j in range(Y.shape[1]):  # Yの列
            tmp = (X[i, :] * Y[:, j]) % MOD
            ret[i, j] = tmp.sum() % MOD
    return ret

def matmul_mod_try(X: np.ndarray, Y: np.ndarray) -> np.ndarray:
    MOD = 10**9 + 7
    # return X @ Y
    ret = np.empty((X.shape[0], Y.shape[1]), dtype=np.int64)
    YT = Y.T
    for i in range(X.shape[0]):  # Xの行
        Xi = X[i, :]
        tmp = (YT * Xi) % MOD
        ret[i, :] = tmp.sum(1) % MOD
    return ret

def matmul_mod_fast(X: np.ndarray, Y: np.ndarray) -> np.ndarray:
    MOD = 10**9 + 7
    X3d = X[:, :, np.newaxis].transpose(0, 2, 1)
    Y3d = Y[:, :, np.newaxis].transpose(2, 1, 0)
    return ((X3d * Y3d) % MOD).sum(2) % MOD

A_double = np.asanyarray(A, dtype=np.int64)
ans = np.eye(N, dtype=np.int64)
for j in range(int(K).bit_length()):
    if (K >> j) & 1:
        ans = matmul_mod_fast(ans, A_double)
    A_double = matmul_mod_fast(A_double, A_double)
print((ans.sum() % MOD))

import sys

sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
import numpy as np
from functools import partial

array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)

def ints():
    return np.fromstring(readline(), sep=" ", dtype=np.int64)

def read_matrix(H, W) -> np.ndarray:
    """return np.ndarray shape=(H,W) matrix"""
    lines = []
    for _ in range(H):
        lines.append(read())
    lines = " ".join(lines)  # byte同士の結合ができないのでreadlineでなくreadで
    return np.fromstring(lines, sep=" ", dtype=np.int64).reshape(H, W)

MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
N, K = ints()
A = read_matrix(N, N)
# from numba import njit
# @njit('i8[:,:](i8[:,:],i8[:,:])', cache=True)
# def matmul_mod(X: np.ndarray, Y: np.ndarray)->np.ndarray:
#     MOD = 10**9 + 7
#     # return X @ Y
#     ret = np.empty((X.shape[0], Y.shape[1]), dtype=np.int64)
#     for i in range(X.shape[0]):  # Xの行
#         for j in range(Y.shape[1]):  # Yの列
#             tmp = (X[i, :] * Y[:, j]) % MOD
#             ret[i, j] = tmp.sum() % MOD
#     return ret
def matmul_mod(X: np.ndarray, Y: np.ndarray, MOD: int = 10**9 + 7) -> np.ndarray:
    # return X@Y %MOD
    ret = np.empty((X.shape[0], Y.shape[1]), dtype=np.int64)
    YT = Y.T
    for i in range(X.shape[0]):  # Xの行
        tmp = (YT * X[i, :]) % MOD
        ret[i, :] = tmp.sum(1) % MOD
    return ret

# def matmul_mod(X: np.ndarray, Y: np.ndarray, MOD: int=10**9 + 7)->np.ndarray:
#     # return X@Y %MOD
#     MOD = 10**9 + 7
#     X3d = X[:, :, np.newaxis].transpose(0, 2, 1)
#     Y3d = Y[:, :, np.newaxis].transpose(2, 1, 0)
#     return ((X3d * Y3d) % MOD).sum(2) % MOD
A_double = np.asanyarray(A, dtype=np.int64)
ans = np.eye(N, dtype=np.int64)
for j in range(int(K).bit_length()):
    if (K >> j) & 1:
        ans = matmul_mod(ans, A_double)
    A_double = matmul_mod(A_double, A_double)
print((ans.sum() % MOD))

-def matmul_mod(X: np.ndarray, Y: np.ndarray) -> np.ndarray:

-    ret = np.empty((X.shape[0], Y.shape[1]), dtype=np.int64)

-        for j in range(Y.shape[1]):  # Yの列

-            ret[i, j] = tmp.sum() % MOD

-def matmul_mod_try(X: np.ndarray, Y: np.ndarray) -> np.ndarray:

+# def matmul_mod(X: np.ndarray, Y: np.ndarray)->np.ndarray:

+#     ret = np.empty((X.shape[0], Y.shape[1]), dtype=np.int64)

+#     for i in range(X.shape[0]):  # Xの行

+#         for j in range(Y.shape[1]):  # Yの列

+#             ret[i, j] = tmp.sum() % MOD

+def matmul_mod(X: np.ndarray, Y: np.ndarray, MOD: int = 10**9 + 7) -> np.ndarray:

-def matmul_mod_fast(X: np.ndarray, Y: np.ndarray) -> np.ndarray:

-    X3d = X[:, :, np.newaxis].transpose(0, 2, 1)

-    Y3d = Y[:, :, np.newaxis].transpose(2, 1, 0)

-    return ((X3d * Y3d) % MOD).sum(2) % MOD

+# def matmul_mod(X: np.ndarray, Y: np.ndarray, MOD: int=10**9 + 7)->np.ndarray:

+#     X3d = X[:, :, np.newaxis].transpose(0, 2, 1)

+#     Y3d = Y[:, :, np.newaxis].transpose(2, 1, 0)

+#     return ((X3d * Y3d) % MOD).sum(2) % MOD

-        ans = matmul_mod_fast(ans, A_double)

-    A_double = matmul_mod_fast(A_double, A_double)

+        ans = matmul_mod(ans, A_double)

+    A_double = matmul_mod(A_double, A_double)


Input:
import sys

sys.setrecursionlimit(500000)

def f(i):

    if dp[i] != -1 and dp[i] != 0: return dp[i]

    if dp[i] == -1: return 0

    if i == -1:

        return f(i - 1)

    elif i > 1:

        dp[i] = f(i - 1) + f(i - 2)

    else:

        dp[i] = f(i - 1)

    return dp[i]

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

dp = [0]*(n+1)

ary = [int(eval(input())) for _ in range(m)]

dp[0] = 1

for i in ary:

    dp[i] = -1

    if dp[i-1] == -1 and dp[i] == -1:print((0));exit()

print((f(n)%(10**9+7)))

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

dp = [0]*(n+1)

for i in range(m):

    x = int(eval(input()))

    dp[x] = -1

dp[0] = 1

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

    if dp[i] == -1:continue

    elif dp[i-1] == -1:dp[i] = dp[i-2]

    elif dp[i-2] == -1:dp[i] = dp[i-1]

    elif i > 1:

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

    else:dp[i] = dp[i-1]

print((dp[n]%(10**9+7) if dp[n] != -1 else 0))

import sys

sys.setrecursionlimit(500000)

def f(i):
    if dp[i] != -1 and dp[i] != 0:
        return dp[i]
    if dp[i] == -1:
        return 0
    if i == -1:
        return f(i - 1)
    elif i > 1:
        dp[i] = f(i - 1) + f(i - 2)
    else:
        dp[i] = f(i - 1)
    return dp[i]

n, m = list(map(int, input().split()))
dp = [0] * (n + 1)
ary = [int(eval(input())) for _ in range(m)]
dp[0] = 1
for i in ary:
    dp[i] = -1
    if dp[i - 1] == -1 and dp[i] == -1:
        print((0))
        exit()
print((f(n) % (10**9 + 7)))

n, m = list(map(int, input().split()))
dp = [0] * (n + 1)
for i in range(m):
    x = int(eval(input()))
    dp[x] = -1
dp[0] = 1
for i in range(1, n + 1):
    if dp[i] == -1:
        continue
    elif dp[i - 1] == -1:
        dp[i] = dp[i - 2]
    elif dp[i - 2] == -1:
        dp[i] = dp[i - 1]
    elif i > 1:
        dp[i] = dp[i - 2] + dp[i - 1]
    else:
        dp[i] = dp[i - 1]
print((dp[n] % (10**9 + 7) if dp[n] != -1 else 0))

-ary = [int(eval(input())) for _ in range(m)]


Input:
a=[]

for x in range(10):

    a.append(eval(input()))

a.sort(reverse=True)

for x in range(3):

    print(a[x])

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

a.sort(reverse=True)

for i in range(3):

    print(a[i])

a = []
for x in range(10):
    a.append(eval(input()))
a.sort(reverse=True)
for x in range(3):
    print(a[x])

a = [eval(input()) for i in range(10)]
a.sort(reverse=True)
for i in range(3):
    print(a[i])

-a = []
-for x in range(10):
-    a.append(eval(input()))
+a = [eval(input()) for i in range(10)]
-for x in range(3):
-    print(a[x])
+for i in range(3):
+    print(a[i])


Input:
[n, m, l] = [int(x) for x in input().split()]

A = []

B = []

C = []

counter = 0

while counter < n:

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

    counter += 1

counter = 0

while counter < m:

    B.append([int(x) for x in input().split()])

    counter += 1

counter = 0

while counter < n:

    C.append([0] * l)

    counter += 1

for i in range(n):

    for j in range(l):

        for k in range(m):

            C[i][j] += (A[i][k] * B[k][j])

for data in C:

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

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

A = []

B = []

counter = 0

while counter < n:

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

    counter += 1

counter = 0

while counter < m:

    B.append([int(x) for x in input().split()])

    counter += 1

B = list(zip(*B))

for i in range(n):

    data = []

    for j in range(l):

        data.append(sum([x[0] * x[1] for x in zip(A[i], B[j])]))

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

[n, m, l] = [int(x) for x in input().split()]
A = []
B = []
C = []
counter = 0
while counter < n:
    A.append([int(x) for x in input().split()])
    counter += 1
counter = 0
while counter < m:
    B.append([int(x) for x in input().split()])
    counter += 1
counter = 0
while counter < n:
    C.append([0] * l)
    counter += 1
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for data in C:
    print((" ".join([str(x) for x in data])))

[n, m, l] = [int(x) for x in input().split()]
A = []
B = []
counter = 0
while counter < n:
    A.append([int(x) for x in input().split()])
    counter += 1
counter = 0
while counter < m:
    B.append([int(x) for x in input().split()])
    counter += 1
B = list(zip(*B))
for i in range(n):
    data = []
    for j in range(l):
        data.append(sum([x[0] * x[1] for x in zip(A[i], B[j])]))
    print((" ".join([str(x) for x in data])))

+        data.append(sum([x[0] * x[1] for x in zip(A[i], B[j])]))


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

ans = 'No'

if 4*X < Y:

    print(ans)

else:

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

        crane = i

        turtle = X - i

        crane2 = X - i

        turtle2 = i

        if 2*crane + 4*turtle == Y or 2*crane2 + 4*turtle2 == Y:

            ans = 'Yes'

            break

    print(ans)

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

ans = 'No'

if 4*X < Y:

    print(ans)

else:

    for i in range(X+1):

        crane = i

        turtle = X - i

        if 2*crane + 4*turtle == Y:

            ans = 'Yes'

            break

    print(ans)

X, Y = list(map(int, input().split()))
ans = "No"
if 4 * X < Y:
    print(ans)
else:
    for i in range(1, X + 1):
        crane = i
        turtle = X - i
        crane2 = X - i
        turtle2 = i
        if 2 * crane + 4 * turtle == Y or 2 * crane2 + 4 * turtle2 == Y:
            ans = "Yes"
            break
    print(ans)

X, Y = list(map(int, input().split()))
ans = "No"
if 4 * X < Y:
    print(ans)
else:
    for i in range(X + 1):
        crane = i
        turtle = X - i
        if 2 * crane + 4 * turtle == Y:
            ans = "Yes"
            break
    print(ans)

-        if 2 * crane + 4 * turtle == Y or 2 * crane2 + 4 * turtle2 == Y:

+        if 2 * crane + 4 * turtle == Y:


Input:
# coding: utf-8

def solve(*args: str) -> str:

    k = int(args[0])

    ret = 1

    a = 7 % k

    while(a):

        a = (a*10+7) % k

        ret += 1

        if k < ret:

            ret = -1

            break

    return str(ret)

if __name__ == "__main__":

    print((solve(*(open(0).read().splitlines()))))

# coding: utf-8

def solve(*args: str) -> str:

    k = int(args[0])

    l = 9*(k//7 if k % 7 == 0 else k)

    if l % 2 == 0 or l % 5 == 0:

        return '-1'

    r = phi = l

    for i in range(2, int(-pow(l, 1/2))):

        if r % i == 0:

            phi = phi//i*(i-1)

            while r % i:

                r //= i

    a = 10 % l

    ret = 1

    while(a != 1):

        a = a*10 % l

        ret += 1

        if phi < ret:

            ret = -1

            break

    return str(ret)

if __name__ == "__main__":

    print((solve(*(open(0).read().splitlines()))))

# coding: utf-8
def solve(*args: str) -> str:
    k = int(args[0])
    ret = 1
    a = 7 % k
    while a:
        a = (a * 10 + 7) % k
        ret += 1
        if k < ret:
            ret = -1
            break
    return str(ret)

if __name__ == "__main__":
    print((solve(*(open(0).read().splitlines()))))

# coding: utf-8
def solve(*args: str) -> str:
    k = int(args[0])
    l = 9 * (k // 7 if k % 7 == 0 else k)
    if l % 2 == 0 or l % 5 == 0:
        return "-1"
    r = phi = l
    for i in range(2, int(-pow(l, 1 / 2))):
        if r % i == 0:
            phi = phi // i * (i - 1)
            while r % i:
                r //= i
    a = 10 % l
    ret = 1
    while a != 1:
        a = a * 10 % l
        ret += 1
        if phi < ret:
            ret = -1
            break
    return str(ret)

if __name__ == "__main__":
    print((solve(*(open(0).read().splitlines()))))

+    for i in range(2, int(-pow(l, 1 / 2))):


Input:
def main():

    from collections import deque

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

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

    def solve(a):

        dq = deque()

        s = 0

        ans = 0

        for x in a:

            if len(dq) > 1:

                t = dq.popleft()

                s -= t

            eat = max(0, s + x - L)

            if eat:

                x -= eat

                ans += eat

            s += x

            dq.append(x)

        return ans

    ans = min(solve(a), solve(reversed(a)))

    print(ans)

if __name__ == '__main__':

    main()

def main():

    from collections import deque

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

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

    def solve(a):

        dq = deque()

        s = 0

        ans = 0

        for x in a:

            if len(dq) > 1:

                t = dq.popleft()

                s -= t

            eat = max(0, s + x - L)

            if eat:

                x -= eat

                ans += eat

            s += x

            dq.append(x)

        return ans

    ans =solve(a) # reversed(a)確認しないとどうなるか

    print(ans)

if __name__ == '__main__':

    main()

def main():
    from collections import deque

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

    def solve(a):
        dq = deque()
        s = 0
        ans = 0
        for x in a:
            if len(dq) > 1:
                t = dq.popleft()
                s -= t
            eat = max(0, s + x - L)
            if eat:
                x -= eat
                ans += eat
            s += x
            dq.append(x)
        return ans

    ans = min(solve(a), solve(reversed(a)))
    print(ans)

if __name__ == "__main__":
    main()

def main():
    from collections import deque

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

    def solve(a):
        dq = deque()
        s = 0
        ans = 0
        for x in a:
            if len(dq) > 1:
                t = dq.popleft()
                s -= t
            eat = max(0, s + x - L)
            if eat:
                x -= eat
                ans += eat
            s += x
            dq.append(x)
        return ans

    ans = solve(a)  # reversed(a)確認しないとどうなるか
    print(ans)

if __name__ == "__main__":
    main()

-    ans = min(solve(a), solve(reversed(a)))

+    ans = solve(a)  # reversed(a)確認しないとどうなるか


Input:
"""Rooted Trees."""

class Node:

    def __init__(self, num, parent, *children):

        self.id = num

        self.parent = parent

        self.children = list(children)

        self.depth = 0

    def show_info(self):

        print('node {0}: '.format(self.id), end = '')

        print('parent = {0}, '.format(self.parent), end = '')

        print('depth = {0}, '.format(self.depth), end = '')

        if self.children and self.parent != -1:

            print('internal node, ', end = '')

        elif self.parent != -1:

            print('leaf, ', end = '')

        else:

            print('root, ', end = '')

        print(self.children)

class RootedTree():

    def __init__(self, n):

        self.nodes = [Node(i, -1) for i in range(n)]

    def set_node(self, i_p):

        i_p = list(map(int, i_p.split()))

        num = i_p[0]

        children = i_p[2:]

        if children:

            self.nodes[num].children = children

            for n in children:

                self.nodes[n].parent = num

    def set_depth(self):

        for n in self.nodes:

            t_n = n

            while t_n.parent != -1:

                n.depth += 1

                t_n = self.nodes[t_n.parent]

    def show_nodes_info(self):

        for n in self.nodes:

            n.show_info()

import sys

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

T = RootedTree(n)

for x in sys.stdin.readlines():

    T.set_node(x)

T.set_depth()

T.show_nodes_info()

class Node:

    def __init__(self, num, parent, *children):

        self.id = num

        self.parent = parent

        self.children = list(children)

        self.depth = 0

    def show_info(self):

        print('node {0}: '.format(self.id), end = '')

        print('parent = {0}, '.format(self.parent), end = '')

        print('depth = {0}, '.format(self.depth), end = '')

        if self.children and self.parent != -1:

            print('internal node, ', end = '')

        elif self.parent != -1:

            print('leaf, ', end = '')

        else:

            print('root, ', end = '')

        print(self.children)

def set_node(i_p):

    i_p = list(map(int, i_p.split()))

    num = i_p[0]

    children = i_p[2:]

    if children:

        T[num].children = children

        for n in children:

            T[n].parent = num

def find_root(node):

    while node.parent != -1:

        node = T[node.parent]

    return node

def set_depth(node, depth):

    node.depth = depth

    for n in node.children:

        set_depth(T[n], depth + 1)

import sys

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

T = [Node(i, -1) for i in range(n)]

for x in sys.stdin.readlines():

    set_node(x)

r_n = find_root(T[0])

set_depth(r_n, 0)

for n in T:

    n.show_info()

"""Rooted Trees."""

class Node:
    def __init__(self, num, parent, *children):
        self.id = num
        self.parent = parent
        self.children = list(children)
        self.depth = 0

    def show_info(self):
        print("node {0}: ".format(self.id), end="")
        print("parent = {0}, ".format(self.parent), end="")
        print("depth = {0}, ".format(self.depth), end="")
        if self.children and self.parent != -1:
            print("internal node, ", end="")
        elif self.parent != -1:
            print("leaf, ", end="")
        else:
            print("root, ", end="")
        print(self.children)

class RootedTree:
    def __init__(self, n):
        self.nodes = [Node(i, -1) for i in range(n)]

    def set_node(self, i_p):
        i_p = list(map(int, i_p.split()))
        num = i_p[0]
        children = i_p[2:]
        if children:
            self.nodes[num].children = children
            for n in children:
                self.nodes[n].parent = num

    def set_depth(self):
        for n in self.nodes:
            t_n = n
            while t_n.parent != -1:
                n.depth += 1
                t_n = self.nodes[t_n.parent]

    def show_nodes_info(self):
        for n in self.nodes:
            n.show_info()

import sys

n = int(sys.stdin.readline())
T = RootedTree(n)
for x in sys.stdin.readlines():
    T.set_node(x)
T.set_depth()
T.show_nodes_info()

class Node:
    def __init__(self, num, parent, *children):
        self.id = num
        self.parent = parent
        self.children = list(children)
        self.depth = 0

    def show_info(self):
        print("node {0}: ".format(self.id), end="")
        print("parent = {0}, ".format(self.parent), end="")
        print("depth = {0}, ".format(self.depth), end="")
        if self.children and self.parent != -1:
            print("internal node, ", end="")
        elif self.parent != -1:
            print("leaf, ", end="")
        else:
            print("root, ", end="")
        print(self.children)

def set_node(i_p):
    i_p = list(map(int, i_p.split()))
    num = i_p[0]
    children = i_p[2:]
    if children:
        T[num].children = children
        for n in children:
            T[n].parent = num

def find_root(node):
    while node.parent != -1:
        node = T[node.parent]
    return node

def set_depth(node, depth):
    node.depth = depth
    for n in node.children:
        set_depth(T[n], depth + 1)

import sys

n = int(sys.stdin.readline())
T = [Node(i, -1) for i in range(n)]
for x in sys.stdin.readlines():
    set_node(x)
r_n = find_root(T[0])
set_depth(r_n, 0)
for n in T:
    n.show_info()

-        self.nodes = [Node(i, -1) for i in range(n)]

-        i_p = list(map(int, i_p.split()))

-            self.nodes[num].children = children

-                self.nodes[n].parent = num

-                t_n = self.nodes[t_n.parent]


Input:
# ContestName

# URL

import sys

#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]

ss2nn = lambda ss: [int(s) for s in ss]

ss2nnn = lambda ss: [s2nn(s) for s in ss]

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

i2n = lambda: int(i2s())

i2nn = lambda: s2nn(i2s())

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

ii2nn = lambda n: ss2nn(ii2ss(n))

ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():

    N = i2n()

    H = i2nn()

    n = 0

    while True:

        l = -1

        r = -1

        for i, h in enumerate(H):

            if l == -1 and h > 0:

                l = i

            if l > -1 and r == -1 and h <= 0:

                r = i

        if l == -1:

            break

        if r == -1:

            r = N

        for i in range(l, r):

            H[i] -= 1

        n += 1

    print(n)

main()

import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]

ss2nn = lambda ss: [int(s) for s in ss]

ss2nnn = lambda ss: [s2nn(s) for s in ss]

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

i2n = lambda: int(i2s())

i2nn = lambda: s2nn(i2s())

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

ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]

ii2nn = lambda n: ss2nn(ii2ss(n))

ii2nnn = lambda n: ss2nnn(ii2ss(n))

from collections import deque  # 双方向キュー

from collections import defaultdict  # 初期化済み辞書

from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー

from bisect import bisect_left, bisect_right  # 二分探索

sys.setrecursionlimit(int(1e+6))

MOD = int(1e+9) + 7

#import numpy as np  # 1.8.2

#import scipy  # 0.13.3

def main():

    N = i2n()

    H = i2nn()

    op = 0

    while True:

        b = False

        hmax = 0

        for i in range(N):

            if H[i] > 0:

                if b == False:

                    b = True

                    op += 1

                H[i] -= 1

                if hmax < H[i]:

                    hmax = H[i]

            else:

                b = False

        if hmax == 0:

            break

    print(op)

main()

# ContestName
# URL
import sys

# import numpy as np
s2nn = lambda s: [int(c) for c in s.split(" ")]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    H = i2nn()
    n = 0
    while True:
        l = -1
        r = -1
        for i, h in enumerate(H):
            if l == -1 and h > 0:
                l = i
            if l > -1 and r == -1 and h <= 0:
                r = i
        if l == -1:
            break
        if r == -1:
            r = N
        for i in range(l, r):
            H[i] -= 1
        n += 1
    print(n)

main()

import sys

s2nn = lambda s: [int(c) for c in s.split(" ")]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索

sys.setrecursionlimit(int(1e6))
MOD = int(1e9) + 7
# import numpy as np  # 1.8.2
# import scipy  # 0.13.3
def main():
    N = i2n()
    H = i2nn()
    op = 0
    while True:
        b = False
        hmax = 0
        for i in range(N):
            if H[i] > 0:
                if b == False:
                    b = True
                    op += 1
                H[i] -= 1
                if hmax < H[i]:
                    hmax = H[i]
            else:
                b = False
        if hmax == 0:
            break
    print(op)

main()

+ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]

+from collections import deque  # 双方向キュー

+from collections import defaultdict  # 初期化済み辞書

+from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー

+from bisect import bisect_left, bisect_right  # 二分探索


Input:
from collections import defaultdict

N = int(eval(input()))

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

d = defaultdict(int)

d[0] = 1

sum = 0

for i in range(N):

    sum += A[i]

    d[sum] += 1

ans = 0

for v in list(d.values()):

    if v >= 2:

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

print(ans)

import collections

N = int(eval(input()))

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

S = [0]

for a in A:

    S.append(S[-1]+a)

C = collections.Counter(S)

ans = 0

for v in list(C.values()):

    if v >= 2:

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

print(ans)

from collections import defaultdict

N = int(eval(input()))
A = [int(i) for i in input().split()]
d = defaultdict(int)
d[0] = 1
sum = 0
for i in range(N):
    sum += A[i]
    d[sum] += 1
ans = 0
for v in list(d.values()):
    if v >= 2:
        ans += (v * (v - 1)) // 2
print(ans)

import collections

N = int(eval(input()))
A = [int(i) for i in input().split()]
S = [0]
for a in A:
    S.append(S[-1] + a)
C = collections.Counter(S)
ans = 0
for v in list(C.values()):
    if v >= 2:
        ans += v * (v - 1) // 2
print(ans)

-from collections import defaultdict
+import collections
-d = defaultdict(int)
-d[0] = 1
-sum = 0
-for i in range(N):
-    sum += A[i]
-    d[sum] += 1
+S = [0]
+for a in A:
+    S.append(S[-1] + a)
+C = collections.Counter(S)
-for v in list(d.values()):
+for v in list(C.values()):
-        ans += (v * (v - 1)) // 2
+        ans += v * (v - 1) // 2


Input:
from itertools import permutations

def solve(string):

    n, a, b, c, *l = list(map(int, string.split()))

    ans = 3000

    for _l in permutations(l):

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

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

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

                    tmp = 10 * (i - 1) + abs(a - sum(_l[:i])) + 10 * (j - i - 1) + abs(

                        b - sum(_l[i:j])) + 10 * (k - j - 1) + abs(c - sum(_l[j:k]))

                    if tmp < ans:

                        ans = tmp

    return str(ans)

if __name__ == '__main__':

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

    print((solve('{} {} {} {}\n'.format(n, a, b, c) + '\n'.join([eval(input()) for _ in range(n)]))))

from itertools import permutations

def solve(string):

    n, a, b, c, *l = list(map(int, string.split()))

    ans = 3000

    for _l in permutations(l):

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

            tmp_a = 10 * (i - 1) + abs(a - sum(_l[:i]))

            if tmp_a >= ans:

                continue

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

                tmp_b = 10 * (j - i - 1) + abs(b - sum(_l[i:j]))

                if tmp_a + tmp_b >= ans:

                    continue

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

                    tmp = tmp_a + tmp_b + 10 * (k - j - 1) + abs(c - sum(_l[j:k]))

                    if tmp < ans:

                        ans = tmp

    return str(ans)

if __name__ == '__main__':

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

    print((solve('{} {} {} {}\n'.format(n, a, b, c) + '\n'.join([eval(input()) for _ in range(n)]))))

from itertools import permutations

def solve(string):
    n, a, b, c, *l = list(map(int, string.split()))
    ans = 3000
    for _l in permutations(l):
        for i in range(1, len(l) - 1):
            for j in range(i + 1, len(l)):
                for k in range(j + 1, len(l) + 1):
                    tmp = (
                        10 * (i - 1)
                        + abs(a - sum(_l[:i]))
                        + 10 * (j - i - 1)
                        + abs(b - sum(_l[i:j]))
                        + 10 * (k - j - 1)
                        + abs(c - sum(_l[j:k]))
                    )
                    if tmp < ans:
                        ans = tmp
    return str(ans)

if __name__ == "__main__":
    n, a, b, c = list(map(int, input().split()))
    print(
        (
            solve(
                "{} {} {} {}\n".format(n, a, b, c)
                + "\n".join([eval(input()) for _ in range(n)])
            )
        )
    )

from itertools import permutations

def solve(string):
    n, a, b, c, *l = list(map(int, string.split()))
    ans = 3000
    for _l in permutations(l):
        for i in range(1, len(l) - 1):
            tmp_a = 10 * (i - 1) + abs(a - sum(_l[:i]))
            if tmp_a >= ans:
                continue
            for j in range(i + 1, len(l)):
                tmp_b = 10 * (j - i - 1) + abs(b - sum(_l[i:j]))
                if tmp_a + tmp_b >= ans:
                    continue
                for k in range(j + 1, len(l) + 1):
                    tmp = tmp_a + tmp_b + 10 * (k - j - 1) + abs(c - sum(_l[j:k]))
                    if tmp < ans:
                        ans = tmp
    return str(ans)

if __name__ == "__main__":
    n, a, b, c = list(map(int, input().split()))
    print(
        (
            solve(
                "{} {} {} {}\n".format(n, a, b, c)
                + "\n".join([eval(input()) for _ in range(n)])
            )
        )
    )

+                if tmp_a + tmp_b >= ans:


Input:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7

dd=[(-1,0),(0,1),(1,0),(0,-1)]

ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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

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

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

def S(): return eval(input())

nmax=50

graph=[[False]*nmax for _ in range(nmax)]

visited=[False]*nmax

def dfs(n,v):

  visited[v]=True

  for v2 in range(n):

    if graph[v][v2]==False:

      continue

    if visited[v2]:

      continue

    dfs(n,v2)

def main():

  n,m=LI()

  a=[]

  b=[]

  for _ in range(m):

    _a,_b=LI()

    a.append(_a-1)

    b.append(_b-1)

    graph[_a-1][_b-1]=True

    graph[_b-1][_a-1]=True

  ans=0

  for i in range(m):

    graph[a[i]][b[i]]=False

    graph[b[i]][a[i]]=False

    for j in range(n):

      visited[j]=False

    dfs(n,j)

    bridge=False

    for j in range(n):

      if visited[j]==False:

        bridge=True

    if bridge:

      ans+=1

    graph[a[i]][b[i]]=True

    graph[b[i]][a[i]]=True

  return ans

# main()

print((main()))

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7

dd=[(-1,0),(0,1),(1,0),(0,-1)]

ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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

def LF(): return [float(x) for x in sys.stdin.readline().split()]

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

def F(): return float(sys.stdin.readline())

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

def S(): return eval(input())

limit=50

graph=[[False]*limit for _ in range(limit)]

visited=[False]*limit

def dfs(n,v):

  visited[v]=True

  for v2 in range(n):

    if graph[v][v2]==False:

      continue

    if visited[v2]:

      continue

    dfs(n,v2)

def main():

  n,m=LI()

  a=[[] for _ in range(n*n)]

  b=[[] for _ in range(n*n)]

  for i in range(m):

    _a,_b=LI()

    _a-=1

    _b-=1

    a[i]=_a

    b[i]=_b

    graph[_a][_b]=True

    graph[_b][_a]=True

  ans=0

  for i in range(m):

    graph[a[i]][b[i]]=False

    graph[b[i]][a[i]]=False

    for j in range(n):

      visited[j]=False

    dfs(n,0)

    no_visited=False

    for j in range(n):

      if visited[j]==False:

        no_visited=True

    if no_visited:

      ans+=1

    graph[a[i]][b[i]]=True

    graph[b[i]][a[i]]=True

  return ans

# main()

print((main()))

import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

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

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

def S():
    return eval(input())

nmax = 50
graph = [[False] * nmax for _ in range(nmax)]
visited = [False] * nmax

def dfs(n, v):
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:
            continue
        if visited[v2]:
            continue
        dfs(n, v2)

def main():
    n, m = LI()
    a = []
    b = []
    for _ in range(m):
        _a, _b = LI()
        a.append(_a - 1)
        b.append(_b - 1)
        graph[_a - 1][_b - 1] = True
        graph[_b - 1][_a - 1] = True
    ans = 0
    for i in range(m):
        graph[a[i]][b[i]] = False
        graph[b[i]][a[i]] = False
        for j in range(n):
            visited[j] = False
        dfs(n, j)
        bridge = False
        for j in range(n):
            if visited[j] == False:
                bridge = True
        if bridge:
            ans += 1
        graph[a[i]][b[i]] = True
        graph[b[i]][a[i]] = True
    return ans

# main()
print((main()))

import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LF():
    return [float(x) for x in sys.stdin.readline().split()]

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

def F():
    return float(sys.stdin.readline())

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

def S():
    return eval(input())

limit = 50
graph = [[False] * limit for _ in range(limit)]
visited = [False] * limit

def dfs(n, v):
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:
            continue
        if visited[v2]:
            continue
        dfs(n, v2)

def main():
    n, m = LI()
    a = [[] for _ in range(n * n)]
    b = [[] for _ in range(n * n)]
    for i in range(m):
        _a, _b = LI()
        _a -= 1
        _b -= 1
        a[i] = _a
        b[i] = _b
        graph[_a][_b] = True
        graph[_b][_a] = True
    ans = 0
    for i in range(m):
        graph[a[i]][b[i]] = False
        graph[b[i]][a[i]] = False
        for j in range(n):
            visited[j] = False
        dfs(n, 0)
        no_visited = False
        for j in range(n):
            if visited[j] == False:
                no_visited = True
        if no_visited:
            ans += 1
        graph[a[i]][b[i]] = True
        graph[b[i]][a[i]] = True
    return ans

# main()
print((main()))

-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy

+import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy

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

-graph = [[False] * nmax for _ in range(nmax)]

+graph = [[False] * limit for _ in range(limit)]


Input:
# ABC068C - Cat Snuke and a Voyage (ARC079C)

def main():

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

    A = tuple(tuple(map(int, input().split())) for _ in range(M))

    S, D = set(), set()  # start, destination

    for a, b in A:

        if a == 1:

            S |= {b}

        if b == N:

            D |= {a}

    flg = S & D  # if the same X in both S & D -> possible

    print(("POSSIBLE" if flg else "IMPOSSIBLE"))

if __name__ == "__main__":

    main()

# ABC068C - Cat Snuke and a Voyage (ARC079C)

import sys

input = sys.stdin.readline

def main():

    N, M = input().split()

    A = tuple(input().split() for _ in range(int(M)))

    S, D = set(), set()  # start, destination

    for a, b in A:

        if a == "1":

            S |= {b}

        if b == N:

            D |= {a}

    flg = S & D  # if the same X in both S & D -> possible

    print(("POSSIBLE" if flg else "IMPOSSIBLE"))

if __name__ == "__main__":

    main()

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

-    A = tuple(tuple(map(int, input().split())) for _ in range(M))

+    A = tuple(input().split() for _ in range(int(M)))


Input:
import heapq

n = int(eval(input()))

happy = []

ans = 0

for i in range(n):

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

    heapq.heappush(happy, - (a + b))

    ans += a

while len(happy) != 0:

    heapq.heappop(happy)

    if len(happy) != 0:

        h = heapq.heappop(happy)

        ans += h

    else:

        break

print(ans)

n = int(eval(input()))

happy = []

ans = 0

for i in range(n):

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

    happy.append(a + b)

    ans += a

happy.sort(reverse=True)

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

    ans -= happy[i]

print(ans)

import heapq

n = int(eval(input()))
happy = []
ans = 0
for i in range(n):
    a, b = tuple(map(int, input().split()))
    heapq.heappush(happy, -(a + b))
    ans += a
while len(happy) != 0:
    heapq.heappop(happy)
    if len(happy) != 0:
        h = heapq.heappop(happy)
        ans += h
    else:
        break
print(ans)

-import heapq
-    heapq.heappush(happy, -(a + b))
+    happy.append(a + b)
-while len(happy) != 0:
-    heapq.heappop(happy)
-    if len(happy) != 0:
-        h = heapq.heappop(happy)
-        ans += h
-    else:
-        break
+happy.sort(reverse=True)
+for i in range(1, n, 2):
+    ans -= happy[i]


Input:
# 入力が10**5とかになったときに100ms程度早い

import sys

read = sys.stdin.readline

def read_ints():

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

def read_a_int():

    return int(read())

def read_matrix(H):

    '''

    H is number of rows

    '''

    return [list(map(int, read().split())) for _ in range(H)]

def read_map(H):

    '''

    H is number of rows

    文字列で与えられた盤面を読み取る用

    '''

    return [read()[:-1] for _ in range(H)]

def read_col(H, n_cols):

    '''

    H is number of rows

    n_cols is number of cols

    A列、B列が与えられるようなとき

    '''

    ret = [[] for _ in range(n_cols)]

    for _ in range(H):

        tmp = list(map(int, read().split()))

        for col in range(n_cols):

            ret[col].append(tmp[col])

    return ret

MOD = 10**9 + 7

X, Y = read_ints()

if (X + Y) % 3 != 0:  # !=0

    print((0))

    exit()

pascal_depth = int((X + Y) / 3)  # パスカルの三角形に当たるn

x, y = int((X + Y) * 2 / 3), (X + Y) / 3

pascal_k = x - X  # 端からいくつずれているか

if pascal_k > pascal_depth / 2:

    pascal_k = pascal_depth - pascal_k

# ans = 1

# # for k in range(int(pascal_k), 0, -1):

# #     ans *= pascal_depth

# #     # print(ans)

# #     pascal_depth -= 1

# #     if ans > MOD:

# #         ans %= MOD

# # for k in range(int(pascal_k), 0, -1):

# # フェルマーの少定理jを使ってみる

# for i in range(1, int(pascal_depth) + 1):

#     ans *= i

#     if ans > MOD:

#         ans %= MOD

# from math import factorial

# # k_fact = factorial(pascal_k)

# k_fact = 1

# # k_fact

# for i in range(1, pascal_k + 1):

#     k_fact *= i

#     if k_fact > MOD:

#         k_fact %= MOD

# ans *= k_fact**(MOD - 2) % MOD

# # nk_fact = factorial(pascal_depth - pascal_k)

# nk_fact = 1

# for i in range(1, int(pascal_depth - pascal_k) + 1):

#     nk_fact *= i

#     if nk_fact > MOD:

#         nk_fact %= MOD

# ans *= nk_fact**(MOD - 2) % MOD

def cmb(n, r, mod):

    if (r < 0 or r > n):

        return 0

    r = min(r, n - r)

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

mod = 10**9 + 7  # 出力の制限

N = pascal_depth

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

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

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

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

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

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

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

a = cmb(pascal_depth, pascal_k, mod)

print(a)

# 入力が10**5とかになったときに100ms程度早い

import sys

read = sys.stdin.readline

def read_ints():

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

def read_a_int():

    return int(read())

def read_matrix(H):

    '''

    H is number of rows

    '''

    return [list(map(int, read().split())) for _ in range(H)]

def read_map(H):

    '''

    H is number of rows

    文字列で与えられた盤面を読み取る用

    '''

    return [read()[:-1] for _ in range(H)]

def read_col(H, n_cols):

    '''

    H is number of rows

    n_cols is number of cols

    A列、B列が与えられるようなとき

    '''

    ret = [[] for _ in range(n_cols)]

    for _ in range(H):

        tmp = list(map(int, read().split()))

        for col in range(n_cols):

            ret[col].append(tmp[col])

    return ret

MOD = 10**9 + 7

X, Y = read_ints()

if (X + Y) % 3 != 0:  # !=0

    print((0))

    exit()

pascal_depth = int((X + Y) / 3)  # パスカルの三角形に当たるn

x, y = int((X + Y) * 2 / 3), (X + Y) / 3

pascal_k = x - X  # 端からいくつずれているか

if pascal_k > pascal_depth / 2:

    pascal_k = pascal_depth - pascal_k

def cmb(n, r, mod):

    if (r < 0 or r > n):

        return 0

    r = min(r, n - r)

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

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

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

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

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

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

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

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

a = cmb(pascal_depth, pascal_k, MOD)

print(a)

# 入力が10**5とかになったときに100ms程度早い
import sys

read = sys.stdin.readline

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

def read_a_int():
    return int(read())

def read_matrix(H):
    """
    H is number of rows
    """
    return [list(map(int, read().split())) for _ in range(H)]

def read_map(H):
    """
    H is number of rows
    文字列で与えられた盤面を読み取る用
    """
    return [read()[:-1] for _ in range(H)]

def read_col(H, n_cols):
    """
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    """
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret

MOD = 10**9 + 7
X, Y = read_ints()
if (X + Y) % 3 != 0:  # !=0
    print((0))
    exit()
pascal_depth = int((X + Y) / 3)  # パスカルの三角形に当たるn
x, y = int((X + Y) * 2 / 3), (X + Y) / 3
pascal_k = x - X  # 端からいくつずれているか
if pascal_k > pascal_depth / 2:
    pascal_k = pascal_depth - pascal_k
# ans = 1
# # for k in range(int(pascal_k), 0, -1):
# #     ans *= pascal_depth
# #     # print(ans)
# #     pascal_depth -= 1
# #     if ans > MOD:
# #         ans %= MOD
# # for k in range(int(pascal_k), 0, -1):
# # フェルマーの少定理jを使ってみる
# for i in range(1, int(pascal_depth) + 1):
#     ans *= i
#     if ans > MOD:
#         ans %= MOD
# from math import factorial
# # k_fact = factorial(pascal_k)
# k_fact = 1
# # k_fact
# for i in range(1, pascal_k + 1):
#     k_fact *= i
#     if k_fact > MOD:
#         k_fact %= MOD
# ans *= k_fact**(MOD - 2) % MOD
# # nk_fact = factorial(pascal_depth - pascal_k)
# nk_fact = 1
# for i in range(1, int(pascal_depth - pascal_k) + 1):
#     nk_fact *= i
#     if nk_fact > MOD:
#         nk_fact %= MOD
# ans *= nk_fact**(MOD - 2) % MOD
def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

mod = 10**9 + 7  # 出力の制限
N = pascal_depth
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
a = cmb(pascal_depth, pascal_k, mod)
print(a)

# 入力が10**5とかになったときに100ms程度早い
import sys

read = sys.stdin.readline

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

def read_a_int():
    return int(read())

def read_matrix(H):
    """
    H is number of rows
    """
    return [list(map(int, read().split())) for _ in range(H)]

def read_map(H):
    """
    H is number of rows
    文字列で与えられた盤面を読み取る用
    """
    return [read()[:-1] for _ in range(H)]

def read_col(H, n_cols):
    """
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    """
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret

MOD = 10**9 + 7
X, Y = read_ints()
if (X + Y) % 3 != 0:  # !=0
    print((0))
    exit()
pascal_depth = int((X + Y) / 3)  # パスカルの三角形に当たるn
x, y = int((X + Y) * 2 / 3), (X + Y) / 3
pascal_k = x - X  # 端からいくつずれているか
if pascal_k > pascal_depth / 2:
    pascal_k = pascal_depth - pascal_k

def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    g1 = [1, 1]  # 元テーブル
    g2 = [1, 1]  # 逆元テーブル
    inverse = [0, 1]  # 逆元テーブル計算用テーブル
    for i in range(2, n + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)
    return g1[n] * g2[r] * g2[n - r] % mod

a = cmb(pascal_depth, pascal_k, MOD)
print(a)

-# # for k in range(int(pascal_k), 0, -1):

-# # フェルマーの少定理jを使ってみる

-# for i in range(1, int(pascal_depth) + 1):

-# # nk_fact = factorial(pascal_depth - pascal_k)

-# for i in range(1, int(pascal_depth - pascal_k) + 1):

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

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

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

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


Input:
while True:

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

    if [n, m] == [0, 0]:

        break

    hoge = list(range(1, n + 1))

    data = []

    for x in range(0, n - 2):

        for y in range(x + 1, n - 1):

            for z in range(y + 1, n):

                s = hoge[x] + hoge[y] + hoge[z]

                if s == m:

                    data.append(s)

    print((len(data)))

while True:

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

    if [n, m] == [0, 0]:

        break

    hoge = list(range(1, n + 1))

    data = []

    for x in range(n - 1, 1, -1):

        for y in range(x - 1, 0, -1):

            for z in range(y - 1, -1, -1):

                # print((x, y, z))

                s = hoge[x] + hoge[y] + hoge[z]

                if s < m:

                    break

                if s == m:

                    data.append(s)

    print((len(data)))

+            for z in range(y - 1, -1, -1):


Input:
# A - Dividing a String

def count_substrings(first_substring):

	arr = [first_substring]

	i = len(first_substring)

	while i < len(S):

		s = S[i]

		if s == arr[-1]:

			if i + 1 < len(S):

				i += 1

				s += S[i]

			else:

				arr[-1] += s

				break

		arr.append(s)

		i += 1

	return len(arr)

S = eval(input())

ans1 = count_substrings(S[:1])

ans2 = count_substrings(S[:2])

print((max(ans1, ans2)))

# A - Dividing a String

S = eval(input())

arr = [S[0]]

i = 1

while i < len(S):

	s = S[i]

	if s == arr[-1]:

		if i + 1 < len(S):

			i += 1

			s += S[i]

		else:

			arr[-1] += s

			break

	arr.append(s)

	i += 1

print((len(arr)))

-def count_substrings(first_substring):
-    arr = [first_substring]
-    i = len(first_substring)
-    while i < len(S):
-        s = S[i]
-        if s == arr[-1]:
-            if i + 1 < len(S):
-                i += 1
-                s += S[i]
-            else:
-                arr[-1] += s
-                break
-        arr.append(s)
-        i += 1
-    return len(arr)
-ans1 = count_substrings(S[:1])
-ans2 = count_substrings(S[:2])
-print((max(ans1, ans2)))
+arr = [S[0]]
+i = 1
+while i < len(S):
+    s = S[i]
+    if s == arr[-1]:
+        if i + 1 < len(S):
+            i += 1
+            s += S[i]
+        else:
+            arr[-1] += s
+            break
+    arr.append(s)
+    i += 1
+print((len(arr)))


Input:
import numpy as np

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

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

l = []

for i in range(N):

    l.append((1+p[i])/2)

a = [0] * N

a[0] = l[0]

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

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

ans = 0

for i in range(K,len(l)):

    ans = max(ans,a[i]-a[i-K])

if N - K == 0:

    print((max(a)))

else:

    print(ans)

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

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

l = []

for i in range(N):

    l.append(((1+p[i])*(p[i]/2))/p[i])

que = [0]*(N+1)

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

    que[i] = l[i-1]+que[i-1]

ans = 0

for i in range(K,len(l)):

    ans = max(ans,que[i+1]-que[i+1-K])

if N == K:

    print((max(que)))

else:

    print(ans)

import numpy as np

N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
l = []
for i in range(N):
    l.append((1 + p[i]) / 2)
a = [0] * N
a[0] = l[0]
for i in range(1, len(l)):
    a[i] = a[i - 1] + l[i]
ans = 0
for i in range(K, len(l)):
    ans = max(ans, a[i] - a[i - K])
if N - K == 0:
    print((max(a)))
else:
    print(ans)

N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
l = []
for i in range(N):
    l.append(((1 + p[i]) * (p[i] / 2)) / p[i])
que = [0] * (N + 1)
for i in range(1, N + 1):
    que[i] = l[i - 1] + que[i - 1]
ans = 0
for i in range(K, len(l)):
    ans = max(ans, que[i + 1] - que[i + 1 - K])
if N == K:
    print((max(que)))
else:
    print(ans)

+    ans = max(ans, que[i + 1] - que[i + 1 - K])


Input:
def main(n,a):

  a=sorted([a[i]-i for i in range(n)])

  m0=a[n//2]

  m1=a[n//2-1]

  ans0,ans1=0,0

  for i in range(n):

    ans0+=abs(a[i]-m0)

    ans1+=abs(a[i]-m1)

  print((min(ans0,ans1)))

if __name__=='__main__':

  import sys

  input = sys.stdin.readline

  n=int(eval(input()))

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

  main(n,a)

n=int(eval(input()))

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

a=[x-i-1 for i,x in enumerate(a)]

a.sort()

b=a[n//2]

print((sum([abs(x-b) for x in a])))

def main(n, a):
    a = sorted([a[i] - i for i in range(n)])
    m0 = a[n // 2]
    m1 = a[n // 2 - 1]
    ans0, ans1 = 0, 0
    for i in range(n):
        ans0 += abs(a[i] - m0)
        ans1 += abs(a[i] - m1)
    print((min(ans0, ans1)))

if __name__ == "__main__":
    import sys

    input = sys.stdin.readline
    n = int(eval(input()))
    a = list(map(int, input().split()))
    main(n, a)

n = int(eval(input()))
a = list(map(int, input().split()))
a = [x - i - 1 for i, x in enumerate(a)]
a.sort()
b = a[n // 2]
print((sum([abs(x - b) for x in a])))

-    a = sorted([a[i] - i for i in range(n)])

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

+a = [x - i - 1 for i, x in enumerate(a)]


Input:
#!/usr/bin/env python3

import sys

import heapq

def solve(N: int, M: int, A: "List[int]"):

    a = []

    for i in A:

        heapq.heappush(a, -i)

    for _ in range(M):

        m = heapq.heappop(a)

        heapq.heappush(a, -(-m // 2))

    sum = 0

    for i in a:

        sum += i

    print((-sum))

    return

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    M = int(next(tokens))  # type: int

    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"

    solve(N, M, A)

if __name__ == '__main__':

    main()

#!/usr/bin/env python3

import sys

import heapq

def main():

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

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

    a = []

    for i in A:

        heapq.heappush(a, -i)

    for _ in range(M):

        m = heapq.heappop(a)

        heapq.heappush(a, -(-m // 2))

    sum = 0

    for i in a:

        sum += i

    print((-sum))

    return

if __name__ == '__main__':

    main()

#!/usr/bin/env python3
import sys
import heapq

def solve(N: int, M: int, A: "List[int]"):
    a = []
    for i in A:
        heapq.heappush(a, -i)
    for _ in range(M):
        m = heapq.heappop(a)
        heapq.heappush(a, -(-m // 2))
    sum = 0
    for i in a:
        sum += i
    print((-sum))
    return

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == "__main__":
    main()

#!/usr/bin/env python3
import sys
import heapq

def main():
    N, M = list(map(int, input().split()))
    A = [int(i) for i in input().split()]
    a = []
    for i in A:
        heapq.heappush(a, -i)
    for _ in range(M):
        m = heapq.heappop(a)
        heapq.heappush(a, -(-m // 2))
    sum = 0
    for i in a:
        sum += i
    print((-sum))
    return

if __name__ == "__main__":
    main()

-def solve(N: int, M: int, A: "List[int]"):

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

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

-# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

-    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"


Input:
S = eval(input())

T = eval(input())

from collections import Counter

s_dict, t_dict = {}, {}

for i in range(len(S)):

    if S[i] in list(s_dict.keys()):

        if s_dict[S[i]] != T[i]:

            print("No")

            exit()

    else:

        s_dict[S[i]] = T[i]

    if T[i] in list(t_dict.keys()):

        if t_dict[T[i]] != S[i]:

            print("No")

            exit()

    else:

        t_dict[T[i]] = S[i]

print("Yes")

S = eval(input())

T = eval(input())

s_dict, t_dict = {}, {}

for i in range(len(S)):

    if S[i] in list(s_dict.keys()):

        if s_dict[S[i]] != T[i]:

            print("No")

            exit()

    else:

        s_dict[S[i]] = T[i]

    if T[i] in list(t_dict.keys()):

        if t_dict[T[i]] != S[i]:

            print("No")

            exit()

    else:

        t_dict[T[i]] = S[i]

print("Yes")


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

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

mod=10**9 +7

dp=[1]*(n+1)

dp[0]=1

dp[1]=1

for i in range(m):

    dp[a[i]] = 0

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

    if dp[i] > 0:

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

print((dp[n]%mod))

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

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

mod=10**9 +7

dp=[1]*(n+1)

dp[0]=1

dp[1]=1

for i in range(m):

    dp[a[i]] = 0

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

    if dp[i] > 0:

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

print((dp[n]))

n, m = list(map(int, input().split()))
a = [int(eval(input())) for i in range(m)]
mod = 10**9 + 7
dp = [1] * (n + 1)
dp[0] = 1
dp[1] = 1
for i in range(m):
    dp[a[i]] = 0
for i in range(2, n + 1):
    if dp[i] > 0:
        dp[i] = dp[i - 1] + dp[i - 2]
print((dp[n] % mod))

n, m = list(map(int, input().split()))
a = [int(eval(input())) for i in range(m)]
mod = 10**9 + 7
dp = [1] * (n + 1)
dp[0] = 1
dp[1] = 1
for i in range(m):
    dp[a[i]] = 0
for i in range(2, n + 1):
    if dp[i] > 0:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
print((dp[n]))


Input:
n = int(input())

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

print(' '.join(map(str,ls[::-1])))

n = int(input())

print(' '.join(input().split()[::-1]))

n = int(input())
ls = list(map(int, input().split()))
print(" ".join(map(str, ls[::-1])))

n = int(input())
print(" ".join(input().split()[::-1]))

-ls = list(map(int, input().split()))
-print(" ".join(map(str, ls[::-1])))
+print(" ".join(input().split()[::-1]))


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

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

l =[0] * (n+1)

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

    l[a[i]] +=1

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

    print((l[i]))

N = int(eval(input()))

l = [0] * (N+1)  # 0は利用しない

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

for a in A:

    l[a] +=1

for i in range(N):

    print((l[i+1]))

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

N = int(eval(input()))
l = [0] * (N + 1)  # 0は利用しない
A = list(map(int, input().split()))
for a in A:
    l[a] += 1
for i in range(N):
    print((l[i + 1]))

-n = int(eval(input()))
-a = list(map(int, input().split()))
-l = [0] * (n + 1)
-for i in range(0, n - 1):
-    l[a[i]] += 1
-for i in range(1, n + 1):
-    print((l[i]))
+N = int(eval(input()))
+l = [0] * (N + 1)  # 0は利用しない
+A = list(map(int, input().split()))
+for a in A:
+    l[a] += 1
+for i in range(N):
+    print((l[i + 1]))


Input:
import numpy as np

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

print((int(np.floor((3*A+P)/2))))

import math

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

print((int(math.floor((3*A+P)/2))))

import numpy as np

A, P = list(map(int, input().split()))
print((int(np.floor((3 * A + P) / 2))))

import math

A, P = list(map(int, input().split()))
print((int(math.floor((3 * A + P) / 2))))

-print((int(np.floor((3 * A + P) / 2))))

+print((int(math.floor((3 * A + P) / 2))))


Input:
# coding: utf-8

def solve(*args: str) -> str:

    n = int(args[0])

    T = [[None]*n for _ in range(n)]

    try:

        it = iter(args[1:])

        a = next(it)

        i = 1

        while a:

            for _ in range(int(a)):

                x, y = list(map(int, next(it).split()))

                T[i-1][x-1] = y == 1

            a = next(it)

            i += 1

    except StopIteration:

        pass

    ret = 0

    for hypo in range(2**n):

        consistent = True

        truth = [None]*n

        count = 0

        i = 0

        while consistent and i < n:

            if (hypo >> i) & 1:

                count += 1

                j = 0

                while consistent and j < n:

                    t = T[i][j]

                    if t is not None:

                        if truth[j] is None:

                            truth[j] = t

                        elif truth[j] != t:

                            consistent = False

                        consistent = (hypo >> j) & 1 == t

                    j += 1

            i += 1

        if consistent:

            ret = max(ret, count)

    return str(ret)

if __name__ == "__main__":

    print((solve(*(open(0).read().splitlines()))))

# coding: utf-8

def solve(*args: str) -> str:

    n = int(args[0])

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

    try:

        it = iter(args[1:])

        a = next(it)

        i = 0

        while a:

            for _ in range(int(a)):

                x, y = list(map(int, next(it).split()))

                XY[i].append((x-1, y == 1))

            a = next(it)

            i += 1

    except StopIteration:

        pass

    ret = 0

    for hypo in range(2**n):

        consistent = True

        truth = [None]*n

        count = 0

        i = 0

        while consistent and i < n:

            if (hypo >> i) & 1:

                count += 1

                for x, y in XY[i]:

                    if truth[x] is None:

                        truth[x] = y

                    elif truth[x] != y:

                        consistent = False

                    consistent &= (hypo >> x) & 1 == y

            i += 1

        if consistent:

            ret = max(ret, count)

    return str(ret)

if __name__ == "__main__":

    print((solve(*(open(0).read().splitlines()))))

# coding: utf-8
def solve(*args: str) -> str:
    n = int(args[0])
    T = [[None] * n for _ in range(n)]
    try:
        it = iter(args[1:])
        a = next(it)
        i = 1
        while a:
            for _ in range(int(a)):
                x, y = list(map(int, next(it).split()))
                T[i - 1][x - 1] = y == 1
            a = next(it)
            i += 1
    except StopIteration:
        pass
    ret = 0
    for hypo in range(2**n):
        consistent = True
        truth = [None] * n
        count = 0
        i = 0
        while consistent and i < n:
            if (hypo >> i) & 1:
                count += 1
                j = 0
                while consistent and j < n:
                    t = T[i][j]
                    if t is not None:
                        if truth[j] is None:
                            truth[j] = t
                        elif truth[j] != t:
                            consistent = False
                        consistent = (hypo >> j) & 1 == t
                    j += 1
            i += 1
        if consistent:
            ret = max(ret, count)
    return str(ret)

if __name__ == "__main__":
    print((solve(*(open(0).read().splitlines()))))

# coding: utf-8
def solve(*args: str) -> str:
    n = int(args[0])
    XY = [[] for _ in range(n)]
    try:
        it = iter(args[1:])
        a = next(it)
        i = 0
        while a:
            for _ in range(int(a)):
                x, y = list(map(int, next(it).split()))
                XY[i].append((x - 1, y == 1))
            a = next(it)
            i += 1
    except StopIteration:
        pass
    ret = 0
    for hypo in range(2**n):
        consistent = True
        truth = [None] * n
        count = 0
        i = 0
        while consistent and i < n:
            if (hypo >> i) & 1:
                count += 1
                for x, y in XY[i]:
                    if truth[x] is None:
                        truth[x] = y
                    elif truth[x] != y:
                        consistent = False
                    consistent &= (hypo >> x) & 1 == y
            i += 1
        if consistent:
            ret = max(ret, count)
    return str(ret)

if __name__ == "__main__":
    print((solve(*(open(0).read().splitlines()))))

-                while consistent and j < n:

-                        if truth[j] is None:

-                            truth[j] = t

-                        elif truth[j] != t:

-                            consistent = False

-                        consistent = (hypo >> j) & 1 == t

+                    if truth[x] is None:

+                    elif truth[x] != y:

+                        consistent = False

+                    consistent &= (hypo >> x) & 1 == y


Input:
# coding:utf-8

import sys

INF = float('inf')

MOD = 10 ** 9 + 7

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

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

def LF(): return [float(x) for x in sys.stdin.readline().split()]

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

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

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

def main():

    n = II()

    P = LF()

    # dp[i]: i枚のコインが表になる確率

    dp = [1]

    # 調和級数

    # O(NlogN)

    for i in range(n):

        tmp = [0] * (i + 2)

        p = P[i]

        q = 1 - P[i]

        for j in range(i + 1):

            tmp[j] += dp[j] * q

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

        dp = tmp

    return sum(dp[n // 2 + 1:])

print((main()))

# coding:utf-8

import sys

import numpy as np

INF = float('inf')

MOD = 10 ** 9 + 7

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

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

def LF(): return [float(x) for x in sys.stdin.readline().split()]

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

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

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

def main():

    n = II()

    P = LF()

    dp = np.zeros(n + 1, dtype=float)

    dp[0] = 1

    for p in P:

        tmp = dp * (1 - p)

        tmp[1:] += dp[:-1] * p

        dp = tmp

    return np.sum(dp[n // 2 + 1:])

print((main()))

# coding:utf-8
import sys

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

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

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

def LF():
    return [float(x) for x in sys.stdin.readline().split()]

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

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

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

def main():
    n = II()
    P = LF()
    # dp[i]: i枚のコインが表になる確率
    dp = [1]
    # 調和級数
    # O(NlogN)
    for i in range(n):
        tmp = [0] * (i + 2)
        p = P[i]
        q = 1 - P[i]
        for j in range(i + 1):
            tmp[j] += dp[j] * q
            tmp[j + 1] += dp[j] * p
        dp = tmp
    return sum(dp[n // 2 + 1 :])

print((main()))

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

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

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

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

def LF():
    return [float(x) for x in sys.stdin.readline().split()]

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

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

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

def main():
    n = II()
    P = LF()
    dp = np.zeros(n + 1, dtype=float)
    dp[0] = 1
    for p in P:
        tmp = dp * (1 - p)
        tmp[1:] += dp[:-1] * p
        dp = tmp
    return np.sum(dp[n // 2 + 1 :])

print((main()))

+import numpy as np
-    # dp[i]: i枚のコインが表になる確率
-    dp = [1]
-    # 調和級数
-    # O(NlogN)
-    for i in range(n):
-        tmp = [0] * (i + 2)
-        p = P[i]
-        q = 1 - P[i]
-        for j in range(i + 1):
-            tmp[j] += dp[j] * q
-            tmp[j + 1] += dp[j] * p
+    dp = np.zeros(n + 1, dtype=float)
+    dp[0] = 1
+    for p in P:
+        tmp = dp * (1 - p)
+        tmp[1:] += dp[:-1] * p
-    return sum(dp[n // 2 + 1 :])
+    return np.sum(dp[n // 2 + 1 :])