Language: C++

#include <iostream>
#include <string>
using namespace std;

int main() {
    int N;
    int M;
    cin >> N >> M;

    int s[M];
    int c[M];
    for (int i=0; i<M; i++) {
        cin >> s[i] >> c[i];
    }

    string str;
    int result[M];
    result[0] = -1;
    int flag = 0;

    if (N == 1) {
        for (int i=0; i<9; i++) {
            str = std::to_string(i);
            for (int j=0; j<M; j++) {
                if (atoi(str[s[j]]) == c[j]) {
                    result[j] = i;
                } else {
                    break;
                }
            }
        }
    } else if (N == 2) {
        for (int i=10; i<99; i++) {
            str = std::to_string(i);
            for (int j=0; j<M; j++) {
                if (atoi(str[s[j]]) == c[j]) {
                    result[j] = i;
                } else {
                    break;
                }
            }
        }
    } else {
        for (int i=100; i<999; i++) {
            str = std::to_string(i);
            for (int j=0; j<M; j++) {
                if (atoi(str[s[j]]) == c[j]) {
                    result[j] = i;
                } else {
                    break;
                }
            }
        }
    }    
    cout << result[0] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:25: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const char*' [-fpermissive]
   25 |                 if (atoi(str[s[j]]) == c[j]) {
      |                     ~~~~^~~~~~~~~~~
      |                         |
      |                         __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdlib.h:105:30: note:   initializing argument 1 of 'int atoi(const char*)'
  105 | extern int atoi (const char *__nptr)
      |                  ~~~~~~~~~~~~^~~~~~
a.cc:36:25: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const char*' [-fpermissive]
   36 |                 if (atoi(str[s[j]]) == c[j]) {
      |                     ~~~~^~~~~~~~~~~
      |                         |
      |                         __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
/usr/include/stdlib.h:105:30: note:   initializing argument 1 of 'int atoi(const char*)'
  105 | extern int atoi (const char *__nptr)
      |                  ~~~~~~~~~~~~^~~~~~
a.cc:47:25: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const char*' [-fpermissive]
   47 |                 if (atoi(str[s[j]]) == c[j]) {
      |                     ~~~~^~~~~~~~~~~
      |                         |
      |                         __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
/usr/include/stdlib.h:105:30: note:   initializing argument 1 of 'int atoi(const char*)'
  105 | extern int atoi (const char *__nptr)
      |                  ~~~~~~~~~~~~^~~~~~