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

import bisect

N = int(input())
a = list(map(int,input().split(' ')))
a.sort(reverse = True)


fathers = [a.pop(0)]
for _ in range(N):
    sons = list()
    for father in fathers:
        for index,value in enumerate(a):
            if father > value:
                sons.append(a.pop(index))
                break

    fathers.extend(sons)

if len(fathers) == 2**N:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

N = int(input())
A = sorted((int(x) for x in input().split()))
 
parent = [A[-1]]
rest = A[:-1]
bl = True
for _ in range(N):
    next_parent = []
    next_rest = []
    for p in parent[::-1]:
        while rest:
            x = rest.pop()
            if x < p:
                next_parent.append(x)
                break
            else:
                next_rest.append(x)
                continue
    parent += next_parent
    parent.sort()
    rest = rest + next_rest[::-1]
 
bl = len(parent) == (2**N)
answer = 'Yes' if bl else 'No'
print(answer)
### BUGGY CODE ###

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

ans = a[0]
for i in range(1,n):
  ans *= a[i]
if ans > 10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

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

if 0 in a:
  print(0)
  exit()

ans = 1
for i in a:
  ans *= i
  if ans > 10**18:
    print(-1)
    exit()
print(ans)
### BUGGY CODE ###

n,goukei = map(int, input().split())
flg = 0
xmax = goukei // 10000
for x in range(0,xmax+1):
  if flg == 1:
    break
  ymax = (goukei-x*10000) // 5000
  for y in range(0, ymax+1):
    ztmp = goukei - (x*10000)- (y*5000)
    if ztmp % 1000 == 0:
      z = ztmp // 1000
      sumxyz = x+y+z
      if sumxyz == n:
        flg = 1
        xx = x
        yy = y
        zz = z
        break
if flg == 0:
  print(-1,-1,-1)
else:
  print(xx,yy,zz)

### FIXED CODE ###

n,goukei = map(int, input().split())
flg = 0
xmax = goukei // 10000
for x in range(0,xmax+1):
  if flg == 1:
    break
  ymax = (goukei-x*10000) // 5000
  for y in range(0, ymax+1):
    ztmp = goukei - (x*10000)- (y*5000)
    if ztmp % 1000 == 0:
      z = ztmp // 1000
      sumxyz = x+y+z
      if sumxyz == n:
        flg = 1
        xx = x
        yy = y
        zz = z
        break
if flg == 0:
  print(-1,-1,-1)
else:
  print(xx,yy,zz)
### BUGGY CODE ###

n = int(input())
s = input()

cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        for k in range(j+1, n):
            if k - j != j - i:
                if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                    cnt += 1
print(cnt)

### FIXED CODE ###

n = int(input())
s = input()
r = 0
g = 0
b = 0
for letter in s:
    if letter == "R":
        r +=1
    elif letter == "G":
        g +=1
    elif letter == "B":
        b +=1
total = r * g * b
subs = 0
for i in range(n):
    for j in range(i + 1, n):
        k = 2 * j - i
        if k <= n - 1:
            if s[i] == s[j]:
                continue
            elif s[j] == s[k]:
                continue
            elif s[k] == s[i]:
                continue
            else:
                subs += 1
        else:
            break
ans = total - subs
print(ans)
### BUGGY CODE ###

H,W,N = map(int,input().split())

from collections import defaultdict
t =defaultdict(int)
L = defaultdict(int)

for i in range(N):
    a,b = map(int,input().split())
    t[(a-1,b-1)] = 1
    for p in [-1,0,1]:
        for q in [-1,0,1]:
            if a+p < 2 or b+q < 2 or a+p >H-1 or b+q >W-1:
                continue
            L[(a+p-1,b+q-1)] = 1



ans = [0]*10
for k in L.keys():
    a,b = k[0],k[1]
    if a < 1 or b < 1 or a >H-2 or b >W-2:
        continue

    c = 0
    for p in [-1,0,1]:
        for q in [-1,0,1]:
            c +=t[(a+p,b+q)]

    ans[c] += 1

ans[0] = (H-2)*(W-2) - sum(ans)
for i in range(10):
    print(ans[i])


### FIXED CODE ###

H,W,N = map(int,input().split())

from collections import defaultdict
t =defaultdict(int)
L = defaultdict(int)

