peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())
ans = 0
prev_A = -10
prev_card_num = 0
for i in range(1,N+1):
    A = int(input())
    ans += (prev_card_num + A)//2
    if prev_card_num == 1 and A == 0:
        prev_card_num = 0
    elif (prev_card_num+A)%2 == 1:
        prev_card_num = 1
        prev_A = i
    else:
        prev_card_num = 0
        prev_A = i
print(ans)
# Judge status: Wrong Answer
N=int(input())
d=-2
ans=[]
while N!=0:
    r=N%(d)
    if r<0:
        r+=2
    N=(N-r)//(d)
    ans.append(str(r))
    
print("".join(ans[::-1]))
# Judge status: Wrong Answer
H,W = [x for x in input().split()]
print(H+W)
# Judge status: Accepted
n=int(input())
for i in range(50000):
    if int(i*1.08)==n:
        print(i)
        exit()
    if i*1.08>n:
        break
print(":(")
# Judge status: Accepted
a,b,c = map(int,input().split())
if b+c > a:
  di = a - b
  print(c - di)
else:
  print(0)
# Judge status: Accepted
x=sorted(list(input()))
if x[0]==x[1] and x[1]!=x[2] and x[2]==x[3]:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
a,b,c,x,y=map(int,input().split())

ans=int(5000*(10**5))

for i in range(10**5):
    a_cnt=max(0,x-i)
    b_cnt=max(0,y-i)
    
    total=i*2*c+a_cnt*a+b_cnt*b
    ans=min(ans,total)

print(ans)
# Judge status: Accepted
k,x=map(int,input().split())
print("Yes" if x<=k*500 else "No")
# Judge status: Wrong Answer
N = int(input())
A = [0] + [int(s) for s in input().split(' ')]

B = [0] * (N + 1)
count = 0
ret = []
for i in range(N, 0, -1):
    ai = A[i]
    ii = i
    total = 0
    while ii < N:
        total += B[ii]
        ii += i
    
    if total % 2 == ai:
        continue
    else:
        B[i] = 1
        count += 1
        ret.append(i)

print(count)
print(' '.join(str(i) for i in ret))
# Judge status: Accepted
n,m,k = map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

aa = [0]
bb = [0]

for i in range(n):
	aa.append(a[i]+aa[i])

for i in range(m):
	bb.append(b[i]+bb[i])

ans=0
j=m
for i in range(n+1):
	if aa[i]>k:
		break
	while bb[j]>k-aa[i]:
		j-=1
	ans=max(i+j,ans)
print(ans)
# Judge status: Wrong Answer
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
Q,H,S,D = LI()
N = I()
min_1 = min(Q*4,H*2,S)
price = [min_1,D]
if 2*min_1<=D:
    ans = min_1*N
else:
    ans = N//2*D+min_1
print(ans)
# Judge status: Wrong Answer
n=int(input())
a=[2,1]
for i in range(2,n):
  a.append(a[i-1]+a[i-2])
  
print(a[n-1])
# Judge status: Wrong Answer
X=int(input())
time=0
p=0
j=1
while True:
    if p+j==X:
        time+=1
        break
    elif X-(p+j)>=j+1:
        p+=j
    j+=1
    time+=1
print(time)
# Judge status: Accepted
from collections import Counter
N,X,Y = map(int, input().split())
X -= 1
Y -= 1
L = []
for i in range(N-1):
  for j in range(i+1,N):
    L.append(min(abs(i-j),abs(X-i)+abs(Y-j)+1,abs(Y-i)+abs(X-j)+1))
D = Counter(L)
for k in range(1,N):
  print (D[k])
# Judge status: Accepted
a,b,c = map(int,input().split())
if a%2==1 or b%2==1 or c%2==1:
  print(0)
elif a == b == c:
  print(-1)
else:
  ans = 0
  while a%2==b%2==c%2==0:
    a,b,c = (b+c)//2,(c+a)//2,(a+b)//2
    ans += 1
  print(ans)
# Judge status: Wrong Answer
N = int(input())
arms = [list(map(int, input().split())) for _ in range(N)]

arms.sort()

ans = 1
left = arms[0][0] + arms[0][1]
for i in range(1, N):
  if left <= arms[i][0] - arms[i][1]:
    ans += 1
    left = arms[i][0] + arms[i][1]

print(ans)
# Judge status: Accepted
n=int(input())
s=''
if n==0:
    print(0)
    exit()
while n!=0:
    m=n%2
    s+=str(m)
    n=(n-m)//-2
