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

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



using namespace std;

typedef long long LL;



int main(){

  int N, X;

  cin >> N >> X;

  vector<int> x(N);

  rep(i,N) cin >> x[i];

  int d[100010]={0};

  rep(i,N) d[i]=abs(X-x[i]);

  int ans=d[0];

  rep(i,N-1) ans=__gcd(ans,d[i+1]);

  cout << ans << endl;



  return 0;

}


// Optimized solution to the same problem (faster):
#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>;



int main(){

	int N, X;

	cin >> N >> X;

	vector<int> x(N), d(N);

	rep(i,N) cin >> x[i];

	rep(i,N) d[i]=abs(X-x[i]);

	int ans=d[0];

	rep(i,N-1) ans=__gcd(ans,d[i+1]);

	cout << ans << endl;



	return 0;

}

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

#include<climits>

#include<vector>

#include<list>

#include<functional>

#include<algorithm>

#include<string>

#include<cmath>

#include<complex>

#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

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

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

#define INF (int)1e9

#define INFL (ll)1e11

using namespace std;

typedef long long ll;

typedef pair<int, int> P;



set<int> yakusu(int x) {

	set<int> tmp;

	for (int i = 1;i <= sqrt(x);i++) {

		if (x%i == 0) {

			tmp.insert(i);

			tmp.insert(x / i);

		}

	}

	return tmp;

}



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);



	int N, X;

	cin >> N >> X;

	set<int> dis;

	REP(i, N) {

		int x;

		cin >> x;

		x = abs(x-X);

		dis.insert(x);

	}

	set<int> y = yakusu(*dis.begin());

	set<int>::iterator res = y.end();

	res--;

	

	bool flag = true;

	while (flag) {

		for (set<int>::iterator itr = dis.begin();itr != dis.end();++itr) {

			if (*itr%*res != 0) {

				res--;

				break;

			}

			

			set<int>::iterator end = dis.end();

			if (itr == --end) flag = false;

		}

	}

	cout << *res << "\n";



	return 0;

}

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

#include<climits>

#include<vector>

#include<list>

#include<functional>

#include<algorithm>

#include<string>

#include<cmath>

#include<complex>

#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

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

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

#define INF (int)1e9

#define INFL (ll)1e11

using namespace std;

typedef long long ll;

typedef pair<int, int> P;



int gcd(int x, int y) {

	if (x < y) return gcd(y, x);

	return y == 0 ? x : gcd(x%y, y);

}



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);



	int N, X;

	cin >> N >> X;

	vector<int> dis(N);

	REP(i, N) {

		int x;

		cin >> x;

		dis[i] = abs(x - X);

	}

	int res = dis[0];

	REP(i, N) res = gcd(res, dis[i]);

	cout << res << "\n";





	return 0;

}

		

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

#include <algorithm>

#include <iostream>

#include <map>

#include <numeric>

#include <set>

#include <sstream>

#include <string>

#include <vector>

using namespace std;

typedef long long ll;



bool check(int i, vector<int> v){

  bool flag = true;

  for (auto e: v){

    if (e%i != 0){

      flag = false;

      break;

    }

  }

  return flag;

}



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



  int N, X; cin >> N >> X;

  vector<int> x(N);

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

    int xtemp; cin >> xtemp;

    x[i] = abs(xtemp-X);

  }

  int xmin = x[min_element(x.begin(), x.end()) - x.begin()];

  int D = 1;

  for (int i=1; i*i<=xmin; i++){

    if (xmin%i == 0){

      if (check(i, x))

        D = max(D, i);

      if (check(xmin/i, x))

        D = max(D, xmin/i);

    }

  }

  cout << D << endl;

  return 0;

}

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

#include <algorithm>

#include <iostream>

#include <map>

#include <numeric>

#include <set>

#include <sstream>

#include <string>

#include <vector>

using namespace std;

typedef long long ll;



