akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    set<int>s;
    s.insert(0);
    vector<int>a,b;
    int c=0,t;
    r(i,n)cin>>t,a.push_back(t),s.insert(t);
    r(i,n*2+1)if(!s.count(i))b.push_back(i);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    while(1){
      int cc=0;
      r(i,a.size())if(a[i]>c){
        c=a[i];cc++;
        a.erase(a.begin()+i);
        break;
      }
      if(!a.size())break;
      if(!cc)c=0;
      cc=0;
      r(i,b.size())if(b[i]>c){
        c=b[i];cc++;
        b.erase(b.begin()+i);
        break;
      }
      if(!b.size())break;
      if(!cc)c=0;
    }
    cout<<b.size()<<endl<<a.size()<<endl;
  }
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
 
using namespace std;
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
 

int main()
{
    string s;
    cin>>s;
    vector <char> beg,end;
    bool rev=0;
    int q;
    cin>>q;
    while(q--)
    {
        int t;
        cin>>t;
        if(t==1)
        {
            if(rev)
                rev=0;
            else
                rev=1;
        }
        else
        {
            int f;
            char c;
            cin>>f;
            cin>>c;
            if(f==1&&rev==0)
                beg.push_back(c);
            else if(f==1&&rev)
                end.push_back(c);
            else if(f==2&&rev==0)
                end.push_back(c);
            else
                beg.push_back(c);
        }
    }
    if(rev)
    {
        for(int i=end.size()-1;i>=0;i--)
            cout<<end[i];
        reverse(s.begin(),s.end());
        cout<<s;
        for(int i=0;i<beg.size();i++)
            cout<<beg[i];
        cout<<endl;
    }
    else
    {
        for(int i=beg.size()-1;i>=0;i--)
            cout<<beg[i];
        cout<<s;
        for(int i=0;i<end.size();i++)
            cout<<end[i];
        cout<<endl;
    }


    return 0;   
}
 
 


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF){
	double ans=a*b;
	printf("%.10lf",ans/3.305785);
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    while (true) {
        int w, h;
        scan(w, h);
        if (w == 0 && h == 0)
            break;
        vector<vector<int>> mp(h, vector<int>(w));
        scan(mp);
        int ans        = 0;
        vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
        vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};
        auto exist     = [](int H, int W, int nx, int ny) -> bool {
            if (nx < 0 || W <= nx || ny < 0 || H <= ny)
                return false;
            else
                return true;
        };
        auto dfs = [&](auto f, int y, int x) -> void {
            mp[y][x] = 0;
            rep(i, dx.size()) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (exist(h, w, nx, ny) && mp[ny][nx] == 1) {
                    f(f, ny, nx);
                }
            }
            return;
        };
        rep(y, h) {
            rep(x, w) {
                if (mp[y][x] == 1) {
                    dfs(dfs, y, x);
                    ans++;
                }
            }
        }
        print(ans);
    }

    return 0;
}


Measured memory_bytes: 3248
H,W=map(int,input().split())
ans=0
if H==1 or W==1:
	ans=1
else:
	if H%2==0:
		ans=H*W//2
	else:
		if W%2!=0:
			ans = H*(W-1)//2+(H//2+1)
		else:
			ans=H*W//2
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n;
    cin>>n;
    vector<ll>v;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            //i n/i
            v.push_back(abs(i-1)+abs(n/i-1));
        }
    }
    sort(v.begin(),v.end());
    cout<<v[0];}

Measured memory_bytes: 3628
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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

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

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

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

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

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> N >> A;

  cout << N*N-A << endl;

}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        long M = Long.parseLong(sc.next());
        long ans = 0;
        if(N <= 2 && M <= 2) {
            if(N == 1 && M == 1) ans = 1;
            else ans = 0; 
        }else if(N == 1) ans = M-2;
        else if(M == 1) ans = N-2;
        else if(N == 2 || M == 2) ans = 0;
        else ans = (N-2) * (M-2);
        System.out.println(ans);
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    ll ans = 0;
    for(int i = 0; i < N; i++){
        ll a = A[i];
        if(a % 2){
            if(i+1 < N && A[i+1] > 0){
                A[i+1]--;
                ans += (a+1)/2;
            }
            else{
                ans += a/2;
            }
        }
        else{
            ans += a/2; 
        }
    }

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


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		var s int
		fmt.Scanf("%d", &s)
		as[i] = s
	}

	as = append([]int{0}, as...)
	as = append(as, 0)
	sum := 0
	for i := 0; i < len(as)-1; i++ {
		d := as[i+1] - as[i]
		if d < 0 {
			d = -d
		}
		sum += d
	}
	for i := 1; i < len(as)-1; i++ {
		d1 := as[i+1] - as[i-1]
		if d1 < 0 {
			d1 = -d1
		}
		d2 := as[i] - as[i-1]
		if d2 < 0 {
			d2 = -d2
		}
		d3 := as[i+1] - as[i]
		if d3 < 0 {
			d3 = -d3
		}
		fmt.Printf("%d\n", sum+d1-d2-d3)
	}
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  vector<ll> A(3);
  for(ll i=0;i<3;i++) {
cin>>A[i];
  }
  sort(all(A));
  cout<<A[2]-A[0]<<endl;
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int x,y;
	cin>>x>>y;
	if(y&1)
		cout<<"No\n";
	else if(y%4==0 && y/4 == x)
		cout<<"Yes\n";
	else if(y%2==0 && y/2==x)
		cout<<"Yes\n";
	else if((y%2)%4==0 && (y/2+(y%2)/4)==x)
		cout<<"Yes\n";
	else if((y%4)%2==0 && (y/4+(y%4)/2)==x)
		cout<<"Yes\n";
	else if((y%6)%4==0 && (2*y/6+(y%6)/4)==x)
		cout<<"Yes\n";
	else if((y%6)%2==0 && (2*y/6+(y%6)/2)==x)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3704
import Control.Monad
import Data.List

main = interact $ show . sol . get

get = map (map read . words) . lines

sol [[n],as] = if sort as==bs then pow2 (n`div`2) else 0
  where
  bs = if odd n
    then 0:dbl [2,4..n-1]
    else dbl [1,3..n-1]

dbl = concatMap ((:) <*> return)

p = 10^9+7 :: Int

pow2 n
  | n == 0    = 1
  | odd n     = 2*r `mod` p
  | otherwise = r
  where
  q = pow2 (n `div` 2)
  r = q*q `mod` p

Measured memory_bytes: 30076
#include <bits/stdc++.h>
 
using namespace std;
 
const int N=1e6+3;
 
const double eps=1e-9;
 
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
 
const int dx[]={1,-1,0,0},
		  dy[]={0,0,1,-1};
 
const int mod=1e9+7,MOD=998244353;
 
int n,a[N],b[N],m,k,q,u,v,x,y,tc,l,r,c,ans,cnt[N];
 
char s[N],grid[N];
 
void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}
 
ll p[N];
 
int main(){
	//IO();
	scanf("%d",&n);
	ll ans=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	for(int i=1;i<=n;i++)
		ans+=(ll)cnt[i]*(cnt[i]-1) / 2;
	for(int i=0;i<n;i++){
		int x=a[i];
		ll r=(ll)cnt[x]*(cnt[x]-1)/2;
		ans-=r;
		printf("%lld\n",ans+(ll)(cnt[x]-1)*(cnt[x]-2) / 2);
		ans+=r;
	}
}

Measured memory_bytes: 8704
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s; cin >> s;
	bool flag = true;
	for (int i = 0; i < s.size(); ++i) {
		if (i & 1) {
			if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) flag = false;
		} else {
			if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) flag = false;
		}
	}
	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
#define s second
#define f first
const int MOD = 1e9+7;
using namespace std;

ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}

ll llmin(ll x, ll y){
	if (x > y) return y;
	return x;
}

bool is_prime(int x){
	for (int i = 2; i*i <= x; i++){
		if (!(x%i)) return false;
	}
	return true;
}


int main(){
	int a, b;
	cin >> a >> b;
	cout << 6 - a - b << endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

typedef unsigned long long ll;

#define fori(x) for (ll i = 0; i < x; ++i)
#define forj(x) for (ll j = 0; j < x; ++j)


const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;
	cin>>n;
	ll a[alength*2]={};
	fori(n){cin>>a[i];}
	ll hoge=a[0];
	fori(n-1){hoge^=a[i+1];}

	fori(n){
		cout<<(hoge^a[i])<<" ";
	}
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
int main() {
    int n,a,b,ans = 0;
    cin >> n >> a >> b;
    for (int i = 1; i <= n; ++i) {
        int tmp = i,dig = 0;
        while(tmp > 0){
            dig += tmp%10;
            tmp /= 10;
        }
        if(dig >= a && dig <= b) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int b = sc.nextInt();
			int p = sc.nextInt();
			int cost = x * b + y * p;
			int discount = x * Math.max(5, b) + y * Math.max(2, p);
			discount = discount * 4 / 5;
			System.out.println(Math.min(cost,discount));
		}
	}

}

Measured memory_bytes: 23444
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, m= LI()
    dic = collections.defaultdict(list)
    ans_lst = []

    for i in range(m):
        p, y = LI()
        dic[p].append((i, y))

    for key in dic.keys():
        dic[key].sort(key=lambda x: x[1])
        pfil = str(key).zfill(6)

        for i in range(len(dic[key])):
            id = pfil + str(i+1).zfill(6)
            ans_lst.append((dic[key][i][0], id))

    ans_lst.sort()
    ans = list(zip(*ans_lst))[1]
    print(*ans,sep="\n")
main()


Measured memory_bytes: 124164
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,K; cin>>N>>K;
  vector<ll> A(N); rep(i,N) cin>>A[i];
  
  map<ll,ll> mp;
  for(auto a:A) mp[a]++;
  
  vector<ll> vec(0); for(auto p:mp) vec.push_back(p.second);
  
  if(vec.size()<=K) {cout<<0<<'\n'; return 0;}
  
  sort(vec.rbegin(),vec.rend());
  ll ans=0; rep(i,K) ans+=vec[i];
  
  cout<<N-ans<<'\n';
  
  return 0;
}


Measured memory_bytes: 19276
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int n = in();
  vector<string> line(n);
  foreach(i,line)in(i);
  bool flag = [&](){
                rep(i,n-1){
                  if(line[i].back()!=line[i+1].front())return false;
                }
                sort(all(line));
                line.erase(unique(all(line)),line.end());
                return n == (int)line.size();
              }();
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  rep(i,n-1){
    
  }
  return 0;
}


Measured memory_bytes: 256
a,b,c,x,y=map(int, input().split())
if a+b<=c*2:
    price=a*x+b*y
elif x<=y:
    price=c*2*x + b*(y-x)
    if price>=c*2*y:
        price=c*2*y
else:
    price=c*2*y + a*(x-y)
    if price>=c*2*x:
        price=c*2*x
print(price)

Measured memory_bytes: 3316
#n = int(input())
a, b = map(int, input().split())
#l = list(map(int, input().split()))
#s = input()

ans = 0

if (a < 1 or a > 9) or (b < 1 or b > 9):
    ans = -1
else:
    ans = a * b
print(ans)




Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    int sum = 1;
    REP(i,M) sum *= 2;
    cout << (1900*M + 100*(N - M)) * sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;

int main(){
    char s[101];
    string ki = "RUD";
    string gu = "LUD";
    cin >> s;
    bool ok = true;

    for (int i = 1; i <= strlen(s); i++){
        size_t ret;
        if (i % 2 == 0){
            ret = gu.find(s[i-1]);
        } else{
            ret = ki.find(s[i-1]);
        }
        if (ret == string::npos){
            ok = false;
            break;
        }        
    }
    if(ok)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

//var done []bool = make([]bool, 10)
//var memo []int = make([]int, 10)

//func fib(n int) int {
//	fmt.Println(n)
//	if n == 0 {
//		return 0
//	}
//	if n == 1 {
//		return 1
//	}
//	if done[n] {
//		fmt.Println("done" + fmt.Sprint(n))
//		return memo[n]
//	}
//	done[n] = true
//	memo[n] = fib(n-1) + fib(n-2)
//	return memo[n]
//}

var m map[string]int = make(map[string]int)
var mInt map[int]int = make(map[int]int)

//var dp []int = make([]int, n)

//func fib(n int) int {
//	dp[0] = 0
//	dp[1] = 1
//	for i := 2; i <= n; i++ {
//		dp[i] = dp[i-1] + dp[i-2]
//	}
//	return dp[n]
//}

func line(ii []int, bn []int) []int {
	var res []int = ii
	for i := 0; i < len(ii); i++ {
		for j := 0; j < len(bn); j++ {
			if ii[i] == bn[j] {
				fmt.Println("hit" + fmt.Sprint(ii[i]))
				if i == len(ii)-1 {
					res = ii[:i]
				} else {
					res = append(ii[:i], ii[i+1:]...)
				}
			}
		}
	}
	return res
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	s := next()
	res := "Yes"
	if s == "AAA" || s == "BBB" {
		res = "No"
	}

	fmt.Fprint(out, res)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N, M;
    cin >> N >> M;
    int S[N], T[M];
    rep(i, N) cin >> S[i];
    rep(i, M) cin >> T[i];
    //dp[i][j]:=S[0,i)とT[0,j)の共通部分列の数
    ll dp[N+1][M+1];
    rep(i, N+1) dp[i][0] = 1;
    rep(j, M+1) dp[0][j] = 1;
    rep2(i, 1, N){
        rep2(j, 1, M){
            if(S[i-1] == T[j-1]){
                dp[i][j] = dp[i-1][j]+dp[i][j-1];
            }
            else{
                dp[i][j] = dp[i-1][j]+dp[i][j-1]+MOD-dp[i-1][j-1];
            }
            dp[i][j] %= MOD;
        }
    }
    cout << dp[N][M] << endl;
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,count,a,b;
	long long num=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		count=i%10+(i%100-i%10)/10+(i%1000-i%100)/100+(i%10000-i%1000)/1000+(i%100000-i%10000)/10000;
		if(count>=a&&count<=b)
			num+=i;
	}
	cout<<num<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 310; 

int n, m, a[N][N], l[N];
bool val[N];
vector<int> t[N];
bool check(int k)
{
	Rep(j, m) val[j] = false, t[j].clear();
	Rep(i, n) t[a[i][1]].push_back(i), l[i] = 1;
	Rep(i, m) {
		bool flag = false;
		Rep(j, m) if (!val[j] && t[j].size() > k){
			flag = val[j] = true;
			Rep0(i0, t[j].size() - 1) {
				int x = t[j][i0];
				while (val[a[x][l[x]]]) l[x] ++;
				if (l[t[j][i0]] > m) return false;
				t[a[x][l[x]]].push_back(x);
			}
			break;
		}
		if (!flag) return true;
	}
	return false;
}

int main()
{
	scanf("%d%d", &n, &m);
	Rep(i, n) Rep(j, m) scanf("%d", &a[i][j]);
	int l = 1, r = n;
	while (l != r) {
		int mid = (l + r) >> 1;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	
	printf("%d\n", l);
	
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main()
{
	int n,m,k;
	scanf("%d %d %d",&n,&m,&k);
	bool fail=true;
	for(int i=0; i<=n; i++){
		for(int j=0; j<=m; j++){
			if((n-i)*j+(m-j)*i==k)
				fail=false;
		}
	}
	puts(fail?"No":"Yes");
	return 0;
}


Measured memory_bytes: 128
#[allow(dead_code)]
fn main() {
    let (a, b, n) = i::u3();
    let x = min(b - 1, n);
    println!("{}", a * x / b - a * (x / b));
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2164
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(5);
    cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
}


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


int main() {

	int arr[3][3];
	for(int i=0;i<3;++i)
	{
		for(int j=0;j<3;++j)
		{
			cin>>arr[i][j];
		}
	}
	int n;
	cin>>n;
	int numlist[n];
	for(int i=0;i<n;++i)
	{
		cin>>numlist[i];
		if(arr[0][0]==numlist[i])
		   arr[0][0]=1;
		if(arr[0][1]==numlist[i])
		   arr[0][1]=1;
		if(arr[0][2]==numlist[i])
		   arr[0][2]=1;
		if(arr[1][0]==numlist[i])
		   arr[1][0]=1;
		if(arr[1][1]==numlist[i])
		   arr[1][1]=1;
		if(arr[1][2]==numlist[i])
		   arr[1][2]=1;
		if(arr[2][0]==numlist[i])
		   arr[2][0]=1;
		if(arr[2][1]==numlist[i])
		   arr[2][1]=1;
		if(arr[2][2]==numlist[i])
		   arr[2][2]=1;
	}
	bool flag=true;
	for(int i=0;i<3;++i)
	   {  flag = true;
	   	  for(int j=0;j<3;++j)
	   	  {
	   	  	  if(arr[i][j]!=1)
	   	  	  {
	   	  	  	flag = false;
	   	  	  	break;
				   }
			 }
			 if(flag==true)
			 {
			 	cout<<"Yes";
			 	return 0;
			 }
	   	  
	   }
	   
	   for(int i=0;i<3;++i)
	   {  flag = true;
	   	  for(int j=0;j<3;++j)
	   	  {
	   	  	  if(arr[j][i]!=1)
	   	  	  {
	   	  	  	flag = false;
	   	  	  	break;
				   }
			 }
			 if(flag==true)
			 {
			 	cout<<"Yes";
			 	return 0;
			 }
	   	  
	   }
	   
	   if(flag == true)
	   {
	   	cout<<"Yes";
	   	return 0;
	   }
	   else if ( arr[0][0]==1 && arr[1][1]==1 && arr[2][2]==1)
	   {
	   	cout<<"Yes";
	   	return 0;
	   }
	   else if(arr[0][2]==1 && arr[1][1]==1 && arr[2][0]==1)
	   {
	   	cout<<"Yes";
	   	return 0;
	   }
	   else
	   cout<<"No";
	
	
	
	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,k,ans=1,i;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		if(ans<k){
			ans=ans*2;
		}else ans+=k;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	std::string s,t;
	std::cin >> s;
	std::cin >> t;
	std::sort(s.begin(),s.end());
	std::sort(t.begin(),t.end(), [](char x, char y){return x > y;});
	for ( int i = 0 ; i < s.length() ; i++ ) {
		if(s[i] > t[i]) {
			std::cout << "No" << std::endl;
			return 0;
		}else if(s[i] < t[i]){
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}
	if (s.size() == t.size()) std::cout << "No" << std::endl;
	else std::cout << "Yes" << std::endl;
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation;
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define puf push_front
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){ll c; while(b!=0){c=a%b; a=b; b=c;} return a;}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a * c%mod;} a=a * a%mod; b>>=1;} return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10); x/=10;} reverse(all(res)); return res;}

void solve() {
  int n; cin>>n; vi A(n); rep(i,n) cin>>A[i];
  int ans=0;
  while(true){
    rep(i,n){if(A[i]%2==1) goto SKIP; A[i]/=2;}
    ans++;
  }
SKIP:
  out(ans);
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
using namespace std;
const int N =2 * 1e5 + 123;
int n , a[N] , p[40] , ans;
map < int , int > cnt;
multiset < int > st;
main(){
	scanf("%lld" , &n);
	p[0] = 1;
	for(int i = 1 ; i <= 33 ; i++)
		p[i] = p[i - 1] * 2ll;
	for(int i = 1 ; i <= n ; i++){
		scanf("%lld" , &a[i]);
		st.insert(a[i]);
	}
	
	while(!st.empty()){
		int x = *st.rbegin();
		st.erase(st.find(x));
		int id = 0;
		while(p[id] <= x)
			++id;
		auto it = st.find(p[id] - x);
		if(it != st.end()){
			++ans;
			st.erase(it);
		}
	}
	cout << ans ;
}


Measured memory_bytes: 11136
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};


int main() {
	int N;

	cin >> N;
	vector<ll>a(N);
	map<ll, ll>m;
	rep(i, N) {
		cin >> a[i];
		m[a[i]]++;
	}
	ll ans = 0;
	for (auto i: m) {
		if (i.second % 2 == 1) {
			ans++;

		}
	}
	cout << ans;
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<ll> &s, ll a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    map<char, ll> m;
    const vector<char> march = {'M', 'A', 'R', 'C', 'H'};
    rep(i, n) {
        string name;
        cin >> name;
        m[name.front()]++;
    }

    ll ans = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                char c = march[i],
                        d = march[j],
                        e = march[k];

                ans += m[c] * m[d] * m[e];

            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int gcd(int x, int y) {
  while(y) {
    int t = x%y;
    x = y;
    y = t;
  }
  return x;
}

int main() {
  for(int tci = 0; ; tci++) {
    int M,N; scanf("%d%d", &M, &N); if(M==0) break;
    static int BC[500],RC[500];
    for(int i = 0; i < M; i++) {
      scanf("%d", BC+i);
    }
    for(int i = 0; i < N; i++) {
      scanf("%d", RC+i);
    }
    static int capa[1002][1002];
    for(int i = 0; i < M+N+2; i++) {
      for(int j = 0; j < M+N+2; j++) {
        capa[i][j] = 0;
      }
    }
    for(int i = 0; i < M; i++) {
      capa[M+N][i] = 1;
    }
    for(int i = 0; i < N; i++) {
      capa[M+i][M+N+1] = 1;
    }
    for(int i = 0; i < M; i++) {
      for(int j = 0; j < N; j++) {
        capa[i][M+j] = (gcd(BC[i],RC[j])>1) ? 1 : 0;
      }
    }
    int flow = 0;
    while(true) {
      vector<int> stk; stk.reserve(M+N+2);
      vector<char> vis(M+N+2, 0);
      vector<int> par(M+N+2);
      stk.push_back(M+N);
      vis[M+N] = 1;
      while(!stk.empty()) {
        int v = stk.back(); stk.pop_back();
        if(v==M+N+1) {
          for(int w = v; w != M+N; w = par[w]) {
            capa[par[w]][w]--;
            capa[w][par[w]]++;
          }
          flow++;
          goto cont;
        }
        for(int w = 0; w < M+N+2; w++) {
          if(capa[v][w]==1 && !vis[w]) {
            vis[w] = 1;
            par[w] = v;
            stk.push_back(w);
          }
        }
      }
      break;
  cont:continue;
    }
    printf("%d\n", flow);
  }
  return 0;
}

Measured memory_bytes: 4748
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int  unsigned long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353 
const int N = 100001; 

// x+26*x+26*26*x

void solve(){
    int n;cin>>n;
    // int num=26;
    string s;
    while(n>0){
        int t=n%26;
        char c='a';
        if(t==0)c='z';
        else c=c+t-1;
        s=c+s;
        // num=num*26;
        // cout<<n<<" "<<t<<" "<<c<<endl;
        n=(n-1)/26;
    }
    cout<<s;
    return;
}
     
signed main(){
    IOS;
 
    int t=1;
    // cin>>t;
    rep(i,0,t){
        solve();
        cout<<"\n";
    //   cout<<" * "<<t<<"\n";
    }
//    return 0;
}


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

//#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
    char S;
    cin>> S;
    S=S + 0x01;
    cout<< S <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int M=1<<16|2,N=16,mod=1e9+7;
ll fac[M],ni[M],dp[M];
int a[N];
ll p(int a,int b){
	return a>=b?fac[a]*ni[a-b]%mod:0;
}
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
int main(){
	int n=read(),m=read();
	For(i,0,m-1)a[i]=read();
	reverse(a,a+m);
	For(i,fac[0]=1,(1<<n))fac[i]=fac[i-1]*i%mod;
	ni[1<<n]=ksm(fac[1<<n],mod-2);
	Rep(i,1<<n,1)ni[i-1]=ni[i]*i%mod;
	dp[(1<<n)-1]=1;
	For(i,0,m-1){
		For(zt,0,(1<<n)-1){
			dp[zt]%=mod;
			For(j,0,n-1)if(zt>>j&1){
				dp[zt^(1<<j)]+=dp[zt]*(mod-p(zt-a[i]+1,(1<<j)-1))%mod*(1<<j);
			}
			
		}
	}
	ll ans=0;
	For(zt,0,(1<<n)-1){
		ans=(ans+dp[zt]%mod*fac[zt])%mod;
	}
	cout<<ans*(1<<n)%mod<<endl;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

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__)

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

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

  SCIN(s);
  int A = s[0] - '0';
  vector< int > d(3);
  REP(i, 3) {
    d[i] = s[i + 1] - '0';
    // debug(d[i]);
  }
  REP(i, (1 << 3)) {
    // debug(i);
    int tmp = A;
    // debug(tmp);
    REP(j, 3) {
      if ((i >> j) & 1) {
        tmp += d[j];
      } else {
	tmp -= d[j];
      }
    }
    // debug(tmp);
    if (tmp == 7) {
      cout << A;
      REP(j, 3) {
	cout << ((i >> j) & 1 ? '+' : '-') << d[j];
      }
      cout << "=7"<< endl;
      return 0;
    }
  }

  return 0;
}



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

typedef long long ll;
#define pb push_back
#define ii pair<int ,int >
#define vi vector<int >
#define vii vector < pair<int ,int > >
#define IO ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define IOfiles freopen("input.txt","r+",stdin) ; freopen("output.txt","w+",stdout)
#define PI 3.14159265
const double eps = 1e-9;


int main()
{
	IO;
	ll n,m;
	cin>>n>>m;
	
	ll cpt=0;
	ll sum=0;
	ll arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	for(int i=0;i<n;i++){
		if(arr[i]*4*m>=sum)
			cpt++;
	}
	if(cpt>=m)
		cout<<"Yes"<<endl;
	else cout<<"No"<<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;
using P = pair<int, int>;

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

  cout << 3 * a * a << endl;

  return 0;
}


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


int main() {
	ll l,r,a=2019;
	cin>>l>>r;
	ll ans=inf;
	for(int i=l;i<r;i++){
		for(int j=l+1;j<=r;j++){
			ans=min(ans,(i%a)*(j%a)%a);
					if(ans==0){
			break;
		}
		}
		if(ans==0){
			break;
		}
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256
import sys

hoge = int(input())
cite = [list(map(int, input().split())) for i in range(hoge)]
cite.insert(0, [0, 0, 0])

for j in range(1, hoge+1):
    x_dif = abs(cite[j][1]-cite[j-1][1])
    y_dif = abs(cite[j][2]-cite[j-1][2])
    t_dif = cite[j][0] - cite[j-1][0]
    
    if x_dif + y_dif > t_dif or (x_dif + y_dif) % 2 != t_dif % 2:
        print("No")
        sys.exit()

print('Yes')


Measured memory_bytes: 27380