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:


def main():

    N = int(input())
    one=9
    hun=900
    man=90000

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




    
if __name__== "__main__":
    main()

Submission status: Accepted

Solution code:
N = input()

buff = int(N)
N = list(N)
# N = N[::-1]
keta = len(N)
ans = 0
if keta % 2 == 0:
    gain = 1
    for i in range(0, keta-1, 2):
        ans += (9*gain)
        gain = gain * 100

    print(ans)

else:
    if keta == 1:
        print(N[0])
        exit()

    gain = 1
    for i in range(0, keta-1, 2):
        ans += (9*gain)
        gain = gain * 100

    gg = 9
    for i in range(keta-2):
        gg *= 10
        gg += 9
    # print(gg)
    ans += buff-gg
    print(ans)

Submission status: Accepted

Solution code:
a = int(input())
if a <10:
  print("{}".format(a))
elif a <100:
  print("9")
elif a < 1000:
  print("{}".format(9+a-99))
elif a < 10000:
  print('909')
elif a < 100000:
  print("{}".format(909+a-9999))
else:
  print('90909')

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
i = 0

while N >= 10**(i+1):
    if i%2 == 0:
        ans += 10**(i+1)- 10**i
    i += 1

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

Submission status: Accepted

Solution code:
n=int(input())
if n<10:
	kazu=n
else:
	if n<100:
		kazu=9
	else:
		if n<1000:
			kazu=n-90
		else:
			if n<10000:
				kazu=909
			else:
				if n<100000:
					kazu=n-9090
				else:kazu=90909
print(kazu)

Submission status: Accepted

Solution code:
#find number range

N = int(input())

range_num = 0
odd_num = 0

for i in range(7):
    if N % (10 ** i) == N:
        range_num = i
        break

if range_num == 1:
    odd_num = N
elif range_num == 2:
    odd_num = 9
elif range_num == 3:
    odd_num = N - 90
elif range_num == 4:
    odd_num = 909
elif range_num == 5:
    odd_num = N-9090
elif range_num == 6:
    odd_num = 90909
else:
    print("out of range")

print(odd_num)

Submission status: Accepted

Solution code:
n = int(input())

if len(str(n)) % 2 == 0:
  print(int("90" * int(len(str(n)) / 2 - 1) + "9"))
elif len(str(n)) == 1:
  print(n)
else:
  print(n - int("9" * (len(str(n)) -1)) + int("90" * (int((len(str(n)) - 1) / 2) - 1) + "9"))

Submission status: Accepted

Solution code:
n = int(input())

base = 1
odd = False

ans = 0

while  n >= base:
    if odd:
        pass
    else:
        if n >= (base * 10):
            ans += (base * 10 - base)
        else:
            ans += n - base + 1
    base *= 10
    odd = not odd

print(ans)

Submission status: Accepted

Solution code:
n=input()
count=0
if len(n)==1:
  count=int(n)
if len(n)==2:
  count+=9
