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

from sys import stdin
from heapq import heappush, heappop


class Dijkstra:
    def __init__(self, num_nodes):
        self.n = num_nodes
        # 隣接行列 d[u][v]: uからvへのコスト
        self.adj_matrix = [[float("inf")]*self.n for i in range(self.n)]

    # Edge数分回すことを想定
    def add_edge(self, start, end, weight=1, undirected=False):
        self.adj_matrix[start][end] = weight
        if undirected:
            self.adj_matrix[end][start] = weight

    def distance(self, start):
        # 始点から各頂点までの最短距離を格納する
        self.dist = [float('inf') for _ in range(self.n)]
        # 最短経路における, その頂点の前の頂点のIDを格納する
        self.prev = [float('inf') for _ in range(self.n)]
        self.dist[start] = 0
        # 各要素は，(頂点vのID, startからある頂点vまでの仮の距離)からなるタプル
        q = []
        heappush(q, (start, 0))
        while len(q) != 0:
            src, prov_cost  = heappop(q)
            # プライオリティキューに格納されている最短距離が, 現在計算できている最短距離より大きければ，distの更新をする必要はない
            if self.dist[src] < prov_cost:
                continue
            # 他の頂点の探索
            for dest in range(self.n):
                cost = self.adj_matrix[src][dest]
                if cost != float('inf') and self.dist[dest] > self.dist[src] + cost:
                    self.dist[dest] = self.dist[src] + cost # distの更新
                    heappush(q, (dest, self.dist[dest])) # キューに新たな仮の距離の情報をpush
                    self.prev[dest] = src
        return self.dist

    def shortest_path(self, goal):
        path = [goal]
        dest = goal
        # 終点から最短経路を逆順に辿る
        while self.prev[dest] != float('inf'):
            path.append(self.prev[dest])
            dest = self.prev[dest]
        return path[::-1]


# BFS pypyでAC
def get_result(data):
    N, X, Y = data
    _data = [[i, i+1] for i in range(1, N)]
    _data += [[X, Y]]
    solver = Dijkstra(N)
    for val in _data:
        solver.add_edge(val[0]-1, val[1]-1, undirected=True)
    dist_cnt = [0 for i in range(N)]
    for i in range(N):
        dist = solver.distance(i)
        for j in range(i, N):
            dist_cnt[dist[j]] += 1
    for i in range(1, N):
        print(dist_cnt[i])


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    get_result(data)


### FIXED CODE ###

from sys import stdin


def get_result(data):
    N, X, Y = data
    dist_cnt = [0 for i in range(N)]
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            min_dist = min([j-i, abs(X-i) + 1 + abs(Y-j), abs(Y-i) + 1 + abs(X-j)])
            dist_cnt[min_dist] += 1
    for i in range(1, N):
        print(dist_cnt[i])


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    get_result(data)
### BUGGY CODE ###

def main():
    n, q = map(int, input().split())
    s = input()
    
    t = [0] * n
    pre = s[0]
    for i in range(1, n):
        if pre == 'A' and s[i] == 'C':
            t[i] = 1
        pre = s[i]
    for _ in range(q):
        l, r = map(int, input().split())
        print(sum(t[l:r]))
        
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, q = map(int, input().split())
    s = input()
    
    t = [0] * n
    pre = s[0]
    t_sum = 0
    for i in range(1, n):
        if pre == 'A' and s[i] == 'C':
            t[i] = t_sum + 1
            t_sum +=  1
        else: 
            t[i] = t_sum
        pre = s[i]
    for _ in range(q):
        l, r = map(int, input().split())
        print(t[r - 1] - t[l - 1])
        
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

N,P=[int(s) for s in input().split()]
DP=[[0 for _ in range(i+1)] for i in range(N)]
ls=[int(s)%P for s in list(input())]

count=[[0 for _ in range(P)] for _ in range(N)]


for j in range(N):
  count[j][ls[j]]+=1

for i in range(1,N):
  a=ls[i]
  for k in range(P):
    count[i][(10*k+a)%P]+=count[i-1][k]
  
ans=0
for j in range(N):
  ans+=count[j][0]
print(ans)

### FIXED CODE ###

