Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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

Flag=False
for x in range(N+1):
    for y in range(N+1):
        for z in range(N+1):
            if 10000*x+5000*y+1000*z==Y and x+y+z==N:
                print(str(x)+' '+str(y)+' '+str(z))
                Flag=True
                break
        if Flag:
            break
    if Flag:
        break

if Flag==False:
    print('-1 -1 -1')


### FIXED CODE ###

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

Flag=False
for x in range(N+1):
    for y in range(N+1):
        z=N-x-y
        if 10000*x+5000*y+1000*z==Y and z>=0:
            print(str(x)+' '+str(y)+' '+str(z))
            Flag=True
            break
    if Flag:
        break

if Flag==False:
    print('-1 -1 -1')
### BUGGY CODE ###

n,y=map(int,input().split())
for i in range(2*(10**3)+1):
  for j in range(4*(10**3)+1):
    res=y-i*10000-j*5000
    if res>=0 and res%1000==0 and res//1000+i+j==n :
      print(i,j,res//1000)
      exit()
print(-1,-1,-1)


### FIXED CODE ###

n,y=map(int,input().split())
for i in range(2*(10**3)+1):
  for j in range(4*(10**3)+1):
    res=y-i*10000-j*5000
    if res>=0 and res%1000==0 and res//1000+i+j==n :
      print(i,j,res//1000)
      exit()
print(-1,-1,-1)
### BUGGY CODE ###

s = input()
count = 0
s = s.replace('BC','X')
s = s.replace('B','Z').replace('C','Z')
s = s.split('Z')
for i in s:
    for j in range(len(i)):
        if i[j] == 'X':
            count += i[:j].count('A')
print(count)

### FIXED CODE ###

s = input()
count = 0
s = s.replace('BC','X')
s = s.replace('B','Z').replace('C','Z')
s = s.split('Z')
for i in s:
    ac = 0
    for j in range(len(i)):
        if i[j] == 'A':
            ac += 1
        if i[j] == 'X':
            count += ac
print(count)
### BUGGY CODE ###

K=int(input())
L=len(input())
m=10**9+7
from numba import*
@njit(cache=1)
def f():
    max_n=2*10**6
    fac=[1]*(max_n+1)
    inv=[1]*(max_n+1)
    ifac=[1]*(max_n+1)
    for n in range(2,max_n+1):
        fac[n]=(fac[n-1]*n)%m
        inv[n]=m-inv[m%n]*(m//n)%m
        ifac[n]=(ifac[n-1]*inv[n])%m
    return fac,inv,ifac
fac,inv,ifac=f()
def comb(n,k):
    if n<k or n<0 or k<0:
        return 0
    return (fac[n]*ifac[k]*ifac[n-k])%m
d=[1]*(K+1)
d2=[1]*(K+1)
for i in range(K):
    d[i+1]=d[i]*25%m
    d2[i+1]=d2[i]*26%m
print(sum([comb(L+i-1,i)*d[i]*d2[K-i]%m for i in range(K+1)])%m)

### FIXED CODE ###

K=int(input())
L=len(input())
from numba import*
@njit(cache=1)
def f():
    m=10**9+7
    max_n=2*10**6
    fac=[1]*(max_n+1)
    inv=[1]*(max_n+1)
    ifac=[1]*(max_n+1)
    for n in range(2,max_n+1):
        fac[n]=(fac[n-1]*n)%m
        inv[n]=m-inv[m%n]*(m//n)%m
        ifac[n]=(ifac[n-1]*inv[n])%m
    d=[1]*(K+1)
    d2=[1]*(K+1)
    for i in range(K):
        d[i+1]=d[i]*25%m
        d2[i+1]=d2[i]*26%m
    a=0
    for i in range(K+1):
        a=(a+fac[L+i-1]*ifac[i]%m*ifac[L-1]%m*d[i]%m*d2[K-i]%m)%m
    return a
print(f())
### BUGGY CODE ###

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

if a[0]==1:
    if n>=2 and a[1]==1:
        print(0)
    else:
        print(1)
else:
    ans = 0
    for num in a:
        if a.count(num) >= 2:
            continue
        else:
            cands = set([i for i in a if i!=num])
            for i in range(2, int(num**0.5)+1):
                if num % i == 0 and (i in cands or num//i in cands):
                    break
            else:
                ans+=1
            
    print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
M = max(a)
cands = [0]*M

ans = 0
for num in a:
    if cands[num-1] >= 2:
        continue
    for i in range(num, M+1, num):
        cands[i-1] += 1
        
for num in a:
    if cands[num-1]==1:
        ans+=1
print(ans)
### BUGGY CODE ###

n=int(input())
elements= input().split()
q=int(input())
actions=[]
for i in range(q):
    actions.append(input().split())

number_list=[]
count_list=[]
for e in elements:
    if int(e) in number_list:
        count_list[number_list.index(int(e))]+=1
    else:
        number_list.append(int(e))
        count_list.append(1)

for act in actions:
    if int(act[0]) in number_list:
        index0=number_list.index(int(act[0]))
        
        if int(act[1]) in number_list:
            index1=number_list.index(int(act[1]))
            count_list[index1]+=count_list[index0]
            number_list.pop(index0)
            count_list.pop(index0)
        else:
            number_list.append(int(act[1]))
            count_list.append(count_list[index0])
            number_list.pop(index0)
            count_list.pop(index0)

    sum=0
    for i in range(len(count_list)):
        sum+=number_list[i]* count_list[i]

    print(str(sum))

### FIXED CODE ###

n=int(input())
elements= input().split()
q=int(input())
actions=[]
for i in range(q):
    actions.append(input().split())
 
dict={}
for e in elements:
    count=dict.get(e,0)
    count+=1
    dict[e]=count
 
sum=0
for key in dict.keys():
    sum+=int(key)* dict[key]

for act in actions:
    count=dict.get(act[0],0)
    sum+=(int(act[1])-int(act[0]))*count
    count+=dict.get(act[1],0)
    dict[act[1]]=count
    dict[act[0]]=0
 
    print(str(sum))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
b.sort()
c.sort()
ai = []
bi = []
for i in range(n):
    ai.append(n - bisect.bisect_right(b, a[i]))
    bi.append(n - bisect.bisect_right(c, b[i]))
ans = 0
for j in ai:
    ans += sum(bi[n-j:])
print(ans)

### FIXED CODE ###

from itertools import accumulate
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
b.sort()
c.sort()
ai = []
bi = []
for i in range(n):
    ai.append(n - bisect.bisect_right(b, a[i]))
    bi.append(n - bisect.bisect_right(c, b[i]))
ans = 0
c = [0]+list(accumulate(bi[::-1]))
for j in ai:
    ans += c[j]
print(ans)
### BUGGY CODE ###

n,k,q=map(int,input().split())
x=list(int(input()) for _ in range(q))

import numpy as np

p=np.array([k]*n)

for i in range(q):
	p=p-1
	p[x[i]-1]+=1
    
for i in range(n):
	if p[i]<=0:
		print('No')
	else:
		print('Yes')

### FIXED CODE ###

n,k,q=map(int,input().split())
x=list(int(input()) for _ in range(q))

p=[0]*n

for i in range(q):
	p[x[i]-1]+=1
    
for i in range(n):
	if k-q+p[i]<=0:
		print('No')
	else:
		print('Yes')
### BUGGY CODE ###

length, questions = [int(a) for a in input().split()]

strings = str(input())
for j in range(questions):
    start, end = [int(a) for a in input().split()]
    moji = strings[start - 1: end]
    counts = 0
    for k in range(len(moji) - 1):
        if moji[k] == 'A' and moji[k + 1] == 'C':
            counts += 1
    print(counts)

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

ans = 0
ans2 = 0
s = input()
l = len(s)
t = 1
for i in range(l):
  print(f'a={t}')
  same = True
  while same:
    if s[i] != s[t]:
      i = t
      print(f'b={t}')
      same = False
    else:
      ans += 1
print(max(ans, ans2))


### FIXED CODE ###

import sys

input = sys.stdin.readline

def main():
    ans = 0
    S = input().rstrip('\n')
    w = 0
    for s in S[::-1]:
        if s == 'W':
            w += 1
        else:
            ans += w
    print(ans)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

# E - Two Currencies

import heapq

n, m, s = map(int, input().split())
adj = {u: [] for u in range(1, n+1)}
for i in range(m):
    u, v, a, b = map(int, input().split())
    adj[u].append((v, a, b)) # to, 料金, 時間
    adj[v].append((u, a, b)) # to, 料金, 時間
exch = {}
for u in range(1, n+1):
    c, d = map(int, input().split())
    exch[u] = (c, d) # レート, 時間

max_silver = 50 * m    # これだけ持ってたらどの都市へも行ける
s = min(s, max_silver) # max_silverまでで十分

# n <= 50, m <= 100, max_silver <= 5000

# (都市,所有銀貨)を頂点とする最短経路問題
# Dijkstra
dist = {(1, s): 0}  # 開始頂点のみ距離0
queue = [(0, 1, s)]

dmin = {u: float('inf') for u in range(1, n+1)} # dmin[u] = min(dist[(u, si)]
dmin[1] = 0

while len(queue) > 0:
    di, u, si = heapq.heappop(queue)
    # 無効なデータ
    if (u, si) in dist and di > dist[(u, si)]:
        continue
    dmin[u] = min(dmin[u], di)
    for v, a, b in adj[u]:
        if si < a:
            continue
        xsi = si - a
        if (v, xsi) not in dist or \
            dist[(v, xsi)] > di + b:
            dist[(v, xsi)] = di + b
            heapq.heappush(queue, (di + b, v, xsi))
    c, d = exch[u]
    xsi = min(si + c, max_silver)
    if (u, xsi) not in dist or \
        dist[(u, xsi)] > di + d:
        dist[(u, xsi)] = di + d
        heapq.heappush(queue, (di + d, u, xsi))

for u in range(2, n+1):
    print(dmin[u])


### FIXED CODE ###

# E - Two Currencies

import heapq

n, m, s = map(int, input().split())
adj = {u: [] for u in range(1, n+1)}
max_silver = 0
for i in range(m):
    u, v, a, b = map(int, input().split())
    adj[u].append((v, a, b)) # to, 料金, 時間
    adj[v].append((u, a, b)) # to, 料金, 時間
    max_silver += a # 全路線の料金の総和 (これ以上は不要)
exch = {}
for u in range(1, n+1):
    c, d = map(int, input().split())
    exch[u] = (c, d) # レート, 時間

s = min(s, max_silver) # max_silverまでで十分

# n <= 50, m <= 100, max_silver <= 5000

# (都市,所有銀貨)を頂点とする最短経路問題
# Dijkstra
dist = {(1, s): 0}  # 開始頂点のみ距離0
queue = [(0, 1, s)]
dmin = {1: 0} # dmin[u] = min(dist[(u, si)] for si)
nfin = 1      # 距離が決まった都市数

while len(queue) > 0:
    di, u, si = heapq.heappop(queue)
    # 用済みのデータ
    if (u, si) in dist and di > dist[(u, si)]:
        continue
    # 都市uの距離を保存
    if u not in dmin:
        dmin[u] = di
        nfin += 1
        if nfin >= n:  # 全都市の距離が決まった
            break
    # uから直接行ける各都市について
    for v, a, b in adj[u]:
        if si < a:  # 銀貨不足
            continue
        xsi = si - a
        if (v, xsi) not in dist or \
            dist[(v, xsi)] > di + b:
            dist[(v, xsi)] = di + b
            heapq.heappush(queue, (di + b, v, xsi))
    # 両替による遷移
    c, d = exch[u]
    xsi = min(si + c, max_silver)
    if (u, xsi) not in dist or \
        dist[(u, xsi)] > di + d:
        dist[(u, xsi)] = di + d
        heapq.heappush(queue, (di + d, u, xsi))

for u in range(2, n+1):
    print(dmin[u])
### BUGGY CODE ###

import numpy as np
N = int(input())
X = [int(i) for i in input().split()]
for i in range(N):
    t = X.pop(i)
    print(int(np.median(X)))
    X.insert(i, t)

### FIXED CODE ###

N = int(input())
X = [int(i) for i in input().split()]
Y = X[:]
Y.sort()

for i in range(N):
    print(Y[int(N/2)] if Y[int(N/2)] > X[i] else Y[int(N/2)-1])
### BUGGY CODE ###

#

import sys
input=sys.stdin.readline

MOD=10**9+7
            
def main():
    N=int(input())
    A=list(map(int,input().split()))
    if N==1:
        print(1)
        exit()
    kl=set()
    p=[{} for i in range(N)]
    for j in range(N):
        n=A[j]
        ret={}
        for i in range(2,int((n)**0.5)+1):
            if n%i==0:
                cnt=0
                while(n%i==0):
                    n/=i
                    cnt+=1
                ret[i]=cnt
                kl.add(i)
        if n!=1:
            ret[int(n)]=1
            kl.add(int(n))
        p[j]=ret
    lcm=1
    for i in kl:
        maxipow=0
        for j in range(N):
            if maxipow < p[j].get(i,0):
                maxipow=p[j].get(i,0)
        lcm*=i**maxipow
        lcm%=MOD

    lcm%=MOD
    ans=0
    for i in range(N):
        ans+=lcm*pow(A[i],MOD-2,MOD)
        ans%=MOD
    print(ans)
    
    
    
if __name__=="__main__":
    main()


### FIXED CODE ###

#

import sys
from fractions import gcd
input=sys.stdin.readline

def main():
    MOD=10**9+7
    N=int(input())
    A=list(map(int,input().split()))
    if N==1:
        print(1)
        exit()
    l=(A[0]*A[1])//gcd(A[0],A[1])
    for i in range(2,N):
        l=(l*A[i])//gcd(A[i],l-A[i])
    l%=MOD
    ans=0
    for i in range(N):
        ans+=l*pow(A[i],MOD-2,MOD)
        ans%=MOD
    print(ans)
    
    
    
if __name__=="__main__":
    main()
### BUGGY CODE ###

from collections import Counter

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

if len(set(V)) == 1:
    print(len(V)//2)
    exit()

V_odd = [i for i in V[::2]]
V_even = [i for i in V[1::2]]
V_odd_counter = Counter(V_odd)
V_even_counter = Counter(V_even)

while True:
    if V_odd_counter.most_common()[0][0] != V_even_counter.most_common()[0][0]:
        print(len(V) - V_odd_counter.most_common()[0][1] - V_even_counter.most_common()[0][1])
        exit()
    else:
        print(min(len(V) - V_odd_counter.most_common()[1][1] - V_even_counter.most_common()[0][1],
                    len(V) - V_odd_counter.most_common()[0][1] - V_even_counter.most_common()[1][1]))

### FIXED CODE ###

from collections import Counter

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

if len(set(V)) == 1:
    print(len(V)//2)
    exit()

V_odd = [i for i in V[::2]]
V_even = [i for i in V[1::2]]
V_odd_counter = Counter(V_odd)
V_even_counter = Counter(V_even)

vodd = V_odd_counter.most_common()
veven = V_even_counter.most_common()
vlen = len(V)
while True:
    if vodd[0][0] != veven[0][0]:
        print(vlen - vodd[0][1] - veven[0][1])
        exit()
    else:
        print(min(vlen - vodd[1][1] - veven[0][1],
                    vlen - vodd[0][1] - veven[1][1]))
        exit()
### BUGGY CODE ###

N = int(input())
T = [0] * N
A = [0] * N
for i in range(N):
    T[i], A[i] = map(int, input().split())

x = 1
y = 1
for i in range(N):
    n = 1
    while not (x <= n * T[i] and y <= n * A[i]):
        n += 1
    else:
        x = n * T[i]
        y = n * A[i]
else:
    print(x + y)

### FIXED CODE ###

N = int(input())
T = [0] * N
A = [0] * N
for i in range(N):
    T[i], A[i] = map(int, input().split())

x = 1
y = 1
for i in range(N):
    k = max(-(-x // T[i]), -(-y // A[i]))
    x = k * T[i]
    y = k * A[i]
else:
    print(x + y)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M, L = map(int, input().split())
roads = [[float('inf')]*N for _ in [0]*N]
kyuyu = [[float('inf')]*N for _ in [0]*N]
for _ in range(M):
    a, b, c = map(int, input().split())
    if c <= L:  # 移動出来ない経路は消す
        roads[a-1][b-1] = c
        roads[b-1][a-1] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            roads[i][j] = min(roads[i][j], roads[i][k]+roads[k][j])

for i in range(N):
    for j in range(i+1, N):
        if roads[i][j] <= L:
            kyuyu[i][j] = 1
            kyuyu[j][i] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            kyuyu[i][j] = min(kyuyu[i][j], kyuyu[i][k]+kyuyu[k][j])

Q = int(input())
for _ in range(Q):
    s, t = map(lambda x: int(x)-1, input().split())
    dist = kyuyu[s][t]
    if dist == float('inf'):
        print(-1)
    else:
        print(dist-1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def WF(mat, N):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                mat[i][j] = min(mat[i][j], mat[i][k]+mat[k][j])
    return mat


N, M, L = map(int, input().split())
roads = [[float('inf')]*N for _ in [0]*N]
kyuyu = [[float('inf')]*N for _ in [0]*N]
for _ in range(M):
    a, b, c = map(int, input().split())
    roads[a-1][b-1] = c
    roads[b-1][a-1] = c

roads = WF(roads, N)
for i in range(N):
    for j in range(i+1, N):
        if roads[i][j] <= L:
            kyuyu[i][j] = 1
            kyuyu[j][i] = 1
kyuyu = WF(kyuyu, N)
Q = int(input())
for _ in range(Q):
    s, t = map(lambda x: int(x)-1, input().split())
    dist = kyuyu[s][t]
    if dist == float('inf'):
        print(-1)
    else:
        print(dist-1)
### BUGGY CODE ###

n=int(input())
L=list(map(int, input().split()))
count = 0
for a in range(n):
  for b in range(a+1,n):
    for c in range(b+1,n):
      if L[a] < L[b] + L[c]:
        if L[b] < L[a] + L[c]:
          if L[c] < L[a] + L[b]:
            count += 1
print(count)

### FIXED CODE ###

n=int(input())
L=list(map(int, input().split()))
L.sort()
count = 0
for a in range(n-2):
  for b in range(a+1,n-1):
    if L[a] + L[b] > L[n-1]:
      count += n - b - 1
      continue
    left = b + 1
    right = n - 1
    while right - left > 0:
      c = (left+right) // 2
      if L[c] < L[a] + L[b]:
        left = c + 1
      else:
        right = c
    count += left - b - 1
print(count)
### BUGGY CODE ###

max_number = int(input())
list_numbers = [i+1 for i in range(max_number)]
count = 0
for i in list_numbers:
  count = 0
  for x in range(1,100):
    for y in range(1,100):
      for z in range(1,100):
        tot = x**2 + y**2 + z**2 + x * y + y * z + z * x
        if (tot == i):
          count += 1
  print(count)

### FIXED CODE ###

N=int(input())
a=[0]*10**4
for j in range(1,101):
    for k in range(1,101):
        for h in range(1,101):
            tmp=h**2+j**2+k**2+h*j+j*k+k*h
            if tmp<=10000:
                a[tmp-1]+=1
for i in range(N):
    print(a[i])
### BUGGY CODE ###

h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c = [[[-1]*2 for i in range(w)] for i in range(h)]

def count(x,y):

    if c[x][y][0] == -1:
        n = 0
        while x+n < h and l[x+n][y] == ".":
            n += 1
        for i in range(n):
            c[x+i][y][0] = n
        
    if c[x][y][1] == -1:
        n = 0
        while y+n < w and l[x][y+n] == ".":
            n += 1
        for i in range(n):
            c[x][y+i][1] = n

    return c[x][y][0]+c[x][y][1]
ans = 0
for i in range(h):
    for j in range(w):
        if l[i][j] == ".":
            ans = max(ans,count(i,j))
print(ans-1)


### FIXED CODE ###


h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c1 = [[-1 for i in range(w)] for i in range(h)]
c2 = [[-1 for i in range(w)] for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if c1[i][j] == -1:
            n = 0
            while i+n < h:
                if l[i+n][j] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c1[i+k][j] = n
            
        if c2[i][j] == -1:
            n = 0
            while j+n < w:
                if l[i][j+n] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c2[i][j+k] = n


        ans = max(ans,c1[i][j]+c2[i][j])
print(ans-1)
### BUGGY CODE ###

from sys import stdin
import fractions
 
N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) // 2 for x in stdin.readline().rstrip().split()]
ans = 0
g = 1
 
for i in range(len(A)):
    g = g * A[i] // fractions.gcd(g, A[i])
 
for i in range(len(A)):
    if (g // A[i]) % 2 == 0:
        print(0)
        exit()
 
ans = M // g
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + 1) // 2)

### FIXED CODE ###

from sys import stdin
import fractions

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) // 2 for x in stdin.readline().rstrip().split()]
ans = 0
g = 1

for i in range(len(A)):
    g = g * A[i] // fractions.gcd(g % A[i], A[i])
    if g > M:
        print(0)
        exit()

for i in range(len(A)):
    if (g // A[i]) % 2 == 0:
        print(0)
        exit()

ans = M // g
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + 1) // 2)
### BUGGY CODE ###

#C-Poll
import collections
n=int(input())
words = [input() for _ in range(n)]
count = collections.Counter(words)
leng = len(count)
ansallay = []
#抽出用に何回出てればansに出すかを変数に突っ込む
record = count.most_common()[0][1]
for num in range(leng):
    if(count.most_common()[num][1] == record):
        ansallay.append(count.most_common()[num][0])
ansallay.sort()
for word in ansallay:
    print(word)

### FIXED CODE ###

#C-Poll
import collections
n=int(input())
words = [input() for _ in range(n)]
count = collections.Counter(words)
leng = len(count)
ansallay = []
#抽出用に何回出てればansに出すかを変数に突っ込む
record = count.most_common()[0][1]
ms=count.most_common()
for num in range(leng):
    if(ms[num][1] == record):
        ansallay.append(ms[num][0])
    else:
        break
ansallay.sort()
for word in ansallay:
    print(word)
### BUGGY CODE ###

from fractions import gcd
def main():
    N=int(input())
    A=list(map(int,input().split()))
    mod=10**9+7
    b=0
    c=1
    for a in A:
        c=c*a//gcd(c,a)
    for a in A:
        b+=(c//a)
        b%=mod
    print(b)
if __name__=="__main__":
    main()

### FIXED CODE ###

from fractions import gcd
def main():
    N=int(input())
    A=list(map(int,input().split()))
    mod=10**9+7
    b=0
    c=1
    for a in A:
        c=c*a//gcd(c,a)
    c%=mod
    for a in A:
        b+=c*pow(a,mod-2,mod)
    print(b%mod)
if __name__=="__main__":
    main()
### BUGGY CODE ###

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

INF = 10**9
dp = [[INF]*(1<<N) for _ in range(M+1)]
dp[0][0] = 0

for i in range(M):
  a, b = map(int, input().split())
  c = sum(map(lambda x: 1 << (int(x)-1), input().split()))
  for j in range(1<<N):
    dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    dp[i+1][j|c] = min(dp[i+1][j|c], dp[i][j|c], dp[i][j] + a)

ans = dp[-1][-1]

if ans == INF:
  print(-1)
else:
  print(ans)


### FIXED CODE ###

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

INF = 10**9
dp = [[INF]*(1<<N) for _ in range(M+1)]
dp[0][0] = 0

for i in range(M):
  a, b = map(int, input().split())
  c = sum(map(lambda x: 1 << (int(x)-1), input().split()))
  for j in range(1<<N):
    k = j|c
    dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    dp[i+1][k] = min(dp[i+1][k], dp[i][k], dp[i][j] + a)

ans = dp[-1][-1]

if ans == INF:
  print(-1)
else:
  print(ans)
### BUGGY CODE ###

K, S = list(map(int, input().split()))

res = 0

for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x + y + z == S:
        res += 1

print(res)

### FIXED CODE ###

K, S = list(map(int, input().split()))

res = 0

for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if z >= 0 and z <= K:
      res += 1

print(res)
### BUGGY CODE ###

MOD=10**9+7
import fractions
N=int(input())
if N==1:
  A=int(input())
  print(1)
  exit()
  
A=list(map(int, input().split()))

def f(a, b):
  return a*b//fractions.gcd(a, b)

tmp=f(A[0], A[1])
for i in range(2, N):
  tmp=f(tmp, A[i])
  
out=0
print(sum([(tmp//A[i])%MOD for i in range(N)])%MOD)


### FIXED CODE ###

MOD=10**9+7
import fractions
N=int(input())
if N==1:
  A=int(input())
  print(1)
  exit()

A=list(map(int, input().split()))
 
def f(a, b):
  return a*b//fractions.gcd(a, b)
 
if N>10:
  A1=A[:N//2]
  A2=A[N//2:]
  
  tmp1=f(A1[0], A1[1])
  n1=len(A1)
  for i in range(2, n1):
    tmp1=f(tmp1, A1[i])
    
  tmp2=f(A2[0], A2[1])
  n2=len(A2)
  for i in range(2, n2):
    tmp2=f(tmp2, A2[i])
    
  tmp=f(tmp1, tmp2)
  
  out1=sum([(tmp1//A1[i]) for i in range(n1)])
  out2=sum([(tmp2//A2[i]) for i in range(n2)])
  out1*=(tmp//tmp1)
  out2*=(tmp//tmp2)
  print((out1+out2)%MOD)
  exit()
  
tmp=f(A[0], A[1])
for i in range(2, N):
  tmp=f(tmp, A[i])
out=0
print(sum([(tmp//A[i])%MOD for i in range(N)])%MOD)
### BUGGY CODE ###

N = int(input())
S = input()
count = 0

while len(S) > 0:
    i = 0
    si = S[i]
    j = i + 1
    while j < len(S) and si == S[j]:
        j += 1
    S = S[j:]
    count += 1

print(count)

### FIXED CODE ###

N = int(input())
S = input()
count = 0

S += "#"
for i in range(N):
    if S[i] != S[i + 1]:
        count += 1
print(count)