peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
W,H,x,y=map(int,input().split())

if x*2==W and y*2==H:
    print(H*W/2,end=" ")
    print(1)
else:
    print(H*W/2,end=" ")
    print(0)
# Judge status: Accepted
S = input()
print("A"+S[8]+"C")
# Judge status: Wrong Answer
# 12:03
import itertools
import math
n = int(input())

cities = [list(map(int, input().split())) for _ in range(n)]
print(cities)
a = []
for i in range(n):
    a.append(i)
a = list(itertools.permutations(a))
sum = 0
for city in a:
    for i in range(n-1):
        sum += ((cities[city[i+1]][0]-cities[city[i]][0])**2 +
                (cities[city[i+1]][1]-cities[city[i]][1])**2)**0.5
print(sum/math.factorial(n))
# Judge status: Wrong Answer
n,m = list(map(int,input().split()))
count = 0

if 2*n < m:
  count += n
  m = m - 2*n
  n = 0  
  count += m//4
else:
  while m >= 2*n:
    count += 1
    m -= 2
    n -= 1

print(count)
# Judge status: Wrong Answer
s=input()
S=[s[i] for i in range(len(s))]
c=1
for i in range(len(S)-1):
  if S[i] in S[i+1:]:
    c=0
    break
if c==1:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import sys
a, b, c = map(int, input().split())
if c <= a+b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())

ans = 0
for i in range(1,N+1):
  if i%3 and i%5:
    ans += i

print(ans)
# Judge status: Accepted
import numpy as np

N, X, Y = map(int, input().split())
X -= 1
Y -= 1

ans = [0 for _ in range(N - 1)]

for i in range(N - 1):
    for j in range(i + 1, N):
        d1 = abs(j - i)
        d2 = abs(X - i) + 1 + abs(j - Y)
        ans[min(d1, d2) - 1] += 1

[print(ans[i]) for i in range(N - 1)]
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
A = [0]*n

for i in a:
    A[i-1] += 1

print(*A)
# Judge status: Accepted
n = int(input())
cnt = [0]*11000

for x in range(1,101):
    for y in range(1, 101):
        for z in range(1, 101):
            value = x*x + y*y + z*z + x*y + y*z + z*x
            if value <= n:
                cnt[value] += 1

for i in range(1, n+1):
    print(cnt[i])
# Judge status: Accepted
a, b, c, d = map(int, input().split())
a_b = max(a, b) - min(a, b) <= d
b_c = max(b, c) - min(b, c) <= d
c_a = max(c, a) - min(c, a) <= d

if (a_b and b_c) or c_a:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

tmp = a[0]
ans = 0
for i in a:
    if i < tmp:
        ans += tmp-i
    else:
        tmp = i
print(ans)
# Judge status: Accepted
n, X = map(int, input().split())
l = list(map(int, input().split()))
x = 0
c = 1
for i in l:
    x += i
    if x <= X:
        c += 1
    else:
        break
print(c)
# Judge status: Accepted
K, X = map(int,input().split())

for i in range(X-K+1,X+K):
  print(i, end=' ')
# Judge status: Accepted
import collections


def main():
    N = int(input())
    A = list(map(int, input().split()))
    counter = collections.Counter(A)
    ans = 0
    for k, v in counter.items():
        if v > k:
            ans += v - k
        elif v < k:
            ans += v
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
S = list(input())
S[3] = "8"
print(S[0:10])
# Judge status: Wrong Answer
s=int(input())
s=list(str(s))
k=int(input())
i=0
while True:
  if i==len(s):
    print(1)
    break
  if s[i]!="1":
    print(s[i])
    break
  else:
    i=i+1
# Judge status: Accepted
n = int(input())
s = list(input())
a = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(len(s)):
    s[i] = a[a.index(s[i]) + n]
print(*s, sep="")
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[10]:


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


# In[12]:


mylist = []
for i in range(Y//X):
    tmp = X*(2**i)
    if tmp <= Y:
        mylist.append(tmp)
    else:
        break
print(len(mylist))


# In[ ]:
# Judge status: Wrong Answer
X = int(input())

print(int(X**0.5)**2)
# Judge status: Accepted
S=list(input())

ans = 'AC'

#条件１
if S[0] != 'A':
    ans = 'WA'

#条件2
C_cnt=0
for s in S[2:-1]:
    if s=='C':
        C_cnt+=1
    
if C_cnt != 1:
    ans = 'WA'
    
#条件3
Up_cnt=0
for s in S:
    if s.isupper()==True:
        Up_cnt+=1
if Up_cnt != 2:
    ans = 'WA'
    
print(ans)
# Judge status: Wrong Answer
def resolve():
    S = str(input())
    ans = 0

    while True:
        tmp1 = S.count('01')
        ans += tmp1 * 2
        S = S.replace('01', '')

        tmp2 = S.count('10')
        ans += tmp2*2
        S = S.replace('10', '')

        if tmp1 == 0 and tmp2 == 0:
            break

    print(ans)
    return
# Judge status: Accepted
s,w=list(map(int,input().split()))
if s>w:
    print('safe')
else:
    print('unsafe')
# Judge status: Accepted
import collections
n, m = map(int, input().split())

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

que = collections.deque([(0, -1)])
visited = [None] * n
while que:
    p, parent = que.popleft()
    if visited[p] is not None:
        continue
    visited[p] = parent
    for to in graph[p]:
        que.append((to, p))

print("Yes")
for v in visited[1:]:
    print(v + 1)
# Judge status: Accepted
d=input()
if d=="25":
  print("Christmas")
elif d=="24":
  print("Christmas Eve")
elif d=="23":
  print("Christmas Eve Eve")
else:
  print("Christmas Eve Eve Eve")
# Judge status: Accepted
import itertools


def main():
    N = int(input())
    P = tuple(int(s) for s in input().split())
    Q = tuple(int(s) for s in input().split())

    if P == Q:
        print(0)
        return

    i = 0
    a, b = 0, 0
    for v in itertools.permutations(range(1, N+1)):
        i += 1
        if v == P:
            a = i
        elif v == Q:
            b = i

    print(abs(a-b))


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n=int(input())
lst=[]
person=list(map(int,input().split()))
person.sort(reverse=True)
conv=0
for i in range(n):
  lst.append(person[i])
  if len(lst)>=2:
    conv+=min(lst[0], lst[len(lst)-2])
print(conv)
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))

print((n+k-3)//(k-1))
# Judge status: Accepted
A, B, T = map(int, input().split())
ans = 0
cnt = A
while cnt <= T + 0.5:
    ans += B
    cnt += A
print(ans)
# Judge status: Accepted
K = int(input())
from collections import deque
p = deque()
for i in range(1,10):
    p.append(i)
for i in range(K):
    if p[0] % 10 != 0:
        p.append(10*p[0]+p[0]%10-1)
    p.append(10*p[0]+p[0]%10)
    if p[0] % 10 != 9:
        p.append(10*p[0]+p[0]%10+1)
    q = p[0]
    p.popleft()
print(q)
# Judge status: Accepted
import sys
X, Y = map(int,input().split())
list1 = []
list2 = []

for x in range(0,101):
  for y in range(0,101):
    list1.append(x+y)
    list2.append(2*x+4*y)


for i in range(len(list1)):
  if list1[i] == X and list2[i] == Y:
    print('Yes')
    sys.exit()
print('No')
# Judge status: Wrong Answer
from collections import Counter
s = input()
n = len(s)
count = dict(Counter(s))
flag = False
if n ==1:
    flag = True
elif n <= 3:
    if max(count.values())==2:
        flag = False
    else:
        flag = True
elif n==4:
    if max(count.values())<=2:
        flag = True
    else:
        flag = False
else:
    if max(count.values()) >= n/2:
        flag = False
    else:
        flag = True
print('YES' if flag==True else 'NO')
# Judge status: Wrong Answer
import math
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sum_A = sum(A)
sum_B = sum(B)
cnt1 = sum_B - sum_A
cnt2 = 0
for a, b in zip(A, B):
    if a > b:
        cnt2 += a - b
    elif a < b:
        cnt2 += math.ceil((b - a) / 2)
if cnt1 >= cnt2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())


def check(n):
    ans=0
    for i in range(1,n+1):
        if n%i==0:
            ans+=1
    if ans==8:
        return True
    return False

ans=0
for i in range(1,n+1,2):
    if check(i):
        ans+=1
print(ans)
# Judge status: Wrong Answer
n,m = map(int,input().split())
room = []
ans = []
for i in range(1,n):
  room.append([i,i])
  ans.append(0)
room.append([n,n])
ab = []
for i in range(m):
  a,b = map(int,input().split())
  ab.append([min(a,b)-1,max(a,b)-1])
ab.sort()
for i in range(len(ab)):
  if(room[ab[i][0]][1]==1):
    ans[ab[i][1]-1]=room[ab[i][0]][0]
    room[ab[i][1]][1]=1
print("Yes")
for i in range(len(ans)):
  print(ans[i])
# Judge status: Wrong Answer
from bisect import *
from heapq import *
import math
mod = 10**9+7
N, K = map(int, input().split())
A = list(map(int, input().split()))
ep = 0.1
l = 0.0
r = 10**9+1
while l+ep < r:
    x = (l+r)/2
    k = 0
    for a in A:
        k += math.floor(a/x)
        if k > K:
            break
    if k <= K:
        r = x
    else:
        l = x
print(math.ceil(l))
# Judge status: Wrong Answer
a = input()
b = input()
if a!= 1 and b!= 1:
  print(1)
elif a!= 2 and b!= 2:
  print(2)
elif a!= 3 and b!= 3:
  print(3)
# Judge status: Accepted
from collections import Counter
a,b=map(int,input().split())
def p_fact(n):
  m=n
  i=2
  a=[1]
  while n>1:
    if i>m**.5:
      a+=[n]
      break
    if n%i==0:
      n//=i
      a+=[i]
    else:i+=1  
  return a
af,bf=p_fact(a),p_fact(b)
da,db={},{}
for i in af:
  if da.get(i):da[i]+=1
  else:da[i]=1
for i in bf:
  if db.get(i):db[i]+=1
  else:db[i]=1
dc={}
for i in da:
  if db.get(i):dc[i]=min(da[i],db[i])
print(len(dc))
# Judge status: Wrong Answer
a, b, k = map(int, input().split())

upper = min(a + k, b + 1)
bottom = max(b - k, upper)

for i in range(a, upper):
    print(i)
for j in range(bottom, b + 1):
    print(j)
# Judge status: Accepted
x,y=map(int,input().split())
ans=x*y-x
if ans%y==0:
    print(-1)
else:
    print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
str_n = str(n)

if n < 10:
    print(n)
    sys.exit(0)

ans = 0
while True:
    if n // 10 == 0:
        break
    ans += 9
    n //= 10

# 最上位から1桁下が全て9の場合、繰り下がりが不要
if set(str_n[1:]) == {'9'}:
    ans += n
else:
    ans += (n - 1)

print(ans)
# Judge status: Accepted
from bisect import bisect_right
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = [0]
for i in range(1, n+1):
   d.append(d[i-1]+l[i-1])
cnt = bisect_right(d, x)
print(cnt)
# Judge status: Wrong Answer
x = int(input())

ans = x//11*2
if x%11 <= 6:
    ans += 1
else:
    ans += 2

print(ans)
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
s=input()
nat=0
intnat=0
for i in range(n):
  if s[i]=="a":
    if nat<a+b:
      print("Yes")
      nat+=1
    else:
      print("No")
  elif i=="b":
    if nat<a+b and intnat<b:
      print("Yes")
      nat+=1
      intnat+=1
    else:
      print("No")
  else:
    print("No")
# Judge status: Accepted
import math
i = list(map(int,input().split()))

x = (i[0] + i[1]) / 2.0

print(math.ceil(x))
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))

MinatoYukina = [0]*100003

for i in range (0, N):
	MinatoYukina[L[i]]+=1
	MinatoYukina[L[i]+1]+=1
	MinatoYukina[L[i]+2]+=1

print(max(MinatoYukina))
# Judge status: Wrong Answer
n,t=map(int,input().split())
ans=10**20
for i in range(n):
  c,tt=map(int,input().split())
  if tt<=t:ans=min(ans,c)
print(ans)
# Judge status: Accepted
N,M,x,y = map(int,input().split())

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

l = max(X)
r = min(Y)

print('No War' if l < r and not (y <= l or r <= x) else 'War')
# Judge status: Accepted
s = input()
days = {
	"SUN" : 7, "MON": 6, "TUE": 5, "WED": 4, "THU" : 3, "FRI" : 2,  "SAT": 1
}
print(days[s])
# Judge status: Wrong Answer
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    e = ""
    for j in range(l):
        if ((i >> j) & 1):
            e += s[j] + "+"
        else:
            e += s[j] + "-"
    if eval(e[:-1]) == 7:
        print('{}=7'.format(e))
        break
# Judge status: Wrong Answer
a = int(input())
if a == 0:
    print(0)
else:
    print(1)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
score = 0
for a, b in zip(A, B):
    diff = b - a
    if diff > 0:
        score += diff // 2
    else:
        score += diff
print("Yes") if score >= 0 else print("No")
# Judge status: Accepted
from heapq import heappush, heappop, heapify
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)


R, B = p[:x], q[:y]
heapify(R)
heapify(B)
for i in range(c):
	if min(R[0], B[0]) > r[i]:
		break
	if R[0] < B[0]:
		heappop(R)
		heappush(R, r[i])
	else:
		heappop(B)
		heappush(B, r[i])

print(sum(R) + sum(B))
# Judge status: Wrong Answer
#%%
n = int(input())
x = [0] * n
l = [0] * n
a = [[0, 0] for _ in range(n)]
for i in range(n):
    x[i], l[i] = map(int, input().split())
    a[i] = [x[i]-l[i], x[i]+l[i]]

a.sort()
#print(a)

ans = 0
t = -(10**10)
for i in range(n):
    if a[i][0] >= t:
        ans += 1
        t = a[i][1]
print(ans)
# Judge status: Wrong Answer
# 2020/01/22
# AtCoder Beginner Contest 063 - C

# Input and Sum
n = int(input())
s_list = list()
s_sum = 0
for i in range(n):
    s = int(input())
    s_list.append(s)
    s_sum = s_sum + s

# Sort
s_list.sort()
print(s_list)

# Calc
i = 0
while s_sum > 0 and s_sum % 10 == 0:
    if s_list[i] % 10 != 0:
        s_sum = s_sum - s_list[i]
    i = i + 1
    if i >= n:
        s_sum = 0

ans = s_sum

