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



using namespace std;



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout << fixed << setprecision(15); 

    int n;

    cin >> n;

    vector<int> a(n);

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

        cin >> a[i]; 

    }

    map<int, int> mpodd, mpeven;

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

        ++mpodd[a[i]]; 

    }  

    for (int i = 1; i < n; i += 2) {

        ++mpeven[a[i]];

    }

    vector<pair<int, int>> odd, even; 

    for (auto it: mpodd) {

        odd.push_back(make_pair(-it.second, it.first)); 

    }

    for (auto it: mpeven) {

        even.push_back(make_pair(-it.second, it.first));  

    }

    odd.push_back(make_pair(0, 0));

    even.push_back(make_pair(0, 0)); 

    sort(odd.begin(), odd.end());

    sort(even.begin(), even.end());

    int ans = 0; 

    if (odd[0].second != even[0].second) ans = n + odd[0].first + even[0].first; 

    else {

        ans = n + min(odd[1].first + even[0].first, odd[0].first + even[1].first); 

    }

    cout << ans << endl; 

    return 0; 

}

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

#define maxn 100010

int cnt[2][maxn], M[2], Q[2], m[2], q[2];

int n;

int main() {

    scanf("%d", &n);

    for (int i = 1, x, p; i <= n; i++) {

        scanf("%d", &x); p = i % 2;

        cnt[p][x]++;

        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;

    }

    if (Q[0] != Q[1]) {

        printf("%d\n", n - M[0] - M[1]);

        return 0;

    }

    for (int i = 1; i <= 100000; i++) {

        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;

        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;

    }

    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);

    else printf("%d\n", n - m[0] - M[1]);

    return 0;

}

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

using namespace std;

#define int long long

#define pb push_back

#define pf push_front

#define pii pair <int, int>

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

#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0

 

//link: https://atcoder.jp/contests/arc103/tasks/arc103_a

 

vector <int> e;

vector <int> o;

map <int, int> mpe;

map <int, int> mpo;

int32_t main() {

	ios_base::sync_with_stdio(0); cin.tie(0);

	bool can = true;

	int n; cin >> n;

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

		int x; cin >> x;

		if (i % 2 == 0) o.pb(x);

		else e.pb(x);

	}

	// find the top 2 modes

	for(auto it:e) {

		++mpe[it];

	}

	vector <pii> MPE; // convert to vector for sorting

	for(auto it:mpe) {

		MPE.pb(make_pair(it.second, it.first));

	}

	sort(all(MPE), greater<pair<int, int> > ());

	int e1 = MPE[0].second;

	int e2 = MPE[1].second;

	cerr << e1 << ' ' << e2 << '\n';

	// repeat!!

	for(auto it:o) {

		++mpo[it];

	}

	vector <pii> MPO;

	for(auto it:mpo) {

		MPO.pb(make_pair(it.second, it.first));

	}

	sort(all(MPO), greater<pair<int, int> >());

	int o1 = MPO[0].second;

	int o2 = MPO[1].second;

	cerr << o1 << ' ' << o2 << '\n';

 

	if (e1 != o1) {

		// assert(0);

		int count = 0;

		for(auto it:e) {

			if (it != e1) ++count;

		}

		for(auto it:o) {

			if (it != o1) ++count;

		}

		cout << count;

		time;

	}

 

	// find the number of changes required for first type

	int count = 0;

	for(auto it:e) {

		if (it != e1) ++count;

	}

	for(auto it:o) {

		if (it != o2) ++count;

	}

	// second type

	int sum = 0;

	for(auto it:e) {

		if (it != e2) ++sum;

	}

	for(auto it:o) {

		if (it != o1) ++sum;

	}

	cout << min(count, sum);

}

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

#define maxn 100010

int cnt[2][maxn], M[2], Q[2], m[2], q[2];

int n;

int main() {

    scanf("%d", &n);

    for (int i = 1, x, p; i <= n; i++) {

        scanf("%d", &x); p = i % 2;

        cnt[p][x]++;

        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;

    }

    if (Q[0] != Q[1]) {

        printf("%d\n", n - M[0] - M[1]);

        return 0;

    }

    for (int i = 1; i <= 100000; i++) {

        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;

        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;

    }

    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);

    else printf("%d\n", n - m[0] - M[1]);

    return 0;

}

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

using namespace std;

 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)

#define mod 1000000007LL

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

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

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

#define sz(v) int(v.size())

 

 

typedef long long ll;

typedef vector<int> vi; 

typedef pair<int,int> ii;





ll pow(ll a, ll b){

    int ans = 1;

    while(b){

        if(b&1) ans=(ans*a)%mod;

        b>>=1;

        a=(a*a)%mod;

    }

    return ans;

}





const int N=1e5;





void run(){

	

	int n; cin>>n;

	

	vi v(n);

	FOR(i,0,n) cin>>v[i];

	

	map<int, int> m, p;

	int x=0, ans=0, b;

	

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

		if(!m.count(v[i])){

			m[v[i]]=1;

		}

		else m[v[i]]=m[v[i]]+1;

		

		if(m[v[i]]>x){

			x=m[v[i]]; b=v[i];

		}

	}

	

	

	int y=0, c;

	

	for(int i=1; i<n; i=i+2){

		if(!p.count(v[i])){

			p[v[i]]=1;

		}

		else p[v[i]]=p[v[i]]+1;

		

		if(p[v[i]]>y){

			y=p[v[i]]; c=v[i];

		}

	}

		

	if(b==c){

		int w=0, z=0;

		for(auto xd : m){

			if(xd.fst==b) continue;

			w=max(w,xd.snd);

		}

		for(auto xd : p){

			if(xd.fst==c) continue;

			w=max(w,xd.snd);

		}

		ans=n-x-max(w,z);

	}

	else ans=n-x-y;

	

	cout<<ans<<"\n";

}





int main(){

	

	fastio;

	

	int tt=1; 

	//cin>>tt;

	

	while(tt--){

		run();

	}

	

	return 0;

}


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

#define maxn 100010

int cnt[2][maxn], M[2], Q[2], m[2], q[2];

int n;

int main() {

    scanf("%d", &n);

    for (int i = 1, x, p; i <= n; i++) {

        scanf("%d", &x); p = i % 2;

        cnt[p][x]++;

        if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;

    }

    if (Q[0] != Q[1]) {

        printf("%d\n", n - M[0] - M[1]);

        return 0;

    }

    for (int i = 1; i <= 100000; i++) {

        if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;

        if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;

    }

    if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);

    else printf("%d\n", n - m[0] - M[1]);

    return 0;

}

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

#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<math.h>

#include<string>

#include<vector>

#include<queue>

#include<stack>

#include<map>

#include<set>

#include<list>

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long



using namespace std;

int num[100005];

int ev[100005];

int od[100005];

int main()

{

	int n;

	cin>>n;

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

		cin>>num[i];



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

	{

		if(i&1) od[num[i]]++;

		else ev[num[i]]++;

	}

	int anse = 0,anso = 0;

	int ae = 0 , ao = 0;

	int sume = 0,sumo = 0;

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

	{

		if(anse <= ev[i])

		{

			ae = anse;

			anse = ev[i];

			sume = i;

		}

		else if(ae < ev[i])

		{

			ae = ev[i];

		}

		if(anso <= od[i])

		{

			ao = anso;

			anso = od[i];

			sumo = i;

		}

		else if(ao < od[i])

		{

			ao = od[i];

		}

	}

	if(sumo != sume)

	{

		cout<<n-anse-anso<<endl;

	}

	else cout<<min(n-anse-ao,n-anso-ae)<<endl;

	

	return 0;

}


// Optimized solution to the same problem (faster):
// oh, the less I know the better

// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz

#include <bits/stdc++.h>

#define endl '\n'

#define pb push_back

#define sz(x) int(x.size())

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

#define trace(x) cout << #x << " = " << x << endl

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

typedef long long ll;

typedef pair<int,int> ii;



int main(){



	fastio;

	int n;

	cin >> n;

	vector<int> a,b;

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

		int x;

		cin >> x;

		if(i&1) a.pb(x);

		else b.pb(x);

	}



	vector< pair<int,int> > besta, bestb;

	map<int,int> mpa,mpb;

	mpa[1e6]; mpb[1e6+1];

	for(int x : a) mpa[x]++;

	for(auto p : mpa){

		besta.pb(make_pair(p.second,p.first));

	}

	for(int x : b) mpb[x]++;

	for(auto p : mpb){

		bestb.pb(make_pair(p.second,p.first));

	}



	sort(besta.rbegin(),besta.rend());

	sort(bestb.rbegin(),bestb.rend());



	int ans = 1e9;

	for(int i = 0; i < min(sz(besta),10); ++i){

		for(int j = 0; j < min(sz(bestb),10); ++j){

			if(besta[i].second == bestb[j].second) continue;

			ans = min(ans, n - besta[i].first - bestb[j].first);

		}

	}



	cout << ans << endl;



	return 0;

}


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

#include<algorithm>

using namespace std;

const int M=2e5+7;

int read(){

	int ans=0,f=1,c=getchar();

	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}

	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}

	return ans*f;

}

int n,s[M],v1[M],v2[M];

int main(){

	n=read();

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

		s[i]=read();

		if(i&1) v1[s[i]]++;

		else v2[s[i]]++;

	}

	int id1=0,cnt1=0,id2=0,cnt2=0;

	for(int i=1;i<=1e5;i++) if(v1[i]>cnt1) cnt1=v1[i],id1=i;

	for(int i=1;i<=1e5;i++) if(i!=id1&&v1[i]>cnt2) cnt2=v1[i],id2=i;

	int id3=0,cnt3=0,id4=0,cnt4=0;

	for(int i=1;i<=1e5;i++) if(v2[i]>cnt3) cnt3=v2[i],id3=i;

	for(int i=1;i<=1e5;i++) if(i!=id3&&v2[i]>cnt4) cnt4=v2[i],id4=i;

	if(id1!=id3) printf("%d\n",n-cnt1-cnt3);

	else printf("%d\n",n-cnt1-max(cnt2,cnt4));

	return 0;

}

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

using namespace std;

const int MAXN=100005;

int a[MAXN];

map<int,int> odd;

map<int,int> even;

typedef pair<int,int> pa;

pa od[MAXN];

pa ev[MAXN];

int main(){

	int n;

	int mxo=0,mx1=0,mxe=0,mx2=0;

	int num1,num2,num3,num4;

	int inf=0;

	scanf("%d",&n);

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

		scanf("%d",&a[i]); 

		inf=inf<a[i]?a[i]:inf;

		if(i&1){

			odd[a[i]]=odd.count(a[i])?odd[a[i]]+1:1;

		}

		else{

			even[a[i]]=even.count(a[i])?even[a[i]]+1:1;

		}

	}

	n>>=1;

	int cnt=0;

	for(map<int,int>::iterator it=odd.begin();it!=odd.end();it++){

		od[++cnt]=make_pair(it->second,it->first);

	}

	cnt=0;

	for(map<int,int>::iterator it=even.begin();it!=even.end();it++){

		ev[++cnt]=make_pair(it->second,it->first);

	}

	sort(od+1,od+n+1);

	sort(ev+1,ev+n+1);

	if(n==1){

		mx1=mx2=0;

	}

	mxe=od[n].first,mxo=ev[n].first;

	mx1=od[n-1].first,mx2=ev[n-1].first;

	num1=od[n].second,num3=ev[n].second;

	num2=od[n-1].second,num4=ev[n-1].second;

	if(num1!=num3){

		printf("%d\n",n*2-mxe-mxo);

	} 

	else{

		printf("%d\n",min(n*2-mx1-mxe,n*2-mx2-mxo));

	}

	return 0;

}

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

#include <vector>

#include <algorithm>



using namespace std;



int main(void) {

    int n;

    cin >> n;

    vector<int> odd(200000), even(200000);

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

        int v;

        cin >> v;

        if(i%2) {

            odd[v]++;

        } else {

            even[v]++;

        }

    }



    int odd_max_pos = distance(odd.begin(), max_element(odd.begin(), odd.end()));

    int odd_max_val = *max_element(odd.begin(), odd.end());

    *max_element(odd.begin(), odd.end()) = 0;

    int odd_sec_pos = distance(odd.begin(), max_element(odd.begin(), odd.end()));

    int odd_sec_val = *max_element(odd.begin(), odd.end());



    int even_max_pos = distance(even.begin(), max_element(even.begin(), even.end()));

    int even_max_val = *max_element(even.begin(), even.end());

    *max_element(even.begin(), even.end()) = 0;

    int even_sec_pos = distance(even.begin(), max_element(even.begin(), even.end()));

    int even_sec_val = *max_element(even.begin(), even.end());



    if(odd_max_pos == even_max_pos) {

        cout << n - max(odd_max_val + even_sec_val, odd_sec_val + even_max_val) << endl;

    } else {

        cout << n - odd_max_val - even_max_val << endl;

    }

    return 0;

}


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

#include <vector>

#include <algorithm>



using namespace std;



