stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include <string>

#include <vector>



using namespace std;



int main() {

  int n;

  cin >> n;

  string s;

  cin >> s;

 

  int ans = 0;

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

	int d = to_string(i).size();

    string t(3-d, '0');

    t += to_string(i);



	std::string::size_type pos = -1;

    bool f = false;

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

	  pos = s.find(t[i], pos+1);

      if (pos == string::npos)  break;

      if (i==2) f = true;

    }

    

    if (f) ans++;

  }

  

  cout << ans << endl;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <string>

#include <vector>



using namespace std;



int main() {

  int n;

  cin >> n;

  string s;

  cin >> s;

 

  int ans = 0;

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

	string t(3,'0');

	for (int tmp=i,j=0; j<3; j++) t[j] = '0' + (tmp%10),tmp/=10;

     

	std::string::size_type pos = -1;

    bool f = false;

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

	  pos = s.find(t[i], pos+1);

      if (pos == string::npos)  break;

      if (i==2) f = true;

    }

    

    if (f) ans++;

  }

  

  cout << ans << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<vector>

#include<numeric>

#include<string>

using namespace std;





int main(){

  int n; cin >> n;

  string s; cin >> s;

  int c = 0;

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

    string p;

    int flag = 0;

    if (i < 10) p = "00" + to_string(i);

    else if (i < 100) p = "0" + to_string(i);

    else p = to_string(i);

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

        if (s[j] == p[0] && flag == 0) flag++;

        else if (s[j] == p[1] && flag == 1) flag++;

        else if (s[j] == p[2] && flag == 2) {

            c++;

            break;

        }

    }

  }

    cout << c;

}




// Optimized solution to the same problem (faster):
#include<iostream>

#include<algorithm>

#include<vector>

#include<numeric>

#include<string>

#include<cmath>

#include<set>

#include<queue>

#include<deque>

#include<bitset>

#include<iomanip>

#include<cctype>

#include<map>

#include<cstring>

#include<bitset>

#include<cassert>

 

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

#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)

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

 

using namespace std;

using ll = long long int;

 

const int inf = 1001001000;

const long long int Inf = 1001001001001001000;

 

template<typename T>

void print1d(vector<T> a){

    for (auto x:a){

        cout << x << " ";

    }

    cout << endl;

}

 

template<typename T>

void print2d(vector<vector<T>> a){

	for (auto v:a){

		for (auto x:v){

			cout << x << " ";

		}

		cout << endl;

	}

}



template<typename T>

void print(T a){

	for (auto x:a){

		cout << x << " ";

	}

	cout << endl;

}



int main()

{

	int n;

	string s;

	cin >> n >> s;

	vector<int> a(3);

	

	int ans = 0;

	rep(i, 1000)

	{

		a[0] = i / 100;

		a[1] = (i / 10) % 10;

		a[2] = i % 10;

		int f = 0;

		rep(j, n)

		{

			if(a[f] + '0' == s[j]){

				f++;

			}

			if(f==3)

				break;

		}

		if(f==3)

			ans++;

	}

	cout << ans << endl;

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main() {

  int n,ans = 0;

  string s;

  cin >> n >> s;

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

    ostringstream sout;

    sout << setw(3) << setfill('0') << i;

    string t = sout.str();

    int k = 0;

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

    {

      if(s[j] == t[k]){

        k++;

      }

      if(k == 3){

        break;

      }

    }

    if(k == 3){

      ans++;

    }

  }

  cout << ans << endl;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



bool find(int i, int j, int k, string s) {

  int now = 0;

  for (int idx = 0; idx < s.size(); idx++) {

    if (now == 0 && s[idx] == '0' + i) {

      now++;

      continue;

    }

    if (now == 1 && s[idx] == '0' + j) {

      now++;

      continue;

    }

    if (now == 2 && s[idx] == '0' + k) {

      now++;

      break;

    }

  }

  if (now == 3) {

    return true;

  } else {

    return false;

  }

}



int solve(int n, string s) {

  int ans = 0;

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

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

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

        if (find(i, j, k, s)) {

          ans++;

        }

      }

    }

  }

  return ans;

}