for i in range(N):
    a,b = map(int,input().split())
    t[(a-1,b-1)] = 1
    for p in [-1,0,1]:
        for q in [-1,0,1]:
            if a+p < 2 or b+q < 2 or a+p >H-1 or b+q >W-1:
                continue
            L[(a+p-1,b+q-1)] += 1
ans = [0]*10
for v in L.values():
    ans[v] += 1

ans[0] = (H-2)*(W-2) - sum(ans)
for i in range(10):
    print(ans[i])
### BUGGY CODE ###

h,w,m = map(int,input().split())
hw = [list(map(int,input().split())) for _ in range(m)]

gh = {i:{} for i in range(h)}
gw = {i:{} for i in range(w)}

for _h, _w in hw:
    gh[_h-1][_w-1]=_w-1
    gw[_w-1][_h-1]=_h-1
    
ansh = 0
posh = {}
answ = 0
posw = {}
for k,v in gh.items():
    if len(v) > ansh:
        ansh = len(v)
        
for k,v in gh.items():
    if len(v) == ansh:
        posh[k]=k
        
for k,v in gw.items():
    if len(v) > answ:
        answ = len(v)
        
for k,v in gw.items():
    if len(v) == answ:
        posw[k]=k
        
hoge = True
for i in posh:
    for j in posw:
        if i not in gw[j]:
            hoge = False
            
if hoge:
    print(ansh+answ-1)
else:
    print(ansh+answ)

### FIXED CODE ###

h,w,m = map(int,input().split())
hw = [list(map(int,input().split())) for _ in range(m)]

hc = [0]*h
wc = [0]*w
d={}
for _h, _w in hw:
    hc[_h-1]+=1
    wc[_w-1]+=1
    d[(_h-1,_w-1)]=1
    
maxh = max(hc)
maxw = max(wc)
    
        
hoge = True
wi = [i for i in range(w) if wc[i]==maxw]
for h in [i for i in range(h) if hc[i]==maxh]:
    for w in wi:
        if (h,w) not in d:
            hoge=False
            break
            
if hoge:
    print(maxh+maxw-1)
else:
    print(maxh+maxw)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from bisect import bisect_left, insort
from math import pi

def inpl(): return tuple(map(int, input().split()))
sx, sy, gx, gy = inpl()

yrev = False
if sx > gx:
    sx, sy, gx, gy = gx, gy, sx, sy

if sy > gy:
    sy, gy = 10**8 - 1 - sy, 10**8 - 1 - gy 
    yrev = True

N = int(input())
fountains = []

for _ in range(N):
    x, y = inpl()
    if yrev:
        y = 10**8 - 1 - y
    if (sx <= x <= gx) & (sy <= y <= gy):
        insort(fountains, [x, y])

L = []
if len(fountains):
    L.append(fountains[0][1])

for f in fountains: # 最長増加部分列
    x, y = f
    if L[-1] < y:
        L.append(y)
    else:
        L[bisect_left(L, y)] = y

if min(gx - sx, gy - sy) + 1 == len(L):
    print(((gx - sx)+(gy - sy))*100 - (20 - 5*pi)*(len(L)-1) + (10*pi - 20))
else:
    print(((gx - sx)+(gy - sy))*100 - (20 - 5*pi)*len(L))

### FIXED CODE ###

# -*- coding: utf-8 -*-
from bisect import bisect_left, insort
from math import pi
 
def inpl(): return tuple(map(int, input().split()))
sx, sy, gx, gy = inpl()
 
yrev = False
if sx > gx:
    sx, sy, gx, gy = gx, gy, sx, sy
 
if sy > gy:
    sy, gy = 10**8 - 1 - sy, 10**8 - 1 - gy 
    yrev = True
 
N = int(input())
fountains = []
 
for _ in range(N):
    x, y = inpl()
    if yrev:
        y = 10**8 - 1 - y
    if (sx <= x <= gx) & (sy <= y <= gy):
        fountains.append([x, y])

fountains.sort()
 
L = []
if len(fountains):
    L.append(fountains[0][1])
 
for f in fountains: # 最長増加部分列
    x, y = f
    if L[-1] < y:
        L.append(y)
    else:
        L[bisect_left(L, y)] = y
 