int gcd(int a, int b){

  if (a<b)

    swap(a,b);

  if (b == 0)

    return a;

  else

    return gcd(b, a%b);

}



int main(){

  

  int N, X; cin >> N >> X;

  

  vector<int> x(N);

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

    int xtemp; cin >> xtemp;

    x[i] = abs(xtemp-X);

  }

  

  int ans = gcd(x[0], x[1]);

  for (int i=2; i<N; i++)

    ans = gcd(ans, x[i]);

  

  cout << ans << endl;

  

  return 0;

}

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

#define model l,mid,num<<1

#define moder mid+1,r,num<<1|1

#define bug(k)  cout<<"text :"<<t<<endl

#define lowbit(k) k&-k

using namespace std;

typedef long long LL;

const LL mod=1e9+7;

const int M=1e5+5;

map <string,int> ma;

int n,x;

int arr[M];

int bits_gcd(int x,int y)

{

    if(y==0)return x;

    if(x==0)return y;

    int i,j;

    for(i=0;0==(x&1);i++)x>>=1;

    for(j=0;0==(y&1);j++)y>>=1;

    if(i>j)i=j;

    while(1)

    {

        if(x<y)x^=y,y^=x,x^=y;

        if(0==(x-=y))return y<<i;

        while(0==(x&1))x>>=1;

    }

}

int main()

{

     int ans;

     int t;

     while(cin>>n>>x)

     {

         ans=INT_MAX;

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

         {

             scanf("%d",&t);

             if(t>x)t^=x,x^=t,t^=x;

             arr[i]=x-t;

         }

         int ans=arr[1];

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

         {

//             cout<<ans<<" "<<arr[i]<<endl;

//             cout<<bits_gcd(ans,arr[i])<<endl;

             ans=bits_gcd(ans,arr[i]);

         }

         cout<<ans<<endl;

     }

}

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

int abs(int x) {

	return (x>0)?x:-x;

}

int n,k;

int gcd(int a,int b) {

	return (b==0)?a:gcd(b,a%b);

}

int main()

{

	int x,G;

	scanf("%d%d",&n,&k);

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

		scanf("%d",&x);

		if(i==1) G=abs(x-k);

		else G=gcd(G,abs(x-k));

	}

	printf("%d",G);

}

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

using namespace std;

int cnt[100010];

int res[100010];

int a[100010];

int main(){

	int n,m;

	cin>>n>>m;

	int b=0;

	for(int i=0;i<n;i++)cin>>a[i];

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

		cnt[b]=abs(a[i]-m);

		b++;

	}

	sort(cnt,cnt+n);

	int x=cnt[0];

	int c=0;

	for(int i=1;i*i<=x;i++){

		if(x%i==0){

			res[c]=i;

			c++;

			res[c]=x/i;

			c++;

		}

	}

	sort(res,res+c);

	for(int i=c-1;i>=0;i--){

		bool flag=true;

		int ans=m;

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

			if(abs(a[j]-ans)%res[i]!=0){

				flag=false;

				break;

			}

			ans=a[j];

		}

		if(flag){

			cout<<res[i]<<endl;

			return 0;

		}

	}

	return 0;

}

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

#include <sstream>

#include <fstream>

#include <string>

#include <vector>

#include <deque>

#include <queue>

#include <stack>

#include <set>

#include <map>

#include <algorithm>

#include <functional>

#include <utility>

#include <bitset>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cstdio>

#include <string.h>

using namespace std;

int n,m;

int a[100010];

int main(){

	//freopen("input.txt","r",stdin);

	//freopen("output.txt","w",stdout);

	cin>>n>>m;

	for(int i=0;i<n;i++)cin>>a[i];

	vector<int> v;

	v.push_back(abs(m-a[0]));

	for(int i=0;i<n-1;i++)v.push_back(abs(a[i]-a[i+1]));

	int ans=v[0];

	for(int i=1;i<v.size();i++)ans=__gcd(ans,v[i]);

	cout<<ans<<endl;

	return 0;

}

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

