stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 1.1602639275234667x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 1.1732537852684297x):
#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;

}
// 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 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;

}


// Faster C++ solution for the same problem (measured speedup: 1.4778044483073671x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 1.716092056570775x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 1.2160748407781399x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.2301569305843492x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.113576042058292x):
#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;

}
// Slower C++ solution:
#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;;

}

// Faster C++ solution for the same problem (measured speedup: 1.114300150999815x):
#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;

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



using namespace std;

using ll=long long;



int main()

{

    int n;cin >>n;

    string s;cin >>s;

    string num[1000];

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

        ostringstream ss;

        ss << i;

        num[i]=ss.str();

        string a="00",b="0";

        if(i<10){

            swap(a,num[i]);

            num[i]+=a;

        }

        else if(i<100){

            swap(b,num[i]);

            num[i]+=b;

        }

    }

    ll ans=0;

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

        bool flg=true;int t=0;

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

            bool w=true;

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

                if(num[i][k]==s[j]&&w){

                    t=j+1;

                    w=false;

                }

            }

            if(w)flg=false;

        }

        if(flg)ans++;

    }

    cout << ans << endl;

    return 0;

}


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



using namespace std;

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

using ll=long long;

const int INF = 1<<30;

const ll INFll =1LL<<62;

const int mod= int(1e9)+7;

using P = pair<ll,ll>;

using ld=long double;



vector<string>ans;

void f(string a){

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

        ans.push_back(a);

        return;

    }

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

        a+=(char)('0'+i);

        f(a);

        a.pop_back();

    }

}



int main(){

    f("");

    ll n;cin >>n;

    string s;cin >>s;

    ll cnt=0;

    for(auto a:ans){

        ll k=0;

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

            if(a[k]==s[i]){

                if(k==2){

                    cnt++;

                    break;

                }

                else k++;

            }

        }

    }

    cout <<cnt <<endl;

    return 0;

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

using namespace std;

typedef long long ll;

const int INF = (1<<30);

const ll INFLL = (1ll<<60);

const ll MOD = (ll)(1e9+7);



#define l_ength size



void mul_mod(ll& a, ll b){

	a *= b;

	a %= MOD;

}



void add_mod(ll& a, ll b){

	a = (a<MOD)?a:(a-MOD);

	b = (b<MOD)?b:(b-MOD);

	a += b;

	a = (a<MOD)?a:(a-MOD);

}



string s;

bool dp[30303][11][11][11];



int main(void){

	int n,i,p,q,r,ans=0;

	cin >> n;

	cin >> s;

	dp[0][10][10][10] = true;

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

		for(p=0; p<11; ++p){

			for(q=0; q<11; ++q){

				for(r=0; r<11; ++r){

					dp[i+1][p][q][r] |= dp[i][p][q][r];

					dp[i+1][q][r][s[i]-'0'] |= dp[i][p][q][r];

				}

			}

		}

	}

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

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

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

					if(dp[n][p][q][r]){

						++ans;

					}

				}

			}

		}

	cout << ans << endl;

	return 0;

}


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

using namespace std;

typedef long long ll;

const int INF = (1<<30);

const ll INFLL = (1ll<<60);

const ll MOD = (ll)(1e9+7);



#define l_ength size



void mul_mod(ll& a, ll b){

	a *= b;

	a %= MOD;

}



void add_mod(ll& a, ll b){

	a = (a<MOD)?a:(a-MOD);

	b = (b<MOD)?b:(b-MOD);

	a += b;

	a = (a<MOD)?a:(a-MOD);

}



string s;

int d[30303][10];

bool ans[10][10][10];



int main(void){

	int n,i,j,k,cnt=0;

	cin >> n;

	cin >> s;

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

		s[i] -= '0';

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

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

		}

		++d[i+1][s[i]];

	}

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

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

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

				if(d[i][j] && (d[n][k]-d[i+1][k])){

					ans[j][s[i]][k] = true;

				}

			}

		}

	}

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

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

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

				if(ans[i][j][k]){

					++cnt;

				}

			}

		}

	}

	cout << cnt << endl;

	return 0;

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

