Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
import heapq
n,x,y = map(int,input().split())
G = [[]*n for i in range(n)]
for i in range(n-1):
  G[i].append((i+1,1))
  G[i+1].append((i,1))
x-=1;y-=1
G[x].append((y,1))
G[y].append((x,1))
# print(G)
def disktra(g,s):
    n=len(g)
    dist = [inf]*n
    dist[s] = 0
    hq=[]
    heapq.heappush(hq,(dist[s],s))
    while hq:
        cost,u =heapq.heappop(hq)
        if dist[u] < cost:
            continue
        for v,c in g[u]:
            if dist[v] <= dist[u] +c:
                continue
            dist[v] = dist[u] + c
            heapq.heappush(hq,(dist[v],v))
    return dist
sets = [set() for i in range(n)]
for i in range(n-1):
  dist = disktra(G,i)
  for j in range(n):
    sets[dist[j]].add((min(i,j),max(i,j)))
for i in range(1,n):
  print(len(sets[i]))
    


### FIXED CODE ###

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
import heapq
n,x,y = map(int,input().split())
G = [[]*n for i in range(n)]
for i in range(n-1):
  G[i].append((i+1))
  G[i+1].append(i)
x-=1;y-=1
G[x].append((y))
G[y].append((x))
# print(G)
def bfs(g,s):
    n=len(g)
    dist = [inf]*n
    dist[s] = 0
    q = collections.deque()
    q.append(s)
    while q:
        u = q.popleft()
        for v in g[u]:
            if dist[v] != inf:continue
            dist[v] = dist[u] + 1
            q.append(v)
    return dist
D = [0]*n
for i in range(n-1):
  dist = bfs(G,i)
  for j in range(i+1,n):
    D[dist[j]] += 1
for i in range(1,n):
  print(D[i])
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = []
for i in range(n):
  ans.append(a.index(i+1)+1)
print(*ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = [0 for i in range(n)]
for i,vol in enumerate(a):
  ans[vol-1]=i+1
print(*ans)
### BUGGY CODE ###

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

if any(a>b for a,b in zip(A,B)):
    print(-1)
    exit()

hq = [(-a,i) for i,a in enumerate(B)]
heapq.heapify(hq)

ans = 0
while hq:
    _,i = heapq.heappop(hq)
    if B[i] == A[i]: continue
    l = B[(i-1)%N]
    r = B[(i+1)%N]
    if B[i]-l-r < A[i]: continue
    k = (B[i]-A[i]) // (l+r)
    ans += k
    B[i] -= k*(l+r)
    heapq.heappush(hq, (-B[i],i))

if all(a==b for a,b in zip(A,B)):
    print(ans)
else:
    print(-1)

### FIXED CODE ###

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

if any(a>b for a,b in zip(A,B)):
    print(-1)
    exit()

def pb(i):
    return i-1 if i-1 >= 0 else N-1
def nx(i):
    return i+1 if i+1 < N else 0

hq = []
for i,(a,b) in enumerate(zip(A,B)):
    if a <= b - B[pb(i)] - B[nx(i)]:
        hq.append((-b,i))
heapq.heapify(hq)

ans = 0
while hq:
    _,i = heapq.heappop(hq)
    if B[i] == A[i]: continue
    l = B[pb(i)]
    r = B[nx(i)]
    if B[i]-l-r < A[i]: continue
    k = (B[i]-A[i]) // (l+r)
    ans += k
    B[i] -= k*(l+r)
    ll = B[pb(pb(i))]
    rr = B[nx(nx(i))]
    if A[nx(i)] <= r - B[i] - rr:
        heapq.heappush(hq, (-r,nx(i)))
    if A[pb(i)] <= l - B[i] - ll:
        heapq.heappush(hq, (-l,pb(i)))

if all(a==b for a,b in zip(A,B)):
    print(ans)
else:
    print(-1)
### BUGGY CODE ###

N = int(input().rstrip())
a = []
for n in range(N):
    a.append(int(input().rstrip()))

if all([num != 2 for num in a]):
    print(-1)
    exit()

button = [1]
for _ in range(N):
    button.append(a[button[-1] - 1])
    current = button[-1]
    if current == 2:
        print(len(button) - 1)
        exit()
    if any([b == current for b in button[:-1]]):
        break

print(-1)

### FIXED CODE ###

N = int(input().rstrip())
a = []
for n in range(N):
    a.append(int(input().rstrip()))

button = [1]
for _ in range(N-1):
    button.append(a[button[-1] - 1])
    if button[-1] == 2:
        print(len(button) - 1)
        exit()
    if button[-1] == button[-2]:
        break
    
print(-1)
### BUGGY CODE ###

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

ans = "IMPOSSIBLE"
list1 = []
listN = []

for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        list1.append(b)
    elif b == N:
        listN.append(a)

for i in range(1, N+1):
    if i in list1 and i in listN:
        ans = "POSSIBLE"
        break

print(ans)

### FIXED CODE ###

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

ans = "IMPOSSIBLE"
list1 = [0] * N
listN = [0] * N

for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        list1[b] = 1
    elif b == N :
        listN[a] = 1

for i in range(N):
    if list1[i] == 1 and listN[i] == 1:
        ans = "POSSIBLE"
        break

print(ans)
### BUGGY CODE ###

import sys

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

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

t = 1

for i in range(n):
    t = t * a[i]

if t > 10**18:
    print("-1")
else:
    print(t)


### FIXED CODE ###

import sys

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

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

t = 1

for i in range(n):
    if a[i] == 0:
        print("0")
        exit()

for i in range(n):
    t = t * a[i]
    if t > 10**18:
        print("-1")
        exit()

print(t)
### BUGGY CODE ###

n, m = map(int, input().split(" "))
path = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split(" "))
    path[u-1].append(v)

s, g = map(int, input().split(" "))

def indicate3(start,path):
    for _ in range(3):
        next = []
        for position in start:
            for next_position in path[position-1]:
                next.append(next_position)
        start = next
    return start

stack = [s]
count = 0
while True:
    n_stack = indicate3(stack,path)
    if g in n_stack:
        count += 1
        print(count)
        break
    else:
        if n_stack == stack:
            print(-1)
            break
        else:
            count += 1
    stack = n_stack


### FIXED CODE ###

n, m = map(int, input().split(" "))
path = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split(" "))
    path[u-1].append(v)

s, g = map(int, input().split(" "))
ifReached = [False for _ in range(n)]

def indicate3(start,path):
    for _ in range(3):
        next = []
        for position in start:
            for next_position in path[position-1]:
                next.append(next_position)
        start = list(set(next))
    return start

stack = [s]
ifReached[s-1] = True
count = 0
while True:
    n_stack = list(set(indicate3(stack,path)))

    tmp_stack = []
    for position in n_stack:
        if ifReached[position-1] == False:
            tmp_stack.append(position)
            ifReached[position-1] = True

    if len(tmp_stack) == 0:
        print(-1)
        break

    count += 1
    if g in tmp_stack:
        print(count)
        break
    stack = tmp_stack
### BUGGY CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

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

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

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

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

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

N, M = map(int,input().split()) 
uf = UnionFind(N)
for _ in range(M):
  a, b = map(int,input().split())
  uf.union(a-1,b-1)

ans = 0
for i in list(uf.all_group_members().values()):
  ans = max(len(i),ans)
print(ans)


### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

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

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

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

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

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

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

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

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

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
  
N, M = map(int,input().split()) 
uf = UnionFind(N)
for _ in range(M):
  a, b = map(int,input().split())
  uf.union(a-1,b-1)

ans = 0
for i in range(N):
  ans=max(ans, uf.size(i))
print(ans)
### BUGGY CODE ###

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

from itertools import combinations_with_replacement

cwr = combinations_with_replacement(range(0, k + 1), 3)
ans = 0

for x, y, z in cwr:
    if x + y + z == s:
        st = set([x, y, z])
        if len(st) == 1:
            ans += 1
        elif len(st) == 2:
            ans += 3
        else: #len(st) == 3
            ans += 6

print(ans)


### FIXED CODE ###

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

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if 0 <= z <= k:
            ans += 1

print(ans)
### BUGGY CODE ###

import bisect

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

st = set(As)

Fs = [0]*N

As.sort()
if N == 1:
  print(1)
  exit()
else:
  rlt = 1
  
for i in range(1,N):
  if As[i] == As[i-1]:
    Fs[i] = 1
    if Fs[i-1] == 0:
      rlt -= 1
    continue
  for j in range(i):
    flag = 0
    if Fs[j] == 1:
      continue
    else:
      if As[i] < 2*As[j]:
        break
      if As[i]%As[j] == 0:
        Fs[i] = 1
        flag = 1
        break
  if flag == 0:
    rlt += 1
        
print(rlt)

### FIXED CODE ###

N = int(input())
As = list(map(int, input().split()))
 
As.sort()
 
st = set(As)
m = As[-1]
rlt = 0
Fs = [1]*(m+1)
 
for i in range(N):
  if i > 0 and As[i] == As[i-1]:
    Fs[As[i]] = 0
    continue
  j = 2
  while As[i]*j <= m:
    Fs[As[i]*j] = 0
    j += 1

