Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())
a = list(map(int, input().split()))
inf = float("inf")
dp = [-inf] * (n+1)
dp[0] = 0
for i in range(1, n+1):
    for j in a:
        cost_j = int("0255456376"[j])
        if i- cost_j >= 0:
            dp[i] = max(dp[i], j+dp[i-cost_j]*10)
        print(dp)
ans = dp[n]
if ans == -inf:
    ans = 0
print(ans)



### FIXED CODE ###

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

inf = float("inf")
dp = [-inf for i in range(n+1)]
dp[0] = 0

cost = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

for i in a:
    for j in range(1, n+1):
        if j - cost[i] >= 0:
            dp[j] = max(dp[j], dp[j-cost[i]]+1)

a.sort(reverse=True)
ans = ""
while n > 0:
    for i in a:
        state = True
        if n-cost[i] >= 0 and dp[n-cost[i]] == dp[n]-1:
            ans += str(i)
            n -= cost[i]
            state = False
            break
    if state:
        break

if ans == "":
    print(0)
else:
    print(ans)
N, X = map(int, raw_input().split())
ans = 0
if N%2 ==0:
    d = min(X, N-X)
    ans = (N-d)*3
else:
    ans = (N-1)*3

print(ans)

### FIXED CODE ###

import numpy as np

N = int(raw_input())
data = np.array(map(int, raw_input().split()))
data = np.sort(data)
idx = np.array([True, False]*N)

ans = sum(data[idx])

print(ans)
import math

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

array = []

for i in range(N):
    x = list(map(int, input().split()))
    array.append(X)
    
dis = 0
sum_dis = 0
for i in range(N-1):
    for j in range(i+1,N):
        for k in range(D):
            dis += (array[i][k] - array[i][k])**2
        dis = math.sqrt(dis)
        if(type(dis) == int): sum_dis += 1
print(sum_dis)

### FIXED CODE ###

import math

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

array = [[0 for i in range(10)] for j in range(10)]

for i in range(N):
    x = list(map(int, input().split()))
    for j in range(0, D):
        array[i][j] = x[j];
sum_dis = 0
for i in range(0,N-1):
    for j in range(i+1,N):
        dis = 0
        for k in range(D):
            dis += (array[i][k] - array[j][k])**2
        dis = math.sqrt(dis)
        if(dis.is_integer()): sum_dis += 1
print(sum_dis)
def PrimeNumber(N):
    ans = list(range(2, N + 1))
    i = 0
    while ans[i] < N ** 0.5 + 1:
        j = 2
        temp = ans[i]
        while temp * j <= ans[-1]:
            if temp * j in ans:
                ans.remove(temp * j)
            j += 1
        i += 1
    return ans

N=int(input())

mod=10**9+7
PN=PrimeNumber(N)
P=[0]*(N+1)

for i in range(2,N+1):
    temp=i
    for j in PN:
        if temp<j:
            break
        cnt=0
        while temp%j==0:
            cnt+=1
            temp=temp//j
        P[j]+=cnt

ans=1

for i in range(1,N+1):
    if P[i]!=0:
        ans=(ans*(P[i]+1))%mod
print(ans)



### FIXED CODE ###

def PrimeNumber(N):
    if N==2:
        ans=[2]
        return ans
    ans = list(range(2, N + 1))
    i = 0
    while ans[i] < N ** 0.5 + 1:
        j = 2
        temp = ans[i]
        while temp * j <= ans[-1]:
            if temp * j in ans:
                ans.remove(temp * j)
            j += 1
        i += 1
    return ans

N=int(input())

if N==1:
    print(1)
    exit()

mod=10**9+7
PN=PrimeNumber(N)
P=[0]*(N+1)

for i in range(2,N+1):
    temp=i
    for j in PN:
        if temp<j:
            break
        cnt=0
        while temp%j==0:
            cnt+=1
            temp=temp//j
        P[j]+=cnt

ans=1

for i in range(1,N+1):
    if P[i]!=0:
        ans=(ans*(P[i]+1))%mod
print(ans)
n = int(input())
t = [int(input()) for i in range(n)]

def gcd(a, b):
  if a<b:
    a, b = b, a
  if b==0:
    return a
  return gcd(b, a%b)

def lcm(a, b):
  g = gcd(a, b)
  return a/g*b

ans = 1
for i in range(n):
  ans = lcm(ans, t[i])
print(int(ans))

### FIXED CODE ###

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

def gcd(a, b):
  if a<b:
    a, b = b, a
  if b==0:
    return a
  return gcd(b, a%b)

def lcm(a, b):
  g = gcd(a, b)
  return a*b//g

ans = 1
for i in range(n):
  ans = lcm(ans, t[i])
print(ans)
a,b = map(int,input().split())
if a>b:
  print(str(b)*a)
 else:
  print(str(a)*b)

### FIXED CODE ###

a,b = map(int, input().split())
if a>b:
    print(str(b)*a)
else:
    print(str(a)*b)
#encoding=utf-8

import sys
import math

printf = sys.stdout.write

x1,y1,x2,y2 = map(int,raw_input().split())

X = x2 - x1
Y = y2 - y1
printf(str(math.sqrt(X**2 + Y**2)))

### FIXED CODE ###

#encoding=utf-8

import sys
import math

printf = sys.stdout.write

x1,y1,x2,y2 = map(float,raw_input().split())

X = x2 - x1
Y = y2 - y1
printf(str(math.sqrt(X**2 + Y**2)))
from statistics import mean
import itertools
import math

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

pos_comb = itertools.combinations(pos, 2)
dis_list = []
for i in pos_comb:
    dis_list.append(math.sqrt((i[0][0]-i[1][0])**2+(i[0][1]-i[1][1])**2))
print(mean(dis_list)*(float(n)-1.0))

### FIXED CODE ###

from statistics import mean
import itertools
import math

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

pos_comb = itertools.combinations(pos,2)
dis_list = []
for i in pos_comb:
    dis_list.append(math.sqrt((i[0][0]-i[1][0])**2+(i[0][1]-i[1][1])**2))

print(mean(dis_list)*(float(n)-1.0))
a = input()
b = input()
print(b + a)

### FIXED CODE ###

a, b = map(str, input().split())
print(b + a)
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
out = 0
if n == 1:
    if a[0] != 0:
        out = 1
elif a[0] == 0:
    for i in range(1,n//2+1):
        if a[2*i-1] == a[2*i] == 2*i:
            None
        else:
            out = 1
elif a[0] == 1:
    for i in range(n//2):
        if a[2*i] == a[2*i+1] == 2*i+1:
            None
        else:
            out = 1
else:
    out = 1
if out:
    print(0)
else:
    print(2**(n//2)%(10**9+7))

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
a.sort()
out = 0
if n == 1:
    if a[0] != 0:
        out = 1
elif a[0] == 0:
    if n%2 == 0:
        out = 1
    else:
        for i in range(1,n//2+1):
            if a[2*i-1] == a[2*i] and a[2*i] == 2*i:
                None
            else:
                out = 1
elif a[0] == 1:
    if n%2 == 1:
        out = 1
    else:
        for i in range(n//2):
            if a[2*i] == a[2*i+1] == 2*i+1:
                None
            else:
                out = 1
else:
    out = 1
if out:
    print(0)
else:
    a = 1
    for i in range(n//2):
        a *= 2
        a = a%(10**9+7)
    print(a)
import itertools

n, m = map(int, input().split(' '))
x = map(int, input().split(' '))
if n >= m:
    print(0)
else:
    x = sorted(x)
    seq = [i for i in range(1,m)]
    locations = list(itertools.combinations(seq,n-1))
    best_sc = None
    for location in locations:
        sc = 0
        for i in range(0,n):
            g = None
            if i == 0:
                g = x[:location[i]]
            elif i == n-1:
                g = x[location[i-1]:]
            else:
                g = x[location[i-1]:location[i]]
            sc += g[-1] - g[0]
        if (best_sc is None) or (best_sc > sc):
            best_sc = sc
    print(best_sc)


### FIXED CODE ###

n, m = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
if n >= m:
    print(0)
else:
    x.sort()
    d = [x[i+1] - x[i] for i in range(m-1)]
    d.sort()
    #print(d)
    print(sum(d[:m-n]))
import functools

N = int(input())
print(functools.reduce(lambda x, y: x * y % 1000000007, range(2, N+1)))


### FIXED CODE ###

import functools

N = int(input())
print(functools.reduce(lambda x, y: x * y % 1000000007, range(1, N+1)))
def popcount(x):
  r, q = 0, x
  while x:
    r += 1
    x &= x - 1
  return r, q
 
n = int(input())
r = range(n)
a = [[0, 0] for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y] |= 1 << (x - 1)
l = (1 << n) - 1 
b = sorted(map(popcount, range(1, l + 1)))
ans = next((i for i, x in reversed(b)
           if all(a[j][0] & x == a[j][1] & l - x == 0 for j in r if x >> j & 1), 0) 
print(ans)


### FIXED CODE ###

from itertools import combinations

n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)

fail = lambda x: (not all(a[i][0].isdisjoint(x) and a[i][1] < x for i in x))

while n and all(map(fail, map(set, combinations(r, n)))):
  n -= 1
print(n)
n = int(input())

l = []
for i in range(n-1, 0, -1):
    if (n/i).is_integer() == True: 
        l.append(i)
        l.append(n/i)
        break
if l[0] < 10 and l[1] < 10:
    print('Yes')
else:
    print("No")

### FIXED CODE ###

n = int(input())
bool = False
for i in range(1, 10, 1):
    for j in range(1, 10, 1):
        if i*j == n:
            bool = True
            break
        else: 
            continue
            
if bool == True:
    print("Yes")
else: 
    print("No")
l,r = map(int,input().split())

if r-l >= 2019:
  ans = 0
else:
  mod_l = l % 2019  
  mod_r = r % 2019
  if mod_r < mod_l:
    ans = 0
  elif mod_l * mod_r == 0:
    ans = 0
    
  else:
    l_list=[]
    a = list(range(mod_l, mod_r+1))
    for i in range(mod_l, mod_r+1):
      ai = a[i]
      for j in range(i+1,mod_r+1):
        aj = a[j]
    l = (ai*aj) % 2019
    l_list.append(l)
    ans = min(l_list)
    
print(ans)

### FIXED CODE ###

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

ans = min([b,n*a])

print(ans)
n,m=map(int,input().split())
edg=[[0]*(n+1) for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    edg[a][b]=1
    edg[b][a]=1
f=1
for i in range(2,n+1):
    if edg[i][1]==1 and edg[i][n]==1:
        f=0
print("POSSIBLE" if f==0 else "IMPOSSIBLE")


### FIXED CODE ###

from _collections import deque
n,m=map(int,input().split())
edg=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    edg[a].append(b)
    edg[b].append(a)
dep=[-1]*(n+1)
dep[1]=0
data=deque([1])
while len(data)>0:
    p=data.popleft()
    for i in edg[p]:
        if dep[i]==-1:
            dep[i]=dep[p]+1
            data.append(i)
print("POSSIBLE" if dep[n]==2 else "IMPOSSIBLE")
a_index, a_v = map(int, input().split())
b_index, b_v = map(int, input().split())
t = input()
 
d = abs(b_index - a_index)
d_v = abs(b_v - a_v)
 
if d == 0 :
  print("YES")
elif d_v != 0 and d / d_v <= t :
  print("YES")
else :
  print("NO")

### FIXED CODE ###

a_index, a_v = map(int, input().split())
b_index, b_v = map(int, input().split())
t = int(input())
 
d = abs(b_index - a_index)
d_v = a_v - b_v
 
if d == 0 :
  print("YES")
elif d_v > 0 and d / d_v <= t :
  print("YES")
else :
  print("NO")
n = int(input())
lsn=[int(input()) for i in range(n)]
m = int(input())
lsm=[int(input()) for i in range(m)]
ls = []
for i in range(n):
  ls.append(lsn.count(lsn[i])-lsm.count(lsn[i]))
if max(ls) <= 0:
  print(0)
else:
  print(max(ls))

### FIXED CODE ###

n = int(input())
lsn=[(input()) for i in range(n)]
m = int(input())
lsm=[(input()) for i in range(m)]
ls = []
for i in range(n):
  ls.append(lsn.count(lsn[i])-lsm.count(lsn[i]))
if max(ls) <= 0:
  print(0)
else:
  print(max(ls))
import sys

readline = sys.stdin.readline
h, w, k = map(int, readline().split())
s = [readline().rstrip() for _ in range(h)]
ans = [[0] * w for _ in range(h)]
peace = 1
not_strawberry = []
for i in range(h):
    strawberry = 0
    for j in range(w):
        if s[i][j] == '#':
            if strawberry == 1:
                peace += 1
                strawberry = 1
            else:
                strawberry = 1
        ans[i][j] = str(peace)
    if not strawberry:
        not_strawberry.append(i)
    else:
        for j in not_strawberry:
            ans[j] = ans[i]
        peace += 1
i = min(not_strawberry) - 1
for j in not_strawberry:
    ans[j] = ans[i]

print('\n'.join(' '.join(i) for i in ans))


### FIXED CODE ###

import sys

readline = sys.stdin.readline
h, w, k = map(int, readline().split())
s = [readline().rstrip() for _ in range(h)]
ans = [[0] * w for _ in range(h)]
peace = 1
not_strawberry = []
for i in range(h):
    strawberry = 0
    for j in range(w):
        if s[i][j] == '#':
            if strawberry == 1:
                peace += 1
                strawberry = 1
            else:
                strawberry = 1
        ans[i][j] = str(peace)
    if not strawberry:
        not_strawberry.append(i)
    else:
        for j in not_strawberry:
            ans[j] = ans[i]
        not_strawberry = []
        peace += 1
if not_strawberry:
    i = min(not_strawberry) - 1
    for j in not_strawberry:
        ans[j] = ans[i]

print('\n'.join(' '.join(i) for i in ans))
c=a*b
 
if c%2==0:
  print('Even')
else:
  print('Odd')

### FIXED CODE ###

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

if a*b%2==0:
  print('Even')
else:
  print('Odd')
{1:14}

if int(A) == int(B):
  print 'Draw'

elif int(A) ＞ int(B):
  print 'Alice'

elif int(B) ＞ int(A):
  print 'Bob'

### FIXED CODE ###

# -*- coading: utf-8 -#-

A = raw_input()
B = A.split()
C, D = int(B[0]), int(B[1])

if C == 1:
  if D == 1:
    print 'Draw'
  else:
    print 'Alice'
else:
  if D == 1:
    print 'Bob'
  else:
    if C > D:
      print 'Alice'
    elif C < D:
      print 'Bob'
    else:
      print 'Draw'
s1 = input()
s2 = input()
s3 = input()
print(s1[0][0],s2[0][1],s3[0][2], sep="")

### FIXED CODE ###

s1 = input()
s2 = input()
s3 = input()
print(s1[0],s2[1],s3[2], sep="")
from functools import lru_cache

n, m = map(int, input().split())
a = []
for i in range(m):
  a.append(int(input()))
  
@lru_cache(maxsize=100000)
def comb(n):
  for i in a:
    if n == i:
      return 0
  if a.count(1) == 0 and n == 1:
    return 1
  elif a.count(1) != 0 and n == 1:
    return 0
  elif n == 0:
    return 1
  else:
    return (comb(n-1) + comb(n-2))

print(comb(n)%(10**9 + 7))

### FIXED CODE ###

n, m = list(map(int,input().split()))
a = []
for i in range(m):
  a.append(int(input()))
c = [0] * (n+2) #combination
for i in a:
  c[i] = -1
c[0] = 1

for i in range(n):
    if c[i] < 0:
      continue
    if c[i+1] >= 0:
        c[i+1] = c[i] + c[i+1]
    if c[i+2] >= 0:
        c[i+2] = c[i] + c[i+2]
    c[i] = c[i] % 10**9+7
print(c[n]%(10**9+7))
def get_divisors(n):
    if n < 1:
        return
    i = 1
    while i * i <= n:
        if n % i == 0:
            yield i
            if i * i != n:
                yield round(n / i)
        i = i + 1



n=int(input())


l=list(get_divisors(n))

l.sort()

for i,ll in enumerate(l):
  if i!=len(l)-1 and ll*l[i+1]==n:
    ans=ll+l[i+1]-2
if n==1:
  print(0)
else:
  print(ans)





### FIXED CODE ###

n=int(input())
import math
ans=10**12
i=0
while i*i<=n:
  i+=1
  if n%i!=0:
    continue
  j=n/i
  ans=min(ans, i+j-2)
if ans ==10**12:
  print(n-1)
else:
  print(int(ans))
n, l = map(int, input().split())

sn = []

for _ in range(n+1):
  sn.append(input())
  
sn = sorted(sn)
sn = ''.join(sn)

print(sn)

### FIXED CODE ###

a, b, c = map(int, input().split())
if a*b*c == 175:
  print('YES')
else:
  print('NO')
n,q = list(map(int,input().split()))
from collections import defaultdict
dd_ab = defaultdict(list)
for i in range(n-1):
    a,b = tuple(map(int,input().split()))
    dd_ab[a].append(b)

dd_px = defaultdict(int)
for i in range(q):
    p,x = tuple(map(int,input().split()))
    dd_px[p] += x

ret = [0] * (n+1)
def add_tree(node,value):
    retn = value
    if dd_px[node]:
        retn += dd_px.pop(node)
    ret[node] += retn
    if dd_ab[node]:
        for n in dd_ab.pop(node):
            add_tree(n,retn)
add_tree(1,0)
for i in ret[1::]:
    print(i)

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

def main():
    N, Q = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        edges[b-1].append(a-1)
        edges[a-1].append(b-1)

    counts = [0]*N
    for _ in range(Q):
        p, x = map(int, input().split())
        counts[p-1] += x

    parent_nodes = deque()
    parent_nodes.append(0)
    visited_nodes = set()
    while parent_nodes:
        parent = parent_nodes.popleft()
        if parent in visited_nodes:
            continue
        visited_nodes.add(parent)
        for child in edges[parent]:
            if child in visited_nodes:
                continue
            counts[child] += counts[parent]
            parent_nodes.append(child)

    print(' '.join(list(map(str, counts))))

if __name__ == "__main__":
    main()
def cal(N):
  for n in range(3,N+1):
    left = N - n
    right = n
    if left < 6:
      return 1
    else:
      return 1 + cal(left)

    if right < 6:
      return 1
    else:
      return 1 + cal(right)
    
    
S = int(input())

if S < 3:
  print(0)
  exit()
else:
  ans = cal(S)
  print((1+ans)%dekai())


### FIXED CODE ###

N = int(input())
mod = 10**9+7
ans = pow(10,N,mod) + pow(8,N,mod) - pow(9,N,mod) - pow(9,N,mod)
print(ans%mod)
N, M = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(M)]
bc.sort(key=lambda x: x[1], reverse=True)
rest = N
for b, c in bc:
  a += [c] * min(rest, b)
  rest -= min(rest, b)
a.sort(reversed=True)
print(sum(a[:N]))

### FIXED CODE ###

N, M = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(M)]
bc.sort(key=lambda x: x[1], reverse=True)
rest = N
for b, c in bc:
  a += [c] * min(rest, b)
  rest -= min(rest, b)
a.sort(reverse=True)
print(sum(a[:N]))
def mina(t, i, L):
  t -= i
  if t == 0:
    return True
  elif t < 0:
    return False
  else:
    for i in L:
      if mina(t, i, L) == True:
        return True
    return False

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

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

t = [2, 5, 5, 4, 5, 6, 3, 7, 6]

A.sort(reverse = True)
D = {}
L = []
X = []
for i in A:
  if t[i - 1] not in D:
    D[t[i - 1]] = i
    L.append(t[i - 1])
    X.append([i, t[i - 1]])

L.sort()

Lmin = N // L[0]
Lmod = N % L[0]

F = True
if Lmod != 0:
  while F:
    Lmin -= 1
    Lmod += L[0]
    t = Lmod
    for i in L[1:]:
      if mina(t, i, L[1:]) == True:
        F = False
        break
  
  X.sort(reverse = True)
  for i in X:
    if i != L[0]:
      k = t - i[1]
      if k == 0:
        List = [i[0]]
        break
      elif k > 0:
        for j in X:
          if i != L[0]:
            if k - j[1] == 0:
              List = [i[0], j[0]]
              F = True
              break
        if F:
          break

Ans = [str(D[L[0]]) for i in range(Lmin)]
if Lmod != 0:
  if len(List) == 1:
    if L[0] < List[0]:
      Ans = [str(List[0])] + Ans
    else:
      Ans = Ans + [str(List[0])]
  else:
    List.sort(reverse = True)
    if L[0] > List[0]:
      Ans += [str(List[0]), str(List[1])]
    elif L[0] < List[1]:
      Ans = [str(List[0]), str(List[1])] + Ans
    else:
      Ans = [str(List[0])] + Ans + [str(List[1])]

print("".join(Ans))

### FIXED CODE ###

import copy

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

t = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
L = {}
for i in A:
  if t[i] in L:
    if L[t[i]] < i:
      L[t[i]] = i
  else:
    L[t[i]] = i

dp = [[0 for j in range(10)] for i in range(N)]
for i in L.items():
  if i[0] - 1 < N:
    dp[i[0] - 1][i[1]] = 1
for i in range(N):
  if max(dp[i]) == 0:
    continue
  for j in L.items():
    k = i + j[0]
    if k < N:
      t = copy.deepcopy(dp[i])
      t[j[1]] += 1
      if sum(t) > sum(dp[k]):
        dp[k] = t
      else:
        for ii in range(9, 0, -1):
          if t[ii] > dp[k][ii]:
            dp[k] = t
            break
          elif t[ii] < dp[k][ii]:
            break
          
t = dp[-1]
Ans = ""
for i in range(9, 0, -1):
  for j in range(t[i]):
    Ans += str(i)
    
print(Ans)
n, m, x = [int(x) for x in input().split()]
c = []
a = []
for i in range(n):
  tmp = [int(x) for x in input().split()]
  c.append(tmp[0])
  a.append(tmp[1:])
#全探索
ans = 10**8 # as INF
for s in range(2**n):
  s = bin(s)
  cost = 0
  d = [0 for j in range(m)]
  for i in range(n):
    is_use = bin(s>>i&1) == bin(1)
    if is_use:
      cost += c[i]
      for j in range(m):
        d[j]+=a[i][j]
  ok = True
  for j in range(m):
    if d[j] < x:
      ok = False
  if ok and cost < ans:
    ans = cost
print(ans)
  	


### FIXED CODE ###

n, m, x = [int(x) for x in input().split()]
c = []
a = []
for i in range(n):
  tmp = [int(x) for x in input().split()]
  c.append(tmp[0])
  a.append(tmp[1:])
#全探索
ans = 10**8 # as INF
for s in range(2**n):
  cost = 0
  d = [0 for j in range(m)]
  for i in range(n):
    is_use = bin(s>>i&1) == bin(1)
    if is_use:
      cost += c[i]
      for j in range(m):
        d[j]+=a[i][j]
  ok = True
  for j in range(m):
    if d[j] < x:
      ok = False
  if ok and cost < ans:
    ans = cost
if ans == 10**8:
  print(-1)
else:
  print(ans)
li= list(map(int, input().split())
while True:
	li.sort()
	if [x,y]=[0,0]
		break
	print(*li)


### FIXED CODE ###

while True:
	x,y=sorted(map(int,input().split()))
	if x==0 and y==0:
		break
	print(x, y)
n,q=map(int,input().split())

s=input()
X=[0]*len(s)
for i in range(len(s)-1):
    if s[i]=='A' and s[i+1]=='C':
        X[i]+=1

A=[]

for i in range(q):
    l,r=map(int,input().split())
    ans=(X[l-1:r]).count(1)
    if s[r-1]=='A' and s[r]=='C':
        A.append(ans-1)
    else:
        A.append(ans)
        
for x in A:
    print(x)

### FIXED CODE ###

n,q=map(int,input().split())
s=input()+'Z'
A=[0]*(n+1)
cnt=0
for i in range(n):
    A[i]=cnt
    if s[i]=='A' and s[i+1]=='C':
        cnt+=1
ANS=[]
for i in range(q):
    l,r=map(int,input().split())
    ANS.append(A[r-1]-A[l-1])
for ans in ANS:
    print(ans)
n=int(input())
s = [input() for i in range(n)]
c=0
for i in range(n):
   r[i]=(((sorted([s[i][j] for j in range(10)]))))
   r[i]=''.join(r[i])
for i in range(n-1):
    for j in range(i+1,n):
        if r[i]==r[j]:
            c+=1
print(c)

### FIXED CODE ###

N = int(input())
S = [''.join(sorted(input().rstrip())) for _ in range(N)]
 
from collections import Counter
counter = Counter(S)
 
answer = sum(x*(x-1)//2 for x in counter.values())
print(answer)
N = int(intput())

sum = 0
max = 0
for _ in range(N):
  p = int(intput())
  if(p > max):
    max = p
  sum += p
val = sum - max/2
print(int(val))

### FIXED CODE ###

N = int(input())
 
sum = 0
max = 0
for _ in range(N):
  p = int(input())
  if(p > max):
    max = p
  sum += p
val = sum - max/2
print(int(val))
def main():
  n, w = [int(e) for e in input().split()]
  maxv = 10 ** 3 * n + 1
  t = [-1 for i in range(maxv)]
  t[0] = w
  cmaxv = 0
  for _ in range(n):
    nw, nv = [int(e) for e in input().split()]
    for i in range(cmaxv - 1, -1, -1):
      if t[i] == -1:
        continue
      if t[i + nv] < t[i] - nw:
        t[i + nv] = t[i] - nw
        if cmaxv < i + nv:
          cmaxv = i + nv:
  print(cmaxv)
main()

### FIXED CODE ###

def main():
  n, w = [int(e) for e in input().split()]
  maxv = 10 ** 3 * n + 1
  t = [-1 for i in range(maxv)]
  t[0] = w
  for _ in range(n):
    nw, nv = [int(e) for e in input().split()]
    for i in range(maxv - 1, -1, -1):
      if t[i] == -1:
        continue
      if t[i + nv] < t[i] - nw:
        t[i + nv] = t[i] - nw
  for i in range(maxv - 1, 0, -1):
    if t[i] == -1:
      continue
    print(i)
    break
main()
S = list(int, map(input().split()))
ans1 = 0
ans2 = 0
for i in range (len(S)-1):
  if i % 2 == 0:
    if S[i] == 0:
      ans1 += 1
  else:
    if S[i] == 1:
      ans1 += 1
for i in range(len(S)-1):
  if i % 2 == 0:
    if S[i] == 1:
      ans2 += 1
  else:
    if S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))



### FIXED CODE ###

S = list(map(int, input()))
ans1 = 0
ans2 = 0
for i in range (len(S)):
  if i % 2 == 0 and S[i] == 0:
      ans1 += 1
  elif i %2 ==1 and S[i] == 1:
      ans1 += 1
for i in range(len(S)):
  if i % 2 == 0 and S[i] == 1:
      ans2 += 1
  elif i % 2 ==1 and S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))