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

#A
from collections import deque
inf = float("inf")
H,W = map(int,input().split())
A = [list(str(input())) for h in range(H)]

C = [[inf for w in range(W)] for h in range(H)]


start = deque([])
for h in range(H):
    for w in range(W):
        if A[h][w] == "#":
            start.append([h,w])
            C[h][w] = 0
            
while start:
    h,w = start.popleft()
    c_old = C[h][w]
    if h > 0:
        c_new = C[h-1][w]
        
        if c_new == inf:
            C[h-1][w] = c_old+1
            start.append([h-1,w])
            
    if w > 0:
        c_new = C[h][w-1]
        
        if c_new == inf:
            C[h][w-1] = c_old+1
            start.append([h,w-1])
            
    if w < W-1:
        c_new = C[h][w+1]
        
        if c_new == inf:
            C[h][w+1] = c_old+1
            start.append([h,w+1])
            
    if h < H-1:
        c_new = C[h+1][w]
        
        if c_new == inf:
            C[h+1][w] = c_old+1
            start.append([h+1,w])
            
            
ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,C[h][w])
        
        
print(ans)        
    




### FIXED CODE ###

#A
from collections import deque
H,W = map(int,input().split())
A = [list(str(input())) for h in range(H)]

C = [[-1 for w in range(W)] for h in range(H)]


start = deque([])
for h in range(H):
    for w in range(W):
        if A[h][w] == "#":
            start.append([h,w])
            C[h][w] = 0
            
while start:
    h,w = start.popleft()
    c_old = C[h][w]
    
    if h > 0:
        c_new = C[h-1][w]
        
        if c_new == -1:
            C[h-1][w] = c_old+1
            start.append([h-1,w])
            
    if w > 0:
        c_new = C[h][w-1]
        
        if c_new == -1:
            C[h][w-1] = c_old+1
            start.append([h,w-1])
            
    if w < W-1:
        c_new = C[h][w+1]
        
        if c_new == -1:
            C[h][w+1] = c_old+1
            start.append([h,w+1])
            
    if h < H-1:
        c_new = C[h+1][w]
        
        if c_new == -1:
            C[h+1][w] = c_old+1
            start.append([h+1,w])
            
            
ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,C[h][w])
        
        
print(ans)
### BUGGY CODE ###

a,b,k=map(int,input().split())
for i in range(k):
    if a>0:
        a=a-1
    elif b>0:
        b=b-1
    else:
        break
print("{0} {1}".format(a,b))

### FIXED CODE ###

a,b,k=map(int,input().split())
k2=0
a2=0
if a>=k:
    k2=a-k
    a=a-k
    print("{0} {1}".format(a,b))
    exit()
else:
    k2=k-a
    a=0
if b>=k2:
    b=b-k2
else:
    b=0
print("{0} {1}".format(a,b))
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
dp = [-1] * N

ans = 0
for i in range(N):
    for j in range(N):
        if A[i] > dp[j]:
            dp[j] = A[i]
            ans = max(ans, j+1)
            break

print(ans)

### FIXED CODE ###

import bisect

N = int(input())
A = [int(input()) for _ in range(N)]
dp = [-1] * N
dp[N-1] = A[0]

ans = 0
for i in range(1, N):
    target_index = bisect.bisect_left(dp, A[i])
    dp[target_index-1] = A[i]

print(N - dp.count(-1))
### BUGGY CODE ###

n = int(input())
s = set()
for i in range(n):
  s = s ^ {input()} 
print(len(s))

### FIXED CODE ###

N=int(input())
s=set()
for i in range(N):s^={input()}
print(len(s))
### BUGGY CODE ###

n, W = map(int, input().split())
w = [0] * n
v = [0] * n
for i in range(n):
    w[i], v[i] = map(int, input().split())

INF = float('inf')
V = max(v)
dp = [[INF for i in range(V * n + 1)] for j in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    for j in range(V * n + 1):
        if v[i] <= j:
            dp[i + 1][j] = min(dp[i][j - v[i]] + w[i], dp[i][j])
        else:
            dp[i + 1][j] = dp[i][j]

ans = 0
for i in range(V * n + 1):
    if dp[n][i] <= W:
        ans = i

print(ans)


### FIXED CODE ###

import numpy as np

n, W = map(int, input().split())
w = [0] * n
v = [0] * n
for i in range(n):
    w[i], v[i] = map(int, input().split())

dp = np.full(10**5 + 1, W + 1, dtype=np.int64)
dp[0] = 0

for i in range(n):
    dp[v[i]:] = np.minimum(dp[: - v[i]] + w[i], dp[v[i]:])

print(np.where(dp <= W)[0][-1])
### BUGGY CODE ###

# coding: utf-8
# Your code here!

# coding: utf-8
# Your code here!
h,w=map(int,input().split())

field=[]
m=[]
INF=10**4

for i in range(h):
    row=list(input())
    field.append(row)
    m.append([INF for i in range(w)])

dx=[1,0,-1,0]
dy=[0,1,0,-1]

for i in range(h):
    for j in range(w):
        if field[i][j]=="#":
            m[i][j]=0
            queue=[]
            queue.append([i,j])
            while len(queue)>0:
                y,x=queue.pop(0)
                for k in range(4):
                    nx=x+dx[k]
                    ny=y+dy[k]
                    if 0<=ny<h and 0<=nx<w:
                        if m[ny][nx]>m[y][x]+1 and field[ny][nx]==".":
                            m[ny][nx]=m[y][x]+1
                            queue.append([ny,nx])

ans=0

for i in range(h):
    ans=max(ans,max(m[i]))

print(ans)

### FIXED CODE ###

h,w=map(int,input().split())
INF=10**10
a=[[INF for i in range(w)] for j in range(h)]
ans=0
for i in range(h):
    s=input()
    for j in range(w):
        if s[j]=="#":
            a[i][j]=0
            
for i in range(h):
    for j in range(w):
        k=a[i][j]+1

        if i!=h-1:
            if k<a[i+1][j]:
                a[i+1][j]=k
        if j!=w-1:
            if k<a[i][j+1]:
                a[i][j+1]=k

for i in range(h):
    for j in range(w):
        k=a[-1-i][-1-j]+1
        if i!=h-1:
            if k<a[-i-2][-j-1]:
                a[-i-2][-j-1]=k

        if j!=w-1:        
            if k<a[-i-1][-j-2]:
                a[-i-1][-j-2]=k

for i in range(h):
    ans=max(ans,max(a[i]))
print(ans)
### BUGGY CODE ###

from collections import defaultdict
import itertools
from  bisect import bisect_left, bisect_right

N=input()

Parts=defaultdict(lambda: 0)

for i in range(1,N+1):
	num_sqrt=int(i**0.5)+2

	for n in range(2,num_sqrt):
		while i%n==0:
			i/=n
			Parts[n]+=1
	else:
		if i!=1:
			Parts[i]+=1

T=[0,2,4,14,24,74]


L=[]
for x in Parts.values():
	bi=bisect_right(T,x)
	L.append( T[:bi] )
	

K=list(itertools.product(*L))	#Kouho

ans=0
for x in K:
	multiple=1
	for v in x:
		multiple*=(v+1)
	if multiple==75:
		ans+=1


print ans

### FIXED CODE ###

import math
from collections import defaultdict

N=input()

C=defaultdict(lambda: 0)

#L=(2,3,5,7)
L=range(2,101)


for i in range(N,0,-1):
	for l in L:
		while i%l==0:
			i/=l
			C[l]+=1

D=defaultdict(lambda: 0)

for x,y in C.items():
	if y>=4:	D[4]+=1
	if y>=2:	D[2]+=1
	if y>=24:D[24]+=1
	if y>=14:D[14]+=1
	if y>=74:D[74]+=1

ans=0

ans+=D[4]*(D[4]-1)/2*(D[2]-2)
ans+=D[24]*(D[2]-1)
ans+=D[14]*(D[4]-1)
ans+=D[74]
print ans
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    ans = 0

    for n in range(1, N+1):
        ans = 0
        for i in range(1, n):
            for j in range(i, n):
                for k in range(j, n):
                    if (i**2 + j ** 2 + k ** 2 + i*j+j*k+k*i == n):
                        tmp = set([i, j, k])
                        if len(tmp) == 3:
                            ans += 6
                        if len(tmp) == 2:
                            ans += 3
                        if len(tmp) == 1:
                            ans += 1
        print(ans)

        # oj t -c "pypy3 main.py"
        # acc s main.py -- --guess-python-interpreter pypy
main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import math
import collections


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    ans = 0
    list_counter = []

    for i in range(1, math.floor(N**(1/2))+1):
        for j in range(i,  math.floor(N**(1/2))+1):
            for k in range(j,  math.floor(N**(1/2))+1):
                n = str(i**2 + j**2 + k**2 + i*j + j*k + k*i)
                tmp = set([i, j, k])

                if len(tmp) == 3:
                    tmp_list = [n]*6
                if len(tmp) == 2:
                    tmp_list = [n]*3
                if len(tmp) == 1:
                    tmp_list = [n]*1
                list_counter.extend(tmp_list)

    counter = collections.Counter(list_counter)
    for n in range(1, N+1):
        print(counter[str(n)])



    # oj t -c "pypy3 main.py"
    # acc s main.py -- --guess-python-interpreter pypy
main()
### BUGGY CODE ###

def abc162d_rgb_triplets():
    n = int(input())
    s = input()
    r_cnt = [0] * n
    g_cnt = [0] * n
    b_cnt = [0] * n
    for i in range(n - 1, -1, -1):
        if i != n - 1:
            r_cnt[i] = r_cnt[i + 1]
            g_cnt[i] = g_cnt[i + 1]
            b_cnt[i] = b_cnt[i + 1]
        if s[i] == 'R':
            r_cnt[i] += 1
        elif s[i] == 'G':
            g_cnt[i] += 1
        else:
            b_cnt[i] += 1

    result = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            if s[i] == s[j]: continue
            total = 0
            if 'R' not in (s[i] + s[j]):
                total = r_cnt[j + 1]
                if j+(j - i) < n and s[j+(j - i)] == 'R':
                    total -= 1
            if 'G' not in (s[i] + s[j]):
                total = g_cnt[j + 1]
                if j + (j - i) < n and s[j + (j - i)] == 'G':
                    total -= 1
            if 'B' not in (s[i] + s[j]):
                total = b_cnt[j + 1]
                if j + (j - i) < n and s[j + (j - i)] == 'B':
                    total -= 1
            result += total
    print(result)
abc162d_rgb_triplets()

### FIXED CODE ###

def abc162d_rgb_triplets():
    n = int(input())
    s = input()
    r_cnt = 0
    g_cnt = 0
    b_cnt = 0
    for i in range(n - 1, -1, -1):
        if s[i] == 'R':
            r_cnt += 1
        elif s[i] == 'G':
            g_cnt += 1
        else:
            b_cnt += 1

    result = r_cnt * g_cnt * b_cnt
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            k = j + (j - i)
            if s[i] == s[j] or k >= n or s[i] == s[k] or s[j] == s[k]: continue
            result -= 1
    print(result)



abc162d_rgb_triplets()
### BUGGY CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
roop_find = [0]
check = [0]
i = 0
count = 0
while a[i]-1 not in roop_find:
    roop_find.append(a[i]-1)
    i = a[i] - 1
    count += 1
b = roop_find.index(a[i]-1)
root = roop_find[b:count+1]

if k < b:
    print(roop_find[k]+1)
else:
    k-=b
    e = k % len(root)
    print(root[e]+1)


### FIXED CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
pos = 0
visit = [0] * n
move = []
loop = []
while visit[pos] != 2:
    if visit[pos] == 0:
        move.append(pos)
    else:
        loop.append(pos)
    visit[pos] += 1
    pos = a[pos] - 1
if len(move) > k:
    print(move[k]+1)
else:
    print(loop[(k-(len(move)-len(loop)))%len(loop)]+1)
### BUGGY CODE ###

N = int(input()) #マスの数
H = list(map(int,input().split())) #各マスの高さ

#リストのソートと添字の紐付け
H_sort = []
for i in range(len(H)):
  	a = [H[i],i]
  	H_sort.append(a)
H_sort.sort(reverse=True)

max_move = 0 #移動距離の最大値
for n in range(0,len(H)):
  move = 0
  i = H_sort[n][1]
  if i <= N-2 and max_move < N-1-i:
    while(i <= N-2 and H[i]>=H[i+1]):
      move += 1
      i += 1
    if max_move <= move:
      max_move = move
print(max_move)


### FIXED CODE ###

N = int(input()) #マスの数
H = list(map(int,input().split())) #各マスの高さ

move  = 0
max_move = 0

for i in range(N-1):
  if H[i] >= H[i+1]:
    move += 1
    if max_move <= move:
      max_move = move
  else:
    move = 0
print(max_move)
### BUGGY CODE ###

n = int(input())
a = [int(x) for x in input().split()]
ans = []
for i in range(1, n+1):
    ans.append(a.index(i)+1)
for i in range(n): print(ans[i])

### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]
ans = [0 for _ in range(n)]
for i, v in enumerate(a):
    ans[v-1] = i+1
for i in ans: print(i)
### BUGGY CODE ###

l = [int(input())]

count = 0
while True:
  if l == []:
    break
  if l[-1] == 1:
    l.pop(-1)
  else:
    temp = l[-1]//2
    l.pop(-1)
    l.append(temp)
    l.append(temp)
  count += 1

print(count)

### FIXED CODE ###

N = int(input())

th = 1

while True:
  if N < th*2:
    break
  else:
    th *= 2

print(th*2-1)
### BUGGY CODE ###

class Union():
  def __init__(me,N):
    me.N = N
    me.up = [-1]*N
    me.down = [ [] for i in range(N) ]
  def union(me,a,b):
    ua = me.up[a] if me.up[a]!=-1 else a
    ub = me.up[b] if me.up[b]!=-1 else b
    if (ua == ub):
      return
    if ( len(me.down[ua]) < len(me.down[ub]) ):
      ub,ua = ua,ub
    for v in me.down[ub]:
      me.up[v] = ua
    me.down[ua].extend( me.down[ub] )
    me.down[ub] = []
    me.up[ub] = ua
    me.down[ua].append( ub )

N,K,L = [ int(it) for it in input().split() ]
uk = Union(N)
for a,b in [ [int(it)-1 for it in input().split()] for i in range(K) ]:
  uk.union(a,b)

ul = Union(N)
for a,b in [ [int(it)-1 for it in input().split()] for i in range(L) ]:
  ul.union(a,b)

for i in range(N):
  if ( uk.up[i] == -1 ):
    uk.down[i].append(i)
    uk.down[i] = set(uk.down[i])
  if ( ul.up[i] == -1 ):
    ul.down[i].append(i)
    ul.down[i] = set(ul.down[i])

li = [-1]*N
for i in range(N):
  if (li[i] != -1):
    continue
  ua = uk.up[i] if uk.up[i]!=-1 else i
  ub = ul.up[i] if ul.up[i]!=-1 else i
  uni = uk.down[ua] & ul.down[ub]
  for it in uni:
    li[i] = len(uni)

print ( " ".join( [ str(it) for it in li ]) )
    
    

### FIXED CODE ###

class Union():
  def __init__(me,N):
    me.N = N
    me.up = [-1]*N
    me.down = [ [] for i in range(N) ]
  def union(me,a,b):
    ua = me.up[a] if me.up[a]!=-1 else a
    ub = me.up[b] if me.up[b]!=-1 else b
    if (ua == ub):
      return
    if ( len(me.down[ua]) < len(me.down[ub]) ):
      ub,ua = ua,ub
    for v in me.down[ub]:
      me.up[v] = ua
    me.down[ua].extend( me.down[ub] )
    me.down[ub] = []
    me.up[ub] = ua
    me.down[ua].append( ub )

N,K,L = [ int(it) for it in input().split() ]
uk = Union(N)
for a,b in [ [int(it)-1 for it in input().split()] for i in range(K) ]:
  uk.union(a,b)

ul = Union(N)
for a,b in [ [int(it)-1 for it in input().split()] for i in range(L) ]:
  ul.union(a,b)

pr = [0]*N
for i in range(N):
  ua = uk.up[i] if uk.up[i]!=-1 else i
  ub = ul.up[i] if ul.up[i]!=-1 else i
  pr[i] = (ua*N+ub,i)
pr.sort(key = lambda x:x[0])

li = [0]*N
de = pr[0][0]
s = [pr[0][1]]
for i in range(1,N):
  if (de!=pr[i][0]):
    for v in s:
      li[v] = len(s)
    s=[pr[i][1]]
    de = pr[i][0]
  else:
    s.append(pr[i][1])
for v in s:
  li[v] = len(s)

print ( " ".join( [ str(it) for it in li ]) )
### BUGGY CODE ###

import fractions
import functools

MOD = 10**9+7

def main():
    def lcm(x, y):
        return (x * y) // fractions.gcd(x, y)

    n = int(input())
    a = [int(_) for _ in input().split()]
    LCM = functools.reduce(lambda x, y : lcm(x, y), a)

    arr = [0] * n
    for i in range(len(a)):
        arr[i] = LCM // a[i]
    print(sum(arr) % MOD)

if __name__ == '__main__':
    main()


### FIXED CODE ###

from fractions import gcd
from functools import reduce

MOD = 1000000007

def lcm(x, y):
    return (x * y) // gcd(x, y)

n = int(input())
a = [int(_) for _ in input().split()]
LCM = reduce(lcm, a)

arr = [LCM // _ for _ in a]
print(sum(arr) % MOD)
### BUGGY CODE ###

n=int(input())
p=[float(i) for i in input().split()]
dp=[[0 for j in range(n+1)] for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    for j in range(i+1):
        dp[i][j]=dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1-p[i-1])
ans=0
for i in range(n//2+1,n+1):
    ans+=dp[n][i]
print(ans)


### FIXED CODE ###

n=int(input())
p=[float(i) for i in input().split()]
dp=[[0 for j in range(n+1)] for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    for j in range(i+1):
        dp[i][j]=dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1-p[i-1])
ans=0
for i in range(n//2+1,n+1):
    ans+=dp[n][i]
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

def cur(x):
    for i in neighbor[x]:
        ans[i]+=ans[x]
        neighbor[i].remove(x)
        cur(i)

n,q=map(int,input().split())
neighbor=[set()  for _ in range(n+1)]
parent=[-1]*(n+1)
ans=[0]*(n+1)
for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].add(b)
    neighbor[b].add(a)


for _ in range(q):
    p,x=map(int,input().split())
    ans[p]+=x

cur(1)
print(" ".join(map(str,ans[1:])))

### FIXED CODE ###

n,q=map(int,input().split())
neighbor=[[]  for _ in range(n+1)]
ans=[0]*(n+1)

for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)


for _ in range(q):
    p,x=map(int,input().split())
    ans[p]+=x

visit=[True]*(n+1)
tmp=[1]
for x in tmp:
    visit[x]=False
    for y in neighbor[x]:
        if visit[y]:
            tmp.append(y)
            ans[y]+=ans[x]

print(*ans[1:])
### BUGGY CODE ###

A, B, N = [eval(v) for v in input().strip().split(" ")]

max_value = -99999

for x in range(1, N + 1):
    value = int(A * x / B) - A * int(x / B)
    max_value = value if value > max_value else max_value
print(max_value)

### FIXED CODE ###

A, B, N = [eval(v) for v in input().strip().split(" ")]

if N < B:
    print(int(A * N / B) - A * int(N / B))
else:
    print(int(A * (B - 1) / B) - A * int((B - 1) / B))
### BUGGY CODE ###

A,B,N=map(int,input().split())
max_L=0
x=0
while x<B and x<=N:
	L=int(A*x/B)-A*int(x/B)
	if max_L<=L:
		max_L=L
		x+=1
	else:
		break

"""
if B>N:
	while x<=N:
		L=int(A*x/B)-A*int(x/B)
		if x<N:
			if max_L<=L:
				max_L=L
				x+=1
			else:
				break
		else:
			if max_L<=L:
				max_L=L
				break
			else:
				x-=1
				break
else:
	while x<B:
		L=int(A*x/B)-A*int(x/B)
		if max_L<=L:
			max_L=L
			x+=1
		else:
			break
"""
print(max_L)

### FIXED CODE ###

A,B,N=map(int,input().split())
max_L=0
x=0
if B>N:
	x=N
	max_L=int(A*x/B)-A*int(x/B)
else:
	x=B-1
	max_L=int(A*x/B)-A*int(x/B)

print(max_L)
### BUGGY CODE ###

N = int(input())
A = input().split()
px = py = pz = 0
for a in A:
  if a == '1':
    px += 1
  elif a == '2':
    py += 1
  elif a == '3':
    pz += 1

nx = px + py + pz
ny = py + pz
nz = pz

dp = [[[0]*(nx+1) for y in range(ny+1)] for z in range(nz+1)]

for z in range(nz+1):
  for y in range(ny+1-z):
    for x in range(nx+1-z-y):
      if x == y == z == 0:
        continue
      
      else:
        s = x + y + z
        t = N/s
        if x > 0:
          t += dp[z][y][x-1]*x/s
        if y > 0:
          t += dp[z][y-1][x+1]*y/s
        if z > 0:
          t += dp[z-1][y+1][x]*z/s
        
        dp[z][y][x] += t


print(dp[pz][py][px])

### FIXED CODE ###

N = int(input())
A = input().split()
px = py = pz = 0
for a in A:
  if a == '1':
    px += 1
  elif a == '2':
    py += 1
  elif a == '3':
    pz += 1

nx = px + py + pz
ny = py + pz
nz = pz

dp = [[[0]*(nx+1) for y in range(ny+1)] for z in range(nz+1)]

for z in range(nz+1):
  for y in range(ny+1-z):
    for x in range(nx+1-z-y):
      if x == y == z == 0:
        continue
      
      else:
        s = x + y + z
        t = N/s
        if x > 0:
          t += dp[z][y][x-1]*x/s
        if y > 0:
          t += dp[z][y-1][x+1]*y/s
        if z > 0:
          t += dp[z-1][y+1][x]*z/s
        
        dp[z][y][x] += t


print(dp[pz][py][px])
### BUGGY CODE ###

import sys

def solve():
    N = int(input())
    S = input()
    words = dict()
    longest = 0
    for i in range(N-1):
        if (N - i) // 2 < longest: break
        else:
            current = S[i]
            if current in words: longest = max(longest, 1)
            else: words[current] = i
            for j in range(1, N - i):
                current += S[i + j]
                if current in words:
                    if words[current] + j + 1 <= i: longest = max(longest, j + 1)
                else: words[current] = i
    if S[N-1] in words: longest = max(longest, 1)

    #print(words)

    print(longest)

    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys

def solve():
    N = int(input())
    S = input()
    lens = len(S)
    alp = ["a", "b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u",\
        "v","w","x","y","z"]
    
    DP = [[0 for j in range(lens)] for i in range(lens)]
    DP[lens - 2][lens - 1] = (1 if S[lens-2] == S[lens - 1] else 0)
    for i in reversed(range(lens - 1)):
        for j in reversed(range(i + 1, lens)):
            if S[i] == S[j]:
                if j == lens - 1: DP[i][j] = 1
                else: DP[i][j] = DP[i+1][j+1] + 1

    maxlength = 0
    for i in range(lens):
        for j in range(i+1, lens):
            maxlength = max(maxlength, min(DP[i][j], j - i))

    print(maxlength)
    return 0

if __name__ == "__main__":
    solve()
### BUGGY CODE ###

n = int(input())
def dividable(p):
    d_max = int(p**(1/2))
    yes=False
    if d_max*d_max==p:
        yes=True
    ret =0
    if yes:
        for i in range(1, d_max):
            if p % i == 0:
                ret += 1
        return ret*2+1
    else:
        for i in range(1, d_max+1):
            if p%i==0:
                ret+=1
        return ret*2
ls=[0]*(n+1)
for i in range(2, n+1):
    ls[i]= ls[i-1] + dividable(i-1)
print(ls[-1])

### FIXED CODE ###

N = int(input())

N_1 = N - 1
counts = 0
i = 1
j = 1
while i <= N_1:
    while j <= N_1:
        if i * j <=  N_1:
            counts = counts + 1
        else:
            j = N_1
        j = j + 1
    j = 1
    i = i + 1

print(counts)
### BUGGY CODE ###

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

A.sort(reverse=True)

for i in range(M):
    # idx = A.index(max(A))
    # A[idx] //= 2
    idx = A.index(max(A[:i+1]))
    A[idx] //= 2
 
print(sum(A))

### FIXED CODE ###

import heapq

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

A_minus = [-int(a) for a in A]
heapq.heapify(A_minus)

for _ in range(M):
    tmp = -heapq.heappop(A_minus)
    tmp //= 2
    heapq.heappush(A_minus, -tmp)
 
print(-sum(A_minus))
### BUGGY CODE ###


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

_10000, _5000, _1000 = 0, 0, 0

exist = False

for i in range(n + 1):

    # print("10000円札 : {0}枚".format(i))
    
    for j in range(n + 1 - i):

        # print("5000円札 : {0}枚".format(j))

        for k in range(n + 1 - i - j):

            # print("1000円札 : {0}枚".format(k))

            if i + j + k == n :

                # print("合計枚数がN枚")
                # print("合計金額 : {0}円".format((i * 10000) + (j * 5000) + (k * 1000)))

                if (i * 10000) + (j * 5000) + (k * 1000) == y :
                    # print("答えを発見!")
                    _10000, _5000, _1000 = i, j, k
                    exist = True

    if exist == True :
        break

if exist == True :
    print("{0} {1} {2}".format(_10000, _5000, _1000))
else :
    print('-1 -1 -1')





                



### FIXED CODE ###


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

_10000, _5000, _1000 = 0, 0, 0

exist = False

for i in range(n + 1):

    # print("10000円札 : {0}枚".format(i))
    
    for j in range(n + 1 - i):

        # print("5000円札 : {0}枚".format(j))

        # print("1000円札 : {0}枚".format(k))

        if (i * 10000) + (j * 5000) + ((n - i - j) * 1000) == y :
                # print("答えを発見!")
                _10000, _5000, _1000 = i, j, n - i - j
                exist = True

        # if i + j + (n - i - j) == n :

        #     # print("合計枚数がN枚")
        #     # print("合計金額 : {0}円".format((i * 10000) + (j * 5000) + (k * 1000)))

        #     if (i * 10000) + (j * 5000) + ((n - i - j) * 1000) == y :
        #         # print("答えを発見!")
        #         _10000, _5000, _1000 = i, j, n - i - j
        #         exist = True

    if exist == True :
        break

if exist == True :
    print("{0} {1} {2}".format(_10000, _5000, _1000))
else :
    print('-1 -1 -1')