Language: C++

#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  string S;
  int K;
  cin >> S >> K;

  if (K == 1) {
    cout << S[0] << endl;
    return;
  }

  for (int i = 0; i < min(K, S.size()); i++) {
    if (S[i] != '1') {
      cout << S[i] << endl;
      return;
    }
  }

  cout << S[K - 1] << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Compiler output:
a.cc:11:26: error: 'numeric_limits' is not a member of 'std'
   11 | constexpr int INF = std::numeric_limits<int>::max();
      |                          ^~~~~~~~~~~~~~
a.cc:10:13: error: expected primary-expression before 'long'
   10 | #define int long long int
      |             ^~~~
a.cc:11:41: note: in expansion of macro 'int'
   11 | constexpr int INF = std::numeric_limits<int>::max();
      |                                         ^~~
a.cc:12:27: error: 'numeric_limits' is not a member of 'std'
   12 | constexpr int NINF = std::numeric_limits<int>::min();
      |                           ^~~~~~~~~~~~~~
a.cc:10:13: error: expected primary-expression before 'long'
   10 | #define int long long int
      |             ^~~~
a.cc:12:42: note: in expansion of macro 'int'
   12 | constexpr int NINF = std::numeric_limits<int>::min();
      |                                          ^~~
a.cc: In function 'void solve()':
a.cc:25:26: error: no matching function for call to 'min(long long int&, std::__cxx11::basic_string<char>::size_type)'
   25 |   for (int i = 0; i < min(K, S.size()); i++) {
      |                       ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:25:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   25 |   for (int i = 0; i < min(K, S.size()); i++) {
      |                       ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:25:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |   for (int i = 0; i < min(K, S.size()); i++) {
      |                       ~~~^~~~~~~~~~~~~