peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def factorial_mod(n, mod):
    ret = 1
    for i in range(1, n + 1):
        ret *= i
        ret %= mod
    return ret


def main():
    N, M = map(int, input().split())

    mod = 10 ** 9 + 7
    factorial = factorial_mod(N, mod) * factorial_mod(M, mod)

    if abs(N - M) > 1:
        print(0)
    elif N == M:
        print((factorial * 2) % mod)
    else:
        print(factorial % mod)


if __name__ == "__main__":
    main()
# Judge status: Accepted
l = int(input())
num = l/3
print(num**3)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int, input().split()))
sum=0
for i,ii in enumerate(a[:-1]):
  for j in a[i+1:]:
    sum+=ii^j
print(int(sum%(1e9+7)))
# Judge status: Accepted
a,b = map(int,input().split())
if a > 12:
  print(b)
elif 6<= a<=12:
  print(b//2)
else:
  print(0)
# Judge status: Accepted
A,B=map(int,input().split())

if A<9 and B<9:
    print("Yay!")
else:
    print(":(")
# Judge status: Wrong Answer
import numpy as np
N = input()
list = list(map(int,input().split(' ')))

list = np.array(list)
A = list[list%2 == 0]
B = np.unique(np.append(list[list%6 == 0],(list[list%10 == 0])))

if len(A) ==0:
        print('APPROVED')
elif len(B) ==0:
    print('DENIED')
else:
    if len(A) == len(B) :
        print('APPROVED')
    else:
        print('DENIED')
# Judge status: Accepted
n,m=map(int,input().split())
if n*2>=m:
  print(m//2)
else:
  print((n*2+m)//4)
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,r = [int(i) for i in readline().split()]

if n >= 10:
    print(r)
else:
    print(r-100*(10-n))
# Judge status: Accepted
n, m = map(int, input().split())
C = [0]*(n+1)
C[1] = 1
D = [1]*(n+1)
for _ in range(m):
  x, y = map(int, input().split())
  if C[x]:
    C[y] = 1
    if D[x] == 1:
      C[x] = 0
  D[x] -= 1
  D[y] += 1
ans = sum(C)
print(ans)
# Judge status: Accepted
a, b = map(int,input().split())
print((a+b+1)//2)
# Judge status: Wrong Answer
n, x, t = map(int, input().split())
print(n//x*t) if t % x == 0 else print((n//x+1)*t)
# Judge status: Wrong Answer
n ,d = map(int, input().split())
if n == d:
    print(1)
elif (n - 2*d) <= d:
    print(d)
elif (n - 2*d) > d:
     print(d -1)
# Judge status: Accepted

n,m = map(int,input().split())
ans = [0] * m
info = []

for i in range(n):
    info = list(map(int,input().split()))
    for j in range(1,info[0]+1):
        ans[info[j]-1] += 1
#    print(ans)

print(ans.count(n))
# Judge status: Accepted
a,b,c = map(int,input().split())
if a+b == c or a+c == b or b+c == a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def gcd(a, b):
    if a < b :
        a, b = b, a
    while True:
        a, b = b, a % b
        if b == 0:
            return a

a, b = map(int, input().split())
print(int(a * b / gcd(a, b)))
# Judge status: Wrong Answer
a, b, c = list(map(int, input().split()))

d = c - a

if d>=0:
    if d <= b:
        print("YES")
else:
    print("NO")
# Judge status: Accepted
a,b = (int(x) for x in input().split())
ans = 0
for i in range(2):
    ans += max([a,b])
    if ans==a:
        a -= 1
    else:
        b -= 1
print(ans)
# Judge status: Accepted
n = input()
if n[1:] == "9" * (len(n)-1) :
    print(int(n[0])+9*(len(n)-1))
else :
    print(int(n[0])+9*(len(n)-1)-1)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
ans=0
import collections
c=collections.Counter(a)
values,counts=zip(*c.most_common())
lv=list(values)
lc=list(counts)
temp=[]
for i in range(0,len(lc)):
  if lc[i]>=2:
    temp.append(lv[i])
temp.sort(reverse=True)
if len(temp)>=2:
  ans=temp[0]*temp[1]
print(ans)
# Judge status: Accepted
n = int(input())
s = list(input())

ans = 0
for i in range(1,n-1):
  t = len(set(s[:i]) & set(s[i:]))
  if ans < t: ans = t
print(ans)
# Judge status: Accepted
h1,m1,h2,m2,K = map(int,input().split())
ans = (60*h2+m2) - (60*h1+m1) -K
print(ans)
# Judge status: Accepted
import numpy as np

N, W = map(int, input().split())
pairs = list(tuple(map(int, input().split())) for _ in range(N))

dp = np.zeros((N+1, W+1), np.int64)

for (i, (w, v)) in enumerate(pairs):
    dp[i+1] = dp[i]
    dp[i+1, w:] = np.maximum(dp[i+1, w:], dp[i, :W-w+1] + v)

print(np.amax(dp[N]))
# Judge status: Accepted
n = int(input())
v = [int(i) for i in input().split()]
v.sort()
ans = (v[0]+v[1])/2
count = 0
for i in range(2,n):
    count=(ans+v[i])/2
    ans = count
if n <=2:
    print(sum(v)/2)
else:
    print(count)
# Judge status: Wrong Answer
print("YNEOS"["000" not in "".join([str(eval(input().replace(" ","-")))for _ in "_"*int(input())])::2])
# Judge status: Accepted
import math
def lcm(x,y):
    return(x*y)//math.gcd(x,y)

a,b,c,d=map(int,input().split())
e=b//c-(a-1)//c
f=b//d-(a-1)//d

g=b//lcm(c,d)-(a-1)//lcm(c,d)
ans=e+f-g
#print(e,f,g)
print(b-a+1-ans)
# Judge status: Accepted
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

L = abs(A - B)
S = V - W
if S * T >= L:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
N,K=map(int,input().split())
A=list(map(int,input().split()))
print((N-1)/(K-1))
# Judge status: Accepted
a, b, c, d = map(int, input().split())
if abs(c-a) <= d or (abs(b-a) <= d and abs(c-b) <= d):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import numpy as np
import math
import collections

S = input()
print(S.replace("?", "D"))
# Judge status: Accepted
import sys
from decimal import Decimal

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    A, B = map(Decimal, readline().split())
    print(int(A * B))

    return


if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()
s = "2018" + s[4:]
print(s)
# Judge status: Accepted
n, k = map(int, input().split())
r,s,p = map(int, input().split())
t = list(input())

lis = []
for i in t:
    if i == 'r':
        lis.append('p')
    elif i == 's':
        lis.append('r')
    else:
        lis.append('s')

ans1 = 0
for i in range(k, len(lis)):
    if lis[i] == lis[i-k]:
        lis[i] = 'o'

rc = lis.count('r') * r
sc = lis.count('s') * s
pc = lis.count('p') * p

print(rc+sc+pc)
# Judge status: Accepted
n = int(input())
al=[]
bl=[]
for i in range(n):
    a , b = map(int, input().split())
    al.append(a)
    bl.append(b)
al.sort()
bl.sort()
if n%2==1:
    mi = al[n//2]
    ma = bl[n//2]
    print(int(ma-mi)+1)
else:
    mi = (al[n//2-1]+al[n//2])/2
    ma = (bl[n//2-1]+bl[n//2])/2
    print(int((ma-mi)*2+1))
# Judge status: Accepted
s = input()
x = len(s)
while x > 0:
    x -= 2
    s = s[:x]
    if s[:x//2] == s[x//2:]:
        print(x)
        break
# Judge status: Accepted
#!/usr/bin/env python3

S = input()
T = input()
if S == T[:-1]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
from math import acos
from math import atan
a,b,x = map(int,input().split())
x /= a
pi = acos(-1.0)
if x > a * b / 2:
    print(atan(2 * (a * b - x) / (a ** 2)) * 180 / pi)
if x <= a * b / 2:
    print(atan((b ** 2) / 2 * x) * 180 / pi)
# Judge status: Accepted
a,b,c=[int(i) for i in input().split()]
if b-a==c-b:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    A,B,C,K = map(int,input().split())
    if K%2 == 0:
        ans = A - B
    else:
        ans = B - A
    if abs(ans) > 1000000000000000000:
        ans = 'Unfair'
    print(ans)
if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
S = []
for i in range(N):
    s = int(input())
    S.append(s)
sumS = sum(S)
if sumS % 10 != 0:
    print(sumS)
else:
    S = sorted(S)
    flag = 0
    for j in range(N):
        if S[j] % 10 != 0:
            print(sumS - S[j])
            flag = 1
            break
    if flag == 0:
        print(0)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))

a.sort()
m = a[-1]
import bisect
j = bisect.bisect_left(a,m//2)
if j==n-1:
    j-=1
print(m,a[j])
# Judge status: Accepted
M = 10**9 + 7
s = int(input()) - 3

f = [1]
for i in range(1, s + 1):
  f.append(f[-1] * i % M)

r = 0
for k in range(s // 3 + 1):
  r += f[s] * pow(f[k], M - 2, M) * pow(f[s - k], M - 2, M)
  s -= 2

print(r % M)
# Judge status: Wrong Answer
N = int(input())
v = list(map(int, input().split()))

v.sort()

print(v)


for i in range(N - 1):
    temp = (v[0] + v[1]) / 2
    v = v[2:]
    v.append(temp)
    v.sort()

print(v[0])
# Judge status: Accepted
from  collections import Counter

s = list(input())

c0 = s.count("0")
c1 = s.count("1")

print(min(c0, c1)*2)
# Judge status: Accepted
n=int(input())

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

c=[]
ans=0
if ab[n-1][0]%ab[n-1][1]!=0:   
    ans+=ab[n-1][1]-(ab[n-1][0]%ab[n-1][1])
#print(ab[n-1][0],ab[n-1][1],ans)
for i in range(n-2,-1,-1):
    ab[i][0]+=ans
    if ab[i][0]%ab[i][1]!=0:
        
        ans+=ab[i][1]-(ab[i][0]%ab[i][1])
    #print(ab[i][0],ab[i][1],ans)
print(ans)
# Judge status: Wrong Answer
x, a, b = map(int, input().split())
if b <= a:
  print('delicious')
elif b <= x:
  print('safe')
else:
  print('dangerous')
# Judge status: Accepted
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
l=[list(map(int,input().split())) for i in range(m)]
l=sorted(l,key=lambda x:x[1], reverse=True)

p=0
comp=[]
for b,c in l:
  comp+=[c]*b
  p+=b
  if p>=n:
    break

ans=0
for i in range(n):
  if i<len(comp):
    ans+=max(a[i],comp[i])
  else:
    ans+=a[i]
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

lis = []
for a in A:
    S = 0
    i = 0
    for i in range(30):
        s = 0 | (a >> i)
        if i%2 == 0:
            if s == 1:
                S += 2**i
        else:
            if s == 0:
                S += 2**i
        i += 1
    lis.append(S)
print(*lis)
# Judge status: Accepted
A,B,K=map(int,input().split())
S=(set(range(A,A+K))|set(range(B-(K-1),B+1)))
S=list(S)
S.sort()

for x in S:
    if A<=x<=B:
        print(x)
# Judge status: Accepted
def f(M,N):
    if M==N:
        return 'Yes'
    else:
        return "No"
N,M=map(int,input().split())
print(f(M,N))
# Judge status: Wrong Answer
s = input()
a = 0
for i in range(3):
    if s[i] == 'R':
        a += 1
    else:
        break
print(a)
# Judge status: Wrong Answer
n = int(input())

count = [0] * 10001

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            temp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if(1 <= temp and temp <= 10000):
                count[temp] += 1

for i in range(n):
    print(count[i])
# Judge status: Accepted
import math
A, B = map(int, input().split())
if B < A:
    A, B = B, A
a = []
while A % 2 == 0:
    a.append(2)
    A //= 2
f = 3
while f * f <= A:
    if A % f == 0:
        a.append(f)
        A //= f
    else :
        f += 2
if A != 1:
    a.append(A)
ans = 0
for i in set(a):
    if B % i == 0:
        ans += 1
print(ans+1)
# Judge status: Wrong Answer
def solve():
  n = int(input())
  a = list(map(int, input().split()))
  state, cut = -1, 0
  for i in range(n-1):
    #print(i, cut, state)
    if a[i] < a[i+1]:
      if state != 1:
        cut += 1
      state = 1
    else:
      if state != 0:
        cut += 1
      state = 0
  return 0
 
if __name__ == "__main__":
  solve()
# Judge status: Accepted
n = int(input())
a = sorted(list(map(int,input().split())))
sum = 0
List_sum = []
Counter = []
Count_num = (a[-1] - a[0])+1
for i in range(Count_num):
    Counter.append(a[0]+i)
    if Counter[-1] == a[-1]:
        break
if len(set(a)) == 1:
    print(0)
else:
    for i in Counter:
        for j in a:
            sum += (i-j)**2
        else:
            List_sum.append(sum)
            sum = 0
    else:
        print(min(List_sum))
# Judge status: Accepted
N,M = map(int, input().split())

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

if N< T:
    print("-1")
else:
    print(N-T)
# Judge status: Accepted

N = int(input())
def dfs(s, l, char_num):
    if l == N:
        print(s)
    else:
        for i in range(char_num+1):
            ns = s+chr(97+i)
            dfs(ns, l+1, len(set(ns)))

dfs('a',1, 1)
# Judge status: Accepted
s = input()
ans = 753
for i in range(len(s)-2):
  ans = min(ans, abs(int(s[i:i+3])-753))
print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
su=0
mi=2000000
for i in range(n):
  su+=a[i]
  
c=0  
for i in range(n):
  c+=a[i]
  left=su-c
  mi=min(mi,max((c-left),(left-c)))

print(mi)
# Judge status: Accepted
import math
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
m = max(math.ceil(N/A),math.ceil(N/B),math.ceil(N/C),math.ceil(N/D),math.ceil(N/E))
print(m+4)
# Judge status: Wrong Answer
# 文字列を取得
s = input()

# バラバラにして並び替え
slist = list(s)
slist.sort()
print(slist)

if slist[0] == slist[1] and slist[2] == slist[3] and slist[0] != slist[2]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import math
K = int(input())
A,B = list(map(int,input().split()))
num = 0
while num <=2000:
    num += K
    if num >1000:
        print("NG")
        break
    if num <= B and A <= num:
        print("OK")
        break
    else:
        continue
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
dp=[0]*(10**5+3)
for i in range(N):
  for j in range(3):
    dp[a[i]+j]+=1
print(max(dp))
# Judge status: Accepted
n = int(input())
tmp = 1
 
for i in range(1,10**6+1):
  if n%i == 0:
    if i <= n//i:
      tmp  = i
    else:
      break
  elif tmp == 1 and i >= n/i:
    break
      
print(tmp + (n//tmp) -2)
# Judge status: Accepted
x, a, b = map(int, input().split())
if b <= a:
  print("delicious")
elif b - a <= x:
  print("safe")
elif b - a > x:
  print("dangerous")
# Judge status: Accepted
n = input()
if n[0] == '9' or n[1] == '9':
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a,b = map(int,input().split())
dum = a+b
if a % 3 == 0 or b % 3 == 0 or dum % 3 == 0:
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
K, S = map(int, input().split())
cnt = 0
for x in range(K+1):
    for y in range(min(K,S-x)+1):
        z = S - x - y
        if z <= K:
            cnt += 1
print(cnt)
# Judge status: Accepted
def main():
    from itertools import takewhile

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

    def accumulate(a):
        s = 0
        yield s
        for x in L:
            s += x
            yield s

    ans = len(tuple(takewhile(lambda s: s <= X, accumulate(L))))

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
lst = list(map(int,input().split()))
mod = 998244353
c = dict(Counter(lst))
c = dict(sorted(c.items(), key=lambda x:x[0]))

ans = 1
pre_v = 1
for e,(k,v) in enumerate(c.items()):
    print(e,k,v)
    if e==0 and k!=0:
        ans = 0
        break
    elif e!=k:
        ans = 0
        break
    else:
        ans = ans*pow(pre_v, v, mod)%mod
        pre_v = v
print(ans%mod)
# Judge status: Accepted
n, m = map(int, input().split())

roads = [0 for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    roads[a-1] += 1
    roads[b-1] += 1

for road in roads:
    print(road)
# Judge status: Accepted
As = sorted(list(map(int, input().split())))
if As[0] + As[1] == As[2]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = input()
red = []
for i in range(n):
    red.append(raw_input())
k = input()
blue = []
for j in range(k):
    blue.append(raw_input())
ans = 0
for r in red:
    counterR = 0
    counterB = 0
    for word in red:
        if word == r:
            counterR += 1
    for word in blue:
        if word == r:
            counterB += 1
    if ans < counterR - counterB:
        ans = counterR - counterB
print ans
# Judge status: Accepted
S=[i for i in input()]
flg = True
while len(S)>=2:
    if S[0]=="h" and S[1]=="i":
        del S[0:2]
    else:
        flg = False
        break
if flg and len(S)==0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
if len(a) == 1:
    res = a[0]
elif len(a) % 2 == 0:
    res = " ".join(map(str, a[-1::-2] + a[::2]))
else:
    res = " ".join(map(str, a[-1::-2] + a[1::2]))
print(res)
# Judge status: Accepted
N=int(input())
s=list(map(int, input().split()))

maxans=0
pre=s[0]
tmpans=0
for i in range(1,N):
  now=s[i]
  if pre>=now:
    tmpans+=1
  else:
    tmpans=0
  pre=now
  maxans=max(tmpans, maxans)
print(maxans)
# Judge status: Accepted
s = input()
if (s[0]==s[1] and s[1]==s[2]):
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
sys.setrecursionlimit(10**6)

n,m = na()
g = [[] for i in range(n)]
for i in range(m):
    a,b = na()
    a,b = a-1,b-1
    g[a].append(b)
    g[b].append(a)

for i in g[0]:
    if n-1 in g[i]:
        print('POSSIBLE')
        exit()

print('INPOSSIBLE')
# Judge status: Wrong Answer
def min_cost(h, n, k):
    dp = [10**6 for i in range(n)]
    dp[0] = 0
    for i in range(1, n):
        for k in range(1, k + 1):
            if (i - k) >= 0:
                dp[i] = min(abs(h[i] - h[i - k]) + dp[i - k], dp[i])


    print(dp[n - 1])

n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
min_cost(h, n, k)
# Judge status: Accepted
n, m, k = map(int, input().split())
ok = False
for i in range(n+1):
    for j in range(m+1):
        if k == (n*j + m*i) - 2*i*j:
            ok = True

if ok:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
S = input()

if S=='AAA' or S=='BBB':
  print('No')
else:
  print('Yes')
# Judge status: Accepted
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7
x = int(input())
cnt = 0
if x<=6:
    print(1)
elif x<=11:
    print(2)
else:
    if x%11 == 0:
        print((x//11)*2)
    elif x%11 > 6:
        print(((x//11)+1)*2)
    else:
        print((x//11)*2 + 1)
# Judge status: Wrong Answer
t=int(input())
if(360%t==0):
  print(int(360/t))
else:
  t=360/t
  s=360%t
  print(int(t)*s)
# Judge status: Accepted
w,h,n = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(n)]
 
xmin,xmax,ymin,ymax = 0,w,0,h
 
for a in A:
  if a[2] == 1:
    xmin = max(xmin, a[0])
  if a[2] == 2:
    xmax = min(xmax, a[0])
  if a[2] == 3:
    ymin = max(ymin, a[1])
  if a[2] == 4:
    ymax = min(ymax, a[1])
    
S = (xmax-xmin) * (ymax-ymin)
if S < 0 or xmin > xmax or ymin > ymax:
  S = 0
print(S)
# Judge status: Accepted
n=int(input())
s=input()
t=input()
ans=0
for i in range(n):
  if s[i:] == t[:n-i]:
    ans = max(n-i,ans)
print(2*n-ans)
# Judge status: Accepted
n, h = map(int, input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i], b[i] = map(int, input().split())

a.sort(reverse=True)
b.sort(reverse=True)
ans = 0
while True:
    if h <= 0:
        break
    if len(b) != 0 and b[0] > a[0]:
        c = b.pop(0)
        h -= c
        ans += 1
    else:
        ans += h // a[0]
        if h%a[0] != 0:
            ans += 1
        break

print(ans)
# Judge status: Accepted
n = int(input())
ABC = [list(map(int, input().split())) for i in range(n)]

# i日目にjを選択した後の幸福度 dp[i][j]
dp = [[0 for j in range(3)] for i in range(n + 1)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + ABC[i][k])

print(max(dp[-1]))
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    t=input()
    if t[:-1]==s:
        print('Yes')
    else:
        print('No')
resolve()
# Judge status: Wrong Answer
n, m = map(int, input().split())

def lp(animal, row):
    for i in range(1, n+1):
        row *= i
    return row

result = abs(n-m)
limit = 10**9+7
row = 1
if result >= 2:
    print(0)
elif result == 1:
    row = lp(n, row)
    row = lp(m, row)
elif n == m:
    row = lp(n, row)
    row = lp(m, row)
    row *= 2

print(row%limit)
# Judge status: Wrong Answer
n, s = int(input()), input()
t = s.lstrip(")").rstrip("(")
a, b = map(t.count, "()")
x, y = map(s.count, "()")
x -= a
y -= b
if a>b:
        a -= b
        b = 0
else:
        b -= a
        a = 0
print("("*(b+y) + s + ")"*(a+x))
# Judge status: Accepted
import math
A, B = map(int,input().rstrip().split())
ans = math.ceil((B-1)/(A-1))
print(ans)
# Judge status: Wrong Answer
K=int(input())
A,B=map(int,input().split())
i=0
ok=0
while i*K <= B:
    if A <= i*K <= B:
        print("OK")
        ok=1
    i=i+1
if ok!=1:
    print("NG")
# Judge status: Accepted
N,K,S=map(int,input().split())
ans=[]

if S<10**9:
    ans=[S for i in range(K)]
    ans+=[S+1 for i in range(N-K)]
else:
    ans=[S for i in range(K)]
    ans+=[1 for i in range(N-K)]

print(*ans)
# Judge status: Accepted
s = input()
t = input()
r = 0
for i in range(len(s)):
    if s[i] != t[i]:
        r += 1
print(r)
# Judge status: Wrong Answer
X,Y,N=map(int,input().split())
max_X=X
max_Y=Y
current_min_x=0
current_min_y=0
current_max_x=X
current_max_y=Y
xy=[list(map(int,input().split())) for _ in range(N)]
for x,y,a in xy:
  n=0
  if a==1:
    current_min_x=max(current_min_x, x)
  elif a==2:
    current_max_x=min(current_max_x, x)
  elif a==3:
    current_min_y=max(current_min_y, y)
  elif a==4:
    current_max_y=min(current_max_y, y)
result=(current_max_x-current_min_x)*(current_max_y-current_min_y)
print(result if result > 0 else 0)
# Judge status: Accepted
N, K, S = map(int, input().split())
a = [S for i in range(K)]
if S == 10 ** 9:
    S -= 2
for i in range(N - K):
    a.append(S + 1)
print(*a)
# Judge status: Accepted
import math

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

max_l = max(A) + 1
min_l = 0
cur = (max_l + min_l) // 2


def check(l):
    count = 0
    for a in A:
        count += math.ceil(a / l) - 1

    return count <= K


while True:
    if check(cur):
        max_l = cur + 1
    else:
        min_l = cur

    if cur == (max_l + min_l) // 2:
        break

    cur = (max_l + min_l) // 2

print(cur)
# Judge status: Accepted
n = int(input())
arr = [0]*10100
for i in range(1,110):
    for j in range(1,110):
        for k in range(1,110):
            s = i*i+j*j+k*k+i*j+j*k+k*i;
            if s<10100:
                arr[s]+=1
for i in range(n):
    print(arr[i+1])
# Judge status: Accepted
MOD = 10**9+7

S = int(input())
memo = {1:0,2:0,3:1,4:1,5:1}

def Redi(n):
    if n in memo:
        return memo[n]
    else:
        ans = 1
        for i in range(3,n-2):
            ans += Redi(n-i)
        memo[n] = ans % MOD
        return memo[n]

print(Redi(S))
# Judge status: Accepted
import sys
input = sys.stdin.readline

S = input().rstrip()
S32 = S[2:-1]
trimed_S = S32.replace('C', '', 1)
ac_cut_S = S.replace('A', '', 1).replace('C', '', 1)

ans = 'AC'
if S[0] != 'A':
  ans = 'WA'
elif (not ac_cut_S.islower()) or len(S32) - len(trimed_S) != 1:
  ans = 'WA'

print(ans)
# Judge status: Wrong Answer
from bisect import bisect_left, bisect_right

def LIS(arr):  #bisect.bisect_left
    n = len(arr)
    lis = [-10**18]
    for a in arr:
        if a >= lis[-1]:
            lis.append(a)
        else:
            lis[bisect_left(lis, a)] = a
    return len(lis) - 1

import sys
input = sys.stdin.readline

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

print(LIS(A))
# Judge status: Wrong Answer
n, m, x = map(int, input().split())
bk = [list(map(int, input().split())) for _ in range(n)]
pr = 10 ** 6
for i in range(2 ** n):
    ef = [0] * (m + 1)
    for j in range(n):
        if i >> j & 1:
            ef = [p + q for (p, q) in zip(ef, bk[j])]
    for k in range(1, m + 1):
        if ef[k] < x:
            break
        if k == m:
            pr = min(pr, ef[0])
print(pr if pr != 10 ** 6 else -1)
# Judge status: Accepted
A, B, K = list(map(int,input().split()))

# A から Kを引く
A = A - K
# Aが負なら，その負の大きさの分だけBから引く
if A < 0:
    B = B + A
    A = 0
# Bが負なら0にする
if B < 0: B = 0

print(A,B)