if min(gx - sx, gy - sy) + 1 == len(L):
    print(((gx - sx)+(gy - sy))*100 - (20 - 5*pi)*(len(L)-1) + (10*pi - 20))
else:
    print(((gx - sx)+(gy - sy))*100 - (20 - 5*pi)*len(L))
### BUGGY CODE ###

import numpy as np
from numba import njit, i8, u1, void, b1
import heapq

@njit(void(i8,i8,i8,i8,b1[:,:]),cache=True)
def solve(ch,cw,dh,dw,road_map):

    h,w = road_map.shape

    queue = [[0,ch*w+cw]]
    used_map = np.full(h*w,-1,dtype=np.int64)

    #move walk
    while used_map[dh*w+dw] == -1 and len(queue) != 0:
        dot = heapq.heappop(queue)
        tl,n = dot[0],dot[1]
        th,tw = divmod(n,w)
        used_map[n] = tl
        for x in range(-2,3,1):
            for y in range(-2,3,1):
                if th+ x < 0 or tw+y < 0 or th+x >= h or tw+y >= w or road_map[th+x][tw+y] == True:
                    continue
                if x == y == 0:
                    continue
                next_n  = (th+x)*w+tw+y
                check = used_map[next_n]
                if check == -1 or check > tl:
                    if abs(x)+abs(y) <= 1:
                        heapq.heappush(queue,[tl,next_n])
                if check == -1 or check > tl+1:
                    heapq.heappush(queue,[tl+1,next_n])

    print(used_map[dh*w+dw])

h,w = map(int,input().split())
ch,cw = map(int,input().split())
ch,cw = ch-1,cw-1
dh,dw = map(int,input().split())
dh,dw = dh-1,dw-1
road_map = np.array([[c=="#" for c in input()] for _ in range(h)])

solve(ch,cw,dh,dw,road_map)



### FIXED CODE ###

#shotoyooさんのコードをお借りしてテスト

import numpy as np
from numba import njit, b1, i4, i8, f8
from heapq import heappop as hpp, heappush as hp

@njit((b1[:, :],i8,i8,i8,i8), cache=True)
def main(ss,ch,cw,dh,dw):
    inf = 1<<30
    h,w = ss.shape
    start = ch*w+cw
    goal = dh*w+dw
    n = h*w
    seen = np.full(n, inf, np.int64)
    seen[start] = 0
    q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
    while q:
        pnum,pu = hpp(q)
        ux,uy = divmod(pu,w)
        if pu==goal:
            break
        for xx in range(-2, 3):
            for yy in range(-2, 3):
                if xx==yy==0:
                    continue
                if abs(xx)+abs(yy)<=1:
                    vv = 0
                else:
                    vv = 1
                x,y = ux+xx, uy+yy
                u = x*w + y
                num = pnum+vv
                if x<0 or y<0 or x>=h or y>=w or ss[x][y]:
                    continue
        #         print(x,y)
                if seen[u]>num:
                    seen[u] = num
                    hp(q,(num, u))
                
    val = seen[goal]
    if val==inf:
        return -1
    else:
        return val
      

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
ss = np.array([[c=="#" for c in input()] for _ in range(h)])

print(main(ss,ch,cw,dh,dw))
### BUGGY CODE ###


import bisect

"""
def wantp(n):

    wq = []
    while p[n] != n:
        wq.append(n)
        n = p[n]

    for i in wq:
        p[i] = n

    return n
"""


N = int(input())

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

"""
p = [i for i in range(N)]
rank = [1] * N
"""
used = [False] * N
ans = 0

for i in range(N):

    i = N - 1 - i
    now = 2 ** 33

    while A[i] * 2 < now:
        now //= 2

    na = A[-1]
    del A[-1]

    if used[i]:
        continue

    ind = bisect.bisect_left(A,now-na)

    while ind < i and used[ind] and na + A[ind] == now:
        ind += 1

    if ind < i and na + A[ind] == now:
        used[ind] = True
        ans += 1

    #print (now,na,ind)

print (ans)
        


### FIXED CODE ###


import bisect

"""
def wantp(n):

    wq = []
    while p[n] != n:
        wq.append(n)
        n = p[n]

    for i in wq:
        p[i] = n

    return n
"""


N = int(input())

B = list(map(int,input().split()))
B.sort()

A = []
AS = []
for i in range(N):
    if len(A) == 0:
        A.append(B[0])
        AS.append(1)
    else:
        if A[-1] == B[i]:
            AS[-1] += 1
        else:
            A.append(B[i])
            AS.append(1)


"""
p = [i for i in range(N)]
rank = [1] * N
"""
ans = 0

for i in range(len(A)):

    i = len(A) - 1 - i
    now = 2 ** 33

    while A[i] * 2 < now:
        now //= 2

    ind = bisect.bisect_left(A,now-A[i])

    if A[ind] + A[i] == now:

        if ind == i:
            ans += AS[i] // 2
            AS[i] = AS[i] % 2

        else:
            ans += min(AS[i],AS[ind])
            AS[ind] = max(AS[ind] - AS[i] , 0)



    #print (now,na,ind)

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

from collections import defaultdict
import sys
input = sys.stdin.readline

mod = 998244353
N, S = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
dp = [defaultdict(int) for j in range(S+1)]
for i in range(1, N+1):
    a = A[i-1]
    for j in range(a+1, S+1)[::-1]:
        for k, v in dp[j-a].items():
            dp[j][k] += v
    if a <= S:
        dp[a][i] = 1
    for k, v in dp[S].items():
        ans += (k * (N-i+1)) * v % mod
        ans %= mod
        dp[S] = defaultdict(int)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

mod = 998244353
N, S = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
dp = [0] * (S+1)
for i in range(1, N+1):
    a = A[i-1]
    for j in range(a+1, S+1)[::-1]:
        dp[j] += dp[j-a]
    if a <= S:
        dp[a] += i
    ans += dp[S] * (N-i+1)
    ans %= mod
    dp[S] = 0
print(ans)
### BUGGY CODE ###

N = int(input())
V = list(map(int, input().split()))
odd = V[::2]
even = V[1::2]

#最大出現する数と数字を検索する
def count(l):
  maximam = 0
  for i in set(l):
    count = l.count(i)
    if count > maximam:
      num = [i]
      maximam = count
    elif count == maximam:
      num.append(i)

  return maximam, num

odd_count = count(odd)
even_count = count(even)

if odd_count[1] == even_count[1] and len(odd_count[1]) ==1:
  if odd_count[0] == N//2:
    ans = N // 2
  else:
    even = [i if i != even_count[1][0] else -1 for i in even]
    odd = [i if i != odd_count[1][0] else -1 for i in odd]
    even_count2 = count(odd)
    odd_count2 = count(even)
    ans = N - max(odd_count[0] + even_count2[0], odd_count2[0] + even_count[0])
else:
  ans = N - (odd_count[0] + even_count[0])
  
print(ans)

### FIXED CODE ###

import collections

N = int(input())
V = list(map(int, input().split()))
odd = V[::2]
even = V[1::2]
odd_count =  collections.Counter(odd).most_common()
even_count = collections.Counter(even).most_common()

if odd_count[0] == even_count[0]:
  if len(odd_count) == 1:
    ans = N//2
  elif odd_count[1][1] == odd_count[0][1] or even_count[1][1] == even_count[0][1]:
    ans = N-(odd_count[0][1] + even_count[0][1])
  else:
    ans = N-max(odd_count[0][1] + even_count[1][1], odd_count[1][1]+ even_count[0][1])
else:
  ans = N-(odd_count[0][1] + even_count[0][1])

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

import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()
def LIR(n): return [S().split() for i in range(n)]

def main():
    s = S()
    Q = I()
    Qu = LIR(Q)
    for que in Qu:
        if que[0] == '1':
            s = ''.join(list(reversed(s)))
        else:
            if que[1] == '1':
                s = que[2]+s
            else:
                s = s+que[2]
    print(s)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict, deque
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()
def LIR(n): return [S().split() for i in range(n)]

def main():
    s = S(); Q = I()
    mode = 2
    d = deque(s)

    for i in range(Q):
        query = S()
        if query[0] == "1": mode = 3 - mode
        else:
            t, f, c = map(str, query.split())
            if (int(f) + mode)% 2  == 0: d.append(c)
            else: d.appendleft(c)
    if mode == 2: print(''.join(d))
    else: print(''.join(list(d)[::-1]))

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

def solve():
    N = int(input())
    
    r = 1e12
    for i in range(N - 1, 0, -1):
        if N % i == 0:
            r = min(r, (N / i - 1) + (i - 1))
            
    
    print(int(r))

solve()

### FIXED CODE ###

import numpy as np

def solve():
    N = int(input())
    
    r = 1e12
    for i in range(1, int(np.sqrt(N)) + 1):
        if N % i == 0:
            r = min(r, (N / i - 1) + (i - 1))
            
    
    print(int(r))

solve()
### BUGGY CODE ###

from fractions import gcd
n = int(input())
gcdf = 0
for i in range (1, n+1):
  for j in range (1, n+1):
    for k in range (1, n+1):
      gcdf  += gcd(gcd(i,j),k)
      
print(gcdf)

### FIXED CODE ###

from math import gcd
N = int(input())
ans = 0
for i in range(1,N+1):
  for j in range(1,N+1):
    for k in range(1,N+1):
      ans += gcd(gcd(i,j),k)
print(ans)
### BUGGY CODE ###

N=int(input())

is_prime = [True] * (N + 1)
is_prime[0] = False
is_prime[1] = False
min_prime=[i for i in range(N+1)]

for i in range(2, int(N**0.5) + 1):
    if not is_prime[i]:
        continue
    for j in range(i * 2, N + 1, i):
        is_prime[j] = False
        min_prime[j]=min_prime[i]

ans=0

for i in range(1,N+1):
    j=i
    dic={}
    while j>1:
        if min_prime[j] in dic:
            dic[min_prime[j]]+=1
        else:
            dic[min_prime[j]]=1
        
        j//=min_prime[j]
    
    cnt=1
    for d in dic.values():
        cnt*=(d+1)
    
    ans+=i*cnt

print(ans)

### FIXED CODE ###

N=int(input())

ans=0
for i in range(1,N+1):
    ans+=(N//i+1)*i*(N//i)//2
print(ans)
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n):
  for j in range(i):
    a = l[i]+l[j]
    for k in l:
      if a > k:
        continue
      cnt += 1