N,P=[int(s) for s in input().split()]
S=list(input())
if P!=2 and P!=5:
  ls=[0 for _ in range(N)]
  mod=[0 for _ in range(P)]
  d=10
  ls[0]=int(S[-1])%P
  mod[ls[0]]+=1
  for i in range(1,N):
    ls[i]=(ls[i-1]+d*int(S[-1-i]))%P
    d=(d*10)%P
    mod[ls[i]]+=1
  #print(ls)
  #print(mod)  
  ans=mod[0]
  for i in range(N):
    m=ls[i]
    mod[ls[i]]-=1
    ans+=mod[ls[i]]
else:
  ans=0
  for i in range(N):
    if int(S[i])%P==0:
      ans+=i+1
print(ans)
### BUGGY CODE ###

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

A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

import itertools
val_list = []

a_max = min(len(A_list), K)
b_max = min(len(B_list), K)
c_max = min(len(C_list), K)

A_list = sorted(A_list, reverse=True)
B_list = sorted(B_list, reverse=True)
C_list = sorted(C_list, reverse=True)
for a, b, c in itertools.product(A_list[:a_max], B_list[:b_max], C_list[:c_max]):
    val_list.append(a + b + c)
    
val_list = sorted(val_list, reverse=True)
for i in range(K):
    print(val_list[i])
    


            


### FIXED CODE ###

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

A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

val_list = []


A_list = sorted(A_list, reverse=True)
B_list = sorted(B_list, reverse=True)
C_list = sorted(C_list, reverse=True)

#print(A_list)
#print(B_list)
#print(C_list)

for a in range(len(A_list)):
    if a + 1 > K:
        break
    for b in range(len(B_list)):
        if b + 1 > K:
            break
        if (a+1) * (b+1) > K:
            break
            
        for c in range(len(C_list)):
            if c + 1 > K:
                break
            if (a+1) * (b+1) * (c+1) > K:
                break
        
            val_list.append(A_list[a] + B_list[b] + C_list[c])

val_list = sorted(val_list, reverse=True)
for i in range(K):
    print(val_list[i])
### BUGGY CODE ###

n, q = map(int,input().split())
ikeru = [[] for _ in range(n)]
for i in range(n-1):
	a, b = map(int, input().split())
	ikeru[a-1].append(b-1)
	ikeru[b-1].append(a-1)

fukasa = [0 for _ in range(n)]
fukasamoto = [set([]) for _ in range(n)]
fukasamoto[0].add(0)
kaisuu = 0
settansaku = set([])
setmada = {0}
kouho = 1

while kouho != 0:
	kaisuu += 1
	for i in list(setmada):
		settansaku.add(i)
		setmada.remove(i)
		kouho -= 1
		for k in ikeru[i]:
			if not k in setmada:
				if not k in settansaku:
					setmada.add(k)
					kouho += 1
					fukasa[k] = kaisuu
					fukasamoto[k] = fukasamoto[i] | {i, k}

kasan = [0 for _ in range(n)]
for i in range(q):
	p, x = map(int,input().split())
	kasan[p-1] += x

ansl = [0 for _ in range(n)]
for i in range(n):
	tmpans = 0
	for j in fukasamoto[i]:
		tmpans += kasan[j]
	ansl[i] = tmpans

print(" ".join([str(ansl[i]) for i in range(n)]))

### FIXED CODE ###

n, q = map(int,input().split())
ikeru = [[] for _ in range(n)]
for i in range(n-1):
	a, b = map(int, input().split())
	ikeru[a-1].append(b-1)
	ikeru[b-1].append(a-1)

kasan = [0 for _ in range(n)]
for i in range(q):
	p, x = map(int,input().split())
	kasan[p-1] += x

ansl = [0 for _ in range(n)]
ansl[0] = kasan[0]
kaisuu = 0
settansaku = set([])
setmada = {0}
kouho = 1

while kouho != 0:
	kaisuu += 1
	for i in list(setmada):
		settansaku.add(i)
		setmada.remove(i)
		kouho -= 1
		for k in ikeru[i]:
			if not k in setmada:
				if not k in settansaku:
					setmada.add(k)
					kouho += 1
					ansl[k] = ansl[i] + kasan[k]

print(" ".join([str(ansl[i]) for i in range(n)]))
### BUGGY CODE ###

s = input()

