Harryxun/stf_run huggingface dataset:
n,k=map(int,input().split())
d=list(map(int,input().split()))
d=d*2
ans=0
for i in range(k):
  
  for j in range(i+1):
    have=[d[n+c-j] for c in range(i)] #ここにi個の宝石を入れる
    have.sort()
    for h in range(k-i):
      if have[0]>=0:
        break
      del have[0]
    #いらない宝石を可能な限り詰めた状態
    if sum(have)>ans:
      ans=sum(have)
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
d=list(map(int,input().split()))
d=d*2
ans=0
for i in range(1,min(k+1,n+1)):
  
  for j in range(i+1):
    have=[d[n+c-j] for c in range(i)] #ここにi個の宝石を入れる
    have.sort()
    if i!=k:
      for h in range(k-i):
        if have==[] or have[0]>=0:
          break
        del have[0]
      #いらない宝石を可能な限り詰めた状態
    if sum(have)>ans:
      ans=sum(have)
print(ans)
x=input()
y=input()
z=input()
if (x*y*z=5*5*7):
    print('true')
else:
    print('False')

### FIXED CODE ###

x,y,z=input().split()
if (float(x)*float(y)*float(z)==175):
    print('YES')
else:
    print('NO')
a, b, t = list(map(int, imput().split()))
print(sum([b for _ in range(a, t+1, a)]))

### FIXED CODE ###

a, b, t = list(map(int, input().split()))
print(sum([b for _ in range(a, t+1, a)]))
import math

r = int(input())
s = math.pai * r ** 2
l = 4 * math.pai * r ** 3 / 3
print(s, l)



### FIXED CODE ###

pai = 3.141592653589793

r = float(input())
s = pai * r ** 2
l = 2 * pai * r
print(s, l)
import sys
import numpy as np
from numba import njit


@njit('i8(i8,i8[:],i8[:,:])')
def main(N, S, dp):
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            dp[i][j] = min(j - i, dp[i - 1][j - 1] + 1) if S[i] == S[j] else 0
        ans = max(ans, max(dp[i]))
    return ans


if sys.argv[-1] == 'ONLINE_JUDGE' and 0:
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc.export('main', 'i8(i8,i8[:])')
    cc.compile()

from my_module import main

N = int(input())
S = np.array([ord(_) for _ in input()])
dp = np.zeros((N + 1, N + 1), dtype=int)
print(main(N, S, dp))


### FIXED CODE ###

import itertools
N = int(input())
S = input()
dp = [[0] * N for _ in range(N)]
ans = 0
for i, j in itertools.combinations(range(N), 2):
    if S[i] == S[j]:
        dp[i][j] = dp[i - 1][j - 1] + 1
    else:
        dp[i][j] = 0
    ans = max(ans, min(j - i, dp[i][j]))
print(ans)
import sys
n,y = map(int, input().split())

for a in range(n+1):
	for b in range(n+1-a):
	  if (a * 10000 + b * 5000 + (n-a-b) * 1000 == y):
		print(str(a) + ' ' + str(b) + ' ' + str(c))
		sys.exit()

print('-1 -1 -1')

### FIXED CODE ###

import sys

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

for a in range(n+1):
	for b in range(n+1-a):
		c = n - a - b
		if (a * 10000 + b * 5000 + c * 1000 == y):
				print(str(a) + ' ' + str(b) + ' ' + str(c))
				sys.exit()
	
print('-1 -1 -1')
sys.exit()
from bisect import bisect_right

A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]