int main() {

  int n;

  string s;

  cin >> n >> s;

  cout << solve(n, s) << endl;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <stdio.h>

#include <string>

#include <cstring>

#include <stdlib.h>

#include <math.h>

#include <algorithm>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <stack>

#include <list>

#include <iterator>

#include <assert.h>

#pragma warning(disable:4996) 

 

typedef long long ll;

#define MIN(a, b) ((a)>(b)? (b): (a))

#define MAX(a, b) ((a)<(b)? (b): (a))

#define LINF 9223300000000000000

#define INF 2140000000

const long long MOD = 1000000007;

//const long long MOD = 998244353;

using namespace std;



char str[30000];



int main(int argc, char* argv[])

{

    int n;

    scanf("%d", &n);

    scanf("%s", str);



    set<int> z1,z2,z3;

    int i;

    for(i=0; i<n; i++) {

        int tmp=str[i]-'0';

        {

            auto it=z2.begin();

            for(; it!=z2.end(); ++it) {

                z3.insert((*it)*10+tmp);

            }

        }

        {

            auto it=z1.begin();

            for(; it!=z1.end(); ++it) {

                z2.insert((*it)*10+tmp);

            }

        }

        z1.insert(tmp);

    }

    printf("%d\n", (int)z3.size());



    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string>

#include <cstring>

#include <stdlib.h>

#include <math.h>

#include <algorithm>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <stack>

#include <list>

#include <iterator>

#include <assert.h>

#pragma warning(disable:4996) 

 

typedef long long ll;

#define MIN(a, b) ((a)>(b)? (b): (a))

#define MAX(a, b) ((a)<(b)? (b): (a))

#define LINF 9223300000000000000

#define INF 2140000000

const long long MOD = 1000000007;

//const long long MOD = 998244353;

 

using namespace std;



char str[30005];



void solve()

{

	int n;

	scanf("%d%s", &n, str);

	

	int flag[10] = { 0 };

	int flag2[100] = { 0 };

	int flag3[1000] = { 0 };

	int i,j;

	for (i = 0; i < n; i++) {

		int tmp = str[i] - '0';

		for (j = 0; j < 100; j++) {

			if (flag2[j]) flag3[j * 10 + tmp] = 1;

		}

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

			if (flag[j]) flag2[j * 10 + tmp] = 1;

		}

		flag[tmp] = 1;

	}

	int cnt = 0;

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

		if (flag3[i]) cnt++;

	}

	printf("%d\n", cnt);

    return;

}





int main(int argc, char* argv[])

{

#if 1

    solve();

#else

    int T; scanf("%d", &T);

    while(T--) {

        solve();

    }

#endif

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, a, b) for (int i = a; i < (int)b; i++)

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

const int MOD = 1e9 + 7;

const int INF = 1e9;

//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122



int n;

string s;



bool exist(int x) {

    string str = to_string(x);

    if (x <= 9) str = "00" + str;

    else if (x <= 99) str = "0" + str;

    rep(i, 0, n) {

        if (s[i] == str[0]) {

            rep(j, i + 1, n) {

                if (s[j] == str[1]) {

                    rep(k, j + 1, n) {

                        if (s[k] == str[2]) {

                            return true;

                        }

                    }

                    return false;

                }

            }

            return false;

        }

    }

    return false;

}



int main() {

    cin >> n;

    cin >> s;

    int ans = 0;

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

        if (exist(i) == true) {

            ans++;

        }

    }

    cout << ans << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, a, b) for (int i = a; i < (int)b; i++)

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

const int MOD = 1e9 + 7;

const int INF = 1e9;

//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122



