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

def resolve():
    n, c, k = map(int, input().split())
    t = list(int(input()) for _ in range(n))
    t.sort()
    ans = 0
    while t:
        candidates = len([tj for tj in t if tj <= t[0] + k])
        num = min(c, candidates)
        t = t[num:]
        ans += 1
    print(ans)


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    n, c, k = map(int, input().split())
    t = list(int(input()) for _ in range(n))
    t.sort()
    ans = 1
    limit = t[0] + k
    bus = 0
    for i in range(n):
        bus += 1
        if t[i] > limit or bus > c:
            limit = t[i] + k
            ans += 1
            bus = 1
    print(ans)


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

N, Q = map(int, input().split())
S = list(input())
lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r])

pair = [0] * len(S)
for i in range(len(S)-1):
    if S[i] is 'A' and S[i+1] is 'C':
        pair[i] = 1

for i in range(Q):
    ans = 0
    l = lr[i][0]-1
    r = lr[i][1]-1
    for j in range(l,r):
        ans += pair[j]
    print(ans)


### FIXED CODE ###

N, Q = map(int, input().split())
S = list(input())
lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r])

pair = [0] * len(S)
for i in range(len(S)-1):
    if S[i] is 'A' and S[i+1] is 'C':
        pair[i+1] = pair[i] + 1
    else:
        pair[i+1] = pair[i]

for i in range(Q):
    ans = 0
    l = lr[i][0]-1
    r = lr[i][1]-1
    print(pair[r]-pair[l])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict


MAX_INT = 2**62-1
sys.setrecursionlimit(10**6)

input = sys.stdin.readline


def solve(g, f, fi, m):
    def dfs(pre, cur):
        if (pre, cur) in memo:
            return memo[pre, cur]

        num, ways = 1, 1

        for nxt in g[cur]:
            if nxt == pre:
                continue
            n, w = dfs(cur, nxt)
            num += n
            ways = ways * w % m * fi[n] % m

        ways = ways * f[num-1] % m
        memo[pre, cur] = num, ways
        return num, ways

    memo = {}
    print(*[dfs(None, i)[1] for i in range(1, len(g))], sep='\n')


def main():
    n = int(input())
    g = [[] for _ in range(n+1)]
    mod = 10**9 + 7

    fact = [1] * (n+1)
    fact_inv = [1] * (n+1)

    for i in range(1, n+1):
        fact[i] = fact[i-1] * i % mod

    fact_inv[-1] = pow(fact[-1], mod-2, mod)

    for i in range(1, n)[::-1]:
        fact_inv[i] = fact_inv[i+1] * (i+1) % mod

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

    solve(g, fact, fact_inv, mod)


if __name__ == "__main__":

    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from functools import reduce

MAX_INT = 2**62-1
sys.setrecursionlimit(10**7)

input = sys.stdin.readline

# @profile
MOD = 10**9 + 7


def mul_mod(*args, mod=MOD):
    return reduce(lambda a, b: a * b % mod, args)


def solve(g, f, fi, m):
    mul = mul_mod

    stack = [(0, 1)]
    pre_order = []
    n = len(g) - 1

    while stack:
        pre, cur = stack.pop()
        pre_order.append((pre, cur))

        for nxt in g[cur]:
            if nxt == pre:
                continue
            stack.append((cur, nxt))

    size = [1] * (n+1)
    dp = [1] * (n+1)

    for pre, cur in reversed(pre_order):
        dp[cur] = mul(dp[cur], f[size[cur]-1])
        dp[pre] = mul(dp[pre], dp[cur], fi[size[cur]])
        size[pre] += size[cur]

    ans = [1] * (n+1)
    ans[1] = dp[1]

    for pre, cur in pre_order[1:]:
        i = size[cur]
        temp = mul(ans[pre], f[n-i-1], fi[n-1], f[i], pow(dp[cur], m-2, m))
        ans[cur] = mul(f[n-1], temp, fi[n-i], dp[cur], fi[i-1])
    print(*ans[1:], sep='\n')


# @profile
def main():
    mul = mul_mod
    mod = MOD
    n = int(input())
    g = [[] for _ in range(n+1)]

    fact = [1] * (n+1)
    fact_inv = [0] * (n+1)

    for i in range(1, n+1):
        fact[i] = mul(fact[i-1], i)

    fact_inv[-1] = pow(fact[-1], mod-2, mod)

    for i in range(n)[::-1]:
        fact_inv[i] = mul(fact_inv[i+1], (i+1))

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

    solve(g, fact, fact_inv, mod)