if len(n)==3:
    count+=(int(n)//100-1)*100+int(n)%100+10
if len(n)==4:
    count+=909
if len(n)==5:
      count+=(int(n)//10000-1)*10000+int(n)%10000+910
if len(n)==6:
      count+=90909
print(count)

Submission status: Accepted

Solution code:
import math

N = int(input())
ans = int(0)
s = math.ceil(math.log10(N+1))


if s == 1:
    ans = N
elif s==2:
    ans = 9
elif s==3:
    ans = (N//100-1)*100+N%100+10
elif s==4:
    ans = 909
elif s==5:
    ans = (N//10000-1)*10000+N%10000+910
elif s==6:
    ans = 90909


print(ans)

Submission status: Accepted

Solution code:
num=int(input())
if len(str(num)) %2 != 0:
  if len(str(num))==7:
    print(num-999999+90000+900+9)
  elif len(str(num))==5:
    print(num-9999+900+9)
  elif len(str(num))==3:
    print(num-99+9)
  elif len(str(num))==1:
    print(num)
else:
  if len(str(num))==8:
    print(9000000+90000+900+9)
  elif len(str(num))==6:
    print(90000+900+9)
  elif len(str(num))==4:
    print(900+9)
  elif len(str(num))==2:
    print(9)

Submission status: Accepted

Solution code:
#coding:utf-8
N = input()
lenN = len(N)
N = int(N)
ls = [N, 9 , N -90, 909, N-9090, 90909]
print (ls[lenN-1])

Submission status: Accepted

Solution code:
import sys
import collections
import copy
input = sys.stdin.readline
N=int(input())
ans = 0
for i in range(N):
    if int(len(str(i+1)))%2 ==1:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

one = n % 10
hund = n // 100
thou = n // 1000
cnt = 0

if  n < 10:
    cnt += n

elif 100 > n >= 10:
    cnt += 9

elif 1000 > n >= 100:
    cnt += (n - 99) + 9

elif 10000 > n >= 1000:
    cnt += 909

elif 100000 > n >= 10000:
    cnt += (n - 9999) + 909

elif n == 100000:
    cnt += 90909

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
digit = len(str(n))
if digit%2 != 0:
    if digit == 1:
        print(n)
    elif digit == 3:
        print(n-90)
    else:
        print(n-10000+900+10)
else:
    if digit == 2:
        print(9)
    elif digit == 4:
        print(909)
    else:
        print(90909)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
count = 0
a = int(input())
for row in range(a):
	if len(str(row + 1)) % 2 == 0:
		pass
	else:
		count += 1
print(count)

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:
import math
N = int(input())

#Nの桁数
a = int(math.log10(N))
count = 0

for x in range(1, N+1):
    # yはxの桁数
    y = int(math.log10(x) + 1)
    if y % 2 == 1:
        count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

# 数値への変換
n = int(stdin.readline().rstrip())

def main():
    keta = len(str(n))
    odd = [ i for i in range(1,(n + 1)) if len(str(i)) % 2 != 0 ]
    print("{}".format(len(odd)))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())

if 1<=N and N<=9:
  result=N
elif 10<=N and N<100 :
  result=9
elif 100<= N and N<1000:
  result=N-90
elif 1000<=N and N<10000:
  result=909
elif 10000<=N and N<100000:
  result=N-9090
elif N==100000:
  result=90909
  
print(result)

Submission status: Accepted

Solution code:
def main():
    N = input()
    i = 0
    while int(N) >0:
        if len(N) % 2 != 0:
            i+=1
        N = int(N) -1
        N = str(N)
    print(i)
main()

Submission status: Accepted

Solution code:
n = input()
keta = len(n)
N = int(n)
#print(keta)                                                                   
k = 0

if keta == 1:
    k = N
elif keta % 2 == 0:
    for i in range(keta):
        if (i+1) % 2 == 0:
            continue
        k += 9*(10**i)
    #print(int(n[0]))                                                          
else:
    for i in range(keta-1):
#        print("i = {}".format(i+1))                                           
        if (i+1) % 2 == 0:
            continue
        k += 9*(10**i)
#        print(k)                                                              
    minus = (10**(keta-1))
 #   print(minus)                                                              
    k += (N-minus+1)
print(k)

Submission status: Accepted

Solution code:
n = input()

count = 0

l = len(n)

if l % 2:
  num = n[0:l]
  tmp = 1
  for i in range(l-1):
    tmp *= 10
  count += int(num) - tmp + 1
  l -= 1

for i in range(l):
  tmp = 1
  if (i+1) % 2:
    for j in range(i+1):
      tmp *= 10
    tmp -= int(float(tmp) / float(10))
    count += tmp
    
print(count)

Submission status: Accepted

Solution code:
n_str = 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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
count = 0
# 10万までだから無理やり解く...
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())
     
cnt = 0
for i in range(1, n+1):
    str_n = str(i)
    if len(str_n) % 2 != 0:
        cnt += 1
            
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

print(len([i for i in range(1, N + 1) if len(str(i)) % 2 == 1]))

Submission status: Accepted

Solution code:
n = int(input())
digit = len(str(n))

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

if digit % 2 == 1:
  count += n - 10 ** (digit - 1) + 1

print(count)

Submission status: Accepted

Solution code:
N = int(input())
v = 0
if N >= 10:
    v += 9
    if N >= 100:
        if N >= 1000:
            v += 900
            if N >= 10000:
                if N >= 100000:
                    v += 90000
                    if N >= 1000000:
                        pass
                else:
                    v += N % 100000 - 10000 + 1
        else:
            v += N % 1000 - 100 + 1
else:
    v += N % 10
print(v)

Submission status: Accepted

Solution code:
N = input().strip()
N = N + "."  # for removing the leading zeroes just in case
N.strip("0")
N = N[:-1]
total = 0
for i in range(1, len(N), 2):
    total += int("1"+"0"*i) - int("1"+"0"*(i-1))
if len(N) % 2 == 0:
    total += 0
else:
    total += int(N) - (int("1" + "0" * (len(N) - 1))) + 1
print(total)

Submission status: Accepted

Solution code:

n = int(input())
count = 0
lenn = len(str(int(n)))
if lenn == 1:
    count += n
else:
    for i in range(1,lenn+1):
        if i == 1:
            count += 9
        elif i == lenn:
            if i % 2 == 0:
                pass #count += n - (10**(i-1)) -1
            else:
                count += n - (10**(i - 1)) + 1
        elif i % 2 == 0:
            pass
        else:
            count += ((10**i) - 1) - (10**(i-1)) + 1
        
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num =  int(input())
cnt = 0

for i in range(num,0,-1) :
    if(len(str(i))%2 != 0):
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N = int(raw_input())
ans = 0
for x in xrange(1, N+1):
    if len(str(x)) % 2:
        ans += 1
print ans

Submission status: Accepted

Solution code:
N = int(input())

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

print(num)

Submission status: Accepted

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


N = int(input())

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

print("{}".format(count))

Submission status: Accepted

Solution code:
n = int(input())

l = len(str(n))

ans=0

if l==1:
    ans=n
elif l==2:
    ans=9
elif l==3:
    ans=n-90
elif l==4:
    ans=909
elif l==5:
    ans=n-9090
elif l==6:
    ans=90909
    

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=input()
i=int(len(N))
N=int(N)
#print(N,i)
x=0
if i%2!=0:
    x=N-10**(i-1)+1
    i=i-1
    if i!=0:
        while i>0:
            i=i-2
            x=x+9*(10**i)
else:
    if N<10:
        x=N
    else:
        while i>1:
            x=x+9*(10**(i-2))
            #print(i)
            i=i-2

print(x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
keta_half = keta // 2

if keta_half > 0:
    if keta % 2 == 0:
        for i in range(keta_half):
            ans += 9 * 10 ** (2*i)
    else:
        for i in range(keta_half):
            ans += 9 * 10 ** (2*i)
        
        zan = int(N) - 10 ** (keta-1)  + 1
        ans += zan
else:
    ans = int(N)

print(ans)

Submission status: Accepted

Solution code:
import math


def main():
    n = int(input())
    ans = 0
    for i in range(1, n + 1):
        if math.log(i, 10) % 2 // 1 == 0 and i != 1000:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
l = int((len(str(n))+1)/2)
s = 0
for i in range(1,l):
  s += 10**(2*i-1)-10**(2*i-2)
k = len(str(n))
if k == l*2:
  s += 10**(2*l-1)-10**(2*l-2)
else:
  s += n+1-10**(2*l-2)
print(s)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
a=int(input())
b = min(a,9)
if a>=100:
    b += min(a-99,900)
if a>=10000:
    b += min(a-9999,90000)
if a>=1000000:
    b += min(a-999999,9000000)
print(b)

Submission status: Accepted

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

for i in range(1, 10):
  if i > N:
    break
  else:
    ans += 1

for i in range(100, 1000):
  if i > N:
    break
  else:
    ans += 1

for i in range(10000, 100000):
  if i > N:
    break
  else:
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

if len(str(n)) == 1:
  print(n)
elif len(str(n)) == 2:
  print(9)
elif len(str(n)) == 3:
  print(9+n-99)
elif len(str(n)) == 4:
  print(9+900)
elif len(str(n)) == 5:
  print(9+900+n-9999)
elif len(str(n)) == 6:
  print(90909)

Submission status: Accepted

Solution code:
n = input()
if(len(n) == 1):
    print(n)
    exit()
ans = 0
if len(n) % 2:
    ans += int(n) - 10 ** (len(n) - 1) + 1
    print(str(int('90' * ((len(n) - 3) // 2) + '9') + ans))

else:
    print(str(int('90' * ((len(n) - 2) // 2) + '9')))

Submission status: Accepted

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

# print(l)
temp=''
ans=0

if l==1:
	print(int(n))
else:
	for i in range(1,l):
		if i%2==1:
			temp='9'
			temp+='0'*(i-1)
			ans+=int(temp)
			# print(ans)

	if l%2==1:
		ans+=(int(n)-int('9'*(l-1)))

	print(ans)

Submission status: Accepted

Solution code:
import math

N=int(input())

keta=0
while N>=math.pow(10,keta):
	keta += 1

count=0
if keta%2==1:
	count = N-int(math.pow(10,keta-1))+1
	keta -= 1
while keta>=2:
	count += 9*int(math.pow(10,keta-2))
	keta -= 2

print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())

cnt = 0
for i in range(n):  
    i += 1
    if len(str(i))%2 != 0:
        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 != 0:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
sum = 0
if n//10!=0:
  sum+=9
  if n//1000!=0:
    sum+=900
    if n//100000!=0:
      sum+=90000
    elif n//10000!=0:
      sum+=n-9999
  elif n//100!=0:
    sum+=n-99
else:
  sum+=n
print(sum)

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())
answer=0
for i in range(6):
  if n/(10**i)>=1:
    if i%2==1:
      answer+=10**i-(10**(i-1))
  else:
    if i%2==1:
      answer+=(n-(10**(i-1))+1)
    break
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

numOfDigit = 1
answer = 0

n = 1
while(N >= n * 10):
    if (numOfDigit % 2):
        answer += n * 9
    numOfDigit += 1
    n *= 10

if (numOfDigit % 2):
    answer += N % (n * 10) - n + 1

print(answer)

Submission status: Accepted

Solution code:
N = int(input())
n = len(list(str(N)))
cnt = 0
if n==1:
    print(N)
else:
    for i in range(n//2):
        cnt += 9 * (10 ** (2 * i))  
    if n%2==1:
        cnt += N - (10 ** (2 * (n//2))) + 1
    print(cnt)

Submission status: Accepted

Solution code:
N = input()
if len(N) == 1:
    print(N)
elif len(N) == 2:
    print(9)
elif len(N) == 3:
    print(9 + int(N[0])*100 - 100 + int(N[1:]) + 1)
elif len(N) == 4:
    print(9 + 900)
elif len(N) == 5:
    print(9 + 900 + 10000*int(N[0]) - 10000 + int(N[1:]) + 1)
elif len(N) == 6:
    print(9 + 900 + 90000)

Submission status: Accepted

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

N = input()
K = int(len(N))
A = 0

if K % 2 == 0:
	for i in range(0,K,2):
		A += 9 * 10 ** i
elif K == 1:
	A = N
else:
	for i in range(0,K - 1,2):
		A += 9 * 10 ** i

if K % 2 != 0 and K != 1:
	A += int(N) - 10**(K - 1) + 1

print(A)

Submission status: Accepted

Solution code:
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    str_n = input()
    n = int(str_n)
    len_n = len(str_n)
    if len_n % 2 == 0:
        if len_n == 6:
            print(90909)
        elif len_n == 4:
            print(909)
        else:
            print(9)
    else:
        if len_n == 5:
            print(909 + n - 10000 + 1)
        elif len_n == 3:
            print(9 + n - 100 + 1)
        else:
            print(n)

# nが奇数桁の場合
# 　より小さい桁の奇数桁の個数 + 今の桁で今の数までの個数
# nが偶数桁の場合
# 　より小さい桁の奇数桁の個数
# 1 9
# 3 900
# 5 90000

Submission status: Accepted

Solution code:
N=input()
C=len(N)

if C % 2 == 0:
  a ="09"
  a=a*(int(C/2))
  print(int(a))
elif C==1:
  print(int(N))
else:
  e = int(N)-10**(C-1)+1
  a = "09"
  a = a * (int((C-1)/2))
  print(int(a)+e)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a = int(input())
if ((a > 0) & (a < 100001)):
    data_size = int (math.log10(a) + 1)
    if a == 100000:
        print(90909)
    elif data_size == 5:
        print(a - 10000 + 1 + 909)
    elif data_size == 4:
        print(909)
    elif data_size == 3:
        print(a - 100 + 1 + 9)
    elif data_size == 2:   
        print(9)
    elif data_size == 1:   
        print(a - 1 + 1)

Submission status: Accepted

Solution code:
N = int(input())

if N < 10:
    print(N)
elif 10 <= N and N < 100:
    print(9)
elif 100 <= N and N < 1000:
    ans = 9 + N - 99
    print(ans)
elif 1000 <= N and N < 10000:
    ans = 9 + 999 - 99
    print(ans)
elif 10000 <= N and N < 100000 :
    ans = 909 + N - 9999
    print(ans)
elif N == 100000 :
    ans = 909 + 99999 - 9999
    print(ans)

Submission status: Accepted

Solution code:
import sys

#+++++
		
def main():
	n = int(input())
	l=[i for i in range(n) if len(str(i+1)) % 2 == 1]
	print(len(l))
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

Solution code:
N = int(input())

keta = len(str(N))
if keta%2 == 0:
    N = 10**(keta-1)-1
total = N
keta = len(str(N))
if keta == 3:
    total -= 90
elif keta == 5:
    total -= 100000-90910

print(total)

Submission status: Accepted

Solution code:
N= int(input())
N_length = len(str(N))
if(N_length == 1):
  print (int(N))
elif(N_length == 2):
  print (9)
elif(N_length == 3):
  print (9+N-100+1)
elif(N_length == 4):
  print (9 +900)
elif(N_length == 5 ):
  print (9+900 + N - 10000 + 1)
elif(N_length == 6):
  print (9+900 + 90000)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n=input()
keta = len(n)
keta_num = 0
for k in range(1,keta):
    if(k%2==1):
        keta_num += (10**k)-(10**(k-1))
if(keta%2==1):
    n_int = int(n)
    keta_num += n_int - (10**(keta-1))+1
if(keta==1):    
    print(int(n))
else:
    print(keta_num)

Submission status: Accepted

Solution code:
"""
https://atcoder.jp/contests/abc136/tasks/abc136_b
"""

import math

import numpy as np


def calc(N: int) -> int:
    if N == 0:
        return 0

    keta_suu = calc_ketasuu(N)

    # Nが奇数桁ならその桁の分を考慮
    max_keta_count = N - 10 ** (keta_suu - 1) + 1 if is_odd(keta_suu) else 0

    # i 桁
    other_keta_count = 0
    for keta in range(keta_suu):
        if not is_odd(keta):
            continue
        other_keta_count += 10 ** keta - 10 ** (keta - 1)

    return max_keta_count + other_keta_count


def calc_ketasuu(value: int) -> int:
    return int(math.log10(value) + 1)


def is_odd(value: int) -> bool:
    return value % 2 == 1


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    N, = load_input_as_int_array()
    result = calc(N)
    print(result)


main()

Submission status: Accepted

Solution code:
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())

digit_num = len(str(N))

ans = 0

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

for i in reversed(range(1,digit_num)):
    if i % 2 != 0:
        ans += 9*(10**(i-1))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input()) #目的

ans = 0
#print(len(str(10)) % 2)
for num in range(1,N+1):
  #print(len(nem))
  if int(len(str(num))) % 2 == 1:
     ans += 1
      
print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())
count = 0
for i in range(1, 6):
    if N-(10**i) < 0:
        break;
    else:
        count += 1
if count == 0:
    p = N
elif count == 1: 
    p = 9
elif count == 2:
    p = 9 + N - 100 + 1
elif count == 3:
    p = 909
elif count == 4:
    p = 909 + N - 10000 + 1
else:
    p = 90909
print(p)

Submission status: Accepted

Solution code:
n = int(input().split()[0])

str_n = str(n)
keta = len(str_n)

c = 0
keta_list = list(range(0, 6))
keta_list.reverse()

# 1の桁
if 1 <= n < 10:
    c += n
else:
    c += 9

# 100の桁
if n >= 100:
    # 100 - 999
    if n <= 999:
        # print('100 - 999')
        c += (n - 99)
    else:
        # 1000 -
        # print('100 -')
        c += 900 # 100から999 までの数

# 10000の桁
if n >= 10000:
    if n <= 99999:
        # 10000 - 99999
        # print('10000 - 99999')
        # print('+ {}'.format(n-9999))
        c += n - 9999
    else:
        # 10000以上
        # print('10000以上')
        c += 90000 # 1000から99999までの個数

print(c)

Submission status: Accepted

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

if len == 1:
  print(n)
elif len == 2:
  print(9)
elif len == 3:
  print(n - 90) # 2桁の数は90こ
elif len == 4:
  print(909) # 999 - 90
elif len == 5:
  print(n - 90 - 9000) # 4桁の数は (9999 - 999)
elif len == 6:
  print(90909)

Submission status: Accepted

Solution code:
n = int(input())

if n >= 1 and n < 10:
  print(n)
elif n >= 10 and n < 100:
  print(9)
elif n >= 100 and n < 1000:
  print(n - 90)
elif n >= 1000 and n < 10000:
  print(909)
elif n >= 10000 and n < 100000:
  print(n - 9090)
elif n == 100000:
  print(90909)

Submission status: Accepted

Solution code:
N = int(input())
O = str(N)
if(len(O) == 1):
    print(N)
elif(len(O) == 2):
    print(9)
elif(len(O) == 3):
    print(N-90)
elif(len(O) == 4):
    print(909)
elif(len(O) == 5):
    print(N-9090)
else:
    print(90909)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    #A, B, C = [int(f) for f in input().split()]
    N = int(input())

    length = len(str(N))
    counter = 0
    if length < 3:
        for _ in range(1, min(10, N+1)):
            counter += 1
    elif length < 5:
        counter = 9
        for _ in range(100, min(1000, N+1)):
            counter += 1
    else:
        counter = 909
        for _ in range(10000, min(100000, N+1)):
            counter += 1
    
    print(counter)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a = int(input())
l = len(str(a))

ans = 0
if l % 2 == 0:
    while l >= 1:
        ans += (10 ** (l - 1) - 1) - (10 ** (l - 2) - 1)
        l -= 2
else:
    ans += a - (10 ** (l - 1) - 1)
    l -= 1
    while l >= 1:
        ans += (10 ** (l - 1) - 1)  - (10 ** (l - 2) - 1)
        l -= 2

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
L = len(str(n))



answer = 0
k = 0
if L == 1:
    print(n)
    
if L % 2 == 0:
    for i in range(1, L,2):
        answer += 9*10**(i-1)
    print(answer)

if L % 2 == 1 and not L ==1:
    
    for j in range(1, L,2):
        answer += 9*10**(j-1)
    k = answer + n - 10**(L-1) + 1
    print(k)

Submission status: Accepted

Solution code:
n = int(input())

if n < 10:  # < 10^1
    # 1-n
    print(n)

elif n < 100:  # < 10^2
    # 1-9
    print(9)

elif n < 1000:  # < 10^3
    # 1-9, 100-n
    print(n-99+9)

elif n < 10000:  # < 10^4
    # 1-9, 100-999
    print(9+900)

elif n < 100000:  # < 10^5
    # 1-9 + 100-999 + 10000-n
    print(n-9999+900+9)

else:  # == 10^5
    # 1-9 + 100-999 + 10000-90000
    print(9+900+90000)

Submission status: Accepted

Solution code:
N = int(input())

lv1 = 10
lv2 = 1000
lv3 = 100000

mod1 = 100
mod2 = 10000

if (N / mod1 < 1):
    if (N < lv1):
        print(N)
    else:
        print(lv1 - 1)
elif (N / mod2 < 1):
    if (N < lv2):
        print(N - (mod1 - 1) + (lv1 - 1))
    else:
        print(lv2 - mod1 + lv1 - 1)
else:
    if (N < lv3):
        print(N - (mod2 - 1) + lv2 - mod1 + lv1 - 1)
    else:
        print(lv3 - mod2 + lv2 - mod1 + lv1 - 1)

Submission status: Accepted

Solution code:
A = int(input())

retval = 0
if (A == 100000):
  A = A-1
  
if (A >= 10000):
  retval += A-9999
  A = 9999
 
if (A >= 1000):
  A = 999

if (A>=100):
  retval += A-99
  A = 99
  
if (A>=10):
  A = 9
 
retval += A
print(retval)

Submission status: Accepted

Solution code:
n = int(input())
if n < 10:
  r = n
elif n < 10**2:
  r = 9
elif n < 10**3:
  r = n-99 + 9
elif n < 10**4:
  r = 999-99 + 9
elif n < 10**5:
  r = n-9999 + 999-99 + 9
elif n == 10**5:
  r = 99999-9999 + 999-99 + 9

print(r)

Submission status: Accepted

Solution code:
n=int(input())

k=str(n)
ans=0

for i in range(1,len(k),2):
  s="9"
  s*=i
  ans+=int(s)-int(s)//10
    
if(len(k)%2==1):
	m=pow(10,len(k)-1)
	ans+=n-m+1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

count = 0

if N < 10:
    print(N)
elif N < 100:
    print(9)
elif N < 1000:
    print(9 + min(N,999) - 100 + 1)
elif N < 10000:
    print(9 + 900)
elif N < 100000:
    print(9 + 900 + min(N , 99999) - 10000 + 1)
else:
    print(90909)

Submission status: Accepted

Solution code:
N = int(input())
count = 0
for i in range(1, N + 1):
    if 1 <= i <= 9: count += 1
    elif 100 <= i <= 999: count += 1
    elif 10000 <= i <= 99999: count += 1
print(count)

Submission status: Accepted

Solution code:

N = int(input())

N_len = len(list(str(N)))

def sn(n):
    if n==1:
        return 9
    else:
        return 9 * (1-100**n)//(1-100)

N_len_fix = (N_len+1)//2
if N_len%2==0:
    print(sn(N_len_fix))
else:
    print(sn(N_len_fix-1) + N - 10**(N_len-1)+1)

Submission status: Accepted

Solution code:
n = int(input())

c = 0
t = n
while t // 10 != 0:
    c += 1
    t = t // 10

ans = 0
if c == 0:
    ans = n
elif c == 1:
    ans = 9
elif c == 2:
    ans = n - 99 + 9
elif c == 3:
    ans = 909
elif c == 4:
    ans = n - 9999 + 909
else:
    ans = 90909

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,N+1):
	if 0 < i <= 9:
		count += 1
	elif 100 <= i <= 999:
		count += 1
	elif 10000 <= i <= 99999:
		count += 1

print(count)

Submission status: Accepted

Solution code:
N = int(input())

count = 0
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-10000+1)
else:
  print(909+100000-10000)

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    N = stdin.readline().rstrip()
    N_num = int(N)

    if len(N) == 1:
        print(N_num)

    elif len(N) == 2:
        print(9)

    elif len(N) == 3:
        print((N_num % 100) + (N_num//100-1)*100 + 10)

    elif len(N) == 4:
        print(909)

    elif len(N) == 5:
        print((N_num % 10000) + (N_num//10000-1)*10000 + 910)

    elif len(N) == 6:
        print(90909)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

X = len(str(N))

if X == 1:
    print(N)
elif X == 2:
    print(9)
elif X == 3:
    print(9 + (N - 100 + 1))
elif X == 4:
    print(909)
elif X == 5:
    print(9 + 900 + (N - 10000 + 1))
elif X == 6:
    print(90909)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(0, 6, 2):
  if i == 0:
    low = 1
  else:
    low = 10 ** i
  up = 10 ** (i + 1 ) - 1
  
  if up <= n:
    ans += up - low + 1
  else:
    if low <= n:
      ans += n - low + 1
    break
    
print(ans)