peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
a,b,c=map(int,input().split())

def block(a,b,c):
    blocksum=a*b*c
    if a%2==0 or b%2==0 or c%2==0:
        print(0)
        return
    else:
        if a!=1:
            print(blocksum-2*(a//2)*b*c)
block(a,b,c)
# Judge status: Accepted
S=int(input())
if S == 10**18:
    print(0,0,10**9,1,0,10**9)
else:
    q,r = S//10**9, S%10**9
    print(0,0,10**9,1,10**9-r,q+1)
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range (A+1):
	for j in range (B+1):
		tmp = i*500 + j*100
		#print(tmp)
		k = (X-tmp) / 50
		if k>=0 and k <= C:
			count +=1
print(count)
# Judge status: Accepted
n,k=map(int,input().split())
s=input()
un=0
for i in range(1,len(s)):
  if s[i-1]!=s[i]:
    un+=1
print((n-1)-max(0,un-2*k))
# Judge status: Accepted
N, M, X, Y = map(int, input().split())
x = sorted(map(int, input().split()))
y = sorted(map(int, input().split()))

if x[-1] < y[0]:
  if Y <= x[-1] or y[0] <= X:
    print('War')
  else:
    print('No War')
else:
  print('War')
# Judge status: Accepted
S = input()

ans = 0 
ans_lis = [0]

for i in range(len(S)):
    if S[i] in "ACGT":
        ans = ans + 1 
        if i == (len(S)-1):
            ans_lis.append(ans)
    else:
        ans_lis.append(ans)
        ans = 0 

print(max(ans_lis))
# Judge status: Accepted
x = int(input())
p = 599
for i in range(8):
    
    if x <= p:
        print(8-i)
        exit()
    p += 200
# Judge status: Accepted
from collections import deque

n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]

t.sort()

q = deque(t)
cnt = 1
ans = 1
curr = q.popleft()

while q:
    tmp = q.popleft()
    if tmp - curr <= k and cnt < c:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        curr = tmp

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

input_num = [0 for _ in range(n)]

for i in range(n-1, -1, -1):
    tmp = 0
    j = i+i+1
    while j < n:
        tmp += input_num[j]
        j += i+1

    if tmp % 2 != a[i]:
        input_num[i] = 1

print(sum((input_num)))
for i, j in enumerate(input_num):
    if j:
        print(i+1, end=' ')
# Judge status: Accepted
N, K = map(int, input().split(" "))
logs = list(map(int, input().split(" ")))

def cal( max_length ):
    cut_count = 0 
    for l in logs :
        cut_count += (l//max_length -1)
        if l % max_length != 0 :
            cut_count += 1
    return cut_count <= K 

i = 1 
j = max(logs)
while i < j :
    m = (i+j)//2
    if cal(m) :
        j = m
    else :
        i = m+1

print(i)
# Judge status: Accepted
n=int(input())
L=[list(map(int,input().split())) for _ in range(n)][::-1]
c=0
for a,b in L:
  a+=c
  c+=(-a)%b
print(c)
# Judge status: Accepted
import math
a,b=map(int,input().split())

print(math.ceil(a/b))
# Judge status: Accepted
import numpy as np
from math import ceil

n,m = map(int,input().split())
a = list(map(int,input().split()))
a = [x//2 for x in a]
lcm = np.lcm.reduce(a)
ans = 0

for i in a:
    if lcm // i % 2 == 0:
        break
else:
    ans = ceil((m//lcm)/2)

print(ans)
# Judge status: Accepted
s = input()
print('Bad' if any(s[i] == s[i + 1] for i in range(3)) else 'Good')
# Judge status: Accepted
L,R,d=map(int,input().split())
n=0
for i in range(L,R+1):
  if i%d==0:
     n+=1
print(n)
# Judge status: Wrong Answer
from itertools import combinations
N,X,Y=(int(x) for x in input().split())
result=[]
for i in combinations(range(1,N+1),2):
	result.append(min(abs(i[0]-X)+abs(i[1]-Y)+1,i[1]-i[0]))
for i in range(1,N+1):
  print(result.count(i))
# Judge status: Wrong Answer
s = input()
if s is 'AAA' or s is 'BBB':
  print('No')
else:
  print('Yes')
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
x = sum(A)
y = 0
z = []

for n in range(N-1):
  y+=A[n]
  z.append(abs(x-2*y))

print(min(z))
# Judge status: Accepted
def getval():
    n = int(input())
    a = list(map(int,input().split()))
    return n,a

def main(n,a):
    a.sort()
    c = a[n-1]
    R = c/2
    r = 0
    for i in a:
        if abs(R-i)<abs(R-r):
            r = i 
    print("{x} {y}".format(x=c,y=r))

if __name__=="__main__":
    n,a = getval()
    main(n,a)
# Judge status: Accepted
n,m = map(int,input().split())
p = [0]*m
s = [""]*m
for i in range(m):
  p[i],s[i] = input().split()
  
p = [int(j) for j in p]

u = [[0 for i in range(2)]for j in range(n)]

for k in range(0,m):
  if(s[k] == "WA" and u[p[k]-1][1] == 0):
    u[p[k]-1][0] += 1
  elif(s[k] == "AC"):
    u[p[k]-1][1] = 1

ans = 0
ac = 0
for i in range(n):
  if(u[i][1] == 1):
    ac += 1
    ans += u[i][0]
print(ac,ans)
# Judge status: Accepted
a,b,c = map(int,input().split())
if b - a == c - b :
    print('YES')
else:
    print('NO')
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
print(int((a+b) * c / 2))
# Judge status: Accepted
x,y,a,b,c = map(int,input().split())
parr = list(map(int,input().split()))
qarr = list(map(int,input().split()))
rarr = list(map(int,input().split()))

parr.sort(reverse=True)
qarr.sort(reverse=True)
rarr.sort(reverse=True)
parr = parr[:x]
qarr = qarr[:y]
arr = parr + qarr + rarr
arr.sort(reverse=True)
print(sum(arr[:x+y]))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
m = len(format(max(a),"0b"))
b = []
for i in range(m):
  b.append(sum([1 for aa in a if (aa%(2**(i+1)))>=2**i]))
ans = 0
for i in range(m):
  ans += b[i]*(n-b[i])*(2**i)%(10**9+7)
ans %= 10**9+7
print(ans)
# Judge status: Wrong Answer
N, A, B = map(int, input().split())

Num = 0
for i in range(1, N+1):
    List = [int(a) for a in list(str(i))]
    if A <= sum(List) <= B:
        Num += 1

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a=I()
    print(a+a**2+a**3)

main()
# Judge status: Accepted
n=int(input())
s=list(input())
w=s.count("W")
e=s.count("E")
x=[0 for i in range(n)]
for i in range(1,n):
    if s[i-1]=="W":
        x[i]=x[i-1]+1
    else:
        x[i]=x[i-1]
ans=n
for i in range(n):
    z=2*x[i]+e-i
    if s[i]=="E":
        z-=1
    ans=min(ans,z)
print(ans)
# Judge status: Wrong Answer
W,a,b=map(int,input().split())
if b-(a+W)==0:
  print(0)
  exit()
print(b-(a+W))
# Judge status: Accepted
s = int(input())
def f(k):
  if k % 2 ==0:
    return k//2
  else:
    return 3*k+1

ary1 = [None]*1000001
ary1[1] = s

for i in range(2,1000001):
  fn = f(ary1[i-1])
  if fn in ary1:
    print(i)
    break
  else:
    ary1[i] = fn
# Judge status: Accepted
n=int(input())
s=input()

if n<3200:print("red")
else:print(s)
# Judge status: Wrong Answer
N, M, K = map(int, input().split())
  
for i in range(N):
  for j in range(M):
    if K == (N-i)*j + i*(M-j):
      print('Yes')
      exit()
      
print('No')
# Judge status: Accepted
n = int(input())
m=int(1e9+7)
print((pow(10,n,m)+pow(8,n,m)-2*pow(9,n,m))%m)
# Judge status: Accepted
a,b = map(int,input().split())

if a>8 or b>8:
  print(":(")
else:
  print("Yay!")
# Judge status: Accepted
a,b,c = list(map(int,input().split()))

if (c-a-b)<=0:
  print("No")
else:
  chk = (c-a-b)**2 - 4*a*b
  if chk > 0:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted

def main():
    s = input()
    if 'a' in s and 'b' in s and 'c' in s:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import sys
A = list(map(int, input().split()))
A.sort(reverse=True)
if(A[-1] == 0):
  print(0)
else:
  p = 1
  for An in A:
    p *= An
    if p > 10 ** 18:
      print(-1)
      sys.exit()
  print(p)
# Judge status: Accepted
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]

ans = 'No'


def check(x, y):
    for i in range(M):
        for j in range(M):
            if A[x + i][y + j] != B[i][j]:
                return False
    return True


for i in range(N - M + 1):
    for j in range(N - M + 1):
        if check(i, j):
            ans = 'Yes'

print(ans)
# Judge status: Wrong Answer
n = int(input())
r = 1
w = 10**9 + 7
for i in range(1, n+1):
  if r > w:
    r = (r % w) * i
  else:
    r *= i
  
  
print(r)
# Judge status: Wrong Answer
S=input()
T=input()
for i in range(1,len(S)):
    if S[-i:]+S[:-i]==T:
        print('Yes')
        exit
print('No')
# Judge status: Accepted
h, n = map(int, input().split())
a = list(map(int, input().split()))
if h <= sum(a):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a = list(map(int, input().split()))
x = a[0]
k = a[1]
d = a[2]
x = abs(x)

if abs(x) - k*d >= -d:
    print(abs(abs(x) - k*d))
else:
    t = x // d
    x = x - d*t
    k = k - t
    if k % 2 == 0:
        print(x)
    else:
        print(abs(x-d))
# Judge status: Accepted
ABCDEK = [int(input()) for _ in range(6)]
print("Yay!" if ABCDEK[-2]-ABCDEK[0] <= ABCDEK[-1] else ":(")
# Judge status: Accepted
a,b,c,d=map(int,input().split())
t=-(-c//b)
a=-(-a//d)
if t<=a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,q = map(int,input().split())
s = input()
lst = [0]*n
for i in range(n-1):
  lst[i+1] = lst[i] + 1*(s[i:i+2] == "AC")
for i in range(q):
  l,r = map(int,input().split())
  print(lst[r-1]-lst[l-1])
# Judge status: Accepted
N = int(input())
*d, = map(int, input().split())
d.sort()
print(d[N//2]-d[N//2-1])
# Judge status: Wrong Answer
N = int(input())
print(pow(10,N,1000000007)-2*pow(9,N,1000000007)+pow(8,N,1000000007))
# Judge status: Accepted
if __name__ == '__main__':

	n,t = map(int,input().split())
	
	cost = 1001
	for i in range(n):
		cn,tn = map(int,input().split())
		if tn <= t :
			cost = min(cost,cn)

	if cost == 1001:
		print("TLE")
	else:
		print(cost)
# Judge status: Accepted
a, b = map(int, input().split())
if a>b:
    print(a-1)
else:
    print(a)
# Judge status: Accepted
#!/usr/bin/env python3

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

if b < a:
    print(a-1)
else:
    print(a)
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))
ans = 0

if n == 0 and A[0] == 1:
    print(1)
    exit()
if n != 0 and A[0] != 1:
    print(-1)
    exit()


start = 1
way = sum(A)

for i in range(1,n+1):
    start *= 2

    if start < A[i]:
        print(-1)
        exit()
    if start > way:
        start = way

    ans += start
    #print(start, start-A[i])
    start -= A[i]
    way -= A[i]
#print()
print(ans+1)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
count = [0 for i in range(n+1)]
ans = 0
for i in range(n):
    count[a[i]] += 1
for i in range(n):
    ans += count[i]*(count[i]-1)//2
for i in range(n):
    num = count[a[i]]

    print(ans-(num*(num-1)//2)+(num-1)*(num-2)//2)
# Judge status: Wrong Answer
from collections import Counter

n = int(input())

ans = Counter()
for _ in range(n):
    s = Counter(list(input()))

    if not ans:
        ans = s
    else:
        temp = Counter()
        for key in set(ans) & set(s):
            temp[key] = min(ans[key], s[key])

        ans = temp

word = ''
for key, value in sorted(ans.most_common()):
    word += key * value

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

if N%K == 0:
    print("0")
else:
    print("1")
# Judge status: Wrong Answer
n, k = map(int, input().split())
h = sorted([int(input()) for _ in range(n)], reverse=True)

m = float('inf')
for i in range(n-k+1):
  m = min(m, h[i]-h[i-k])

print(m)
# Judge status: Accepted
n, c, k = map(int, input().split())

lt = list()
for i in range(n):
    lt.append(int(input()))
lt.sort()

b = 1  #the number of buses
p = 0  #passengers
m = lt[0]

for i in range(n):
    if p < c and lt[i]-m <= k:
        p += 1
    else:
        p = 1
        b += 1
        m = lt[i]

print(b)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
for i in range(b):
  if (i*a)%b==c:
    print('YES')
    break
print('NO')
# Judge status: Accepted
from sys import stdin
X,Y,A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
Q = [int(x) for x in stdin.readline().rstrip().split()]
R = [int(x) for x in stdin.readline().rstrip().split()]

P.sort(reverse=True)
Q.sort(reverse=True)

res = P[:X] + Q[:Y] + R
res.sort(reverse=True)

print(sum(res[:X+Y]))
# Judge status: Wrong Answer

n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    x = a[i]
    a[i] = (x*(x+1))/2/x
print(a)
for i in range(n-k+1):
    print(i,a[i:i+k])
    ans = max(ans,sum(a[i:i+k]))
print(ans)
# Judge status: Accepted
N=int(input())
li = list(map(int,input().split()))

x = ""
count = 1

for i in range(N - 1):
  if li[i] == li[i + 1]:
    continue

  if x == "":
    if li[i] < li[i + 1]:
      x = 'UP'
    
    if li[i] > li[i + 1]:
      x = 'DOWN'

  else:
    if x == 'UP' and li[i] > li[i + 1]:
      x = ""
      count += 1
    elif x == 'DOWN' and li[i] < li[i + 1]:
      x = ""
      count += 1

print(count)
# Judge status: Wrong Answer
print(['No','Yes'][int(''.join(list(input().split()))[1:])%4==0])
# Judge status: Accepted
n = int(input())
ls = list(map(int, input().split()))

ans = 0

for i in range(n):
    if i != n - 1:
        if ls[i] == i + 1:
            ls[i], ls[i + 1] = ls[i + 1], ls[i]
            ans += 1
    elif i == n - 1:
        if ls[i] == i + 1:
            ls[i], ls[i - 1] = ls[i - 1], ls[i]
            ans += 1

print(ans)
# Judge status: Accepted
#!/usr/bin/env python3

def solve(n,h):
    ans = 0
    counter = 0
    memo = 0
    for i in range(n):
        if h[i] <= memo:
            counter += 1
        else:
            counter = 0
        memo = h[i]
        ans = max(ans,counter)
    return ans

def main():
    N = int(input())
    H = list(map(int,input().split()))
    print(solve(N,H))

if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
import math

def getk(num):
    return int((1+math.sqrt(8*num-7))/2)

while(True):
    k = getk(n)
    print(k)
    n-=k
    if k == 1 or n<=0:
        break
# Judge status: Accepted
s = input()
n = len(s)
Ccnt = 0
def end():
  print('WA')
  exit(0)
  return 
for i in range(n):
  if i == 0:
    if s[i] != 'A':end()
  else:
    if s[i].isupper():
      if 2<=i<n-1 and s[i] == 'C':Ccnt += 1
      else:end()
if Ccnt != 1:end()
print('AC')
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

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


for i in range(1, M + 1):
    print(i, 2*M + 1 - i)
# Judge status: Accepted
x=int(input())
a=x//100
b=x%100
if b>=0 and b<=5*a:
    print("1")
else:
    print("0")
# Judge status: Accepted
def main():
    a = int(input())
    b = int(input())

    c = a * b
    if c == 2:
        print(3)
    elif c==3:
        print(2)
    else:
        print(1)


    
if __name__ == "__main__":
    main()
# Judge status: Accepted
N,X,T = map(int,input().split())

if N%X != 0:
	print(((N//X)+1)*T)
else:
	print(((N//X))*T)
# Judge status: Wrong Answer
a,b,c,d,e,k=[int(input())for _ in range(6)]
if e-a >= k:
  print(':(')
else:
  print('Yay!')
# Judge status: Wrong Answer
N, K, S = [int(v) for v in input().split()]

array = []

    
if N == K:
    for i in range(N):
        array.append(str(S))
else:
    for i in range(K):
        array.append(str(S))

    if S == 1000000000:
        while len(array) < N:
            array.append(str(S+1))
    else:
        while len(array) < N:
            array.append(str(1))

print(" ".join(array))
# Judge status: Accepted
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
print(sum(a[::2])-sum(a[1::2]))
# Judge status: Accepted
arr=[int(input()) for i in range(5)]
brr=[]
result=0

for i in range(5):
    if arr[i]%10!=0:
        brr.append(arr[i]%10)
    else:
        brr.append(arr[i])
ans=brr.index(min(brr))



for i in range(5):
    if i==ans or arr[i]%10==0:
        result+=arr[i]
    else:
        result+=arr[i]+10-arr[i]%10
        
print(result)
# Judge status: Wrong Answer
n,q = map(int,input().split())
s = input()
lr=[list(map(int,input().split())) for i in range(q)]
l=[0]*n
r=[0]*n
lcnt=0
rcnt=0
for i in range(n-1):
    if s[i]=="A" and s[i+1] == "C":
        # lcnt+=1
        rcnt+=1
        l[i+1]=1
    r[i+1]=rcnt
for i in lr:
    print(max(0,r[i[1]-1]-r[i[0]-1]-l[i[0]-1]))
# Judge status: Accepted
import math
a,b,n = map(int,input().split())
if n < b-1:
    x = n
else:
    x = b-1
ans = math.floor(a*x/b) - a * math.floor(x/b)
print(ans)
# Judge status: Wrong Answer
#!/usr/bin/env python3
def main():
    N, M = map(int, input().split())
    pS = [list(input().split()) for _ in range(M)]

    score = [0] * (N + 1)
    ac = [0] * (N + 1)
    for p, S in pS:
        p = int(p)
        if S == 'AC':
            ac[p] = 1
        if ac[p]:
            continue
        score[p] += 1
    print(sum(ac), sum(score))
    # print(score)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import math
from functools import reduce
from itertools import product
K=int(input())
gcd=0.
for i in range(K):
    for j in range(K):
        a=math.gcd(i+1,j+1)
        for k in range(K):
            gcd+=math.gcd(a,k+1)
print(gcd)
# Judge status: Wrong Answer
import numpy as np

def takahashi_info():
    
    A = []
    for i in range(3):
        A += [int(j) for j in input().split()]

        
    if sum(A) % 3 == 0:
        print('Yes')
    
    else:
        print('No')
        
takahashi_info()
# Judge status: Wrong Answer
n = int(input())
x = list(map(int,input().split()))
y = x.copy()
y.sort()
a = y[n//2]
b = y[n//2-1]
for i in range(n):
    if x[i] == a:
        print(b)
    else:
        print(a)
# Judge status: Accepted
import math

a, b, x = map(int, input().split())
x /= a
if a * b >= x * 2:
    c = x * 2 / b
    print(math.degrees(math.atan2(b, c)))
else:
    c = (a * b - x) * 2 / a
    print(math.degrees(math.atan2(c, a)))
# Judge status: Accepted
import math
from functools import reduce

def gcd(ns):
    return reduce(math.gcd, ns)

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

diff = [abs(x - X) for x in L]

if len(diff) == 1:
    print(diff[0])
else:
    print(gcd(diff))
# Judge status: Accepted
a,b,_ = map(int,input().split())
print(a * b //2)
# Judge status: Wrong Answer
from itertools import product
n, m = list(map(int, input().split()))
A = [list(input()) for _ in range(n)]
B = [list(input()) for _ in range(m)]
for i, j in product(range(n - m + 1), range(n - m + 1)):
    if all([A[i + k][j:j + m + 1] == B[k] for k in range(m)]):
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
def main():
    S = input()
    weeks = list(reversed(['SUN','MON','TUE','WED','THU','FRI','SAT']))
    print(weeks.index(S)+1)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

# B - KEYENCE String
def is_keyence_string():
	i = 0

	for s in S:
		if s == key[i]:
			i += 1
			if i == len(key):
				return True

	return False


S = input()
key = 'keyence'

if is_keyence_string():
	print('YES')
else:
	print('NO')
# Judge status: Accepted
a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())

if v <= w:
    print('NO')
elif ((a-b)/(v-w))**2 <=t**2:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
s=input()
ans=0
for i in range(len(s)//2):
    if s[i]!=s[len(s)-1-i]:
        ans+=1
print(ans)
# Judge status: Accepted
#!/usr/bin/env python
import math

def main():
    a, b, n = map(int, input().split())

    if n < b-1:
        x = n
    else:
        x = b-1

    ret = math.floor(a * x / b)
    print(ret)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]
h.sort()

m=h[-1]
for i in range(n-k+1):
  if m > h[i+k-1]-h[i]:
    m=h[i+k-1]-h[i]
print(m)
# Judge status: Accepted
import copy
import sys
N = int(input())
H = list(map(int,input().split()))
C = 0

if sorted(H) == H:
	print("YES")
	sys.exit()

for i in range(0,N-1):
	for j in range(1,N):
		L = copy.copy(H)
		L[i],L[j] = L[j],L[i] 
		if L == sorted(H):
			print("YES")
			sys.exit()
print("NO")
# Judge status: Accepted
s = input()
t = input()
c = 0

for i in range(len(s) - len(t) + 1):
    c_1 = 0
    for j in range(len(t)):
        if s[i + j] == t[j]:
            c_1 += 1
    if c < c_1:
        c = c_1

print(len(t) - c)
# Judge status: Accepted
N = int(input())
S = input()

x = 0
l = [0]
for i in range(N):
    if S[i] == "I":
        x += 1
    else:
        x += -1
    l.append(x)
print(max(l))
# Judge status: Wrong Answer
S = input()
if S[5:7] == "12>=05":
  print("TBD")
else:
  print("Heisei")
# Judge status: Accepted
N = int(input())
S = input()

L, R = 0, 0
cnt = 0
for s in S:
    if s == '(':
        cnt += 1
    else:
        if cnt > 0:
            cnt -= 1
        else:
            L += 1

R = cnt
print(L * '(' + S + R * ')')
# Judge status: Wrong Answer
A =list(map(int,input().split()))
K =int(input())

A.sort(reverse = True)
#print(A)
#print(A[0])

x1 =0

for i in range(K):
    x = A[0] * 2
    x1 = x1 + x
#print(x1)
print(x1 +A[1] +A[2])
# Judge status: Wrong Answer
n = int(input())
for i in range(n//4):
    for j in range(n//7):
        if 4*i + 7*j == 0:
            print('Yes')
            break
    else:
        break
else:
    print('No')
# Judge status: Accepted
strlist = ["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"]
print(strlist[strlist.index(input()) + 1])
# Judge status: Accepted
S = input()
l, r =  map(int, [S[:2], S[2:]])

if 1 <= l <= 12 and 1 <= r <= 12:
  print("AMBIGUOUS")
elif 1 <= l <= 12 and (r == 0 or r > 12):
  print("MMYY")
elif (l == 0 or l > 12) and 1 <= r <= 12:
  print("YYMM")
else:
  print("NA")
# Judge status: Wrong Answer
import math
n,d=map(int,input().split())
print(math.ceil(n/2/d))
# Judge status: Accepted
#45
a=int(input())
b=int(input())
h=int(input())
if h%2==0:
    print(int((a+b)*h/2))
# Judge status: Wrong Answer
a = input()
if int(a[5]) == 1:
  print('TBD')
else:
  if int(a[6]) > 4:
    print('TBD')
  else:
    print('heisei')
# Judge status: Accepted
s=str(input())
S=set(s)
if len(S)==3:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

from copy import deepcopy

B = deepcopy(A)

for i in range(N):
    A[i] += i+1
    B[i] = (i+1)-B[i]

from collections import Counter

C = Counter(A)
D = Counter(B)

E = list(C.keys())

ans = 0
for i in E:
    ans += C[i]*D[i]

print(ans)
# Judge status: Accepted
a,b = input().split()
A = int(a+b)

flg = False
for i in range(1,1000):
  if i*i == A:
    flg = True
    break

if flg:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n=int(input())
count=0
for i in range(1,10):
    for j in range(1,10):
        if i*j==n:
            count=1
            break
    else:
        continue
print("Yes"if count==1 else"No")
# Judge status: Accepted
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
ans = 0
for i in range(n):
    if a_list[i] + a_list[i + 1] > b_list[i]:
        ans += b_list[i]
        a_list[i + 1] = min(a_list[i + 1], a_list[i] + a_list[i + 1] - b_list[i])
    else:
        ans += a_list[i] + a_list[i + 1]
        a_list[i + 1] = 0
print(ans)
# Judge status: Accepted
# 線形探索
# 与えられた数字を一気に2で割るとしたとき、何回まで整数のままで割れますか、という考え方
# 2進数の1/2倍は右論理シフトになるだけ
# 2進数での右の0の個数(=はじめに1が出てくる数から1を引いた数)が2で割れる回数に等しい

import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
# Judge status: Accepted
if __name__ == '__main__':
    n = int(input())
    setN =set([n])
    count=1
    while True:
        if n %2 ==1:
            n=3*n+1
        else:
            n=n/2
        if n in setN:
            print(count+1)
            break
        else:
            count+=1
            setN.add(n)
# Judge status: Accepted
A,B,M = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
d = []
ans = a[0]+b[0]
for i in range(M):
    d.append(list(map(int,input().split())))
for i in range(M):
    x = a[d[i][0]-1] + b[d[i][1]-1] - d[i][2]
    if x < ans:
        ans = x
a.sort()
b.sort()
print(min(a[0]+b[0],ans))