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 C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int ans = 0;
        for (int i = 1; i <= N; i++) {
            if (i.ToString().Length % 2 == 1) ans++;
        }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 0) return 1;
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
}
public class MinTree
{
    private List<int> table = new List<int>();
    private static int size = 1;
    private static int high = 1;
    public MinTree(int n, int k = 0)
    {
        while (size < n) size *= 2;
        high = (int)Math.Log(size, 2);
        for (int i = 0; i < 2 * size - 1; i++) table.Add(k);
    }
    public void Add(int x, int v)
    {
        x += size - 1;
        table[x] += v;
        table[x] = Math.Max(0, table[x]);
        while (x != 0)
        {
            x = (x % 2 == 0 ? x / 2 - 1 : x / 2);
            table[x] = table[x * 2 + 1] + table[x * 2 + 2];
        }
    }
    public int MLS(int k)
    {
        if (table.First() == 0) return -1;
        int index = 0;
        for (int y = 0; y < high; y++)
        {
            int left = index * 2 + 1;
            int right = index * 2 + 2;
            if (table[left] >= k) index = left;
            else { k -= table[left]; index = right; }
        }
        return index - size + 1;
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}