for x in X:
    # Shrine -> Temple
    idx_s = bisect_right(S, x)
    if abs(S[min(A - 1, idx_s)] - x) > abs(S[max(0, idx_s - 1)] - x):
        x_s = S[max(0, idx_s - 1)]
    else:
        x_s = S[min(A - 1, idx_s)]

    idx_t = bisect_right(T, x_s)
    if abs(T[min(A - 1, idx_t)] - x_s) > abs(T[max(0, idx_t - 1)] - x_s):
        x_t = T[max(0, idx_t - 1)]
    else:
        x_t = T[min(A - 1, idx_t)]

    cand_0 = abs(x_s - x) + abs(x_t - x_s)

    # Temple -> Shrine
    idx_t = bisect_right(T, x)
    if abs(T[min(A - 1, idx_t)] - x) > abs(T[max(0, idx_t - 1)] - x):
        x_t = T[max(0, idx_t - 1)]
    else:
        x_t = T[min(A - 1, idx_t)]

    idx_s = bisect_right(S, x_t)
    if abs(S[min(A - 1, idx_s)] - x_t) > abs(S[max(0, idx_s - 1)] - x_t):
        x_s = S[max(0, idx_s - 1)]
    else:
        x_s = S[min(A - 1, idx_s)]

    cand_1 = abs(x_t - x) + abs(x_s - x_t)

    print(min(cand_0, cand_1))


### FIXED CODE ###

from bisect import bisect_right

A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]

INF = 10 ** 18
s = [-INF] + s + [INF]
t = [-INF] + t + [INF]

for i in range(Q):
    b = bisect_right(s, x[i])
    d = bisect_right(t, x[i])
    res = INF
    for n in [s[b - 1], s[b]]:
        for m in [t[d - 1], t[d]]:
            d1 = abs(n - x[i]) + abs(m - n)
            d2 = abs(m - x[i]) + abs(n - m)
            res = min(res, d1, d2)
    print(res)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def calc_coord(theta, length):
    # 第一象限
    if 0 <= theta <= 90:
        rad1 = round(math.radians(90-theta), 11)
        min_x = length * round(math.cos(rad1), 11)
        min_y = length * round(math.sin(rad1), 11)
    elif 90 < theta <= 180:
        rad1 = round( math.radians(90 - theta), 11)
        min_x = round(length * math.cos(rad1),11)
        min_y = round(length * math.sin(rad1),11)
    elif 180 < theta <= 270:
        rad2 = round(math.radians(450-theta),11)
        min_x = round(length * math.cos(rad2),11)
        min_y = round(length * math.sin(rad2),11)
    elif 270 < theta <= 359:
        rad2 = round(math.radians(450 - theta),11)
        min_x = round(length * math.cos(rad2),11)
        min_y = round(length * math.sin(rad2),11)

    return min_x, min_y


def resolve():
    a, b, h, m = map(int, input().split())

    # 時刻を角度に変換
    min_theta = 6.0 * m
    hour_theta = 30 * h + 0.5 * m

    min_x, min_y = calc_coord(min_theta, b)
    hour_x, hour_y = calc_coord(hour_theta, a)

    ans = math.sqrt((min_x - hour_x) ** 2 + (min_y - hour_y) ** 2)

    print(ans)

if __name__ == "__main__":
    resolve()



### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def calc_coord(theta, length):
    # 第一象限
    if 0 <= theta <= 90:
        rad1 = round(math.radians(90-theta), 11)
        min_x = length * round(math.cos(rad1), 11)
        min_y = length * round(math.sin(rad1), 11)
    elif 90 < theta <= 180:
        rad1 = round( math.radians(90 - theta), 11)
        min_x = round(length * math.cos(rad1),11)
        min_y = round(length * math.sin(rad1),11)
    elif 180 < theta <= 270:
        rad2 = round(math.radians(450-theta),11)
        min_x = round(length * math.cos(rad2),11)
        min_y = round(length * math.sin(rad2),11)
    elif 270 < theta <= 360:
        rad2 = round(math.radians(450 - theta),11)
        min_x = round(length * math.cos(rad2),11)
        min_y = round(length * math.sin(rad2),11)

    return min_x, min_y


def resolve():
    a, b, h, m = map(int, input().split())

    # 時刻を角度に変換
    min_theta = 6.0 * m
    hour_theta = 30 * h + 0.5 * m

    min_x, min_y = calc_coord(min_theta, b)
    hour_x, hour_y = calc_coord(hour_theta, a)

    ans = math.sqrt((min_x - hour_x) ** 2 + (min_y - hour_y) ** 2)

    print(ans)

