peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

list_range = list(range(1,n+1))
pattern_list = list(itertools.permutations(list_range, n))
pattern_list.sort()
ans = [0] * 2
for i in range(len(pattern_list)):
  if p == list(pattern_list[i]):
    ans[0] = i
  elif q == list(pattern_list[i]):
    ans[1] = i
print(abs(ans[0] - ans[1]))
# Judge status: Wrong Answer
if input() == 'ARC':
  print('ABC')
else: 
  print('ARD')
# Judge status: Wrong Answer
N = int(input())
ti = [int(input()) for i in range(N)]


def euc_alg(val1, val2):
    assert val1 >= val2

    if val1 == val2:
        return val1

    mod = val2
    divided = val1
    while 1:
        tmp_mod = divided % val2

        if tmp_mod == 0:
            break
        divided = mod
        mod = tmp_mod

    ret = val1 // mod * val2

    return ret

maxti = max(ti)
least_common_mult = max([euc_alg(maxti, t) for t in ti])

print(least_common_mult)
# Judge status: Accepted
import math
N,D = map(int, input().split())
print(math.ceil(N/(2*D+1)))
# Judge status: Wrong Answer
import numpy as np   
n,m = [int(i)for i in input().split()]

l = [[int(i)-1 for i in input().split()] for _ in range(m)]

line = np.array([1 for _ in range(n)])
is_red = np.zeros(n,dtype = np.int32)
is_red[0] = 1

for x,y in l:
    line[x] -= 1 if line[x] > 0 else 0
    line[y] += 1
    is_red[y] = 1 if is_red[x] == 1 else is_red[y] if line[x] > 0 else 0
    

ans = np.count_nonzero(is_red[line > 0])

print(ans)
# Judge status: Accepted
s = [input() for i in range(3)]
t = ["a", "b", "c"]
cur = 0
while len(s[cur]) > 0:
  next = s[cur][0]
  s[cur] = s[cur][1:]
  cur = t.index(next)
print(t[cur].upper())
# Judge status: Accepted
A,B,K = map(int,input().split())
if A >= K:
  print(A-K,B)
elif K >= A+B:
  print(0,0)
else:
  print(0,B-(K-A))
# Judge status: Wrong Answer

Ls = sorted(map(int, input().split()))
if Ls[-1] < sum(Ls) - Ls[-1]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    if n==1 and m==1:
        ans=1
    elif m==1:
        ans=max(0,n-2)
    elif n==1:
        ans=max(0,m-2)
    else:
        ans=(n-2)*(m-2)
    print(ans)
resolve()
# Judge status: Accepted
n = int(input())
A = [int(x) for x in input().split()]
lst = [0] * n
for i, a in enumerate(A, 1):
  lst[a-1] = i
print(*lst)
# Judge status: Accepted
n = int(input())
ts = []
for i in range(n):
    x, l = map(int, input().split())
    t = x + l
    s = x - l
    ts.append([t, s])

ts.sort()
ans = 0
T = float("inf") * - 1
for i in range(n):
    if T <= ts[i][1]:
        ans += 1
        T = ts[i][0]

print(ans)
# Judge status: Wrong Answer
import itertools
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    print(N)
    h_list = list(map(int, input().split()))
    print(h_list)
    c_list = list(itertools.combinations(range(N),2))
    ans = 0

    for c in c_list:
            if abs(c[0] - c[1]) == h_list[c[0]] + h_list[c[1]]:
                ans += 1

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))
DIV = 10 ** 9 + 7
import math

from functools import reduce

