Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int N,M; cin >> N >> M ;
    vector<int> s(M);
    vector<int> c(M);
    map<int,int> mp;
    bool res = true;
    rep(i,M) {
        cin >> s[i] >> c[i];
        if (mp[s[i]] !=0 ){
            if (mp[s[i]] != c[i]){
                res = false;
                break;
            }
        }
        mp[s[i]] = c[i];
        if (N>1 && s[i] ==1 && c[i] == 0){
            res = false;
            break;
        }
    }
    if (mp.size() < N) res = false;
    if (!res) cout << -1 << endl;
    else {
        vector<int> ans(N,0);
        rep(i,M){
            ans[s[i]-1] = c[i];
        }
        rep(i,N){
            cout << ans[i] ;
        }
    }
}
 T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int N,M; cin >> N >> M ;
    vector<int> s(M);
    vector<int> c(M);
    map<int,int> mp;
    bool res = true;
    rep(i,M) {
        cin >> s[i] >> c[i];
        if (mp[s[i]] !=0 ){
            if (mp[s[i]] != c[i]){
                res = false;
                break;
            }
        }
        mp[s[i]] = c[i];
        if (N>1 && s[i] ==1 && c[i] == 0){
            res = false;
            break;
        }
    }

    if (!res) cout << -1 << endl;
    else {
        vector<int> ans(N,0);
        rep(i,M){
            ans[s[i]-1] = c[i];
        }
        rep(i,N){
            cout << ans[i] ;
        }
    }
}


Compiler output:
a.cc:13:35: error: stray '#' in program
   13 | template<class T, class U>U COUNT(#include <bits/stdc++.h>
      |                                   ^
a.cc:13:36: error: 'include' was not declared in this scope
   13 | template<class T, class U>U COUNT(#include <bits/stdc++.h>
      |                                    ^~~~~~~
a.cc:13:45: error: 'bits' was not declared in this scope
   13 | template<class T, class U>U COUNT(#include <bits/stdc++.h>
      |                                             ^~~~
a.cc:13:50: error: 'stdc' was not declared in this scope; did you mean 'std'?
   13 | template<class T, class U>U COUNT(#include <bits/stdc++.h>
      |                                                  ^~~~
      |                                                  std
a.cc:16:1: error: expected primary-expression before 'const'
   16 | const int INF = 1001001001;
      | ^~~~~
a.cc:18:10: error: redefinition of 'const ll MOD'
   18 | const ll MOD=1000000007;
      |          ^~~
a.cc:6:10: note: 'const ll MOD' previously defined here
    6 | const ll MOD=1000000007;
      |          ^~~
a.cc:20:31: error: redefinition of 'template<class T> bool chmax(T&, T)'
   20 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:8:31: note: 'template<class T> bool chmax(T&, T)' previously declared here
    8 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:21:31: error: redefinition of 'template<class T> bool chmin(T&, T)'
   21 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:9:31: note: 'template<class T> bool chmin(T&, T)' previously declared here
    9 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:22:23: error: redefinition of 'template<class T> auto MAX(const T&)'
   22 | template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
      |                       ^~~
a.cc:10:23: note: 'template<class T> auto MAX(const T&)' previously declared here
   10 | template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
      |                       ^~~
a.cc:23:23: error: redefinition of 'template<class T> auto MIN(const T&)'
   23 | template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
      |                       ^~~
a.cc:11:23: note: 'template<class T> auto MIN(const T&)' previously declared here
   11 | template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
      |                       ^~~
a.cc:24:29: error: redefinition of 'template<class T, class U> U SUM(const T&, const U&)'
   24 | template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
      |                             ^~~
a.cc:12:29: note: 'template<class T, class U> U SUM(const T&, const U&)' previously declared here
   12 | template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
      |                             ^~~
a.cc:25:57: error: 'template<class T, class U> U COUNT(const T&, const U&)' conflicts with a previous declaration
   25 | template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
      |                                                         ^
a.cc:13:29: note: previous declaration 'template<class T, class U> U COUNT<T, U>'
   13 | template<class T, class U>U COUNT(#include <bits/stdc++.h>
      |                             ^~~~~
a.cc:64:2: error: 'T' does not name a type
   64 |  T& a, const U& v) { return count(a.begin(),a.end(), v); }
      |  ^
a.cc:65:31: error: redefinition of 'template<class T, class U> int LOWER(const T&, const U&)'
   65 | template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
      |                               ^~~~~
a.cc:26:31: note: 'template<class T, class U> int LOWER(const T&, const U&)' previously declared here
   26 | template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
      |                               ^~~~~
a.cc:66:31: error: redefinition of 'template<class T, class U> int UPPER(const T&, const U&)'
   66 | template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
      |                               ^~~~~
a.cc:27:31: note: 'template<class T, class U> int UPPER(const T&, const U&)' previously declared here
   27 | template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
      |                               ^~~~~
a.cc:67:5: error: redefinition of 'int GCD(int, int)'
   67 | int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
      |     ^~~
a.cc:28:5: note: 'int GCD(int, int)' previously defined here
   28 | int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
      |     ^~~
a.cc:68:5: error: redefinition of 'int LCM(int, int)'
   68 | int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
      |     ^~~
a.cc:29:5: note: 'int LCM(int, int)' previously defined here
   29 | int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
      |     ^~~
a.cc:70:5: error: redefinition of 'int main()'
   70 | int main(void){
      |     ^~~~
a.cc:31:5: note: 'int main()' previously defined here
   31 | int main(void){
      |     ^~~~