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

}


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

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

}

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

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

}


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



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

}


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

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

}

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

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

}

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

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

using namespace std;

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

#define rep1(i,N) for(int i=1;i<int(N);++i)

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

#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }



typedef long long ll;



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

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



const int INF = 1e9;

const ll INFLL = 1e18;

const ll MOD = 1e9+7;

const double PI = acos(-1.0);



const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};



/*------------------------------------/

for library*/



/*------------------------------------*/



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);

    cout << fixed << setprecision(20);



    int N;

    string S;

    cin>>N>>S;

    set<string> set1pre,set2pre,set3;

    string y = "";

    y.push_back(S[0]);

    set1pre.insert(y);

    rep1(i,N){

        set<string> set1,set2;

        string xx = "";

        xx.push_back(S[i]);

        set1.insert(xx);

        for(auto x1:set1pre){

            set1.insert(x1);

            x1.push_back(S[i]);

            set2.insert(x1);

        }

        for(auto x2:set2pre){

            set2.insert(x2);

            x2.push_back(S[i]);

            set3.insert(x2);

        }

        swap(set1pre,set1);

        swap(set2pre,set2);

    }

    /*

    for(auto x:set1pre){

        cerr<<x<<endl;

    }

    cerr<<endl;

    for(auto x:set2pre){

        cerr<<x<<endl;

    }

    cerr<<endl;

    for(auto x:set3){

        cerr<<x<<endl;

    }

    cerr<<endl;

    */

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



}

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

using namespace std;

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



int main() {

    int N;

    string S;

    cin>>N>>S;

    

    set<int> s1,s2,s3;

    rep(i,N){

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

        for(auto x:s2){

            s3.insert(x * 10 + num);

        }

        for(auto x:s1){

            s2.insert(x * 10 + num);

        }

        s1.insert(num);

    }

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

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

}




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

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

}

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

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

}


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

}