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

Solution in Rust (1.15.1) (judge verdict: Accepted)

#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn keta(n: i32) -> u32 {
    let mut x = n;
    let mut cnt: u32 = 0;
    while x != 0 {
        x /= 10;
        cnt += 1;
    }
    return cnt;
}
fn main() {
    let n = get!(i32);
    if n < 10 {
        println!("{}", n);
        return;
    } else if n < 100 {
        println!("9");
        return;
    }
    let keta = keta(n);
    // eprintln!("n: {}", n);
    // eprintln!("keta: {}", keta);
    let mut ans = 0;
    if keta % 2 == 0 {
        let mut odd = keta + 1;
        // eprintln!("{}", odd);
        while 0 < odd {
            odd -= 2;
            if odd == 1 {
                ans += 9;
                break;
            }
            ans += 9 * 10_i32.pow(odd - 1);
        }
    } else {
        let minus = 10_i32.pow(keta - 1);
        // eprintln!("minus: {}", minus);
        ans += n - (minus - 1);
        // eprintln!("ans: {}", ans);
        let mut odd = keta;
        while 0 < odd {
            odd -= 2;
            if odd == 1 {
                ans += 9;
                break;
            }
            ans += 9 * 10_i32.pow(odd - 1);
        }
    }
    println!("{}", ans);
}