Language: C++

#include<bits/stdc++.h>
using namespace std;

string ope(string s,long long kaisu){
  for(int i=0,m=1;i<kaisu;i+=m){
    if(s[i] == '2'){
      s.replace(i,1,'22');
      m=2;
    }else if(s[i] == '3'){
      s.replace(i,1,'333');
      m=3;
    }else if(s[i] == '4'){
      s.replace(i,1,'4444');
      m=4;
    }else if(s[i] == '5'){
      s.replace(i,1,'55555');
      m=5;
    }else if(s[i] == '6'){
      s.replace(i,1,'666666');
      m=6;
    }else if(s[i] == '7'){
      s.replace(i,1,'7777777');
      m=7;
    }else if(s[i] == '8'){
      s.replace(i,1,'88888888');
      m=8;
    }else if(s[i] == '9'){
      s.replace(i,1,'999999999');
      m=9;
    }
  }
  return s;
}

int main(){
  string s; cin>>s;
  int k; cin>>k;
  ope(s,5000000000000000);
  cout<<s[k-1]<<endl;
}
  

Compiler output:
a.cc:7:21: warning: multi-character character constant [-Wmultichar]
    7 |       s.replace(i,1,'22');
      |                     ^~~~
a.cc:10:21: warning: multi-character character constant [-Wmultichar]
   10 |       s.replace(i,1,'333');
      |                     ^~~~~
a.cc:13:21: warning: multi-character character constant [-Wmultichar]
   13 |       s.replace(i,1,'4444');
      |                     ^~~~~~
a.cc:16:21: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
   16 |       s.replace(i,1,'55555');
      |                     ^~~~~~~
a.cc:19:21: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   19 |       s.replace(i,1,'666666');
      |                     ^~~~~~~~
a.cc:22:21: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
   22 |       s.replace(i,1,'7777777');
      |                     ^~~~~~~~~
a.cc:25:21: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   25 |       s.replace(i,1,'88888888');
      |                     ^~~~~~~~~~
a.cc:28:21: warning: multi-character literal with 9 characters exceeds 'int' size of 4 bytes
   28 |       s.replace(i,1,'999999999');
      |                     ^~~~~~~~~~~
a.cc: In function 'std::string ope(std::string, long long int)':
a.cc:7:16: error: no matching function for call to 'std::__cxx11::basic_string<char>::replace(int&, int, int)'
    7 |       s.replace(i,1,'22');
      |       ~~~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:2275:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (near match)
 2275 |       replace(size_type __pos, size_type __n1, const _CharT* __s)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2275:7: note:   conversion of argument 3 would be ill-formed:
a.cc:7:21: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
    7 |       s.replace(i,1,'22');
      |                     ^~~~
      |                     |
      |                     int
/usr/include/c++/14/bits/basic_string.h:2413:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(const_iterator, const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2413 |         replace(const_iterator __i1, const_iterator __i2,
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2413:9: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2522:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2522 |         replace(size_type __pos, size_type __n, const _Tp& __svt)
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2522:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]':
/usr/include/c++/14/bits/basic_string.h:149:8:   required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = int; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  149 |         using _If_sv = enable_if_t<
      |               ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2522:2:   required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::replace(size_type, size_type, const _Tp&) [with _Tp = int]'
 2522 |         replace(size_type __pos, size_type __n, const _Tp& __svt)
      |         ^~~~~~~
a.cc:7:16:   required from here
    7 |       s.replace(i,1,'22');
      |       ~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/type_traits:2711:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>'
 2711 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:2540:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _Tp&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2540 |         replace(size_type __pos1, size_type __n1, const _Tp& __svt,
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2540:9: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2562:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(const_iterator, const_iterator, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2562 |         replace(const_iterator __i1, const_iterator __i2, const _Tp& __svt)
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2562:9: note:   template argument deduction/substitution failed:
a.cc:7:17: note:   cannot convert 'i' (type 'int') to type 'std::__cxx11::basic_string<char>::const_iterator'
    7 |       s.replace(i,1,'22');
      |                 ^
/usr/include/c++/14/bits/basic_string.h:2200:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2200 |       replace(size_type __pos, size_type __n, const basic_string& __str)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2200:67: note:   no known conversion for argument 3 from 'int' to 'const std::__cxx11::basic_string<char>&'
 2200 |       replace(size_type __pos, size_type __n, const basic_string& __str)
      |                                               ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:2223:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2223 |       replace(size_type __pos1, size_type __n1, const basic_string& __str,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2223:7: note:   candidate expects 5 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2249:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2249 |       replace(size_type __pos, size_type __n1, const _CharT* __s,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2249:7: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2300:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2300 |       replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2300:7: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2319:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 2319 |       replace(__const_iterator __i1, __const_iterator __i2,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2319:32: note:   no known conversion for argument 1 from 'int' to 'std::__cxx11::basic_string<char>::__const_iterator' {aka 'std::__cxx11::basic_string<char>::const_iterator'}
 2319 |       replace(__const_iterator