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


import fractions

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

g=fractions.gcd(A,B)

if g==1:
    print(1)
    exit()
cnt=0
for i in range(2,g+1):
    if g%i==0:
        cnt+=1
        g=g//i
        while g%i==0:
            g=g//i
print(cnt+1)





### FIXED CODE ###

def div(N):
    ans = []
    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            ans.append(i)
            if N // i != i:
                ans.append(N // i)
    ans.sort()
    return ans
import fractions

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

g=fractions.gcd(A,B)

if g==1:
    print(1)
    exit()
cnt=0
di=div(g)

for i in di:
    f=True
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            f=False
            break
    if f:
        cnt+=1
print(cnt)
### BUGGY CODE ###

n = int(input())

power = 1
for i in range(1, n + 1):
    power *= i

mod = 10 ** 9 + 7
ans = power % mod
print(ans)


### FIXED CODE ###

n = int(input())

from math import factorial

power = factorial(n)
mod = 10 ** 9 + 7
ans = power % mod
print(ans)
### BUGGY CODE ###

import heapq as h
import sys

input=sys.stdin.readline

N,M=map(int,input().split())
hen=[[] for i in range(0,N)]
for i in range(0,M):
    u,v=map(int,input().split())
    hen[u-1].append(v-1)

S,T=map(int,input().split())

triplehen=[[] for i in range(0,N)]
for i in range(0,N):
    q=[i]
    h.heapify(q)
    sub=[]
    h.heapify(sub)
    count=0
    while 3>count:
        while q!=[]:
            x=h.heappop(q)
            for p in hen[x]:
                h.heappush(sub,p)
            if q==[]:
                count+=1
                if count==3:
                    for j in sub:
                        triplehen[i].append(j)
                else:
                    if sub==[]:
                        count=3
                q=sub
                sub=[]
                h.heapify(sub)
                break
triplehen=[list(set(triplehen[i])) for i in range(0,N)]

ans=[-1 for i in range(0,N)]
ans[S-1]=0

q=[]
q.append(S-1)
h.heapify(q)
sub=[]
h.heapify(sub)
count=0
while q!=[]:
    while q!=[]:
        x=h.heappop(q)
        for p in triplehen[x]:
            if ans[p]==-1:
                h.heappush(sub,p)
        if q==[]:
            count+=1
            for j in sub:
                ans[j]=count
            q=sub
            sub=[]
            h.heapify(sub)
            break

print(ans[T-1])


### FIXED CODE ###

import heapq as h

N,M=map(int,input().split())
hen={(i,j):[] for i in range(0,N) for j in range(0,3)}
for i in range(0,M):
    u,v=map(int,input().split())
    hen[(u-1,0)].append((v-1,1))
    hen[(u-1,1)].append((v-1,2))
    hen[(u-1,2)].append((v-1,0))

S,T=map(int,input().split())

start=(S-1,0)
goal=(T-1,0)

distance={(i,j):-1 for i in range(0,N) for j in range(0,3)}

q=[]
q.append(start)
distance[start]=0
h.heapify(q)
sub=[]
h.heapify(sub)
while q!=[]:
    while q!=[]:
        x=h.heappop(q)
        for p in hen[x]:
            if distance[p]==-1:
                h.heappush(sub,p)
                distance[p]=distance[x]+1
        #何らかの操作
        #ここでsubキューに次に使うものを格納
        if q==[]:
            q=sub
            sub=[]
            h.heapify(sub)
            break

if distance[goal]==-1:
    print(-1)
else:
    print(distance[goal]//3)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(L: str):
    n = len(L)
    memo = [0] * (n + 1)
    memo[0] = 1
    for i in range(1, n + 1):
        memo[i] = memo[i - 1] * 3 % MOD

    ret = 0
    cnt = 0
    for i in range(n):
        c = L[i]
        if c == '1':
            rest = n - i - 1
            ret += memo[rest] * (2 ** cnt)
            cnt += 1
            #print(ret)
    ret = (ret + 2 ** cnt) % MOD
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = str(next(tokens))
    solve(L)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(L: str):
    n = len(L)
    memo = [0] * (n + 1)
    memo[0] = 1
    for i in range(1, n + 1):
        memo[i] = memo[i - 1] * 3 % MOD
    cum = [0] * (n + 1)
    cum[0] = 1
    for i in range(1, n + 1):
        cum[i] = (cum[i - 1] * 2) % MOD

    ret = 0
    cnt = 0
    for i in range(n):
        c = L[i]
        if c == '1':
            rest = n - i - 1
            ret = (ret + memo[rest] * cum[cnt]) % MOD
            cnt += 1
            #print(ret)
    ret = (ret + cum[cnt]) % MOD
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = str(next(tokens))
    solve(L)

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

n = int(input())
a = [int(input()) for i in range(n)]
check = []
cnt = 0
i = 0
while True:
    if i in check:
        print(-1)
        break
    if i not in check:
        check.append(i)
        i = a[i]-1
    if cnt >= n/2:
        print(-1)
        break
    if i == 1:
        print(len(check))
        break
    cnt += 1
    
    

### FIXED CODE ###

n = int(input())
a = [None]
for j in range(n):
    a.append(int(input()))

i = 1
c = 0
r = [1]
while True:
    c += 1
    i = a[i]
    if i == 2:
        print(c)
        break
    if c > (10**5):
        print(-1)
        break
### BUGGY CODE ###

import sys
from heapq import heappop, heappush, heapify

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, M = MAP()
A = MAP()
BC = [MAP() for _ in range(M)]

BC.sort(key= lambda x:x[1], reverse=True)

heapify(A)

fin = False
for b, c in BC:
	#print(A, b, c)
	while b:
		a = heappop(A)
		if a>c:
			fin = True
			heappush(A, a)
			break
		else:
			heappush(A, c)
			b -= 1
	if fin:
		break

print(sum(A))

### FIXED CODE ###

import sys
from heapq import heapify, heappop
from operator import itemgetter

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N, M = MAP()
	A = MAP()
	BC = [MAP() for _ in range(M)]
	
	BC.sort(key= itemgetter(1), reverse=True)
	
	heapify(A)
	
	ans = 0
	
	fin = False
	for b, c in BC:
		#print(A, b, c)
		for _ in range(b):
			a = A[0]
			if a>c:
				fin = True
				break
			else:
				heappop(A)
				ans += c
				N -= 1
				if N == 0:
					fin = True
					break
		if fin:
			break
	
	print(ans+sum(A))

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

def main():
    n = int(input())
    x = input()
    x = '0b'+x

    x = int(x,0)

    ans = dict()

    for i in range(n-1,-1,-1):
        a = x ^ (1<<i)
        b = a
        cnt = 0
        while a != 0:
            if a in ans.keys():
                cnt += ans[a]
                break
            cnt += 1
            a = solve(a)
        ans[b] = cnt
        # z.append(cnt)
        print(cnt)
    # print(z)
        
def solve(n):
    m = bin(n).count('1')
    return n%m

main()


### FIXED CODE ###

def main():
    n = int(input())
    x = input()
    x = '0b'+x

    x = int(x,0)
    m = bin(x).count('1')

    if m > 1:
        a = x%(m-1)
    b = x%(m+1)
    tmp_a = 1
    tmp_b = 1
    xx = []

    for i in range(n):
        if (x >> i) &1:
            if m == 1:
                xx.append(0)
                continue
            else:
                y = (a - tmp_a)%(m-1)
        else:
            y = (b + tmp_b)%(m+1)
        tmp_a *= 2
        if m > 1:
            tmp_a %= (m-1)
        tmp_b *= 2
        tmp_b %= (m+1)

        cnt = 1
        while y != 0:
            cnt += 1
            y = solve(y)
        xx.append(cnt)
    
    # print(xx)
    for i in range(n-1,-1,-1):
        print(xx[i])

def solve(n):
    m = bin(n).count('1')
    return n%m

main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

SC=[0,0,0,0]#0個,1個,2個,3個

for a in A:
    SC[a]+=1
SC=tuple(SC)

DAYSDICT=dict()

def days(SC):
    if DAYSDICT.get(SC)!=None:
        return DAYSDICT[SC]

    if SC[1]<0 or SC[2]<0 or SC[3]<0:
        return 0

    k=SC[1]+SC[2]+SC[3]

    if k==0:
        return 0

    DAYSDICT[SC]=(SC[0]+k)/k+days((SC[0]+1,SC[1]-1,SC[2],SC[3]))*SC[1]/k+days((SC[0],SC[1]+1,SC[2]-1,SC[3]))*SC[2]/k+days((SC[0],SC[1],SC[2]+1,SC[3]-1))*SC[3]/k
    return DAYSDICT[SC]


print(days(SC))


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

SC=[0,0,0]#1個,2個,3個

for a in A:
    SC[a-1]+=1
one,two,three=SC

DAYSDICT=[[[0.0]*301 for j in range(301)] for k in range(301)]
DAYSDICT[0][0][0]=0
def days(one,two,three):
    ANS=N
    if one>0:
        ANS+=DAYSDICT[one-1][two][three]*one
    if two>0:
        ANS+=DAYSDICT[one+1][two-1][three]*two
    if three>0:
        ANS+=DAYSDICT[one][two+1][three-1]*three
        
    DAYSDICT[one][two][three]=ANS/(one+two+three)


for k in range(three+1):
    for j in range(two+three+1-k):
        for i in range(one+two+three+1-j-k):
            if i==j==k==0:
                continue
            days(i,j,k)

print(DAYSDICT[one][two][three])
### BUGGY CODE ###

import sys
input=sys.stdin.readline
h,w=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(h)]
b=[list(map(int,input().split()))for _ in range(h)]
l=80*80+1
dp=[l*[False]for _ in range((h+1)*(w+1))]
mid=l//2
for i in range(h):
  for j in range(w):
    c=abs(a[i][j]-b[i][j])
    if i==j==0:dp[w+2][c]=True;continue
    else:
      for k in range(l-c):dp[(i+1)*(w+1)+j+1][k]=dp[i*(w+1)+j+1][abs(k-c)] or dp[(i+1)*(w+1)+j][abs(k-c)] or dp[i*(w+1)+j+1][abs(k+c)] or dp[(i+1)*(w+1)+j][abs(k+c)]
for i in range(l):
  if dp[-1][i]:print(i);exit()

### FIXED CODE ###

h,w=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(h)]
b=[list(map(int,input().split()))for _ in range(h)]
d=[[a[i][j]-b[i][j]for j in range(w)]for i in range(h)]
dp=[w*[0]for _ in range(h)]
dp[0][0]=1<<(80+d[0][0])|1<<(80-d[0][0])
for i in range(h):
  for j in range(w):
    if i!=0:
      dp[i][j]|=(dp[i-1][j]<<80+d[i][j])
      dp[i][j]|=(dp[i-1][j]<<80-d[i][j])
    if j!=0:
      dp[i][j]|=(dp[i][j-1]<<80+d[i][j])
      dp[i][j]|=(dp[i][j-1]<<80-d[i][j])
n=dp[-1][-1]|(1<<15000)
ans=1<<1000
for i in range(15000):
  if n&(1<<i):ans=min(ans,abs(i-(h+w-1)*80))
print(ans)
### BUGGY CODE ###

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

score: list = []
for i in range(k - 1, n):
    tmp_score = 1
    for j in range(k):
        tmp_score *= a[i - j]
    score.append(tmp_score)

for i in range(len(score) - 1):
    # print(score[i], score[i + 1])
    if score[i + 1] > score[i]:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

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

for i in range(k, n):
    if a[i - k] < a[i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
while a[0]>0 and m>0:
    a[0]=a[0]//2
    a.sort(reverse=True)
    m-=1
print(sum(a))

### FIXED CODE ###

import heapq
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x:x*(-1),a))
heapq.heapify(a)
while m>0:
    ma = heapq.heappop(a)*(-1)
    ma //=2
    heapq.heappush(a,ma*(-1))
    m-=1
print(sum(a)*(-1))
### BUGGY CODE ###

a = input()
a_set = set([a])
for i in range(len(a)):
    for j in range(i+1, len(a)):
        if a[:i] + "".join(list(reversed(a[i:j+1]))) + a[j+1:] not in a_set:
            a_set.add(a[:i] + "".join(list(reversed(a[i:j+1]))) + a[j+1:])