#include <bits/stdc++.h>

#define pb push_back

#define ob pop_back

#define xx first

#define yy second

#define dob double

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

#define int long long int

#define ss size()

using namespace std;

const int M=1e9+7,maxn=100010;

std::vector<int> adj[maxn];

std::vector<int> v1;

int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn];

bool mark[maxn],bpart[maxn];

string s,s1,s2;

map <string ,int> mp;

bool markchaild[maxn];

bool dfsmach(int v){

    if(v==-1) return true;

    if(mark[v]==1) return false;

    mark[v]=1;

    for(int i=0;i<adj[v].ss;i++){

        int u=adj[v][i];

        if(dfsmach(mach[u])){

            bpart[u]=((bpart[v]+1)%2);

            mach[u]=v;

            mach[v]=u;

            return true;

        }

    }

    return false;

}





int32_t main() {

    cin>>n>>m>>k;

    if(n<=k&&m>=k)

        cout<<"Yes";

    else

        cout<<"No";

    return 0;

}


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



int main()

{

	int a,b,c;

	scanf ("%d %d %d",&a,&b,&c);

	if (c>=a && c<=b )

	{

		printf ("Yes\n");

	}

	else printf ("No\n");

}

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

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<cstring> 

#include<queue>

#include<stack> 

#include<string.h>

#include<set>

#define ll long long

using namespace std;

int main()

{

	int a,b,c;

	scanf("%d%d%d",&a,&b,&c);

	if(c>=a&&c<=b)

	{

		printf("Yes\n");

	}

	else

	printf("No\n");

	return 0;

}

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



int main()

{

	int a,b,c;

	scanf ("%d %d %d",&a,&b,&c);

	if (c>=a && c<=b )

	{

		printf ("Yes\n");

	}

	else printf ("No\n");

}

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

#include <cstring>

#include <cmath>

#include <algorithm>

#include <iostream>

#include <sstream>

#include <queue>

#include <map>

#include <vector>

#include <set>

#include <cstdlib>

#include <stack>



using namespace std;



typedef long long LL;

typedef double db;

#define FAST ios::sync_with_stdio(false);

const int MaxN = 105;

int main()

{

	int a , b ,c;

	cin >> a >> b >> c;

	if(c >= a && c <= b)cout << "Yes" << endl;

	else cout << "No" << endl;

	return 0;

	}

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



int main()

{

	int a,b,c;

	scanf ("%d %d %d",&a,&b,&c);

	if (c>=a && c<=b )

	{

		printf ("Yes\n");

	}

	else printf ("No\n");

}

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

using namespace std;



int main()

{

    int a; int b; int c;

    cin>>a>>b>>c;

    if(c>=a&&c<=b)

        cout<<"Yes"<<endl;

    else

        cout<<"No"<<endl;



}


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



int main()

{

	int a,b,c;

	scanf ("%d %d %d",&a,&b,&c);

	if (c>=a && c<=b )

	{

		printf ("Yes\n");

	}

	else printf ("No\n");

}

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

using namespace std;

int main()

{

   int a,b,c;

   cin>>a>>b>>c;

   if(c>=a && c<=b)

    cout<<"Yes";

    else

        cout<<"No";

    return 0;

}

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



int main()

{

	int a,b,c;

	scanf ("%d %d %d",&a,&b,&c);

	if (c>=a && c<=b )

	{

		printf ("Yes\n");

	}

	else printf ("No\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
//This code is solely the property of StarnyC



#include<bits/stdc++.h>

using namespace std;

int main()



{

int a,b,c;

cin>>a>>b>>c;

if(c<=b&&a<=c){cout<<"Yes";}

else{cout<<"No";

}

}






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



int main()

{

	int a,b,c;

	scanf ("%d %d %d",&a,&b,&c);

	if (c>=a && c<=b )

	{

		printf ("Yes\n");

	}

	else printf ("No\n");

}

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

using namespace std;

int main()

{

   int A,B,C;

  cin>>A>>B>>C;

  if(C>=A&&C<=B)

cout<<"Yes";

else

cout<<"No";

return 0;

}

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



int main()

{

	int a,b,c;

	scanf ("%d %d %d",&a,&b,&c);

	if (c>=a && c<=b )

	{

		printf ("Yes\n");

	}

	else printf ("No\n");

}

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

using namespace std;

int main()

{

	int a,b,c;

	cin>>a>>b>>c;

	if(c>=a)

	{

		if(c<=b)

		cout<<"Yes";

		else

		cout<<"No";

	}

	else

	cout<<"No";

}

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



int main()

{

	int a,b,c;

	scanf ("%d %d %d",&a,&b,&c);

	if (c>=a && c<=b )

	{

		printf ("Yes\n");

	}

	else printf ("No\n");

}

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

using namespace std;

int main(){

int A,B,C;









cin>>A>>B>>C;





if( A>=-100 && A<=100 && B>=-100 && B<=100 && C>=-100 && C<=100){



if(A<=C && B>=C ){

cout<<"Yes";

}

else cout<<"No";

}

}


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



int main()

{

	int a,b,c;

	scanf ("%d %d %d",&a,&b,&c);

	if (c>=a && c<=b )

	{

		printf ("Yes\n");

	}

	else printf ("No\n");

}

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



using namespace std;



int main()

{

    int A;

    int B;

    int C;

    cin>>A;

    cin>>B;

    cin>>C;

    if(A<=C&&C<=B){

        cout<<"Yes";

    }

    else{

        cout<<"No";

    }

}




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



int main()

{

	int a,b,c;

	scanf ("%d %d %d",&a,&b,&c);

	if (c>=a && c<=b )

	{

		printf ("Yes\n");

	}

	else printf ("No\n");

}

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

using namespace std;

int main()

{

        int a,b,c;

        scanf("%d%d%d",&a,&b,&c);

        if(c<=b && c>=a)

                printf("Yes\n");

        else

                printf("No\n");

}


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

#include <stdlib.h>

int main()

{

	int a,b,c;

    scanf("%d",&a);

    scanf("%d",&b);

    scanf("%d",&c);

if (a <=c)

	{

		if (c <=b)

		{

			printf("Yes\n");

		}

		else

		{

			printf("No\n");

		}

	}

	else

	{

		printf("No\n");

	}

	system("pause");

}

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

using namespace std;



int main() {

	

	int A,B,C;

	

	cin >> A;

	cin >> B;

	cin >> C;

	

	if((C >= A)&&(C<=B)){

	printf("Yes");

	}

	else{

	printf("No");

	}

	

	return 0;

}


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

#include <stdlib.h>

int main()

{

	int a,b,c;

    scanf("%d",&a);

    scanf("%d",&b);

    scanf("%d",&c);

if (a <=c)

	{

		if (c <=b)

		{

			printf("Yes\n");

		}

		else

		{

			printf("No\n");

		}

	}

	else

	{

		printf("No\n");

	}

	system("pause");

}

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

#include<cstring>

#include<algorithm>

#include<queue>

#include<map>

#include<iostream>

using namespace std;

typedef long long ll;

const int INF = 0x3f3f3f3f;

int main()

{



    int a, b, c; 

    scanf("%d%d%d",&a,&b,&c);

    if(c >= a && c <= b)

        printf("Yes\n");

    else

    {

        printf("No\n");

    }

    return 0;

}




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

#include <stdlib.h>

int main()

{

	int a,b,c;

    scanf("%d",&a);

    scanf("%d",&b);

    scanf("%d",&c);

if (a <=c)

	{

		if (c <=b)

		{

			printf("Yes\n");

		}

		else

		{

			printf("No\n");

		}

	}

	else

	{

		printf("No\n");

	}

	system("pause");

}

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

using namespace std;

int main()

{

    int A,B,C;

    cin>>A>>B>>C;

    if(C>=A&&B>=C){

        cout<<"Yes";

    }

    else{

        cout<<"No";

    }

}

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

#include<string.h>

using namespace std;

int main()

{

    int A, B, C;

    scanf("%d %d %d", &A, &B, &C);

    if(A >= -100 && B >= -100 && C >= -100 && A <= 100 && B <= 100 && C <= 100){

    if(C >= A && C <= B){

      printf("Yes\n");

    }

    else{



    printf("No\n");

    }

    }



    return 0;

}


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



using namespace std;



int a, b, c;



int main(){

	cin >> a >> b >> c;

	if(c >= a && c <= b){

		cout << "Yes" << endl;

		return 0;

	}

	cout << "No" << endl;

	return 0;

}

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

#include<string.h>

using namespace std;

int main()

{

    int A, B, C;

    scanf("%d %d %d", &A, &B, &C);

    if(A >= -100 && B >= -100 && C >= -100 && A <= 100 && B <= 100 && C <= 100){

    if(C >= A && C <= B){

      printf("Yes\n");

    }

    else{



    printf("No\n");

    }

    }



    return 0;

}


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

#include <bits/stdc++.h>

#define pb push_back

#define ob pop_back

#define xx first

#define yy second

#define dob double

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

#define int long long int

#define ss size()

using namespace std;

const int M=1e9+7,maxn=100010;

std::vector<int> adj[maxn];

std::vector<int> v1;

int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn];

bool mark[maxn],bpart[maxn];

string s,s1,s2;

map <string ,int> mp;

bool markchaild[maxn];

bool dfsmach(int v){

    if(v==-1) return true;

    if(mark[v]==1) return false;

    mark[v]=1;

    for(int i=0;i<adj[v].ss;i++){

        int u=adj[v][i];

        if(dfsmach(mach[u])){

            bpart[u]=((bpart[v]+1)%2);

            mach[u]=v;

            mach[v]=u;

            return true;

        }

    }

    return false;

}





int32_t main() {

    cin>>n>>m>>k;

    if(k>=n&&k<=m)

        cout<<"Yes";

    else

        cout<<"No";

    return 0;

}


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

using namespace std;

main()

{

    int a,b,c;

    cin>>a>>b>>c;

    if((a<=c)&&(c<=b))

       cout<<"Yes";

    else

        cout<<"No";

}


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

using namespace std;



int main()

{

    int a,b,c;

    cin>>a>>b>>c;

    if(c>=a && c<=b){

        cout<<"Yes";

    }

    else{

        cout<<"No";

    }

    return 0;

}


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

int main(){

	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

		if(c>=a && c<=b){

			printf("Yes\n");

		}

		else{

			printf("No\n");

		}

	return 0;

}

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

using namespace std;

#define MN 200005

char c[MN];

int n,num[26];

long long ans;

int main(){

	scanf("%s",c+1);

	n=strlen(c+1);

	for(int i=n;i>=1;i--) ans+=(n-i)-num[c[i]-'a']++;

	ans++;

	printf("%lld",ans);

	return 0;

}

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

char c[200005];

int n;

long long ans,t[26];

int main()

{

	scanf("%s",c);

	for(int i=0;c[i]!='\0';++i)++n,t[c[i]-'a']++;

	for(int i=0;i<26;++i)ans+=t[i]*(n-t[i]);

	printf("%lld\n",ans/2+1);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
//============================================================================

// Name        : training.cpp

// Author      : CoNKeR The Red Squirrel

//============================================================================

#include <bits/stdc++.h>



#define MAX_N 200005

#define INF 1000000000

#define bit(mask, i) (mask & (1<<i))



using namespace std;



typedef pair<int, int> ii;

typedef pair<ii, int> iii;

typedef vector<ii> vii;

typedef vector<int> vi;

typedef vector<vi> vvi;

typedef vector<vii> vvii;

typedef long long ll;

typedef double lf;



ll dp[MAX_N], frec[30], n;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    //freopen("acmproject.in", "r", stdin);

    //freopen("acmproject.out", "w", stdout);



    string s;

    cin>>s;

    n = (ll)s.size();

    dp[0] = 1;

    frec[s[0] - 'a']++;

    for(ll i = 1; i < n; ++i) { dp[i] = dp[i - 1] + i - frec[s[i] - 'a']++; }

    cout<<dp[n - 1]<<"\n";



    return 0;

}

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

#include<algorithm>

#include<cstring>

using namespace std;

#define MAXN 200010

#define LL long long

char s[MAXN];

int cnt[30];

LL ans;

int main()

{

	scanf("%s",s);

	int n=strlen(s);

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

		cnt[s[i]-'a']++;

	ans=1LL*n*(n-1)/2;

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

		if(cnt[i]>1)

			ans-=1LL*cnt[i]*(cnt[i]-1)/2;

	ans++;

	printf("%lld\n",ans);

}

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

using namespace std;



using VS = vector<string>;    using LL = long long;

using VI = vector<int>;       using VVI = vector<VI>;

using PII = pair<int, int>;   using PLL = pair<LL, LL>;

using VL = vector<LL>;        using VVL = vector<VL>;



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

#define RALL(a) (a).rbegin(), (a).rend()

#define PB push_back

#define EB emplace_back

#define MP make_pair

#define SZ(a) int((a).size())

#define SORT(c) sort(ALL((c)))

#define RSORT(c) sort(RALL((c)))

#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)

#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)

#define debug(x) cerr << #x << ": " << x << endl

const int INF = 1e9;                          const LL LINF = 1e16;

const LL MOD = 1000000007;                    const double PI = acos(-1.0);

int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };



/* -----  2018/03/03  Problem: 019_agc_b / Link: https://agc019.contest.atcoder.jp/tasks/agc019_b ----- */

/* ------問題------



英小文字からなる文字列 A=A1A2…An があります。

あなたは 1≤i≤j≤n であるような任意の二つの添字 i,j を選び、A のうち部分文字列 AiAi+1…Aj を反転することができます。

この操作は一回まで行うことができます。

これによって得られる文字列は何通りあるでしょうか？



-----問題ここまで----- */

/* -----解説等-----



アルファベットについての累積和を取ると、部分問題として見れるので、重複数え上げがないようにすればよい。

[str] +'a'のとき、aを含む反転をして一致するのは反転の区間の左端がaとなる場合である。

ex: strstrstr|abca| -> strstrstr|abca|

なぜなら、[str]内の計算で cを右端とした場合にbc->cbを事前に計算終えているからである。

したがって文字列の先頭から走査し、現在見ている文字を両端としない場合は反転をしてuniqueになることが保証あされるので、

これを答えとしてよい。

この方法では反転するものしか数えないので、全く反転しない場合の数1を加える。





----解説ここまで---- */



LL N;



LL ans = 0LL;



int main() {

	cin.tie(0);

	ios_base::sync_with_stdio(false);



	string s;

	cin >> s;



	VVI cnt(SZ(s) + 1, VI(26, 0));

	FOR(i, 0, SZ(s)) {

		FOR(j, 0, 26) {

			cnt[i + 1][j] += cnt[i][j] + (s[i] - 'a' == j);

		}

	}

	ans = 1;

	FOR(i, 0, SZ(s)) {

		ans += i - cnt[i][s[i] - 'a'];

	}

	cout << ans << "\n";



	return 0;

}


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

#include<cstring>

#include<algorithm>

#include<cmath>

#define SF scanf

#define PF printf

#define MAXN 200010

using namespace std;

typedef long long ll;

char s[MAXN];

ll ans,cnt[30];

int main(){

	SF("%s",s);

	int len=strlen(s);

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

		ans+=(i-cnt[s[i]-'a']);

		cnt[s[i]-'a']++;

	}

	PF("%lld",ans+1ll);

}

// Fastest known solution for this problem: