akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = 1;
    fact[1] = 1;
    for(int i=2; i<=num; i++){
        fact[i] = fact[i-1] * i % MOD;
    }
}

void create_seq_inv_mod(int num){
    seq_inv[0] = 1;
    seq_inv[1] = 1;
    for(int i=2; i<=num; i++){
        seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
    }
}

void create_fact_inv_mod(int num){
    fact_inv[0] = 1;
    fact_inv[1] = 1;
    for(int i=2; i<=num; i++){
        fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
    }
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int64_t N, M, K;
    cin >> N >> M >> K;
    int64_t A = N*M;

    int64_t ans = 0;
    for(int t=0; t<2; t++){
        int64_t res = 0;
        for(int i=1; i<N; i++) add(res, (N-i) * (N-i+1) % MOD * inv_mod(2) % MOD);
        mul(res, M*M % MOD);
        add(ans, res);
        swap(N, M);
    }
    
    create_mod_tables(A);
    mul(ans, comb_mod(A-2, K-2));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;


int main(){
    int N, M ,Q;
    cin >> N >> M >> Q;
    int L[M], R[M];
    int p, q;
    int cnt[N][N] = {};
    for(int i=0; i<M;i++){
        int l, r;
        cin >> l >> r;
        --l;
        --r;
        L[i] = l;
        R[i] = r;
        cnt[l][r]++;
    }

    //for(int l = N-1; l >= 0; l--){
    //    for(int r = 0; r < N; r++){
    //        cout << cnt[l][r] << " ";
    //    }
    //    cout << endl;
    //}

    int box[N][N] = {};
    box[0][0] = cnt[0][0];
    for(int r = 1; r < N; r++){
        box[0][r] += box[0][r-1] + cnt[0][r];
        box[r][0] += box[r-1][0] + cnt[r][0];
    }
    for(int r = 1; r < N; r++){
        for(int l = 1; l < N; l++){
           //cout << box[l][r-1] << endl;
           //cout << box[l-1][r] << endl;
           //cout << box[l-1][r-1] << endl;
           box[l][r] = cnt[l][r] + box[l][r-1] + box[l-1][r] - box[l-1][r-1];
        }
    }

    //for(int l = N-1; l >= 0; l--){
    //    for(int r = 0; r < N; r++){
    //        cout << box[l][r] << " ";
    //    }
    //    cout << endl;
    //}

    for(int i=0; i<Q;i++){
        cin >> p >> q;
        p--, q--;
        //int ans = (p > 0) ? box[q][q] - box[p-1][p-1] : box[q][q];
        int ans = (p > 0) ? box[q][q] - box[p-1][q] : box[q][q];
        cout << ans << endl;
    }
    return 0;

}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define All(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

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

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n);

  for (int i = 1; i <= 9; ++i) {
    if (n % i != 0) continue;
    int j = n / i;
    if (1 <= j && j <= 9) {
      puts("Yes");
      return;
    }
  }
  puts("No");
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

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

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<int> alp(26,0);
  rep(i,n){
    int p = (int)s.at(i)-97;
    alp.at(p)++;
  }

  mint ans=1;
  rep(i,26) ans*=(alp.at(i)+1);

  ans = ans-1;
  cout << ans;
}

Measured memory_bytes: 3752
#include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;

      v[0]=v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]){
        for(long long int j=(long long int)i*(long long int)i;j<MAX;j+=i){
         v[j]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())break;;
      cout << v[a] << endl;
    }
    return 0;
}



Measured memory_bytes: 6616
#include <bits/stdc++.h>
using namespace std;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

typedef pair<int, int> P;

const int inf = 1001001001;
int dist[100005][3];

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> to(n);
    for(int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
    }
    int sv, tv;
    cin >> sv >> tv;
    --sv; --tv;

    for(int i=0; i<n; i++) for(int j=0; j<3; j++) dist[i][j] = inf;
    queue<P> q;
    q.push(P(sv, 0));
    dist[sv][0] = 0;
    while(!q.empty()){
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for(int u : to[v]){
            int nl = (l+1)%3;
            if(dist[u][nl] != inf) continue;
            dist[u][nl] = dist[v][l] + 1;
            q.push(P(u, nl));
        }
    }

    int ans = dist[tv][0];
    if(ans == inf) ans = -1;
    else ans /= 3;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6912
