akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;

struct UnionFind {
    vector<int> parent;  // parent[root] is the negative of the size.
    UnionFind(int n) : parent(n, -1){};
    bool unite(int u, int v) {
        u = root(u);
        v = root(v);
        if (u == v) return false;
        if (parent[u] > parent[v]) swap(u, v);
        parent[u] += parent[v];
        parent[v] = u;
        return true;
    }
    bool find(int u, int v) { return root(u) == root(v); }
    int root(int u) { return parent[u] < 0 ? u : parent[u] = root(parent[u]); }
    int size(int u) { return -parent[root(u)]; }
};

int main() {
    int n, m, r=0;
    cin >> n >> m;
    struct UnionFind uf(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        uf.unite(a-1, b-1);
    }
    for (int i = 0; i < n; ++i) r = max(r, uf.size(i));
    cout << r;
}

Measured memory_bytes: 4052
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

long long int modpow(long long int p, long long int q, long long int mod)
{
  long long int i;
  long long int r=1;
  while(q>0)
  {
    if(q%2>0) r=r*p%mod;
    p=p*p%mod;
    q/=2;
  }
  return r;
}

int main(void)
{
  long long int sum[100001]={};
  long long int mod = 1000000007;
  long long int ans = 0;
  long long int n,k,i,j;

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

  for(i=k;i>0;i--)
  {
    sum[i]=modpow(k/i,n,mod);
    for(j=2;i*j<=k;j++) sum[i]=(sum[i]-sum[i*j]+mod)%mod;
    ans=(ans+i*sum[i])%mod;
  }

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

  return 0;
}

Measured memory_bytes: 2516
#include <cstdio>