if __name__ == "__main__":

    main()
### BUGGY CODE ###

S = input()
leng = len(S)

count = [0] * 2019
count[0] = 1

num = 0
d = 1

for i in range(leng):
    num += int(S[leng-1-i]) * d
    num %= 2019
    count[num] += 1
    d *= 10


res = 0
for cnt in count:
    res += cnt * (cnt - 1) // 2

print(res)

### FIXED CODE ###

s = input()[::-1]

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

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

def op2(f, c, r):
  if r == 0:
    if f == "1":
      slist.insert(0, c)
    elif f == "2":
      slist.append(c)

  if r == 1:
    if f == "2":
      slist.insert(0, c)
    elif f == "1":
      slist.append(c)

S = input()
Q = int(input())
v = [list(input().split()) for i in range(Q)]
rev = 0
slist = [S]

for val in v:
  if val[0] == "1":
    if rev == 0:
      rev = 1
    elif rev == 1:
      rev = 0
  elif val[0] == "2":
    S = op2(val[1], val[2], rev)

ans = "".join(slist)

if rev == 0:
  print(ans)
else:
  print(ans[::-1])

### FIXED CODE ###

def op2(f, c, r):
  if r == 0:
    if f == "1":
      left.append(c)
    elif f == "2":
      right.append(c)

  if r == 1:
    if f == "1":
      right.append(c)
    elif f == "2":
      left.append(c)

S = input()
Q = int(input())
v = [list(input().split()) for i in range(Q)]
rev = 0
left = []
right = []

for val in v:
  if val[0] == "1":
    if rev == 0:
      rev = 1
    elif rev == 1:
      rev = 0
  elif val[0] == "2":
    op2(val[1], val[2], rev)

nleft = left[::-1]
ans = "".join(nleft + [S] + right)

if rev == 0:
  print(ans)
else:
  print(ans[::-1])
### BUGGY CODE ###

n,a,b=map(int, input().split())
pot = b-a+1
if(b<a):
    print(0)
    exit()
if n==0:
    print(0)
elif n==1:
    if a==b:
        print(1)
    else:print(0)
elif n==2:
    if a==b:print(1)
    print(1)
else:
    k = n-2
    ans=0

    for i in range(k):
        ans+=pot
        pot-=1
    print(ans)


### FIXED CODE ###

n,a,b=map(int, input().split())
pot = b-a+1
if(b<a):
    print(0)
    exit()
if n==0:
    print(0)
elif n==1:
    if a==b:
        print(1)
    else:print(0)
elif n==2:
    if a==b:print(1)
    print(1)
else:
    k = n-1
    m = k*b
    high = m+a
    low = a*k + b
    print(high-low+1)
### BUGGY CODE ###

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

dp = [float("inf")] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,N):
    for j in range(1,K+1):
        dp[i] = min(dp[i],dp[i-j] + abs(h[i] - h[i-j]))

print(dp[-1])

### FIXED CODE ###

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

dp = [float("inf")] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,N):
    for j in range(1,K+1):
        dp[i] = min(dp[i],dp[i-j] + abs(h[i] - h[i-j]))

print(dp[-1])
### BUGGY CODE ###

"""
連続する部分文字列の種類は多くてN**2個ある。
N<=5000という制約から考えて、これらの連続する部分文字列に対して全探索ができる。
問題は、各部分文字列が条件を満たしているかどうかをどうやって調べるかだ。
これは、各部分文字列種ごとにどの区間で出現するかをメモしておけば良い。
dic["hogehoge"] => "hogehoge"という連続部分文字列が出現する区間をメモした配列
dic["hogehoge"] = [(0,7),(2,9),(6,13),(10,17)]　といった具合だ。
dic[hogehoge][x][1]とdic[hogehoge][x+1][1]が重複しているかを調べることで条件を満たすかどうかを判定できる。
区間(i,j)のjで昇順並びになっている必要があるが、実直にi,jでループして連続部分文字列を探索すれば、自然と昇順でメモされる。
計算量はO(N**2)で間に合う。
"""
N = int(input())
S = input()

dic = {}
for i in range(N):
    for j in range(i,N):
        if S[i:j+1] not in dic:
            dic[S[i:j+1]] = []
        dic[S[i:j+1]].append((i,j))

