Language: C++

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<pair<int ,int>> P(N);
  for (int i = 0; i < M; i++){
    cin >> P[i].first >> P[i].second;
  }
  
  int n1 = -1;
  int n2 = -1;
  int n3 = -1;
  int r = -1;
  if(N == 3){
    for (int i = 0; i < M; i++){
      if(P[i].first == 1){
        // N>1の場合に、一番上の桁が0  
        if(P[i].second == 0){
          cout << r << endl;
          return 0;
        }
        // 同じ桁で数字が違う
        if(n1 != -1 && n1 != P[i].second){
          cout << r << endl;
          return 0;
        }
        n1 = P[i].second;
      }
      if(P[i].first == 2){
        // 同じ桁で数字が違う
        if(n2 != -1 && n2 != P[i].second){
          cout << r << endl;
          return 0;
        }
        n2 = P[i].second;
      }
      if(P[i].first == 3){
        // 同じ桁で数字が違う
        if(n3 != -1 && n3 != P[i].second){
          cout << r << endl;
          return 0;
        }
        n3 = P[i].second;
      }
    }
    if (n1 == 0} {
      cout << r << endl;
      return 0;      
    }
    r = n1 * 100;
    if (n2 == -1) n2 = 0; 
    r += n2 * 10;
    if (n3 == -1) n3 = 0; 
    r += n3;
  }
  else if(N == 2){
    for (int i = 0; i < M; i++){
      if(P[i].first == 1){
        // N>1の場合に、一番上の桁が0  
        if(P[i].second == 0){
          cout << r << endl;
          return 0;
        }
        // 同じ桁で数字が違う
        if(n1 != -1 && n1 != P[i].second){
          cout << r << endl;
          return 0;
        }
        n1 = P[i].second;
      }
      if(P[i].first == 2){
        // 同じ桁で数字が違う
        if(n2 != -1 && n2 != P[i].second){
          cout << r << endl;
          return 0;
        }
        n2 = P[i].second;
      }
      if(P[i].first == 3){
        // 存在しない桁
        cout << r << endl;
        return 0;
      }
    }
    if (n1 == 0} {
      cout << r << endl;
      return 0;      
    }
    r = n1 * 10;
    if (n2 == -1) n2 = 0; 
    r += n2;
  }
  else {
    for (int i = 0; i < M; i++){
      if(P[i].first == 1){
        // 同じ桁で数字が違う
        if(n1 != -1 && n1 != P[i].second){
          cout << r << endl;
          return 0;
        }
        n1 = P[i].second;
      }
      if(P[i].first == 2){
        // 存在しない桁
        cout << r << endl;
        return 0;
      }
      if(P[i].first == 3){
        // 存在しない桁
        cout << r << endl;
        return 0;
      }
    }
    r = n1;
  }

  cout << r << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:50:16: error: expected ')' before '}' token
   50 |     if (n1 == 0} {
      |        ~       ^
      |                )
a.cc:50:16: error: expected primary-expression before '}' token
a.cc: At global scope:
a.cc:60:3: error: expected unqualified-id before 'else'
   60 |   else if(N == 2){
      |   ^~~~
a.cc:89:18: error: expected unqualified-id before '{' token
   89 |     if (n1 == 0} {
      |                  ^
a.cc:93:5: error: 'r' does not name a type
   93 |     r = n1 * 10;
      |     ^
a.cc:94:5: error: expected unqualified-id before 'if'
   94 |     if (n2 == -1) n2 = 0;
      |     ^~
a.cc:95:5: error: 'r' does not name a type
   95 |     r += n2;
      |     ^
a.cc:96:3: error: expected declaration before '}' token
   96 |   }
      |   ^
a.cc:97:3: error: expected unqualified-id before 'else'
   97 |   else {
      |   ^~~~
a.cc:121:3: error: 'cout' does not name a type
  121 |   cout << r << endl;
      |   ^~~~
a.cc:122:1: error: expected declaration before '}' token
  122 | }
      | ^