int main(){
	int a[3][6];
	int b[3][3];
	
	for(int i=0; i<3; i++){
		scanf("%d %d %d %d %d %d", &a[i][1], &a[i][2], &a[i][3], &a[i][4], &a[i][5], &a[i][6]);
	}
	for(int i=0; i<3; i++){
		if(a[i][6] < a[i][3]){
			a[i][5]--;
			a[i][6] += 60;
			if(a[i][5] < a[i][2]){
				a[i][4]--;
				a[i][5] += 60;
			}
		}		
	}
	for(int i=0; i<3; i++){
		b[i][1] = a[i][4] - a[i][1];
		b[i][2] = a[i][5] - a[i][2];
		b[i][3] = a[i][6] - a[i][3];
	}
	for(int i=0; i<3; i++){
		printf("%d %d %d\n", b[i][1], b[i][2], b[i][3]);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    // dp[i][j] = sのi文字目, tのj文字目までのLCSの長さ
    vector<vector<int>> dp(sz(s)+1, vector<int>(sz(t)+1));
    rep(i, 1, sz(s)+1) rep(j, 1, sz(t)+1) {
        if(s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
        else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
    int i = sz(s), j = sz(t);
    int len = dp[i][j];
    string ans = "";
    while(len > 0) {
        if(s[i-1] == t[j-1]) {
            ans = s[i-1] + ans;
            i--; j--; len--;
        } else if(dp[i][j] == dp[i-1][j]) {
            i--;
        } else {
            j--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 38848
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();

        long max = Math.max(a, b);
        List<Long> list = new ArrayList<>();
        for (long i = max; i >= 2; i--) {
            if (a % i == 0 && b % i == 0) {
                boolean skip = false;
                for (long j : list) {
                    if (j % i == 0) {
                        skip = true;
                    }
                }
                if (!skip) {
                    list.add(i);
                }
            }
        }

        long ans = a * b;
        for (long i : list) {
            ans /= i;
        }
        System.out.println(ans);

        sc.close();
    }

}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi=3.14159265358979323846;
 
int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll num=a-b;
    if (k%2==1){
        cout<<(-1)*num<<endl;
    }
    else{
        cout<<num<<endl;
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    vector<vector<int>> graph(N);
    for(int i = 0; i < N - 1; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }

    vector<int> dist(N);
    auto dfs = [&](auto&& self, int from, int d = 0, int par = -1) -> void {
        dist[from] = d;
        for(int to : graph[from]){
            if(to != par)   self(self, to, d + 1, from);
        }
    };
    dfs(dfs, 0);
    int u = max_element(dist.begin(), dist.end()) - dist.begin();
    dfs(dfs, u);
    
    int D = *max_element(dist.begin(), dist.end());
    if(D % 3 == 1)  cout << "Second\n";
    else    cout << "First\n";
}

Measured memory_bytes: 27228
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A[3], res;
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<3;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY, Q5VJL1cS;
    if(3==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = A[0];
      for(KL2GvlyY=1;KL2GvlyY<3;KL2GvlyY++){
        Q5VJL1cS = max_L(Q5VJL1cS, A[KL2GvlyY]);
      }
    }
    {
      int cTE1_r3A, e98WHCEY;
      if(3==0){
        cTE1_r3A = 0;
      }
      else{
        cTE1_r3A = A[0];
        for(e98WHCEY=1;e98WHCEY<3;e98WHCEY++){
          cTE1_r3A += A[e98WHCEY];
        }
      }
      res =cTE1_r3A-Q5VJL1cS;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int A[3], res;
//   rd(A(3));
//   res = sum(A(3)) - max(A(3));
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std; 

long long n,m;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
    return 0;
}


Measured memory_bytes: 256
#if 0
????????£????????????15m
set??§???????????????1.61s?????£??????????????????????????§?????????
?????????unordered_set??§???1.14s?????£??????
1s?????????????????§???????????¨?????????????????£?????????
set???????????¨??¢?´¢??????????????±???????????????????????????????????????????????¨??????????????????
#endif

#include <iostream>
#include <unordered_set>
#include <string>
using namespace std;

int main(){
	unordered_set<string> S;
	string cmd;
	string word;
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>cmd;
		if(cmd=="insert"){
			cin>>word;
			S.insert(word);
		}else if(cmd=="find"){
			cin>>word;
			if(S.count(word)==0)
				cout<<"no"<<endl;
			else
				cout<<"yes"<<endl;
		}
	}
}

Measured memory_bytes: 32140
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
typedef pair<int,int> P;
const int INF=1000000000;
const int MOD_2=998244353;

int main()
{
	int A,B;
	int ans=-1;
	cin>>A>>B;
	for(int i=0;i<=1100;i++)
	{
		if(i*8/100 == A && i*10/100 == B){ans=i;break;}
	}
	cout<<ans<<"\n";
	return 0;
}
	

Measured memory_bytes: 256
// A - XOR Circle

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int N;
	cin >> N;

	map<int, int> A;

	for (int i=0; i<N; i++) {
		int a;
		cin >> a;
		A[a]++;
	}

	vector<int> a;
	vector<int> cnt;
	for (auto itr : A) {
		a.push_back(itr.first);
		cnt.push_back(itr.second);
	}

	string ans = "Yes";
	if (a.size() == 1) {
		if (a[0] != 0) ans = "No";
	} else if (a.size() == 2) {
		if (a[0] != 0) ans = "No";
		if (cnt[0] * 2 != cnt[1]) ans = "No";
	} else if (a.size() == 3) {
		if (cnt[0] != cnt[1] || cnt[1] != cnt[2] || cnt[2] != cnt[0]) ans = "No";
		if ((a[0] ^ a[1] ^ a[2]) != 0) ans = "No";
	} else {
		ans = "No";
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7776
#include<stdio.h>

int main(){
  int A[251], H, i;

  scanf("%d", &H);
  if(H <= 250){
    for(i = 1; i < H+1; i++){
      scanf("%d", &A[i]);
    }

    i = 1;
    while(i-1 != H){
      printf("node %d: key = %d, ", i, A[i]);
      if(i / 2 > 0)
	printf("parent key = %d, ", A[i/2]);
      if(i * 2 < H+1)
	printf("left key = %d, ", A[i*2]);
      if(i * 2 + 1< H+1)
	printf("right key = %d, ", A[i*2+1]);
      printf("\n");
      i++;
    }
  }
  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define all(obj) (obj).begin(),(obj).end()

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll c[3][3],x[3],y[3];
    x[0]=0;
    rep(i,3)rep(j,3)cin>>c[i][j];
    rep(i,3)y[i]=c[0][i]-x[0];
    rep(i,3)x[i]=c[i][0]-y[0];
    rep(i,3)rep(j,3)if(x[i]+y[j]!=c[i][j]){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
//2017
#include<iostream>
using namespace std;
int main(void){
	int i,n,a[100],cnt=0,max=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		if(a[i]==1){
			cnt++;
			if(max<cnt){
				max=cnt;
			}
		}
		else if(a[i]==0){///???
			cnt=0;
		}
	}
	cout<<max+1<<endl;///????
	
	return 0;
}


Measured memory_bytes: 3092
//In the name of ALLAH
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define mod 1000000007


int p[200001];
int A[200001];


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	p[0]=p[1]=0;
	for(int i=2;i<=2e5;i++)
		p[i]=1;
	for(int i=2;i*i<=2e5;i++)
		if(p[i])
			for(int j=2*i;j<=2e5;j+=i)
				p[j]=0;
	A[200000]=200000;
	for(int i=199999;i>=1;i--) {
		A[i]=A[i+1];
		if(p[i])
			A[i]=i;
	}
	int x;
	cin>>x;
	cout<<A[x]<<"\n";
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int g1[7] = {1, 3, 5, 7, 8, 10, 12};
	int g2[4] = {4, 6, 9, 11};
	int x, y;
	cin >> x >> y;
	int * x1 = find(g1, g1 + 7, x);
	int * x2 = find(g2, g2 + 4, x);
	int * y1 = find(g1, g1 + 7, y);
	int * y2 = find(g2, g2 + 4, y);
	if(((x1 != g1 + 7) && (y1 != g1 + 7)) || ((x2 != g2 + 4) && (y2 != g2 + 4))) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int color[8] = {0};
    int cnt = 0;
    int super = 0;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        if (a < 3200) {
            color[a / 400]++;
            if (color[a / 400] == 1) cnt++;
        } else super++;
    }
    if (cnt == 0) {
        cout << 1 << " " << super << endl;
    } else {
        cout << cnt << " " << cnt + super << endl;
    }
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

p_list = [a, b, c, d, e]
neg_pair = False

for i in range(5):
  for j in range(5):
    dist = abs(p_list[i] - p_list[j])
    if dist > k:
      neg_pair = True
      break
if neg_pair:
  print(":(")
else:
  print("Yay!")

Measured memory_bytes: 3064
n = int(input())

def get_divisors(n):
    return [i for i in range(1, n//2+1) if n%i == 0] + [n]

ans = 0
for i in range(1, n+1, 2):
    if len(get_divisors(i)) == 8:
        ans += 1
print(ans)

Measured memory_bytes: 2940
#include <stdio.h>
int main(void){
 int a[101],n,b[10],c,i;
 
 for(i=0;i<101;i++){
     a[i]=0;
 }
 for(i=1;i<=9;i++){
    scanf("%d",&n);
    a[n]=i;
 }
 scanf("%d",&n);
 for(i=0;i<n;i++){
     scanf("%d",&c);
     b[a[c]]=1;
 }
 
 if(b[1]*b[2]*b[3]==1||b[4]*b[5]*b[6]==1||b[7]*b[8]*b[9]==1||
    b[1]*b[4]*b[7]==1||b[2]*b[5]*b[8]==1||b[3]*b[6]*b[9]==1||
    b[1]*b[5]*b[9]==1||b[3]*b[5]*b[7]==1){printf("Yes\n");}
    else{printf("No\n");}
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_D
{
    class D047
    {
        public static void Main(string[] args)
        {
            int[] h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = h[0], T = h[1];
            int[] A= Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();


            Dictionary<int, MaxDif> dic = new Dictionary<int, MaxDif>();
            List<int> minIndexList = new List<int>();
            int min = int.MaxValue;
            int maxdif = 0;
            for(int i = 0; i < N; i++)
            {
                if (A[i] < min)
                {
                    min = A[i];
                    minIndexList.Clear();minIndexList.Add(i);
                }
                else if (A[i] == min)
                {
                    minIndexList.Add(i);
                }                

                int dif = A[i] - min;
                if (dif >= maxdif && dif>0)
                {
                    //ペアが変わらないタイ記録
                    if (dif == maxdif && dic.ContainsKey(min))
                    {
                        dic[min].IndexMax.Add(i);
                    }
                    else
                    {
                        //新記録
                        if(dif>maxdif) dic.Clear();

                        maxdif = dif;
                        MaxDif md = new MaxDif();
                        md.Min = min; md.Max = A[i]; md.Dif = dif;
                        md.IndexMin = minIndexList;
                        md.IndexMax = new List<int>(); md.IndexMax.Add(i);
                        dic.Add(min, md);
                    }
                }
            }
            long sum = 0;
            foreach(var v in dic.Values)
            {
                sum += v.GetLeastOperation();
            }
            Console.WriteLine(sum);
        }

    }

    class MaxDif
    {
        public int Dif;
        public int Min, Max;
        public List<int> IndexMin = new List<int>();
        public List<int> IndexMax = new List<int>();

        public int GetLeastOperation()
        {
            return Math.Min(IndexMin.Count , IndexMax.Count);
        }
    }

}


Measured memory_bytes: 32732
n = gets.chomp.to_i

cnt = 0
3.upto(9) do |l|
  cnt += [7,5,3]
    .repeated_permutation(l)
    .map { |a| a.join }
    .select { |s| s.include?("7") && s.include?("5") && s.include?("3") && s.to_i <= n }
    .length
end

puts cnt

Measured memory_bytes: 8828
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		if(n>=3200) {
			System.out.println(s);
		}else {
			System.out.println("red");
		}
	}

}


Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;

bool comp(int a, int b){
    return a>b;
}

int main(){

    int n,k;
    cin>>n>>k;
    int arr[n+1];
    for(int i =1;i<=n;i++){
        cin>>arr[i];
        arr[i]+=arr[i-1];
    }
    int ans = 0;
    for(int i =k;i<=n;i++){
        ans = max(ans , arr[i]-arr[i-k]);
    }
    cout<<fixed<<setprecision(10)<<double(ans)/2 + k/2.0<<endl;
    
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(string, S);

  if(S == "Sunny") {
    fin("Cloudy");
  } else if(S == "Cloudy") {
    fin("Rainy");
  } else {
    fin("Sunny");
  }
}

Measured memory_bytes: 256
a,b = map(int,input().split())
import math

for i in range(1,1101):
    a1 = int( math.floor( i * 0.08 ) )
    if a1 == a:
        b1 = int( math.floor( i * 0.10 ) )
        if b1 == b:
            print(i)
            exit()
print(-1)

Measured memory_bytes: 3060
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define		vii 			vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
#define     test(i)        cout<<i<<endl
int dx[] = {-1 , 1 , 0 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 0 , 1 ,-1 ,-1 , 1 ,-1 , 1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
const int mxN=3e3+5,oo=0x3f3f3f3f,mod=1e9+7;
string s,t;
int dp[mxN][mxN];
int go(int i,int j){
    if(j>sz(t)||i>sz(s))
        return 0;
    int &ret=dp[i][j];
    if(~ret)
        return ret;
    if(s[i]==t[j])
        return 1+go(i+1,j+1);
    return ret=max(go(i,j+1),go(i+1,j));
}
void build(int i,int j){
    if(i==sz(s)||j==sz(t))
        return;
    int res=go(i,j);
    if(s[i]==t[j])
        cout<<s[i],build(i+1,j+1);
    else
        if(res==go(i,j+1))
            build(i,j+1);
        else
            build(i+1,j);
}
void solve(){
    cin>>s>>t;
    if(sz(t)>sz(s))
        swap(s,t);
    mem(dp,-1);
    build(0,0);
}
int main() {
    fast();
    solve();
}


Measured memory_bytes: 36096
#include <bits/stdc++.h>
using namespace std;

int main(){
int N,M;
cin>>N>>M;
int ans=0;
int sum=0;
vector<int> vec(N+10);
for(int i=0;i<N;++i){
    cin>>vec.at(i);}
    
for(int i=0;i<N;++i){
   sum=sum+vec.at(i);
   }
for(int i=0;i<N;++i){
    
if(4*M*vec.at(i)>=sum)++ans;
}
if(ans>=M)cout<<"Yes"<<endl;
else {cout<<"No"<<endl;}

}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
# include <climits>
#define ll long long
#define rep(i,rept) for (ll i = 0; i < rept; i++)
#define yes(b) std::cout<< (b ? "Yes" : "No")
#define YES(b) std::cout<< (b ? "YES" : "NO")
const ll INF = 1LL << 50;
using namespace std;
/*int ketawa(ll num) {
int dig, sum = 0;
while (num) {
dig = num % 10;
sum = sum + dig;
num = num / 10;
}
return sum;
}

bool keta(ll num, vector<int> v) {
int dig;
while (num) {
dig = num % 10;
for (auto& i : v) {
if (dig == i) {
return false;
}
}
num = num / 10;
}
return true;
}

ll func(ll a, ll b, ll c, ll d, int n) {
return ((c / (d - b) + n)*(d - b)) + (a % (d - b));
}
*/
int main(void) {
	int n, m, a[2000], b[2000];
	ll ans, c[2000], dist[1000];
	bool negative[1000];
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i] >> c[i];
		c[i] = -c[i];

	}

	dist[0] = 0;

	for (int i = 1; i < n; ++i) {
		dist[i] = INF;
	}

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

			if (dist[a[j] - 1] == INF) {
				continue;
			}
			if (dist[b[j] - 1] >(dist[a[j] - 1] + c[j])) {
				dist[b[j] - 1] = (dist[a[j] - 1] + c[j]);
			}

		}
	}

	ans = dist[n - 1];

	for (int i = 0; i < n; ++i) {
		negative[i] = false;

	}

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

			if (dist[a[j] - 1] == INF) {
				continue;
			}
			if (dist[b[j] - 1] > dist[a[j] - 1] + c[j]) {
				dist[b[j] - 1] = (dist[a[j] - 1] + c[j]);
				negative[b[j] - 1] = true;
			}

			if (negative[a[j] - 1] == true) {
				negative[b[j] - 1] = true;
			}

		}
	}


	if (negative[n - 1]) {
		cout << "inf" << endl;
	}
	else {
		cout << -ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll MOD=INF;
ll mod=INF;


int main() {
  int n;
  cin >> n;
  cout << (110000-n)%1000 << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

int main(void){
    ll n,m;
    cin>>n>>m;
    vl a(m);
    rep(i,m) cin>>a[i];
    ll sum = 0;
    rep(i,m) sum+=a[i];
    if(sum>n) cout<<-1<<endl;
    else cout<<n-sum<<endl;
}


Measured memory_bytes: 3700
import java.util.*;
public class Main{
  
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N=scanner.nextInt();
    int remDiv=((N%500)/5);

    int gc=((N/500)*1000)+(remDiv*5);
    System.out.println(gc);
  }

}

Measured memory_bytes: 21972
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		out.println(inint()/3);

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 21972
#include<iostream>
using namespace std;

int main() {
	int a, s, m, h;
	cin >> a; //時間入力
	h = a / 3600; // 時間
	m = (a % 3600) / 60; //分
	s = (a % 3600) % 60;
	cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

const Int N = 1e6;
Int used[N],mem[N];
Int dfs(Int n){
  if(n < 0LL) return INF;
  if(n == 0) return 0;
  if(used[n]++) return mem[n];
  Int a = 1 + dfs(n - 1);
  Int b = INF, c = INF;
  for(Int i=6;i <= n;i*=6) Min(b, 1 + dfs(n - i));
  for(Int i=9;i <= n;i*=9) Min(c, 1 + dfs(n - i));
  return mem[n] = min({a, b, c});
}

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  
  Int n;
  cin>>n;
  
  Int ans = dfs(n);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9856
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd

int n,x;

set <int> s;

int main(){
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> x;
        s.insert(x);
    }
    cout << s.sz;
}


Measured memory_bytes: 256
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int h,w,n;

vector<string> process(vector<string> &v){
    vector<string> tmp;
    rep(i,h+1)tmp.pb(v[i]);
    LOOP:
    bool f1=false;
    bool f2;
    do{
        f2=false;
        rep(j,w){
            rev(i,h-1){
                if(tmp[i+1][j]=='.'&&tmp[i][j]!='.'){
                    f1=true;
                    f2=true;
                    swap(tmp[i][j],tmp[i+1][j]);
                }
            }
        }
    }while(f2);
    vector<pair<pi,pi>> p;
    rep(i,h){
        rep(j,w){
            if(tmp[i][j]=='.')continue;
            int t=1;
            int k=j;
            while(tmp[i][k]==tmp[i][k+1]){
                t++;
                k++;
            }
            if(t>=n){
                p.pb({{i,j},{0,t}});
                f1=true;
            }
        }
    }
    rep(j,w){
        rep(i,h){
            if(tmp[i][j]=='.')continue;
            int t=1;
            int k=i;
            while(tmp[k][j]==tmp[k+1][j]){
                t++;
                k++;
            }
            if(t>=n){
                p.pb({{i,j},{1,t}});
                f1=true;
            }
        }
    }
    rep(i,p.size()){
        int x=p[i].fi.se,y=p[i].fi.fi;
        int d=p[i].se.fi;
        int c=p[i].se.se;
        if(d==0){
            rep(j,c){
                tmp[y][x+j]='.';
            }
        }
        else{
            rep(j,c){
                tmp[y+j][x]='.';
            }
        }
    }
    if(f1)goto LOOP;
    return tmp;
}

bool judge(vector<string> &v){
    rep(i,h)rep(j,w)if(v[i][j]!='.')return false;
    return true;
}

bool solve(vector<string> &v){
    bool ret=false;
    vector<string> t(h+1);
    rep(i,h+1)t[i]=v[i];
    rep(i,h){
        rep(j,w-1){
            swap(t[i][j],t[i][j+1]);
            vector<string> tt=process(t);
            ret|=judge(tt);
            // cout<<i<<" "<<j<<endl;
            // rep(i,h)cout<<tt[i]<<endl;
            swap(t[i][j],t[i][j+1]);
            // cout<<endl;
        }
    }
    return ret;
}

void run(){
    cin>>h>>w>>n;
    vector<string> v(h+1);
    rep(i,h){
        cin>>v[i];
        v[i]+=' ';
    }
    rep(i,w+1)v[h]+=' ';
    YES(solve(v));
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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 (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


int main()
{
cin.tie(0);
ios::sync_with_stdio(false);

int a,b; cin >> a >> b; a--; b--; cout << a*b << endl;

return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    long long a, b, c; cin >> a >> b >> c;
    long long x = (c - a - b);
    x = x < 0 ? -x * x : x * x;
    cout << (4 * a * b < x ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<"\n" //to debug values of variables
#define ZINDA cerr<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define mkp make_pair
#define pb push_back
#define endl '\n'
#define mod 1000000007
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
lld power(lld b, lld e)
{
    if(e==0)
        return 1;
    if(e%2==1)
        return b*power(b*b,(e-1)/2);
    else
        return power(b*b,e/2);
}
 
lld power(lld b, lld e, lld m)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(((b%m)*(b%m))%m,(e-1)/2,m)%m;
	else
		return power(((b%m)*(b%m))%m,e/2,m)%m;
}
 
int nDig(lld n)
{
	if(n<0) 
		n*=-1;
	if(n==0)
		return 1;

    return floor(log10(n) + 1);
}

//endl : changed to '\n', to flush comment that definition
//--------------------------------------------------------------------------------

void swagWaalaFunction()
{
	lld n,k,ans=0;
	cin>>n>>k;

	n%=k;
	if(n<k and n>abs(n-k))
		n=abs(n-k);

	cout<<n;
	return;
}

int main()
{
    SPEEDUP;
 	lld t=1;
 	//cin>>t;

 	while(t--)
 		swagWaalaFunction();

 	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 K, X;
    read(K, X);

    print((500 * K >= X) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		int A10 = 10 * A + B + C;
		int B10 = 10 * B + A + C;
		int C10 = 10 * C + A + B;
		
		int AB10 = Math.max(A10, B10);
		int max = Math.max(AB10, C10);
		
		System.out.println(max);
		
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

bool cmp(pint a, pint b) {return a.second < b.second;}
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 (a > b) { a = b; return 1; } return 0; }

vb num(1000000100);

int main() {
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    bool ok = true;
    rep(i, n) {
        if(!num[a[i]]) num[a[i]] = true;
        else ok = false;
    }

    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 123904
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
string str[maxn];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> str[i];
		sort (str[i].begin(), str[i].end());
	}
	long long ans = 0;
	map<string, int> mp;
	for (int i = 1; i <= n; i++) {
		ans += mp[str[i]];
		mp[str[i]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 18176
// problem: "https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b"

#include<bits/stdc++.h>
#define ll long long
#define Pair pair<ll,ll>

using namespace std;

bool func(Pair &p1,Pair &p2)
{
    return p1.first < p2.first;
}

ll MaxRobots(vector<Pair>&V,int n)
{
    stack<Pair>S;
    ll i;
    for(i=0;i!=n;i++)
    {
        if(S.empty())
            S.push(V[i]);

        else if(S.top().second <= V[i].first)
            S.push(V[i]);

        else if(S.top().second > V[i].second)
        {
            S.pop();
            S.push(V[i]);
        }
    }

    return S.size();
}

int main()
{
    ll n;
    cin>>n;

    ll i,x,l;
    vector<Pair>V;
    for(i=0;i!=n;i++)
    {
        cin>>x>>l;
        V.push_back(Pair(x-l,x+l));
    }

    sort(V.begin(),V.end(),func);       // define

    // for(i=0;i!=n;i++)
    //     cout<<V[i].first<<' '<<V[i].second<<'\n';

    cout<<MaxRobots(V,n);       // define

    return 0;
}


Measured memory_bytes: 3440
#include <iostream>
#include<cmath>

using namespace std;

bool hantei(int num){
    if(num/10000==num%10){
        if((num%10000)/1000==(num%100)/10){
            return true;
        }
    }
    return false;
}

int main() {
  int A,B;
  cin>>A>>B;
  int ans=0;
  for(int i=A;i<=B;i++){
      if(hantei(i)){
          ans++;
      }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace _2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int output = 0;
            for (int i = 0; i < N; i++)
            {
                int minj = i;
                for (int j = i; j < N; j++)
                {
                    if (A[j] < A[minj])
                    {
                        minj = j;
                    }
                }
                if (A[i] != A[minj])
                {
                    int x = A[i];
                    A[i] = A[minj];
                    A[minj] = x;
                    output++;
                }
            }
            Console.Write(A[0]);
            for (int i = 1; i < N; i++)
            {
                Console.Write(" " + A[i]);
            }
            Console.WriteLine();
            Console.WriteLine(output);
        }
    }
}

Measured memory_bytes: 9540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
int n,h,w;
cin >> n >> h >> w;
int ans = (n-h+1)*(n-w+1);
cout << ans << endl;
}


Measured memory_bytes: 3580
s = input()
q = int(input())

# 毎回反転させていたら時間切れになる
is_reverse = False
forward = dict()  # あとで別のデータ構造に変更する
backward = dict()  # あとで別のデータ構造に変更する
# forward = list()
# backward = list()
forward_num = 0
backward_num = 0

for _ in range(q):
    query = input().split()
    if len(query) == 1:
        if is_reverse:
            is_reverse = False
        else:
            is_reverse = True
    else:
        _, f, c = query
        if f == '1':
            if is_reverse:
                backward[backward_num] = c
                backward_num += 1
                # s = s + c
                # backward.append(c)
            else:
                forward[forward_num] = c
                forward_num += 1
                # s = c + s
                # forward.insert(0, c)
        else:
            if is_reverse:
                forward[forward_num] = c
                forward_num += 1
                # forward.insert(0, c)
                # s = c + s
            else:
                backward[backward_num] = c
                backward_num += 1
                # backward.append(c)
                # s = s + c

# print(forward)
# print(backward)
forward = list(forward.values())[::-1]
backward = list(backward.values())
# print(is_reverse)
# print(forward)
# print(backward)

if is_reverse:
    s = s[::-1]
    print(''.join(backward)[::-1] + s + ''.join(forward)[::-1])
else:
    print(''.join(forward) + s + ''.join(backward))


Measured memory_bytes: 85336
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

vector<ll> v1, v2;
ll k;

bool check(ll mid)
{
	ll cnt=0;
	int n = (int)v1.size();
	rep(i,0,n)
	{
        if(v1[i]*v2[i]>=mid)
        {
            ll x = (v1[i]*v2[i]-mid)/v2[i];
            if((v1[i]*v2[i]-mid)%v2[i])
                x++;
            cnt += x;
        }
	}
	return (cnt<=k);
}

int main()
{
	fast;
	ll n;
	cin>>n>>k;
	v1.resize(n);
	v2.resize(n);
	rep(i,0,n)
		cin>>v1[i];
	rep(i,0,n)
		cin>>v2[i];
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end(), greater<ll>());
	ll beg = 0;
	ll end = (ll)1e18;
    ll mid;
	ll ans=-1;
	while(beg<=end)
	{
		mid = beg+(end-beg)/2;
		if(check(mid))
		{
			ans=mid;
			end=mid-1;
		}
		else
		{
			beg=mid+1;
		}
	}
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3328
import sys, itertools
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, M, Q = LI()
    abcd = [LI() for _ in range(Q)]

    ans = 0
    for i in itertools.combinations_with_replacement(range(1, M+1), N):
        # print(i)
        score = 0
        for j in abcd:
            a = j[0]-1
            b = j[1]-1
            c = j[2]
            d = j[3]
            if i[b]-i[a]==c:
                score += d
        ans = max(score, ans)

    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9244
#include <iostream>
#define llint long long
#define sgn(x) (((x)%2)?-1:1)
#define inf 100000000000000000

using namespace std;

llint N;
llint A[100005];
char op[100005];
llint dp[100005][10];

int main(void)
{
	cin >> N;
	N--;
	
	cin >> A[0];
	for(int i = 1; i <= N; i++) cin >> op[i] >> A[i];
	
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= 2; j++){
			dp[i][j] = -inf;
		}
	}
	
	dp[0][0] = A[0];
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= 2; j++){
			if(dp[i][j] == -inf) continue;
			if(op[i+1] == '+'){
				dp[i+1][j] = max(dp[i+1][j], dp[i][j] + sgn(j)*A[i+1]);
				if(j > 0) dp[i+1][j-1] = max(dp[i+1][j-1], dp[i][j] + sgn(j)*A[i+1]);
			}
			else{
				dp[i+1][j] = max(dp[i+1][j], dp[i][j] + sgn(j+1)*A[i+1]);
				dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + sgn(j+1)*A[i+1]);
				if(j > 0) dp[i+1][j-1] = max(dp[i+1][j-1], dp[i][j] + sgn(j+1)*A[i+1]);
			}
		}
	}
	
	/*for(int i = 0; i <= N; i++){
		for(int j = 0; j <= N; j++){
			if(dp[i][j] == -inf) cout << "-inf" << " ";
			else cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	
	cout << dp[N][0] << endl;
	return 0;
}

Measured memory_bytes: 8960