for a in As:
  rlt += Fs[a]
    
print(rlt)
### BUGGY CODE ###

class BIT:
    '''
    0-indexed
    '''
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.depth = n.bit_length()

    def _bitsum(self, i):
        ret = 0
        while i:
            ret += self.tree[i]
            i ^= i & -i
        return ret

    def bitsum(self, l, r=None): # [l, r)
        if r is None:
            return self._bitsum(l)
        else:
            return self._bitsum(r) - self._bitsum(l)

    def bitadd(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        return

n = int(input())
m = (n * (n - 1) // 2) // 2 + 1
a = list(map(int, input().split()))
d = dict()
_a = sorted(set(a))
for i, x in enumerate(_a):
  d[x] = i
a = [d[x] for x in a]


def check(X):
  b = [0] + [(y>=X)*2 - 1 for y in a]
  for i in range(n):
    b[i+1] += b[i]
  c = min(b)
  b = [x-c for x in b] 
  bit = BIT(n + 10)
  ans = 0
  for x in b:
    ans += bit.bitsum(x+1)
    bit.bitadd(x, 1)
  return ans >= m

t = [len(_a) + 1, -1]
while t[0] - t[1] > 1:
  mid = (t[0] + t[1]) // 2
  t[check(mid)] = mid
print(_a[t[1]])


### FIXED CODE ###

class BIT:
    '''
    0-indexed
    '''
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.depth = n.bit_length()

    def _bitsum(self, i):
        ret = 0
        while i:
            ret += self.tree[i]
            i ^= i & -i
        return ret

    def bitsum(self, l, r=None): # [l, r)
        if r is None:
            return self._bitsum(l)
        else:
            return self._bitsum(r) - self._bitsum(l)

    def bitadd(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        return

n = int(input())
m = n * (n + 1) // 4
a = list(map(int, input().split()))
d = dict()
_a = sorted(set(a + [0]))
for i, x in enumerate(_a):
  d[x] = i
a = [d[x] for x in a]


def check(X):
  b = [0] + [(y>=X)*2 - 1 for y in a]
  for i in range(n):
    b[i+1] += b[i]
  c = min(b)
  b = [x-c for x in b] 
  bit = BIT(max(b) + 2)
  ans = 0
  for x in b:
    ans += bit.bitsum(x + 1)
    bit.bitadd(x, 1)
  return ans >= m

t = [len(_a), 0]
while t[0] - t[1] > 1:
  mid = (t[0] + t[1]) // 2
  t[check(mid)] = mid
print(_a[t[1]])
### BUGGY CODE ###

MOD = 10 ** 9 + 7
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))


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

for i in range(1, N + 1):
    for j in range(1, M + 1):
        if S[i - 1] == T[j - 1]:
            dp[i][j] = sm[i - 1][j - 1] + 1
        else:
            dp[i][j] = 0
        sm[i][j] = (sm[i - 1][j] + sm[i][j - 1] - sm[i - 1][j - 1] + dp[i][j]) % MOD

print(sum([sum(x) % MOD for x in dp]) % MOD)


### FIXED CODE ###

MOD = 10 ** 9 + 7
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))


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

for i in range(1, N + 1):
    for j in range(1, M + 1):
        if S[i - 1] == T[j - 1]:
            dp[i][j] = (sm[i - 1][j - 1] + 1) % MOD
        else:
            dp[i][j] = 0
        sm[i][j] = (sm[i - 1][j] + sm[i][j - 1] - sm[i - 1][j - 1] + dp[i][j]) % MOD

print(sm[N][M] + 1)
### BUGGY CODE ###

s = input()
q = int(input())
back = 1
for i in range(q):
    query = input().split()
    if query[0] == '1':
        back *= -1
    else:
        if query[1] == '1':
            if back == 1:
                s = query[2] + s
            else:
                s = s + query[2]
        else:
            if back == 1:
                s = s + query[2]
            else:
                s = query[2] + s
if back == -1:
    s = s[-1::-1]
print(s)

### FIXED CODE ###

import collections
s = input()
q = int(input())
back = 1
t = collections.deque()
for ss in s:
    t.append(ss)
for i in range(q):
    query = input().split()
    if query[0] == '1':
        back *= -1
    else:
        if query[1] == '1':
            if back == 1:
                t.appendleft(query[2])
            else:
                t.append(query[2])
        else:
            if back == 1:
                t.append(query[2])
            else:
                t.appendleft(query[2])
ans = ''
if back == -1:
    for i in range(len(t)):
        ans += t.pop()
else:
    for i in range(len(t)):
        ans += t.popleft()
print(ans)
### BUGGY CODE ###

N = int(input())
a = [int(c) for c in input().split()]
#ループしてX候補を求める
ma = 0
tmp = 0
for i in range(N):
    tmp = a.count(a[i]-1)+a.count(a[i])+a.count(a[i]+1)
    if ma < tmp:
        ma = tmp
print(ma)

### FIXED CODE ###

N = int(input())
a = sorted([int(c) for c in input().split()])
#2回の変わり目を記憶
c1,c2,c3 = [0,0,0]
ma = 1
for i in range(N):
    if i > 0:
        if a[i]==a[i-1]+1:
            c1 = c2 
            c2 = c3
            c3 = i
        elif a[i]!=a[i-1]:
            c1,c2,c3=[i,i,i]
    if ma < i - c1+1:
        ma = i - c1+1

print(ma)
### BUGGY CODE ###

from collections import *
n=int(input())
a=list(map(int,input().split()))
#a.sort()
b=sorted(set(a))[::-1]
wid=0
hei=0
for i in b:
  c=a.count(i)
  if(c>3):
    if(hei==0):
      hei,wid=i,i
    elif(wid==0):
      wid=i
    break
  elif(c>1):
    if(hei==0):hei=i
    elif(wid==0):
      wid=i
      break
print(wid*hei)

### FIXED CODE ###

from collections import *
n=int(input())
a=list(map(int,input().split()))
b=sorted(set(a))[::-1]
d=defaultdict(int)
wid=0
hei=0
for i in a:
  d[i]+=1
for i in b:
  if(d[i]>3):
    if(wid==0):wid,hei=i,i
    else:hei=i
    break
  elif(d[i]>1):
    if(wid==0):wid=i
    else:
      hei=i
      break
print(wid*hei)
### BUGGY CODE ###

N=int(input())
G=[[] for _ in range(N)]
for i in range(N-1):
    a,b,c=map(int,input().split())
    G[a-1].append([b-1,c])
    G[b-1].append([a-1,c])

Q,K=map(int,input().split())

SD=[0]*N

for i in range(N):
    if i==K-1:continue
    ans=[]
    seen=[0]*N
    stack=[[i,0]]
    seen[i]=1
    while stack:
        x,d=stack.pop()
        if x==K-1:
            ans.append(d)
        elif SD[x]!=0:
            ans.append(d+SD[x])
        else:
            for y,co in G[x]:
                if seen[y]==0:
                    stack.append([y,d+co])
                    seen[y]=1
    SD[i]=min(ans)


for i in range(Q):
    x,y=map(int,input().split())
    ans=SD[x-1]+SD[y-1]
    print(ans)



### FIXED CODE ###

N=int(input())
G=[[] for _ in range(N)]
for i in range(N-1):
    a,b,c=map(int,input().split())
    G[a-1].append([b-1,c])
    G[b-1].append([a-1,c])

Q,K=map(int,input().split())

SD=[0]*N
seen=[0]*N
stack=[]
stack.append([K-1,0])
seen[K-1]=1
while stack:
    x,d=stack.pop()
    for y,d0 in G[x]:
        if seen[y]==0:
            SD[y]=d+d0
            stack.append([y,d+d0])
            seen[y]=1
for i in range(Q):
    x,y=map(int,input().split())
    ans=SD[x-1]+SD[y-1]
    print(ans)
### BUGGY CODE ###

n, q = list(map(int, input().split(" ")))
s = input()
s = s.replace("AC", "ZC")
ac_index = [s[:i].count("Z") for i in range(len(s))]
num = 0
for _s in s:
    if _s == "Z":
        num += 1
    ac_index.append(num)

i = 0

for _ in range(q):
    l, r = list(map(int, input().split(" ")))
    print(ac_index[r-1] - ac_index[l-1])


### FIXED CODE ###

n, q = list(map(int, input().split(" ")))
s = input()
s = s.replace("AC", "ZC")
num = 0
ac_index = []
for _s in s:
    if _s == "Z":
        ac_index.append(num)
        num += 1
    else:
        ac_index.append(num)
i = 0

for _ in range(q):
    l, r = list(map(int, input().split(" ")))
    print(ac_index[r-1] - ac_index[l-1])
### BUGGY CODE ###

# 2125
# 方針．f(n)を求めるのがlog(N)で終わりそうだから普通に素直に実装すればいいのでは？
N = int(input())
X = list(input())

import math
# 最初にpopcount用のリストを作成する，そもそも2**(10**5)だから圧倒的に範囲が足らなかった
L = [0 for i in range(int(math.log(N,2))+10)]
for i in range(int(math.log(N,2))+10):
    bi = list(str(bin(i)))
    bi = bi[1:]
    L[i] = bi.count('1')