ans = 0
for k,v in dic.items():
    if len(v) > 1:
        for i in range(1,len(v)):
            if v[i][0]<=v[i-1][1]:
                break
        else:
            ans = max(ans,len(k))
print(ans)




### FIXED CODE ###

"""
X文字が条件にあてはまるとき、X-1文字も条件に当てはまる。したがって、二分探索を使うのがよい。
一回の探索に、O(N**2)かかる。
探索はO(logN)回行うため、全体でO(N**2logN)で、ギリ間に合う。
"""
N = int(input())
S = input()

def is_ok(X):
    dic = {}
    for i in range(N+1-X):
        sub = S[i:i+X]
        if sub not in dic:
            dic[sub] = (i,i+X-1)
        else:
            if dic[sub][1] < i:
                return True
    return False

def bisearch(high,low):
    while high - low > 1:
        mid = (high+low)//2
        if is_ok(mid):
            low = mid
        else:
            high = mid
    return low
print(bisearch(N,0))
### BUGGY CODE ###

k=int(input())

# mod k で考える
mod=k

for i in range(1,10**6+1):
    if mod>7*int(str(1)*i):
        continue
    else:
        if mod==k:
            mod = 7 * int(str(1) * i) % mod
            if mod == 0:
                print(i)
                exit()
        else:
            mod= (mod*10+7)%k
            if mod==0:
                print(i)
                exit()

print(-1)


### FIXED CODE ###

k=int(input())

cur=0
for i in range(k+2):
    cur=(cur*10+7)%k
    if cur==0:
        print(i+1)
        exit()

print(-1)
### BUGGY CODE ###

h,w,d = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for i in range(h)]
q = int(input())
lr = [[int(i) for i in input().split()] for i in range(q)]

def abs(c): 
    if c > 0: 
        return c 
    else: 
        return -c
    
def distance_2d(a,b):
    return(abs(a[0]-b[0])+abs(a[1]-b[1]))
    
def list_1d(d,v):
    return [ v for i in range(d)]
 
def search_2d(a,key):
    x = -1
    y = -1
    for i in range(0,len(a)):
        for j in range(0,len(a[0])):
            if a[i][j] == key:
                x = i
                y = j
        if x != -1:
            break
    
    return([x,y])
 
sa = list_1d(h*w,[])
 
for i in range(0,h*w):
    sa[i] = search_2d(a,i+1)
 
 
 
for i in range(0,q):
    present = lr[i][0]
    goal = lr[i][1]
    power = 0
    while present != goal:
        power += distance_2d(sa[present-1],sa[present+d-1])
        present += d
    print(power)

### FIXED CODE ###

def list_1d(d,v):
    return [ v for i in range(d)]

def abs(c): 
    if c > 0: 
        return c 
    else: 
        return -c

def distance_2d(a,b):
    return(abs(a[0]-b[0])+abs(a[1]-b[1]))

h,w,d = [int(i) for i in input().split()]
sa = list_1d(h*w+1,[])
da = list_1d(h*w+1,0)
for i in range(h):
    a = [int(k) for k in input().split()]
    for j in range(w):
        sa[a[j]] = [i,j]
q = int(input())
lr = [[int(i) for i in input().split()] for i in range(q)]

for i in range(d+1,h*w+1):
    da[i] = da[i-d] + distance_2d(sa[i],sa[i-d])

for i in range(0,q):
    print(da[lr[i][1]]-da[lr[i][0]])
### BUGGY CODE ###

import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
from decimal import Decimal
# from fractions import Fraction
# sys.setrecursionlimit(100000)
mod = 998244353
INF=float('inf')
 
n,k=mdata()
lis=[]
dp=[0]*(n)
dp[0]=1
for i in range(k):
    l,r=mdata()
    for j in range(l,r+1):
        lis.append(j)
lis.sort()
for i in range(1,n):
    for j in lis:
        if j>i:
            break
        dp[i]=(dp[i]+dp[i-j])%mod
out(dp[-1])

### FIXED CODE ###

import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
from decimal import Decimal
# from fractions import Fraction
# sys.setrecursionlimit(100000)
mod = 998244353
INF=float('inf')

n,k=mdata()
set1=set()
dp=[0]*(n)
s=[0]*n
lis=sorted([mdata() for i in range(k)],key=lambda x:x[0])
for i,j in lis:
    for m in range(i,j+1):
        set1.add(m)
