Problem:


Score : 200 points

Problem Statement

Given is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).

Constraints

1 \leq N \leq 10^5

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of positive integers less than or equal to N that have an odd number of digits.

Sample Input 1

11

Sample Output 1

9

Among the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \ldots, 9.

Sample Input 2

136

Sample Output 2

46

In addition to 1, 2, \ldots, 9, another 37 integers also have an odd number of digits: 100, 101, \ldots, 136.

Sample Input 3

100000

Sample Output 3

90909



Sample input:
11


Sample output:
9

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

if 1 <= N <= 9:
    print(N)
elif N <= 99:
    print(9)
elif N <= 999:
    print(9 + N - 99)
elif N <= 9999:
    print(909)
elif N <= 99999:
    print(909 + N - 9999)
else:
    print(90909)

Submission status: Accepted

Solution code:
n = int(input())

if n == 100000:
  print(90909)
elif 10000 <= n <= 99999:
  print(909 + n - 9999)
elif 1000 <= n <= 9999:
  print(909)
elif 100 <= n <= 999:
  print(9 + n - 99)
elif 10 <= n <= 99:
  print(9)
else:
  print(n)

Submission status: Accepted

Solution code:
N = int(input())
A1, A2, A3 = 9, 900, 90000

if len(str(N))%2 == 0:
  if N < 100 :
    print(A1)
  elif 100< N < 10000:
    print(A1 + A2)
  else:
    print(A1 + A2 + A3)
else:
  if N < 10:
    print(N)
  elif 10< N < 1000:
    print(N - 99 + A1)
  else:
    print(N - 9999 + A1 + A2)

Submission status: Accepted

Solution code:
n = int(input())

if 1 <= n < 100:
    print(min(9, n))
elif 100 <= n < 10000:
    print(min(909, n - 99 + 9))
elif 10000 <= n <= 100000:
    print(min(90909, n - 9999 + 909))

Submission status: Accepted

Solution code:
s=input()

a=int(s)

n = len(s)

m = int((n) /2)

ans = 0
for i in range(m):
    ans += 9 * (100 ** i)

if(n % 2 == 1):
    ans += a - 10 ** (n-1) + 1

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
count=0
if 1<=N<=9:
  print(N)
elif 10<=N<=99:
  print(9)
elif 100<=N<=999:
  print(9+N-100+1)
elif 1000<=N<=9999:
  print(9+999-100+1)
elif 10000<=N<=99999:
  print(9+999-100+1+N-10000+1)
else:
  print(9+999-100+1+99999-10000+1)

Submission status: Accepted

Solution code:
def main():
    n = int(input())

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

    print(count)


main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python

import sys

n= int(sys.stdin.readline())

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

Submission status: Accepted

Solution code:
N=int(input())
ans=0
if N<10**1:
  ans=N
elif N<10**2:
  ans=9
elif N<10**3:
  ans=N-90
elif N<10**4:
  ans=909
elif N<10**5:
  ans=N-9000-90
else:
  ans=90909
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n = int(input())

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

print(counter)

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())

ans = 0

keta = int(np.log10(n))
# print(keta)
for i in range(1, keta+1, 2):
    ans += 10**i - 10**(i-1)
    
if keta%2 == 0:
    ans += n - 10**keta + 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1,N+1):
    if ((10<=i and i<=99) or (1000<=i and i<=9999) or i ==100000):
        continue
    else:
        ans += 1 


print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
if N <= 9:
    ans = N
elif N <= 99:
    ans = 9
elif N <= 999:
    ans = N - 90
elif N <= 9999:
    ans = 909
elif N <= 99999:
    ans = N - 9090
else:
    ans = 90909

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
if n >= 10000:
    ans += (min(99999, n) - 9999) + 909
elif n >= 100:
    ans += (min(999, n) - 99) + 9
else:
    ans += min(9, n)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
t=0
for i in range(1,n+1):
    if len(str(i))%2==1:
        t+=1
print(t)

Submission status: Accepted

Solution code:
n = int(input())
if n >= 10000:
	if n >= 100000:
		print(90909)
	else:
		print(n-9999 + 909)
elif n >= 100:
	if n >= 1000:
		print(909)
	else:
		print(n-99 + 9)