int main() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    vector<vector<int>> v(10);

    rep(i, 0, n) {

        v[s[i] - '0'].push_back(i);

    }

    int ans = 0;

    rep(i, 0, 1000) {

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

        int p = 0;

        bool found = true;

        int cnt = 0;

        rep(j, 0, 3) {

            if ((int)v[t[j]].size() == 0) {

                found = false;

                break;

            }

            auto it = lower_bound(all(v[t[j]]), p);

            if (it - v[t[j]].begin() == (int)v[t[j]].size()) {

                found = false;

                break;

            }

            p = *it + 1;

            cnt++;

        }

        if (found && cnt == 3) ans++;

    }

    cout << ans << endl;

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, a, b) for (int i = a; i < (int)b; i++)

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

const int MOD = 1e9 + 7;

const int INF = 1e9;

//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122



int n;

string s;



bool exist(int i) {

    string str = to_string(i);

    if (i <= 9) str = "00" + str;

    else if (i <= 99) str = "0" + str;

    int tmp = 0;

    rep(i, 0, n) {

        if (s[i] == str[tmp]) tmp++;

        if(tmp == 3) break;

    }

    if (tmp == 3) return true;

    else return false;

}



int main() {

    cin >> n;

    cin >> s;

    int ans = 0;

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

        if (exist(i)) ans++;

    }

    cout << ans << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, a, b) for (int i = a; i < (int)b; i++)

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

const int MOD = 1e9 + 7;

const int INF = 1e9;

//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122



int main() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    vector<vector<int>> v(10);

    rep(i, 0, n) {

        v[s[i] - '0'].push_back(i);

    }

    int ans = 0;

    rep(i, 0, 1000) {

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

        int p = 0;

        bool found = true;

        int cnt = 0;

        rep(j, 0, 3) {

            if ((int)v[t[j]].size() == 0) {

                found = false;

                break;

            }

            auto it = lower_bound(all(v[t[j]]), p);

            if (it - v[t[j]].begin() == (int)v[t[j]].size()) {

                found = false;

                break;

            }

            p = *it + 1;

            cnt++;

        }

        if (found && cnt == 3) ans++;

    }

    cout << ans << endl;

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main() {

  int N;

  cin>>N;

  string S;

  cin>>S;

  int ans=0;

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

  int dp[N+1][4];

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

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

          dp[i][j]=0;

        }

      }

      string t;

      int d=k;

      int d1=k%10;

      int d2=(k/10)%10;

      int d3=k/100;

      t=to_string(d3)+to_string(d2)+to_string(d1);



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

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

            if (S[i] == t[j]) {

                dp[i+1][j+1] = dp[i][j] + 1;

            }

            else {

                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);

            }

        }

    }

    if(dp[N][3]==3) ans++;

  }





cout<<ans<<endl;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;





int main() {

int N;

string S;

cin>>N>>S;



int ans=0;

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

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

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

      int x=0;

      vector<char> t(3);

      t[0]=i,t[1]=j,t[2]=k;

      int y=0;

      while(x<N){

        if(S[x]==t[y]){

          y++;

          x++;

          if(y==3){

            ans++;

            break;

          }

        }

        else x++;

      }

    }

  }

}

cout<<ans<<endl;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

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

#define REPR(i, n) for(int i = n; i >= 0; i--)

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

#define ALL(v) v.begin(), v.end()

using namespace std;

typedef long long ll;

typedef long double ld;

const ll MOD = 1e9 + 7;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(nullptr);

  int n;

  string s;

  cin >> n >> s;

  int ans = 0;

  REP(i,1000){

    stringstream ssub;

    ssub << setw(3) << setfill('0') << i;

    string ss = ssub.str();

    int p = 0;

    while(s[p]!=ss[0]){

      p++;

      if(p==n-2) break;

    }

    if(p==n-2) continue;

    p++;

    while(s[p]!=ss[1]){

      p++;

      if(p==n-1) break;

    }

    if(p==n-1) continue;

    p++;

    while(s[p]!=ss[2]){

      p++;

      if(p==n) break;

    }

    if(p==n) continue;

    ans++;

  }

  cout << ans << '\n';

  return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

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