S = str(input())
Q = int(input())
Qvery = [0]*Q
for i in range(Q):
    Qvery[i] = list(map(str,input().split()))
frontback = 1
tail = ''
head = ''
for i in range(Q):
    if Qvery[i][0]=='1':
        frontback *= -1
        
    else:
        if Qvery[i][1]=='2':
            if frontback == 1:
                tail +=  str(Qvery[i][2])
            else:
                head = str(Qvery[i][2]) + head
        else:
            if frontback == 1:
                head = str(Qvery[i][2])+head
            else:
                tail += str(Qvery[i][2])
S = head + S + tail
if frontback == -1:
    S = S[::-1]
    
print(S)

Measured memory_bytes: 263488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll t;
  cin>>t;ll fac=1;
  const int m=1e9+7;
  for(int i=1;i<=t;i++)
  {
    fac=(fac%m)*(i%m);
    fac=fac%m;
  }
  cout<<fac;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<cmath>
#define LL long long
LL N, A, B, C, D;
LL DP[1010][1010];
LL kai[1010];
LL fer[1010];
const LL mod = 1e9 + 7;
LL fermat(LL x, int y) {
	if (y == 0)return 1;
	if (y == 1)return x;
	LL F = fermat(x, y / 2);
	F *= F;
	F %= mod;
	if (y % 2)return (F*x) % mod;
	if (!(y % 2))return F;
}


int main() {
	std::cin >> N >> A >> B >> C >> D;
	kai[0] = 1;
	for (LL i = 1; i <= N; i++) {
		kai[i] = kai[i - 1] * i;
		kai[i] %= mod;
	}
	fer[N] = fermat(kai[N], mod - 2);
	for (LL i = N; i >= 1; i--) {
		fer[i - 1] = (fer[i] * i) % mod;
	}
	DP[A - 1][0] = 1;
	for (int i = A; i <= B; i++) {
		for (int j = 0; j <= N; j++) {
			DP[i][j] += DP[i - 1][j];
			DP[i][j] %=mod;
			LL a = 1;
			for (int m = 1; m < C; m++) {
				a *= fer[i];
				a %= mod;
			}
			for (int k = C; k <= D; k++) {
				if (i*k + j > N) {
					break;
				}
				LL KA = kai[N - j] * fer[N - j - i * k];
				KA %= mod;
				a *= fer[i];
				a %= mod;
				KA *= a;
				KA %= mod;
				KA *= fer[k];
				KA %= mod;
				DP[i][i*k + j] += DP[i - 1][j] * KA;
				DP[i][i*k + j] %= mod;
			}
		}
	}
	std::cout << DP[B][N] << std::endl;
	return 0;
}

Measured memory_bytes: 8192
def getKth(x, a, k):
    if(k < a):
        return k
    return k + 1
def getRKth(x, a, k):
    if(x < a):
        return x - k + 1
    if(k < (x - a)):
        return x - k + 1
    return x - k
def NB(x, b):
    if(x < b):
        return x
    return x + 1
def f(x, a, b):
    mv = 5
    half = (x + 1) / 2
    rep = 0
    for delta in xrange(-mv, mv + 1):
        if(half + delta >= 1 and half + delta <= x):
            rep = max(rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta))
    half = b - a
    for delta in xrange(-mv, mv + 1):
        if(half + delta >= 1 and half + delta <= x):
            rep = max(rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta))
    half = NB(x, b) - b
    for delta in xrange(-mv, mv + 1):
        if(half + delta >= 1 and half + delta <= x):
            rep = max(rep, getKth(x, a, half + delta) * getRKth(NB(x, b), b, half + delta))
    return rep
q = int(raw_input())
while(q > 0):
    a, b = map(int, raw_input().split())
    if(a > b):
        a, b = b, a
    lo = 1
    hi = 10**19
    res = 0
    # print f(1, a, b)
    # print f(2, a, b)
    # print f(3, a, b)
    # print getKth(2, a, 1), getRKth(NB(2, b), b, 1)
    # print getKth(2, a, 2), getRKth(NB(2, b), b, 2)
    while(lo <= hi):
        mid = (lo + hi)/2
        if(f(mid, a, b) < a * b):
            lo = mid + 1
            res = mid
        else:
            hi = mid - 1
    print res
    q -= 1


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int n, m;
int d[55], e[55];
vector<Pi> G[55];
vector<Pi> rG[55];
int id[55], cnt[1010];

int dp[55][55][1<<10];

struct State {
  int u, v, bit, cost;
  State(){}
  State(int u, int v, int bit, int cost):u(u), v(v), bit(bit), cost(cost){}
  bool operator < (const State& rhs) const {
    return cost > rhs.cost;
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> n >> m, n || m) {
    rep(i, n) {
      G[i].clear();
      rG[i].clear();
    }
    memset(cnt, 0, sizeof(cnt));
    d[0] = 0; e[0] = 0;
    id[0] = cnt[0]++;
    reps(i, 1, n-1) {
      cin >> d[i] >> e[i];
      id[i] = cnt[e[i]]++;
    }
    d[n-1] = 0; e[n-1] = 1000;
    id[n-1] = cnt[1000]++;
    rep(i, m) {
      int a, b, c;
      cin >> a >> b >> c;
      --a, --b;
      G[a].emplace_back(b, c);
      rG[b].emplace_back(a, c);
    }
    auto dijkstra = [&]() -> int {
      fill((int*)dp[0], (int*)dp[55], inf);
      priority_queue<State> que;
      que.push(State(0, 0, 0, 0));
      while(!que.empty()) {
	State now = que.top(); que.pop();
	//cout<<now.u<<" "<<now.v<<" "<<now.bit<<" "<<now.cost<<endl;
	if(now.u == n-1 && now.v == n-1) return now.cost;
	if(dp[now.u][now.v][now.bit] < now.cost) continue;
	if(e[now.u] <= e[now.v]) {
	  for(Pi p : G[now.u]) {
	    State nxt = now;
	    if(e[now.u] > e[p.first]) continue;
	    if(e[now.v] != e[p.first]) {
	      nxt.u = p.first;
	      nxt.bit = 0;
	      nxt.cost += p.second+d[p.first];
	    } else if((now.bit>>id[p.first])&1) {
	      nxt.u = p.first;
	      nxt.cost += p.second;
	    } else {
	      nxt.u = p.first;
	      nxt.bit |= (1<<id[p.first]) | (1<<id[now.v]);
	      nxt.cost += p.second+(p.first == now.v ? 0 : d[p.first]);
	    }
	    if(nxt.cost < dp[nxt.u][nxt.v][nxt.bit]) {
	      dp[nxt.u][nxt.v][nxt.bit] = nxt.cost;
	      que.emplace(nxt);
	    }
	  }
	}
	if(e[now.u] >= e[now.v]) {
	  for(Pi p : rG[now.v]) {
	    State nxt = now;
	    if(e[now.v] > e[p.first]) continue;
	    if(e[now.u] != e[p.first]) {
	      nxt.v = p.first;
	      nxt.bit = 0;
	      nxt.cost += p.second+d[p.first];
	    } else if((now.bit>>id[p.first])&1) {
	      nxt.v = p.first;
	      nxt.cost += p.second;
	    } else {
	      nxt.v = p.first;
	      nxt.bit |= (1<<id[p.first]) | (1<<id[now.u]);
	      nxt.cost += p.second+(p.first == now.u ? 0 : d[p.first]);
	    }
	    if(nxt.cost < dp[nxt.u][nxt.v][nxt.bit]) {
	      dp[nxt.u][nxt.v][nxt.bit] = nxt.cost;
	      que.emplace(nxt);
	    }
	  }
	}
      }
      return -1;
    };
    cout << dijkstra() << endl;
  }

  return 0;
}



Measured memory_bytes: 29012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=3e2+5;
const int M=3e2+5;
const ll mod=1e9+7;
//ÌâÒâ:n¼þÎïÆ·,m¸öÒªÇó,3ÖÖÑÕÉ«,n,m<=300,ÏÞÖÆÎª(li,ri,xi) ÒªÇó[li~ri]ÄÚ²»Í¬ÑÕÉ«¸öÊýÎªxi ÎÊÂú×ãmÌõ¼þµÄÉÏÉ«·½°¸Êý? 
ll dp[N][N][N];//dp[r][g][b] Ç°k¸ö¿éÖÐ,k=max(r,g,b),×îºóÒ»¸öÉÏºìÉ«,ÂÌÉ«,À¶É«µÄÎ»ÖÃÎªr,g,b &&Âú×ãri<=kµÄËùÓÐÌõ¼þ 
int n,m;
vector<ii> v[N];// 
bool check(int r,int g,int b)
{
	int k=max(r,max(g,b));
	for(int j=0;j<v[k].size();j++)
	{
		int l=v[k][j].first,x=v[k][j].second;
		//[l~k]
		int cnt=0;
		if(r>=l)	cnt++;
		if(g>=l)	cnt++;
		if(b>=l) 	cnt++;
		if(cnt!=x)
			return false;
	}
	return true;	
}
int main()
{
	while(cin>>n>>m)
	{
		for(int i=1;i<=n;i++)
			v[i].clear();
		int l,r,x;
		for(int i=1;i<=m;i++)
		{
			cin>>l>>r>>x;
			v[r].push_back(ii(l,x)); 
		}		
		memset(dp,0,sizeof(dp));
		dp[0][0][0]=1;
		ll ans=0;
		for(int r=0;r<=n;r++)
		{
			for(int g=0;g<=n;g++)
			{
				for(int b=0;b<=n;b++)
				{
					if(dp[r][g][b]==0)//·Ç·¨ 
						continue;	
					if(!check(r,g,b))
					{
						dp[r][g][b]=0;
						continue;
					}
					int k=max(r,max(g,b))+1;				
					if(k==n+1)
						ans=(ans+dp[r][g][b])%mod;
					//ÏÂÒ»¸öÎ»ÖÃÑÕÉ«
					dp[k][g][b]+=dp[r][g][b]%mod;
					dp[r][k][b]+=dp[r][g][b]%mod;
					dp[r][g][k]+=dp[r][g][b]%mod;	
				}	
			}	
		}	
		cout<<ans<<endl;	
	}
	return 0;
}

Measured memory_bytes: 221952
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> par_size;

    UnionFind(int N) : par(N){ //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            par[i] = i;
        }
        par_size.resize(N);
        for(int i = 0; i < N; i++){
            par_size[i] = 1;
        }

    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x){
            return x;
        }
        else{
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        par_size[ry] += par_size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int get_size(int x){
        int rx = root(x);
        return par_size[rx];
    }
};


int main(){

    ll N, M;
    cin >> N >> M;

    vector <ll> v(N);
    for(int i = 0; i < N; i++) {
        cin >> v[i];
        v[i] --;
    }

    UnionFind uni(N);
    for(int i = 0; i < M; i++){
        ll x, y;
        cin >> x >> y;
        uni.unite(x-1, y-1);
    }

    ll ans = 0;
    for(int i = 0; i < N; i++){
        if(uni.same(i, v[i]) ) ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) {
      cin >> v[i];
  }
  sort(v.begin(),v.end());
  int q,ans=0,a;
  cin >> q;
  while(q--) {
      cin >> a;
      if(binary_search(v.begin(),v.end(),a)) {
          ans++;
      }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3124
#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>;

int main(){
	int n;
	cin >> n;
	int ans = 0;
    int ansnum;
	for(int i = 1;i <=n;i++){
		int cnt = 0;
		int j = i;
		while(1){
			if(j % 2 == 0) cnt++;
			else break;
			j /= 2;
		}
        if(ans <= cnt){
		    ans = max(ans,cnt);
            ansnum = i;
        }
	}
	cout << ansnum << endl;
}

Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-6;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif
const long double PI = acos(-1);
int a, b ,x; 

double volx(double A){

	double tmp = tan(A * PI / 180) , vol ;
	if(b * tmp  <= a){
		vol = ( 0.5 * a * b * b * tmp )  ;
	}else{
		double bb = a / tmp ;
		vol = a * a * ( b - bb ) + 0.5 * a * a * bb ;
	}
	return vol ;
}
void solve()
{
	cin >> a >> b >> x; 
	double l = 0.0 , r = 90.0; 
	cout << std::fixed << setprecision(10) ;
	while(r - l > eps){
		double m = (l + r) / 2 ; 
		// cout << l << " " << r << " " << m << " " << x << " " << volx(m) << endl ;
		if(volx(90 - m) < x) // decrease volume, by decreasing angle
			r = m ;
		else 
			l = m ;
	}
	cout << l ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin>>N;
  vector<string> ss;
  vector<int> snum;
  
  for(int i=0;i<N;i++){
    string tmp;
    cin>>tmp;
    bool ok=false;
    for(int j=0;j<ss.size();j++){
      if(ss.at(j)==tmp){snum.at(j)++;ok=true;break;}
    }
    if(!ok){ss.push_back(tmp);snum.push_back(1);}
  }
  cin>>M;
  for(int i=0;i<M;i++){
    string tmp;
    cin>>tmp;
    for(int j=0;j<ss.size();j++){
      if(ss.at(j)==tmp){snum.at(j)--;break;}
    }
  }
  
  int max=0;
  for(int i=0;i<ss.size();i++){
  	  if(max<snum.at(i))max=snum.at(i);
  }
  cout<<max<<endl;
}

Measured memory_bytes: 256
// Problem : B - Crane and Turtle
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mk make_pair
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x) (int)x.size()
#define mem(a, val) memset(a, val, sizeof(a))
#define deci(x) cout << fixed << setprecision(x);
#define bitcount(x) __builtin_popcountll(x)

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

const long long int mod = 1e9 + 7;
const long double EPS = 1e-12;
const int N = 1e5 + 20;

void solve() {
  ll x, y;
  cin >> x >> y;
  if ((2 * x) > y || (4 * x) < y || (y % 2)) {
    cout << "No";
    return;
  }
  cout << "Yes";
}
int main() {
  fast;
  ll t;
  t = 1;

  // cin>>t;

  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+10;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

int main() {
    string s; cin >> s;
    int n = s.size();
    vector<vector<mint>> dp(n+1,vector<mint>(4,0));
    dp[0][0] = 1;
    REP(i,n+1) {
        rep(j,4) {
            dp[i][j] += dp[i-1][j] * (s[i-1] == '?' ? 3 : 1);
        }
        rep(j,3) {
            if (s[i-1] == "ABC"[j] || s[i-1] == '?') {
                dp[i][j+1] += dp[i-1][j];
            }
        }
    }
    cout << dp[n][3] << endl;
}

Measured memory_bytes: 10344
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#define pi 3.14159265358979323846

using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN = 3005;
int n,L;
ld t[MAXN],pre[2][2][MAXN][MAXN];

int main()
{
	cin >> n >> L;
	for(int i = 1; i<=n; i++)
	    cin >> t[i];
	ld ansx = 0, ansy = 0;
	for(int i = 1; i<=n; i++)
		for(int j = i+1; j<=n; j++)
	    {
			int cnt = j-i-1;
			ld tmp = pi*(t[i]+t[j])/L;
			ansx += cos(tmp)*(n-2*cnt-2), ansy += sin(tmp)*(n-2*cnt-2);
		}
	ansx /= 1ll*n*(n-1)*(n-2)/6;
	ansy /= 1ll*n*(n-1)*(n-2)/6;
	printf("%.12lf %.12lf\n",(double)ansx,(double)ansy);
	return 0;
}


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

using namespace std;

constexpr long long MOD = 1e9+7;

// MOD考慮べき乗関数 計算量O(log(N))
template<typename type>
inline type ModPow(type a, type b)
{
	type ret=1;
	while(b>0){
		if(b&0x1) ret=ret*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return ret;
}

// メモ化MOD考慮Combination関数使用準備関数 計算量O(N)
vector<long long> fac, finv, inv;
inline void ModCombiSetup(int size)
{
	fac.resize(size+1);
	finv.resize(size+1);
	inv.resize(size+1);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(long long i=2;i<size;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}

// メモ化MOD考慮Combination関数 計算量O(1)
inline long long ModCombi(long long n, long long r)
{
	if(n==0 && r==0) return 1;
	if(n<r || n<0) return 0;
	return fac[n]*(finv[r]*finv[n-r]%MOD)%MOD;
}

int main()
{
    int k;
    string s;
    cin >> k;
    cin >> s;

    long long ans=0;
    long long s_length    = s.length();
    long long word_length = s.length()+k;
    ModCombiSetup(word_length);

    for(long long i=s_length;i<=word_length;i++){
        long long t = ModCombi(i-1, s_length-1);
        t = t * ModPow(25ll, i-s_length) % MOD;
        t = t * ModPow(26ll, word_length-i) % MOD;
        ans = (ans+t) % MOD;
    }

    cout << ans << endl;
}

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

template <int MOD_>
struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");
 
private:
	using ll = long long;
 
	int v;
 
	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}
 
public:
 
	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
 
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
 
	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
 
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}
 
	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}
 
	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<998244353>;

const int MAXN = 2.1e5;
int N;
string X_;
bool X[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> X_;
	for (int i = 0; i < N; i++) {
		X[i] = bool(X_[i] - '0');
	}

	num ans = 0;
	unordered_map<int, num> weights;
	for (int p = 1; p <= 2*N; p++) {
		if ((2*N) % p != 0 || N % p == 0) continue;
		assert(p % 2 == 0);

		num weight = 0;
		for (int i = 0; i < p/2; i++) {
			weight *= 2;
			weight += int(X[i]);
		}
		bool canEqual = true;
		for (int i = 0; i < N; i++) {
			bool v = X[i % (p/2)] ^ ((i / (p/2) & 1));
			if (v < X[i]) {
				break;
			}
			if (v > X[i]) {
				canEqual = false;
				break;
			}
		}
		weight += int(canEqual);

		for (auto it : weights) {
			if (p % it.first == 0) {
				weight -= it.second;
			}
		}
		ans += weight * p;
		weights[p] = weight;
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 788
mod = 1000000007
s = input()
al = 0
cr = s.count('C')
ql = 0
qr = s.count('?')
ans = 0
for c in s:
  if c == 'C':
    cr -= 1
  elif c == '?':
    qr -= 1
    ans += (3 * al + ql) * (3 * cr + qr) * pow(3, ql + qr + mod - 3, mod)
    ans %= mod
    ql += 1
  elif c == 'B':
    ans += (3 * al + ql) * (3 * cr + qr) * pow(3, ql + qr + mod - 3, mod)
    ans %= mod
  else:
    al += 1
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
// Union-Find with potential
//https://qiita.com/drken/items/cce6fc5c579051e64fab

struct Potential_UnionFind {
    vector<int> par;
    vector<long long> diff_weight;
    Potential_UnionFind(int n = 1, long long SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, long long SUM_UNITY = 0) {
        par.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = -1, diff_weight[i] = SUM_UNITY;
    }

    int root(int x){
        if (par[x] < 0) {
            return x;
        }else{
            //path compression
            int rt = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = root(par[x]);
        }
    }

    int size(int x){
        return -par[root(x)];
    }

    int weight(int x){
        root(x);
        return diff_weight[x];
    }

    int diff(int x,int y){
        return weight(y) - weight(x);
    }

    bool isConnect(int x,int y){
        return root(x) == root(y);
    }

    bool connect(int x , int y, long long w){
        //weight(y) - weight(x) = w
        //xとyの差を無理やりwにするために現状の親からのpotentialの差をキャンセルする．
        w += weight(x); w-= weight(y);
        x = root(x);
	    y = root(y);
	
        if(x==y) return false;
        
        //if rank[x] < rank[y]
        if(par[x] > par[y]){
            x ^= y;
            y ^= x;
            x ^= y;
            w = -w;
        }
        
        par[x] = par[x] + par[y]; // membersize++
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
};

Potential_UnionFind U(100002);

int main(){
    int N,M;
    SCD2(N,M);

    REP(i,M){
        int L,R;
        integer D;
        SCD2(L,R); SCLLD(D);

        if (U.isConnect(L,R)){
            if (D != (integer)U.diff(L,R)){
                printf("No\n");
                return 0;
            }
        }else{
            U.connect(L,R,D);
        }
    }

    printf("Yes\n");
}




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


struct P
{
    int x,y;
};
int h,w,k;
char a[1111][1111];
int o[1111][1111],dx[10]={1,0,-1,0},dy[10]={0,1,0,-1};
queue<P> q;


int main()
{
    memset(o,-1,sizeof(o));
	scanf("%d %d",&h,&w);
	for(int i=1;i<=h;i++)
        scanf("%s",a[i]+1);
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
        if(a[i][j]=='#')
    {
        o[i][j]=0;
        q.push({i,j});
    }
    for(;q.size();q.pop())
    for(int h=0;h<4;h++)
    {
        int x=dx[h]+q.front().x,y=dy[h]+q.front().y;
        if(o[x][y]<0&&a[x][y])
        {
            o[x][y]=o[q.front().x][q.front().y]+1;
            k=max(k,o[x][y]);
            q.push({x,y});
        }
    }
    printf("%d",k);
}


Measured memory_bytes: 14352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  ll value; ll ans_first = a*x + b*y;
  ll ans = 1000000007;
  int x_now; int y_now;
  for (ll i=0; i<=max(x,y)*2; i+=2){
    if (x-i/2 < 0) x_now = x;
    else x_now = i/2;
    if (y-i/2 < 0) y_now = y;
    else y_now = i/2;
    value = ans_first + c*i - a*x_now - b*y_now;
    if (value < ans) ans = value;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
 {  fast();
	int t, n, k;
	t=1;
	string s;
	while(t--) {
	    cin >> s;
	    cout<<s.substr(0,3);
	    
	  
	}}

Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	// Code for A - Diagonal String
	S := make([]string, 3)
	fmt.Scanf("%s", &S[0])
	fmt.Scanf("%s", &S[1])
	fmt.Scanf("%s", &S[2])

	fmt.Printf("%c%c%c\n", S[0][0], S[1][1], S[2][2])
}


Measured memory_bytes: 1828
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl

typedef long long ll;
using namespace std;

bool isPrime(int n) {
	if (n == 1) return false;
	if (n == 2) return true;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) return false;
	}
	return true;
}

void calc(int n) {
	int count = 0;
	REG(i, n + 1, 2 * n + 1) {
		if (isPrime(i)) {
			count++;
		}
	}
	PRINT(count);
}

int main() {
	cin.tie(0); //対話型には使えない
	ios::sync_with_stdio(false); //printfと共には使えない
	int n;
	while (cin >> n, n != 0) {
		calc(n);
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)

const int MAX = 100010;
bool dp[MAX];
int a[MAX];
int main(){
	fill((bool*)dp, (bool*)(dp+MAX), true);
	dp[0] = dp[1] = false;
	repi(i,2,MAX){
		if(dp[i] == true)for(int j = 2;j*i < MAX;j++){
			dp[i*j] = false;
		}
	}
	rrep(i,MAX){
		if(dp[i] && dp[(i+1)/2])a[i]++;
	}
	rrep(i,MAX)a[i] += a[i-1];
	//rep(i,10)printf("%d ", a[i]);
	int n;
	scanf("%d", &n);
	rep(i,n){
		int l, r;
		scanf("%d%d", &l, &r);
		printf("%d\n", a[r]-a[l-1]);
	}
	return 0;
}

Measured memory_bytes: 1152
N = int(input())
A = list(map(int, input().split()))

dic = {}
cnt = 0

for x in A:
    if x not in dic.keys():
        dic[x] = 1
    else:
        dic[x] += 1

dic = sorted(dic.items(), reverse=True)

ans = 0
for i in range(len(dic)):
    if dic[i][1] >= 4 and cnt == 0:
        ans = dic[i][0]**2
        break
    elif dic[i][1] >= 2:
        if cnt == 1:
          ans = t*dic[i][0]
          break 
        if cnt == 0:
            t = dic[i][0]
            cnt = 1
print(ans)

Measured memory_bytes: 21028
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[3] , b , c = 1;
    cin >> a[0] >> a[1] >> a[2];
    if ( a[0] == a[1] && a[0] == a[2] ) cout << 1;
    if ( a[0] == a[1] && a[0] != a[2] ) cout << 2;
    if ( a[0] == a[2] && a[0] != a[1] ) cout << 2;
    if ( a[1] == a[2] && a[1] != a[0] ) cout << 2;
    if ( a[0] != a[1] && a[1] != a[2] && a[0] != a[2] ) cout << 3;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int ans = (a-b)%c;
	cout<<ans<<endl;
	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//main code



int main(int argc, char const* argv[])
{
	int n,m;
	cin >> n >> m;
	VVL v(n*3);
	for (int i = 0; i < m; i++) {
		int x,y;
		cin >> x >> y;
		--x;--y;
		v[x].push_back(y+n);
		v[x+n].push_back(y+2*n);
		v[x+2*n].push_back(y);
	}
	int s,t;
	cin >> s >> t;
	--s;--t;
	VL dist(3*n,-3);
	dist[s]=0;
	queue<int> q;
	q.push(s);
	while (!q.empty()) {
		int cur=q.front();q.pop();
		for (auto&& to : v[cur]) {
			if ((uint64_t)dist[to] > dist[cur]+1) {
				dist[to]=dist[cur]+1;
				q.push(to);
			}
		}
	}
	cout << dist[t]/3 << endl;
	return 0;
}


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

int main(){
  int N; cin >> N;
  int a[100000],b[100000],c[100000];
  for(int i=0; i<N; i++) cin >> a[i] >> b[i] >> c[i];
  
  int dp[100001][3];
  memset(dp,0,sizeof(dp));
  for(int i=0; i<N; i++){
    dp[i+1][0]=max(dp[i][1],dp[i][2])+a[i];
    dp[i+1][1]=max(dp[i][0],dp[i][2])+b[i];
    dp[i+1][2]=max(dp[i][0],dp[i][1])+c[i];
  }
  cout << max({dp[N][0],dp[N][1],dp[N][2]}) << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;

void dfs(vector<array<ll, 2>> g[], int u, int v, ll dist[])
{
	for (auto x : g[u])
	{
		if (x[0] == v) continue;
		dist[x[0]] = x[1] + dist[u];
		dfs(g, x[0], u, dist);
	}
}

void solve()
{
	int n; cin >> n;
	vector<array<ll, 2>> g[n+1];
	for (int i = 0; i < n-1; ++i)
	{
		ll u, v, w; cin >> u >> v >> w;
		g[u].pb({v, w});
		g[v].pb({u, w});
	}
	ll dist[n+1];
	dist[1] = 0;
	dfs(g, 1, -1, dist);
	for (int i = 1; i <= n; ++i)
	{
		if (dist[i] & 1) cout << 0 << '\n';
		else cout << 1 << '\n';
	}
}

//  ---------------------Template---------------------------
void InputSetup()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
}

int main(void)
{
	auto start = chrono::high_resolution_clock::now();

	InputSetup();
	solve();

	auto finish = chrono::high_resolution_clock::now();
	cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
}
//  ---------------------Template---------------------------

Measured memory_bytes: 11648
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int m;
vector<vector<bool> > room;
vector<vector<vector<vector<int> > > > memo;

int solve(int a, int b, int turn, int depth)
{
    if(depth >= 2*m)
        return INT_MAX/2;
    if(memo[a][b][turn][depth] != -1)
        return memo[a][b][turn][depth];

    if(turn == 0){
        int ret = 0;
        for(int i=0; i<m; ++i){
            if(a != i && !room[a][i])
                continue;
            ret = max(ret, solve(i, b, 1, depth+1));
        }
        return memo[a][b][0][depth] = ret;
    }else{
        int ret = INT_MAX/2;
        for(int i=0; i<m; ++i){
            if(b == i || !room[b][i])
                continue;
            ret = min(ret, solve(a, i, 0, depth+1)+1);
        }
        return memo[a][b][1][depth] = ret;
    }
}

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

    while(--n >= 0){
        cin >> m;
        room.assign(m, vector<bool>(m));
        memo.assign(m, vector<vector<vector<int> > >(m, vector<vector<int> >(2, vector<int>(2*m, -1))));
        for(int i=0; i<m; ++i){
            for(int j=0; j<m; ++j){
                int tmp;
                cin >> tmp;
                room[i][j] = (tmp == 1);
            }
            for(int j=0; j<2*m; ++j){
                memo[i][i][0][j] = 0;
                memo[i][i][1][j] = 0;
            }
        }

        int a, b;
        cin >> a >> b;

        int ret = solve(a, b, 0, 0);
        if(ret >= INT_MAX/2)
            cout << "infinity" << endl;
        else
            cout << ret << endl;
    }
}

Measured memory_bytes: 0
T=!!0
F=!T
[T,F].map{|c|
class<<c
alias:%:==
def!=x
!self|x
end
end
}
until(s=gets.tr"-=>*+","!%=&|")=~/#/
puts %w(T F).repeated_permutation(11).all?{|a|
eval s.tr (?a..?k).to_a*'',a*''
}?'YES':'NO'
end

Measured memory_bytes: 13368
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
using bll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(v) (v).begin(), (v).end()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
template<typename T> inline void pv(vector<T> v) { for(ll i=0, N=v.size()-1; i<=N; i++) if(i!=N) cout << v[i] << ' '; else cout << v[i] << endl; }
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

signed main() {
	string S;
	cin >> S;
    vector<ll> a(26,0);
    rep(i,S.size()){
        char c=S[i]-'a';
        a[c]++;
    }

    ll ans=(S.size()-1)*S.size()/2;
    rep(i,26){
        ans-=a[i]*(a[i]-1)/2;
    }
    p(ans+1);
	return 0;
}


Measured memory_bytes: 640