m=lis[0][0]
for i in range(m,n):
    for j in range(k):
        if lis[j][0]>=i:
            break
        dp[i]+=s[i-lis[j][0]]-s[i-min(lis[j][1],i-1)-1]
    if i in set1:
        dp[i]+=1
    dp[i]%=mod
    s[i]=dp[i]+s[i-1]
out(dp[-1])
### BUGGY CODE ###

from collections import deque
import copy

H, W = map(int, input().split())
blacks = deque()
maps = []
for h in range(H):
  line = list(input())
  for w in range(W):
    if line[w] == '#':
      blacks.append([h,w])
  maps.append(line)
copied_maps = copy.deepcopy(maps)

def fill():
  new_blacks = deque()
  while len(blacks) > 0:
    x, y = blacks.popleft()
    for dx, dy in [[0,1],[0,-1],[1,0],[-1,0]]:
      nx = x+dx
      ny = y+dy
      if H > nx >= 0 and W > ny >= 0 and copied_maps[nx][ny] != '#':
        copied_maps[nx][ny] = '#'
        new_blacks.append([nx,ny])
  return new_blacks

end = False
for i in range(H*W):
  blacks = fill()
  if len(blacks) == 0:
      print(i)
      exit()

### FIXED CODE ###

# python には結構厳しいTLE・・・python以外のお勉強時間ないよ～( ;∀;)
# . から見た # の最大距離の方が楽ではあるが・・・
# 嫌いだけど def main も使ってみた．
from collections import deque
import copy
 
def main():
  H, W = list(map(int, input().split()))
  L = [[j=="#" for j in input()] for i in range(H)]
  q = deque([(i, j) for i in range(H) for j in range(W) if L[i][j]])
  cands = [(0, -1), (0, 1), (-1, 0), (1, 0)]
  result = 0
  while True:
    nq = deque()
    while q:
      i, j = q.popleft()
      if i > 0 and not L[i-1][j]:
        L[i-1][j] = True
        nq.append((i-1, j))
      if j > 0 and not L[i][j-1]:
        L[i][j-1] = True
        nq.append((i, j-1))
      if i < H-1 and not L[i+1][j]:
        L[i+1][j] = True
        nq.append((i+1, j))
      if j < W-1 and not L[i][j+1]:
        L[i][j+1] = True
        nq.append((i, j+1))
    if nq:
      q = copy.copy(nq)
    else:
      break    
    result += 1
  print(result)
 
if __name__ == "__main__":
  main()
### BUGGY CODE ###

N = int(input())

kami = []
for i in range(N):
    A = int(input())
    if A not in kami:
        kami.append(A)
    else:
        kami.remove(A)
    
print(len(kami))

### FIXED CODE ###

N = int(input())

kami = set([])
for i in range(N):
    A = int(input())
    if A not in kami:
        kami.add(A)
    else:
        kami.remove(A)

print(len(kami))
### BUGGY CODE ###

from math import sqrt


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    divisors.sort()
    return divisors


if __name__ == "__main__":
    N, P = map(int, input().split())

    A = Calc_Divisors(P)

    ans = 1
    for i in A:
        tmp = P % (i ** N)
        if i ** N > P:
            print(ans)
            exit()
        if tmp == 0:
            ans = i

    print(ans)


### FIXED CODE ###

from math import sqrt


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    divisors.sort()
    return divisors

if __name__ == "__main__":
    N, P = map(int, input().split())

    A = Calc_Divisors(P)

    ans = 1
    for i in A:
        tmp = P % (pow(i, N))
        if N > 40:
            print(ans)
            exit()
        if pow(i, N) > P:
            print(ans)
            exit()
        if tmp == 0:
            ans = i

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

n=int(input())
a=[[0]*n]*n
s=set()

for i in range(n):
  a[i]=[int(x)-1 for x in input().split()]

t=0
f=True
while f==True:
  f=False
  s.clear()
  for i in range(n):
    if len(a[i])==0:
      continue
    f=True
    if i==a[a[i][0]][0]:
      s.add(i)
      s.add(a[i][0])

  if f==False:
    break

  if len(s)!=0:
    t+=1
    l = list(s)
    for i in range(len(l)):
      a[l[i]].pop(0)
  else:
    t = -1
    break
print(t)


### FIXED CODE ###

from collections import deque

def main():
  N=int(input())
  A=[deque(int(a)-1 for a in input().split()) for _ in range(N)]

  P,W=[0]*N,[-1]*N
  c=deque(range(N))

  while c:
    i=c.popleft()
    j=A[i].popleft()
    W[i]=j

    if W[j]==i:
      P[i]=P[j]=max(P[i],P[j])+1
      if A[i]:
        c.append(i)
      if A[j]:
        c.append(j)

  print(-1 if any(len(a) for a in A) else max(P))

main()
### BUGGY CODE ###

import numpy as np
n=input()
data=list(map(int,input().split()))
is_i=0
num=sorted(data)
count=num[1]
if 2<len(data):
    if num[0]!=num[1] and any([x%num[1]!=0 for x in num[1::]]):
        count=int(num[1]/2+1)
for i in range(count+1)[::-1]:
    is_i=0
    if all([x%i==0 for x in data]):
        print(i)
        break
    else:
        for j in range(len(data)):
            if data[j]%i!=0:
                is_i+=1
        if is_i==1:
            print(i)
            break

### FIXED CODE ###

from fractions import gcd
import numpy as np
n=int(input())
data=list(map(int,input().split()))
left=np.zeros(n+1,dtype=np.int)
right=np.zeros(n+1,dtype=np.int)
kotae=1
for i in range(n):
    left[i+1]=gcd(left[i],data[i])
    right[n-i-1]=gcd(right[n-i],data[n-i-1])
for j in range(n):
    num=gcd(left[j],right[j+1])
    kotae=max(num,kotae)
print(kotae)
### BUGGY CODE ###

N, K = map(int, input().split())
ret = 0
for x in range(1, N + 1):
    for y in range(K - x, N + 1, K):
        for z in range(K - y, N + 1, K):
            if  y > 0 and z > 0 and (z + x) % K == 0:
                ret += 1
print(ret)

### FIXED CODE ###

N, K = map(int, input().split())
n = sum([1 for x in range(K, N + 1, K)])
if K % 2 == 1:
    print(n ** 3)
else:
    m = sum([1 for x in range(K // 2, N + 1, K)])
    print(n ** 3 + m ** 3)
### BUGGY CODE ###

from collections import deque

s = input()
Q = int(input())
query = [list(map(str, input().split())) for _ in range(Q)]

d = deque(s)

for q in query:
    if q[0] == '1':
        s = s[::-1]
    else:
        d = deque(s)
        if q[1] == '1':
            d.appendleft(q[2])
        else:
            d.append(q[2])
        d_list = list(d)
        s = ''.join(d_list)

print(s)

### FIXED CODE ###

from collections import deque

s = input()
Q = int(input())
query = [list(map(str, input().split())) for _ in range(Q)]

d = deque(s)

cnt = 0
for q in query:
    if q[0] == '1':
        cnt += 1
    else:
        if q[1] == '1':
            if cnt % 2:
                d.append(q[2])
            else:
                d.appendleft(q[2])
        else:
            if cnt % 2:
                d.appendleft(q[2])
            else:
                d.append(q[2])
        
d_list = list(d)
s = ''.join(d_list)
if cnt % 2 == 0:
    print(s)
else:
    print(s[::-1])
### BUGGY CODE ###

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

rn = [0]*(N+1)
gn = [0]*(N+1)
bn = [0]*(N+1)

for i in range(N):
    rn[i+1] = rn[i]
    gn[i+1] = gn[i]
    bn[i+1] = bn[i]
    if S[i]=="R":
        rn[i+1] = rn[i]+1
    if S[i]=="G":
        gn[i+1] = gn[i]+1
    if S[i]=="B":
        bn[i+1] = bn[i]+1
   
ans = 0
for i in range(N):
    a = S[i]
    rem = "RGB".replace(a,"")
    for j in range(N-i):
        if (S[j+i] == a):
            continue
        b = S[j+i]
        rem2 = rem.replace(b,"")
        if rem2 == "R":
            ans += rn[N]-rn[j+i+1]
        if rem2 == "G":
            ans += gn[N]-gn[j+i+1]
        if rem2 == "B":
            ans += bn[N]-bn[j+i+1]
        if 0 <= j*2+i <= N-1:
          if S[j*2+i] == rem2 :
              ans -=1
            
print(ans)
        

### FIXED CODE ###

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

rn = [0]*(N+1)
gn = [0]*(N+1)
bn = [0]*(N+1)

for i in range(N):
    rn[i+1] = rn[i]
    gn[i+1] = gn[i]
    bn[i+1] = bn[i]
    if S[i]=="R":
        rn[i+1] = rn[i]+1
    if S[i]=="G":
        gn[i+1] = gn[i]+1
    if S[i]=="B":
        bn[i+1] = bn[i]+1
   
ans = 0
for i in range(N):
    a = S[i]
    rem = "RGB".replace(a,"")
    for j in range(N-i):
        if (S[j+i] == a):
            continue
        b = S[j+i]
        rem2 = rem.replace(b,"")
        if rem2 == "R":
            ans += rn[N]-rn[j+i+1]
        if rem2 == "G":
            ans += gn[N]-gn[j+i+1]
        if rem2 == "B":
            ans += bn[N]-bn[j+i+1]
        if 0 <= j*2+i <= N-1:
          if S[j*2+i] == rem2 :
              ans -=1
            
print(ans)
### BUGGY CODE ###

#C問題
N,Q=map(int,input().split())
S=str(input())
Slist=list(S)
LR=[list(map(int,input().split())) for i in range(Q)]
for i in range(Q):
    karis=Slist[LR[i][0]-1:LR[i][1]]
    karistr="".join(karis)
    ans=karistr.count("AC")
    print(ans)

### FIXED CODE ###

#C問題  
N,Q=map(int,input().split())
S=str(input())
Slist=list(S)
pile=[0 for i in range(N)]
for i in range(N-1):
    if i == 0:
        pass
    else:
        pile[i]=pile[i-1]
  
    if Slist[i] == "A" and Slist[i+1] == "C":
        pile[i]+=1
pile[-1]=pile[-2]
pile.insert(0,0)
for i in range(Q):
    l,r=map(int,input().split())
    print(pile[r-1]-pile[l-1])
### BUGGY CODE ###

import itertools
n = int(input())
L = list(map(int,input().split()))
ans = 0

for v in itertools.combinations(L, 3):
  if v[0] < v[1]+v[2]:
    if v[1] < v[0]+v[2]:
      if v[2] < v[0]+v[1]:
        ans += 1
        
print(ans)

### FIXED CODE ###

import bisect
 
n = int(input())
l = [int(_) for _ in input().split()]
 
l.sort()
 
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        a, b = l[i], l[j]
        k = bisect.bisect_right(l, a+b-1)
        ans += k - j - 1
print(ans)
### BUGGY CODE ###

n,x = open(0).read().splitlines()

n = int(n)
x = int(x,2)

#count
d = {0:0}

def calc(n):
    if n not in d:
        pop = n % bin(n).count('1')
        d[n] = calc(pop) + 1
    return d[n]

for i in range(n-1,-1,-1):
    m = x ^ (1<<i)
    print(calc(m))

### FIXED CODE ###

from sys import exit
from collections import defaultdict
n,x = open(0).read().split()
n = int(n)
cnt = x.count('1') 
digits = list(map(int, list(x)))
x = int(x, 2)

d = defaultdict(int)
d[0] = 0
def calc(m):
    if m not in d:
        nxt = m % bin(m).count('1')
        d[m] = calc(nxt) + 1
    return d[m]

if n == 1:
    print(calc(x^1))
    exit()

mmod = cnt - 1
pmod = cnt + 1

if mmod > 0:
    mx = x % mmod
px = x % pmod

mbase = 1
pbase = 1

ans = []
while digits:
    digit = digits.pop()
    
    if digit and mmod <= 0:
        ans.append(0)
    else:
        if digit:
            nx = (mx - mbase)%mmod
        else:
            nx = (px + pbase)%pmod
        ans.append(calc(nx) + 1)

    if mmod > 0:
        mbase = (mbase * 2) % mmod
    pbase = (pbase * 2) % pmod

while ans:
    print(ans.pop())
### BUGGY CODE ###

def getCount(num, i,j):
    cnt = 0
    for n in range(1,num+1):
        s = str(n)
        if s[0] == str(i) and s[-1] == str(j):
            cnt+=1
    return cnt        

n = int(input())

res = 0
for i in range(0,10):
    for j in range(0,10):
        res += getCount(n,i,j) * getCount(n,j,i)
print(res)




### FIXED CODE ###

from collections import defaultdict
def getLeft(num):
    while num >= 10:
        num = int(num / 10)
    return num

def getRight(num):
    return num % 10

n = int(input())
a = defaultdict(int)
for number in range(1,n+1):
    left = getLeft(number)
    right = getRight(number)
    a[(left,right)] += 1


res = 0
for i in range(0,10):
    for j in range(0,10):
        res += a[(i,j)] * a[(j,i)]
print(res)