# Output
print(ans)
# Judge status: Accepted
'''
Created on 2020/08/28

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  A=[]
  B=[]
  for _ in [0]*N:
    a,b=map(int,pin().split())
    A.append(a)
    B.append(b)
  m=0
  for j in range(1,N+1):
    t=(A[-j]+m)%B[-j]
    if t!=0:
      m+=B[-j]-t
  print(m)
  return 
main()
# Judge status: Wrong Answer
M,D=map(int,input().split())
MX = 10**9+7
 
import math
if abs(M - D) >= 2:
  print(0)
elif abs(M - D) == 1:
  ANS=math.factorial(M) * math.factorial(D)
  if ANS >= MX:
    ANS %= MX
  print(ANS)
else:
  ANS=math.factorial(M)
  if ANS >= MX:
    ANS %= MX
  print(ANS * ANS * 2)
# Judge status: Accepted
a, b = map(int, input().split())
print(int(a+b/2))
# Judge status: Wrong Answer
#英小文字 cが与えられるので、
#cが母音であるか判定してください。
#ここで、英小文字のうち母音は a、e、i、o、uの 5つです。
# Judge status: Accepted
def comb(x, y):
    temp1 = 1
    temp2 = 1
    for i in range(x, x-y, -1):
        temp1 = temp1 * i % mod
    for i in range(1, y+1):
        temp2 = temp2 * i % mod
    temp = pow(temp2, mod-2, mod)
    return temp1 * temp % mod
n,a,b = map(int, input().split())
mod = 10 ** 9 + 7
total = pow(2, n, mod) - 1
a = comb(n, a)
b = comb(n, b)
print((total - a - b) % mod)
# Judge status: Accepted
a,b=map(int,input().split())
cnt=0
while a<=b:
    a*=2
    if a<=b:
        cnt+=1
print(cnt+1)
# Judge status: Accepted
N = int(input())
An = list(map(int, input().split()))

Sn = [0] * (N+1)
for i in range(1, N+1):
    Sn[i] = An[i-1] + Sn[i-1]

ans = float("inf")
for i in range(1, N):
    ans = min(ans, abs(Sn[N]-Sn[i] - Sn[i]))

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

abc=list()
for i in range(n):
    abc.append([int(e) for e in input().split()])

A=[]
B=[]
C=[]

A.append(abc[0][0])
B.append(abc[0][1])
C.append(abc[0][2])

for i in range(1,n):
    a = abc[i][0] + max(B[-1],C[-1])
    b = abc[i][1] + max(A[-1],C[-1])
    c = abc[i][2] + max(A[-1],B[-1])
    A.append(a)
    B.append(b)
    C.append(c)

print(max(A[-1],B[-1],C[-1]))
# Judge status: Accepted
N,M=map(int,input().split())
box=[1 for _ in range(N)]
ans=[0 for _ in range(N)]
ans[0]=1
for i in range(M):
    x,y=map(int,input().split())
    box[x-1]-=1
    box[y-1]+=1
    if ans[x-1]==1:
        ans[y-1]=1
    if box[x-1]==0:
        ans[x-1]=0
print(sum(ans))
# Judge status: Wrong Answer
#from itertools import combinations 
import sys
import math as mt
input=sys.stdin.buffer.readline  
t=1


#t=int(input())
for _ in range(t):
    n=int(input())
      
    #n,m,k=map(int,input().split())
    l=list(map(int,input().split()))
    suma=sum(l[:])
    mini=min(l[:])
    print(suma-mini)
# Judge status: Accepted
s=str(input())
a=len(s)
b=['hi','hihi','hihihi','hihihihi','hihihihihi']
if a%2!=0:
  print('No')
elif s in b:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
flg = True
for z in range(100):
  if X < z <= Y:
    for xn in x:
      if xn < z:
        for yn in y:
          if yn < z:
            flg = False 
        if flg:
          print('No War')
          exit()
        else:
          flg = True
print('War')
# Judge status: Wrong Answer
N, K = map(int, input().split())

for i in range(1, N**N):
  if N < K**i:
    print(i)
    break
# Judge status: Accepted
from collections import Counter
n, m = map(int, input().split())
a = list(map(int, input().split()))
d = Counter(a)

for i in range(m):
    b, c = map(int, input().split())
    d[c] += b
key = list(d.keys())
key.sort(reverse = True)

ans = 0
for k in key:
    if n <= d[k]:
        ans += k*n
        break
    else:
        ans += k*d[k]
        n -= d[k]

print(ans)
# Judge status: Accepted
I = lambda: map(int, input().rstrip().split())
s = input()
flag = 1
for i in range(len(s)):
    if s[i] == "A" and flag == 1:
        start = i
        flag = 0
    elif s[i] == "Z":
        end = i
print(end - start + 1)
# Judge status: Accepted
n, r=map(int,input().split())
if n<10:
  print(100*(10-n)+r)
else:
  print(r)
# Judge status: Accepted
a, b, c = map(int, input().split())
k = int(input())
print(a + b + c + max(a, b, c) * 2 ** k - max(a, b, c))
# Judge status: Wrong Answer
s = input()
n = len(s)
ans = 0
for i in range(n):
  res =0 
  d = int(s[i])
  if d==0:
    continue
  else:
    d -= 1
  for c in s[:i]:
    res += int(c)
  res += d
  res += (n-i-1)*9
  ans = max(ans, res)
print(ans)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
print(int((b-a+1)/c))
# Judge status: Accepted
a,b,c = map(int,input().split())
print(min(b//a, c))
# Judge status: Accepted
# ROT N

# libraries
from string import ascii_uppercase as ALP

# input
N = int(input())
S = input()

# solve
ALPALP = ALP + ALP

def f(s, N = N):
    return ALPALP[ALPALP.index(s) + N]

res = ''.join([f(s) for s in S])

# output
print(res)
# Judge status: Accepted
import math
def findAngle(h,m):
	hour=(h*360)/12+(m*360)/(12*60)
	mint=(m*360)/60
	angle=abs(hour-mint)
	if(angle>180):
		angle=360-angle
	return angle
def dist(a,b,h,m):
  x=a**2+b**2-2*a*b*math.cos(math.radians(findAngle(h,m)))
  return x**0.5
a,b,h,m=map(int,input().split())
print(dist(a,b,h,m))
# Judge status: Wrong Answer
s = list(str(input()))

for i in range(2**3):
    t = ['']
    ans = int(s[0])
    for j in range(3):
        if (i >> j) & 1:
            t.append('+')
            ans += int(s[j+1])
        else:
            t.append('-')
            ans -= int(s[j+1])
    if ans == 7:
        siki = ''
        for i in range(4):
            siki += t[i]+s[i]
        siki += '=7'
        print(siki)
# Judge status: Accepted
n,k=map(int,input().split())
s=input()

score=0
for i in range(n-1):
    if s[i]==s[i+1]:
        score+=1
ans=min(score+2*k,n-1)
print(ans)
# Judge status: Accepted
a=int(input())
b=input().split(" ")
sum1=1
 
if "0" in b:
    print("0")
else:
    for i in range(a):
        sum1=sum1*int(b[i])
        if sum1>10**18:
            sum1=-1
            break
    print(sum1)
# Judge status: Wrong Answer
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect

n=int(input())
a=list(map(int,input().split()))
n2=n4=0

for i in range(n):
    if a[i]%2==0:
        n2+=1
    if a[i]%4==0:
        n4+=1
if n2==n:
  print("Yes")
  exit()
if n4>=(n+2)//3:
    print("Yes")
else:
    if (n2-n4)>=n-3*n4+1:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
n=int(input())
s=input()

a=0
b=0

for i in s:
  if i=='(':
    a+=1
  else:
    if a!=0:
      a-=1
    else:
      b+=1

ans='('*b+s+')'*a
print(ans)
# Judge status: Wrong Answer
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
else:
    tmp = [0 for _ in range(10 ** 5)]
    for i in range(N):
        tmp[D[i]] += 1

    ans = 1
    flag = False
    for i in range(10 ** 5 - 1):
        if tmp[i+1] == 0:
            break

        ans = ans * (tmp[i] ** tmp[i+1]) 

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

Physical_strength = 0
flag = 0
n=0
while 1:
    n += 1
    flag=0
    for Xi in X:
        flag += (Xi-n)**2
    if n == 1:
        Physical_strength = flag
    if Physical_strength > flag:
        Physical_strength = flag
    elif Physical_strength < flag and n > N:
        break

print(Physical_strength)
# Judge status: Wrong Answer
n = int(input())
k = int(input())
x = int(input())
y = int(input())

fee1 = n * x
fee2 = y * (n - k)

if n > k :
    print(fee1 + fee2)
else:
    print(fee1)
# Judge status: Accepted
s = input()
len_s = len(s)

ans=0
for i in range(1,len_s//2+1):
    if s[-i]!=s[-len_s-1+i]:
        ans+=1
print(ans)
# Judge status: Wrong Answer
s=str(input())

a=s[0]
b=s[1]
c=s[2]
d=s[3]

if a==b and b==c and c==d:
  print("NO")
elif a==b and c==d:
  print("Yes")
elif a==c and b==d:
  print("Yes")
elif a==d and b==c:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
x = int(input())
if (-1+(1+8*x)**0.5)/2 == int((-1+(1+8*x)**0.5)/2):
    print(int((-1+(1+8*x)**0.5)/2))
else:
    print(int((-1+(1+8*x)**0.5)/2)+1)
# Judge status: Accepted
n=int(input())
x=list(map(int,input().split()))
y=sorted(x)
a=[y[n//2-1],y[n//2]]

for i in range(n):
  print(a[1] if x[i]<= a[0] else a[0])
# Judge status: Accepted
N,Q = map(int,input().rstrip().split())
S = input().rstrip()
a = [0]*N
for i in range(N):
    if i > 1:
        a[i] = a[i-1]
    if i != 0 and S[i-1]=='A' and S[i] == 'C':
        a[i] += 1
for _ in range(Q):
    l, r = map(int,input().rstrip().split())
    print(a[r-1]-a[l-1])
# Judge status: Accepted
n=int(input())
flag=0

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

for i in range(n):
	if(a[i]%2==0):
		if(a[i]%3!=0 and a[i]%5!=0):
			flag=1

if(flag==1):
	print("DENIED")
else:
	print("APPROVED")
# Judge status: Wrong Answer
from collections import Counter

n = int(input())
al = sorted(list(map(int, input().split())), reverse=True)

c = Counter(al)

print(c)

l4 = []
l2 = []

for k, v in c.items():
    if v >= 4:
        l4.append(k)
    elif v >= 2:
        l2.append(k)

s1, s2 = 0, 0

if len(l4) > 0:
    s1 = l4[0]*2
if len(l2) >= 2:
    s2 = l2[0] * l2[1]

if s1 != 0 or s2 != 0:
    print(max(s1, s2))
else:
    print(0)
# Judge status: Accepted
x, y = (int(x) for x in input().split())
ans = 0
while x <= y:
    ans += 1
    x *= 2
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
S = list(str(input()))

S[K-1] = S[K-1].lower()

print("".join(S), end='')
# Judge status: Accepted
N, K = map(int, input().split())
X = list(map(int, input().split()))
T = 10**18
for i in range(N-K+1):
  if X[i+K-1]<=0:
    T = min(T, -X[i])
  elif X[i]>=0:
    T = min(T, X[i+K-1])
  else:
    T = min(T, X[i+K-1]-X[i]+min(-X[i], X[i+K-1]))
print(T)
# Judge status: Accepted
N,X,T = map(int,input().split())
if N % X ==0:
    a = int(N/X)
    print(a*T)
else:
    a = int(N/X)+1
    print(a*T)
# Judge status: Wrong Answer
Row = int(input())
List = []
for i in range (Row):
  List.append(list(map(int, input().split())))
Slist = [0]*Row
for i in range(Row):
  Slist[i] = abs(List[i][0]) + abs(List[i][1])
Slist.sort()
res = Slist[Row-1] - Slist[0]
print(res)