int main(void) {

    int n;

    cin >> n;

    vector<int> odd(200000), even(200000);

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

        int v;

        cin >> v;

        if(i%2) {

            odd[v]++;

        } else {

            even[v]++;

        }

    }



    auto m = max_element(odd.begin(), odd.end());

    int odd_max_pos = distance(odd.begin(), m);

    int odd_max_val = *m;

    *m = 0;

    m = max_element(odd.begin(), odd.end());

    int odd_sec_pos = distance(odd.begin(), m);

    int odd_sec_val = *m;



    m = max_element(even.begin(), even.end());

    int even_max_pos = distance(even.begin(), m);

    int even_max_val = *m;

    *m = 0;

    m = max_element(even.begin(), even.end());

    int even_sec_pos = distance(even.begin(), m);

    int even_sec_val = *m;



    if(odd_max_pos == even_max_pos) {

        cout << n - max(odd_max_val + even_sec_val, odd_sec_val + even_max_val) << endl;

    } else {

        cout << n - odd_max_val - even_max_val << endl;

    }

    return 0;

}


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

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

using namespace std;

using ll = long long;

using P = pair<int, int>;

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 (b<a) {a=b; return 1;} return 0;}



int main(){

    int n;

    cin >> n;

    string s;

    cin >> s;

    int ans = 0;

    rep(i, 10) {

        rep(j, 10) {

            rep(k, 10) {

                string num = to_string(i*100+j*10+k);

                if (i == 0) {

                    if (j == 0) { 

                        num = "00" + num;

                    }

                    else {

                        num = "0" + num;

                    }

                }

                int now = 0;

                rep(l, n) {

                    if (now == 3) break;

                    if (s[l] == num[now]) now++;

                }

                if (now == 3) ans++;

            }

        }

    }

    cout << ans << endl;

}

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

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

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

using namespace std;

using ll = long long;

using P = pair<int, int>;

template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}

template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>

auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}

template<typename T,typename U,typename... V>

typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>

typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int n; string s;

    cin >> n >> s;



    int ans = 0;

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

        int now = 0;

        rep(l, n) {

            if (now == 0) {

                if (s[l] == '0' + i) now = 1;

            } else if (now == 1) {

                if (s[l] == '0' + j) now = 2;

            } else if (now == 2) {

                if (s[l] == '0' + k) {

                    now = 3;

                    break;

                }

            }

        }

        if (now == 3) ans++;

    }

    cout << ans << endl;

}


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

using namespace std;



int main(){

  int N,spos,spos2,spos3;

  string S,ans,s1,s2,s3;

  set<string> result;

  cin >>N>>S;

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

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

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

        

        ans=S;

        s1=to_string(l);

        s2=to_string(j);

        s3=to_string(i);

        spos=ans.find_last_of(s1);

        if(spos == std::string::npos)

         continue;

        else{

          ans.erase(spos);

          //cout<<ans<<"a"<<endl;

        }

        spos=ans.find_last_of(s2);

        if(spos == std::string::npos)

          continue;

        else{

          ans.erase(spos);

          //cout<<ans<<"b"<<endl;

        }

        spos=ans.find_last_of(s3);

        if(spos == std::string::npos)

          continue;

        else{

          ans.erase(spos);

          //cout<<ans<<"c"<<endl;

        }

        ans=s3+s2+s1;

        //cout <<ans<<"d"<<endl;

        result.insert(ans);

      }

      //cout<<endl;

    }

    //cout<<endl;

  }

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

}


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

using namespace std;



int main() {

    string S,CS,CS2,CS3;

    int N,ans=0;

    char num1,num2,num3;

    cin >> N;

    cin >> S;

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

        CS  = S;

        num1 = '0' + i;

        if(CS.find(num1)==string::npos){

                    continue;

                }

        else

        {

            CS.erase(0,CS.find(num1)+1);

        }

        

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

            CS2=CS;

            num2 = '0' + j;

            if(CS2.find(num2)==string::npos){

                    continue;

                }

            else

            {

                CS2.erase(0,CS2.find(num2)+1);

            }

            

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

                CS3=CS2;

                num3 = '0' + k;

                if(CS3.find(num3)==string::npos){

                    continue;

                }

                else

                {

                    ans++;

                }

            }

        }

    }



    cout << ans <<endl;



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
// template.cpp



// Defines.

//#define DEBUG

#define NUMBER_OF_DIGITS 6



// Includes.

#include <bits/stdc++.h>



#ifdef DEBUG

#include <chrono>

#endif



// Usings.

using namespace std;



// Main function.

int main()

{

#ifdef DEBUG

	chrono::system_clock::time_point start, end;

	

	start = chrono::system_clock::now();

#endif

	

	// settings.

	ios::sync_with_stdio(false);

	

	//cout << fixed;

	//cout << setprecision(NUMBER_OF_DIGITS);

	

	// logic.

	int n;

	cin >> n;

	

	string s;

	cin >> s;

	

	set<char> flags1;

	set<char> flags2;

	

	set<string> keys;

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

	{

		if (flags1.count(s[i]) > 0)

		{

			continue;

		}

		

		for (int j = (i + 1); j < n; j++)

		{

			if (flags2.count(s[j]) > 0)

			{

				continue;

			}

			

			for (int k = (j + 1); k < n; k++)

			{

				string key;

				key += s[i];

				key += s[j];

				key += s[k];

				

				keys.insert(key);

				flags1.insert(s[i]);

				flags2.insert(s[j]);

			}

		}

		

		flags2.clear();

	}

	

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

	

#ifdef DEBUG

	end = chrono::system_clock::now();

	

	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();

	cout << elapsed << "[ms]" << endl;

#endif

	

	return 0;

}


// Optimized solution to the same problem (faster):
// template.cpp



// Defines.

//#define DEBUG

#define NUMBER_OF_DIGITS 6



// Includes.

#include <bits/stdc++.h>



#ifdef DEBUG

#include <chrono>

#endif



// Usings.

using namespace std;



// Main function.

int main()

{

#ifdef DEBUG

	chrono::system_clock::time_point start, end;

	

	start = chrono::system_clock::now();

#endif

	

	// settings.

	ios::sync_with_stdio(false);

	

	//cout << fixed;

	//cout << setprecision(NUMBER_OF_DIGITS);

	

	// logic.

	int n;

	string s;

	cin >> n;

	cin >> s;

	

	int counter = 0;

	

	vector<bool> flags1;

	for (int number = 0; number < 10; number++)

	{

		flags1.push_back(false);

	}

	

	for (int i = 0; i < (n - 2); i++)

	{

		char c1 = s[i];

		if (flags1[c1 - '0'] == true)

		{

			continue;

		}

		flags1[c1 - '0'] = true;

		

		vector<bool> flags2;

		for (int number = 0; number < 10; number++)

		{

			flags2.push_back(false);

		}

		

		for (int j = (i + 1); j < (n - 1); j++)

		{

			char c2 = s[j];

			if (flags2[c2 - '0'] == true)

			{

				continue;

			}

			flags2[c2 - '0'] = true;

			

			vector<bool> flags3;

			for (int number = 0; number < 10; number++)

			{

				flags3.push_back(false);

			}

			

			for (int k = (j + 1); k < n; k++)

			{

				char c3 = s[k];

				if (flags3[c3 - '0'] == true)

				{

					continue;

				}

				flags3[c3 - '0'] = true;

				counter++;

			}

		}

	}

	

	

	cout << counter << endl;



#ifdef DEBUG

	end = chrono::system_clock::now();

	

	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();

	cout << elapsed << "[ms]" << endl;

#endif

	

	return 0;

}


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

using namespace std;

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

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

#define  all(x) (x).begin(),(x).end()     // 昇順ソート

#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート

#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef long long ll;

using P = pair<int,int>;

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

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



int main(){

    int n;

    string s;

    cin >> n >> s;

    set<string> st1;

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

        set<string> st2 = st1;

        for(auto stt: st2){

            if (stt.size() == 3) continue;

            if (st2.find(stt+s[i]) == st2.end()) st1.insert(stt+s[i]);

        }

        st1.insert({s[i]});

    }

    int ans = 0;

    for(auto stt: st1){

        if (stt.size() == 3) ans++;

    }

    cout << ans << endl;

    return 0;

}

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

using namespace std;

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

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

#define  all(x) (x).begin(),(x).end()     // 昇順ソート

#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート

#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef long long ll;

using P = pair<int,int>;

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

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



int main(){

    int n;

    string s;

    cin >> n >> 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++){

                int cnt = 0;

                int l = 0;

                while(l < n){

                    if (cnt == 0 && s[l] == '0'+i) cnt++;

                    else if (cnt == 1 && s[l] == '0'+j) cnt++;

                    else if (cnt == 2 && s[l] == '0'+k) cnt++;

                    l++;

                }

                if (cnt == 3) ans++;

            }

        }

    }

    cout << ans << endl;

    return 0;

}

// Fastest known solution for this problem: