Harryxun/stf_run huggingface dataset:
n = int(input())
x = input()
temp = x.count("1")
x2 = int(x, 2)
for i in range(n):
    if x[i] == "1":
        temp2 = -1
    else:
        temp2 = 1
    num = x2 ^ (2 ** (n - 1 - i))
    num %= (temp + temp2)
    count = 1
    while num:
        num %= bin(num).count("1")
        count += 1
    print(count)

### FIXED CODE ###

n = int(input())
x = input()
temp = x.count("1")
mod1 = [1]
for i in range(n-1):
    mod1.append(mod1[-1] * 2 % (temp + 1))
mod1.reverse()
num1 = 0
for i in range(n):
    if x[i] == "1":
        num1 += mod1[i]
        num1 %= (temp + 1)
if temp == 1 or temp == 2:
    mod2 = [0] * n
else:
    mod2 = [1]
    for i in range(n-1):
        mod2.append(mod2[-1] * 2 % (temp - 1))
    mod2.reverse()
    num2 = 0
    for i in range(n):
        if x[i] == "1":
            num2 += mod2[i]
            num2 %= (temp - 1)
x2 = int(x, 2)
for i in range(n):
    if x[i] == "1":
        if temp == 1:
            print(0)
            continue
        elif temp == 2:
            print(1)
            continue
        else:
            num = num2 - mod2[i]
            num %= (temp - 1)
    else:
        num = num1 + mod1[i]
        num %= (temp + 1)
    count = 1
    while num:
        num %= bin(num).count("1")
        count += 1
    print(count)
f = list(map(int, input().split()))
s = list(map(int, input().split()))
t = list(map(int, input().split()))
n = int(input())
k = []
for i in range(n):
    k.append(int(input()))

lis = []

lis.append(f)
lis.append(s)
lis.append(t)

ans = 0

for i in lis:
    c =0
    for n in range(len(i)):
        if i[n] in k:
            i[n] = 'X'
            c += 1
            if c == 3:
                ans +=1
                break

if f[0] == 'X' and s[0] == 'X' and t[0] == 'X':
    ans +=1
elif f[1] == 'X' and s[1] == 'X' and t[1] == 'X':
    ans += 1
elif f[2] == 'X' and s[2] == 'X' and t[2] == 'X':
    ans += 1
elif f[0] == 'X' and s[1] == 'X' and t[3] == 'X':
    ans += 1
elif f[3] == 'X' and s[2] == 'X' and t[1] == 'X':
    ans += 1
    
if ans >= 1:
    print('Yes')
elif ans == 0:
    print('No')

### FIXED CODE ###

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

lis = []

lis.append(f)
lis.append(s)
lis.append(t)

ans = 0

for i in lis:
    c =0
    for n in range(len(i)):
        if i[n] in k:
            i[n] = 'X'
            c += 1
            if c == 3:
                ans +=1
                break

if f[0] == 'X' and s[0] == 'X' and t[0] == 'X':
    ans +=1
elif f[1] == 'X' and s[1] == 'X' and t[1] == 'X':
    ans += 1
elif f[2] == 'X' and s[2] == 'X' and t[2] == 'X':
    ans += 1
elif f[0] == 'X' and s[1] == 'X' and t[2] == 'X':
    ans += 1
elif f[2] == 'X' and s[1] == 'X' and t[0] == 'X':
    ans += 1
    
if ans >= 1:
    print('Yes')
elif ans == 0:
    print('No')
N = int(input())
a = list(map(int, input().split(" ")))


l = [[] for i in range(N)]
c = 0

s = 0
t = a[0]

for i in a[1:]:
	if t > i:
		l[s].append((c))
		s = c+1
	c += 1
	t = i
else:
	l[s].append((c))

c = 0

s = 0
t = a[0]

for i in a[1:]:
	if t < i:
		l[s].append((c))
		s = c+1
	c += 1
	t = i
else:
	l[s].append((c))

l[0] = max(l[0])
for i in range(1,N):
	if i!=N-1:
		l[i+1].append(-1)
		l[i] = max(l[i-1],max(l[i]),max(l[i+1]))
	else:
		l[i] = max(l[i-1],max(l[i]))


now = 0
res = 0

while now<N-1:
	now = l[now]	
	res+=1

print(res)

### FIXED CODE ###

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


l = [[] for i in range(N)]
c = 0

s = 0
t = a[0]

for i in a[1:]:
	if t > i:
		l[s].append((c))
		s = c+1
	c += 1
	t = i
else:
	l[s].append((c))

c = 0

s = 0
t = a[0]

for i in a[1:]:
	if t < i:
		l[s].append((c))
		s = c+1
	c += 1
	t = i
else:
	l[s].append((c))

l[0] = max(l[0])
for i in range(1,N):
	l[i].append(-1)
for i in range(1,N):
	
	if i!=N-1:
		l[i+1].append(-1)
		l[i] = max(l[i-1],max(l[i]),max(l[i+1]))
	else:
		l[i] = max(l[i-1],max(l[i]))


now = 0
res = 0

while now<N-1:
	now = l[now]	
	res+=1
if N==1:
	print(1)
	exit()
print(res)
list = []
	setup.strip','
	print(T,S)
list



### FIXED CODE ###

A, B = input().split()
C = B + A
print(C)
n=input()
aa=map(int,input().split())
aa.sort(reverse=True)

ab=[0]*2

i=0
for a in aa:
  ab[i%2]+=a
  i+=1

print(ab[0]-ab[1])



### FIXED CODE ###

n=input()
aa=list(map(int,input().split()))
aa.sort(reverse=True)

ab=[0]*2

i=0
for a in aa:
  ab[i%2]+=a
  i+=1

print(ab[0]-ab[1])
n=input()
n.remove('Buzz','Fizz','FizzBuzz')
print(sum(n))

### FIXED CODE ###

n=int(input())
a=1
b=0
while True:
	if a%3!=0 and a%5!=0:
		b+=a
	if a==n:
		break
	a+=1
print(b)
n, m = map(int, input().split())

s = [0] * m
c = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())

ans = False
for x in range(10 ** (n - 1), 10 ** n):
    x = list(str(x))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        break

if n == 1:
    x = list(str(0))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        break
    
if ans == False:
    print(-1)


### FIXED CODE ###

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

s = [0] * m
c = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())

ans = False

if n == 1:
    x = list(str(0))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        
for x in range(10 ** (n - 1), 10 ** n):
    x = list(str(x))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag and ans == False:
        print(int(''.join(x)))
        ans = True
        break


    
if ans == False:
    print(-1)
if 1<=x<=100 :
    s=x*x*x
print(s)


### FIXED CODE ###

x = int(input())
print(x*x*x)
from functools import reduce
l = [int(input()) for _ in range(5)]
r = min([i % 10 for i in l if i % 10 != 0])
l = [i if i % 10 == 0 else i // 10 * 10 + 10 for i in l]
print(reduce(lambda a, b: a + b, l) + r - 10)


### FIXED CODE ###

import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a, b, c, d, e]
ans = 9
n = 0
j = 0
for i in [i % 10 for i in l]:
    if i != 0 and i < ans:
        ans = i
        n = j
    j += 1
m = l.pop(n)
r = 0
for i in l:
    r += math.ceil(i / 10) * 10
print(r + m)
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
dp=[inf]*(110000)
for i in range(110000):
    dp[i] = N 
dp[0]=0
for n in range(N):
    pow6,pow9 = 1,1
    while pow6<=N:
        dp[n+pow6] = min(dp[n+pow6],dp[n]+1)
        pow6 *= 6
    while pow9 <=N:
        dp[n+pow9] = min(dp[n+pow9],dp[n]+1)
        pow9 *= 9
print(dp[N])


### FIXED CODE ###

N = int(input())
l = [1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
dp = [N]*(N+1)
dp[0]=0

for i in range(1,N+1):
    for j in l:
        if i-j >= 0:
            dp[i] = min(dp[i],dp[i-j]+1)
print(dp[N])
s=list(map(str,input().split()))

print(''.join([s[0][0],s[1][0],s[2][0]]))s=list(map(int,input().split()))



### FIXED CODE ###

s=list(map(str,input().split()))

print(''.join([s[0][0],s[1][0],s[2][0]]))
N = int(input())
L = list(map(int, input().split()))

counter = 0

max_n = 0

for i in range(0,N):
	if L[i] > L[i+1]:
		counter += 1
	else:
		max_m = max(max_m,counter)
		ct = 0
			
print(max(max_m,counter))

### FIXED CODE ###

N = int(input())
L = [int(i) for i in input().split()]

Max =  0
Count = 0
for i in range(N-1):
    if L[i] >= L[i+1]:
        Count += 1
    else:
        Count = 0
    if Count >= Max:
        Max = Count
print(Max)
n,m  =map(int,input().split())
a = [int(i) for i in input().split()]

ans = 0

for k in range(m):
		max(a)=max(a)//2


for i in range(n):
	ans+=a[i]

print(ans)


### FIXED CODE ###

import heapq

n,m = (int(x) for x in input().split())

a = [int(i)*(-1) for i in input().split()]
heapq.heapify(a)
for _ in range(m):

    b  = -(heapq.heappop(a))//2
    heapq.heappush(a,-b)


print(-sum(a))
n=int(input())
a,b=int(input()),int(input())
if n==1:print('Hello World')
else:print(a+b)

### FIXED CODE ###

n=int(input())
if n==1:print('Hello World')
else:
  a,b=int(input()),int(input())
  print(a+b)
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    v = A[i]
    j = i - 1
    while((j >= 0) and A(j) > v):
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(A)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    v = A[i]
    j = i - 1
    while((j >= 0) and A[j] > v):
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)
def resolve():
    N, M, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    read = deque()

    while sum(read) <= K:
        if len(A) == 0 and len(B) == 0:
            break

        if len(A) == 0:
            if sum(read) + B[0] <= K:
                read.append(B[0])
            B.pop(0)
            continue

        if len(B) == 0:
            if sum(read) + A[0] <= K:
                read.append(A[0])
            A.pop(0)
            continue

        if A[0] < B[0]:
            if sum(read) + A[0] <= K:
                read.append(A[0])
            A.pop(0)
        else:
            if sum(read) + B[0] <= K:
                read.append(B[0])

            B.pop(0)

    print(len(read))


resolve()

### FIXED CODE ###

def resolve():
    N, M, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    ans = 10 ** 10
    t = 0

    for i in range(M):
        t += B[i]
    j = M
    ans = 0
    for i in range(N+1):
        while j > 0 and t > K:
            j -= 1
            t -= B[j]
        
        if t > K:
            break
        
        ans = max(ans, i+j)
        
        if i == N:
            break
        t += A[i]
    
    print(ans)

resolve()
import collections
n,x,m=map(int,input().split())
if n==1 or x==0:
  print(x)
  exit()
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
  wk=(wk*wk)%m
  if not wk in a:
    a[wk]=i
  else:
    start=a[wk]
    end=i
    break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiindex):
  koteiwa+=a[i][0]
loopcnt=(n-koteiindex)//(end-start)
loopindex=start-1+(n-koteiindex)%(end-start)
loopwa=0
amariwa=0
for i in range(start,end):
  if i<=loopindex:
    amariwa+=a[i][0]
  loopwa+=a[i][0]
ans=koteiwa+loopwa*loopcnt+amariwa
print(ans)


### FIXED CODE ###

s=input()
if s[len(s)-1]=="s":
  print(s+"es")
else:
  print(s+"s")
import math
r = 10000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        for j in range(2*i+1,r,i+1):
            p[j] = 0

while True:
    n = int(raw_input())
    if not n:
        break
    i, num, sum = 0, 0, 0
    while num < n:
        if p[i] == 1:
            num += 1
            sum += i+1
        i += 1
    print sum

### FIXED CODE ###

import math

r = 105000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]

s = [0 for i in range(11000)]
s[0] = 2
k = 1
for i in range(2,r):
    if p[i]:
        s[k] = i+1+s[k-1]
        k += 1
        
while True:
    n = int(raw_input())
    if not n:
        break
    print s[n-1]
N = int(input())
D = list(map(int, input().split()))

diff = [0]*13
# D.sort()
for i in range(N):
    diff[D[i]] += 1
    if diff[i] > 2:
        print(0)
        exit(0)
if diff[0] > 0:
    print(0)
    exit(0)
else:
    diff2 = [diff[12 - i] for i in range(1, N-1)]

ans = []
for i in range(N):
    if i % 2 == 0:
        ans.append(D[i])
    else:
        ans.append(24 - D[i])

ans = [abs(ans[i+1] - ans[i]) for i in range(N-1)]

print(min(ans))


### FIXED CODE ###

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


D.sort()
ans = [0]
ans = [D[i]
       for i in range(N) if i % 2 == 0] + [24 - D[i] for i in reversed(range(N)) if i % 2 == 1]

ans = [0] + ans + [0]

ans = [abs(ans[i+1] - ans[i]) for i in range(N+1)]