print(s[::-1])
# Judge status: Accepted
import collections
N,K = map(int,input().split())
d = collections.defaultdict(int)
b = map(int,input().split())
for e in b:
  d[e]+=1
ret = 0
a = sorted([v for v in d.values()],reverse=True)
while len(a) > K:
  ret += a.pop()
print(ret)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
a.sort()
l = [x//400 if x//400 <= 7 else 8 for x in a]
p = [0]*8
for i in l:
    if i < 8:
        p[i] = 1
if p.count(0) == 8:
    pmin = 1
    pmax = pmin + min(l.count(8)-1,p.count(0)-1)
else:
    pmin = sum(p) if sum(p) != 0 else 1
    pmax = pmin + min(l.count(8),p.count(0))
print(l)
print(p)
print(pmin, pmax)
# Judge status: Accepted
import collections
n = int(input())
S = []
for i in range(n):
    s = collections.Counter(input())
    S.append(s)
ans = ''
for key in S[0].keys():
    cnt = S[0][key]
    for i in range(1,n):
        cnt = min(cnt,S[i][key])
    for i in range(cnt):
        ans += key
ans = sorted(ans)
print(''.join(ans))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

from collections import Counter
c = Counter(A)

x = 0
y = 0
for k, v in sorted(c.items(), key=lambda x: -x[0]):
    if v >= 4 and x == 0 and y == 0:
        x = y = k
    elif v >= 2:
        if x == 0:
            x = k
        elif y == 0:
            y = k

print(x*y)
# Judge status: Wrong Answer
n,m=map(int,input().split())
ans=list(range(1,m+1))
print(ans)
for i in range(n):
    l=list(map(int,input().split()))[1:]
    ans=list(set(ans)&set(l))
print(len(ans))
# Judge status: Accepted
s = input()
n = len(s)
s1 = s[:n//2] 
s2 = s[n//2 + 1:]

if s == s[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N,M=map(int,input().split())    
X=list(map(int,input().split()))
X.sort()
Y=[]
for i in range(len(X)-1):
    Y.append(X[i+1]-X[i])
Y.sort()    
if N!=1:
    Y = Y[:-(N-1)]
    print(sum(Y))
else:
    print(sum(Y))
# Judge status: Accepted
a, b, c = list(map(int, input().split()))
if a % 2 == 1 and b % 2 == 1 and c % 2 == 1:
    print(min(a*b, b*c, a*c))
else:
    print(0)
# Judge status: Wrong Answer
N, A, B = map(int, input().split())

if A > B:
    print(0)
elif N == 1 and A != B:
    print(0)
elif N == 1 and A == B:
    print(1)
elif N == 2 and A != B:
    print(1)
else:
    print(1000)
# Judge status: Wrong Answer
day = input()
week = ["SAT","FRY","THU","WED","TUE","MON","Sun"]
for s in range(len(week)):
  if day == week[s]:
    print(s + 1)
# Judge status: Wrong Answer
N = int(input())
while N >= 1000:
    N = N - 1000
else:
    print(N)
# Judge status: Wrong Answer
n, m = map(int, input().split())
XY = list(map(int, input().split()) for _ in range(m))

Ball = [1] * n
Done = [False] * n

flg = True
for i in range(m):
	x, y = XY[i]
	x -= 1
	y -= 1
	if Ball[x] >= 1:
			Ball[x] -= 1
			Ball[y] += 1
			if x == 0 and flg:
				Done[y] = True
				flg = False
			elif Done[x]:
				Done[y] = True
				
res = 0
for i in range(n):
	if Ball[i] != 0 and Done[i]:
		res += 1

print(res)
# Judge status: Accepted
n = int(input())

dp = [n+1]*(n+1)
dp[0] = 0

for i in range(1, n+1):
    j = 1
    while j <= n:
        dp[i] = min(dp[i], dp[i-j]+1)
        j *= 6

    k = 1
    while k <= n:
        dp[i] = min(dp[i], dp[i-k]+1)
        k *= 9

print(dp[n])
# Judge status: Accepted
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    A.append(A[i]-1)
    A.append(A[i]+1)
S = Counter(A)
print(max(S.values()))
# Judge status: Wrong Answer
x = int(input())
lis = [3,5,7]

for i in range(3):
    if x == lis[i]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
from collections import Counter
N, K = map(int, input().split())
A = Counter(input().split())

print(sum(sorted(A.values(), reverse=True)[K:]))
# Judge status: Wrong Answer
n = int(input())

res = 1
for i in range(n):
  res *= (i+1)

print(res)
# Judge status: Accepted
n=int(input())
d=[0 for i in range(10**7)]
    
def jud(l):
    if len(set(l))==3:
        return 6
    if len(set(l))==2:
        return 3
    if len(set(l))==1:
        return 1

for i in range(1,101):
    for j in range(i,101):
        for k in range(j,101):
            l=[i,j,k]
            p=i**2+j**2+k**2+i*j+j*k+k*i
            d[p-1]+=jud(l)

for i in range(n):
    print(d[i])
# Judge status: Accepted
n = int(input())
a = int(input())
print("Yes" if n%500 <=a else "No")
# Judge status: Wrong Answer
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)
      
N=int(input())
T=[]
total=1
for i in range(N):
    a=int(input())
    T.append(a)
T_set=sorted(list(set(T)))
M=len(T_set)

if M==1:
    ans=T_set[0]
else:
    for i in range(M-1):
        ans=lcm(T_set[i],T_set[i+1])

print(ans)
# Judge status: Accepted
# Problem A - Painting

import math

# input
H = int(input())
W = int(input())
N = int(input())

# initialization
max_num = max(H, W)
ans = math.ceil(N / max_num)

# output
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

diff = N-M

for d in range(diff):
    for i in range(M):
        for j in range(M):
            flag = True
            if B[i][j] != A[i+d][j+d]:
                flag = False
                break
        
        if flag:
            print('Yes')
            exit()

print('No')
# Judge status: Wrong Answer
N=int(input())
H=list(map(int,input().split()))
ans=0
_=0
for i in range(N-1):
  if H[i]>=H[i+1]:
    _+=1
  else:
    if _>ans:
      ans=_
    _=0
print(ans)
# Judge status: Accepted
A, B = map(int, input().split())
print((A+B)//2 if (A+B) % 2 == 0 else "IMPOSSIBLE")
# Judge status: Wrong Answer
n=input()
if n in "9":
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from collections import deque
import bisect

N = int(input())

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

q = deque([A[0]])

for a in A[1:]:
    idx = bisect.bisect_left(q, a)
    if idx == 0:
        q.appendleft(a)
    else:
        q[idx-1] = a

print(len(q))
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))
csum = []
s = 0

for i in range(N):
    s += a[i]
    csum.append(s)

if N == 2:
    print(abs(a[0] - a[1]))
    exit()

s = sum(a)
ans = 1e10
for i in range(1,N-1):
    ans = min(ans,abs(2*csum[i]-s))

print(ans)
# Judge status: Accepted
N,R = map(int, input().split())

if N>=10:
    print(R)
else:
    print(R+100*(10-N))
# Judge status: Accepted
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(N: int):
    return (N//2 + N % 2) / N


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(f'{solve(N)}')


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N, K = map(int,input().split())
S = list(input())
S[K-1]=S[K-1].lower()
ans=' '.join(S)
print(ans)
# Judge status: Accepted
import sys
S = input()
K = int(input())
for k in range(K):
  if S[k] != "1":
    print(S[k])
    sys.exit()
print(1)
# Judge status: Accepted
N = int(input())
h = list(map(int,input().split()))
cost = [0]*N
cost[0] = 0
cost[1] = abs(h[1]-h[0])

for i in range(2,N):
  cost[i] = min((cost[i-2]+abs(h[i]-h[i-2])), (cost[i-1]+abs(h[i]-h[i-1])))
print(cost[-1])
# Judge status: Accepted
S = input()
A = []
A.append(0)

for i in range(len(S)):
    if S[i] == "<":
        A.append(A[i] + 1)
    else:
        A.append(0)

for i in range(len(S)):
    if S[len(S) - i - 1] == ">":
        A[len(S) - i - 1] = max(A[len(S) - i - 1], A[len(S) - i] + 1)
    else:
        continue

# print(A)
print(sum(A))
# Judge status: Wrong Answer
N,M = map(int,input().split())
X = list(map(int,input().split()))
li = [0]*(M-1)
X.sort()
for i in range(M-1):
    li[i] = abs(X[i+1]-X[i])

li.sort()
print(sum(li[:M-N]))
# Judge status: Accepted
N, K = map(int, input().split())

p = 0
for i in range(1, N + 1):
    j = 0
    while (i << j) < K:
        j += 1
    p += 0.5**j
ans = p / N
print(ans)
# Judge status: Wrong Answer
N,K=map(int,input().split())
ans=0
for i in range(K-1,N+1):
    c=(i+1)*i/2
    d=(N+N-i)*(i+1)/2
    ans+=int(d-c+1)
print(ans)
# Judge status: Accepted
import itertools

n, m, q = map(int, input().split())
abcds = [tuple(map(int, input().split())) for _ in range(q)]
x = [(i + 1) for i in range(m)]
ans = 0
for elem in itertools.combinations_with_replacement(x, n):
    rep = 0
    for i in range(q):
        if elem[abcds[i][1] - 1] - elem[abcds[i][0] - 1] == abcds[i][2]:
            rep += abcds[i][3]
    ans = max(ans, rep)
print(ans)
# Judge status: Wrong Answer
N = int(input())
S = input()
T = list()
for i in range(int(N / 2), N):
    t = S[i]
    T.append(t)
y = 0
n = 0
for i, k in zip(T, S):
    if i == k:
        y += 1
    else:
        n += 1
if y >= int(N / 2):
    print('Yes') 
else:
    print('No')
# Judge status: Accepted
s = list(str(input()))
for i in range(3):
  if s[i] == s[i+1]:
    print("Bad")
    quit()
print("Good")
# Judge status: Accepted

a, b, c, k = map(int, input().split())
if a > k:
    print(k)
elif a+b >k:
    print(a)
else:
    print(a-(k-(a+b)))
# Judge status: Accepted
import bisect


def main():
    N = int(input())
    AArr = list(map(int, input().split()))
    BArr = list(map(int, input().split()))
    CArr = list(map(int, input().split()))

    AArr.sort()
    CArr.sort()
    ans = 0
    for i in range(N):
        a = bisect.bisect_left(AArr, BArr[i])
        c = bisect.bisect_right(CArr, BArr[i])
        c = N-c
        ans += a*c

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
S = input()[::-1]
S = S.replace('dream'[::-1], '').replace('dreamer'[::-1], '').replace(
    'eraser'[::-1], '').replace('erase'[::-1], '')

if len(S) == 0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
a,b,c,k = map(int, open(0).read().split())

fact = 1
if k%2:
    fact = -1
print((a-b)*fact)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
b = [sum(a)]
for i in range(n):
    b.append(b[-1] - a[i])
flag = True
if a[0] != 0:
    flag = False
else:
    count = 1
    temp = 1
    for i in range(1, n + 1):
        temp2 = min(temp * 2, b[i])
        count += temp2
        temp = temp2 - a[i]
        if temp <= 0:
            if i != n:
                flag = False
                break
if flag == True:
    print(count)
else:
    print(-1)
# Judge status: Accepted
N = int(input())

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

div_lst = make_divisors(N)

min_num = float("inf")
for d in div_lst:
    tmp = d[0]+d[1]
    if tmp < min_num:
        min_num = tmp

print(min_num-2)
# Judge status: Wrong Answer
n=int(input())
cnt=0
a=[int(e) for e in input().split()]
for i in range(1,n):
    if n-i>=a[i]:
        for j in range(i+1,n+1):
            if a[i-1]+a[j-1]==j-i:
                cnt+=1
print(cnt)
# Judge status: Accepted
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


n, x = map(int, input().split())
x_l = list(map(int, input().split()))
dist = []
for i in range(n):
    dist.append(abs(x - x_l[i]))

res = dist[0]
for i in range(len(dist)):
    res = gcd(res, dist[i])
print(res)
# Judge status: Accepted
A,B = map(int,input().split())
if A % 3 == 0:
    print("Possible")
elif B % 3 == 0:
    print("Possible")
elif (A + B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
l,r,d=map(int,input().split())
c=0
for i in range(l,r+1):
  if i%d==0:c+=1
print(c)
# Judge status: Accepted
N = int(input())

sc = {"AC":0, "WA":0, "TLE":0, "RE":0} 

for i in range(N):
  S = input()
  sc[S] += 1
#
print("AC", " x ", sc["AC"])
print("WA", " x ", sc["WA"])
print("TLE", " x ", sc["TLE"])
print("RE", " x ", sc["RE"])
# Judge status: Wrong Answer
ss = input()+'**'
n = len(ss)
arrs = [ss[0]]

for i in range(1, n):
  if len(arrs[-1]) == 2:
    if arrs[-1].endswith(ss[i]):
      continue
    else:
      arrs.append(ss[i])
  else:
    if ss[i-1] == ss[i]:
      arrs.append(ss[i: i+2])
    else:
      arrs.append(ss[i])
while '*' in arrs:
  arrs.remove('*')


print(len(arrs))
# Judge status: Wrong Answer
from sys import stdin
from sys import setrecursionlimit
import numpy as np
import math

setrecursionlimit(10 ** 7)

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

a.sort()
a = np.array(a,dtype=np.int64)

low = -1
hi = 10**9
point = 0

while hi-low > 0.001:
    ave = (hi+low)/2
    if np.sum(a//ave) <= k:
        hi = ave
    else:
        low = ave

print(math.ceil(ave))
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
 
n1 = int(readline())
if n1 % 2 == 1:
    print(0)
else:
    n1 //= 2
    ans = 0
    while n1:
        n1 //= 5
        ans += n1
    print(ans)
# Judge status: Wrong Answer
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

d = defaultdict(int)
strong = 0

for a in A:
    if a >= 3200:
        strong += 1
        continue
    d[a // 400] += 1

Cmin = len(d)
Cmax = len(d) + strong
print(Cmin, Cmax)
# Judge status: Wrong Answer
import math
N,K = map(int,input().split())
print(math.ceil((math.log(N,K))))
# Judge status: Accepted
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

journey = [1]

for i in range(2*n + 100):
    nxt = a[journey[-1]]
    journey.append(nxt)
    
if k < n + 1:
    print(journey[k])
    exit()

loop_end = n

loop_start = n-1

while(journey[loop_start] != journey[loop_end]):
    loop_start -= 1

period = loop_end - loop_start

k %= period
while k<= n:
    k += period

print(journey[k])
# Judge status: Wrong Answer
N,M = map(int,input().split())
cnt = 0
cnt += ((N * N-1) / 2)
cnt += ((M * M-1) / 2)
print(cnt)
# Judge status: Accepted
import sys
n = int(input())
for i in range(int(n**0.5), 0, -1):
    if n%i==0:
        j=n//i
        print(i+j-2)
        sys.exit()
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import collections
import itertools
import bisect
mod = 10 ** 9 + 7
N, K, Q = list(map(int, input().split()))
A = [0]*Q
for q in range(Q):
    A[q] = int(input())
# 自分以外の人がK回答えたら敗退
seikai_num = [0]*(N+1)

for a in A:
    seikai_num[a] += 1
print(seikai_num)

for seikai in seikai_num[1:]:
    if (Q - seikai >= K):
        print('No')
    else:
        print('Yes')
# Judge status: Wrong Answer
a,b=map(int,input().split())
#n=int(input())
#s=input()
if a==b:
  print("Draw")
elif a>b and a!=1:
  print(a)
elif a>b:
  print(b)
elif a<b and a!=1:
  print(b)
else:
  print(a)
# Judge status: Wrong Answer
S = input()
list(S)
if S in "A":
  if S in "B":
    print("Yes")
  
  else:
    print("No")

else:
  print("No")
# Judge status: Accepted
n=input()
if '9' in n:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
N = int(input())
if N%2:
  print(N//2+1)
else:
  print(N/2)
# Judge status: Wrong Answer
a, b = input().split()
c = '{}{}'.format(a, b)
distinguish = []
for x in range(4, 101):
  if int(c) == x*x:
    distinguish.append(1)
if distinguish.count(1) >= 1:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
A,B = map(int,input().split())
min_8=int(A*(100/8))
max_8=int((A+1)*(100/8))
min_10=int(B*10)
max_10=int((B+1)*10)
if max_8 < min_10:
    print("-1")
elif min_8 > max_10:
    print("-1")
elif max_8 >= min_10:
    if min_8 < min_10:
        print(min_10)
    elif min_8 >= min_10:
        print(min_8)
# Judge status: Accepted
import sys
import numpy as np

n=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

ans=[0]*n
for i in range(n-1):
    ans[a[i]-1]+=1
for i in range(n):
    print(ans[i])
# Judge status: Wrong Answer
s = input()
print(s[:2]+"8"+s[4:])
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        a,b=map(int, input().split())
        for i in range(13,1250):
            if (i*8)//100==a and (i*10)//100==b:
                return i
        return -1
    print(main())
resolve()
# Judge status: Accepted
N=int(input())
S=input()

cs=0
mincs=1000
enc={'(':1,')':-1}

for c in S:
    cs+=enc[c]
    mincs=min(mincs,cs)

while mincs<0:
    S='('+S
    mincs+=1
    cs+=1

while cs>0:
    S=S+')'
    cs-=1

print(S)
# Judge status: Wrong Answer
n,m = map(int,input().split())
li = []
for i in range(n):
    a,b = map(int,input().split())
    li.append([str(a),b])
li = sorted(li)
coin = 0
cnt = 0
i = 0
while cnt != m:
    if li[i][1] <= 0:
        i+=1
    else:
        li[i][1]-=1
        coin += int(li[i][0])
        cnt +=1
print(coin)
# Judge status: Accepted
from random import randint
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
    s.append(list(map(int, input().split())))

### input end ###

for i in range(D):
    print(randint(1, 26))
# Judge status: Accepted
N,K,Q =map(int,input().split())
A = [int(input()) for i in range(Q)]
point = [K-Q]*N
for i in range(Q):
    point[A[i]-1] +=1
for i in range(N):
    if(point[i]>0):
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
X = int(input())

if X >= 400 and X < 599:
    print('8')
elif X >= 600 and X < 799:
    print('7')
elif X >= 800 and X < 999:
    print('6')
elif X >= 1000 and X < 1199:
    print('5')
elif X >= 1200 and X < 1399:
    print('4')
elif X >= 1400 and X < 1599:
    print('3')
elif X >= 1600 and X < 1799:
    print('2')
elif X >= 1800 and X < 1999:
    print('1')
# Judge status: Accepted
a,b = map(int,input().split())

print((a+b) % 24)
# Judge status: Accepted
n = int(input())

works = list()
for num in range(n):
    a = list(map(int, input().split()))
    works.append(a)

works.sort(key = lambda x :x[1])

time = 0
limit = 0

for row in works:
    time += row[0]
    limit = row[1]
    if time > limit:
        print("No")
        exit()

print("Yes")
# Judge status: Accepted
n = int(input())
a = int(n/1.08)
if int(a*1.08) == n:
  print(a)
elif int((a+1)*1.08) == n:
  print(a+1)
else:
  print(':(')
# Judge status: Accepted
n = int(input())
a = []
b = []
for i in range(n):
    t, m = map(int, input().split())
    a.append(t)
    b.append(m)
ans = 0
for i in range(n):
    if((ans + a[-1 - i]) % b[-1 - i]!=0):
        ans += b[-1 - i] - (ans + a[-1 - i]) % b[-1 - i]
print(ans)
# Judge status: Accepted
import itertools
N = int(input())
zahyo =[list(map(int,input().split())) for _ in range(N)]
N_list = [i for i in range(N)]
P = itertools.permutations(N_list,N)
P = list(P)
sm = 0
for p in P:
    for i,j in zip(p,p[1:]):
        xi,yi = zahyo[i]
        xj,yj = zahyo[j]
        sm += (((xi-xj)**2+(yi-yj)**2)**0.5)
print(sm/len(P))
# Judge status: Accepted
N,Y=map(int,input().split())
A=[]
for i in range(Y//10000+1):
    for j in range((Y-i*10000)//5000+1):
        c1=(Y-10000*i-5000*j)/1000
        c2=N-i-j
        if c1==c2:
            A=[i,j,c1]
            break
        if c1!=c2:
            continue
if len(A)==0:
    print("-1 -1 -1")
else:
    A[2]=int(A[2])
    #intは整数、floatは少数
    print(str(A[0])+" "+str(A[1])+" "+str(A[2]))
# Judge status: Accepted
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())
rsp={"r":p,"s":r,"p":s}
sumt=0
chk=[1]*n
for i in range(len(t)):
  sumt+=rsp[t[i]]
  if i>=k and t[i]==t[i-k]:
    chk[i]=chk[i-k]+1
    chk[i-k]=1
ans=sumt
for i in range(len(chk)):
  if chk[i]!=1:
    chg=chk[i]//2
    ans-=(rsp[t[i]])*chg
print(ans)
# Judge status: Accepted
# %% AGC 025 A


def sumOfDigits(n):
    res = 0
    while n > 0:
        res += n % 10
        n //= 10
    return res


n = int(input())
mn = n
for i in range(1, n):
    b = n - i
    mn = min(sumOfDigits(i) + sumOfDigits(b), mn)

print(mn)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
num1=0
num2=0
ans=1
for i in range(n):
    if a[i]==num1:
        ans*=a[i]
        num2+=1
        num1=0
    else:
        num1=a[i]
    if num2==2:
        break
if num2==2:
    print(ans)
else:
    print(0)