Mycode:
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
typedef long long ll;
string now;
ll n;
int len(ll m)
{
if(m<=9)return 1;
else if(m<=99)return 2;
else if(m<=999)return 3;
else if(m<=9999)return 4;
else if(m<=99999)return 5;
else if(m<=999999)return 6;
else if(m<=9999999)return 7;
else if(m<=99999999)return 8;
else return 9;
}
int main()
{
while(~scanf("%lld",&n))
{
now="";
ll m=1;
ll sum=0;
while(1)
{
now+=std::to_string(m);
m++;
if(sum+now.size()<n)
{
sum+=now.size();
}
else if(sum+now.size()==n)
{
cout<<now[now.size()-1]<<endl;
break;
}
else
{
ll pos=n-sum;
cout<<now[pos-1]<<endl;
break;
}
}
}
return 0;
}