Harryxun/stf_run huggingface dataset:
S = list(input())
stlen = len(S) 
if len(S)%2 == 0:
    a = '10'*(stlen/2)
    b = '01'*(stlen/2)
    counta = countb = 0
    for i in range(stlen):
        if a[i] != S[i]:
            counta += 1
        if b[i] != S[i]:
            countb += 1
    print(min(counta,countb))
else:
    a = '10'*(int(stlen/2))+'1'
    b = '01'*(int(stlen/2))+'0'
    counta = countb = 0
    for i in range(stlen):
        if a[i] != S[i]:
            counta += 1
        if b[i] != S[i]:
            countb += 1
    print(min(counta,countb))

### FIXED CODE ###

S = list(input())
stlen = len(S) 
if len(S)%2 == 0:
    a = '10'*(int(stlen/2))
    b = '01'*(int(stlen/2))
    counta = countb = 0
    for i in range(stlen):
        if a[i] != S[i]:
            counta += 1
        if b[i] != S[i]:
            countb += 1
    print(min(counta,countb))
else:
    a = '10'*(int(stlen/2))+'1'
    b = '01'*(int(stlen/2))+'0'
    counta = countb = 0
    for i in range(stlen):
        if a[i] != S[i]:
            counta += 1
        if b[i] != S[i]:
            countb += 1
    print(min(counta,countb))
import math
X=int(input())
answers=[]
for a in range(-math.ceil(X**0.2),math.ceil(X**0.2)+1):
    for b in range(-math.ceil(X**0.2),math.ceil(X**0.2)+1):
        if a**5-b**5==X:
            answers.append([a,b])
print(answers[0][0],answers[0][1])


### FIXED CODE ###

import math
X=int(input())
a=pow(10,9)
c=math.ceil(a**0.3)
answers=[]
for a in range(-c,c+1):
    for b in range(-c,c+1):
        if pow(a,5)-pow(b,5)==X:
            answers.append(a)
            answers.append(b)
            break
print(answers[0],answers[1])
N,M = map(int, input().split())
ks = [[int(i) for i in input().split()] for j in range(M)]
p = [int(i) for i in input().split()] 

l = max(max(ks))

lis_swi = s = [[] for i in range(l)]

for m in range(M):
    for s in ks[m][1:]:
        lis_swi[s-1].append(m)


ans = 0

for i in range(1 << l):
    cnt_on = [0]*M
    for j in range(l):
        if ((i >> j) & 1) == 1:
            for m in lis_swi[j]:
                cnt_on[m] +=1

    f = True
    for m in range(M):
        if cnt_on[m]%2 != p[m]:
            f = False
            break
    
    if f:
        ans += 1


print(ans)

### FIXED CODE ###

N,M = map(int, input().split())
ks = [[int(i) for i in input().split()] for j in range(M)]
p = [int(i) for i in input().split()] 

ans = 0

for i in range(1 << N):
    cnt_on = [0]*M
    for j in range(N):
        if ((i >> j) & 1) == 1:
            for m in range(M):
                cnt_on[m] += ks[m][1:].count(j+1)

    c = 0
    for m in range(M):
        if cnt_on[m]%2 == p[m]:
            c += 1
    
    if c == M:
        ans += 1


print(ans)
def check(y,x):
    if 0<=y<=n-1 and 0<=x<=n-1:
        return True
    return False

n,m=map(int,raw_input().split())
a=[raw_input() for _ in xrange(n)]
b=[raw_input() for _ in xrange(m)]
for i in xrange(n):
    for j in xrange(n):
        cnt=0
        for k in range(m):
            for l in xrange(m):
                if check(k+i,l+j):
                    if a[k+i][l+j]==b[k][l]:
                        cnt+=1
        if cnt==m*m:
            print("Yes")
            exit()
print("No")


### FIXED CODE ###

a,b=map(int,raw_input().split())
if a==b:
    print("Draw")
elif a==1:
    print("Alice")
elif b==1:
    print("Bob")
elif b<a:
    print("Alice")
else:
    print("Bob")
def main():
    # n = int(input())
    # l = [int(j) for j in input().split()]
    

    for t in range(int(input())):
        #n,m = [int(j) for j in input().split()]
        n = int(input())
        print(n+n**2+n**3)
# endregion

if __name__ == "__main__":
    main()


### FIXED CODE ###

n = int(input())
print(n+n**2+n**3)
A,B,C,D = map( int,input().split() )
while A > 0 and c > 0:
    C -= B
    if C <= 0 :
        print( 'Yes' )
        exit()
    A -= D 
    if A <= 0 :
        print( 'No' )
        exit()


### FIXED CODE ###

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

while A > 0 and C > 0:
    C -= B
    if C <= 0:
        print("Yes")
        exit()
    A -= D
    if A <= 0:
        print("No")
        exit()
s = input()
if s == "Sunny"
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
else:
    print("Sunny")

### FIXED CODE ###

s = input()
if s == "Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
else:
    print("Sunny")
INF = 1*((10**9)*5000 + 1)
n, k = map(int, input().split())
P = [*map(lambda x: int(x)-1, input().split())]
C = [*map(int, input().split())]

# print(n,k)
# print(P)
# print(C,end='\n\n')

vis = [False]*(n+1)
def dfs(i, c, sum_c=0):
    if vis[i]: return c, sum_c
    vis[i] = True
    c.append(C[i])
    sum_c += C[i]
    ret = dfs(P[i], c, sum_c)
    # vis[i] = False
    return ret

lst_costs = []
for i in range(n):
    costs, lp_c = dfs(i, [])
    if len(costs) == 0: continue
    lst_costs.append((costs,lp_c))

def max_calc(costs, st, num):
    len_c = len(costs)
    max_c = -INF
    sum_c = 0
    for d in range(num):
        i = (st + d) % len_c
        x = costs[i]
        sum_c += x
        max_c = max(max_c, sum_c)
    return max_c

score = -INF
for costs, lp_c in lst_costs:
    # print(costs, lp_c)
    len_c = len(costs)
    cnt, remain = divmod(k, len_c)
    for st in range(len_c):
        cost = -INF
        if lp_c <= 0:
            max_c = max_calc(costs, st, len_c)
            cost = max_c
            # print('1. cost',cost)
        else: # lp_c > 0:
            if cnt == 0:
                max_c = max_calc(costs, st, min(len_c, k))
                cost = max_c
                # print('2. cost',cost)
            else: # cnt > 0
                max_c = max_calc(costs, st, len_c + remain)
                if cnt > 1 :
                    cost = lp_c * (cnt-1)
                    cost = max({cost, cost + max_c, max_c})
                    # print('3. cost',cost)
                else: # cnt == 1
                    cost = max({lp_c, max_c})
                    # print('4. cost',cost)
        score = max({score, cost})
print(score)


### FIXED CODE ###

n, k = map(int, input().split())
P = [*map(lambda x: int(x)-1, input().split())]
C = [*map(int, input().split())]

INF = 10**18
max_score = -INF
for st in range(n):
    lc = 0 # lap count
    lap_sc = 0 # lap score
    nx = st
    while True:
        lc += 1
        lap_sc += C[nx]
        nx = P[nx]
        if nx == st: break

    sum_sc = 0
    kc = 0
    while True:
        kc += 1
        if k < kc: break

        sum_sc += C[nx]
        score = sum_sc + max(0, lap_sc) * ((k - kc) // lc)
        max_score = max(max_score, score)

        nx = P[nx]
        if nx == st: break

print(max_score)

# print('===')
# print(n,k)
# print(P)
# print(C,end='\n\n')
array = list(map(int, input().split()))
if array[0] == array[2]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

array = list(map(str, input()))
if array[0] == array[2]:
    print("Yes")
else:
    print("No")
n= int(input())
a= list(map(int,input().split()))
 
ans = 1
over = -1
 
if 0 in a:
    print(0)
    exit(0)

for i in a:
  ans = i * ans
  if ans > 10**18:
	print(over)
    exit(0)

print(ans)

### FIXED CODE ###

n= int(input())
a= list(map(int,input().split()))
 
ans = 1
over = -1
 
if 0 in a:
    print(0)
    exit(0)

for i in a:
  ans = i * ans
  if ans > 10**18:
      print(-1)
      exit(0)

print(ans)
letter = str(input())
N = len(letter)

l_1 = letter[:int((N-1)/2)]
l_2 = letter[int((N+3)/2-1):]

if(l == l[::-1] and l_1 == l_1[::-1] and l_2 == l_2[::-1]):
    ans = "Yes"
else:
    ans = "No"
# print(l_1)
# print(l_2)

print(ans)


### FIXED CODE ###

letter = str(input())
N = len(letter)

l_1 = letter[:int((N-1)/2)]
l_2 = letter[int((N+3)/2-1):]

if(letter == letter[::-1] and l_1 == l_1[::-1] and l_2 == l_2[::-1]):
    ans = "Yes"
else:
    ans = "No"
# print(l_1)
# print(l_2)

print(ans)
n = int(input())
print(len(list(set(map(int, input() for i in range(n))))))

### FIXED CODE ###

n = input()
n = int(n)
s = set([])

for i in range(1, n+1):
    a = input()
    a = int(a)
    s.add(a)

print(len(s))
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = sorted([A[i]-B[i] for i in range(N)],reverse=True)
cp = 0
cm = 0
for i in range(N):
    if C[i]>0:
        cp += C[i]
    elif C[i]<0:
        cm += -C[i]
if cm>cp:
    print(-1)
else:
    cur = 0
    tot = C[cur]
    for i in range(N):
        if C[i]<0:
            while tot-abs(C[i])<0:
                tot += C[cur+1]
                cur += 1
            tot += C[i]
print(cur+1+cm)     

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = sorted([A[i]-B[i] for i in range(N)])
tot = sum(C)
cnt = 0
if tot<0:
    cnt = -1
else:
    a = 0
    for i in range(N):
        if C[i]<0:
            a += C[i]
            cnt += 1
        else:
            break
    for i in range(N-1,-1,-1):
        if a>=0:break
        a += C[i]
        cnt += 1
print(cnt)
n = int(input())
w = [map(int, input().split())]
ans = float('inf')
for i in range(n):
    s1 = sum(w[:i])
    s2 = sum(w[i:])
    z = int(abs(s1 - s2))
    ans = min(ans, z)
print(ans)

### FIXED CODE ###

n = int(input())
w = list(map(int, input().split()))
ans = float('inf')
for i in range(n):
    s1 = sum(w[:i])
    s2 = sum(w[i:])
    z = abs(s1 - s2)
    ans = min(ans, z)
print(ans)
import sys
read=sys.stdin.read
readline=sys.stdin.readline

def isinsums(x,lst):
  if not lst:
    if x:
      return False
    else:
      return True
  s=sum(lst)
  if (s-x)%2:
    return False
  t=(s+x)//2
  m1=1<<(t+1)-1
  m2=1<<t
  sums=0
  for e in lst:
    sms=(sums|(1+sums)<<e)&m1
    if (sms|1)&m2>0:
      return True
  return False

s=readline().strip()
x,y=map(int,readline().split())

s=s.replace('TF','T F')
s=s.replace('FT','F T')
bs=s.split()
if bs[0][0]=='F':
  x-=len(bs[0])
  del bs[0]

xy=[[],[]]
f=0
for i,e in enumerate(bs):
  if not i%2:
    l=len(e)
  else:
    f^=l%2
    xy[f].append(len(e))
if isinsums(x,xy[0]) and isinsums(y,xy[1]):
  print('Yes')
else:
  print('No')


### FIXED CODE ###

import sys
read=sys.stdin.read
readline=sys.stdin.readline

def isinsums(x,lst):
  s=sum(lst)
  t=(s+x)//2
  if s==0 and x==0:
    return True
  if (s-x)%2 or t<0:
    return False
  t=(s+x)//2
  m1=(1<<(t+1))-1
  m2=1<<t
  sums=0
  for e in lst:
    sums=(sums|(1+sums)<<e)&m1
  sums|=1
  if (sums)&m2>0:
    return True
  return False

s=readline().strip()
x,y=map(int,readline().split())

s=s.replace('TF','T F')
s=s.replace('FT','F T')
bs=s.split()
if bs[0][0]=='F':
  x-=len(bs[0])
  del bs[0]

xy=[[],[]]
f=0
for i,e in enumerate(bs):
  if not i%2:
    l=len(e)
  else:
    f^=l%2
    xy[f].append(len(e))
if isinsums(x,xy[0]) and isinsums(y,xy[1]):
  print('Yes')
else:
  print('No')
import numpy as np
import sys
input = sys.stdin
h, w, d = map(int, input().split())
num = h * w
mass = np.array([[0, 0] for _ in range(num + 1)])
mp = np.zeros(num+1, dtype=int)
for i in range(h):
    for j, a in enumerate(list(map(int, input().split()))):
        mass[a] += [i, j]
for i in range(d+1, num+1):
    mp[i] = mp[i-d] + np.sum(abs(mass[i]-mass[i-d]))
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(mp[r]-mp[l])


### FIXED CODE ###

import sys
input = sys.stdin.readline
h, w, d = map(int, input().split())
num = h * w
x = [0] * (num + 1)
y = [0] * (num + 1)
mp = [0] * (num + 1)
for i in range(h):
    for j, a in enumerate(map(int, input().split())):
        x[a], y[a] = [i+1, j+1]
for i in range(d+1, num+1):
    mp[i] = mp[i-d] + abs(x[i] - x[i-d]) + abs(y[i] - y[i-d])
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(mp[r]-mp[l])
N = int(input())
if(N in [1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81]):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A, B = map(int, input().split())
print(A*B if A <= 9 and B <= 9 else -1)
N = int(input())
A = [int(x) for x in input().split(' ')]

s = 0
mc = 0
for i in A:
  if i <= 0:
    mc += 1
  s += abs(i)

if (mc % 2 == 1):
  mv = min(A[0],A[-1])
  #print('mv',mv)
  s -= mv*2
print(s)

### FIXED CODE ###

A,B,T = [int(x) for x in input().split(' ')]
print(int(B * ((T + 0.5) // A)))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
n =  int(input())
lista = a+b+c
call_number = []
for i in range(n):
    k = int(input())
    call_number.append(k)
bingo_number_list = []
for m,n in enumerate(lista):
    if n in call_number:
        bingo_number_list.append(m)
    
lista  = [0,4,8]
list0 = [0,1,2]
list1 = [3,4,5]
list2 = [6,7,8]
list3 = [0,3,6]
list4 = [1,4,7]
list5 = [2,5,8]
list6 = [0,4,8]
list7 = [2,4,6]

for i in range(8):
    name = "list"+str(i)
    if set(name) <= set(lista):
        bingo += 1

if bingo > 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
n =  int(input())
lista = a+b+c
call_number = []
for i in range(n):
    k = int(input())
    call_number.append(k)
bingo_number_list = []
for m,n in enumerate(lista):
    if n in call_number:
        bingo_number_list.append(m)
    
list0 = [0,1,2]
list1 = [3,4,5]
list2 = [6,7,8]
list3 = [0,3,6]
list4 = [1,4,7]
list5 = [2,5,8]
list6 = [0,4,8]
list7 = [2,4,6]
bingo = 0
for i in range(8):
    if set(list0) <= set(bingo_number_list):
        bingo += 1
    if set(list1) <= set(bingo_number_list):
        bingo += 1
    if set(list2) <= set(bingo_number_list):
        bingo += 1
    if set(list3) <= set(bingo_number_list):
        bingo += 1
    if set(list4) <= set(bingo_number_list):
        bingo += 1
    if set(list5) <= set(bingo_number_list):
        bingo += 1
    if set(list6) <= set(bingo_number_list):
        bingo += 1
    if set(list7) <= set(bingo_number_list):
        bingo += 1

if bingo > 0:
    print("Yes")
else:
    print("No")
n=int(input())
if (n < 1000)
	print("ABC")
else
	print("ABD")


### FIXED CODE ###

n = int(input())
if n < 1000:
	print('ABC')
else:
	print('ABD')
n,k = map(int,input().split())
p = list[]
ans = 0

for i in range (n):
  p[i] = int(input())

p.sort()

for i in range(k):
  ans += p[i]

print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0


p.sort()

for i in range(k):
  ans += p[i]

print(ans)
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N, K=LI()
A=LI()

counts = collections.Counter(A)

result = 0
while len(counts) != K:
    result=counts.pop()[1]
    
print(result)
    

### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N, K=LI()
A=LI()

counts = collections.Counter(A)
counts = counts.values()
counts = sorted(counts, reverse=True)
result = 0
while len(counts) > K:
    result+=counts.pop()
    
print(result)
mod = 998244353

N, S, *A = map(int, open(0).read().split())

dp = [[0] * (S + 1) for _ in range(N + 1)]
dp[0][0] = 1

for i, a in enumerate(A, 1):
    for j in range(S + 1):
        dp[i][j] = 2 * dp[i - 1][j] + dp[i - 1][j - a] * (j >= a)

print(dp[N][S])

### FIXED CODE ###

mod = 998244353

N, S, *A = map(int, open(0).read().split())

dp = [[0] * (S + 1) for _ in range(N + 1)]
dp[0][0] = 1

for i, a in enumerate(A):
    for j in range(S + 1):
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod

        if j + a <= S:
            dp[i + 1][j + a] += dp[i][j]
            dp[i + 1][j + a] %= mod

print(dp[N][S])
import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

##* graph
##pre graph
m,lst,nxt,to=0,[],[],[]

def init_graph(node_count, edge_count):
    global lst,nxt,to
    lst = [-1 for _ in range(node_count)]
    nxt = [0  for _ in range(edge_count)]
    to  = [0  for _ in range(edge_count)]

# bidirection
def add_edge(u, v):
    global m
    nxt[m], lst[u], to[m], m = lst[u], m, v, m + 1
    nxt[m], lst[v], to[m], m = lst[v], m, u, m + 1

# bidirection weight
def add_edge(u, v, w):
    global m
    nxt[m], lst[u], to[m], m = lst[u], m, (v, w), m + 1
    nxt[m], lst[v], to[m], m = lst[v], m, (u, w), m + 1

def traverse(u):
    m = lst[u]
    while m != -1:
        yield m
        m = nxt[m]


n = getint()
init_graph(n, 2 * n)

for _ in range(n - 1):
    u, v, w = getints()
    add_edge(u - 1, v - 1, w)

def get_distance(u, dist, d):
    dist[u] = d
    for m in traverse(u):
        v, w = to[m]
        if dist[v] >= 0:
            continue
        get_distance(v, dist, d + w)

dist = [-1]*n
get_distance(0, dist, 0)


for i in range(n):
    print(dist[i] % 2)

### FIXED CODE ###


import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

##* graph
##pre graph
m,lst,nxt,to=0,[],[],[]

def init_graph(node_count, edge_count):
    global lst,nxt,to
    lst = [-1 for _ in range(node_count)]
    nxt = [0  for _ in range(edge_count)]
    to  = [0  for _ in range(edge_count)]

# bidirection
def add_edge(u, v):
    global m
    nxt[m], lst[u], to[m], m = lst[u], m, v, m + 1
    nxt[m], lst[v], to[m], m = lst[v], m, u, m + 1

# bidirection weight
def add_edge(u, v, w):
    global m
    nxt[m], lst[u], to[m], m = lst[u], m, (v, w), m + 1
    nxt[m], lst[v], to[m], m = lst[v], m, (u, w), m + 1

def traverse(u):
    m = lst[u]
    while m != -1:
        yield m
        m = nxt[m]


n = getint()
init_graph(n, 2 * n)

for _ in range(n - 1):
    u, v, w = getints()
    add_edge(u - 1, v - 1, w)

def get_distance(u, dist):
    dist[u] = 0
    stk = [(u, 0)]
    while stk:
        v, d = stk[-1]
        stk.pop()
        for m in traverse(v):
            vv, w = to[m]
            if dist[vv] >= 0:
                continue
            dist[vv] = d + w
            stk.append((vv, d + w))


dist = [-1]*n
get_distance(0, dist)

# print(dist)


for i in range(n):
    print(dist[i] % 2)
N=input()
a=list(map(int,input().split()))
c=0
T=True
for i in a:
    if (i%2)!=0:
        print(c)
        break
    else:
        while T:
            a=list(map(lambda x:x/2,a))
            c+=1
            b=list(map(lambda x:True if x%2==0 else False,a))
            T=b[False]
print(c)

### FIXED CODE ###

print(input().count("1"))
import sys

n = int(input())
d = list(map(int, input().split()))
dic = {}
val = 0

for i in range(n):
    if d[i] in dic.keys():
        dic[d[i]] += 1
    else:
        dic[d[i]] = 1

dic = sorted(dic.items())

for i in range(len(dic) - 1):
    val += dic[i][1]
    if val == n//2:
        ans = (dic[i][0] + 1, dic[i+1][0])
        break
    elif i == len(dic) - 2:
        print(0)
        sys.exit()

print(ans[1] - ans[0] + 1)


### FIXED CODE ###

import sys

n = int(input())
d = list(map(int, input().split()))
dic = {}
val = 0

for i in range(n):
    if d[i] in dic.keys():
        dic[d[i]] += 1
    else:
        dic[d[i]] = 1

dic = sorted(dic.items())

if len(dic) == 1:
    print(0)
    sys.exit() 

for i in range(len(dic) - 1):
    val += dic[i][1]
    if val == n//2:
        ans = (dic[i][0], dic[i+1][0])
        print(ans[1] - ans[0])
        break
    elif val > n//2:
        print(0)
        break
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    key = [0]
    box = [0]
    for _ in range(M):
        k,_ = LI()
        key.append(k)
        b = 0
        for c in LI():
            b += 2**(c-1)
        box.append(b)

    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(1,M+1):
        for j in range(2**N):
            dp[i][j] = min(dp[i-1][j],dp[i-1][j - (j&box[i])]+key[i])
    if dp[-1][-1] == INF:
        print(-1)
    else:
        print(dp[-1][-1])
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    INF = 10**8
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    key = [0]
    box = [0]
    for _ in range(M):
        k,_ = LI()
        key.append(k)
        b = 0
        for c in LI():
            b += 2**(c-1)
        box.append(b)

    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(1,M+1):
        for j in range(2**N):
            dp[i][j] = min(dp[i-1][j],dp[i-1][j - (j&box[i])]+key[i])
    if dp[-1][-1] == INF:
        print(-1)
    else:
        print(dp[-1][-1])
if __name__ == '__main__':
    main()
def calc(oniend, kid , pase):
  if (pase <= 0) or ((oniend * pase) < kid):
    return "NO"
  #elif ((oniend - kid) % pase) == 0:
  else:
    return "YES"

in1 = input().split()
in2 = input().split()
in3 = input()
oni = int(in1[0])
onispeed = int(in1[1])
kid = int(in2[0])
kidspeed = int(in2[1])
time = int(in3)

pase = onispeed - kidspeed
oniend = (pase * time) + oni

if (pase <= 0) or ((oniend * pase) < kid):
  print("NO")
  #elif ((oniend - kid) % pase) == 0:
else:
  print("YES")



### FIXED CODE ###

hoge=input()
print(hoge[0:3])
S = int(input())
h = int(S // (60*60))
m = int((S % 3600) // 60)
s = int((S % 3600) %60)

print('{0}:{1}:{2}'.format(h.m.s))

### FIXED CODE ###

S = int(input())
h = int(S // (60*60))
m = int(S / 60) % 60
s = S%60

print('{}:{}:{}'.format(h,m,s))
N, M = input().split()
for _ in range(M):
    a, b = input().split()
for _ in range(1, N+1):
    print(a.count("i")+b.count("i")

### FIXED CODE ###

n, m = map(int, input().split())
a, b = [0]*m, [0]*m
for i in range(m):
    a[i], b[i] = map(int, input().split())
for j in range(1,n+1):
    print(a.count(j)+b.count(j))
def isEven(num):
  if num%2 == 0:
  	return True
  return False

def isOdd(num):
  if num%2 == 1:
    return True
  return False

if __name__ == "__main__":
  x,k,d = map(int, input().split())
  div = x//d
  cmp = x
  defo = x
  if isOdd(k):
    if x > d:
      if k%div != 0:
        div = min(div,k%div)
      for i in [d,-d]:
        cmp = min(cmp,abs(defo+div*i))
      print(cmp)
    else:
      for i in [d,-d]:
        cmp = min(cmp,abs(defo+i))
      print(cmp)
  if isEven(k):
    div = x//(2*d)
    if x > d:
      div = min(div,k)
      for j in range(1,div)
        for i in [d,-d]:
          cmp = min(cmp,abs(defo+(2*j)*i))
      print(cmp)
    else:
      print(cmp)

### FIXED CODE ###

x,k,d = map(int,input().split())
x = abs(x)
div = min(x//d,k)
cnt = 0
k-=div
x -= div*d
if k%2 == 0:
  print(x)
else:
  print(abs(x-d))
n = int(input())
a = list(int(x) for x in input().split())
x = 0

a.reverse()
for i in range(n):
    if a[-1] - a[-2] == 0:
        print("NO")
        x = 1
        break
    a.pop()

if x == 0:
    print("YES")


### FIXED CODE ###

n = int(input())
a = list(int(x) for x in input().split())
x = 0
 
a.sort()
for i in range(n-1):
    if a[-1] - a[-2] == 0:
        print("NO")
        x = 1
        break
    a.pop()
 
if x == 0:
    print("YES")
N = int(input())
A = list(map(int, input().split()))
cnt = 0

while all(a%2 == 0 for a in A):
  A = [a/2 a for A]
  cnt += 1

print(cnt)

### FIXED CODE ###

N = input()
A = list(map(int, input().split()))
cnt = 0
while all(a%2 == 0 for a in A):
  A = [a/2 for a in A]
  cnt += 1
print(cnt)