Harryxun/stf_run huggingface dataset:
n, k = map(int, input().split())
d = []
a = []
for i in range(k):
    d.append(int(input))
    a.append(list(map(int, input().split())))

aa = [0]*n

for j in a:
    for t in j:
        aa[t - 1] += 1

ans = 0

for z in aa:
    if z == 0:
        ans += 1
    else:
        ans += 0

print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))

aa = [0]*n

for j in a:
    for t in j:
        aa[t - 1] += 1

ans = 0

for z in aa:
    if z == 0:
        ans += 1
    else:
        ans += 0

print(ans)
n,k,x,y=int(input()) for i in range(4)
if n - k > 0:
  ans = k * x + (n - k) * y
else:
  ans = n * x
print(ans)


### FIXED CODE ###

n,k,x,y=(int(input()) for i in range(4))
if n - k > 0:
  ans = k * x + (n - k) * y
else:
  ans = n * x
print(ans)
coding: utf-8

N, M = list(map(int, input().split()))
begin = 0 if N == 1 else 10**(N-1)

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

for i in range(begin, 10**N):
    flag = True
    for j in range(M):
        if str(i)[sc[j][0]-1] != str(sc[j][1]):
            flag = False
            break

    if flag == True:
        print(i)
        break

if flag == False: print(-1)

### FIXED CODE ###

# coding: utf-8

N, M = list(map(int, input().split()))
begin = 0 if N == 1 else 10**(N-1)

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

for i in range(begin, 10**N):
    flag = True
    for j in range(M):
        if str(i)[sc[j][0]-1] != str(sc[j][1]):
            flag = False
            break

    if flag == True:
        print(i)
        break

if flag == False: print(-1)
N, P = map(int, input().split())
ans = 0
if N == 1:
    print(P)
else:
    for i in range(1, int(P**(1/N)+5)):
        if P % i**N == 0:
            ans = i
    print(ans)


### FIXED CODE ###

N, P = map(int, input().split())
ans = 0
if N == 1:
    print(P)
elif N >= P or N > 50:
    print(1)

else:
    for i in range(1, int(P**(1/N)+2)):
        if P % i**N == 0:
            ans = i
    print(ans)
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -float('inf')
for i in range(N):
    cnt = 0
    k = 0
    done = set()
    S = []
    while i not in done:
        done.add(i)
        ni = P[i] - 1
        if len(S):
            S.append(S[-1] + C[ni])
        else:
            S.append(C[ni])
        i = ni
    if K <= len(S):
        score = max(S[:K])
    elif S[-1] <= 0:
        score = max(S)
    else:
        score = S[-1] * (K // len(S))
        r = K % len(S)
        score += max(0, max(S[:r]))
    ans = max(ans, score)
print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -float('inf')
for i in range(N):
    cnt = 0
    k = 0
    done = set()
    S = []
    while i not in done:
        done.add(i)
        ni = P[i] - 1
        if len(S):
            S.append(S[-1] + C[ni])
        else:
            S.append(C[ni])
        i = ni
    if K <= len(S):
        score = max(S[:K])
    elif S[-1] <= 0:
        score = max(S)
    else:
        score1 = S[-1] * ((K // len(S)) - 1)
        score1 += max(S)
        score2 = S[-1] * (K // len(S))
        r = K % len(S)
        if r != 0:
            score2 += max(0, max(S[:r]))
        score = max(score1, score2)
    ans = max(ans, score)
print(ans)
n = int(input())

for i in range(1,10):
	a = n % i
    if !isinstance(a, int):
		print('No')
print('Yes')

### FIXED CODE ###

n = int(input())

for i in range(1,10):
	a = n / i
	if a - int(a) == 0 and a < 10:
		print('Yes')
		exit()
print('No')
ans=""
for i in input():
  if x=="B":
    if len(t)==0:
      t=t[a:-1]
  else:t+=i
print(ans)

### FIXED CODE ###

t=""
for i in input():
  if i=="B":
    if len(t)!=0:
      t=t[:-1]
  else:t+=i
print(t)
x = input()
y = input()

x = int(x)
y = int(y)

if x + y >= 10 :
  print("error")
else:
  print(x+y)

### FIXED CODE ###

x, y = input().split()

x = int(x)
y = int(y)

if x + y >= 10 :
  print("error")
else:
  print(x+y)
import sys
n=1

ff=map(input().split())
for i in ff:
	if i==0:
		break
	print("Case {0}: {1},".format(n,i))
	n=n+1

### FIXED CODE ###

import sys
#a = open("test.txt", "r")
a = sys.stdin
 
count = 1
for line in a:
    if int(line) == 0:
    	break
    print("Case {0}: {1}".format(count, line), end="")
    count = count + 1
import os
import sys

weather_list = ['Sunny', 'Cloudy', 'Rainy']

today_weather = sys.argv[1]

weather_index = weather_list.index(today_weather)

weather_index = weather_index+1 if len(weather_list)-1!=weather_index else 0

print(weather_list[weather_index])

### FIXED CODE ###

import os
import sys

weather_list = ['Sunny', 'Cloudy', 'Rainy']

#today_weather = sys.argv[1]
today_weather = input()

weather_index = weather_list.index(today_weather)

weather_index = weather_index+1 if len(weather_list)-1!=weather_index else 0

print(weather_list[weather_index])
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - SP[n][1]).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[0]+SP[1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
[print(i) for i in ans]

### FIXED CODE ###

N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - int(SP[n][1])).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[n][0]+SP[n][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)
D = int(input())
c = list(map(int,input().rstrip().split(" ")))
s = []
for i in range(D):
    a.append(list(map(int,input().rstrip().split(" "))))

p = 0
t = 0
for i in range(D):
    for i2 in range(26):
        if p < S[i][i2]:
            p = s[i][i2]
            t = i2
    print(t)

### FIXED CODE ###

D = int(input())
c = list(map(int,input().rstrip().split(" ")))
s = []
kankaku = [0 for i in range(27)]
for i in range(D):
    s.append(list(map(int,input().rstrip().split(" "))))

for i in range(D):
    p = 0
    t = 0
    for i2 in range(26):
        if p < s[i][i2] + c[i2] * kankaku[i2] * (kankaku[i2] * 2) // 2:
            p = s[i][i2] + c[i2] * kankaku[i2] * (kankaku[i2] * 2) // 2
            t = i2 + 1
    kankaku[t - 1] = -1
    print(t)
    for i in range(26):
        kankaku[i] += 1
from collections import deque
n = int(input())
v = list(map(int,input().split()))

e = Counter(v[::2])
o = Counter(v[1::2])

e = sorted([(k,v) for k, v in e.items()],key = lambda z:z[1],reverse = True) + [(0,0)]
o = sorted([(k,v) for k, v in o.items()],key = lambda z:z[1],reverse = True) + [(0,0)]

if e[0][0] != o[0][0]:
    print(n - e[0][1] - o[0][1])
else:
    print(n - max(e[0][1] + o[1][1], e[1][1] + o[0][1]))

### FIXED CODE ###

from collections import Counter
n = int(input())
v = list(map(int,input().split()))

e = Counter(v[::2])
o = Counter(v[1::2])

ev = sorted([(k,i) for k, i in e.items()],key = lambda z:z[1],reverse = True) + [(0,0)]
od = sorted([(k,i) for k, i in o.items()],key = lambda z:z[1],reverse = True) + [(0,0)]

if ev[0][0] != od[0][0]:
    print(n - ev[0][1] - od[0][1])
else:
    print(n - max(ev[0][1] + od[1][1], ev[1][1] + od[0][1]))
n=input()
l=[int(input()) for i in range(n)]
s=set(l)
print(len(s))


### FIXED CODE ###

s=input()
print(s[:3]+"8"+s[4:])
3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5

### FIXED CODE ###

n,m=[int(_)for _ in input().split()]

ab=[[int(_) for _ in input().split()]for i in range(n)]
cd=[[int(_) for _ in input().split()]for i in range(m)]


def dist(p1,p2):
  return abs(p1[0]-p2[0])+abs(p1[1]-p2[1])

for i in range(n):
  d=1000000000
  ans=0
  for j in range(m):
    if d>dist(ab[i],cd[j]):
      ans=j+1
      d=dist(ab[i],cd[j])
  print(ans)
n, m = map(int, input().split())
num = ['x'] * n
flag = 0

if n == 1:
    for i in range(m):
        s, c = map(int, input().split())
        if num[s-1] == 'x':
            num[s-1] = c
        else:
            if num[s-1] != c:
                print(-1)
                flag = 1
                break
    if flag == 0:
        print(num[s-1])

else:
    for i in range(m):
        s, c = map(int, input().split())
        if num[s-1] == 'x':
            num[s-1] = c
            if s == 1 and c == 0:
                print(-1)
                flag = 1
                break
        else:
            if num[s-1] != c:
                print(-1)
                flag = 1
                break
    if flag == 0:
        if num[0] == 'x':
            num[0] = 1
        for j in range(1, n):
            if num[j] == 'x':
                num[j] = 0
        str_num = map(str, num)
        print(''.join(str_num))

### FIXED CODE ###

n, m = map(int, input().split())
num = ['x'] * n
flag = 0

if n == 1:
    if m == 0:
        print(0)
    else:
        for i in range(m):
            s, c = map(int, input().split())
            if num[s-1] == 'x':
                num[s-1] = c
            else:
                if num[s-1] != c:
                    print(-1)
                    flag = 1
                    break
        if flag == 0:
            print(num[s-1])

else:
    for i in range(m):
        s, c = map(int, input().split())
        if num[s-1] == 'x':
            num[s-1] = c
            if s == 1 and c == 0:
                print(-1)
                flag = 1
                break
                
        else:
            if num[s-1] != c:
                print(-1)
                flag = 1
                break
    if flag == 0:
        if num[0] == 'x':
            num[0] = 1
        for j in range(1, n):
            if num[j] == 'x':
                num[j] = 0 
        str_num = map(str, num)
        print(''.join(str_num))
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
N=input()
M=list(map(int,input().split()))
print(gcd(*M))

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
def u(x,y):
    if x%y==0:
        return y
    else:
        return u(y,x%y)
b=list(range(N))
b[0]=a[0]
for i in range(1,N):
    b[i]=u(b[i-1],a[i])
print(int(b[N-1]))
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
manzoku = sum(B)
i = 0
while N>i:
    if A[i+1]-A[i] == 1:
        manzoku += C[i]
    i += 1
print(manzoku)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
i = 1
manzoku = sum(B)
while N>i:
    if A[i]-A[i-1] == 1:
      j = A[i-1]
      manzoku += C[j-1]
    i += 1
print(manzoku)
N=int(input())
A=list(map(int,input().split()))
I=2*N
D=[[-I]*(N+1)for _ in range(N+1)]
M=0
r=[-I]*(N+1)
def c(i,j,k):
    DP[i][j]=max(k,D[i][j])
    DP[j][i]=max(k,D[j][i])
    r[i]=max(r[i],D[i][j])
    r[j]=max(r[j],D[i][j])
    global M
    M=max(M,k)
a=0
D[A[0]][A[1]]=0
D[A[1]][A[0]]=0
r[A[0]]=0
r[A[1]]=0
for i in range(N-1):
    n=A[3*i+2:3*i+5]
    C=[]
    if len(set(n))==1:
        a+=1
        continue
    if len(set(n))==2:
        for j in range(3):
            if n.count(n[j])==2:
                X=n[j]
            else:
                Y=n[j]
        for j in range(1,N+1):
            C.append((j,Y,D[X][j]+1))
    X,Y,Z =n
    C.append((X,Y,D[Z][Z]+1))
    C.append((Y,Z,D[X][X]+1))
    C.append((X,Z,D[Y][Y]+1))
    C.append((X,Y,M))
    C.append((X,Z,M))
    C.append((Y,Z,M))
    for j in range(1,N+1):
        for k in range(3):
            C.append((j,n[k],r[j]))
    for j,k,l in C:
        c(j,k,l)
M=max(M,D[A[-1]][A[-1]]+1)
print(a+M)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
INF = 2*N
DP = [[-INF]*(N+1) for _ in range(N+1)]
M = 0
rowM = [-INF]*(N+1)

def chmax(i,j,k):
    DP[i][j] = max(k,DP[i][j])
    DP[j][i] = max(k,DP[j][i])
    rowM[i] = max(rowM[i],DP[i][j])
    rowM[j] = max(rowM[j],DP[i][j])
    global M
    M = max(M,k)

ans = 0
DP[A[0]][A[1]] = 0
DP[A[1]][A[0]] = 0
rowM[A[0]] = 0
rowM[A[1]] = 0
for i in range(N-1):
    new = A[3*i+2:3*i+5]
    change = []
    if len(set(new)) == 1:
        ans += 1
        continue
    if len(set(new)) == 2:
        for j in range(3):
            if new.count(new[j]) == 2:
                X = new[j]
            else:
                Y = new[j]
        for j in range(1,N+1):
            change.append((j,Y,DP[X][j]+1))
    X,Y,Z = new
    change.append((X,Y,DP[Z][Z]+1))
    change.append((Y,Z,DP[X][X]+1))
    change.append((X,Z,DP[Y][Y]+1))
    change.append((X,Y,M))
    change.append((X,Z,M))
    change.append((Y,Z,M))
    for j in range(1,N+1):
        for k in range(3):
            change.append((j,new[k],rowM[j]))
    for j,k,l in change:
        chmax(j,k,l)
M = max(M,DP[A[-1]][A[-1]]+1)
print(ans+M)
N, M = map(int, input().split())
adjL = [set() for v in range(N)]
indegs = [0] * N
for _ in range(N+M-1):
    u, v = map(int, input().split())
    adjL[u-1].add(v-1)
    indegs[v-1] += 1

parents = [-1] * N
v0s = [set() for v in range(N)] # 前回まで
vRoot = [v for v in range(N) if indegs[v] == 0][0]

vNows = set([vRoot])
while vNows:
    vNexts = set()
    v0News = [set() for v in range(N)] # 今回新しく
    for vNow in vNows:
        for v2 in adjL[vNow]:
            parents[v2] = vNow
            vNexts.add(v2)
            v0News[v2].add(vNow)
    vNows = vNexts

    for v in range(N):
        if not v0News[v]: continue
        for v0 in v0s[v]:
            adjL[v0].remove(v)
    for v in range(N):
        v0s[v] = v0News[v]

for v in range(N):
    print(parents[v] + 1)


### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())
adjL = [[] for v in range(N)]
indegs = [0] * N
for _ in range(N+M-1):
    u, v = map(int, input().split())
    adjL[u-1].append(v-1)
    indegs[v-1] += 1

parents = [-1] * N
Q = deque([v for v in range(N) if indegs[v] == 0])
while Q:
    vNow = Q.popleft()
    for v2 in adjL[vNow]:
        parents[v2] = vNow
        indegs[v2] -= 1
        if indegs[v2] == 0:
            Q.append(v2)

for v in range(N):
    print(parents[v] + 1)
N=int(input())
A=[int(x)for x in input().split()]
B=[]
if N%2==0:
    for i in range((N//2)):
        B.append(2*i+1)
        B.append(2*i+1)
    if sorted(A)==B:
        ans0=pow(2,(N/2))
        
        ans=ans0%(10**9+7)
    else:
        ans=0
else:
    B.append(0)
    for i in range(1,((N-1)//2)+1):
        B.append(2*i)
        B.append(2*i)
    if sorted(A)==B:
        ans0=pow(2,(N-1)/2)
        ans=ans0%(10**9+7)
    else:
        ans=0
print(int(ans))
 

### FIXED CODE ###

mod = 10**9 + 7
n = int(input())
a = sorted(list(map(int,input().split())))
 
if n % 2 == 0:
  for i in range(n//2):
    if not a[2*i] == a[2*i+1] == 2*i+1:
      print(0)
      exit()
else:
  if a[0] != 0:
    print(0)
    exit()
  for i in range(n//2):
    if not a[2*i+1] == a[2*i+2] == 2*i+2:
      print(0)
      exit()
print(pow(2, n//2) % mod)
s = input()
n = len(s)
cr, cl = 1, 0
ans = [0]*n
isRL = False
bp = 0

for i in range(1, n):
    cr += 1 if s[i] == "R" else 0
    cl += 1 if s[i] == "L" else 0
    if  isRL:
        if s[i] == "R" or i == n-1:
            cr -= 1 if i != n-1 else 0
            ans[bp-1] = math.ceil(cr/2) + int(cl/2)
            ans[bp] = int(cr/2) + math.ceil(cl/2)
            cr, cl, isRL = 1, 0, False
    else:
        if s[i-1] == "R" and s[i] == "L":
            bp = i
            isRL = True
            if i == n-1:
                ans[bp-1] = math.ceil(cr/2) + int(cl/2)
                ans[bp] = int(cr/2) + math.ceil(cl/2)
            
for a in ans:
    print(a, end=" ")


### FIXED CODE ###

import math
s = input()
n = len(s)
cr, cl = 1, 0
ans = [0]*n
isRL = False
bp = 0

for i in range(1, n):
    cr += 1 if s[i] == "R" else 0
    cl += 1 if s[i] == "L" else 0
    if  isRL:
        if s[i] == "R" or i == n-1:
            cr -= 1 if i != n-1 else 0
            ans[bp-1] = math.ceil(cr/2) + int(cl/2)
            ans[bp] = int(cr/2) + math.ceil(cl/2)
            cr, cl, isRL = 1, 0, False
    else:
        if s[i-1] == "R" and s[i] == "L":
            bp = i
            isRL = True
            if i == n-1:
                ans[bp-1] = math.ceil(cr/2) + int(cl/2)
                ans[bp] = int(cr/2) + math.ceil(cl/2)
            
for a in ans:
    print(a, end=" ")
n=int(input())
h=list(map(int,input().split()))
l=[]
for i in range(n-1):
    if h[i+1]-h[i]<=0:
        l.append(1)
    else:
        l.append(0)
ans=0
mn=[]
for j in range(len(l)):
    if l[j]==0:
        mn.append(ans)
        ans=0
    else:
        ans+=1
        mn.append(ans)
print(max(mn))

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
ans = 0
cnt = 0
for i in range(n-1):
    if h[i+1]<=h[i]:
        cnt+=1
    else:
        ans = max(ans, cnt)
        cnt = 0
print(max(ans, cnt))
A,B,C,D,E,F=map(int,input().split())
E=(100*E)/(100+E)
M=[]
S=[]
for i in range(F//100*A+1):
    for j in range(F//100*B+1):
        t=i*100*A+j*100*B
        if t<=F and t!=0:
            M.append(t)
for i in range(F//C+1):
    for j in range(F//D+1):
        ta=i*C+j*D
        if ta<=F:
            S.append(ta)
tmp=0
for x in M:
    for y in S:
        f=x+y
        e=(100*y)/f
        if f<=F and e<=E:
            if e>tmp:
                tmp=e
                ans1,ans2=f,y
print(ans1,ans2)

### FIXED CODE ###

a,b,c,d,e,f=map(int,input().split())
a=100*a
b=100*b
dp1=[0]*(f+1)
dp2=[0]*(f+1)
for i in range(f+1):
    if i%a==0:
        if i+a<=f:
            dp1[i+a]=1
for i in range(f+1):
    if i==0 or dp1[i]==1:
        if i+b<=f:
            dp1[i+b]=1
for i in range(f+1):
    if i%c==0:
        if i+c<=f:
            dp2[i+c]=1
for i in range(f+1):
    if i==0 or dp2[i]==1:
        if i+d<=f:
            dp2[i+d]=1

ans=[-1,-1,-1]
for i in range(f+1):
    if dp1[i]==1:
        x=min(f-i,(i//100)*e)
        k=-1
        for j in range(x,-1,-1):
            if dp2[j]==1 or j==0:
                k=j
                if ans[0]<100*k/(i+k):
                    ans=[100*k/(i+k),i+k,k]
                break
print(str(ans[1])+" "+str(ans[2]))
a = int(input())
b = int(input())
c = int(input())
d = int(input())
if abs(a -c) <= d :
    print('Yes')
elif abs(a - b) <= d and abs(b -c) <= d:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

a,b,c,d = map(int , input().split())
if abs(c -a) <= d :
    print('Yes')
elif abs(b -a) <= d and abs(c -b) <= d:
    print('Yes')
else:
    print('No')
N=int(input())
A=list(map(int,input().split()))

for j in range(1,N+1):
    totalj=0
    for i in range(N-1):
        if A[i]==j:
            totalj=totalj+1
    print(totalj)

### FIXED CODE ###

R=input()
import math
print(2*math.pi*int(R))
data = input().split

a = int(data[0])
b = int(data[1])

pricea = a // 0.08
priceb = b // 0.1

if a == b:
  ans = a
elif a + 1 == b:
  ans = b
elif a == b + 1:
  ans = a
else:
  ans = -1
  
print(ans)


### FIXED CODE ###

data = input().split()

a = int(data[0])
b = int(data[1])

n = min(int(a / 0.08), int(b / 0.1))

def lookup():    
    for i in range(n, 10000):
        tax_a = int(i * 0.08)
        tax_b = int(i * 0.1)
        if tax_a == a and tax_b == b:
            print(i)
            return
    print(-1)

lookup()
import itertools


def checkArrays(arr1, arr2):
    if len(arr1) != len(arr2):
        return False

    for i in range(len(arr1)):
        if arr1[i] != arr2[i]:
            return False

    return True


n = int(input())

arrays = list(itertools.permutations([i for i in range(1, n + 1)]))

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

a = b = 1
for i in range(len(arrays)):
    ar = list(arrays[i])
    if checkArrays(ar, p):
        a = i + 1
    if checkArrays(ar, q):
        b = i + 1

print(abs(a, b))



### FIXED CODE ###

import itertools


def checkArrays(arr1, arr2):
    if len(arr1) != len(arr2):
        return False

    for i in range(len(arr1)):
        if arr1[i] != arr2[i]:
            return False

    return True


n = int(input())

arrays = list(itertools.permutations([i for i in range(1, n + 1)]))

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

a = b = 1
for i in range(len(arrays)):
    ar = list(arrays[i])
    if checkArrays(ar, p):
        a = i + 1
    if checkArrays(ar, q):
        b = i + 1

print(abs(a - b))
A, B = map(int, input().split())
_MAX_PRICE = 1001
for n in range(1, _MAX_PRICE):
  if int(n * 0.08) == A and int(n * 0.1) == B:
    print(n)
    exit()
print(-1)c

### FIXED CODE ###

A, B = map(int, input().split())
_MAX_PRICE = 1001
for n in range(1, _MAX_PRICE):
  if int(n * 0.08) == A and int(n * 0.1) == B:
    print(n)
    exit()
print(-1)
n = int(input())
l = [int(i) for i in input().split()]
if 2 * max(l) - sum(l) < 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = int(input())
a = [s]
i = 1
while True :
    if a[i-1] % 2 == 0:
        t = int((a[i-1])/2)
    else:
        t = int((a[i-1])*3+1)
        
    i +=1 
    
    if t in a:
        print(i)
        break  
    a.append(t)
N, M = map(int, input().split())

A = list(map(int, input().split()))
def soujyuu(left, right, num):
    if right - left <= 1:
        A.insert(right, num)
    else:
        if num >= A[left + right // 2]:
            left = left + right // 2
        else:
            right = left + right // 2
        soujyuu(left, right, num)


A.sort()
for i in range(M):
    maxA = A.pop(N-1)
    maxA = maxA // 2
    soujyuu(0,N-2, maxA)
    #print(A)

print(sum(A))


### FIXED CODE ###

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

A = list(map(int, input().split()))
h = []

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

for i in range(N):
    heapq.heappush(h, A[i])

for i in range(M):
    num = heapq.heappop(h)
    num = num * -1
    num = num // 2
    heapq.heappush(h, -num)

print(-sum(h))
N,M=map(int,input().split())
A=dict()
ans=0
for i in range(N):
    a,b=map(int,input().split())
    A[a]=b
A=list(A.items())
A.sort()
for i in range(N):
    if M>=A[i][0]:
        M-=A[i][1]
        ans+=A[i][0]*A[i][1]
    else:
        ans+=A[i][0]*M
        break
print(ans)


### FIXED CODE ###

N,M=map(int,input().split())
A=dict()
ans=0
A=[list(map(int,input().split()))for i in range(N)]
A.sort()
for i in range(N):
    if M>A[i][1]:
        M-=A[i][1]
        ans+=A[i][0]*A[i][1]
    else:
        ans+=A[i][0]*M
        break
print(ans)
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))

buka_num = []

for i in range(1, N):
  tmp_A = A[i:]
	buka_num.append(tmp_A.count(i))

buka_num.append(0)

print(buka_num, sep='¥n')

### FIXED CODE ###

import collections
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))
c = collections.Counter(A)
buka_num = []

for i in range(1,N):
    buka_num.append(c[i])
    
buka_num.append(0)
for ele in buka_num:
    print(ele)
n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0]*(50*n+1) for _ in range(n+1)] for _ in range(n+1)]
for i in range(n+1):
    for j in range(n+1):
        for k in range(50*n+1):
            if i == 0 and j == 0 and k == 0:
                dp[i][j][k] = 1
            elif i and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i and j and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
ans = 0
for j in range(1, n+1):
    ans += dp[n][j][a*j]
print(ans)



### FIXED CODE ###

N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N <= K:
    print(N * X)
else:
    print(K * X + (N - K) * Y)
def g(n,r):return f[n]//f[n-r]//f[r]
n,*a=map(int,open(0).read().split())
m=max(a)
f=[1]*-~m
for i in range(m):f[i+1]=f[i]*-~i
o=min(a)
for A in a:
 if g(m,A)>g(m,o):o=A
print(m,o)


### FIXED CODE ###

n,*a=map(int,open(0).read().split())
m=max(a)
b=m//2
o=min(a)
for A in a:
 if abs(A-b)<abs(o-b):o=A
print(m,o)
N=input()

if N==1:
  print("Hello World")
else:
  A=int(input())
  B=int(input())
  print(A+B)

### FIXED CODE ###

N=int(input())     
if N==1:
    print("Hello World")
else:
    A=int(input())
    B=int(input())
    print(A+B)