else:
	if n >= 10:
		print(9)
	else:
		print(n)

Submission status: Accepted

Solution code:
N = int(input())

if N <= 9:
    ans = N
elif N <= 99:
    ans = 9
elif N <= 999:
    ans = 9 + N - 100 + 1
elif N <= 9999:
    ans = 9 + 900
elif N <= 99999:
    ans = 9 + 900 + N - 10000 + 1
else:
    ans = 9 + 900 + 90000
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
k = len(str(n))
count = 0
for i in range(k):
    if i % 2 == 1:
        count = count + 10**(i-1)*9
if k % 2 == 1:
    count = count + n - 10**(k-1) + 1
print(count)

Submission status: Accepted

Solution code:
n=int(input())
l=len(str(n))
ls=[9,0,900,0,90000,0,900000]
if l%2==0:
    print(sum(ls[:l]))
else:
    ans=sum(ls[:l-1])
    ans+=n-(10**(l-1)-1)
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
result = 0
for i in range(N + 1):
    if len(str(i)) % 2 == 0:
        pass
    else:
        result += 1
print(result - 1)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""
 
import sys, math, random
import numpy as np
 
# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
# S=numpp.assaray(S)=="#"
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LLS(): return [list(sys.stdin.readline().rstrip()) for _ in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
 
 
 
def main():
    N = I()
    out=0
    if N==100000:
        out=90909
    elif N>9999:
        out+=N-9999
        out+=9+900
    elif N>999:
        out+=909
    elif N>99:
        out+=N-99
        out+=9
    elif N>9:
        out+=9
    else:
        out+=N
    print(out)
 
 
 
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():

    """ convenient functions
    # for i, a in enumerate(iterable)
    # q, mod = divmod(a, b)
    # divmod(x, y) returns the tuple (x//y, x%y)
    # Higher-order function: reduce(operator.mul, xyz_count, 1)
    # manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
    """

    """convenient decorator
    # @functools.lru_cache():
    # to facilitate use of recursive function
        # ex:
        # from functools import lru_cache
        # import sys
        # sys.setrecursionlimit(10**9)
        # @lru_cache(maxsize=None)
        # def fib(n):
        #     if n < 2:
        #         return n
        #     return fib(n-1) + fib(n-2)
        # print(fib(1000))
    """
    
    # import numpy as np
    import sys
    sys.setrecursionlimit(10**7)
    from itertools import accumulate, combinations, permutations, product # https://docs.python.org/ja/3/library/itertools.html
    # accumulate() returns iterator! to get list: list(accumulate())
    from math import factorial, ceil, floor, sqrt
    def factorize(n):
        """return the factors of the Arg and count of each factor
        
        Args:
            n (long): number to be resolved into factors
        
        Returns:
            list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
        """
        fct = []  # prime factor
        b, e = 2, 0  # base, exponent
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct
    def combinations_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        # TODO: How should I do when n - r is negative?
        if n < 0 or r < 0:
            raise Exception('combinations_count(n, r) not defined when n or r is negative')
        if n - r < r: r = n - r
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
        return result
    def combinations_with_replacement_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        if n < 0 or r < 0:
            raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
        elif n == 0:
            return 1
        else:
            return combinations_count(n + r - 1, r)
    from bisect import bisect_left, bisect_right
    from collections import deque, Counter, defaultdict # https://docs.python.org/ja/3/library/collections.html#collections.deque
    from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
    from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
    import operator
    from operator import itemgetter #sort 
    # ex1: List.sort(key=itemgetter(1))
    # ex2: sorted(tuples, key=itemgetter(1,2))
    from functools import reduce, lru_cache
    def chmin(x, y):
        """change minimum
        if x > y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current minimum value
            y (long): potential minimum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x > y:
            x = y
            return (x, True)
        else:
            return (x, False)
    def chmax(x, y):
        """change maximum
        if x < y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current maximum value
            y (long): potential maximum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x < y:
            x = y
            return (x, True)
        else:
            return (x, False)

    from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
    def gcds(numbers):
        return reduce(gcd, numbers)
    def lcm(x, y):
        return (x * y) // gcd(x, y)
    def lcms(numbers):
        return reduce(lcm, numbers, 1)

    # first create factorial_list
    # fac_list = mod_factorial_list(n)
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    modpow = lambda a, n, p = MOD: pow(a, n, p) # Recursive function in python is slow!
    def modinv(a, p = MOD):
        # evaluate reciprocal using Fermat's little theorem:
        # a**(p-1) is identical to 1 (mod p) when a and p is coprime
        return modpow(a, p-2, p)
    def modinv_list(n, p = MOD):
        if n <= 1:
            return [0,1][:n+1]
        else:
            inv_t = [0,1]
            for i in range(2, n+1):
                inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
            return inv_t
    def modfactorial_list(n, p = MOD):
        if n == 0:
            return [1]
        else:
            l = [0] * (n+1)
            tmp = 1
            for i in range(1, n+1):
                tmp = tmp * i % p
                l[i] = tmp
            return l
    def modcomb(n, k, fac_list = [], p = MOD):
        # fac_list = modfactorial_list(100)
        # print(modcomb(100, 5, modfactorial_list(100)))
        from math import factorial
        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        if len(fac_list) <= n:
            a = factorial(n) % p
            b = factorial(k) % p
            c = factorial(n-k) % p
        else:
            a = fac_list[n]
            b = fac_list[k]
            c = fac_list[n-k]
        return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
    def modadd(a, b, p = MOD):
        return (a + b) % MOD
    def modsub(a, b, p = MOD):
        return (a - b) % p
    def modmul(a, b, p = MOD):
        return ((a % p) * (b % p)) % p
    def moddiv(a, b, p = MOD):
        return modmul(a, modpow(b, p-2, p))

    class UnionFindTree:
        """union find tree class
        TODO: fix this description...
        how to use (example):
        >>  uf = UnionFindTree(N) 
        >>  if uf.find_root(a) == uf.find_root(b):
        >>      do something
        >>  else:
        >>      do something
        >>      uf.unite(a, b)
        """
        def __init__(self, N):
            self.root = [-1] * (N+1)
            self.rank   = [0]  * (N+1)
            self.connected_num = [1] * (N+1)
    
        def find_root(self,x):
            root = self.root
            while root[x] != -1:
                x = root[x]
            return x
    
        def unite(self,x,y):
            root = self.root
            rank = self.rank
            connected_num = self.connected_num
            find_root = self.find_root
    
            rx = find_root(x)
            ry = find_root(y)
            if rx != ry:
                if rank[rx] < rank[ry]:
                    root[rx] = ry
                    rx,ry = ry,rx
                else:
                    if rank[rx] == rank[ry]:
                        rank[rx] += 1
                    root[ry] = rx       
                connected_num[rx] += connected_num[ry]

    """ initialize variables and set inputs
    # initialize variables
        # to initialize list, use [0] * n
        # to initialize two dimentional array, use [[0] * N for _ in range(N)]
    # set inputs
        # put inputs between specific values (almost as quickly)
        # ex) S = [-INF] + [int(r()) for _ in range(A)] + [INF]
        # open(0).read() is sometimes useful:
        # ex) n, m, *x = map(int, open(0).read().split())
        #     min(x[::2]) - max(x[1::2])
        # ex2) *x, = map(int, open(0).read().split())
        #     don't forget to add comma after *x if only one variable is used
    # preprocessing
        # transpose = [x for x in zip(*data)]
        # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
        # flat = [flatten for inner in data for flatten in inner]
        # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [1, 2, 3, 4, 5, 6, 7, 8, 9]
    # calculate and output
        # output pattern
        # ex1) print(*l) => when l = [2, 5, 6], printed 2 5 6
    """

    # functions used
    r = lambda: sys.stdin.readline().strip()
    r_int = lambda: int(r())
    R = lambda: list(map(int, r().split()))
    Rmap = lambda: map(int, r().split())
    Rfloat = lambda: list(map(float, r().split()))
    Rtuple = lambda: tuple(map(int, r().split()))

    """ how to treat input
    # single int: int(r())
    # single string: r()
    # single float: float(r())
    # line int: R()
    # line string: r().split()
    # line (str, int, int): [j if i == 0 else int(j) for i, j in enumerate(r().split())]
    # lines int: [R() for _ in range(n)]
    """

    if __name__ != '__main__':
        # for test
        sys.stdin = open('sample.txt')
        
    # ----------------------------------
    # main

    N = r()
    length = len(N)
    intN = int(N)
    ans = 0
    for i in range(1,length,2):
        ans += 9 * (10**(i-1))
    if length%2 != 0:
        ans += intN-10**(length-1) + 1
    print(ans)
    
    
    # end of main
    # ----------------------------------

    """memo: how to use defaultdict of list
    # initialize
    Dic = defaultdict(list)
    # append / extend
    Dic[x].append(y)
    # three methods for loop: keys(), values(), items()
    for k, v in Dic.items():
    """
    
    """memo: how to solve binary problems
    # to make binary digits text
    >>> a = 5
    >>> bin_str_a = format(a, '#06b')
    >>> print(bin_str_a)
    0b0101 # first 2 strings (='0b') indicates it is binary
    """
    
    """memo: how to solve the problem
    creating simple test/answer
    greed
    simple dp
    graph
    """

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
N = int(input())

cnt = 0
for i in range(N+1):
    if math.ceil(math.log10(i+1)) % 2 == 1:
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
keta = len(str(N))

ans = 0
for i in range(keta-1):
    if i % 2 == 0:
        ans += 10 ** i * 9
if keta % 2:
    ans += N - 10 ** (keta-1) + 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n+1):
    if i<10:
        ans+=1
    elif i>= 100 and i<1000:
        ans+= 1
    elif i>=10000 and i<100000:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n=input()
length=len(n)
if length==1:
    print(n)
elif length==2:
    print(9)
elif length==3:
    print(9+int(n)-99)
elif length==4:
    print(9+900)
elif length==5:
    print(9+900+int(n)-9999)
else:
    print(9+900+90000)

Submission status: Accepted

Solution code:
n = int(input())

count = 0

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

print(count)

Submission status: Accepted

Solution code:
N = int(input())

len_n = len(str(N)) # N <= 10 ^ 5 より len(N) <= 6

count = 0 

if len_n == 1:
  count += N
elif len_n == 2:
  count += 9
elif len_n == 3:
  count += 9
  count += (N - 99)
elif len_n == 4:
  count += 909
elif len_n == 5:
  count += 909
  count += (N - 9999)
elif len_n == 6:
  count += 90909
  
print(count)

Submission status: Accepted

Solution code:
# ABC136B - Uneven Numbers
def main():
    n = int(input())
    d = len(str(n))
    if d == 6:
        ans = 9 + 900 + 90000
    elif d == 5:
        ans = 9 + 900 + n - 9999
    elif d == 4:
        ans = 9 + 900
    elif d == 3:
        ans = 9 + n - 99
    elif d == 2:
        ans = 9
    elif d == 1:
        ans = n
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
if n < 10:
  print(n)
