stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

#define all(x) (x).begin(), (x).end()



int main() {

    int N;

    string S;

    cin >> N >> S;

    int res = 0;

    rep(a, 0, 10) {

        int a_i = -1;

        rep(i, 0, N-2) {

            if (S[i] == to_string(a)[0]) {

                a_i = i;

                break;

            }

        }

        if (a_i == -1) continue;

        rep(b, 0, 10) {

            int b_i = -1;

            rep(i, a_i+1, N-1) {

                if (S[i] == to_string(b)[0]) {

                    b_i = i;

                    break;

                }

            }

            if (b_i == -1) continue;

            rep(c, 0, 10) {

                rep(i, b_i+1, N) {

                    if (S[i] == to_string(c)[0]) {

                        res++;

                        break;

                    }

                }

            }

        }

    }

    cout << res << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.388166738725406x):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

#define all(x) (x).begin(), (x).end()



int main() {

    int N;

    string S;

    cin >> N >> S;



    int ans = 0;

    rep(i,0,10) {

        int i0 = find(all(S), to_string(i)[0]) - S.begin();

        if (i0 >= N-2) continue;

        rep(j,0,10) {

            int i1 = find(S.begin() + i0 + 1, S.end(), to_string(j)[0]) - S.begin();

            if (i1 >= N-1) continue;

            rep(k,0,10) {

                int i2 = find(S.begin() + i1 + 1, S.end(), to_string(k)[0]) - S.begin();

                if (i2 < N) ans++;

            }

        }

    }



    cout << ans << endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

  int N;

  cin >> N;

  string S;

  cin >> S;

  int ans = 0;

  for (int i = 0; i < 1000; i++)

  {

    string now = to_string(i);

    int digit1 = 0, digit2 = 0;

    if (i < 10)

    {

      for (int j = 0; j < S.size(); j++)

      {

        if (digit1 == 0 && S[j] == '0')

        {

          digit1++;

          continue;

        }

        if (digit2 == 0 && digit1 > 0 && S[j] == '0')

        {

          digit2++;

          continue;

        }

        if (digit2 > 0 && S[j] == now[0])

        {

          ans++;

          break;

        }

      }

    }

    if (i >= 10 && i < 100)

    {

      for (int j = 0; j < S.size(); j++)

      {

        if (digit1 == 0 && S[j] == '0')

        {

          digit1++;

          continue;

        }

        if (digit2 == 0 && digit1 > 0 && S[j] == now[0])

        {

          digit2++;

          continue;

        }

        if (digit2 > 0 && S[j] == now[1])

        {

          ans++;

          break;

        }

      }

    }

    if (i >= 100)

    {

      for (int j = 0; j < S.size(); j++)

      {

        if (digit1 == 0 && S[j] == now[0])

        {

          digit1++;

          continue;

        }

        if (digit2 == 0 && digit1 > 0 && S[j] == now[1])

        {

          digit2++;

          continue;

        }

        if (digit2 > 0 && S[j] == now[2])

        {

          ans++;

          break;

        }

      }

    }

  }

  cout << ans << endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.1685307376202825x):
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;

using P = pair<int, int>;



const long long MOD = 1000000007;

const long long INF = 1LL << 60;



int main()

{

  int N;

  string S;

  cin >> N >> S;

  ll ans = 0;

  for (int i = 0; i <= 9; i++)

  {

    for (int j = 0; j <= 9; j++)

    {

      for (int k = 0; k <= 9; k++)

      {

        bool first = false, second = false, third = false;

        for (int l = 0; l < N; l++)

        {

          if (!first && S[l] - '0' == i)

            first = true;

          else if (first && !second && S[l] - '0' == j)

            second = true;

          else if (first && second && !third && S[l] - '0' == k)

            third = true;

        }

        if (first && second && third)

          ans++;

      }

    }

  }

  cout << ans << endl;

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

typedef long long ll;

const int INF = 1e9;

using namespace std;



int main(){

    int n;

    string s;

    cin >> n >> s;

    int num = 0;

    for (int i = 0; i < 10; ++i) {

       for (int j = 0; j < 10; ++j) {

            for (int k = 0; k < 10; ++k) {

                size_t si = s.find(to_string(i));

                if(si == string::npos){

                    continue;

                }

                size_t sj = s.find(to_string(j), si+1);

                if(sj == string::npos){

                    continue;

                }

                size_t sk = s.find(to_string(k), sj+1);

                if(sk == string::npos){

                    continue;

                }

                else{

                    num++;

                }

            }

        }

    }

    cout << num << endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.2392164891891204x):
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;



int main(){

    int n;

    string s;

    cin >> n >> s;

    int res = 0;

    for (int i = 0; i < 10; ++i) {

        int iid = s.find(to_string(i));

        if (iid == string::npos) continue;



        for (int j = 0; j < 10; ++j) {

            string sj = s.substr(iid + 1);

            int jid = sj.find(to_string(j));

            if (jid == sj.length() - 1) continue;

            if (jid == string::npos) continue;



            for (int k = 0; k < 10; ++k) {

                string sk = sj.substr(jid + 1);

                int kid = sk.find(to_string(k));

                if (kid != string::npos){

                    res++;

                }

            }

        }

    }

    cout << res << endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)



int main(){

    set<string> x,y,z;

    int N;

    string S;

    cin >> N >> S;

    FOR(i,0,S.size()){

        string a = "2";

        a[0] = S[i];

        for(auto b:y){

            z.insert(b+a);

        }

        for(auto b:x){

            y.insert(b+a);

        }

        x.insert(a);

    }

    cout << z.size() << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.1673896363893614x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define P pair<ll,ll>

#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)

#define TO(x,t,f) ((x)?(t):(f))

#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9

#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted

#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted

#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted

#define REV(x) (reverse(x.begin(),x.end())) //reverse

ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}

ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}

#define NEXTP(x) next_permutation(x.begin(),x.end())

const ll INF=ll(1e16)+ll(7);

const ll MOD=1000000007LL;

#define out(a) cout<<fixed<<setprecision((a))

//tie(a,b,c) = make_tuple(10,9,87);

#define pop_(a) __builtin_popcount((a))

ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}





int main(){



  int N;

  string s;

  cin >> N >> s;

  bool ok1[10]={},ok2[10][10]={},ok3[10][10][10]={};

  for(auto c:s){

    FOR(i,0,10)FOR(j,0,10)ok3[i][j][c-'0'] |= ok2[i][j];

    FOR(i,0,10)ok2[i][c-'0'] |= ok1[i];

    ok1[c-'0'] = true;

  }

  ll ans = 0;

  FOR(i,0,10)FOR(j,0,10)FOR(k,0,10){

    ans += ok3[i][j][k];

  }

  cout << ans << endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

//const ll MOD = 1e9 + 7;

//const ll MOD = 998244353;

//const ll MOD = ;

ll mod(ll A, ll M) {return (A % M + M) % M;}

const ll INF = 1LL << 60;

template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}

template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}

ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}

ll myctoi(char C) {return C - '0';}

char myitoc(ll N) {return '0' + N;}

#define FINALANS(A) {cout << (A) << '\n'; exit(0);}



int main()

{

  ll N;

  cin >> N;

  string S;

  cin >> S;



  vector<vector<bool>> dp(1001, vector<bool>(4, false));

  dp.at(0).at(0) = true;

  for (ll i = 0; i < N; i++)

  {

    ll x = myctoi(S.at(i));

    for (ll j = 1000; j >= 0; j--)

    {

      for (ll k = 2; k >= 0; k--)

      {

        if (!dp.at(j).at(k))

          continue;

        dp.at(j * 10 + x).at(k + 1) = true;

        //cerr << j << " " << k << endl;

      }

    }

  }



  ll ans = 0;

  for (ll i = 0; i < 1001; i++)

  {

    if (dp.at(i).at(3))

    {

      //cerr << i << endl;

      ans++;

    }

  }

  cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.1100141572083577x):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 1e9 + 7;

//const ll MOD = 998244353;

//const ll MOD = ;

ll mod(ll A, ll M) {return (A % M + M) % M;}

const ll INF = 1LL << 60;

template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}

template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}

ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}

ll myctoi(char C) {return C - '0';}

char myitoc(ll N) {return '0' + N;}

#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)



int main()

{

  ll N;

  cin >> N;

  string S;

  cin >> S;



  ll ans = 0;

  for (char c1 = '0'; c1 <= '9'; c1++)

  {

    for (char c2 = '0'; c2 <= '9'; c2++)

    {

      for (char c3 = '0'; c3 <= '9'; c3++)

      {

        vector<char> x = {c1, c2, c3};



        ll cnt = 0;

        for (ll i = 0; i < N; i++)

        {

          if (S.at(i) == x.at(cnt))

          {

            cnt++;

            if (cnt == 3)

            {

              ans++;

              break;

            }

          }

        }

      }

    }

  }

  

  cout << ans << endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <iostream>



using namespace std;



typedef long long ll;



int main() {

    map<string, bool> A1, A2, A3;



    int N;

    cin >> N;

    string S;

    cin >> S;



    A1[S.substr(N-1, 1)] = true;

    A1[S.substr(N-2, 1)] = true;

    A2[S.substr(N-2)] = true;

    for (int i = N - 3; i >= 0; i--) {

        for (auto const& e : A2) {

            string s = S.substr(i, 1);

            s += e.first;

            A3[s] = true;

        }



        for (auto const& e : A1) {

            string s = S.substr(i, 1);

            s += e.first;

            A2[s] = true;

        }



        A1[S.substr(i, 1)] = true;

    }

    

    cout << A3.size() << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.1035854621715167x):
#include <bits/stdc++.h>

#include <iostream>



using namespace std;



typedef long long ll;



int main() {

    int N;

    cin >> N;

    string S;

    cin >> S;



    int cnt = 0;

    for (int i = 0; i < 1000; i++) {

        int c[3] = { i / 100, (i % 100) / 10, i % 10};

        int p = 0;

        for (int j = 0; j < N; j++) {

            if (S[j] == ('0' + c[p])) {

                p++;

            }

            if (p == 3) {

                cnt++;

                break;

            }

        }

    }



    cout << cnt << endl;

/*

    map<string, bool> A1, A2, A3;

    A1[S.substr(N-1, 1)] = true;

    A1[S.substr(N-2, 1)] = true;

    A2[S.substr(N-2)] = true;

    for (int i = N - 3; i >= 0; i--) {

        for (auto const& e : A2) {

            string s = S.substr(i, 1);

            s += e.first;

            A3[s] = true;

        }



        for (auto const& e : A1) {

            string s = S.substr(i, 1);

            s += e.first;

            A2[s] = true;

        }



        A1[S.substr(i, 1)] = true;

    }

    

    cout << A3.size() << endl;

*/    

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <iostream>



using namespace std;



typedef long long ll;



int main() {

    map<string, bool> A1, A2, A3;



    int N;

    cin >> N;

    string S;

    cin >> S;



    A1[S.substr(N-1, 1)] = true;

    A1[S.substr(N-2, 1)] = true;

    A2[S.substr(N-2)] = true;

    for (int i = N - 3; i >= 0; i--) {

        for (auto const& e : A2) {

            string s = S.substr(i, 1);

            s += e.first;

            A3[s] = true;

        }



        for (auto const& e : A1) {

            string s = S.substr(i, 1);

            s += e.first;

            A2[s] = true;

        }



        A1[S.substr(i, 1)] = true;

    }

    

    cout << A3.size() << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.1520183734607428x):
#include <bits/stdc++.h>

#include <iostream>



using namespace std;



typedef long long ll;



int main() {

    int N;

    cin >> N;

    string S;

    cin >> S;



    int cnt = 0;

    for (char i = '0'; i <= '9'; i++) {

        size_t pi = S.find(i);

        if (pi == string::npos) { continue; }



        for (char j = '0'; j <= '9'; j++) {

            size_t pj = S.find(j, pi+1);

            if (pj == string::npos) { continue; }



            for (char k = '0'; k <= '9'; k++) {

                size_t pk = S.find(k, pj+1);

                if (pk == string::npos) { continue; }



                cnt++;

            }

        }

    }



    cout << cnt << endl;



    /*

    int cnt = 0;

    for (int i = 0; i < 1000; i++) {

        int c[3] = { i / 100, (i % 100) / 10, i % 10};

        int p = 0;

        for (int j = 0; j < N; j++) {

            if (S[j] == ('0' + c[p])) {

                p++;

            }

            if (p == 3) {

                cnt++;

                break;

            }

        }

    }



    cout << cnt << endl;

    */

/*

    map<string, bool> A1, A2, A3;

    A1[S.substr(N-1, 1)] = true;

    A1[S.substr(N-2, 1)] = true;

    A2[S.substr(N-2)] = true;

    for (int i = N - 3; i >= 0; i--) {

        for (auto const& e : A2) {

            string s = S.substr(i, 1);

            s += e.first;

            A3[s] = true;

        }



        for (auto const& e : A1) {

            string s = S.substr(i, 1);

            s += e.first;

            A2[s] = true;

        }



        A1[S.substr(i, 1)] = true;

    }

    

    cout << A3.size() << endl;

*/    

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<math.h>

#include<complex>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<bitset>

#include<functional>

#include<assert.h>

#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )

#define rep(i,n) REP(i,0,n)

using ll = long long;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;



int main(){

    int n;cin>>n;

    string s;

    cin>>s;

    int ans = 0;

    rep(i,10)rep(j,10)rep(k,10){

        vector<char> v = {char('0'+i),char('0'+j),char('0'+k),'-'};

        int c=0;

        rep(l,n){

            if(s[l]==v[c])c++;

        }

        ans += c==3;

    }

    cout<<ans<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1668497470982357x):
#include <stdio.h>

#include <algorithm>

#include <vector>

#include <string>

const long long mod = 1000000007;

 

 

int main() {

	int N;

	scanf("%d", &N);

	char*S = new char[N + 1];

	scanf("%s", S);

	int cnt = 0;

	for (char s1 = '0'; s1 <= '9'; s1++) {

		int p1 = 0;

		for (; p1 < N; p1++) {

			if (S[p1] == s1)break;

		}

		p1++;

		if (p1 == N)continue;

		for (char s2 = '0'; s2 <= '9'; s2++) {

			int p2 = p1;

			for (; p2 < N; p2++) {

				if (S[p2] == s2)break;

			}

			p2++;

			if (p2 == N)continue;

			for (char s3 = '0'; s3 <= '9'; s3++) {

				int p3 = p2;

				for (; p3 < N; p3++) {

					if (S[p3] == s3) {

						cnt++;

						break;

					}

				}

				p3++;

				if (p3 == N)continue;

 

			}

		}

	}

	printf("%d", cnt);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<math.h>

#include<complex>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<bitset>

#include<functional>

#include<assert.h>

#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )

#define rep(i,n) REP(i,0,n)

using ll = long long;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;



int main(){

    int n;cin>>n;

    string s;

    cin>>s;

    int ans = 0;

    rep(i,10)rep(j,10)rep(k,10){

        vector<char> v = {char('0'+i),char('0'+j),char('0'+k),'-'};

        int c=0;

        rep(l,n){

            if(s[l]==v[c])c++;

        }

        ans += c==3;

    }

    cout<<ans<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.257324704416923x):
#include <stdio.h>





int main(){

	int n;

	char str[50010];

	int x = 0;

	int ctr = 0;

	scanf("%d", &n);

	scanf("%s", str);



for(int i = 0;i < 10;i++){

	for(int j = 0;j<10;j++){

		for(int k = 0;k<10;k++){

			char test[] = {i,j,k};

		    x = 0;

			for(int a = 0;a <n;a++){

				if(str[a] - '0' == test[x]){

					x++;

				}

				if(x == 3){

					ctr++;

					break;

				}

			}

			

		}

	}

}

printf("%d", ctr);

	return 0;

}
// Slower C++ solution:
#include <stdio.h>

#include <algorithm>

#include <vector>

#include <string>

const long long mod = 1000000007;

 

 

int main() {

	int N;

	scanf("%d", &N);

	char*S = new char[N + 1];

	scanf("%s", S);

	int cnt = 0;

	for (char s1 = '0'; s1 <= '9'; s1++) {

		int p1 = 0;

		for (; p1 < N; p1++) {

			if (S[p1] == s1)break;

		}

		p1++;

		if (p1 == N)continue;

		for (char s2 = '0'; s2 <= '9'; s2++) {

			int p2 = p1;

			for (; p2 < N; p2++) {

				if (S[p2] == s2)break;

			}

			p2++;

			if (p2 == N)continue;

			for (char s3 = '0'; s3 <= '9'; s3++) {

				int p3 = p2;

				for (; p3 < N; p3++) {

					if (S[p3] == s3) {

						cnt++;

						break;

					}

				}

				p3++;

				if (p3 == N)continue;

 

			}

		}

	}

	printf("%d", cnt);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.6485629062389497x):
#include <stdio.h>





int main(){

	int n;

	char str[50010];

	int x = 0;

	int ctr = 0;

	scanf("%d", &n);

	scanf("%s", str);



for(int i = 0;i < 10;i++){

	for(int j = 0;j<10;j++){

		for(int k = 0;k<10;k++){

			char test[] = {i,j,k};

		    x = 0;

			for(int a = 0;a <n;a++){

				if(str[a] - '0' == test[x]){

					x++;

				}

				if(x == 3){

					ctr++;

					break;

				}

			}

			

		}

	}

}

printf("%d", ctr);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define rep(i, n) for(int i = 0; i < n; i++)



using namespace std;

using ll = long long;

int mod = 1000000007;



int num[3] = {0, 0, 0};

void add(){

    if(num[2] == 9 && num[1] == 9){

        num[0] += 1; num[1] = 0; num[2] = 0;

    }

    else if(num[2] == 9){

        num[1] += 1; num[2] = 0;

    }

    else num[2] += 1;

}



int main(void){

    int N; cin >> N;

    string S; cin >> S;

    for(int i = 0; i < 30000; i++) S += "1";

    int cnt = 0;

    for(int i = 0; i < 1000; i++){

        int idx = 0;

        for(int j = 0; j < N; j++){

            if(S[j] - '0' == num[idx]){

                idx++;

                if(idx == 3) break;

            }

        }

        if(idx == 3) cnt++;

        add();

    }

    cout << cnt << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.2838304437184358x):
#include <bits/stdc++.h>



#define rep(i, n) for(int i = 0; i < n; i++)



typedef long long ll;

using namespace std;

int mod = 1000000007;



int main(void){

    int N; cin >> N;

    string S; cin >> S;

    vector<int> dig_pos[10];

    int num_dig[10];

    int ans = 0;

    rep(i, N) dig_pos[S[i]-'0'].push_back(i);

    rep(i, 10) num_dig[i] = dig_pos[i].size();

    rep(i, 1000){

        bool ok = false;

        string S = "";

        int val = i;

        rep(j, 3){

            S += ('0' + (val % 10));

            val /= 10;

        }

        reverse(S.begin(), S.end());

        if(num_dig[S[0]-'0'] > 0 && num_dig[S[1]-'0'] > 0 && num_dig[S[2]-'0'] > 0){

            int st = dig_pos[S[0]-'0'][0], fin = dig_pos[S[2]-'0'][num_dig[S[2]-'0']-1];

            int aim = S[1]-'0';

            rep(j, num_dig[aim]){

                if(st < dig_pos[aim][j] && dig_pos[aim][j] < fin){

                    ans++;

                    break;

                }

            }

        }

    }

    cout << ans << endl;

    return 0;

}