if __name__ == "__main__":
    resolve()
n = int(input())

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

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

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

m = n-1
sumc = 0
for i in range(m):
    if a[i+1] == a[i]+1:
        sumc += c[i]
#tmp = a[m]
#if m > 1:
#    if tmp <= m:
#        sumc -= c[tmp-1]
if m == 1:
    if tmp == 1:
        sumc = 0
ans = sum(b)
ans += sumc

print(ans)


### FIXED CODE ###


n = int(input())

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

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

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

m = n-1
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if (i>0)and(a[i] == a[i-1]+1):
        ans += c[a[i-1]-1]

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

grid = [[str(i) for i in input()]for _ in range(a)]
dxdy = [[1, 0], [0, 1], [-1, 0], [0, -1]]

for i in range(b):
    for j in range(a):
        if grid[i][j]=="#":
            f = False
            for d in dxdy:
                if(i+d[0]>-1 and j+d[1]>-1 and i+d[0]<b and j+d[1]<a):
                    if grid[i+d[0]][j+d[1]]=="#":
                        f = True
                        continue
            if f==False:
                print("No")
                exit()


print("Yes")


### FIXED CODE ###

h,w = map(int, input().split())

grid = [[str(i) for i in input()]for _ in range(h)]
dxdy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
for i in range(h):
    for j in range(w):
        if grid[i][j]=="#":
            f = False
            for d in dxdy:
                if(i+d[0]>-1 and j+d[1]>-1 and j+d[1]<w and i+d[0]<h):
                    if grid[i+d[0]][j+d[1]]=="#":
                        f = True
                        continue
            if f==False:
                print("No")
                exit()