#include<iomanip>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<functional>

#include<map>

#include<cstdlib>

#include<complex>

#include<numeric>

#include<set>

#include<deque>

#include<queue>



using namespace std;

using Int = long long;

Int INF = 1LL << 60;

const Int MOD = 1000000000 + 7;



template<class T>//ex) auto dp = make_vec(4,4,4,INF);

vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }

template<class... Size>

auto make_vec(size_t s, Size... tail) {

	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));

}





int main() {



	cin.tie(nullptr);

	ios::sync_with_stdio(false);



	Int N;

	cin >> N;



	string S;

	cin >> S;



	auto dp = make_vec(N + 1, 4, 1000, 0);//dp[i+1][j][k]:i文字目まで見てj文字確定したときの文字列kが実現できるなら1

	dp[0][0][0] = 1;



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

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

			for (Int k = 0; k < 100; k++) {

				if (dp[i][j][k]==0) {

					continue;

				}

				//i文字目を選択する場合

				dp[i + 1][j + 1][10 * k + (S[i] - '0')] = 1;

			

				//i文字目を選択しない場合

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

			}

		}

	}



	Int ans = 0;

	vector<bool> seen(1000,false);

	for (Int i = 1; i <= N; i++) {

		for (Int k = 0; k < 1000; k++) {

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

				if (seen[k]) {

					continue;

				}

				ans++;

				seen[k] = true;

			}

		}

	}

	cout << ans << "\n";



}


// Faster C++ solution for the same problem (measured speedup: 1.5772302110390999x):
#include<iostream>

#include<iomanip>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<functional>

#include<map>

#include<cstdlib>

#include<complex>

#include<numeric>

#include<set>

#include<deque>

#include<queue>



using namespace std;

using Int = long long;

Int INF = 1LL << 60;

const Int MOD = 1000000000 + 7;



template<class T>//ex) auto dp = make_vec(4,4,4,INF);

vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }

template<class... Size>

auto make_vec(size_t s, Size... tail) {

	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));

}





int main() {



	cin.tie(nullptr);

	ios::sync_with_stdio(false);



	Int N;

	cin >> N;



	string S;

	cin >> S;



	auto dp = make_vec(N + 1, 4, 1000, false);//dp[i+1][j][k]:i文字目まで見てj文字確定したときの文字列kが実現できるなら1

	dp[0][0][0] = 1;



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

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

			for (Int k = 0; k < 100; k++) {

				if (!dp[i][j][k]) {

					continue;

				}

				//i文字目を選択する場合

				dp[i + 1][j + 1][10 * k + (S[i] - '0')] = true;

			

				//i文字目を選択しない場合

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

			}

		}

	}



	Int ans = 0;

	vector<bool> seen(1000,false);

	for (Int i = 1; i <= N; i++) {

		for (Int k = 0; k < 1000; k++) {

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

				if (seen[k]) {

					continue;

				}

				ans++;

				seen[k] = true;

			}

		}

	}

	cout << ans << "\n";



}
// 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.3805996136271732x):
#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;

        char a_ = to_string(a)[0];

        rep(i, 0, N-2) {

            if (S[i] == a_) {

                a_i = i;

                break;

            }

        }

        if (a_i == -1) continue;

        rep(b, 0, 10) {

            int b_i = -1;

            char b_ = to_string(b)[0];

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

                if (S[i] == b_) {

                    b_i = i;

                    break;

                }

            }

            if (b_i == -1) continue;

            rep(c, 0, 10) {

                char c_ = to_string(c)[0];

                rep(i, b_i+1, N) {

                    if (S[i] == c_) {

                        res++;

                        break;

                    }

                }

            }

        }

    }

    cout << res << endl;

}