print(len(a_set))

### FIXED CODE ###

from collections import Counter
a = input()
k = Counter(a).values()
ans = len(a) * (len(a) - 1) // 2
for k_v in k:
    if k_v > 1:
        ans -= k_v * (k_v - 1) // 2
print(ans + 1)
### BUGGY CODE ###

n, t = map(int, input().split())
f = [[0, 0] for i in range(t + 1)]
for i in range(n):
  w, v = map(int, input().split())
  for j in range(t, 0, -1):
    f[j][1] = max(f[j][1], f[j - 1][0] + v)
    if j >= w:
      f[j][0] = max(f[j][0], f[j - w][0] + v)
      f[j][1] = max(f[j][1], f[j - w][1] + v)
print(f[t][1])

### FIXED CODE ###

n, t = map(int, input().split())
f = [[0, 0] for i in range(t + 1)]
for i in range(n):
  w, v = map(int, input().split())
  for j in range(t, 0, -1):
    f[j][1] = max(f[j][1], f[j - 1][0] + v)
    if j >= w:
      f[j][0] = max(f[j][0], f[j - w][0] + v)
      f[j][1] = max(f[j][1], f[j - w][1] + v)
print(f[t][1])
### BUGGY CODE ###

from collections import deque

h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1
t = [[i for i in range(w)] for j in range(h)]
ans = 0
for i in range(h):
  temp = input()
  for j in range(w):
    t[i][j] = temp[j]

d = deque([(Ch, Cw)])  # 陸路で行くところ
d2 = deque([(Ch, Cw)]) # 直前のワープ後に陸路でいった場所のメモ
s = set() # いったところ
ans = 0
a = [(1,0),(-1,0),(0,1),(0,-1)]
b = [-2, -1, 0, 1, 2]

while True:
  # 移動A
  while len(d) != 0:
    Th, Tw = d.popleft()
    s.add((Th, Tw))
    d2.append((Th, Tw))
    for i, j in a:
      _h = Th + i
      _w = Tw + j
      _p = (_h, _w)
      if _p == (Dh, Dw):
        print(ans)
        exit()
      if not _p in s and 0 <= _h < h and 0 <= _w < w and t[_h][_w] == '.' and (not (_p) in d):
        d.append(_p)
  # 移動B
  ans += 1
  while len(d2) != 0:
    Th, Tw = d2.popleft()
    for i in b:
      for j in b:
        _h = Th + i
        _w = Tw + j
        _p = (_h, _w)
        if _p == (Dh, Dw):
          print(ans)
          exit()
        if not _p in s and 0 <= _h < h and 0 <= _w < w and t[_h][_w] == '.':
          d.append(_p)
  if len(d) == 0:
    print('-1')
    exit()

### FIXED CODE ###

from collections import deque

h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1
t = [[i for i in range(w)] for j in range(h)]
visited = [[0 for i in range(w)] for j in range(h)] # いったところ
ans = 0
for i in range(h):
  temp = input()
  for j in range(w):
    t[i][j] = temp[j]

d = deque([(Ch, Cw)])
ans = 0
a = [(1,0),(-1,0),(0,1),(0,-1)]

while True:
  # 移動A
  stemp = set()
  while len(d) != 0:
    Th, Tw = d.popleft()
    # s.add((Th, Tw))
    visited[Th][Tw] = 1
    stemp.add((Th, Tw))
    if (Th,Tw) == (Dh, Dw):
      print(ans)
      exit()
    for i, j in a:
      _h,_w = Th + i, Tw + j
      _p = (_h, _w)
      if 0 <= _h < h and 0 <= _w < w and t[_h][_w] == '.' and visited[_h][_w] == 0:
        d.append(_p)
        visited[_h][_w] = 1
  # 移動B
  ans += 1
  for Th,Tw in stemp:
    for i in range(-2, 3) :
      for j in range(-2, 3) :
        _h,_w = Th + i, Tw + j
        _p = (_h, _w)
        if 0 <= _h < h and 0 <=  _w < w and t[_h][_w] == '.' and visited[_h][_w] == 0:
          d.append(_p)
  if len(d) == 0:
    print('-1')
    exit()
### BUGGY CODE ###

import collections
n=int(input())
a=list(map(int, input().split(' ')))
c = collections.Counter(a)


def n_c_2(val):
  ret = 0
  if val > 1:
    ret = (val)*(val-1)//2
  return ret

org_nc2 = {}
org_minus1_nc2 = {}

for k in list(c.keys()):
  org_nc2[k] = n_c_2(c[k])
for k in list(c.keys()):
  org_minus1_nc2[k] = n_c_2(c[k] - 1)

for d in a:
  ans = 0
  for k in list(c.keys()):
    if d == k:
      ans += org_minus1_nc2[k]
    else:
      ans += org_nc2[k]
  print (ans)

### FIXED CODE ###

import collections
n=int(input())
a=list(map(int, input().split(' ')))
c = collections.Counter(a)

def n_c_2(val):
  ret = 0
  if val > 1:
    ret = (val)*(val-1)//2
  return ret

org_nc2 = {}
org_minus1_nc2 = {}
sumall = 0
for k in list(c.keys()):
  org_nc2[k] = n_c_2(c[k])
  org_minus1_nc2[k] = n_c_2(c[k] - 1)
  sumall += org_nc2[k]
for d in a:
  ans = sumall - org_nc2[d] + org_minus1_nc2[d]
  print (ans)
### BUGGY CODE ###

def F(a,b):
    a=len(str(a))
    b=len(str(b))-2#float型のため
    return a if a>b else b
n=int(input())
o=[]
k=100000000
c=0
m=10000000000
for i in range(1,n):
    if c>0:
        c-=1
        continue
    s=n/i
    if s.is_integer():
        k=F(i,s)
        o.append(k)
        if k>m:
            break
        m=k
        i=int("1"+"0"*len(str(i)))-i#iを次の位にする
try:
    print(min(o))
except:
    print(1)

### FIXED CODE ###

from math import sqrt
def F(A,B):
    A=len(str(A))
    B=len(str(B))-2
    return A if A>B else B
n=int(input())
o=[]
for a in range(1,int(sqrt(n))+1):
    b=n/a
    if b.is_integer():
        o.append(F(a,b))
print(o[-1])
### BUGGY CODE ###

from collections import deque

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

rev_p = [0] * (n * n)
for offset in range(len(p)):
    rev_p[p[offset] - 1] = offset

ans = 0
for i, pi in enumerate(p):
    d = deque()
    d.append((0, pi-1))
    memo = set()

    while d:
        cost, pos = d.popleft()

        if pos in memo:
            continue

        memo.add(pos)

        if pos < n or pos >= n * (n-1) or pos % n == 0 or pos % n == n-1:
            ans += cost
            break

        for offset in [-1, -n, 1, n]:
            if 0 <= pos + offset < n * n:
                if rev_p[pos + offset] < i:
                    d.appendleft((cost, pos + offset))
                else:
                    if pos+offset not in memo:
                        d.append((cost + 1, pos + offset))

print(ans)


### FIXED CODE ###

from collections import deque

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

costs = [0] * n2

for i in range(n2):
    costs[i] = min(i // n, n - i // n - 1, i % n, n - i % n - 1)

remains = [1] * n2

ans = 0
for i, pi in enumerate(p):
    ans += costs[pi-1]
    remains[pi-1] = 0

    d = deque()
    d.append((pi-1, costs[pi-1]))

    while d:
        pos, cost = d.popleft()

        for offset in [-1, -n, 1, n]:
            if 0 <= pos + offset < n2:
                next_cost = cost + remains[pos]

                if costs[pos+offset] > next_cost:
                    costs[pos+offset] = next_cost
                    d.append((pos+offset, next_cost))

print(ans)
### BUGGY CODE ###

"""1, 2, 3, 4, 5, 6, 7, 8, 9, 
10, 11, 12, 21, 22, 23, 32, 33, 34, 43, 44, 45, 54, 55, 56, 65, 66, 67, 76, 77, 78, 87, 88, 89, 98, 99, 
100, 101, 110, 111, 112, 121, 122, 123, 210, 211, 212, 221, 222, 223, 232, 233, 234, 321, 322, 323, 33

1 -> 10,11,12 -> 100,101 ,110,111,112, 121,122,123

2 -> 21,22,23 -> 210,211,212, 221,222,223, 232,233,234"""

n = int(input())

queue = [i for i in range(1,10)]
while True:
    if n == 1:
        print(queue.pop(0))
        break
    tmp = queue.pop(0)
    n -= 1
    if tmp%10 != 0:
        queue.append(tmp*10 + tmp%10 - 1)
    queue.append(tmp*10 + tmp%10)
    if tmp%10 != 9:
        queue.append(tmp*10 + tmp%10 + 1)

### FIXED CODE ###

"""1, 2, 3, 4, 5, 6, 7, 8, 9, 
10, 11, 12, 21, 22, 23, 32, 33, 34, 43, 44, 45, 54, 55, 56, 65, 66, 67, 76, 77, 78, 87, 88, 89, 98, 99, 
100, 101, 110, 111, 112, 121, 122, 123, 210, 211, 212, 221, 222, 223, 232, 233, 234, 321, 322, 323, 33

1 -> 10,11,12 -> 100,101 ,110,111,112, 121,122,123

2 -> 21,22,23 -> 210,211,212, 221,222,223, 232,233,234"""
def main():
    n = int(input())
    
    queue = [i for i in range(1,10)]
    if n < 10:
        print(queue[n-1])
        return
    n -= 9
    while True:
        if n <= 0:
            print(queue[n-1])
            return
        tmp = queue.pop(0)
        if tmp%10 == 0:
            queue += [tmp*10 + tmp%10, tmp*10 + tmp%10 + 1]
            n -= 2
        elif tmp%10 == 9:
            queue += [tmp*10 + tmp%10 - 1, tmp*10 + tmp%10]
            n -= 2
        else:
            queue += [tmp*10 + tmp%10 - 1, tmp*10 + tmp%10, tmp*10 + tmp%10 + 1]
            n -= 3

main()
### BUGGY CODE ###

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

while m > 0:
    A = sorted(A, reverse=True)
    A[0] = A[0]//2
    m -= 1

print(sum(A))


### FIXED CODE ###

import heapq

n, m = map(int, input().split())
A = sorted(list(map(lambda x: int(x)*(-1), input().split())))

heapq.heapify(A)

for i in range(m):
    a = heapq.heappop(A)
    a = a * (-1) // 2
    heapq.heappush(A, -a)

print(-sum(A))
### BUGGY CODE ###

import math
N=int(input())

for i in range(1,N+1):
  n=math.ceil(math.sqrt(N))
  res=0
  for x in range(1,n+1):
    for y in range(1,n+1):
      for z in range(1,n+1):
        if x*x+y*y+z*z+x*y+y*z+z*x==i:
          res+=1
  print(res)

### FIXED CODE ###

import math
N=int(input())


n_max=math.ceil(math.sqrt(N))
res=[0]*(N+1)

for x in range(1,n_max+1):
  for y in range(1,n_max+1):
    for z in range(1,n_max+1):
      v=x*x+y*y+z*z+x*y+y*z+z*x
      if v <= N:
        res[v]+=1

for i in range(1,N+1):
  print(res[i])
### BUGGY CODE ###

import sys
from itertools import permutations, combinations

n, c = map(int, sys.stdin.readline().split())
d = [[int(x) for x in sys.stdin.readline().split()] for _ in range(c)]
grid = [[int(x) - 1 for x in sys.stdin.readline().split()] for _ in range(n)]

cost = [[0] * c for _ in range(3)]
for i in range(n):
  for j in range(n):
    k = (i + j) % 3
    for l in range(c):
      cost[k][l] += d[grid[i][j]][l]
  
def main():
  res = []
  for comb in combinations(range(c), 3):
    for i, j, k in permutations(comb):
      res.append(cost[0][i] + cost[1][j] + cost[2][k])
  print(min(res))

if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
import numpy as np 
from itertools import permutations

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, C = I[:2]
cost = I[2:2+C**2].reshape(C, C)
color = I[2+C**2:].reshape(n, n) - 1

def main():
    mod_3 = (np.arange(1, n+1)[:, None] + np.arange(1, n+1)) % 3
    c0 = np.bincount(color[mod_3 == 0], minlength=C)
    c1 = np.bincount(color[mod_3 == 1], minlength=C)
    c2 = np.bincount(color[mod_3 == 2], minlength=C)

    ans = float('inf')
    for i, j, k in permutations(range(C), 3):
        res = np.sum(c0 * cost[:, i])
        res += np.sum(c1 * cost[:, j])
        res += np.sum(c2 * cost[:, k])
        ans = min(ans, res)
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)