CodeEff/ECCO huggingface dataset:
# Original solution
from  operator import itemgetter

# 満足ポイントを求める関数
def f(a, b):
    return len(a) ** 2 + sum(a) + sum(b)

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

sushi = []
for i in range(n):
    sushi.append(list(map(int, input().split())))

sushi.sort(key=itemgetter(1), reverse=True)

s = []
s_change = []
types = []
# 集合Sの生成
for i in range(k):
    if sushi[i][0] not in types:
        s.append(sushi[i])
        types.append(sushi[i][0])
    else:
        s_change.append(sushi[i])

s_change.sort(key=itemgetter(1))
#print(s)
#print(s_change)

m = []
# 交換用の集合の生成
for i in range(k, n):
    if sushi[i][0] not in types:
        m.append(sushi[i])
        types.append(sushi[i][0])

#print(m)
#print([l[1] for l in s])
g = []
g.append(f([l[1] for l in s], [l[1] for l in s_change]))

# 集合gを求める
for i in range(min(len(s_change), len(m))):
    s.append(m[i])
    s_change.pop(0)
    g.append(f([l[1] for l in s], [l[1] for l in s_change]))

print((max(g)))



# Optimized solution
# 入力
n, k = list(map(int, input().split()))
A = [] # 寿司のネタの美味しさと種類を入れるリスト
for _ in range(n):
    A.append(list(map(int, input().split())))

# 美味しさ順にソートする
A.sort(key=lambda x: x[1], reverse=True)

# 美味しさで貪欲にとる
X = [] # 同じ種類で他に美味しさの大きい寿司が存在する
Y = [] # 取った寿司の中の各々の種類で美味しさが最も大きい
st = set() # 種類
for i in range(k):
    t, d = A[i]
    if t in st:
        X.append(d)
    else:
        Y.append(d)
        st.add(t)

# 美味しさポイントを求める
x = sum(X)
y = sum(Y)
v = len(Y) # 種類数
ans = x + y + v ** 2
for i in range(k, n):
    if not X:
        break
    t, d = A[i]
    if t in st:
        continue
    st.add(t)
    x -= X.pop()
    y += d
    v += 1
    ans = max(ans, x + y + v ** 2)

print(ans)
# Original solution
print((sum(len(str(i))%2 for i in range(1, int(eval(input())) + 1))))


# Optimized solution
n = int(eval(input()))
i = 1
r = 0
while 10 * i <= n + 1:
    r += 9 * i
    i *= 100
print((r + max(0, n + 1 - i)))
# Original solution
from math import log10
n = int(eval(input()))
cnt = 0
for i in range(1,n+1):
  if int(log10(i)+1) % 2 != 0 and i <= n:
    cnt += 1
print(cnt)

# Optimized solution
from math import log10
n =int(eval(input()))
print((len([i for i in range(1, n+1) if int(log10(i)+1) % 2 != 0 and i <= n])))
# Original solution
N = int(eval(input()))

count = 0
for i in range(1, N + 1):
    num_dig = 0
    ii = i
    while ii > 0:
        ii = int(ii / 10)
        num_dig += 1
    if num_dig % 2 != 0:
        count += 1

print(count)

# Optimized solution
N = int(eval(input()))

count = 0
for i in range(1, N + 1):
    if len(str(i)) % 2 != 0:
        count += 1
print(count)
# Original solution
#!/usr/bin/env python3
n=int(eval(input()))
a=0
for i in range(1,n+1):
    if len(str(i))%2>0:
        a+=1
print(a)


# Optimized solution
print((sum(len(str(-~i))%2>0 for i in range(int(eval(input()))))))
# Original solution
n = int(eval(input()))
count = 0

for i in range(1,n+1):
    if len(str(i)) % 2 == 1:
        count += 1
print(count)


# Optimized solution

n = eval(input())
num = int(n)
ans = 0

for i in range(1,num+1):
    if len(str(i)) % 2 == 1:
        ans += 1
#        print(i)

print(ans)
# Original solution
N = int(eval(input()))

answer = 0
for x in range(1,N+1):
    if len(str(x)) & 1:
        answer += 1
        
print(answer)

# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())

answer = sum(len(str(x))&1 for x in range(1,N+1))
print(answer)
# Original solution
N = int(eval(input()))

count = 0
for i in range(1, N+1):
    s = str(i)
    if len(s) % 2 == 1:
        count += 1
print(count)

# Optimized solution
def main():

    N = int(eval(input()))
    ans = 0
    for i in range(1, N+1):
        s = str(i)
        if(len(s) % 2 == 1): ans +=1

    return ans

if __name__ == '__main__':
    print((main()))
# Original solution
# 単純にすべてをまわして桁数を計算したのでよかったらしい

n = int(eval(input()))
ans = 0

for i in range(1, n+1):
    if len(str(i)) % 2 == 1:
        ans += 1

print(ans)


# Optimized solution
n = eval(input())
digit_n = len(str(n))
n = int(n)
ans = 0

if digit_n % 2 == 0:
    for i in range(digit_n // 2):
        ans += 9 * 10 ** (i * 2)

else:
    if digit_n != 1:
        for i in range((digit_n - 1) // 2):
            ans += 9 * 10 ** (i * 2)
        hasuu = n - 10 ** ((i+1)*2)
        ans += hasuu + 1
    
    else:
        ans = n

    
print(ans)

# 端数の計算が間違っていた
# Original solution
# -*- coding: utf-8 -*-


def main():
    n = int(eval(input()))
    ans = 0

    for i in range(1, n + 1):
        if len(list(str(i))) % 2 == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
# -*- coding: utf-8 -*-


def count_digit(n: int) -> int:
    digit = 0

    while n:
        digit += 1
        n //= 10

    return digit


def main():
    n = int(eval(input()))
    ans = 0

    for i in range(1, n + 1):
        if count_digit(i) % 2 == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))

i = 1
cnt = 0

while i <= N:
  cnt += 1
  i += 1
  if len(str(i)) % 2 == 0:
    i *= 10
print(cnt)

# Optimized solution
N = int(eval(input()))

cnt = 0
i = 0
for i in range(0, 5, 2):
  m = 10 ** i
  if len(str(m)) > len(str(N)):
    break
  M = int("9" * (i + 1))
  
  if M > N:
    M = N
  
  cnt += M - m + 1

print(cnt)
# Original solution
n = int(eval(input()))
num = 0
for i in range(n):
  if len(str(i+1))%2 == 1:
    num += 1
print(num)

# Optimized solution
n = int(eval(input()))

cnt = 0
for i in range(1,n+1):
    s = len(str(i))
    if s%2 == 1:
        cnt +=1
print(cnt)
# Original solution
# 2019-11-16 10:55:08(JST)
import sys
# import collections
import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n = int(sys.stdin.readline().rstrip())

    digits = math.floor(math.log10(n))
    if  digits % 2 == 0:
        ans = n
    else:
        ans = 10 ** digits - 1
        
    for i in range(1, digits, 2):
        ans -= 10 ** (i+1) - 1 - 10 ** i + 1
    
    print(ans)

if __name__ == "__main__":
    main()


# Optimized solution
import sys

n = sys.stdin.readline().rstrip()
l = len(n)

def main():
    cnt = 0
    for i in range(0, l, 2):
        if i < l-1:
            cnt += 10 ** (i + 1) - 10 ** i
        else:
            cnt += int(n) - (10 ** i - 1)

    return cnt

if __name__ == '__main__':
    ans = main()
    print(ans)
# Original solution
# ABC 136: B – Uneven Numbers
n = int(eval(input()))

odd_digits = 0

for i in range(1, n + 1):
    if len(str(i)) % 2 != 0:
        odd_digits += 1

print(odd_digits)

# Optimized solution
# ABC 136: B – Uneven Numbers
N = int(eval(input()))

count = 0

for i in range(1, N + 1):
    if len(str(i)) % 2 == 1:
        count += 1

print(count)
# Original solution
# ABC136b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(eval(input()))

c = 0
for i in range(1, n+1):
    if (len(str(i)) % 2 == 1):
        c += 1
print(c)

# Optimized solution
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # map(int, input().split())
    n = int(eval(input()))
    ans = 0
    for i in range(1, n + 1):
        if len(str(i)) % 2 == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
cnt = 0

while N > 0:
  s = str(N)
  length = len(s)
  if length % 2 == 0:
    N -= 1
  else:
    cnt += 1
    N -= 1
    
print(cnt)

# Optimized solution
N = int(eval(input()))
cnt = 0

for i in range(1, N + 1):
  if len(str(i)) % 2 == 1:
    cnt += 1

print(cnt)
# Original solution
n = int(eval(input()))
ans = 0

for i in range(1,n+1):
    digit = 1
    while i//10 > 0:
        digit += 1
        i /= 10
    if digit%2 == 1:
        ans += 1
print(ans)

# Optimized solution
n = int(eval(input()))
ans = 0
for i in range(1,n+1):
    if len(str(i))%2 == 1:
        ans += 1

print(ans)
# Original solution
n = int(eval(input()))
print((len(list([x for x in range(1,n+1) if len(str(x))%2 == 1]))))

# Optimized solution
n = int(eval(input()))
gen = (x for x in range(1,n+1) if len(str(x))%2 == 1)
print((len(list(gen))))
# Original solution
a=0
for i in range(int(eval(input()))):
  if len(str(i+1))%2==1:a+=1
print(a)

# Optimized solution
n=int(eval(input()))
ans=0
for i in range(1, n+1):
    if len(str(i))%2 == 1:
        ans+=1
print(ans)
# Original solution
n = int(eval(input()))
res = 0

for i in range(1, n + 1):
  l = len(str(i))
  res += l & 1

print(res)

# Optimized solution
n = int(eval(input()))
print((sum([len(str(x)) & 1 for x in range(1, n+1)])))
# Original solution
N = int(eval(input()))

count = 0
for i in range(N):
    if len(str(i + 1)) % 2 == 1:
        count += 1
print(count)

# Optimized solution
N = int(eval(input()))

# count = 0
# for i in range(N):
#     if len(str(i + 1)) % 2 == 1:
#         count += 1
# print(count)

print((sum(1 for i in range(N) if len(str(i + 1)) % 2 == 1)))
# Original solution
N = int(eval(input()))
ans = 0
for i in range(1,N+1):
    s = str(i)
    if (len(s) % 2 != 0):
        ans+=1

print(ans)




# Optimized solution
n = int(eval(input()))
ans = 0
for i in range(1,n+1):
    if len(str(i)) % 2 != 0:
        ans += 1
print(ans)
# Original solution
import math
n = int(eval(input()))
cnt = 0
for i in range(1, n + 1):
    if math.floor(math.log10(i) + 1) % 2:
        cnt += 1
print(cnt)

# Optimized solution
n = int(eval(input()))
cnt = 0
for i in range(1, n + 1):
    if len(str(i)) % 2:
        cnt += 1
print(cnt)
# Original solution
n = int(eval(input()))
cnt = 0
for i in range(1, n + 1):
    if len(str(i)) % 2:
        cnt += 1
print(cnt)

# Optimized solution
n = int(eval(input()))
print((sum(len(str(i + 1)) % 2 for i in range(n))))
# Original solution
N = int(eval(input()))
s = 0
for i in range(1, N+1):
    if len(str(i))%2 == 1:
        s = s+1
print (s)

# Optimized solution
N = int(eval(input()))
s = len(str(N))
t = 0
for i in range(0,s//2):
    t = t+9*10**(i*2)
if s%2 == 1:
    t = t+N-10**(s-1)+1
print (t)
# Original solution
N = int(eval(input()))
cnt = 0
for i in range(1,N+1):
    if len(str(i)) %2 != 0:
        cnt+=1
print(cnt)

# Optimized solution
N = int(eval(input()))
cnt = 0
for i in range(1,N+1):
    if len(str(i))%2==1:
        cnt+=1
print(cnt)
# Original solution
N=int(eval(input()))
ans=0
for i in range (1,N+1):
    if len(str(i))%2==1:
      ans +=1
ans=int(ans)
print(ans)

# Optimized solution
N = int(eval(input()))
cnt=0
for i in range(1,N+1):
  a = len(str(i))
  if a%2==1:
    cnt +=1
print(cnt)
# Original solution
import math
def digits(n):
  return int(math.log10(n))+1
  
def main():
  n = int(eval(input()))
  n_digit = digits(n)
  ans = 0
  
  if n_digit%2==0:
    for i in range(n_digit-1,0,-2):
      ans = ans + (pow(10,i)-pow(10,i-1))  
  else:
    ans = n - pow(10,n_digit-1) + 1
    for i in range(n_digit-2,0,-2):
      ans = ans + (pow(10,i)-pow(10,i-1)) 
  print(ans)
    
  
if __name__ == "__main__":
  main()



# Optimized solution
n = int(eval(input()))
import math
digit = int(math.log10(n))+1
ans = 0
if digit%2==0:
  for i in range(digit-1,0,-1):
    if i%2!=0: ans += (10**i-10**(i-1))
  print(ans)
else:
  ans = n-10**(digit-1)+1
  for i in range(digit-2,0,-1):
    if i%2!=0: ans += (10**i-10**(i-1))
  print(ans)
# Original solution
N = int(eval(input()))
ans = 0
for i in range(1, N + 1):
  if len(str(i)) % 2 == 1:
    ans += 1
print(ans)

# Optimized solution
#!/usr/bin/env python3
import sys


def solve(N: int):
    result = 0
    for i in range(1, N + 1):
        if len(str(i)) % 2 != 0:
            result += 1

    print(result)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()
# Original solution
n = eval(input(''))

n = int(n)

result = []
for i in range(1,n+1):
    if len(str(i)) % 2 !=0:
        result.append(i)
print((len(result)))

# Optimized solution
n = int(eval(input()))

result = []
for i in range(1,n+1):
    if len(str(i)) % 2 != 0:
        result.append(i)
        
print((len(result)))
# Original solution
N = int(eval(input()))
cnt = 0
for i in range(1,N+1):
    if len(str(i))%2 == 1:
        cnt += 1
print(cnt)

# Optimized solution
print((sum([1 for i in range(1,int(eval(input()))+1) if len(str(i))%2==1])))
# Original solution
def f(x):
    res = 0
    while x > 0:
        x //= 10
        res += 1
    return res


n = int(eval(input()))

ans = 0
for i in range(1, n + 1):
    if f(i) % 2 == 1:
        ans += 1
print(ans)


# Optimized solution
n = int(eval(input()))
print((len(tuple([x for x in range(1, n + 1) if len(str(x)) % 2 == 1]))))
# Original solution
N = int(eval(input()))

ans = sum(len(str(i)) % 2 == 1 for i in range(1, N + 1))

print(ans)


# Optimized solution
N = int(eval(input()))

ans = min(9, N) + max(0, min(999, N) - 99) + max(0, min(99999, N) - 9999)

print(ans)
# Original solution
N = int(eval(input()))

c = 0
for i in range(1,N + 1):
    if len(str(i))%2 == 1:
        c += 1
print(c)
        

# Optimized solution
n=int(eval(input()))
c=0
for i in range(1,n+1):
      if len(str(i))%2!=0:
            c+=1
print(c)
# Original solution
n=int(eval(input()))
c=0
for i in range(1,n+1):
      if len(str(i))%2!=0:
            c+=1
print(c)


# Optimized solution
n=int(eval(input()))
print((sum(len(str(i))%2 for i in range(1,n+1))))
# Original solution
a=int(eval(input()))
lis=[]
for i in range(1,a+1):
    lis.append(str(i))
cnt=0
for i in lis:
    if len(i)%2==1:
        cnt+=1
print(cnt)

# Optimized solution
n=int(eval(input()))
ans=0
for i in range(1,n+1):
    i=str(i)
    if len(i)%2==1:
        ans+=1
print(ans)
# Original solution
N = int(eval(input()))
count = 0
for i in range(1, N+1):
    s = str(i)
    if len(s) % 2 == 1:
        count += 1

print(count)

# Optimized solution
def I(): return int(eval(input()))
N = I()
ans = 0
for i in range(1,N+1):
    if len(str(i))%2==1:
        ans += 1
print(ans)
# Original solution
#!/usr/bin/env python

def main(N):
    ans = 0
    for i in range(1, N+1):
        if len(str(i)) % 2 == 1:
            ans += 1
    return(ans)
    
if __name__ == '__main__':
    N = int(eval(input())) 
    print((main(N)))


# Optimized solution
#!/usr/bin/env python
def main():
    N = int(eval(input()))
    ans = 0
    for i in range(1, N+1):
        if len(str(i)) %2 == 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))

count = 0
for i in range(1, N+1):
  if len(str(i)) % 2 == 1:
    count += 1
print(count)    

# Optimized solution
def resolve():
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        s = str(i)
        if len(s)%2 == 0:
            continue
        ans += 1
    return print(ans)

if __name__ == "__main__":
    resolve()
# Original solution
ans = 0
for i in range(1, int(eval(input()))+1):
    if((1<=i and i<=9)or(i>=100 and i<=999)or(i>=10000 and i<=99999)):
        ans += 1
print(ans)

# Optimized solution
ans = 0
for i in range(1, int(eval(input()))+1):
    if((1<=i<=9)or(100<=i<=999)or(10000<=i<=99999)):
        ans += 1
print(ans)
# Original solution
n_str = eval(input())
n_int = int(n_str)
# 1 ~ 50000
# 桁数が奇数= 1桁, 3桁, 5桁
# 1 ~ 9, 100 ~ 999,10000 ~ 99999の90909個しかないので全探索いけるか?
exs_list = []
for i in range(1, 100000):
    if len(str(i)) % 2 == 1:
        exs_list.append(i)

exs = {i: i for i in exs_list}

n_s = []
ans = 0
for i in range(1, n_int + 1):
    if len(str(i)) % 2 == 0:
        continue
    if i in exs:
        ans += 1

print(ans)







# Optimized solution
def digit_sum(n):
    # 各桁の和を求める
    # 計算量: O(logN)
    ans = 0
    while n > 0:
        ans += 1
        n //= 10
    return ans

n = int(eval(input()))
cnt = 0

for i in range(1, n+1):
    cnt += digit_sum(i) % 2

print(cnt)
# Original solution
N=int(eval(input()))
count=0
for i in range(1,N+1):
    if len(str(i))%2==1:count+=1
print(count)

# Optimized solution
N=int(eval(input()))
print((sum(len(str(i))%2==1 for i in range(1,N+1))))
# Original solution
N=int(eval(input()))
print((sum(len(str(i))%2==1 for i in range(1,N+1))))

# Optimized solution
N=int(eval(input()))
print((sum(len(str(i))%2 for i in range(1,N+1))))
# Original solution
n = int(eval(input()))
count= 0
for i in range(1,n+1):
    if len(str(i)) == 1 or len(str(i)) == 3 or len(str(i)) == 5:
        count+=1
print(count)

# Optimized solution
n = int(eval(input()))
count= 0
for i in range(1,n+1):
    if len(str(i))%2 == 1:
        count+=1
print(count)
# Original solution
print((sum(len(str(x+1))%2for x in range(int(eval(input()))))))

# Optimized solution
print(sum(len(str(x+1))%2for x in range(eval(input()))))
# Original solution
n = int(eval(input()))


def countKeta(num):
    count = 1
    while num / 10 >= 1:
        count += 1
        num = num // 10
    return count


count = 0

for i in range(1, n+1):
    if(countKeta(i) % 2 == 1):
        count += 1

print(count)

# Optimized solution
n = int(eval(input()))

if n < 10:
    print(n)
elif n < 100:
    print((9))
elif n < 1000:
    print((n-90))
elif n < 10000:
    print((909))
elif n < 100000:
    print((n-9090))
elif n < 1000000:
    print((90909))
# Original solution
N = int(eval(input()))
hako = []
ans = 0
for i in range(N):
    hako.append(N-i)
for k in range(N):
    nakami = hako[k]
    if len(str(nakami))%2 >= 1:
        ans += 1
print(ans)


# Optimized solution
count = 0
S=int(eval(input()))
for i in range(1,S+1):
    if len(str(i))%2==1:
        count +=1
print(count)