import re
#re.findall('01', s)
ans = 0
while '01' in s or '10' in s:
    ans += len(re.findall('01', s))
    s = re.sub('01', '', s)
    ans += len(re.findall('10', s))
    s = re.sub('10', '', s)

print(ans * 2)

### FIXED CODE ###

s = input()
s_list = list(s)

print(min(s_list.count('1'), s_list.count('0')) * 2)
### BUGGY CODE ###

import sys

class DoublyLinkedList:
    def __init__(self, value = -1):
        self.value = value
        self.prev = self
        self.next = self

    def insert(self, value):
        newNode = DoublyLinkedList(value)
        newNode.next = self.next
        newNode.prev = self
        self.next.prev = newNode
        self.next = newNode

    def delete(self, value):
        node = self.next
        while node.value != -1:
            if node.value == value:
                node.next.prev = node.prev
                node.prev.next = node.next
                break
            node = node.next

    def deleteFirst(self):
        if self.next.value != -1:
            self.next = self.next.next
            self.next.prev = self

    def deleteLast(self):
        if self.prev.value != -1:
            self.prev = self.prev.prev
            self.prev.next = self

    def printAll(self):
        node = self.next
        while node.next.value != -1:
            print node.value,
            node = node.next
        print node.value

if __name__ == "__main__":
    dll = DoublyLinkedList()
    N = input()
    lines = sys.stdin.readlines()
    for line in lines:
        raw = line.split()
        com = raw[0]
        if len(raw) > 1:
            value = int(raw[1])
        if com == "insert":
            dll.insert(value)
        elif com == "delete":
            dll.delete(value)
        elif com == "deleteFirst":
            dll.deleteFirst()
        else:
            dll.deleteLast()
    dll.printAll()

### FIXED CODE ###

import sys

class DoublyLinkedList:
    def __init__(self, value = -1):
        self.value = value
        self.prev = self
        self.next = self

    def insert(self, value):
        newNode = DoublyLinkedList(value)
        newNode.next = self.next
        newNode.prev = self
        self.next.prev = newNode
        self.next = newNode

    def delete(self, value):
        node = self.next
        while node.value != -1:
            if node.value == value:
                node.next.prev = node.prev
                node.prev.next = node.next
                break
            node = node.next

    def deleteFirst(self):
        if self.next.value != -1:
            self.next = self.next.next
            self.next.prev = self

    def deleteLast(self):
        if self.prev.value != -1:
            self.prev = self.prev.prev
            self.prev.next = self

    def printAll(self):
        node = self.next
        while node.next.value != -1:
            print node.value,
            node = node.next
        print node.value

if __name__ == "__main__":
    dll = DoublyLinkedList()
    lines = sys.stdin.readlines()
    lines.pop(0)
    for line in lines:
        if line[0] == "i":
            dll.insert(int(line[7:]))
        elif line[6] == "F":
            dll.deleteFirst()
        elif line[6] == "L":
            dll.deleteLast()
        else:
            dll.delete(int(line[7:]))
    dll.printAll()
### BUGGY CODE ###

n = int(input())
suuretu = list(map(int,input().split()))
nn = mm = 0
for nn in range(n-1):
    for mm in range(nn+1,n):
        if suuretu[nn] == suuretu[mm]:
            print('NO')
            exit()            
print('YES')

### FIXED CODE ###

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

if len(li) == len(set(li)):
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

N,M = map(int,input().split())
if N == 1:
    print(M)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        ans = i
        break
print(ans)

### FIXED CODE ###