elif n < 100:
  print(9)
elif n < 1000:
  print(9+(n-99))
elif n < 10000:
  print(9+900)
elif n < 100000:
  print(9+900+(n-9999))
else:
  print(90909)

Submission status: Accepted

Solution code:
n = int(input())
s = list(map(str, range(n+1)))
s.pop(0)
# print(s)
# print(s[0],s[1])
count = 0
for i in range(n):
    if len(s[i])%2==1:
        count += 1
print(count)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


if __name__ == '__main__':
    n = int(input())
    num = 0
    for i in range(n):
        if len(str(i+1)) % 2 == 1:
            num += 1
    print(num)

Submission status: Accepted

Solution code:
n = int(input())
result = 0
for i in range(1, n + 1):
  if len(str(i)) % 2 == 1:
    result += 1
print(result)

Submission status: Accepted

Solution code:
n=int(input())
if n<10:print(n)
elif n<100:print(9)
elif n<10**3:print(n-90)
elif n<10**4:print(909)
elif n<10**5:print(n-9090)
else: print(90909)

Submission status: Accepted

Solution code:
N = int(input())
# print(N)
n = N
digit = 0
while n > 0:
    n //= 10
    digit += 1

# print(digit)

ans = 0
for i in range(digit - 1):
    if i % 2 == 0:
        ans += (10**(i + 1) - 10**i)

if digit % 2 == 1:
    ans += N + 1 - (10**(digit - 1))
