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

using ll = long long;
const int INF = INT_MAX;//2147483647
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#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(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline double isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
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<-----*/


int main(){
	int n,m;
	cin >> n >> m;
	vector<vector<int>> path(m, vector<int>(2, 0));
	rep(i,m){
		int a,b;
		cin >> a >> b;
		path[i]={a,b};
	}

	vector<int> route(n,0);
	repeq(i,n){
		route[i-1]=i;
	}

	debug(path);

	int count=0;
	do {
		if(route[0]!=1)continue;
		[&]{
			for (int i = 1; i < route.size(); i++) {
				bool ok=false;
				int a=route[i-1];
				int b=route[i];
				if(a>b)swap(a,b);
				for(auto pp:path){
					if(pp[0]==a && pp[1]==b){
						ok=true;
						break;
					}
				}
				if(!ok){
					return;
				}
			}
			count++;
		}();
	} while (std::next_permutation(route.begin(), route.end()));//昇順順列生成、vが昇順ソート済みの必要あり

	p(count);
	return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[200005];
void score(char c,int i,int j,int k) {
    if(c == '+') {
        cnt[k] = cnt[i]+cnt[j];
    }
    else {
        cnt[k] = (int)(cnt[j] > cnt[i]);
    }
}
signed main() {
    cnt[0] = 2;cnt[1] = 3;
    int ans = 0;
    cout << 85623 << endl;
    cout << "+ 0 1 2000" << endl;
    score('+',0,1,2000);
    cout << "< 4 2000 4" << endl;
    score('<',4,2000,4);
    ans++;
    for(int i = 5; i <= 33; i++) {
        cout << "+ " << i-1 << " " << i-1 << " " << i << endl;
        score('+',i-1,i-1,i);
        ans++;
    }
    cout << "+ 0 4 0" << endl;
    cout << "+ 1 4 1" << endl;
    score('+',0,4,0);
    score('+',1,4,1);
    ans += 2;
    for(int i = 33; i >= 4; i--) {
        cout << "+ 3 " << i << " " << 34 << endl;
        score('+',3,i,34);
        cout << "< 34 1 35" << endl;
        score('<',34,1,35);
        ans += 2;
        for(int j = 36; j <= 64; j++) {
            cout << "+ " << j-1 << " " << j-1 << " " << j << endl;
            score('+',j-1,j-1,j);
            ans++;
        }
        cout << "+ 3 " << i+31 << " " << 3 << endl;
        score('+',3,i+31,3);
        ans++;
        for(int j = 33; j >= 4; j--) {
            cout << "+ 65 " << j << " " << 66 << endl;
            score('+',65,j,66);
            cout << "< 66 0 67" << endl;
            score('<',66,0,67);
            ans+=2;
            for(int k = 68; k <= 96; k++) {
                cout << "+ " << k-1 << " " << k-1 << " " << k << endl;
                score('+',k-1,k-1,k);
                ans++;
            }
            cout << "+ 67 35 97" << endl;
            score('+',67,35,97);
            ans++;
            cout << "< 4 97 98" << endl;
            score('<',4,97,98);
            ans++;
            cout << "+ " << "65 " << j+63 << " " << 65 << endl;
            score('+',65,j+63,65);
            ans++;
            for(int k = 99; k  <= 127; k++) {
                cout << "+ " << k-1 << " " << k-1 << " " << k << endl;
                score('+',k-1,k-1,k);
                ans++;
            }
            cout << "+ " << 600 << " " << j+94 << " " << 128 << endl;
            score('+',600,j+94,128);
            ans++;
            for(int k = 129; k <= 157; k++) {
                cout << "+ " << k-1 << " " << k-1 << " " << k << endl;
                score('+',k-1,k-1,k);
                ans++;
            }
            cout << "+ " << 2 << " " << i+124 << " " << 2 << endl;
            score('+',2,i+124,2);
            ans++;
        }
        cout << "+ 700 700 65" << endl;
        score('+',700,700,65);
        ans++;
    }
}


Measured memory_bytes: 3556
import java.util.Scanner;

/**
 * A - Multiplication 1
 * A×B を求めてください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 入力値
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println( a * b );

        sc.close();
    }
}

Measured memory_bytes: 35828
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define LLIandI pair<long long int , int>
#define ll long long




//xy平面上にN個の点が与えられる．
//半径1の円をxy平面 上で動かして，それらの点をなるべくたくさん囲むようにする．
//このとき，最 大でいくつの点を同時に囲めるかを答えなさい．
//ここで，ある円が点を「囲む」 とは，その点が円の内部または円周上にあるときをいう．

int main(){
    while(1){
        //1 <= N <= 300, 0.0 <= X <= 10.0, および0.0 <= Y <= 10.0と仮定してよい
        int N;
        scanf("%d",&N);
        if(N==0)break;
        float X[303],Y[303];
        rep(i,N){
            scanf("%f %f",&X[i],&Y[i]);
        }
        //二つの点を通る縁を全て考える
        //二つの縁の組み合わせが300*299/2通り、
        //それぞれについて2通りの縁が考えられる。
        //3つの点が円を通過することがないという条件から、重複はない。
        int ans=0;
        rep(i,N){
            rep(j,i){
                //円の中心を計算
                float nx=(X[i]+X[j])/2.0;//二等分点
                float ny=(Y[i]+Y[j])/2.0;
                float len1=sqrt(pow(X[i]-nx,2.0)+pow(Y[i]-ny,2.0));
                if(len1>1.0)continue;
                float ex=(Y[i]-ny)/len1;
                float ey=-(X[i]-nx)/len1;
                float len=sqrt(1.0-pow(len1,2.0));
                for(float swi=-1.0;swi<=1.0;swi+=2.0){
                    float cx=nx+ex*len*(swi);
                    float cy=ny+ey*len*(swi);
                    int sans=0;
                    //単位ベクトル
                    rep(k,N){
                        if(k==i||k==j){sans++;}
                        else{
                            if(sqrt(pow(X[k]-cx,2.0)+pow(Y[k]-cy,2.0))<1.0)sans++;
                        }
                    }
                    ans=max(ans,sans);
                }
            }
        }
        printf("%d\n",max(1,ans));
    }
	return 0;
}



Measured memory_bytes: 2616
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(void){
	int h=0,r=0;
	scanf("%d %d",&h,&r);
	if(abs(h)==abs(r)){
		if(h<0){
			cout<<0<<endl;
		}
		else{
			cout<<1<<endl;
		}
	}
	else if(abs(h)<abs(r)){
		cout<<1<<endl;
	}
	else if(abs(h)>abs(r)){
		if(h>0){
			cout<<1<<endl;
		}
		else{
			cout<<-1<<endl;
		}
	}
}


Measured memory_bytes: 3228
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=998244353;
const int maxn=3e5+100;
const int N=1e6+100;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll a[N];
bool check(ll x,ll y,ll z)
{
    if(x==y||y==z||x==z) return 0;
    if(x+y<=z||x+z<=y||y+z<=x) return 0;
    return 1;
}
int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    int n;cin>>n;
    rep1(i,n) cin>>a[i];
    int ans=0;
    for(int i=1;i<=n;++i)
        for(int j=i+1;j<=n;++j)
            for(int k=j+1;k<=n;++k)
                if(check(a[i],a[j],a[k])) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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 int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    const ll INF = 1e18;
    int V, E;
    cin >> V >> E;
    ll dis[V][V];
    rep(i,V)rep(j,V){
        if(i==j) dis[i][j] = 0;
        else dis[i][j] = INF;
    }
    rep(i,E){
        int a, b, c;
        cin >> a >> b >> c;
        dis[a][b] = c;
    }
    rep(k,V)rep(i,V)rep(j,V){
        dis[i][j] = min(dis[i][j], dis[i][k]+dis[k][j]);
    }
    rep(i,V)rep(j,V){
        if(dis[i][j]+dis[j][i] < 0){
            cout <<"NEGATIVE CYCLE" << endl;
            return 0;
        }
    }
    rep(i,V)rep(j,V){
        if(dis[i][j] >= 1e17) cout << "INF";
        else cout << dis[i][j];
        if(j==V-1) cout << endl;
        else cout << " ";
    }
}


Measured memory_bytes: 3180
#include <stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int A,B,C,D;
	A = N/1000;
	B = (N-A*1000)/100;
	C = (N-A*1000-B*100)/10;
	D = (N-A*1000-B*100-C*10);
	if(A+B+C+D == 7)printf("%d+%d+%d+%d=7",A,B,C,D);
	else if(A+B+C-D == 7)printf("%d+%d+%d-%d=7",A,B,C,D);
	else if(A+B-C+D == 7)printf("%d+%d-%d+%d=7",A,B,C,D);
	else if(A+B-C-D == 7)printf("%d+%d-%d-%d=7",A,B,C,D);
	else if(A-B+C+D == 7)printf("%d-%d+%d+%d=7",A,B,C,D);
	else if(A-B+C-D == 7)printf("%d-%d+%d-%d=7",A,B,C,D);
	else if(A-B-C+D == 7)printf("%d-%d-%d+%d=7",A,B,C,D);
	else if(A-B-C-D == 7)printf("%d-%d-%d-%d=7",A,B,C,D);
	
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
    ll N; cin >> N;
    string S; cin >> S;
    map<char, vector<ll>> m;
    for (int i = 0; i < S.size(); ++i) {
        m[S[i]].push_back(i);
    }
    ll ans = m['R'].size() * m['G'].size() * m['B'].size();
    for (auto i: m['R']) {
        for (auto j: m['G']) {
            for (auto k: m['B']) {
                if (i * 2 == j + k || j * 2 == i + k || k * 2 == i + j) ans--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3676
import bisect

N = int(input())
A = list(map(int, input().split()))

A.sort()

# 組み合わせの片方は最大値
n = A[-1]

# もう片方はnの半分に近い値
# 二分探索で最も近い値を見つける
mid = bisect.bisect(A, n/2)

# 一つ手前の値とどちらが近いかチェックして、近い方を出力する
if abs(n/2-A[mid-1]) > abs(n/2-A[mid]):
    print(n, A[mid])
else:
    print(n, A[mid-1])


Measured memory_bytes: 19880
import java.io.*;
import java.util.*;
import java.text.*;
public class Main {
	static class Node implements Comparable<Node>{
		int t,y,l,r;
		public Node(int t,int y,int l,int r){
			this.t=t;
			this.y=y;
			this.l=l;
			this.r=r;
		}
		@Override
		public int compareTo(Node arg0) {
			// TODO Auto-generated method stub
			if(this.y==arg0.y){
				if(this.t>arg0.t)return 1;
				else return -1;
			}
			else{
				if(this.y>arg0.y)return 1;
				else return -1;
			}
		}
		
	}
	static StreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
	static int nextInt()throws IOException{
		in.nextToken();
		return (int)in.nval;
	}
	static int n,m=200000,s,time,x1,y1,x2,y2,temp,ed,aed;
	static long ans,k;
	static long[] f=new long[200002];
	static long[] a=new long[200002];
	static long[] b=new long[200002];
	static HashMap<Long,Integer> hm=new HashMap<Long,Integer>();
	static int lowb(int x){
		return x&(-x);
	}
	static long sum(int x){
		long ans=0;
		while(x>0){
			ans+=f[x];
			x-=lowb(x);
		}
		return ans;
	}
	static void add(int x,int p){
		while(x<=m){
			f[x]+=p;
			x+=lowb(x);
		}
	}
	public static void main(String args[])throws IOException{
		n=nextInt();
		k=nextInt();
		for(int i=1;i<=n;i++){
			a[i]=a[i-1]+nextInt()-k;
			b[i]=a[i];
		}	
		Arrays.sort(b,1,n+1);
		hm.clear();
		ed=0;
		for(int i=1;i<=n;i++){
			if(!hm.containsKey(b[i]))hm.put(b[i],++ed);
		}
		ans=0;
		for(int i=1;i<=n;i++){
			if(a[i]>=0)ans++;
			ans+=sum(hm.get(a[i]));
			add(hm.get(a[i]),1);
		}
		out.println(ans);
		out.flush();	
	}
}


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

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, list) for(auto i : list)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define mp make_pair

using namespace std;

using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;

const int INF = 1e9;
const int MOD = 1e9+7;

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; }

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int H, W; cin >> H >> W;
    int ans = 0;
    vvi c(10, vi(10)); REP(i, 10) REP(j, 10) cin >> c[i][j];
    vvi A(H, vi(W)); REP(i, H) REP(j, W) cin >> A[i][j];
    REP(k, 10) REP(i, 10) REP(j, 10) chmin(c[i][j], c[i][k]+c[k][j]);
    REP(i, H) REP(j, W) if(A[i][j] != -1 && A[i][j] != 1) ans += c[A[i][j]][1];
    cout << ans << endl;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数
ll d[1000000];
ll e[3000000];

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int ans1 = 0, ans2 = 0;
	char s[100001];
	scanf("%s", s);
	REP(i, strlen(s)) {
		if (i % 2 == s[i] - '0') {
			ans1++;
		}
		else {
			ans2++;
		}
	}
	PRINTD(Min(ans1, ans2));
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;

void merge (int *first1, int *last1, int *first2, int *last2){
    int size1 = last1 - first1;
    int size2 = last2 - first2;
    int *result = new int[size1+size2];
    int i = 0;
    int j = 0;
    int index = 0;
    while (true){
        if (i < size1 && (first1[i] <= first2[j] || j >= size2)){
            result[index] = first1[i];
            ++i; ++index;
        }
        if (j < size2 && (first1[i] > first2[j] || i >= size1)){
            result[index] = first2[j];
            ++j; ++index;
        }
        if (i==size1 && j==size2){
            for (i=0; i<size1; ++i) first1[i] = result[i];
            for (j=0; j<size2; ++j) first2[j] = result[j+size1];
            delete[] result;
            return;
        }
    }
}
void MergeSort (int *first, int *last){
    int size = last - first;
    if(size <= 1) return;
    MergeSort(first, first+size/2);
    MergeSort(first+size/2, last);
    merge(first, first+size/2, first+size/2, last);
}


int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

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

    string s="qwertasdfgzxcvb", m="yuiophjklnm",moji;

    while(1){
      cin >> moji;
      if(moji=="#") break;

      int a[moji.size()];
      int cnt = 0;
      int flag;
      REP(j, moji.size()){
        REP(i, 11){
          if(m[i] == moji[j]){
            flag = 1;
            break;
          }else flag = 0;
      }
      a[j] = flag;
      if(j != 0 && a[j-1] != a[j]) cnt++;
    }

      cout << cnt << endl;
    }
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> p(n),q(n),r(n);
    for(int i=0; i<n; i++) cin >> p[i];
    for(int i=0; i<n; i++) cin >> q[i];
    for(int i=0; i<n; i++){
        r[i] = i + 1;
    } 
    int a = 0;
    int b = 0;
    int i = 0;
    do{
        if(r == p) a = i;
        if(r == q) b = i;
        i++;        
    }while(next_permutation(r.begin(),r.end()));

    cout << max(a-b,b-a) << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

struct edge{
    ll to, w;
};

struct zapros{
    ll  u,v,w;
};

ll n,m;
vector<vector<edge>> g;
vector<ll> d;
vector<bool> used;


void dfs(ll v, ll ts){
    d[v] = ts;
    used[v] = true;
    for(int i = 0;i<g[v].size();++i){
        ll to = g[v][i].to;
        ll w = g[v][i].w;
        if(!used[to]){
            dfs(to, ts+w);
        }
    }
}


main(){
    cin >> n>> m;
    g.resize(n+10);
    used.assign(n+10,false);
    d.assign(n+10,0);
    vector<zapros> zap(m+10);
    ll f1,f2,f3;

    for(int i=0;i<m;++i){
        cin >> f1 >> f2 >> f3;
        g[f1].push_back({f2,f3});
        g[f2].push_back({f1,-f3});
        zap[i] = {f1,f2,f3};
    }

    for(int i=1;i<=n;++i){
        if(!used[i]){
            dfs(i, 0);
        }
    }

    bool ans = true;

    for(int i=0;i<m;++i){
        if(d[zap[i].v]-d[zap[i].u] != zap[i].w){
            ans = false;
        }
    }

    if(ans){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

}


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

int main() {

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

    int cnt = 1;

    while (n / k != 0) {
        n /= k;
        cnt++;
    }

    printf("%d", cnt);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using namespace std;
#define PI 3.14159265358979

int main()
{
    int n;
    cin >> n;
    map<int64_t, bool> check;
    rep(i, n)
    {
        int64_t a;
        cin >> a;
        if (check[a - 1] != true)
        {
            check[a - 1] = true;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

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

long long n, m = 0;
long long c[200000], y[200001];
const long long M = 1000000007;

int main()
{
    cin >> n;

    y[0] = 1;
    y[1] = 2;
    for (int i = 1; i < n; i++)
        y[i + 1] = y[i] * 2 % M;

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

    sort(c, c + n);

    if (n > 1) {
        for (int i = 0; i < n; i++)
            m = (m + (((n - i + 1) * y[n - 2] % M) * y[n] % M) * c[i]) % M;
    }
    else
        m = 2 * c[0] % M;
 
    cout << m << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
bool hav[60][60];
int n,k,z;
vector<int> v[50];
int main(){
	while(cin>>n&&n){
	for(int i=0;i<50;i++)v[i].clear();
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)hav[i][j]=0;
		hav[i][i]=1;
	}
	for(int i=0;i<n;i++){
		cin>>k;
		while(k--){
			cin>>z;
			v[z-1].push_back(i);
		}
	}
	int ans=-1;
	for(int d=0;d<30;d++){
		for(int i=0;i<v[d].size();i++){
			for(int j=i+1;j<v[d].size();j++){
				for(int r=0;r<n;r++){
					bool t=max(hav[v[d][i]][r],hav[v[d][j]][r]);
					hav[v[d][i]][r]=t,hav[v[d][j]][r]=t;
				}
			}
		}
		for(int i=0;i<n;i++){
			bool ok=true;
			for(int j=0;j<n;j++)if(!hav[i][j])ok=false;
			if(ok){
				ans=d+1;
				goto loop;
			}
		}
	}
	loop:
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define int long long
using namespace std;

int dp[105][100005];

signed main() {
	int n, m; cin >> n >> m;
	vector<int> w(n + 1), v(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++) {
		if (j < w[i]) dp[i][j] = dp[i - 1][j];
		else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
	}
	cout << dp[n][m] << '\n';
}


Measured memory_bytes: 81696
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int MOD;

int add(int a, int b)
{
	a+=b;
	a%=MOD;
	if(a<0) a+=MOD;
	return a;
}

int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}

int dp[311][311];
int suf[311][311];
int c[555][555];

int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0||b==a) return 1;
	if(c[a][b]!=-1) return c[a][b];
	return (c[a][b]=add(choose(a-1,b),choose(a-1,b-1)));
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k>>MOD; n++;
	memset(c,-1,sizeof(c));
	for(int i=0;i<=k;i++) 
	{
		dp[0][i]=dp[1][i]=1;
	}
	for(int i=0;i<2;i++)
	{
		for(int j=k;j>=0;j--)
		{
			suf[i][j]=add(dp[i][j],suf[i][j+1]);
		}
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			for(int sub1=1;sub1<=i-1;sub1++)
			{
				dp[i][j] = add(dp[i][j], mult(mult(choose(i-2,sub1-1),suf[sub1][j+1]), dp[i-sub1][j]));
			}
		}
		for(int j=k;j>=0;j--)
		{
			suf[i][j]=add(dp[i][j],suf[i][j+1]);
		}
	}
	cout<<dp[n][0]<<'\n';
}


Measured memory_bytes: 2176
#include <iostream>           
                              
using namespace std;          
                              
int main(void){               
  int A,B,count = 0;          
  cin >> A >> B;              
  for(int i = 0; i < 2;++i){  
    if(A >= B){               
      count += A;             
      A--;                    
    }else{                    
      count += B;             
      B--;                    
    }                         
  }                           
  cout << count << endl;      
  return 0;                   
}                             

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < N; i++) {
		cout << S[i] << T[i];
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    float n,m;
    cin>>n>>m;
    int a[100];
    float sum=0;
    int b=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]>=sum/4/m){
            b++;
        }
    }
    if(b>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import math
T = list(map(float,input().split()))
si = T[2]*(math.pi/180)

S = T[0]*T[1]*(math.sin(si))*(1/2)
L1 = math.sqrt(T[0]**2 + T[1]**2 - 2*T[0]*T[1]*math.cos(si))
L = T[0] + T[1] + L1

x = 2 * S *(1/T[0])
print(S)
print(L)
print(x)


Measured memory_bytes: 5692
N, K = map(int, input().split())
R = N - K
mod = 10 ** 9 + 7


def makeTableMod(N, mod=10 ** 9 + 7):
    fac = [1 for i in range(N)]
    finv = [1 for i in range(N)]
    inv = [1 for i in range(N)]
    for i in range(2, N):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv


fac, finv = makeTableMod(2001, mod)


def binomialCoefficient(N, r, mod=10 ** 9 + 7):
    if N < r:
        return 0
    else:
        return fac[N] * (finv[r] * finv[N - r] % mod) % mod


def solve(i):
    # (N-K+1, i) * (K-1, i-1)を計算すれば良い
    ans = binomialCoefficient(N-K+1, i) * binomialCoefficient(K-1, i-1) % mod
    return ans


for i in range(K):
    if i == 0:
        print((R+1) % mod)
    else:
        ans = solve(i+1)
        print(ans % mod)

Measured memory_bytes: 43376
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int n, y;

    while (cin >> n, n) {
        cin >> y;
        vector<pair<long double, int> > bank(n);
        for (int i = 0; i < n; i++) {
            int b, r, t;
            cin >> b >> r >> t;
            long double res = 0;
            if (t == 1) {
                res = 1 * (1 + y * (long double)r / 100.0);
            } else {
                res = pow(1 + (long double)r / 100.0, y);
            }

            bank[i] = make_pair(res, b);
        }
        sort(bank.begin(), bank.end());
        cout << bank[n - 1].second << endl;
    }
    
    return 0;
}

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

class DSU {
	private:
		int *data;
	public:
		DSU(int n) {
			data = new int[n];
			for(int i = 0; i < n; i++) {
				data[i] = -1;
			}
		}

		~DSU() {delete[] data;}

		int find(int i) {
			int parent;
			int back_to = -1;
			for(; (parent = data[i]) >= 0; i = parent) {
				data[i] = back_to;
				back_to = i;
			}
			int root = i;
			while(back_to != -1) {
				i = back_to;
				back_to = data[i];
				data[i] = root;
			}
			return root;
		}

		void merge(int i, int j) {
			int ri = find(i), rj = find(j);
			if (ri == rj)
				return;
			if (data[ri] > data[rj]) {
				int t = ri;
				ri = rj;
				rj = t;
			}
			data[ri] = data[ri] + data[rj];
			data[rj] = ri;
		}

		int get_size(int i) {
			return -data[find(i)];
		}
};
using namespace std;

int main() {
	int n, m, k;
	int excluded[100000] = {};
	cin >> n >> m >> k;
	DSU forest{n};
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		forest.merge(a, b);
		excluded[a]++;
		excluded[b]++;
	}
	for(int i = 0; i < k; i++) {
		int c, d;
		cin >> c >> d;
		c--; d--;
		if (forest.find(c) == forest.find(d)) {
			excluded[c]++;
			excluded[d]++;
		}
	}
	for(int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << forest.get_size(i) - 1 - excluded[i];
	}
	cout << endl;
}


Measured memory_bytes: 1664
N = int(input())
A_list = list(map(int, input().split()))
B_list = [0 for i in range(N)]
ans_list = ""

count = 0
for i in range(N-1, -1, -1):
    box_num = N // (i+1)
    sum_ball = 0
    for j in range(box_num):
        sum_ball += B_list[(j + 1) * (i + 1) - 1]
    if sum_ball % 2 != A_list[i]:
        B_list[i] = 1
        ans_list += str(i + 1) + " "
        count += 1

# print(A_list)
# print(B_list)

if count != 0:
    print(count)
    print(ans_list[:-1])
else:
    print(0)


Measured memory_bytes: 9912
fun main(args: Array<String>) {
    // Your code here!
    val n = readLine()!!.toInt()
    val list  = readLine()!!.split(" ").map{it.toInt()}
    var cnt = 0
    
    for(i in 1..n-2){
        var min = mutableListOf(list[i-1],list[i],list[i+1]).sorted()
        if(min[1] == list[i]){
            cnt += 1
        }
    }
    print(cnt)
}


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

int main(void) {
    int H,W;cin>>H>>W;
    char ch[H + 2][W + 2];
    for (int i = 0; i < H + 2; i++) {
        ch[i][0] = '.';
        ch[i][W + 1] = '.';
    }
    for (int j = 0; j < W + 2; j++) {
        ch[0][j] = '.';
        ch[H + 1][j] = '.';
    }
    for (int i = 1; i <= H; i++) {
        string S;cin>>S;
        for (int j = 1; j <= W; j++) ch[i][j] = S[j - 1];
    }
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            char c = ch[i][j];
            if (c == '#') {
                if (ch[i - 1][j] == '.' && ch[i + 1][j] == '.' && ch[i][j - 1] == '.' && ch[i][j + 1] == '.') {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  	int r;
  	cin >> r;
  	int ret = 3 * r * r;
  	cout << ret << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


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

namespace ABC066A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, c, s;

				string[] ward=Console.ReadLine().Split(' ');

			a = int.Parse(ward[0]);
			b = int.Parse(ward[1]);
			c = int.Parse(ward[2]);

            //a,b,c,の最大値を求める

			int m = a;
			if (b > m) m = b;
			if (c > m) m = c;

			//最大値を除く金額の和
			s = a + b + c - m;


			Console.WriteLine(s);

			//Console.ReadKey();
		}
	}
}


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

const int N=200100,mod=1000000007,inv_2=(mod+1)/2;
typedef long long ll;
int ksm(ll a,int b,int c=1){
	for(;b;b/=2,a=a*a%mod)
		if(b&1)c=c*a%mod;
	return c;
}
int n,fa[N],tag[N];
vector<int>g[N],f[N];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>fa[i];
	for(int i=n;i;--i){
		f[i].push_back(inv_2);g[i].push_back(inv_2);tag[i]=f[i].size();
		int u=fa[i];
		if(f[u].size()<f[i].size()){
			swap(f[u],f[i]);
			swap(g[u],g[i]);
			swap(tag[u],tag[i]);
		}
		for(int j=0;j<tag[i];++j)f[i][j]=(mod+1-g[i][j])%mod;
		for(int j=0;j<(int)f[i].size();++j){
			int nj=f[i].size()-1-j,nk=f[u].size()-1-j;
			if(nk<tag[u])--tag[u],f[u][nk]=(mod+1-g[u][nk])%mod;
			g[u][nk]=((ll)g[u][nk]*f[i][nj]+(ll)f[u][nk]*g[i][nj])%mod,
			f[u][nk]=(ll)f[u][nk]*f[i][nj]%mod;
		}
	}
	int ans=inv_2;
	for(int i:g[0])ans=(ans+i)%mod;
	cout<<(ans=ksm(2,n+1,ans))<<'\n';
	return 0;
}


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

using namespace std;
using ll = long long;

ll A, B, N;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N>>A>>B;
    cout<<N/(A+B)*A + min(A, N%(A+B));
    return 0;
}

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

int main()
{
    int a[3][3],c[3][3],k;

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

    int n;
    cin>>n;

    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
            c[i][j]=0;
    }
    for(int i=0;i<n;i++)
    {
        cin>>k;
        int flag=1;

        for(int p=0;p<3;p++)
        {
            for(int m=0;m<3;m++)
            {
                if(a[p][m]==k)
                {
                    c[p][m]=1;
                    flag=0;
                    break;
                }
            }
            if(flag==0)
                break;

        }
    }
    int i;
    for(i=0;i<3;i++)
    {  int j;
        for( j=0;j<3;j++)
        {
            if(c[i][j]==0)
            break;
        }
        if(j==3)
            break;
    }
    if(i!=3)
        cout<<"Yes\n";
    else
    {
        int q,l;
        for(q=0;q<3;q++)
        {
            for(l=0;l<3;l++)
            {
                if(c[l][q]==0)
                    break;
            }
            if(l==3)
                break;
        }
        if(q!=3)
        cout<<"Yes\n";
        else
        {
            if(c[0][0]==1&&c[1][1]==1&&c[2][2]==1)
                 cout<<"Yes\n";
            else if(c[0][2]==1&&c[1][1]==1&&c[2][0]==1)
                cout<<"Yes\n";
            else
                cout<<"No\n";
        }
    }


    return 0;
}


Measured memory_bytes: 256
n = int(input())
num = list(map(int, input().split()))

q = int(input())
for i in range(q):
    query = list(map(int, input().split()))
    flag = query[0]
    start = query[1]
    end = query[2]

    if flag == 0:
        print(min(num[start:end]))
    elif flag == 1:
        print(max(num[start:end]))


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin>>a;
  int ans=700;
 if(a[0] == 'o') ans += 100;
 if(a[1] == 'o') ans += 100;
 if(a[2] == 'o') ans += 100;

  cout<<ans<<endl;
  
}


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

// bool check( string s, string t)
// {
// 	for(int i =0; i < s.size(); i++ )
// 		if(s[i] != t[i])
// 			return false;
// 	return true;
// }

int main()
{
	// int T;
	// cin>>T;
	// while(T--)
	// 	cout<<T<<endl;
	// return 0;
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if( k <= a )
		cout<<k;
	else if( k <= (a+b) )
		cout<<a;
	else
		cout<<(a-(k-a-b));

}

Measured memory_bytes: 3624
# include <bits/stdc++.h>
using namespace std ;
 
int main() {
  int N, M, C; cin >> N >> M >> C;
  //cout << N << M << C << endl;
  vector<int> B(M);
  vector<vector<int>> A(N, vector<int>(M));
  int temp;
  int count = 0;
  for (int i = 0; i < M; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < N; i++) {
    temp = 0;
    for (int j = 0; j < M; j++){
      cin >> A.at(i).at(j);
      //cout << A.at(i).at(j) << endl;
      temp += A.at(i).at(j) * B.at(j);

    }
    if (temp + C > 0) {
      count++;
    } 
  }
  cout << count << endl;
}

Measured memory_bytes: 256
from itertools import product

Q = int(input())
mxs = [tuple(map(int, input().split())) for _ in range(Q)]

p1s = [2,3,5,7,11,13,17]
nums = [9,6,4,3,3,3,3]
rangeNums = [range(num) for num in nums]
p2s = [19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293]

mx1s = []
mx2ss = [[] for _ in range(len(p2s))]
for m, x in mxs:
    for i, p2 in enumerate(p2s):
        if m % p2 == 0:
            mx2ss[i].append((m, x))
            break
    else:
        mx1s.append((m, x))

ans = 0
for es in product(*rangeNums):
    f = 1
    for p1, e in zip(p1s, es):
        f *= p1**e

    A = 0
    for m1, x1 in mx1s:
        if f % m1 == 0:
            A += x1

    for p2, mx2s in zip(p2s, mx2ss):
        A2 = 0
        for m2, x2 in mx2s:
            if f*p2 % m2 == 0:
                A2 += x2
        if A2 > 0:
            A += A2

    ans = max(ans, A)

print(ans)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

// 乱数
unsigned int xor32() {
  static unsigned int x = 2463534242;
  x = x ^ (x << 13); x = x ^ (x >> 17);
  return x = x ^ (x << 15);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  time_t start=clock();
  int D, c[30], s[400][30];
  cin>>D;
  REP(i, 26){
    cin>>c[i];
  }
  REP(i, D){
    REP(j, 26){
      cin>>s[i][j];
    }
  }
  REP(i, D){
    cout<<1<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3704
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()

m=0
a=0
r=0
c=0
h=0

for i in range(n):
    s=ss()
    if s[0]=="M":m+=1
    elif s[0]=="A":a+=1
    elif s[0]=="R":r+=1
    elif s[0]=="C":c+=1
    elif s[0]=="H":h+=1
mat=[m,a,r,c,h]
#print(mat)
arr=list(combinations([0,1,2,3,4],3))
ans=0
for i in arr:
    if mat[i[0]]>0 and mat[i[1]]>0 and mat[i[2]]>0:
        ans+=mat[i[0]]*mat[i[1]]*mat[i[2]]
print(ans)












Measured memory_bytes: 67048
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

const int N = 2e5+5;
ll a[N];
int main(){
    ios::sync_with_stdio(0);
    int n;cin>>n;
    rep(i,1,n){
        cin>>a[i];
    }
    ll sum = 0;
    rep(i,2,n){
        if(a[i-1]>a[i]){
            sum+= a[i-1]-a[i];
            a[i] = a[i-1];
        }
       
    }
    cout<<sum;
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	char last = -1;
	int ans = 0, len = s.size();
	for(int i = 0; i < len; ){
		if(i == len - 1){
			if(s[i] != last)
				ans++;
			i++;
			continue;
		}
		if(s[i] == last){
			last = -1;
			i += 2;
			ans++;
		} else {
			last = s[i];
			i++;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

class MyClass
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine((input[0] + input[1]) / 2);
    }
}


Measured memory_bytes: 18444
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"--------------------------"<<endl; 
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll x;
    cin>>x;
    cout<<x+x*x+x*x*x<<endl;
    return 0;
}

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

int main() {
  int N,n;
  cin >> N;
  n = N;
  int sum = 0;
  int i = 0;
  
  while (n > 0) {
    sum += (n % 10);
    n = (n - (n % 10)) / 10;
    i++;
  }
  
  if (N % sum == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
    

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

int main()
{
    int n;
    cin>>n;
    int o = n%10;
    if(o == 2 || o ==  4 || o == 5 || o == 7 || o == 9)
    {
        cout<<"hon"<<endl;
    }
    else if(o ==  0 || o == 1 || o == 6 || o == 8)
    {
        cout<<"pon"<<endl;
    }
    else
    {
        cout<<"bon"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)

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

    int n, k;
    cin >> n >> k;
    vector<ll> a(n),s, copy;
    rep(i, n) cin >> a[i];

    rep(i, n)
    {
        ll x = 0;
        forx(j, i, n)
        {
            x += a[j];
            s.push_back(x);
        }
    }

    int y = s.size();
    ll t = 1, ans = 0;
    rep(i, 40) t *= 2;

    rep(i, 41)
    {
        sort(s.begin(), s.end());
        reverse(s.begin(), s.end());
        int last = 0, c = 0;

        rep(j, y) if (s[j] >= t)
        {
            last = j + 1;
            c++;
            s[j] -= t;
        }

        if (c >= k)
        {
            ans += t;
            y = last;
        }
        else
            last = y;

        rep(j, last) copy.push_back(s[j]);
        
        s = copy;
        copy.clear();

        t /= 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12140