import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(m.floor(pow(M,1/2)),1,-1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()
### BUGGY CODE ###

def main():
  import sys
  input = sys.stdin.readline
  from collections import deque
  num,capacity=map(int,input().split())
  DP=[-1]*(capacity+1)
  DP[0]=0
  for _ in range(num):
    weight,value=map(int,input().split())
    left=capacity-weight
    for i in range(left,-1,-1):
      if DP[i]<0:
        continue
      DP[i+weight]=max(DP[i]+value,DP[i+weight])
  print(max(DP))
      
if __name__=="__main__":
  main()

### FIXED CODE ###

n,w=map(int,input().split())
goods=[list(map(int,input().split())) for _ in range(n)]
DP=[[0]*(w+1) for _ in range(n+1)]
for i in list(range(n))[::-1]:
  wi,vi=goods[i][0],goods[i][1]
  for j in range(w+1):
    if j<wi:
      DP[i][j]=DP[i+1][j]
    else:
      DP[i][j]=max(DP[i+1][j],DP[i+1][j-wi]+vi)
print(DP[0][w])
### BUGGY CODE ###

# abc144 C
# 素因数分解してみる（これは後でちゃんと理解しておく！！！）
import numpy as np
import itertools

n = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


# リストを2分割する
n_insu_list = prime_factorize(n)
bunkai_list = []
# for i in range(1, len(n_insu_list)):
#     bunkai_list.append((np.prod(n_insu_list[:i]), np.prod(n_insu_list[i:])))  # ここが間違っている。
# あらゆる並べ方に対して、この部屋分け的発想を試す必要がある
# n_insu_listを並べ替えたやつ
n_insu_list_list = list(itertools.permutations(n_insu_list))
for nlist in n_insu_list_list:
    for i in range(1, len(nlist)):
        bunkai_list.append((np.prod(nlist[:i]), np.prod(nlist[i:])))
bunkai_list = list(set(bunkai_list))
bunkai_list.append((1, n))

# bunkai_listのうち、tupleの和が最小であるものを選び、そのindexを取得する。そのindexのtupleを取得し、そこまでの移動回数を調べる
bunkai_list_sum = [sum(x) for x in bunkai_list]

min_tuple = bunkai_list[bunkai_list_sum.index(min(bunkai_list_sum))]

print(sum(min_tuple) - 2)


### FIXED CODE ###

n = int(input())
import math
sqrt_n = math.floor(math.sqrt(n))

seisu_tuple = []
for a in range(1,sqrt_n+1):
    if n/a == math.floor(n/a):  # 整数判定
        seisu_tuple.append((a,n/a))
bunkai_list_sum = [sum(x) for x in seisu_tuple]
min_tuple = seisu_tuple[bunkai_list_sum.index(min(bunkai_list_sum))]
print(int(sum(min_tuple) - 2))
### BUGGY CODE ###


#import numpy as np


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



mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

H,W,D=acinput()
#Ad={}
Ad=[0]*(H*W+1)
for i in range(H):
    ar=acinput()
    for j,sar in enumerate(ar):
        #Ad[sar]=np.array((i,j))
        Ad[sar] = (i, j)

dp = [[0 for j in range(H*W+1)]for i in range(H*W+1)]

for x in range(1, H*W+1):
    dp[x][x]=0

for x in range(1,H*W+1):
    y=x+D
    while True:
        if y > H*W:
            break
        #print(x,y)
        #tmp = Ad[y]-Ad[y-D]
        #S = np.sum(np.abs(tmp[0])+abs(tmp[1]))
        #tmp = Ad[y]-Ad[y-D]
        S = abs(Ad[y][0]-Ad[y-D][0])+abs(Ad[y][1]-Ad[y-D][1])

        dp[x][y]=dp[x][y-D]+S
        y+=D
        

#print(np.array(dp))

Q=int(input())
for i in range(Q):
    l,r=acinput()
    print(dp[l][r])


#print(Ad)
#print(np.array(dp))



### FIXED CODE ###


#import numpy as np


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


mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


H, W, D = acinput()
# Ad={}
Ad = [0]*(H*W+1)
for i in range(H):
    ar = acinput()
    for j, sar in enumerate(ar):
        # Ad[sar]=np.array((i,j))
        Ad[sar] = (i, j)

#dp = [[0 for j in range(H*W+1)]for i in range(H*W+1)]
d = [0]*(H*W+1)

# for x in range(1, H*W+1):
#    dp[x][x]=0

y = D+1
while True:
        if y > H*W:
            break
        # print(x,y)
        #tmp = Ad[y]-Ad[y-D]
        #S = np.sum(np.abs(tmp[0])+abs(tmp[1]))
        #tmp = Ad[y]-Ad[y-D]
        S = abs(Ad[y][0]-Ad[y-D][0])+abs(Ad[y][1]-Ad[y-D][1])

        # dp[x][y]=dp[x][y-D]+S
        d[y] = d[y-D]+S
        y += 1


# print(np.array(dp))

Q = int(input())
for i in range(Q):
    l, r = acinput()
    print(d[r]-d[l])


# print(Ad)
# print(np.array(dp))
#print(d)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

inf=10**8

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

A=[]
C=[]
dp=[inf]*(1<<n)
dp[0]=0

for _ in range(m):
  a,_=map(int,input().split())
  c=list(map(int,input().split()))
  A.append(a)
  tmp=0
  for i in c:
    tmp+=1<<(i-1)
  C.append(tmp)

for i in range(1<<n):
  for index,j in enumerate(C):
    dp[i|j]=min(dp[i|j],dp[i]+A[index])
ans=dp[-1]
if ans==inf:ans=-1
print(ans)

### FIXED CODE ###

inf=10**8

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

A=[]
C=[]
dp=[inf]*(1<<n)
dp[0]=0

for _ in range(m):
  a,_=map(int,input().split())
  c=list(map(int,input().split()))
  A.append(a)
  tmp=0
  for i in c:
    tmp+=1<<(i-1)
  C.append(tmp)

for i in range(1<<n):
  for index,j in enumerate(C):
    dp[i|j]=min(dp[i|j],dp[i]+A[index])
ans=dp[-1]
if ans==inf:ans=-1
print(ans)
### BUGGY CODE ###

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

if a==b:
  print(0)
elif k==0:
  print(a-b)
else:
  for i in range(k):
    a,b,c = b+c,a+c,a+b
  if abs(a-b)>=10**18:
    print(-1)
  else:
    print(a-b)
  

### FIXED CODE ###

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

if a==b:
  print(0)
else:
  ans_0=a-b
  ans_1=b-a
  if abs(ans_0)>=10**18:
    print("Unfair")
  elif k%2!=0:
    print(ans_1)
  elif k%2==0:
    print(ans_0)
### BUGGY CODE ###

n=int(input())
a=[]
ans=[]
for i in range(n):
    b=input()
    a+=[b]
    if a[i] in ans:
        ans.remove(a[i])
    else:
        ans.append(a[i])
print(len(ans))

### FIXED CODE ###

n=int(input())
ans=set([])
for i in range(n):
    a=int(input())
    if a in ans:
        ans.remove(a)
    else:
        ans.add(a)
print(len(ans))
### BUGGY CODE ###

from numpy import cumsum
from itertools import combinations
import bisect

n, k = [int(item) for item in input().split()]
xy = [[int(item) for item in input().split()] for _ in range(n)]

xsort = sorted([xy[i][0] for i in range(n)])
ysort = sorted([xy[i][1] for i in range(n)])

l = [0] * n
cumsum_id = [[0] * n for _ in range(n)]
for i, (x, y) in enumerate(xy):
    l[i] = i
    xid = bisect.bisect_left(xsort, x)
    yid = bisect.bisect_left(ysort, y)
    cumsum_id[xid][yid] = 1
cumsum_id = cumsum(cumsum_id, axis=0)
cumsum_id = cumsum(cumsum_id, axis=1)

def count_points_in_rec(x0, x1, y0, y1):
    count = 0
    count += cumsum_id[x1][y1]
    if x0 > 0:
        count -= cumsum_id[x0-1][y1]
        if y0 > 0:
            count += cumsum_id[x0-1][y0-1]
    if y0 > 0:
        count -= cumsum_id[x1][y0-1]
    return count

ans = 5 * 10**18
for a, b in combinations(l, 2):
    if b - a < k-1:
        continue
    for c, d in combinations(l, 2):
        if d - c < k-1:
            continue
        if count_points_in_rec(a, b, c, d) == k:
            ans = min(ans, (xsort[b]-xsort[a]) * (ysort[d]-ysort[c]))
print(ans)

### FIXED CODE ###

from itertools import combinations
 
n, k = [int(item) for item in input().split()]
xy = [[int(item) for item in input().split()] for _ in range(n)]
 
xsort = sorted(xy, key=lambda x: x[0])
ysort = sorted(xy, key=lambda x: x[1])
l = [i for i in range(n)]
 
cum = [[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(n):
        cum[i+1][j+1] = cum[i+1][j] + cum[i][j+1] - cum[i][j] + ([xsort[i][0], ysort[j][1]] in xy)

def count_points_in_rec(x0, x1, y0, y1):
    point = cum[x1+1][y1+1] - cum[x0][y1+1] - cum[x1+1][y0] + cum[x0][y0]
    return point

ans = 5 * 10**18
comb = []
for a, b in combinations(l, 2):
    if b - a >= k-1:
        comb.append([a, b])
for a, b in comb:
    for c, d in comb:
        if count_points_in_rec(a, b, c, d) == k:
            ans = min(ans, (xsort[b][0]-xsort[a][0]) * (ysort[d][1]-ysort[c][1]))
print(ans)
### BUGGY CODE ###

# D - Multiple of 2019

s = str(input())
ans = 0

for i in range(len(s)):
    for j in range(i, len(s)):
        if int(s[i:j+1])%2019==0:
            ans += 1

print(ans)

### FIXED CODE ###

# D - Multiple of 2019

from collections import defaultdict
d = defaultdict(int)

mod = 2019
s = str(input())[::-1]

ssum = 0
d[0] = 1
for i in range(len(s)):
    ssum = (ssum + int(s[i])*pow(10, i, mod))%mod
    d[ssum] += 1

ans = 0
for n in d.values():
    ans += n*(n-1)//2

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

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
b = list(a)
max_num = max(a)

for i in range(n):
    if a[i] == max_num and a.count(max_num) == 1:
        a.pop(i)
        print(max(a))
        a = list(b)
    else:
        print(max_num)

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
b = list(a)
a.sort(reverse=True)

max_num = max(a)
count = a.count(max_num)

for i in a:
    if i < max_num:
        max_num2 = i
        break

for i in range(n):
    if b[i] == max_num and count == 1:
        print(max_num2)
    else:
        print(max_num)
### BUGGY CODE ###

n=int(input())
A=list(map(int,input().split()))
from collections import deque
q=deque(A)

ans=1
while len(q)>0:
    p=q.popleft()
    ans=ans*p
if ans>1000000000000000000:
    print(-1)
else:
    print(ans)
    

### FIXED CODE ###

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

ans=1

if 0 in A:
    print(0)
    exit()

for i in A:
   ans=ans*i
   if ans>10**18:
    print(-1)
    exit()


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

#2020-05-10
a,b,c,k = map(int,input().split())
lst = []
for i in range(a):
    lst.append(1)
for i in range(b):
    lst.append(0)
for i in range(c):
    lst.append(-1)
print(sum(lst[:k]))

### FIXED CODE ###

#2020-05-10
a, b, c, k = map(int, input().split())
d = k - a
e = d - b
f = k -(a + b)
if d <= 0:
    print(1 * k)
else:
    print(a + f * (-1))
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    count = 0
    while True:
        if i+1 in a:
            a.remove(i+1)
            count += 1
        else:
            break
    print(count)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
# for i in range(n):
#     count = 0
#     while True:
#         if i+1 in a:
#             a.remove(i+1)
#             count += 1
#         else:
#             break
#     print(count)
b = [0]*n
for i in range(n-1):
    b[a[i]-1] += 1
for i in range(n):
    print(b[i])
### BUGGY CODE ###

import itertools

n = int(input())

s = []
for i in range(n):
    s.append(input())

comb_s = list(itertools.permutations(s, len(s)))

def checker(x):
    jud = 1
    ans = ''.join(x)

    if not s:
        return jud

    r = x.count('(')
    l = x.count(')')
    if r != l:
        jud =0
        return jud

    if x[0] != '(' or x[-1] != ')':
        jud =0

    return jud

def main():
    for i in range(len(comb_s)):
        juds = checker(''.join( [j for j in comb_s[i]]))
        if juds == 1:
            print('Yes')
            return

    print('No')
    return
main()


### FIXED CODE ###

from sys import stdin

def main():
    readline = stdin.readline
    n = int(readline())
    s = tuple(readline().strip() for _ in range(n))

    plus, minus = [], []
    for c in s:
        if 2 * c.count('(') - len(c) > 0:
            plus.append(c)
        else:
            minus.append(c)

    plus.sort(key = lambda x: x.count(')'))
    minus.sort(key = lambda x: x.count('('), reverse = True)
    plus.extend(minus)
    sum = 0
    for v in plus:
        for vv in v:
            sum = sum + (1 if vv == '(' else -1)
            if sum < 0 : return print('No')
    if sum != 0:
        return print('No')

    return print('Yes')

if __name__ == '__main__':
    main()