print("Yes")
import math
def c(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
 
n,k=map(int,input().split())
mod=10**9+7
 
for i in range(K):
    if n-k<i:
        print(0)
    else:
        print(c(k-1,i)*c(n-k+1,i+1)%mod)

### FIXED CODE ###

import math
def c(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
 
n,k=map(int,input().split())
mod=10**9+7
 
for i in range(k):
    if n-k<i:
        print(0)
    else:
        print(c(k-1,i)*c(n-k+1,i+1)%mod)
I,*U=N,*D=9**9,
P,*L='x+y,',
M,*R='x-y,',
for t in[*open(n:=0)][1:]:*z,u=t.split();exec(u+'+=[*map(int,z)],')
for*A,S in(D,U,'x,y,'),(L,R,'y,x,'),(U,R,P+M),(L,U,M+P),(L,D,P+M),(D,R,M+P):
 for x,y,r in eval('sorted((%sQ)for Q,P in enumerate(A)for x,y in P)'%S):
  if r:n,p=x,y
  elif x==n:N=min(N,y-p)
print(N%I*5or'SAFE')

### FIXED CODE ###

d=[[],[],[],[]]
for t in[*open(0)][1:]:*z,u=t.split();d[ord(u)%5]+=[*map(int,z)],
I=N=9**9
P,M='x+y,','x-y,'
for*A,S in(3,0,'x,y,'),(1,2,'y,x,'),(0,2,P+M),(1,3,P+M),(1,0,M+P),(3,2,M+P):
 n=p=-I
 for x,y,r in eval('sorted((%sQ)for Q,P in enumerate(A)for x,y in d[P])'%S):
  if r:n,p=x,y
  elif x==n:N=min(N,y-p)
print(N%I*5or'SAFE')
a, b = map(int, raw???input().split())

if a<b :
   print a<b
elif a>b :
   print a>b
elif a = b :
   print a==b

### FIXED CODE ###

a, b = map(int, raw_input().split())
  
if a>b:
  print 'a > b'
elif a<b:
  print 'a < b'
elif a==b:
  print 'a == b'
import math

x = int(input())
g = math.gdc(x,360)
print(360//g)


### FIXED CODE ###

import math

x = int(input())
g = math.gcd(x,360)
print(360//g)
# -*- coding: utf-8 -*-
from itertools import combinations

def inpl(): return tuple(map(int, input().split()))

N = int(input())
res = 0
exist = True
A = []

for _ in range(N):
    A.append(inpl())

for i, j in combinations(range(N), 2):
    vervose = False

    for k in range(N):
        if A[i][j] > A[i][k] + A[k][j]:
            exist = False
            break
    
    if not exist:
        break
    
    for k in range(N):
        if i == k or j == k:
            pass
        elif A[i][j] == A[i][k] + A[k][j]:
            vervose = True
            break
        
    if not vervose:
        res += A[i][j]
if exist:
    print(res)
else:
    print(-1)


### FIXED CODE ###

# -*- coding: utf-8 -*-
A, B, C, D, E, F = tuple(map(int, input().split()))
A, B = 100*A, 100*B
waters = set([a+b for b in range(0, F+1, B) for a in range(0, F+1, A) if a+b <= F])

res_water = min(A, B)
res_sugar = 0
max_ratio = 0

for w in sorted(waters):
    sugars = [c+d for c in range(0, int(w//100)*E+1, C)
                         for d in range(0, int(w//100)*E+1, D) 
                             if (c+d+w <= F) and (c+d <= int(w/100)*E)]
    sugar = max(sugars)
    #print(sugars)
    if w+sugar==0:
        continue
    if 100*sugar / (w+sugar) > max_ratio:
        max_ratio = 100*sugar / (w+sugar)
        res_water = w
        res_sugar = sugar
print("{} {}".format(res_water+res_sugar, res_sugar))
a,b=map(int,input().split())
print(max(2*a-1,a+b,2*b-1)

### FIXED CODE ###

a,b=map(int,input().split())
print(max(2*a-1,a+b,2*b-1))
n = input()
print(n**3)

### FIXED CODE ###

n = input()
print(n**3)
k,x=int(input())
print(*[i for i in range(x-k+1,x+k)])

### FIXED CODE ###

k, x = map(int, input().split())
print(*list(range(x-k+1, x+k)))
x=[]
y=[]
for i in range(10**5//2+1):
	x.append([i,0])
	y.append([i,0])
n=int(input())
a=list(map(int,input().split()))
for i in range(n//2):
	x[a[i*2]][1]+=1
	y[a[i*2+1]][1]+=1
x.sort(key=lambda x:-x[1])
y.sort(key=lambda x:-x[1])
# if x[0][0]!=y[0][0]:
# 	print(n-x[0][1]-y[0][1])
# else:
# 	print(n-max(x[0][1]+y[1][1],
# 		x[1][1]+y[0][1]))
print(1)

### FIXED CODE ###

x=[]
y=[]
n=int(input())
a=list(map(int,input().split()))
for i in range(10**5+1):
	x.append([i,0])
	y.append([i,0])
for i in range(n//2):
	x[a[i*2]][1]+=1
	y[a[i*2+1]][1]+=1
x.sort(key=lambda x:-x[1])
y.sort(key=lambda x:-x[1])
if x[0][0]!=y[0][0]:
	print(n-x[0][1]-y[0][1])
else:
	print(n-max(x[0][1]+y[1][1],
		x[1][1]+y[0][1]))
pi = 3.141592
r = int(input())
S = pi * r * r
R = 2 * pi * r
print("{0} {1}".format(S, R))

### FIXED CODE ###

from math import pi
r = float(input())
S = pi * r * r
R = 2 * pi * r
print("{0} {1}".format(S, R))
sys.setrecursionlimit(10**7)

MOD=10**9+7

N,K=map(int,input().split())
g=[[] for _ in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)

MAX=10**6
fc=[1]*MAX
inv=[1]*MAX
ifc=[1]*MAX

for i in range(2,MAX):
    fc[i]=i*fc[i-1]%MOD
    inv[i]=MOD-(MOD//i)*inv[MOD%i]%MOD
    ifc[i]=inv[i]*ifc[i-1]%MOD

def comb(n,k):
    if n<0 or k<0 or n-k<0:
        return 0
    return fc[n]*ifc[n-k]%MOD*ifc[k]%MOD

def dfs(cur,par):
    ret=1
    ch=len(g[cur])
    if par!=-1:
        ch-=1
    
    if par==-1:
        ret=comb(K-1,ch)*fc[ch]%MOD
    else:
        ret=comb(K-2,ch)*fc[ch]%MOD
        
        
    for dst in g[cur]:
        if dst==par:
            continue
        ret=ret*dfs(dst,cur)%MOD
    return ret

ans=K*dfs(0,-1)%MOD
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

MOD=10**9+7

N,K=map(int,input().split())
g=[[] for _ in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)

MAX=10**6
fc=[1]*MAX
inv=[1]*MAX
ifc=[1]*MAX

for i in range(2,MAX):
    fc[i]=i*fc[i-1]%MOD
    inv[i]=MOD-(MOD//i)*inv[MOD%i]%MOD
    ifc[i]=inv[i]*ifc[i-1]%MOD

def comb(n,k):
    if n<0 or k<0 or n-k<0:
        return 0
    return fc[n]*ifc[n-k]%MOD*ifc[k]%MOD

def dfs(cur,par):
    ret=1
    ch=len(g[cur])
    if par!=-1:
        ch-=1
    
    if par==-1:
        ret=comb(K-1,ch)*fc[ch]%MOD
    else:
        ret=comb(K-2,ch)*fc[ch]%MOD
        
        
    for dst in g[cur]:
        if dst==par:
            continue
        ret=ret*dfs(dst,cur)%MOD
    return ret

ans=K*dfs(0,-1)%MOD
print(ans)
N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]


print(int(result%(N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]

print(int(result/(10**9+7)))


### FIXED CODE ###

def solve():
    N, K, *a_l = map(int, open(0).read().split())
    MOD = 10**9+7
    count_a, count_b = 0, 0
    inversion = 0

    for i in range(N):
        for j in range(N):
            if a_l[i] > a_l[j]:
                if i < j:
                    count_a += 1
                count_b += 1

    inversion = count_a * K + count_b * (K * (K - 1)) // 2
    print(inversion%MOD)



if __name__ == '__main__':
    solve()
import numpy as np
L=int(input())

if L==1:
    res1=0
    x = np.arange(0.1, 10.1, 0.1)
    for i in x:
        for j in x:
            res1=max(res1,i*j*(L-i-j))
else:
    res=0
    for i in range(1,1001):
        for j in range(1,1001):
            res=max(res,i*j*(L-i-j))
print(res if res!=0 else res1)

### FIXED CODE ###

L=int(input())
import math
l=L/3
print(l**3)
h,w = map(int, raw_input().split(' '))
def f(h,w):
	x = w - w/2
	y = w/2
	count = 0
	count += (h - h/2) * x
	count += (h/2) * y
	return count
		


print f(h,wa)

### FIXED CODE ###

h,w = map(int, raw_input().split(' '))
def f(h,w):
	if h == 1 or w == 1:
		return 1
	x = w - w/2
	y = w/2
	count = 0
	count += (h - (h/2)) * x
	count += ((h/2)) * y
	return count
		


print f(h,w)
import math

while True :

x = int(input()) 

  if x == 0 :
    break 

  else :
    sum = 0 
    n=floor(log(x,10))
    sum = floor(x/pow(10,n))
    for i in reversed(range(n+1))
      sum = sum + floor((x%pow(10,i))/pow(10,i-1))

  print(sum)
      

  

### FIXED CODE ###

while True :
  x = input()
  if x == '0' :
    break 

  else:
   sum = 0 
   for i  in range(len(x)) :  
    sum += int(x[i])

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

m,p = [],[]
m_total = 0
p_total = 0
p_max,p_min = 0,10**10
c,p_min_idx,p_max_idx = 0,0,0
for a in A:
    if a < 0:
        m_total += a
        m.append(a)
    else:
        if p_min > a:
            p_min = a
            p_min_idx = c
        if p_max < a:
            p_max = a
            p_max_idx = c
        p_total += a
        p.append(a)
        c += 1

if len(m) > 0:
    print(p_total-m_total)
    for i,v in enumerate(p):
        if i != p_max_idx:
            print(m[0], v)
            m[0] -= v
    for i in range(len(m)):
        print(p[p_max_idx],m[i])
        p[p_max_idx] -= m[i]
else:
    print(p_total-2*p_min)
    for i in range(len(p)-1):
        if i != p_min_idx:
            print(p[p_min_idx],p[i])
            p[p_min_idx] -= p[i]
    print(p[-1],p[p_min_idx])

### FIXED CODE ###

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

p,m = [],[]
p_total = 0
m_total = 0
p_max,p_min = 0,10**10
m_max,m_min = -10**10,0
p_count,p_min_idx,p_max_idx = 0,0,0
m_count,m_min_idx,m_max_idx = 0,0,0
for a in A:
    if a < 0:
        if m_min > a:
            m_min = a
            m_min_idx = m_count
        if m_max < a:
            m_max = a
            m_max_idx = m_count
        m_total += a
        m.append(a)
        m_count += 1
    else:
        if p_min > a:
            p_min = a
            p_min_idx = p_count
        if p_max < a:
            p_max = a
            p_max_idx = p_count
        p_total += a
        p.append(a)
        p_count += 1

if len(m) == 0:
    print(p_total-2*p_min)
    for i in range(len(p)-1):
        if i != p_min_idx:
            print(p[p_min_idx],p[i])
            p[p_min_idx] -= p[i]
    print(p[-1],p[p_min_idx])

elif len(p) == 0:
    print(2*m_max-m_total)
    for i in range(len(m)-1):
        if i != m_max_idx:
            print(m[m_max_idx],m[i])
            m[m_max_idx] -= m[i]
    print(m[m_max_idx],m[-1])

else:
    print(p_total-m_total)
    for i,v in enumerate(p):
        if i != p_max_idx:
            print(m[0], v)
            m[0] -= v
    for i in range(len(m)):
        print(p[p_max_idx],m[i])
        p[p_max_idx] -= m[i]
import sys
sys.setrecursionlimit(10**8)

n = int(input())
x = list(input())
bit_cnt = x.count('1')

# bitを一つ増やす場合
pos = [0] * n
pos_total = 0

# bitを一つ減らす場合
neg = [0] * n
neg_total = 0

base = 1
for i in range(n):
    pos[i] = base%(bit_cnt+1)
    if x[n-i-1] == '1':
        # 同時にmod(bit_cnt+1)の法でトータルを作成
        pos_total = (pos_total + base) % (bit_cnt+1)
    base = (base*2) % (bit_cnt+1)
pos = pos[::-1]

base = 1
for i in range(n):
    neg[i] = base%(bit_cnt-1)
    if x[n-i-1] == '1':
        # 同時にmod(bit_cnt-1)の法でトータルを作成
        neg_total = (neg_total + base) % (bit_cnt-1)
    base = (base*2) % (bit_cnt-1)
neg = neg[::-1]

def popcount(n):
    s = list(bin(n)[2:])
    return s.count('1')

memo = {}
memo[0] = 0
def dfs(n, depth=0):
    if n in memo:
        return depth + memo[n]
    else:
        ret = dfs(n%popcount(n), depth+1)
        # memo[n] = ret
        return ret

ans = []
for i in range(n):
    if x[i] == '0':
        st = (pos_total + pos[i]) % (bit_cnt+1)
        print(dfs(st, depth=1))
    elif bit_cnt == 1:
        # コーナーケース：すべてのbitが0となる
        print(0)
    else:
        st = (neg_total - neg[i]) % (bit_cnt-1)
        print(dfs(st, depth=1))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

n = int(input())
x = list(input())
bit_cnt = x.count('1')

# bitを一つ増やす場合
pos = [0] * n
pos_total = 0

# bitを一つ減らす場合
neg = [0] * n
neg_total = 0

base = 1
for i in range(n):
    pos[-i-1] = base%(bit_cnt+1)
    if x[-i-1] == '1':
        # 同時にmod(bit_cnt+1)の法でトータルを作成
        pos_total = (pos_total + base) % (bit_cnt+1)
    base = (base*2) % (bit_cnt+1)

base = 1
if bit_cnt == 1:
    # mod取れない
    pass
else:
    for i in range(n):
        neg[-i-1] = base%(bit_cnt-1)
        if x[-i-1] == '1':
            # 同時にmod(bit_cnt-1)の法でトータルを作成
            neg_total = (neg_total + base) % (bit_cnt-1)
        base = (base*2) % (bit_cnt-1)

def popcount(n):
    s = list(bin(n)[2:])
    return s.count('1')

memo = {}
memo[0] = 0
def dfs(n, depth=0):
    if n in memo:
        return depth + memo[n]
    else:
        ret = dfs(n%popcount(n), depth+1)
        # memo[n] = ret
        return ret

ans = []
for i in range(n):
    if x[i] == '0':
        st = (pos_total + pos[i]) % (bit_cnt+1)
        print(dfs(st, depth=1))
    elif bit_cnt == 1:
        # コーナーケース：すべてのbitが0となる
        print(0)
    else:
        st = (neg_total - neg[i]) % (bit_cnt-1)
        print(dfs(st, depth=1))
a = input()
s = 0
for i in range(int(a[0]+a[2]+a[3])+1):
    if int(a[0]+a[2]+a[3]) == i**2:
        s += 1
        break
if s == 1:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

a = list(map(int,input().split()))
s = int(str(a[0]) + str(a[1]))
for i in range(s):
    if s == i**2:
        print("Yes")
        exit()
print("No")
import math
N, W = map(int, input().split())
A = list()
for n in range(N):
	A.append(list(map(int, input().split())))
g = math.gcd(W, A[0][0]) 
for a in range(1, N):
	g = math.gcd(g, A[a][0])
W = W//g 
# print(g)
dp = [[0 for w in range(W+1)] for n in range(N+1)]
for i in range(W+1):
	dp[0][i] = 0
for p in range(1, N+1):
	for q in range(W+1):
		dp[p][q] = dp[p-1][q]
		if (A[p-1][0]//g <= q):
			dp[p][q] = max(dp[p][q], dp[p-1][q - (A[p-1][0]//g)] + A[p-1][1])
# print(dp)
print(dp[N][W])

### FIXED CODE ###

N, W = map(int, input().split())
A = list()
for n in range(N):
	A.append(list(map(int, input().split())))
inf = 10**10
V = 0
for a in range(N):
	V += A[a][1]
dp = [inf for v in range(V+1)]
dp[0] = 0
for p in range(N):
	for q in range(V - A[p][1], -1, -1):
		dp[q + A[p][1]] = min(dp[q + A[p][1]], dp[q] + A[p][0])
# print(dp)
ans = 0
for b in range(V+1):
	if (dp[b] <= W):
		ans = b
print(ans)
S0 = input().strip()
S1 = input().strip()
ok = "No"
for i in range(len(S0)):
  if S0 == Si[i:] + S1[:i]:
    ok = "Yes"
print(ok)

### FIXED CODE ###

S0 = input().strip()
S1 = input().strip()
ok = "No"
for i in range(len(S0)):
  if S0 == S1[i:] + S1[:i]:
    ok = "Yes"
print(ok)
S = input()
N = int(input())

T = S[0:N / 2 - 1]

if (T + T in s):
 print('Yes')
  
else:
 print('No')


### FIXED CODE ###

N = int(input())
S = str(input())

T = S[0:int(N) // 2]
W = S[int(N) // 2:int(N) + 1] 

if T == W:
	print('Yes')
else:
	print('No')