#define REPR(i, n) for(int i = n; i >= 0; i--)

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

#define ALL(v) v.begin(), v.end()

using namespace std;

typedef long long ll;

typedef long double ld;



int n; string s;

vector<vector<int>> inds(10);

int ans = 0;



void fanc(string st)

{

  if(st.size()==3){

    bool flag = true;

    int ind = 0;

    for(auto c: st){

      auto itr = lower_bound(ALL(inds[c-'0']), ind);

      if(itr==inds[c-'0'].end()){

        flag = false;

        break;

      }else{

        ind = (*itr) + 1;

      }

    }

    if(flag) ans++;

  }else{

    REP(i,10){

      st.push_back('0'+i);

      fanc(st);

      st.pop_back();

    }

  }

}



int main() {

  ios::sync_with_stdio(false);

  cin.tie(nullptr);

  cin >> n >> s;

  REP(i,n){

    inds[s[i]-'0'].push_back(i);

  }

  fanc("");

  cout << ans << endl;

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<string>

#include<vector>

#include<algorithm>

#include<bitset>

#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

#include<list>

#include<iomanip>

#include<cmath>

#include<cstring>

#include<functional>

#include<cstdio>

#include<cstdlib>

using namespace std;



#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)

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

#define INF 2e9

#define MOD 1000000007

//#define MOD 998244353

#define LINF (long long)4e18

#define jck 3.141592



const double EPS = 1e-10;



using ll = long long;

using Pi = pair<int,int>;

using Pl = pair<ll,ll>;



int main(){

    int N; cin >> N;

    string S; cin >> S;

    int ans = 0;

    rep(i,1000){

        string t = to_string(i);

        int m = t.size();

        int a,b,c;

        if(m == 1){

            a = 0;

            b = 0;

            c = t[0]-'0';

        }

        else if(m == 2){

            a = 0;

            b = t[0]-'0';

            c = t[1]-'0';

        }

        else{

            a = t[0]-'0';

            b = t[1]-'0';

            c = t[2]-'0';

        }

        bool ok = false;

        int now = 0;

        rep(j,N){

            if(now == 0 && S[j]-'0' == a) now++;

            else if(now == 1 && S[j]-'0' == b) now++;

            else if(now == 2 && S[j]-'0' == c){

                ok = true;

            }

        }

        if(ok) ans++;

    }

    cout << ans << endl;

}


// Optimized solution to the same problem (faster):
#include<iostream>

#include<string>

#include<vector>

#include<algorithm>

#include<bitset>

#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

#include<list>

#include<iomanip>

#include<cmath>

#include<cstring>

#include<functional>

#include<cstdio>

#include<cstdlib>

#include<unordered_map>

#include<unordered_set>

using namespace std;



#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)

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

#define INF 2e9

#define MOD 1000000007

//#define MOD 998244353

#define LINF (long long)4e18

#define jck 3.141592



const double EPS = 1e-10;



using ll = long long;

using Pi = pair<int,int>;

using Pl = pair<ll,ll>;







int main(){

    int N; cin >> N;

    string S; cin >> S;

    vector<int> suml(N+1),sumr(N+1);

    vector<bool> usedr(10,false),usedl(10,false);

    rep(i,N){

        int d = S[i]-'0';

        if(!usedl[d]){

            suml[i+1] = suml[i]+1;

            usedl[d] = true;

        }

        else suml[i+1] = suml[i];

    }

    for(int i = N-1; i >= 1; i--){

        int d = S[i]-'0';

        if(!usedr[d]){

            sumr[i] = sumr[i+1]+1;

            usedr[d] = true;

        }

        else sumr[i] = sumr[i+1];

    }

    vector<int> ans(10);

    vector<int> before(10);

    rep(i,N){

        int d = S[i]-'0';

        ans[d] += (suml[i]-suml[before[d]])*sumr[i+1];

        before[d] = i;

    }

    int ans2 = 0;

    rep(i,10) ans2 += ans[i];

    cout << ans2 << endl;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

const double EPS=1e-2;

int main(){

	int n;

    string s;

    cin >> n >> s;



    set<int> st;

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

        string t;

        if(i<10) t += '0';

        if(i<100) t += '0';

        t += to_string(i);

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

        vector<int> v={t[2]-'0', t[1]-'0', t[0]-'0'};

        int k=2;

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

            if(s[j]-'0'==v[k]){

                --k;

                if(k==-1){

                    st.insert(i);

                    break;

                }

            }

        }

    }

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

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

int main(){

	int n;

    string s;

    cin >> n >> s;



    int cnt=0;

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

        vector<int> v={i/100, i/10%10, i%10};

        int k=0;

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

            if(s[j]-'0'==v[k]){

                if(k==2){

                    ++cnt;

                    break;

                }

                ++k;

            }

        }

    }

    cout << cnt << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

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

#define ALL(a) a.begin(), a.end()

#define MOD 1000000007

using namespace std;

typedef long long ll;



int main() {

    int N; string S; cin >> N >> S;

    bool dp[N + 1][4][1000] = {};

    REP(i, 0, N + 1) dp[i][0][0] = true;

    REP(i, 0, N) {

        int cur = S[i] - '0';

        REP(j, 0, 4) {

            REP(k, 0, 1000) {

                dp[i + 1][j][k] = (dp[i + 1][j][k] | dp[i][j][k]);

                int next = 10 * k + cur;

                if (next < 1000 && j < 3) {

                    dp[i + 1][j + 1][next] = (dp[i + 1][j + 1][next] | dp[i][j][k]);

                }

            }

        }

    }

    int ans = 0;

    REP(i, 0, 1000) {

        if (dp[N][3][i]) {

            ans++;

        }

    }

    cout << ans << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

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

#define ALL(a) a.begin(), a.end()

#define MOD 1000000007

using namespace std;

typedef long long ll;



int main() {

    int N; string S; cin >> N >> S;

    bool dp[4][1000] = {};

    dp[0][0] = true;

    REP(i, 0, N) {

        int cur = S[i] - '0';

        for (int j = 2; j >= 0; j--) {

            REP(k, 0, 1000) {

                int next = 10 * k + cur;

                if (next < 1000 && j < 3) {

                    dp[j + 1][next] = (dp[j + 1][next] | dp[j][k]);

                }

            }

        }

    }

    int ans = 0;

    REP(i, 0, 1000) {

        if (dp[3][i]) {

            ans++;

        }

    }

    cout << ans << endl;

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <string>

using namespace std;



int main(){

    int n; cin >> n;

    int cnt = 0;

    string S; cin >> S;

    //cout << S;

    string subS1, subS2, subS3;

    int idx1, idx2, idx3;

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

        string s1 = to_string(i);

        idx1 = S.find_first_of(s1);

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

        subS1 = S.substr(idx1+1);

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

            string s2 = to_string(j);

            idx2 = subS1.find_first_of(s2);

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

            subS2 = subS1.substr(idx2+1);

            

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

                string s3 = to_string(k);

                idx3 = subS2.find_first_of(s3);

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

                else cnt++;

            }

        }

    }

    cout << cnt << endl;;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



int main(){

    ll N; 

    string S;

    ll ans = 0;

    cin >> N >> S;

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

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

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

                char d1 = i+48, d2 = j+48, d3 = k+48;

                auto pos1 = S.find(d1);

                if(pos1 != string::npos){

                    auto pos2 = S.find(d2, pos1+1);

                    if(pos2 != string::npos){

                        auto pos3 = S.find(d3, pos2+1);

                        if(pos3 != string::npos) {

                            ans++;

                        }

                    }



                }

            }

        }

    }

    cout << ans << endl;

}

// Fastest known solution for this problem: