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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

lnt powmod(lnt a, lnt p, lnt m){
	lnt res = 1, tmp = a;
	while(p != 0){
		if(p % 2) res = (res*tmp) % m;
		tmp = (tmp*tmp) % m;
		p /= 2;
	}
	return res;
}

int main(){
	summon_tourist;

	lnt N, K; cin >> N >> K;
	lnt ans = 0, cnt[100010] = {};
	for(lnt g = K; g >= 1; g--){
		cnt[g] = powmod(K/g, N, MOD);
		for(lnt num = g*2; num <= K; num += g){
			cnt[g] -= cnt[num];
			if(cnt[g] < 0) cnt[g] += MOD;
		}
		ans += g*cnt[g]%MOD;
		ans %= MOD;
	}
	cout << ans << ln;
}


Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
long double prob[3005], dp[3005][3005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> prob[i];
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		dp[0][i] = dp[0][i - 1] * (1 - prob[i]);
		dp[i][0] = dp[i - 1][0] * prob[i];
		for (int j = 1; j < i; ++j) {
			dp[j][i - j] = dp[j - 1][i - j] * prob[i] + dp[j][i - j - 1] * (1 - prob[i]);
		}
	}
	long double ans = 0;
	for (int i = n; n - i < i; --i)
		ans += dp[i][n - i];
	cout << fixed << setprecision(10) << ans << '\n';
	return 0;
}

Measured memory_bytes: 139776
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

int main(){
    int n;cin>>n;
    int p;cin>>p;
    if(p==1)cout<<0<<endl;
else if(n-p>0)cout<<n-p<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int bb(int a,int s){
  int y=max(a,s);
  int x=min(a,s);
  if(y%x==0){
    return x;
  }
  int z=y%x;
  return bb(x,z);
}
int main(){
  int a,s;
  cin>>a>>s;
  cout<<bb(a,s)<<endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 1e6;
int main(){
    int *arr;
    arr = new int [MAX];
    fill(arr , arr + MAX , 0);
    for (int i = 1 ; i <= 100 ; i++){
        for (int j = 1 ; j <= 100 ; j++){
            for (int k = 1 ; k <= 100 ; k++){
                ++arr[i * i + j * j + k * k + i * j + i * k + k * j];
            }
        }
    }
    int N;
    cin >> N;
    for (int i = 1 ; i <= N ; i++)
        cout << arr[i] << endl;
}


Measured memory_bytes: 7452
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=200000+10;

int n,fa[N],vis[N],inc[N],f[N],o[N];
vector<int> E[N];

void dfs(int u) {
	for (int v:E[u]) if (!inc[v]) dfs(v);
	for (int v:E[u]) if (!inc[v]) o[f[v]]=1;
	while (o[f[u]]) ++f[u];
	for (int v:E[u]) if (!inc[v]) o[f[v]]=0;
}

int main() {
	n=read();
	for (int i=1;i<=n;++i)
		E[fa[i]=read()].emplace_back(i);
	int x=1;
	for (;!vis[x];x=fa[x]) vis[x]=1;
	for (;!inc[x];x=fa[x]) inc[x]=1;
	int cnt=0,mn=1e9,mx=-1e9;
	for (int i=1;i<=n;++i)
		if (inc[i]) dfs(i),mn=min(mn,f[i]),mx=max(mx,f[i]),++cnt;
	if (mn==mx&&(cnt&1)) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 16520
#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#define M_PI 3.14159265358979323846

main() {
	double r;

	scanf("%lf", &r);
	printf("%lf %lf", M_PI*r*r, 2*M_PI*r);

	return 0;
}


Measured memory_bytes: 2104
s=input()
L=len(s)
ans=""
for i in range(0,L):
    if s[i]=="0":
        ans+="0"
    elif s[i]=="1":
        ans+="1"
    elif s[i]=="B":
        if ans=="":
            pass
        else:
            ans=ans[:-1]
print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int numm=scan.nextInt();
int[] num=new int[numm];
int[][] que=new int[numm][numm];
int[][] ans=new int[numm][numm];

int i=0;
int j=0;
for(i=0;i<numm;i++){
    num[i]=scan.nextInt();
    for(j=0;j<num[i];j++){
        que[i][j]=scan.nextInt()-1;
        ans[i][j]=scan.nextInt();
    }
}

int[] tur=new int[15];
int[] a=new int[32768];
int[] l=new int[32768];
int[] sum=new int[32768];
int max=0;

goback:
for(int k=0;k<32768;k++){
    tur[0]=k%2;
    tur[1]=k/2%2;
    tur[2]=k/4%2;
    tur[3]=k/8%2;
    tur[4]=k/16%2;
    tur[5]=k/32%2;
    tur[6]=k/64%2;
    tur[7]=k/128%2;
    tur[8]=k/256%2;
    tur[9]=k/512%2;
    tur[10]=k/1024%2;
    tur[11]=k/2048%2;
    tur[12]=k/4096%2;
    tur[13]=k/8192%2;
    tur[14]=k/16384%2;

    for(a[k]=0;a[k]<numm;a[k]++){
        for(l[k]=0;l[k]<(num[a[k]]);l[k]++){
            if(tur[a[k]]==1&&!(tur[que[a[k]][l[k]]]==ans[a[k]][l[k]])){
            continue goback;
            }
        }
    }

    for(a[k]=0;a[k]<numm;a[k]++){
        if(tur[a[k]]==1){
            sum[k]=sum[k]+1;
        }
    }

    if(max<sum[k]){
        max=sum[k];
    }

}

System.out.println(max);

}
}

Measured memory_bytes: 24932
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int v[100],w[100] ;
int dp[100][100005] ;
int f(int i,int value)
{
    if(value < 0 ) return 1000000000 ;
    if(value == 0) return 0;
    if(i<0) return 1000000000 ;
    if( dp[i][value] != -1 ) return dp[i][value] ;
    return dp[i][value] = min( f(i-1,value) , f(i-1,value-v[i])+w[i] );
}



signed main()
{
    int N,W;
    cin >> N >> W ;
    int sum = 0 ;
    for(int i=0;i<N;i++)
    {
        cin >> w[i] >> v[i] ;
        sum += v[i] ;
    }
    for(int i=0;i<N;i++)
    for(int j=0;j<=sum;j++)
    dp[i][j] = -1 ;
    int ans = 0 ;
    for(int val = 1 ; val <= sum ; val++)
    {
        if( f(N-1,val) <= W ){
            ans = val ;
        }
    }
    cout << ans ;
    
    

    return 0;
}


Measured memory_bytes: 78336
import Data.Bool

main = do
 [n,a,b,c,d] <- map read . words <$> getLine :: IO [Int]
 putStrLn $ bool "NO" "YES" $ moderate n a b c d

moderate n a b c d = any (within b) [(a + i*d + j*c, a + i*c + j*d) | i<-[-(n-1)..0], let j = (n-1) - abs i]

within x (a,b) = a <= x && x <= b

Measured memory_bytes: 1020
n=int(input())
a=0
b=0
end=0
for i in range(9):
    for j in range(9):
        if n==(i+1)*(j+1):
            print("Yes")
            end+=1
            break
        elif i==8 and j==8:
            print("No")
        else:
            pass
    if end==1:
        break

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

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

  ll l, r; cin >> l >> r;
  int ans = 1e9;
  for(ll i = l; i < min(r, l+2019); ++i) {
    for(ll j = r; max(i, r-2019) < j; --j) {
      int i_mod = i%2019;
      int j_mod = j%2019;
      ans = min(ans, i_mod*j_mod%2019);
    }
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
   int n,k;
	cin >>n >>k;
	if(n%2==0){
	     if(k<=n/2)cout << "YES" << endl;
		 else {
		 	cout << "NO" << endl;
		 }
    }  
    if(n%2==1){
         if(k<=(n+1)/2) cout << "YES" << endl;
         else {
              cout << "NO" << endl;
		 }	  
	}
 
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int s;
	cin >> s;

	set<int> se;
	se.emplace(s);

	int ans = 0, now = s;
	for (int i = 2;; i++) {
		int oldSeSize = se.size();
		now = now & 1 ? 3 * now + 1 : now / 2;
		se.emplace(now);

		if (se.size() == oldSeSize) {
			ans = i;
			break;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int a[1000010];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0;i < n;i++)
		scanf("%d", &a[i]);
	sort(a, a+n);
	int m = unique(a, a + n) - a;
	printf(n==m ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
  string str;
  cin >> str;
  int n=0,s=0,w=0,e=0;
  for(int i=0;i<str.length();i++){
    if(str[i]=='N'){
      n=1;
    }
    if(str[i]=='S')
      s=-1;
    if(str[i]=='W')
      w=1;
    if(str[i]=='E')
      e=-1;
  }
  if((n+s==0) && (w+e==0)){
    cout <<"Yes"<<endl;
  }
  else
    cout <<"No"<<endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int n, m, i, j, nr, nr1, nr2, sol;
char s[15];
int main(){
    cin>> n;
    for(i = 1; i <= n; i++){
        cin>> s + 1;
        m = strlen(s + 1);
        for(j = 2; j <= m; j++){
            if(s[j] == 'B' && s[j - 1] == 'A'){
                sol++;
            }
        }
        if(s[1] == 'B' && s[m] == 'A'){
            nr++;
        }
        else{
            if(s[1] == 'B'){
                nr1++;
            }
            else{
                if(s[m] == 'A'){
                    nr2++;
                }
            }
        }
    }
    if(min(nr1, nr2) == 0){
        sol += max(nr - 1, 0);
        if(nr1 != 0 || nr2 != 0){
            if(nr != 0){
                sol++;
            }
        }
    }
    else{
        sol += nr + min(nr1, nr2);
    }
    cout<< sol;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  ll N,M,K;
  cin >> N >> M >> K;
  FOR(i,0,N+1)FOR(j,0,M+1){
    if(i*(M-j)+j*(N-i) == K){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <math.h>
//#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int a;
    int b;
    int t;
    int ans=0;

    cin >> a >> b >> t;
    for(int i=a; i<=t; i=i+a){
        ans += b;
    }
    cout << ans << endl;
}


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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    ll n,d,a,x,h;
    cin >> n >> d >> a;

    vector<pair<ll, ll>> v;

    rep(i, n){
        cin >> x >> h;
        v.pback(mpair(x, h));
    }

    sort(ALL(v));

    vector<pair<ll,ll>> v2(1, mpair(-1, 0)); //vを座標圧縮したものx座標が隣でないなら、間に1つ区切りをいれるようにする

    v2.pback(v[0]);

    ll oldx = v[0].first;
    ll oldh = v[0].second;

    rep(i, n - 1){

        if(v[i + 1].first - oldx == 1){
            v2.pback(v[i + 1]);
        }else{
            v2.pback(mpair(v2[v2.size() - 1].first + 1, 0));
            v2.pback(v[i + 1]);
        }

        oldx = v[i + 1].first;
        oldh = v[i + 1].second;
    }

    v2.pback(mpair(v2[v2.size() - 1].first + 1, 0));

    int v2size = v2.size();

    vector<ll> imos(v2size); //爆弾の範囲攻撃のダメージをimos法で管理

    ll ans = 0;

    for(int i = 1; i < v2size - 1; i++){

        imos[i] = imos[i] + imos[i - 1];

        assert(imos[i] >= 0);

        ll tmpx = v2[i].first;
        ll tmph = v2[i].second - imos[i];

        if(tmph > 0){

            ll bombcount = (tmph + (a - 1)) / a;
            ll right = tmpx + (2 * d) + 1; //爆発範囲の上限ではなくそれより+1したもの

            auto itr = lower_bound(ALL(v2), mpair(right, LLONG_MIN));
            int index = min((int)(itr - v2.begin()), v2size - 1);

            imos[i] += bombcount * a;
            imos.at(index) -= bombcount * a;

            /*
            cerr << "bomb " <<  tmpx << " "  << right << " " << bombcount << endl;
            cerr << itr - v2.begin() << endl;
            cerr << "right index " << index << endl;
            */

            ans += bombcount;

        }

    }

    /*
    rep(i, v2size){
        cerr << v2[i].first << " " << v2[i].second << endl;
    }
    */
    


    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15208
N, M = map(int, input().split())
L = []
for _ in range(M):
  k, *S = map(int, input().split())
  L.append(S)
P = list(map(int, input().split()))
c = 0
for i in range(2**N):
  A = []
  for j in range(N):
    if (i>>j)&1:
      A.append(j+1)
  A = set(A)
  for i in range(M):
    if len(A&set(L[i]))%2!=P[i]:
      break
  else:
    c += 1
print(c)

Measured memory_bytes: 9208
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll x,y,z;
    cin >> x >> y >>z;
    x -= z;
    cout << x/(y+z) << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())


def gcd(p, q):
	if p % q == 0:
		return q
	else:
		return gcd(q, p % q)

def cnt(A, B, K):
    a = (A // K + (A % K != 0)) * K
    b = (B // K) * K
    if a > b:
        return 0
    else:
        return (b - a) // K + 1


lcm = c * d // gcd(c, d)
res1 = cnt(a, b, c)
res2 = cnt(a, b, d)
res3 = cnt(a, b, lcm)
print(b - a + 1 - res1 -res2 + res3)

Measured memory_bytes: 3064
#include<stdio.h>
	   const int MAX_V = 1000000;
	   int prime[MAX_V+1];
	   int main(){
	   	int i,k,v,m=2;
	   	for(i=m;i<=MAX_V;i++){
	   		prime[i]=1;
	   	}
	   	for(i=m;i*i<=MAX_V;i++){
	   		if(prime[i]){
	   			for(k=2*i;k<=MAX_V;k+=i){
	   				prime[k]=0;
	   			}
	   		}
	   	}
	   	while(scanf("%d",&v)!=EOF){
	   		if(v==0)break;
	   		for(i=v;i>=m;i--){
	   			if(prime[i]==1 && prime[i-2]==1){
	   				printf("%d %d\n",i-2,i);
	   				break;
	   			}
	  	   	}
	  	}
	   	return 0;
	  }

Measured memory_bytes: 6532
#include <bits/stdc++.h>
#define itn int
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
typedef long long ll;

int main() {
  int a,b;
  cin >> a >> b;
  if(a>12){
    cout << b << endl;
  }
  else if(a>5){
    cout<< b/2 << endl;
  }
  else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

int main()
{
    ll i,j,k,n,a[200005];
    cin>>n;
    rep(i,0,n-1)cin>>a[i];
    k=0;j=0;
    rep(i,0,n-2)
    {
        if(a[i]>=a[i+1])
        {
            j++;
        }
        else
        {
            k=max(k,j);
            j=0;
        }
    }k=max(k,j);
    cout<<k;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = scan.nextInt();
		}
		
		Arrays.sort(list);
		int total = 0;
		for(int i = 0; i<k; i++) {
			total += list[i];
		}
		System.out.print(total);
	}

}


Measured memory_bytes: 38764
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    
    sum /= 2;
    for (int i = 1; i < N; i += 2) sum -= A[i];
    cout << sum * 2 << " ";
    for (int i = 0; i < N - 1; i++) {
        sum = A[i] - sum;
        cout << sum * 2;
        if (i != N - 2) cout << " ";
    }
    cout << endl;
}

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

int main() {
  int n;
  cin >> n;
  ll a[90];
  a[0] = 2;
  a[1] = 1;
  for (int i = 2; i <= n + 2; i++) a[i] = a[i - 1] + a[i - 2];
  cout << a[n] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>


void intersectionSort(int A[], int n) 
{ 
    //move postion 
	int i, key, j; 
	for (i = 1; i < n; i++) { 
		key = A[i]; 
		j = i - 1; 

    
		while (j >= 0 && A[j] > key) { 
			A[j + 1] = A[j]; 
			j = j - 1; 
            
		A[j + 1] = key;  
        
	}
     for (j = 0; j < n; j++)
     {
          if (j==n-1)
     {
         printf("%d\n", A[j]);
        
     }

      else {printf("%d ", A[j]);}
     }
    
    
       
} 
}
    int main()
    {
        //size
        int n=0;
        //printf("enter the number of elements in the sequence: \n");
        scanf("%d", &n);
       
        if (n>100 || n<1)
        {
            //printf("range should be between 1 to 100");
            return 1;
        }
        //printf("enter the elemetns of sequence by space: \n");
       
      
//scan array 
 int A[100];
 
 for (int i = 0; i < n; i++) {
  scanf("%d", &A[i]);
 }
        
	 for (int j = 0; j < n; j++) {
  if (j == n- 1)printf("%d\n", A[j]);
  else printf("%d ", A[j]);
 }
     
     
        intersectionSort(A,n);
        
     
        return 0;
    }
    




Measured memory_bytes: 2036
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>
typedef long long int ll;


using namespace std;

int main(){
	while(1){
		int n;
		ll sum=0;
		if( !(cin>>n) )break;
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				for(int k=0;k<=9;k++){
					for(int l=0;l<=9;l++){
						if( i+j+k+l==n )sum++;
					}
				}
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_HW = 55;
char s[MAX_HW][MAX_HW];
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};

int main()
{
	int H,W;
	cin >> H >> W;
	rep(i,H)
	{
		rep(j,W)
		{
			cin >> s[i][j];
		}
	}

	rep(i,H)
	{
		rep(j,W)
		{
			if (s[i][j] == '.') continue;
			bool flag = false;
			rep(k,4)
			{
				int ii = i + dx[k], jj = j + dy[k];
				if (ii >= 0 && ii < H && jj >= 0 && jj < W && s[ii][jj] == '#') flag = true;
			}
			if (!flag)
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
   
int main()
{
	int s,k,m,n;
	char str[201];
	while (1) {
		cin >> str;
		if (str[0]=='-') break;
		n=0;
		while(str[n++]);
		n -= 1;
		cin >> s;
		m=0;
		for (int i=0; i<s; i++) {
			cin >> k;
			m += k;
		}	
		k = m % n;		

		for (int i=k; i<n; i++)
			cout << str[i];
		for (int i=0; i<k; i++)
			cout << str[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    double n, k;
    cin >> n >> k;
    double ans = 0.0;
    for ( int i = 1; i <= n; ++i ) {
        double prob = (double)1 / n;
        int point = i;
        while(1) {
            if ( point >= k ) break;
            prob /= 2;
            point *= 2;
        }
        ans += prob;
    }
    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=1e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}/*
struct Edge{
	int nxt,v;
//	int w;
//	int id;
}e[N<<1];
void add(int u,int v){
	e[++tot].v=v,e[tot].nxt=head[u],head[u]=tot;
	e[++tot].v=u,e[tot].nxt=head[v],head[v]=tot;
}*/

int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	ll n=read(),x=read(),t=read();
	cout<<(ll)(ceil((double)n/x))*t;
	return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>

template<typename T>
void print_ary(std::vector<T> ary, char delim = '\n') {
    for(int i = 0; i < ary.size()-1; i++) {
        std::cout << ary[i] << delim;
    }
    std::cout << ary[ary.size()-1];
}


template<typename T>
void insertion_sort(std::vector<T>&& ary) {
    for (int i = 1; i < ary.size(); i++) {
        int target = ary[i];
        int j = i - 1;
        while(j >= 0 &&  ary[j] > target) {
            ary[j+1] = ary[j];
            j--;
        }
        ary[j+1] = target;
        print_ary(ary, ' ');
        std::cout << std::endl;
    }
}

template<typename T>
void bubble_sort(std::vector<T> && ary) {
    int n = ary.size();
    bool flag = true;
    int counter = 0;
    while (flag) {
        flag = false;
        for (int j = n - 1; j > 0; j--) {
            if (ary[j] < ary[j - 1]) {
                std::swap(ary[j], ary[j - 1]);
                flag = true;
                counter++;
            }
        }
    }
    print_ary(ary, ' ');
    std::cout << std::endl << counter << std::endl;;
}

template<typename T>
void selection_sort(std::vector<T>&& ary){
    int counter = 0;
    for (int i = 0; i < ary.size(); i++) {
        int min_index = i;
        for(int j = i + 1; j < ary.size(); j++) {
            if (ary[min_index] > ary[j]) {
                min_index = j;
            }
        }
        if(i != min_index) {
            std::swap(ary[i], ary[min_index]);
            counter++;
        }
    }
    print_ary(ary, ' ');
    std::cout << std::endl << counter << std::endl;;
}

template<typename T>
void insertion_sort(std::vector<T>&& ary, int g, int& cnt) {
    int n = ary.size();
    for (int i = g; i < n; i++) {
        int target = ary[i];
        int j = i - g;
        while(j >= 0 && ary[j] > target) {
            ary[j + g] = ary[j];
            cnt++;
            j -= g;
        }
        ary[j + g] = target;
    }
}

template<typename T>
void shell_sort(std::vector<T>&& ary){
    int cnt = 0;
    std::vector<int> G;
    for(int h = 1; ; ){
        if(h > ary.size())
            break;
        G.push_back(h);
        h = 3 * h + 1;
    }
    std::cout << G.size() << std::endl;
    for(int i = G.size() - 1; i >= 0; i--) {
        insertion_sort(std::move(ary), G[i], cnt);
        std::cout << G[i];
        if (i != 0) {
            std::cout << " ";
        }else{
            std::cout << std::endl;
        }
    }
    std::cout << cnt << std::endl;
    print_ary(ary);
}


int main(int argc, char const* argv[])
{
    int n;
    std::cin >> n;
    std::vector<int> ary(n);
    for (auto &i: ary) {
        std::cin >> i;
    }
    shell_sort(std::move(ary));
    return 0;
}

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

int main() {
  int mx=0, ans=0;
  int n;
  cin >> n;
  for(int i=0; i<n; i++) {
    int a; cin>>a;
    if(a>=mx) {
      ans++;
      mx=a;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a_b=[list(map(int,input().split())) for _ in range(n)]
c_d=[list(map(int,input().split())) for _ in range(m)]
for i in range(n):
  res=1
  d=abs(a_b[i][0]-c_d[0][0])+abs(a_b[i][1]-c_d[0][1])
  for j in range(1,m):
    t=abs(a_b[i][0]-c_d[j][0])+abs(a_b[i][1]-c_d[j][1])
    if t<d:
      d=t
      res=j+1
  print(res)
  


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    int cnt[31] = {0, };
    int n, m; cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int k; cin >> k;
        while (k--) {
            int tmp; cin >> tmp;
            cnt[tmp]++;
        }
    }
    
    int total = 0;
    for (int i = 1; i <= m; i++) {
        if (cnt[i] == n) total++;
    }
    
    cout << total << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  int q;
  cin >> q;
  while(q--) {
    int b, m, e;
    cin >> b >> m >> e;
    rotate(a.begin()+b, a.begin()+m, a.begin()+e);
  }
  for(int i = 0; i < n; ++i) cout << a[i] << " \n"[i==n-1];

  return 0;
}



Measured memory_bytes: 3148
N = int(input())
ans = 0
i = 1
while i <= N:
    if i < 10:
        ans += 1
    elif i < 100:
        if i % 10 == 0:
            pass
        elif i // 10 == i % 10:
            ans += 3
        elif i // 10 > i % 10:
            ans += 2
        else:
            pass
    elif i < 1000:
        if i % 10 == 0:
            pass
        elif i // 100 == i % 10:
            ans = ans + ((i % 100)//10)*2 + 5
        elif i // 100 > i % 10:
            ans += 22
        else:
            ans += 2
    elif i < 10000:
        if i % 10 == 0:
            pass
        elif i // 1000 == i % 10:
            ans = ans + ((i % 1000)//10)*2 + 25
        elif i // 1000 > i % 10:
            ans += 222
        else:
            ans += 22
    elif i < 100000:
        if i % 10 == 0:
            pass
        elif i // 10000 == i % 10:
            ans = ans + ((i % 10000)//10)*2 + 225
        elif i // 10000 > i % 10:
            ans += 2222
        else:
            ans += 222
    else:
        if i % 10 == 0:
            pass
        elif i // 100000 == i % 10:
            ans = ans + ((i % 100000)//10)*2 + 2225
        elif i // 100000 > i % 10:
            ans += 22222
        else:
            ans += 2222
    i +=1

print(ans)


Measured memory_bytes: 3064
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

multiset<int> s;
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;	cin >> n;
	for(int i = 1; i <= n; i++){
		int p; cin >> p;
		auto it = s.lower_bound(p);
		if(it == s.begin())
			s.insert(p);
		else{
			it--;
			s.erase(it);
			s.insert(p);
		}
	}
	cout << s.size();
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int>c(n),v(n);
  rep(i,n)cin>>v[i];
  rep(i,n)cin>>c[i];
  int res=0;
  rep(i,n)res+=max(0,v[i]-c[i]);
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  ll long long int
#define loop(i,n) for(int i =0 ;i<n;i+=1)
#define loop2(i,n) for(int i = 1;i<=n;i+=1)
//Till the end of the contest
//I'm standing up, I'ma face my demons
//I'm manning up, I'ma hold my ground
//I've had enough, now I'm so fed up
//Time to put my life back together right now!


ll n;
ll arr[(ll)1e5+100];
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
    
    cin>>n;
    loop(i,n)
    {
        cin>>arr[i];
    }
    //change first number to pos,neg,same as it is
    ll curr = 0 ;
    ll ans1 = 0 ;
    loop(i,n)
    {
        ll prev = curr;
        curr+=arr[i];
        if(i==0)
        {
            if(curr==0)
            {
                curr+=1;
                ans1+=1;
                continue;
            }
            else{
                curr = 1;
                ans1+=abs(arr[i])+1;
                continue;
            }
        }
        if(prev<0&&curr<=0)
        {
            ans1+=(abs(curr)+1);
            curr = 1;
        }
        else if(prev>0&&curr>=0)
        {
            ans1+=(abs(curr)+1);
            curr = -1;
        }
    }
    
    curr = 0 ;
    ll ans2 = 0;
    loop(i,n)
    {
        ll prev = curr;
        curr+=arr[i];
        if(i==0)
        {
            if(curr==0)
            {
                curr-=1;
                ans2+=1;
                continue;
            }
            else{
                curr = -1;
                ans2+=(abs(arr[i])+1);
                continue;
            }
        }
        if(prev<0&&curr<=0)
        {
            ans2+=(abs(curr)+1);
            curr = 1;
        }
        else if(prev>0&&curr>=0)
        {
            ans2+=(abs(curr)+1);
            curr = -1;
        }
    }
    curr = 0 ;
    ll ans3 = 0;
    loop(i,n)
    {
        ll prev = curr;
        curr+=arr[i];
        if(i==0)
        {
            if(curr==0)
            {
                curr-=1;
                ans3+=1;
                continue;
            }
            else{
                continue;
            }
        }
        if(prev<0&&curr<=0)
        {
            ans3+=(abs(curr)+1);
            curr = 1;
        }
        else if(prev>0&&curr>=0)
        {
            ans3+=(abs(curr)+1);
            curr = -1;
        }
    }
    ans1 = min(ans1,ans3);
    cout<<min(ans1,ans2)<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define INF 2147483647
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
	
	int n,a[111111];
	cin>>n;
	int f=0,t=0,o=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%4==0)f++;
		else if(a[i]%2==0)t++;
		else o++;
	}
	if(f!=0){
		if(o==0)cout<<"Yes"<<endl;
		else{
			if(t==0){
				if(f>=o-1)cout<<"Yes"<<endl;
				else cout<<"No"<<endl;
			}
			else {
				if(f>=o)cout<<"Yes"<<endl;
				else cout<<"No"<<endl;
			}
		}
	}
	else if(o==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}

Measured memory_bytes: 640
n,k=map(int,input().split())
x=list(map(int,input().split()))

ans=10**9
for i in range(n-k+1):
  x_max=x[i+k-1]
  x_min=x[i]

  t_ans=x_max-x_min
  t_ans+=min(abs(x_max),abs(x_min))

  ans=min(ans,t_ans)

print(ans)

Measured memory_bytes: 15020
#include <cstdio>
const int M = 100005;
int read()
{
	int x=0,flag=1;char c;
	while((c=getchar())<'0' || c>'9') if(c=='-') flag=-1;
	while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*flag;
}
int n,p,q,a[10],b[M],x[M],y[M],f[M];char s[10];
signed main()
{
    n=read();
    for(int i=1;i<=3;i++)
        a[i]=read();
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s);
        if(s[0]=='A') x[i]=1;
        if(s[0]=='B') x[i]=2;
        if(s[1]=='B') y[i]=2;
        if(s[1]=='C') y[i]=3;
    }
    for(int i=1;i<=n;i++)
    {
        p=x[i];q=y[i];
        if(a[p]+a[q]>=3)
        {
            if(a[p]>=a[q]) a[p]--,a[q]++,b[i]=q;
            else a[p]++,a[q]--,b[i]=p;
            continue;
        }
        if(a[p]+a[q]==0)
        {
            if(i>1 && f[i-1]==0 && a[x[i-1]]+a[y[i-1]]==2)
            {
                f[i-1]=1;
                a[x[i-1]]=a[y[i-1]]=1;
                i-=2;continue;
            }
            puts("No");
            return 0;
        }
        if(a[p]+a[q]==1)
        {
            if(a[p]==0) a[p]=1,a[q]=0,b[i]=p;
            else a[p]=0,a[q]=1,b[i]=q;
            continue;
        }
        if(a[p]==2 || a[q]==2)
        {
            b[i]=a[p]==2?q:p;
            a[p]=a[q]=1;
            continue;
        }
        if(f[i]==0)
        {
            a[p]=0;a[q]=2;
            b[i]=q;
        }
        else
        {
            a[p]=2;a[q]=0;
            b[i]=p;
        }
    }
    puts("Yes");
    for(int i=1;i<=n;i++)
        printf("%c\n",'A'+b[i]-1);
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  while(true){
    int n, x;cin>>n>>x;
    if(n==0 && x==0)break;

    int result = 0;
    rep1(i, n-2){
      for(int j=i+1;j<=n-1; j++){
        for(int k = j+1;k<=n; k++){
          if(i+j+k == x)result++;
        }
      }
    }

    cout<<result<<endl;
  }
  return 0;
}



Measured memory_bytes: 3056
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

enum Type{
	Call,
	Called,
	Lonely,
};

int N,memo[5001][3];

vector<int> V[5001];

int recursive(int node_id,Type type){

	if(memo[node_id][type] != -1)return memo[node_id][type];

	int ret = 0,tmp,sum;

	switch(type){
	case Call:
		sum = 0;
		for(int i = 0; i < V[node_id].size(); i++){
			sum += max(recursive(V[node_id][i],Call),recursive(V[node_id][i],Lonely));
		}
		for(int i = 0; i < V[node_id].size(); i++){
			ret = max(ret,sum-max(memo[V[node_id][i]][Call],memo[V[node_id][i]][Lonely])+recursive(V[node_id][i],Called)+1);
		}
		break;
	case Called:
		for(int i = 0; i < V[node_id].size(); i++){
			ret += max(recursive(V[node_id][i],Call),recursive(V[node_id][i],Lonely));
		}
		break;
	case Lonely:
		for(int i = 0; i < V[node_id].size(); i++){
			ret += max(recursive(V[node_id][i],Call),recursive(V[node_id][i],Lonely));
		}
		break;
	}

	return memo[node_id][type] = ret;
}

int func(){

	return max(recursive(0,Call),recursive(0,Lonely));
}


int main(void){

	scanf("%d",&N);
	int tmp;

    for(int day = 1;day <= N; day++){

        scanf("%d",&tmp);
        V[tmp].push_back(day);
        for(int i = 0; i <= day; i++){
        	for(int k = 0; k < 3; k++)memo[i][k] = -1;
        }

        printf("%d\n",func());
    }
    return 0;
}

Measured memory_bytes: 3512
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> a(n + 1);
    vector<int> b(n + 1);
    vector<int> c(n);
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 1; i <= n; ++i)
        cin >> b[i];
    for (int i = 1; i < n; ++i)
        cin >> c[i];

    int satisfication = 0;
    int prev;
    for (int i = 1; i <= n; ++i) {
        satisfication += b[a[i]];
        if (i > 1 && prev + 1 == a[i])
            satisfication += c[prev];
        prev = a[i];
    }
    cout << satisfication << '\n';
}


Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector           as V

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

getIntVec n = V.unfoldrN n (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine

main = do
  n <- getInt
  as <- getIntVec n
  let m = V.foldr' lcm 1 as
      as' = V.map (\i -> m `div` i) as
  print $ (sum as') `mod` 1000000007


Measured memory_bytes: 6524
N=int(input())
name_dict={'M':0,'A':0,'R':0,'C':0,'H':0}
for n in range(N):
    S=list(input())
    if S[0] in name_dict:
        name_dict[S[0]]+=1

ans=name_dict['M']*name_dict['A']*name_dict['R']\
    +name_dict['M']*name_dict['A']*name_dict['C']\
    +name_dict['M']*name_dict['A']*name_dict['H']\
    +name_dict['M']*name_dict['R']*name_dict['C']\
    +name_dict['M']*name_dict['R']*name_dict['H']\
    +name_dict['M']*name_dict['C']*name_dict['H']\
    +name_dict['A']*name_dict['R']*name_dict['C']\
    +name_dict['A']*name_dict['R']*name_dict['H']\
    +name_dict['A']*name_dict['C']*name_dict['H']\
    +name_dict['R']*name_dict['C']*name_dict['H']
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define tddd tuple<double,double,double>
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<int,pair<int,int> > >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 1<<16
typedef long long int ll;
int v[16][16],on[16];
ll dp[N],val[N];
int main()
{
    int n,i,j,k,a;
    int mask,S;
    ll x;
    in(n);
    twod(v,i,j,n,n);
    S=(1<<n);
    rep(mask,S)
    {
        k=0;
        rep(i,n)
            if((mask>>i)&1)on[k++]=i;
        rep(i,n)
        {
            if(!((mask>>i)&1))
            {
                x=0;
                rep(j,k)
                    x+=v[i][on[j]];
                a=(mask|(1<<i));
                val[a]=x+val[mask];
            }
        }
    }
    rep(i,S)
    {
        mask=(S-1)^i;
        a=mask;
        while(a>0)
        {
            dp[i^a]=max(dp[i^a],dp[i]+val[a]);
            a=(mask&(a-1));
        }
    }
    outl(dp[S-1]);



}





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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> sn(n, 1);
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a, a--;
            sn[a] = 0;
        }
    }
    cout << accumulate(begin(sn), end(sn), 0) << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            sum += a[i];
        }
        int mid1 = (int)Math.ceil(sum / (double)n);
        int mid2 = (int)Math.floor(sum / (double)n);
        
        long cost1 = 0;
        long cost2 = 0;
        for (int i = 0; i < n; i++) {
            cost1 += (int)Math.pow((a[i] - mid1), 2);
            cost2 += (int)Math.pow((a[i] - mid2), 2);
        }
//        System.out.println(mid1 + " " + mid2);
//        System.out.println(cost1 + " " + cost2);
        System.out.println((cost1<cost2)?cost1:cost2);
    }
}


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

typedef long long ll;

int main() {
ll n,a,b;
cin>>n>>a>>b;
if (n == 1 && (a != b)) { cout<<0<<endl; return 0; }
if (a > b) { cout<<0<<endl; return 0; }
ll k = (n-1)*a + b, l = a + (n-1)*b;
cout<<(l-k+1)<<endl;
}


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

int main() {
  string S1, S2, S3;
  cin >> S1 >> S2 >> S3;

  cout << (char)toupper(S1[0]) << (char)toupper(S2[0]) << (char)toupper(S3[0])
       << endl;
  return 0;
}

Measured memory_bytes: 3576
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		
		int D = sc.nextInt();
		int M = sc.nextInt();

		if(D==0){
			if(M==100) System.out.println(101);
			else System.out.println(M);
		}

		if(D==1){
			if(M==100) System.out.println(10100);
			else System.out.println(M*100);
		}

		if(D==2){
			if(M==100) System.out.println(1010000);
			else System.out.println(M*10000);
		}
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
  string b;
  cin>>b;
  int d=0;
  rep(i,a-2){
  if(b[i]=='A'&&b[i+1]=='B'&&b[i+2]=='C'){
  d++;
  }
  }
  cout<<d<<endl;
}

Measured memory_bytes: 256
// G++ MACRO.CPP -STD=C++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define str string

#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n);
  COUT(n/3);



  return 0;
}


Measured memory_bytes: 256