print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())
#a, b, c = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#list = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
#s = [input() for i in range(n)]
#s = input()
#list = list(s)
#temp = [[0 for _ in range(13)] for _ in range(13)]

if (n // 10 == 0) :
    print(n)
elif (n // 100 == 0) :
    print(9)
elif (n // 1000 == 0) :
    print(n - 90)
elif (n // 10000 == 0) :
    print(909)
elif (n // 100000 == 0):
    print(n - 9090)
else :
    print(90909)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

for i in range(n+1):
  
    if 1<=i<=9:
      ans += 1
      continue
    if 100<=i<=999:
      ans += 1
      continue
    if 10000<=i<=99999:
      ans += 1
      continue
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
count = 0

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

print(count)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
count = 0

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

print(count)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())

A = len(str(N))
ans = 0

for a in range(A-1):
    if a % 2 != 0:
        continue
    ans += 9*10**a

if A % 2 != 0:
    ans += N - 10**(A-1) + 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

def digit_num(n):
    for i in range(1, 7):
        if n < 10 ** i:
            return i
    return 6

ans = 0
for i in range(1, N + 1):
    #print(i, digit_num(i))
    if (digit_num(i) % 2)== 1:
        ans += 1
        
print(ans)

Submission status: Accepted

Solution code:
n = input()
s = len(n)
n = int(n)

if s == 1:
    print(n)
elif s == 2:
    print(9)
elif s == 3:
    print(9 + n - 99)
elif s == 4:
    print(9 + 900)
elif s == 5:
    print(9 + 900 + n - 9999)
else:
    print(9 + 900 + 90000)

Submission status: Accepted

Solution code:
n = input()

if len(n) == 1:
    print(n)
elif len(n) == 2:
    print(9)
elif len(n) == 3:
    print(int(n) - 90)
elif len(n) == 4:
    print(909)
elif len(n) == 5:
    print(int(n) - 9999 + 909)
elif len(n) == 6:
    print(90909)

Submission status: Accepted

Solution code:
N = int(input())

if N <= 99:
    print(min(9,N))
    exit()

if N <= 9999:
    print(min(N - 99 + 9, 999 - 99 + 9))
    exit()

print(min(N - 9999 + 909, 90909))

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    ans = 0
    if n < 10:
        print(n)
        return

    ans = 9  # 1-9
    if n < 100:
        print(ans)
        return

    if n < 1000:
        ans += (n - 100 + 1)
        print(ans)
        return
    ans += 900  # 100-999

    if n < 10000:
        print(ans)
        return

    if n < 100000:
        ans += (n - 10000 + 1)
        print(ans)
        return
    ans += 90000  # 10000-99999

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = input()
n_keta = len(n)

if n_keta % 2 == 0:
    total = 0
    for i in range(n_keta // 2):
        total += 10 ** (2*i) * 9
else:
    total = 0
    for i in range(n_keta//2):
        total += 10 ** (2*i) * 9
    total += int(n) - 10 ** (n_keta-1) + 1
print(total)

Submission status: Accepted

Solution code:
n = input()
len_n = len(n)
if len_n == 1:
  print(int(n))
elif len_n == 2:
  print(9)
elif len_n == 3:
  n = int(n)
  print(n - 99 + 9)
elif len_n == 4:
  print(909)
elif len_n == 5:
  n = int(n)
  print(n - 9999 + 909)  
else:
  print(90909)

Submission status: Accepted

Solution code:
n=int(input())
if n<10:
	print(n)
elif n<100:
	print(9)
elif n<1000:
	print(9+n-99)
elif n<10000:
	print(9+900)
elif n<100000:
	print(909+n-9999)
else:
	print(90909)

Submission status: Accepted

Solution code:
n=int(input())
if n<100:
  print(min(9,n))
elif n<10000:
  print(min(909,n-90))
else:
  print(min(90909,n-9090))

Submission status: Accepted

Solution code:
N = int(input())
if N < 10:
  print(N)
elif N < 100:
  print(9)
elif N < 1000:
  print(9 + N - 99)
elif N < 10000:
  print(909)
elif N < 100000:
  print(909 + N - 9999)
else:
  print(90909)

Submission status: Accepted

Solution code:
n=input()
l=len(n)
c=0
if l%2==0:
  for i in range(1,l,2):
    c+=9*(10**(i-1))
  print(c)
else:
  m=int(n)
  d=m-(10**(l-1))+1
  c+=d
  for i in range(1,l-1,2):
    c+=9*(10**(i-1))
  print(c)

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
for i in range(1, N + 1):
    if 10 <= i <= 99 or 1000 <= i <= 9999 or i == 100000:
        continue
    else:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N=int(input())
s=str(N)
l=len(s)
if l==1:
    print(N)
elif l==2:
    print(9)
elif l==3:
    print(9+(N-99))
elif l==4:
    print(9+900)
elif l==5:
    print(9+900+(N-9999))
elif l==6:
    print(9+900+90000)

Submission status: Accepted

Solution code:
n=int(input())

if n<10:
    print(n)
elif n>=10 and n<100:
    print(9)
elif n>=100 and n<1000:
    print(9+(n-99))
elif n>=1000 and n<10000:
    print(909)
elif n>=10000 and n<100000:
    print(909+(n-9999))
else:
    print(90909)

Submission status: Accepted

Solution code:
N = int(input())

T = [9, 900, 90000]
L = len(str(N))

ans = sum(T[i] for i in range(L//2))
if L % 2 == 1:
    ans += N - (10 ** (L-1)) + 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
for i in range(1, n + 1):
    if len((str(i))) % 2 == 1:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = input()
ans = 0
for i in range(1,len(n)+1):
    if i % 2 == 1 and i != len(n):
        ans = ans + 10**i -10**(i-1)
    elif i %2 == 1:
        ans = ans + int(n) - 10**(i-1) + 1
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N < 10 :
    print(N)
    exit()

if N < 100 :
    print(9)
    exit()

if N < 1000 :
    print(9 + (N - 99))
    exit()

if N < 10000 :
    print(909)
    exit()

if N < 100000 :
    print(909 + (N - 9999))
    exit()

print(90909)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def even_digits(i):
    if (1 <= i <= 9) or (100 <= i <= 999) or (10000 <= i <= 99999) or (1000000 <= i <= 9999999):
        return True
    else: return False

def main(): 
    N = II()
    counter = 0
    for i in range(1, N+1):
        if even_digits(i):
            counter+=1
    print(counter)

main()

Submission status: Accepted

Solution code:
N=int(input())
if N>=100000:
    print(9+900+90000)
elif N>=10000:
    print(9+900+N-9999)
elif N>=1000:
    print(9+900)
elif N>=100:
    print(9+N-99)
elif N>=10:
    print(9)
else:
    print(N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
for i in range(1,n+1):
    if (i<10)or(100<=i<1000)or(10000<=i<100000):
        cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
ans=0
for i in range(int(input())+1):
	if 0 < i < 10:
		ans+=1
	elif 100 <= i < 1000:
		ans+=1
	elif 10000 <= i < 100000:
		ans+=1
	elif 1000000 <= i < 10000000:
		ans+=1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if 1 <= n <= 9:
    print(n)
elif 10 <= n <= 99:
    print(9)
elif 100 <= n <= 999:
    print(n-99+9)
elif 10**3 <= n <= 9999:
    print(909)
elif 10**4 <= n <= 99999:
    print(n-9999+909)
else:
    print(90909)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1,n+1):
    if(len(str(i)) % 2 == 1):
        ans += 1
        
print(ans)

Submission status: Accepted

Solution code:
import os,re
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations
from sys import stdin,setrecursionlimit
from copy import deepcopy
setrecursionlimit(10**6)

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

Submission status: Accepted

Solution code:
import sys, math

def main():
    N = int(input())

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

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N = int(input())

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

print(str(count))

Submission status: Accepted

Solution code:
import sys


N = int(sys.stdin.readline().rstrip())



# 1 <= N <= 10000

# 1 ~ 9 -> 9
# 100 ~ 999 -> 1000
# 10000 ~ 99999 -> 100000

a = range(1, N + 1)
A = [a for a in a if 1 <= a <= 9]
B = [a for a in a if 100 <= a <= 999]
C = [a for a in a if 10000 <= a <= 99999]
print(len(A) + len(B) + len(C))