# i番目のビットを反転させて,
dic={}
x0 = int(''.join(X),2)
for i in range(N):
    # ちゃんともとに戻してね，ということで本のビット
    b = int(X[i]) & 1
    bn = b ^ 1
    xi = x0 - b * pow(2,N-1-i) + bn * pow(2,N-1-i)
    num = xi
    count = 0
    while num > 0:
        bi = list(str(bin(num)))
        bi = bi[2:]
        st = ''.join(bi)
        if st in dic:
            bic = dic[st]
        else:
            bic = bi.count('1')
            dic[st] = bic
        num = num % bic
        count += 1
    print(count)


### FIXED CODE ###

# 2125
# 方針．f(n)を求めるのがlog(N)で終わりそうだから普通に素直に実装すればいいのでは？
# ただし最初だけは別に実装する必要がある
N = int(input())
X = list(input())

# i番目のビットを反転させて,
# やってることは似てるはずなのになんかうまく行かない
dic={}
bn00 = X.count('1')
x00 = int(''.join(X),2)
aa = x00 % (bn00+1)
if bn00-1==0:
    bb = 0
else:
    bb = x00 % (bn00-1)
for i in range(N):
    # ちゃんともとに戻してね，ということで本のビット
    b = int(X[i]) & 1
    bn = b ^ 1
    if bn:
        bn0 = bn00 + 1
        x0 = aa
    else:
        bn0 = bn00 - 1
        x0 = bb
    if bn0==0: # ビットが全く立っていないつまり0の時，0%0はエラーを起こすので，n%0もエラーを起こす
        print(0)
        continue
    if b: # もとのビットが立っている場合は減らす，ここの計算量が一番重いので計算量を削減してみる
        xi = x0 - b * pow(2,N-1-i,bn0)
    if bn:
        xi = x0 + bn * pow(2, N - 1 - i, bn0)
    xi %= bn0
    num = xi
    count = 1
    while num > 0:
        p = format(num,'b').count('1') # 10進数を２進数にかえるなら，これがいいのかも,int(str(i),2)を使うっていう手もあるけど周りくどい
        num = num % p
        count += 1
    print(count)
### BUGGY CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(min(K,50)):
        dm = [0]*N
        for x in range(N):
            dm[max(x - A[x],0)]+=1
            if x+A[x]+1<N:
                dm[x+A[x]+1]+=-1
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(min(K,50)):
        dm = [0]*N
        for x in range(N):
            dm[max(x - A[x],0)]+=1
            if x+A[x]+1<N:
                dm[x+A[x]+1]+=-1
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
res = "YES"
for i in range(n):
  if a.count(a[i])>=2:
    res="NO"
    break
print(res)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b) else "NO")
### BUGGY CODE ###

import copy

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

jumpIndex = -1

for i in range(N):
    if i < jumpIndex:
        A.remove(A[i])
        print(tmpMax)
        continue
    tmp = copy.copy(A)
    tmp.remove(A[i])
    tmpMax = max(tmp)
    for j in range(i + 1, N):
        if A[i] == tmpMax:
            jumpIndex = i
    print(tmpMax)

### FIXED CODE ###

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

maxNum = max(A)
index = -1
for i in range(N):
    if A[i] == maxNum:
        index = i

for i in range(N):
    if i != index:
        print(maxNum)
        continue
    else:
        A.remove(maxNum)
        print(max(A))
### BUGGY CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)

if N == 1:
    print(A[0]//(2**M))
else:
    for i in range(M):
        A[0] = A[0]//2
        j = 0
        while(A[j]<A[j+1]):
            t = A[j]
            A[j] = A[j+1]
            A[j+1] = t
            j += 1
            if j == N-1:
                break
    print(sum(A))

### FIXED CODE ###

import sys

N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
m = A[0]
seg = [1]

t = 1
while(True):
    t *= 2
    if t > m:
        break
    seg.append(t)

c = 0
for i in range(-1,-len(seg)-1,-1):
    for j in range(N):
        if A[j] < seg[i]:
            break
        A[j] = A[j]//2
        c += 1
        if c == M:
            print(sum(A))
            sys.exit()
    A.sort(reverse=True)

print(sum(A))
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
x=1
f=0
for a in A:
    x*=a
    if x>10**18:
        f=1
print(0 if 0 in A else -1 if f else x)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
x=1
f=0
for a in A:
    x*=a
    if x>10**18:
        f=1
        break
print(0 if 0 in A else -1 if f else x)