print(n*(n-1)*(n-2)//6-cnt)

### FIXED CODE ###

n = int(input())
l = sorted(map(int, input().split()))
cnt = 0
m = n-1
g = []
for i in range(n):
  for j in range(i):
    g.append(l[i]+l[j])
g = sorted(g,reverse = True)
for i in g:
  while l[m] >= i:
    m-=1
  cnt += n-m-1
print(n*(n-1)*(n-2)//6-cnt)
### BUGGY CODE ###

x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

AB = []
for xi in range(x):
  for yi in range(y):
    AB.append(A[xi]+B[yi])

AB = sorted(AB,reverse=True)
C = sorted(C,reverse=True)

i=0
j=0

ABC = []
for ab in AB[:k]:
  for c in C[:k]:
    ABC.append(ab+c)

ABC = sorted(ABC,reverse=True)
for abc in ABC[:k]:
  print(abc)

### FIXED CODE ###

x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

AB = []
for xi in range(x):
  for yi in range(y):
    AB.append(A[xi]+B[yi])

AB = sorted(AB,reverse=True)
C = sorted(C,reverse=True)

i=0
j=0

ABC = []
for ab in AB[:k]:
  for c in C[:k]:
    ABC.append(ab+c)

ABC = sorted(ABC,reverse=True)
for abc in ABC[:k]:
  print(abc)
### BUGGY CODE ###

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

maxpair = (-1,-1)

for i in range(N-K+1):
    ksum = sum(PP[i:i+(K)])
    if ksum > maxpair[1]:
        maxpair = (i,ksum)
        
        
mp = maxpair[0]        
maxrange = PP[mp:(mp+K)]

esum = 0
for m in maxrange:
    esum += (m+1)/2
    
print(esum)


### FIXED CODE ###

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


mind = -1
mmax = -1

sums = []
csum = 0

for i in range(N):
    p = PP[i]
    csum += (p+1)/2
    sums.append(csum)
    if i < K:
        if mmax < csum:
            mind = i
            mmax = csum
    else:
        ksum = csum - sums[(i-K)]
        if mmax < ksum:
            mind = i
            mmax = ksum


print(mmax)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

H,W = map(int,input().split())
INF = 10**18
q = []

visited = [[True]*(W+2)] + [[True]+[False]*W+[True] for _ in range(H)] + [[True]*(W+2)]# '#'からの距離

for i in range(1,H+1):
  for j,c in enumerate(input(),1):
    if c == '#':
      visited[i][j] = True
      q.append((i,j))

ans = -1
qq = []
while q:
  ans += 1
  for x,y in q:
    for dx,dy in [(0,1),(0,-1),(1,0),(-1,0)]:
      xx = x+dx
      yy = y+dy
      if not visited[xx][yy]:
        visited[xx][yy] = True
        qq.append((xx,yy))
  q = qq
  qq = []
  
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

H,W = map(int,input().split())
INF = 10**18
q = []

visited = [[True]*(W+2)]
visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
visited.append([True]*(W+2))
  
for i in range(1,H+1):
  for j in range(1,W+1):
    if visited[i][j]:
      q.append((i,j))

moves = [(0,1),(0,-1),(1,0),(-1,0)]

ans = -1
while q:
  qq = []
  ans += 1
  for x,y in q:
    if not visited[x-1][y]:
      visited[x-1][y] = True
      qq.append((x-1,y))
    if not visited[x+1][y]:
      visited[x+1][y] = True
      qq.append((x+1,y))
    if not visited[x][y-1]:
      visited[x][y-1] = True
      qq.append((x,y-1))
    if not visited[x][y+1]:
      visited[x][y+1] = True
      qq.append((x,y+1))
  q = qq
  
print(ans)
### BUGGY CODE ###

a, b, x = map(int, input().split())

start = a
end = b
while start <= end:
    if start % x == 0:
        break
    if start == end:
        print(0)
        exit()
    start += 1

result = (end - start) // x + 1
print(result)


### FIXED CODE ###

a, b, x = map(int, input().split())

start = 0
end = b
if a > x:
    if a % x == 0:
        start = a
    else:
        start = x * (a // x + 1)
else:
    start = x

if start > end:
    result = 0
else:
    result = (end - start) // x + 1
if a == 0:
    result += 1
print(result)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(int(1e7))
n=int(input())
a=list(map(int,input().split()))

A=a.count(1)
B=a.count(2)
C=a.count(3)

memo=[[[-1]*(301) for _ in range(301)] for _ in range(301)]
memo[0][0][0]=0
def c(i,j,k):
        if memo[i][j][k]!=-1:
            return memo[i][j][k]
        else:
            memo[i][j][k]=n/(i+j+k)
            if 1<=i<=300:
                memo[i][j][k]+=c(i-1,j,k)*i/(i+j+k)
            if 0<=i<=299 and 1<=j<=300:
                memo[i][j][k]+=c(i+1,j-1,k)*j/(i+j+k)
            if 0<=j<=299 and 1<=k<=300:
                memo[i][j][k]+=c(i,j+1,k-1)*k/(i+j+k)
            return memo[i][j][k]

print(c(A,B,C))

### FIXED CODE ###

import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))

A=a.count(1)
B=a.count(2)
C=a.count(3)

dp=[[[0.0]*(n+1) for _ in range(n+1)] for _ in range(n+1)]
def c():
    for k in range(C+1):
        for j in range(B+C+1-k):
            for i in range(n+1-k-j):
                if i==0 and j==0 and k==0:
                    continue
                res=1.0*n
                if i>0:
                    res+=i*dp[i-1][j][k]
                if j>0:
                    res+=j*dp[i+1][j-1][k]
                if k>0:
                    res+=k*dp[i][j+1][k-1]
                dp[i][j][k]=res/(i+j+k)
    print(dp[A][B][C])
c()
### BUGGY CODE ###

N = int(input())
S = input().strip()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if i >= j:
            continue
        if S[i] != S[j]:
            dp[i][j] = 0
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1

ans = 0
for i in range(N):
    for j in range(N):
        now = min([dp[i][j], j-i])
        ans = max(ans, now)

print(ans)


### FIXED CODE ###

N = int(input())
S = input().strip()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if i >= j:
            continue
        if S[i] != S[j]:
            dp[i][j] = 0
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1

ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        now = min([dp[i][j], j-i])
        ans = max(ans, now)

print(ans)