def lcm(a,b,):
  return (a // math.gcd(a,b)) * b

G = reduce(lcm, A)
ans = sum(map(lambda x:G // x, A))

print(ans % DIV)
# Judge status: Wrong Answer
value = input()
if value == "AAA" or "BBB" or "ABA" or "BAB":
  print("No")
else:
  print("Yes")
# Judge status: Accepted
N, M = map(int, input().split())
ans = [0 for _ in range(N)]
for _ in range(M):
  a, b = map(int, input().split())
  ans[a-1] += 1
  ans[b-1] += 1
for i in range(N):
  print(ans[i])
# Judge status: Wrong Answer
N = int(input())
j = 0
while j**2 < N:
  j +=1
print((j-1)**2)
# Judge status: Accepted
# 2020/07/04
# AtCoder Beginner Contest 071 - C

# Input
n = int(input())
a = list(map(int,input().split()))

a.sort()

h_long = 0
h_short = 0
i = n - 1

#for i in range(n-1, 0, -1):
while i > 0:
    if a[i-1] == a[i]:
        if h_long == 0:
            h_long = a[i]
            i = i - 1
        else:
            h_short = a[i]
            break
    i = i - 1

ans = h_short * h_long

# Output
print(ans)
# Judge status: Accepted
a,b=map(int, input().split())
print("-1" if a>9 or b>9 else a*b)
# Judge status: Wrong Answer
n,x=map(int,input().split())
li=list(map(int,input().split()))
s=0
ans=0
for i in li:
  if s<=x:
    s+=i
    ans+=1
print(ans)
# Judge status: Accepted
moji = str(input())
dictionary = {}
for i in moji:
    if i not in dictionary:
        dictionary[i] = 1
    else:
        dictionary[i] += 1
if len(dictionary) == 2 & dictionary[i] == 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
#import numpy as np
#import math
import heapq

n, m = map(int, input().split())
#a = list(map(int, input().split()))
a = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(a)  # aを優先度付きキューに

for _ in range(m):
    MAX = heapq.heappop(a)  # −１かけたリストのMin　＞Max
    heapq.heappush(a, (-1) * (-MAX // 2))

ans = (sum(a)) * (-1)  # そのままリストでOK
print(ans)
# Judge status: Accepted
N, K = map(int,input().split())

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

Visited = [-1]*N
now = 1
Order = [0]*N

loopcount = 1
Order[0] = 1
Visited[0] = 1
for i in range(1,N):
    nt = Map[now-1]
    Order[i] = nt
    loopcount += 1
    if Visited[nt-1] == -1:
        Visited[nt-1] = loopcount
    else:
        break
    now = nt
    

ns = Visited[nt-1]
period = loopcount - ns

if period == 0:
    period = loopcount
    ns = 0

Kmod = K - ns
if Kmod > 0:
    Kmod %= period

print(Order[ns+Kmod])
# Judge status: Accepted
a,b,x = map(int, input().split())

if x<a or a+b<x:
        print("NO")
else:
        print("YES")
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(int, input().split()))

def isOk(x):
    cnt = 0
    for a in A:
        cnt += a // x
    return cnt <= K

ok = max(A)
ng = 0
while ok - ng > 1:
    mid = (ok + ng) // 2
    if isOk(mid):
        ok = mid
    else:
        ng = mid

if ok > 1 and isOk(ok - 1):
    ok -= 1

print(ok)
# Judge status: Accepted
x=[i for i in input()]
print(len(x)*"x")
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

sunuke = [0] * (N)
guma = [0] * (N)

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

for j in range(N-1,0,-1):
  if j == N - 1:
    guma[j] += A[j]
    continue
  guma[j] += guma[j+1] + A[j]
  
ans = float("inf")
for k in range(N-1):
  ans = min(ans, abs(sunuke[k] - guma[k+1]))

print(ans)
# Judge status: Accepted
def solve():
    S = input()
    return 'Bad' if S[0] == S[1] or S[1] == S[2] or S[2] == S[3] else 'Good'

print(solve())
# Judge status: Accepted
N,L=map(int,input().split())
J=[]
for i in range(N):
    J.append(L+i)
for i in J:
    if i == 0:
        J.pop(J.index(0))
        print(sum(J))
        exit(0)
J.sort()
print(sum(J[1:]) if J[0]>0 else sum(J[:-1]))
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
k = int(input())
flg = False
for i in range(k+1):
  b = (2**i) * b
  c = (2**(k-i)) * c
  if a < b < c:
    flg = True
    break

if flg:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
C = 'abcdefghijklmnopqrstuvwxyz'
N = int(input())
def dfs(s):
  l = len(s)
  if l >= N:
    print(s)
    return
  for i in range(l+1):
    if len(set(s)) < i:
      continue
    dfs(s+C[i])
dfs('')
# Judge status: Accepted
def solve(n):
	if n==1:
		return 1
	return 1+2*solve(n//2)
n=int(input())
print(solve(n))
# Judge status: Wrong Answer
s = list(input())

g = []

g.append(0)
g.append(1)
if s[1] == s[2]:
    g.append(1)
else:
    g.append(2)

for i in range(3,len(s)+1):
    if s[i-1] != s[i-2]:
        g.append(g[i-1]+1)
    else:
        g.append(g[i-3]+2)

print(g[len(s)])
# Judge status: Wrong Answer
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))
not_b10 = [s for s in S if s%10 != 0]
b10 = [s for s in S if s%10 == 0]
    
if sum(S)%10!=0:
    print(sum(S))
elif S ==b10:
    print(0)
else:

    print(sum(S)-not_b10[0])
# Judge status: Accepted
N,A,B,C,D = map(int,input().split())
S=input()
ans="Yes"

if D<C:
  triple = S[B-2:D+1].count("...")
  if triple ==0:
    ans="No"

double= S[A-1:max(C,D)].count("##")
if double > 0:
  ans="No"
  
print(ans)
# Judge status: Accepted
s = input()
ans = ''
for a in s:
    if a =='B':
        if len(ans) > 0: ans = ans[:-1]
    else: ans += a
print(ans)
# Judge status: Accepted
N,M=map(int,(input().split()))
k=list(map(int,input().split()))[1:]
for i in range(N-1):
  A=list(map(int,input().split()))[1:]
  l=[]
  for j in k:
    if j in A:
      l.append(j)
  k=l
print(len(k))
# Judge status: Accepted
import heapq

x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

ans=[]
for i in range(x):
  ans.append(p[i])
  
for j in range(y):
  ans.append(q[j])
  
ans.sort()

heapq.heapify(ans)

for j in range(c):
  min_a=heapq.heappop(ans)
  if min_a<=r[j]:
    heapq.heappush(ans,r[j])
  else:
    heapq.heappush(ans,min_a)
    break
    
print(sum(ans))
# Judge status: Accepted
n=int(input())
s=input()
l=0

for i in range(n):
    a=set(s[:i])
    b=set(s[i:])
    c=list(a & b)
    l=max(len(c),l)
print(l)
# Judge status: Wrong Answer
n,m=map(int,input().split())
if n<=2*m:
    ans=n
    m-=2*n
    ans+=m//4
    print(ans)
else:
    print(m//2)
# Judge status: Accepted
a,b,c=map(int,input().split())

kai=b//a
print(min([kai,c]))
# Judge status: Accepted
import sys
N = int(input())
if N == 1:
    print(0)
    sys.exit()
alla = 1
for i in range(N):
    alla = (alla * 10) % (10**9+7)
exi1or9 = 1
for i in range(N):
    exi1or9 = (exi1or9 * 9) % (10**9+7)
exi1and9 = 1
for i in range(N):
    exi1and9 = (exi1and9 * 8) % (10**9+7)
ans = (alla-2*exi1or9+exi1and9) % (10**9+7)
print(ans)
# Judge status: Accepted
from collections import deque

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

graph = [[] for _ in range(n+1)]
dist = [0] * (n+1)
visited = [0] * (n+1)


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

root = 1
visited[root] = 1
d  = deque([root])

while d:
    v = d.popleft()
    for i in graph[v]:
        if visited[i]:
            continue
        visited[i] = 1
        dist[i] = v
        d.append(i)

print('Yes')
ans = dist[2:]
print(*ans, sep="\n")
# Judge status: Accepted
n = int(input())
s = input()
t = input()
a = 0
for i in range(n+1):
    if s[len(s)-i:] == t[:i]:
        a = i
print(2*n-a)
# Judge status: Accepted
n = int(input())
s = input()

l_lack=0
l_cnt=0

for tmp in s:
    if tmp==")":
        if l_cnt==0:
            l_lack+=1
        else:
            l_cnt-=1
    if tmp=="(":
        l_cnt+=1

left="("*l_lack
right=")"*l_cnt
print(left+s+right)
# Judge status: Wrong Answer
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    h,w = map(int, input().split())
    
    print(max(ceil(h/2) * ceil(w/2) + floor(w/2)*floor(h/2), h*w//2+1))
        

    return

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
w, h, n = map(int, input().split())

list = [0, w, 0, h]

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and list[0] <= x:
        list[0] = x
    elif a == 2 and list[1] >= x:
        list[1] = x
    elif a == 3 and list[2] <= y:
        list[2] = y
    elif a == 4 and list[3] >= y:
        list[3] = y
    else:
        pass


print((list[0] - list[1]) * (list[2] - list[3]))
# Judge status: Accepted
import fractions
a,b = map(int,input().split())
print((a*b)//fractions.gcd(a,b))
# Judge status: Wrong Answer
N, K = map(int, input().split())

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

INF = 10**6
dp = [INF for _ in range(N)]
dp[0] = 0

for i in range(1, N):
    for j in range(1, K+1):
        if i - j < 0:
            continue
        dp[i] = min(dp[i], dp[i-j] + abs(H[i-j] - H[i]))

print(dp[N-1])
# Judge status: Accepted
n=int(input())
a=[int(x) for x in input().split()]
m=10**9+7
s=sum(a)
ans=0
for i in range(n-1):
  s-=a[i]
  ans+=a[i]*s
  ans%=m
ans%=m
print(ans)
# Judge status: Accepted
import numpy as np

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
sorted_ab = sorted(ab, key=lambda x: x[1])
arr = np.array(sorted_ab)
if np.any((arr[:, 1] - np.cumsum(arr[:, 0])) < 0):
  print('No')
else:
  print('Yes')
# Judge status: Accepted
S = input()
m =  0
cnt = 0
for s in S:
    if s == 'A':
        cnt += 1
    elif s == 'C':
        cnt += 1
    elif s == 'G':
        cnt += 1
    elif s == 'T':
        cnt += 1
    else:
        cnt = 0
    m = max(m, cnt)
print(m)
# Judge status: Wrong Answer
X = int(input())

for i in range(X, 2 * X):
  flg = False
  for j in range(2, i-1):
    if X % j == 0:
      flg = True
    
  if flg == False:
    print(i)
    exit()
# Judge status: Accepted
S=input()
ans=0
for i in range(len(S)-2):
    tmp=abs(int(S[i]+S[i+1]+S[i+2])-753)
    if i==0:
        ans=tmp
    elif ans>tmp:
        ans=tmp
print(ans)
# Judge status: Accepted
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

if N == 100:
    print(100 ** D * (N + 1))
else:
    print(100 ** D * N)
# Judge status: Accepted
a,b=map(int,input().split())
ans=0
list=[i+b-1 for i in range(1,a+1)]
list.sort(key=lambda i:abs(i))
ans=sum(list[1:])
print(ans)
# Judge status: Accepted
from operator import itemgetter

N = int(input())

X = []
L = []

for i in range(N):
    a,b = map(int,input().split())
    X.append(a-b)
    L.append(a+b)

xl = sorted([(X[i],L[i]) for i in range(N)], key = itemgetter(1))

ans = 0
last = -float("inf")

for i in range(N):
    if last <= xl[i][0]:
        ans += 1
        last = xl[i][1]

print(ans)
# Judge status: Accepted
A=list(map(int,input().split()))
print(max(A)*9+sum(A))
# Judge status: Accepted
from collections import defaultdict
def main():
    N = int( input())
    d = defaultdict( int)
    for i in range(2, int(N**(1/2))+1):
        while N%i == 0:
            d[i] += 1
            N //= i
    if N > 1:
        d[N] += 1
    ans = 0
    for key in d:
        for i in range(1, 100):
            if i*(i+1)//2 > d[key]:
                ans += i-1
                break
    print(ans)
if __name__ == '__main__':
    main()
# Judge status: Accepted
MOD = 10 ** 9 + 7
dog, cat = map(int, input().split())
pd = 1
pc = 1
ans = 0
if abs(dog - cat) > 1:
    ans = 0
elif abs(dog - cat) == 1:
    for i in range(1, min(dog, cat)+1):
        pd = pd * i % MOD
    pc = pd * max(dog, cat) % MOD
    ans = pd * pc % MOD
else:
    for i in range(1, dog+1):
        pd = pd * i % MOD
    ans = pd * pd % MOD
    ans = ans * 2 % MOD
print(ans)
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))
now = 0
for i in range(N):
    if a[i] % 4 == 0:
        now += 2
        continue
    if a[i] % 2 == 0:
        now += 1
if N%2 == 1:
    if now >= N-1:
        print("Yes")
    else:
        print("No")
else:
    if now >= N:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
from collections import Counter
s = sorted(list(Counter(list(input())).values()))[::-1]
if len(s)==1:
  if s[0]!=1:
    print("NO")
    exit()
  else:
    print("YES")
    exit()
a = s[0]
if len(s)==2:
  if s[0]==1 and s[1]==1:
    print("YES")
    exit()
  else:
    print("NO")
    exit()
for i in s:
  if a==i or a==i+1:
    continue
  else:
    print('NO')
    exit()
else:
  print("YES")
# Judge status: Accepted
import sys
input = sys.stdin.readline

x,y = list(map(int,input().split()))
nl = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
nd = {1:0,1:0,3:0,5:0,7:0,8:0,10:0,12:0,4:1,6:1,9:1,11:1,2:2}
print('Yes' if y in nl[nd[x]] else 'No')
# Judge status: Accepted
n = int(input())
c = list(map(int, input().split()))
d = sorted(c, reverse=True)
print(sum(d[0::2]) - sum(d[1::2]))
# Judge status: Wrong Answer
n,k = map(int,input().split())
x = list(map(int,input().split()))

mi = 99999

for i in range(n-k+1):
    l = x[i]
    r = x[i+k-1]
    vall = abs(l) + abs(r - l)
    valr = abs(r) + abs(r - l)
    mi = min(mi,vall,valr)

print(mi)
# Judge status: Accepted
x, k, d = map(int,input().split())
x = abs(x)
if (x >= k*d):
  print(x - k*d)
else:
  nokori = k - x//d
  if (nokori%2 == 0):
    print(abs(x%d))
  else:
    print(abs(x%d - d))
# Judge status: Accepted
x = int(input())

ans = x//11*2
if 1<= x%11 <= 6:
    ans += 1
elif x%11 >= 7:
    ans += 2

print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
z = b // a
print(min([z, c]))
# Judge status: Wrong Answer
X=int(input())
n = 200000
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)
for i in range(len(primes)-1):
    if X==2:
        print("2")
    elif (primes[i]<X)and(X<=primes[i+1]):
        print(primes[i+1])
# Judge status: Accepted
n,m = map(int, input().split())

from collections import defaultdict
d = defaultdict(int)
a=1
b=n

def nxt(a,b):
    b-=1
    while True:
        a+=1
        if b-a != n-b+a and d[b-a] != 1 and d[n-b+a] != 1:
            break
    d[b-a]+=1
    d[n-b+a]+=1
    return a,b


for i in range(m):
    print(a,b)
    a,b = nxt(a,b)
# Judge status: Accepted
N,K=map(int,input().split())



for i in reversed(range(18)):
    while N > 10 ** i * K:
        N=N-10 ** i * K


while abs(N-K)<N:

    N=abs(N-K)

print(N)
# Judge status: Accepted
X=input()
ans=len(X)
count_s=0
for i in X:
    if i=='S':
        count_s+=1
    if i=='T' and count_s>=1:
        count_s-=1
        ans-=2

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

for i in range(n):
    a,b = map(int,ab_input[i])
    
    tmp=float('inf')
    for j in range(m):
        c,d = map(int,cd_input[j])
        dist=abs(a-c)+abs(b-d)
        if tmp>dist:
            tmp=dist
            ans=j
    print(ans+1)
# Judge status: Wrong Answer
a, b, k = list(map(int,input().split()))
print(a,b,k)
if a+b < k:
  a = 0
  b = 0
elif a >= k:
  a -= k
else:
  b = b - (k-a)
  a = 0
print(a,b)
# Judge status: Wrong Answer
n, q = map(int, input().split())
s = input()
cum = [0] * n  # i文字目までに含まれるACの個数
for i in range(1, n):
    if s[i-1:i+1] == 'AC':
        cum[i] = cum[i-1] + 1
    else:
        cum[i] = cum[i-1]
print(cum)

for i in range(q):
    l, r = map(int, input().split())
    l, r = l-1, r-1
    print(cum[r] - cum[l])
# Judge status: Accepted
a,b,c=[int(i) for i in input().split()]

if a+b>=c:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x, a, b= map(int, input().split())
print("A" if (x-a)<(x-b) else "B")
# Judge status: Wrong Answer
s=list(input())
ans=0
for i in s:
    k=int(i)
    ans+=k
if k%9==0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,q = map(int, readline().split())
#*a, = map(int, readline().split())

n = int(input())

cnt = 0
for i in range(n):
    a,b = map(int, readline().split())
    if a==b:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        break
else:
    print("No")
# Judge status: Accepted
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
i = A.index(1)
print(math.ceil((N-1)/(K-1)))
# Judge status: Accepted
n, m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-2)
else:
    print((n-2)*(m-2))
# Judge status: Accepted
n,m,x=map(int,input().split())
ca=[list(map(int,input().split())) for _ in range(n)]
c=[0]*n
ans=10**7
for i in range(n):
  c[i]=ca[i][0]
for i in range(2**n):
  l=[0]*m
  prime=0
  for j in range(n):
    if ((i >> j) & 1):
      prime+=c[j]
      for k in range(m):
        l[k]+=ca[j][k+1]
  if all([j>=x for j in l]):
    ans=min(ans,prime)
print(-1 if ans==10**7 else ans)
# Judge status: Accepted
N,K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
for i in range(K):
    H.pop()
    if len(H) == 0:
        break
print(sum(H))
# Judge status: Wrong Answer
r=int(input())

print(int(r^2))
# Judge status: Wrong Answer
import numpy as np
N, W = map(int, input().split())
dp = np.zeros((N, W+1), dtype = "int64")
for i in range(N):
    w, v = map(int, input().split())
    dp[i,-w:] = dp[i-1, -w:] #残りの重さW-w以上にするためには、荷物を入れられない。
    dp[i, :W-w+1] = np.fmax(dp[i-1, :W-w+1], dp[i-1, w:]+v)
dp[N-1, 0]
# Judge status: Accepted
def f(n):
    if n % 2== 0:
        return n // 2
    else:
        return 3 * n + 1

s = int(input())
ans = 2
if s == 1 or s == 2:
    print(4)
    exit()
while(s > 1):
    s = f(s)
    ans += 1
print(ans)
# Judge status: Accepted
a,b,k = map(int, input().split())

s = set()
if a==b:
    s.add(a)
for x in range(a,min(a+k,b)):
    s.add(x)
for x in range(b,max(a,b-k),-1):
    s.add(x)

l = [x for x in s]
l.sort()
for x in l:
    print(x)
# Judge status: Accepted
s = input()
t = input()

s_f = [0 for _ in range(26)]
t_f = [0 for _ in range(26)]

for ss, tt in zip(s, t):
    s_f[ord(ss) - ord('a')] += 1
    t_f[ord(tt) - ord('a')] += 1

s_f.sort()
t_f.sort()

for ss, tt in zip(s_f, t_f):
    if ss != tt:
        print('No')
        exit()

print('Yes')
# Judge status: Accepted
N = int(input())
V = list(map(int, input().split()))
V.sort()
res = V[0]
for v in V[1:]:
    res = (res + v)/2
print(res)
# Judge status: Accepted
import numpy as np
N,X,Y=map(int, input().split())
ans = [0]*(N-1)
for i in range(1,N):
  for j in range(i+1,N+1):
    root1 = j-i
    root2 = abs(X-i) + 1 + abs(Y-j)
    min_k = min(root1, root2)
    ans[min_k-1] = ans[min_k-1] + 1

for a in ans:
  print(int(a))
# Judge status: Wrong Answer
X = int(input())
if -40 <= X <= 40:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a=sorted(list(map(int,input().split())))
print(a[2]*10+a[1]+a[0])
# Judge status: Accepted
n=int(input())
s=input()
accum=[0]*n
if s[0]=="#":
    accum[0]=1
for i in range(n-1):
    accum[i+1]+=accum[i]+(s[i+1]=="#")
accum=[0]+accum
ans=10**18
for i in range(n+1):
    ans=min(ans,accum[i]+n-i-accum[n]+accum[i])
#print(accum)
print(ans)
# 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 n4>=(n+2)//3:
    print("Yes")
else:
    if (n2-n4)>=n-3*n4+1:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
#!/usr/bin/env python3
import fractions


def main():
    A, B, C, D = map(int, input().split())

    num_C = B // C - (A - 1) // C
    num_D = B // D - (A - 1) // D
    lcm = C * D // fractions.gcd(C, D)
    num_CD = B // lcm - (A - 1) // lcm

    ans = (B - A + 1) - num_C - num_D + num_CD
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N=int(input())
ans=0
l=[0]*N
for i in range(N):
   ans+=int(input())//2
for i in range(1,N):
   if l[i]==1 and l[i-1]==1:
      ans+=1
      l[i]=0
print(ans)
# Judge status: Accepted
s = input()
for i in range(1, 4):
    if s[i] == s[i - 1]:
        print("Bad")
        exit()
print("Good")
# Judge status: Accepted
A, B, C, K = list(map(int, input().split()))

if K%2 == 0:
  if A-B > 10**18:
    print("Unfair")
  else:
    print(A-B)
else:
  if -(A-B) > 10**18:
    print("Unfair")
  else:
    print (-(A-B))
# Judge status: Accepted
a, s = int(input()), input()
print(s if a>=3200 else 'red')