print(min(ans))
N = 6
val = []
for i in range(N):
    val.append(int(input())
if val[4]-val[0] <= val[5]:
    print('Yay!')
else:
    print(':(')


### FIXED CODE ###

N = 6
val = []
for i in range(N):
    val.append(int(input()))

if val[4]-val[0] <= val[5]:
    print('Yay!')
else:
    print(':(')
n = int(input())
aaa = map(int, input().split())

length = 0
lengths = []
for a in aaa:
  length += a
  lengths.append(length)
  
diff = 200000 * 2020202020
for l in lengths:
  if abs(l - (length - l)) < diff:
    diff = abs(l - (length - l))
  else:
    break
    
print(diff)020202020

### FIXED CODE ###

n = int(input())
aaa = map(int, input().split())

length = 0
lengths = []
for a in aaa:
  length += a
  lengths.append(length)
  
diffs = []
for l in lengths:
  diff = abs(l - (length - l))
  diffs.append(diff)
    
print(min(diffs))
s = input()
n = len(s)
mod = 10**9 + 7
dp = [[0 for i in range(n)] for j in range(13)]

if s[0] == '?':
    for i in range(10):
        dp[i][0] = 1
else:
    dp[s][0] = 1

mod_change_table = [(i*10)%13 for i in range(13)]

for x in range(1,len(s)):
    for y in range(13):
        if s[x]=='?':
            for j in range(10):
                dp[(mod_change_table[y]+j)%13][x] += dp[y][x-1]
        else:
            dp[(mod_change_table[y]+int(s[x]))%13][x] += dp[y][x-1]
            

print(dp[5][n-1] % mod)

### FIXED CODE ###

s = input()
mod = 10**9+7

# dp[逆順i桁][j mod 13] := 総数
dp = [[0]*13 for _ in range(len(s)+1)]
dp[0][0] = 1
mul = 1
s_rev = s[::-1]
for i in range(len(s)):
    x = s_rev[i]
    if x == '?':
        for k in range(10):
            for j in range(13):
                dp[i+1][(mul*k+j)%13] += dp[i][j]
                dp[i+1][(mul*k+j)%13] %= mod
    else:
        k = int(x)
        for j in range(13):
            dp[i+1][(mul*k+j)%13] += dp[i][j]
            dp[i+1][(mul*k+j)%13] %= mod
    mul = mul * 10 % 13

print(dp[len(s)][5] % mod)
N = int(input())
u = [input().split() for _ in range(N)]

Y=0
for i in u:
    if i[i][0]=="JPY":
        Y+=u[i][1]
    else:
        Y+=u[i][1]*380000

print(Y)

### FIXED CODE ###

N = int(input())
u = [input().split() for _ in range(N)]

Y=0
for i in range(N):
    if u[i][1]=="JPY":
        Y+=float(u[i][0])
    else:
        Y+=float(u[i][0])*380000

print(Y)
a = int(input())

S = input()

if a >= 3200:
    print(s)

elif a < 3200:
    print('red')


### FIXED CODE ###

a = int(input())

s = input()

if a >= 3200:
    print(s)

else:
    print('red')
#レート
#1-399：灰色
#400-799：茶色
#800-1199：緑色
#1200-1599：水色
#1600-1999：青色
#2000-2399：黄色 
#2400-2799：橙色
#2800-3199：赤色



N = int(input())
scores = sorted(list(map(int,input().split())))
colors = []

color = ""
another = 0

for point in scores:
  if point <= 399:
    color = "gray"
    if color not in colors:
      colors.append(color)
  elif point <= 799 and points :
    color = "brown"
    if color not in colors:
      colors.append(color)
  elif point <= 1199:
    color = "sky"
    if color not in colors:
      colors.append(color)
  elif point <= 1999:
    color = "blue"
    if color not in colors:
      colors.append(color)
  elif point <= 2399:
    color = "yellow"
    if color not in colors:
      colors.append(color)
  elif point <= 2799:
    color = "orange"
    if color not in colors:
      colors.append(color)
  elif point <= 3199:
    color = "red"
    if color not in colors:
      colors.append(color)
  elif point > 3199:
    another += 1
    
ans = len(colors)
if ans == 0:
  print(1,another)
else:
  print(ans,ans + another)

### FIXED CODE ###

#レート
#1-399：灰色
#400-799：茶色
#800-1199：緑色
#1200-1599：水色
#1600-1999：青色
#2000-2399：黄色 
#2400-2799：橙色
#2800-3199：赤色

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

colors = []
color = ""
another = 0

for point in scores:
  if point <= 399:
    color = "gray"
    if color not in colors:
      colors.append(color)
  elif point <= 799:
    color = "brown"
    if color not in colors:
      colors.append(color)
  elif point <= 1199:
    color = "green"
    if color not in colors:
      colors.append(color)
  elif point <= 1599:
    color = "sky"
    if color not in colors:
      colors.append(color)
  elif point <= 1999:
    color = "blue"
    if color not in colors:
      colors.append(color)
  elif point <= 2399:
    color = "yellow"
    if color not in colors:
      colors.append(color)
  elif point <= 2799:
    color = "orange"
    if color not in colors:
      colors.append(color)
  elif point <= 3199:
    color = "red"
    if color not in colors:
      colors.append(color)
  elif point > 3199:
    another += 1
    
ans = len(colors)
if ans == 0:
  print(1,another)
else:
  print(ans,ans + another)
N,M = map(int, input().split())
hune = sorted([list(map(int, input().split())) for _ in range(M)], key=lambda x:x[0])

for a,b in hune:
    if a == 1:
        for c,d in hune:
            if c == b and d == N:
                print('Yes')
                return
    if a == 2:
        break
print('No')

### FIXED CODE ###

from collections import defaultdict


def check():
    N,M = map(int, input().split())
    B = []
    hune = defaultdict(list)
    for _ in range(M):
        a,b = map(int, input().split())
        if a == 1:
            B.append(b)
        hune[a].append(b)
    
    for b in B:
        for goal in hune[b]:
            if goal == N:
                print('POSSIBLE')
                return
    print('IMPOSSIBLE ')
    
check()
from operator import itemgetter, attrgetter

h,n = map(int,input().split())
ls = []

for _ in range(n):
  a,b =  map(int,input().split())
  ls.append(a,b)

ls = sorted(ls,key = lambda x: min(x[0],h)/x[1], reverse = True)
ans = 0

t = ls[0]
ans += h//t
h %= t

while h>0:
  ls = sorted(ls,key = lambda x: min(x[0],h)/x[1], reverse = True)
  t = ls[0]
  ans += h//t
  h %= t
print(ans)






### FIXED CODE ###

n,m=map(int, input().split())
s=[list(map(int, input().split())) for i in range(m)]
x=max(a for a,b in s)
dp=[0]*(n+x)
for i in range(0,n+x):
  if i>0:
    dp[i]=min(dp[i-a]+b for a,b in s)
print(min(dp[n:]))
def gcd(*args):
    a, *args = args
    if len(args) == 0:
        return a
    elif len(args) > 1:
        return gcd(a, gcd(*args))
    else:
        b = args[0]
        if a < b:
            a, b = b, a
        while b != 0:
            a, b = b, a % b
        return a


n, x = map(int, input().split())
c = [abs(x - xn) for xn in map(int, input().split())]
print(gcd(*c))


### FIXED CODE ###

from functools import reduce

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

def gcd_from_list(vals):
    return reduce(gcd, vals)

n, x = map(int, input().split())
c = [abs(x - xn) for xn in map(int, input().split())]
print(gcd_from_list(c))
def merge(A,left,mid,right):
    global cnt
    L = A[left:mid]
    R = A[mid:right]
    L.append(float("inf"))
    R.append(float("inf"))
    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if L[i] <=R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


def mergeSort(A,left,right):
        if left+1 < right:
            mid = (left+right) // 2
            mergeSort(A,left,mid)
            mergeSort(A,mid,right)
            merge(A,left,mid,right)

n = input()
S = list(map(int,input(),split()))
cnt=0

mergeSort(S,0,n)

print(" ".join(map(str,S)))
print(cnt)

### FIXED CODE ###

def merge(A,left,mid,right):
    global cnt
    L = A[left:mid]
    R = A[mid:right]
    L.append(float("inf"))
    R.append(float("inf"))
    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if L[i] <=R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


def mergeSort(A,left,right):
        if left+1 < right:
            mid = (left+right) // 2
            mergeSort(A,left,mid)
            mergeSort(A,mid,right)
            merge(A,left,mid,right)

n = int(input())
S = list(map(int,input().split()))
cnt=0

mergeSort(S,0,n)

print(" ".join(map(str,S)))
print(cnt)
s=input()
while(1):
  s=s[:-2]
  l=len(s)
  if s[:l/2]==s[l/2:]:
  	print(l)
    break


### FIXED CODE ###

s=input()
while 1:
  s=s[:-2]
  l=len(s)
  if s[:l//2]==s[l//2:]:
    print(l)
    break
N, K = input().split()
if N%K == 0:
    print(0)
else :
    print(1)

### FIXED CODE ###

N, K = input().split()
N=int(N)
K=int(K)
if K==0:
    print("ZeroDivisionError!!")
elif N % K ==0:
    print(0)
else :
    print(1)
a,b =map(int,input())
print((b-1)//(a-1))


### FIXED CODE ###

a,b =map(int,input().split())
print(-((1-b)//(a-1)))
import bisect

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

x_negative = x[:bisect.bisect_left(x,0)]
x_positive = x[bisect.bisect_left(x,0):]

# 地点0にロウソクがある場合
if x_positive[0] == 0:
    if K == 1:
        print(0)
        exit()
    K -= 1
    del x_positive[0]

t_list = []

# 全くターンしない場合
if len(x_negative) >= K:
    t_list.append(x_negative[-K])
if len(x_positive) >= K:
    t_list.append(x_positive[K-1])

# 1回だけターンする場合
for i in range(1, K-1):
    t_list.append(2*abs(x_negative[-i]) + x_positive[K-i-1])
    t_list.append(2*x_positive[i-1] + abs(x_negative[-(K-i)]))

print(min(t_list))

### FIXED CODE ###

import bisect

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

x_negative = x[:bisect.bisect_left(x,0)]
x_positive = x[bisect.bisect_left(x,0):]

# 0以上の地点にロウソクが無い場合
if len(x_positive) == 0:
    print(abs(x_negative[-K]))
    exit()

# 地点0にロウソクがある場合
if x_positive[0] == 0:
    if K == 1:
        print(0)
        exit()
    K -= 1
    del x_positive[0]

t_list = []

# 全くターンしない場合
if len(x_negative) >= K:
    t_list.append(abs(x_negative[-K]))
if len(x_positive) >= K:
    t_list.append(x_positive[K-1])

# 1回だけターンする場合
for i in range(1, K-1):
    try:
        t_list.append(2*abs(x_negative[-i]) + x_positive[K-i-1])
    except IndexError:
        pass
    
for i in range(1, K-1):
    try:
        t_list.append(2*x_positive[i-1] + abs(x_negative[-(K-i)]))
    except IndexError:
        pass

print(min(t_list))
from heapq import heappush, heappop
from collections import defaultdict

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

q = []
for _ in range(N):
    t, d = map(int, input().split())
    heappush(q, (-d, t))

now_used = []
not_used = []

c = 0
su = 0
kn = set()
while q and c<K:
    d, t = heappop(q)
    if not t in kn:
        kn.add(t)
        heappush(now_used, (-d, t))
        su -= d
        c += 1
    else:
        heappush(not_used, (d, t))

used = len(now_used)
for _ in range(K-used):
    d, t = heappop(not_used)
    su -= d
    heappush(now_used, (-d, t))

ans = su+c*c

while not_used:
    a, grp = heappop(now_used)
    su -= a
    kn.remove(grp)
    a, grp = heappop(not_used)
    kn.add(grp)
    su -= a
    c = len(kn)
    ans = max(ans, su+c*c)
print(ans)

### FIXED CODE ###

from collections import defaultdict as dd
import heapq

n,k=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
l.sort(key=lambda x:-x[1])

sushi_types = set()
sushies = []
v=0

for i in range(k):
    t,d=l[i]
    v+=d
    if t in sushi_types:
        heapq.heappush(sushies,d)
    else:
        sushi_types.add(t)

remaining_sushi=dd(list)
for i in range(k,n):
    t,d=l[i]
    if not t in sushi_types:
        heapq.heappush(remaining_sushi[t],-d)

eat_candidate_sushi = []
for i in remaining_sushi.keys():
    if not i in sushi_types:
        heapq.heappush(eat_candidate_sushi,remaining_sushi[i][0])

sushi_kinds=len(sushi_types)
val=v
ans=v+sushi_kinds**2

for i in range(sushi_kinds+1,k+1):
    if sushies and eat_candidate_sushi:
        v-=heapq.heappop(sushies)
        v-=heapq.heappop(eat_candidate_sushi)
        ans=max(ans,v+i**2)
    else:
        break

print(ans)