akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<iostream>
#include<queue>
#define rep(i,a,b) for(i=a;i<b;i++)
#define F1 first.first
#define F2 first.second
#define F3 second
#define INF 2100000000
#define long long int int
using namespace std;
typedef pair<pair<int,int>,int> P1;
typedef pair<int,int> P2;
int main(void)
{
	priority_queue<P2,vector<P2>,greater<P2> > que;
	int i,j,k,n,m,x,s,e;
	int a,b,cos,tim,st,en,way;
	int leng[1001],kami[1002];
	P1 glid1[6000],glid2[6000];
	P2 tori;
	while(1) {
		cin>>n>>m;
		if(n==0&&m==0) break;
		rep(i,0,n) {
			cin>>a>>b>>cos>>tim;
			glid1[i*2].F1=a,glid1[i*2].F2=b,glid1[i*2].F3=cos;
			glid2[i*2].F1=a,glid2[i*2].F2=b,glid2[i*2].F3=tim;
			glid1[i*2+1].F1=b,glid1[i*2+1].F2=a,glid1[i*2+1].F3=cos;
			glid2[i*2+1].F1=b,glid2[i*2+1].F2=a,glid2[i*2+1].F3=tim;
		}
		sort(glid1,glid1+n*2);sort(glid2,glid2+n*2);
		kami[1]=0;
		rep(i,1,n*2) {
			if(glid1[i].F1!=glid1[i-1].F1) {
				x=glid1[i].F1;
				kami[x]=i;
			}
		}
		kami[m+1]=n*2;
		
		cin>>k;
		rep(i,0,k) {
			cin>>st>>en>>way;
			for(j=1;j<=m;j++) leng[j]=INF;
			while(!que.empty()) que.pop();
			que.push(P2(0,st));
			while(!que.empty()) {
				tori=que.top(),que.pop();
				a=tori.first,b=tori.second;
				if(a<leng[b]) {
					leng[b]=a;
					if(b==en) break;
					s=kami[b],e=kami[b+1];
					if(way==0)rep(j,s,e) que.push(P2(a+glid1[j].F3,glid1[j].F2));
					else rep(j,s,e) que.push(P2(a+glid2[j].F3,glid2[j].F2));
				}
			}
			cout<<leng[en]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3256
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var n, l int
	fmt.Scanf("%d %d", &n, &l)

	var s = make([]string, n)

	for i := 0; i < n; i++ {
		fmt.Scanln(&s[i])
	}
	fmt.Println(logic(s))
}

func logic(s []string) string {
	sort.Strings(s)
	return strings.Join(s, "")
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int n,ans;
class men{
	public:
	int a,b,c;
	men(int aa,int bb,int cc){
		a=aa;
		b=bb;
		c=cc;
	}
	men(){
	a=0;
	b=0;
	c=0;
	}
};

men table[1000];

int main(){

	cin>>n;
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(a<b)swap(a,b);
		if(a<c)swap(a,c);
		if(b<c)swap(b,c);
		men tmp;
		tmp.a=a;
		tmp.b=b;
		tmp.c=c;
		table[i]=tmp;			
	}	
	
	for(int i=0;i<n;i++){
		int ta,tb,tc;
		ta=table[i].a;
		tb=table[i].b;
		tc=table[i].c;
		
		for(int j=i+1;j<n;j++){
			if(table[j].a==-1||table[j].b==-1||table[j].c==-1)continue;
			if(ta==table[j].a&&tb==table[j].b&&tc==table[j].c){
				ans++;
				table[j].a=-1;
				table[j].b=-1;
				table[j].c=-1;
			}
		}
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3092
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin>>N;
  vector<ll> a(N);
  rep(i,N) cin>>a[i];

  vector<vector<ll> > res(N, vector<ll>(25, 0)) ;
  // 前処理それぞれの数について二進法のベクトルを作っておく
  rep(i,N){
    ll k = 0;
    while(a[i] != 0){
      if(a[i] % 2 == 1){
        res[i][k]++;
        a[i] = (a[i] - 1) / 2;
      }
      else a[i] /= 2;
      k++;
    }
  }

  /*
  //check
  rep(i,N){
    rep(j,25){
      cout<<res[i][j]<<" ";
    }
    cout<<endl;
  }
  */

  map<ll,ll> m;

  //最初に入れとく
  rep(j,25){
    if(res[0][j]) m[j] = 1;
  }

  ll t = 1;
  ll ans = 0;
  rep(i,N){
    bool check = true;
    while( (t < N) and check ){
      rep(j,25){
        //判定してからたす
        ll tmp = res[t][j];
        if(tmp and m[j]) check = false;
      }
      if(check){
        //そいつを足しても大丈夫
        rep(j,25){
          ll tmp = res[t][j];
          if(tmp) m[j] = tmp;
        }
        t++;
      }
      else{
        // 進んでいない場合はtを下げたくない
        break;
      }
    }
    // cout<<i<<" "<<t<<" "<<endl;
    //先頭削除
    rep(j,25){
      ll c = res[i][j];
      if(c and m[j]) m[j] = 0;
      // cout<<m[j]<<" ";
    }
    // cout<<endl;

    // if(t == N) t--;
    ans += t - i;
    // 残量がある時はt更新
  }
  cout<<ans<<endl;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, m, c=1, x=1e9 + 7;
  cin >> n >> m;
  if(abs(n-m) > 1){
	cout << 0 << endl;
    return 0;
  }
  forll(i, 1, n+1)
	c = c * i % x;
  forll(i, 1, m + 1)
	c = c * i % x;
  if (n == m)
	cout << c * 2 % x << endl;
  else
	cout << c << endl;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    int n; cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    sort(a,a+n);
    ll sum1 = 0,sum2 = 0;
    ll ans = 0;
    if(n % 2 == 0){
        for(int i = 0; i < n/2; i++) {
            if(i == n/2-1) ans -= a[i];
            else ans -= 2*a[i];
        }
        for(int i = n/2; i < n; i++){
            if(i == n/2) ans += a[i];
            else ans += 2*a[i];
        }
    }else{
        for(int i = 0; i <= n/2; i++){
            if(i == n/2-1 || i == n/2) sum1 -= a[i];
            else sum1 -= 2*a[i];
        }
        for(int i = n/2+1; i < n; i++){
            sum1 += 2*a[i];
        }

        for(int i = 0; i < n/2; i++){
            sum2 -= 2*a[i];
        }
        for(int i = n/2; i < n; i++){
            if(i == n/2 || i == n/2+1){
                sum2 += a[i];
            }else{
                sum2 += 2*a[i];
            }
        }
        ans = max(sum1,sum2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4392
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n;
		int[] a;
		int o;
		int i;
		boolean flag;
		
		while(true){
			n = scan.nextInt();
			if(n == 0)break;
			
			a = new int[n];
			
			for(int j = 0;j < n; j++){
				a[j] = scan.nextInt(); 
			}
			
			o = 32;
			i = 0;
			flag = true;
			while(o > 0){
				if(flag){
					o -= (o-1)%5;
				}else{
					o = Math.max(0, o - a[i]);
					i = (i + 1) % n;
				}
				System.out.println(o);
				flag =! flag;
			}
		}
	}
}

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

int main(void){
	int N,L;
	cin >> N >> L;
	string s[N];
	for(int i=0;i<N;i++)cin >> s[i];
	sort(s, s + N);
	string ans = "";
	for(int i=0;i<N;i++){
		ans = ans + s[i];
	}
	cout << ans;
}

Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
n_list = [10] * n
for _ in range(m):
  si, ci = [int(i) for i in input().split()]
  if n_list[si - 1] == 10:
    n_list[si - 1] = ci
  elif n_list[si - 1] != ci:
    print(-1)
    exit()
if n != 1:
  ans = n_list[0] if n_list[0] != 10 else 1
else:
  ans = n_list[0] if n_list[0] != 10 else 0
if ans == 0 and n != 1:
  print(-1)
  exit()
for ai in n_list[1:]:
  if ai != 10:
    ans = ans * 10 + ai
  else:
    ans = ans * 10
print(ans)

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

namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
            string inp = Console.ReadLine();
            
            for(int i = 0;i<3;i++)
            {
              char num = inp[i];
                 
                if(num=='1')
                {
                    num='9';
                }
                else
                {
                    num='1';
                }
                
             Console.Write(num);
            }
            
        }
    }
}

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

int mba(string s){
  vector<int> t;
  t.push_back(s[0] - '0');
  for(int i = 1; i < s.size() ; i+=2){
    if(s[i]=='+'){
      t.push_back(s[i+1] - '0');
    } else {
      t.back() *= s[i+1] - '0';
    }
  }
  int res = 0;
  for(int i : t)res += i;
  return res;
}
int ltr(string s){
  int res = s[0] - '0';
  for(int i = 1; i < s.size() ; i+=2){
    if(s[i]=='+'){
      res += s[i+1] - '0';
    } else {
      res *= s[i+1] - '0';
    }
  }
  return res;
}
int main(){
  string out = "IMLU";
  string s; cin >> s;
  int e; cin >> e;
  cout << out[(mba(s)==e) + 2*(ltr(s)==e)] << endl;
}

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

typedef long long int ll;
int dp[100005],N,H[100005];
int fun(int i)
{
    if(i>N)
    return 100000000;
   else if(i==N)
    {
        return 0;
    }
  else if(i==N-1)
    {
        return abs(H[N]-H[N-1]);
    }
    else
    {
        if(dp[i]==-1)
        dp[i]= min((abs(H[i]-H[i+1])+fun(i+1)),(abs(H[i]-H[i+2])+fun(i+2)));
        
        else
        return dp[i];
    }
    return dp[i];
    
}




int main()
{ 
    int i,ans;
    cin>>N;
    for(i=1;i<=N;i++)
    {
        cin>>H[i];
    }
    dp[N]=0;
    memset(dp,-1,sizeof dp);
    ans = fun(1);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
public class ABC134D {
    public static void Main() {
        int N, M = 0, sum = 0;
        string ans = "";
        List<int> a = new List<int>(), b = new List<int>();
        N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) {
            a.Add(int.Parse(str[i]));
            b.Add(0);
        }
        for (int i = N - 1; i >= 0; i--) {
            sum = 0;
            for (int j = 2; j * (i+1) <= N; j++) {
                sum += b[j * (i+1) - 1];
            }
            sum %= 2;
            if (sum == a[i]) b[i] = 0;
            else {
                b[i] = 1;
                M++;
            }
        }
        Console.WriteLine(M);
        for (int i = 0; i < N; i++) {
            if (b[i] == 1) {
                Console.Write(i+1);
                Console.Write(" ");
            }
        }
    }
}


Measured memory_bytes: 28764
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <math.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(int i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(int i=(s), i##_len=(n); i<i##_len; ++i)


using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return (a.first*a.first + a.second*a.second) > (b.first*b.first + b.second*b.second);
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (1000000007)


int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, M;
    cin >> N >> M;
    ll S = 0;
    ll B = 0;
    map<int, int> m;
    m[0] = 1;
    REP(i, N) {
        int A;
        cin >> A;
        B = (B+A)%M;
        m[B]++;
    }
    
    for (auto it = m.begin(); it != m.end(); it++) {
        ll c = it->second;
        if (c > 1) {
            S += c*(c-1)/2;
        }
    }
    cout << S << endl;
}


Measured memory_bytes: 3200
let id x = x
let n = Scanf.scanf "%d\n" id
let h = Hashtbl.create n
let ans = ref 0

let () =
  for i = 1 to n do
    let a = Scanf.scanf "%d " id in
    let v = try Hashtbl.find h a with _ -> 0 in
    Hashtbl.replace h a (v + 1)
  done ;
  Hashtbl.iter
    (fun k v ->
      if v < k then ans := !ans + v else if v > k then ans := !ans + (v - k))
    h ;
  Printf.printf "%d\n" !ans

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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

ll cnt = 0;
map<ll,int> done;

void f(ll n) {
	for(ll p = 2; p*p <= n; ++p) {
		ll e = 0;
		if(n%p) continue;
		while(n%p == 0) {
			n /= p;
			++e;
		}

		ll cur=1;
		while(cur<=e) {
			cnt++;
			e-=cur;
			cur++;
		}
	}
	if(n > 1) {
		cnt++;
		n/=n;
	}
	// assert(n == 1);
}

void solve() {

	ll n;
	cin>>n;

	f(n);
	cout<<cnt;
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
}



Measured memory_bytes: 3644
t = int(input())


def dfs(i):
    if i in memo:
        return memo[i]
    memo[i] = 10 ** 18
    s = d * i
    j = i // 5
    s = min(s, dfs(j) + c + d * (i - j * 5))
    j = (i + 4) // 5
    s = min(s, dfs(j) + c + d * (j * 5 - i))

    j = i // 3
    s = min(s, dfs(j) + b + d * (i - j * 3))
    j = (i + 2) // 3
    s = min(s, dfs(j) + b + d * (j * 3 - i))

    j = i // 2
    s = min(s, dfs(j) + a + d * (i - j * 2))
    j = (i + 1) // 2
    s = min(s, dfs(j) + a + d * (j * 2 - i))
    memo[i] = s
    return s


for _ in range(t):
    n, a, b, c, d = [int(i) for i in input().split()]
    memo = {}
    print(dfs(n))


Measured memory_bytes: 10964
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;



signed main(){
	int N;
	cin >> N;
	vector<int>x(N), y(N);
	REP(i, N) cin >> x[i] >> y[i];

	vector<int>p(N), m(N);
	REP(i, N) p[i] = x[i] + y[i];
	REP(i, N) m[i] = x[i] - y[i];
	sort(ALL(p));
	sort(ALL(m));
	vector<int>a = {*max_element(ALL(p)), *min_element(ALL(p))};
	vector<int>b = {*max_element(ALL(m)), *min_element(ALL(m))};
	int ans = -INF;
	for(auto e: a) for(auto ee: a) CHMAX(ans, e - ee);
	for(auto e: b) for(auto ee: b) CHMAX(ans, e - ee);
	out(ans);
}

Measured memory_bytes: 9576
n = int(input())
A = list(map(int, input().split()))
A.sort()

dp = [False] * (A[-1] + 1)
for a in A:
    dp[a] = True

for idx, a in enumerate(A):
    if A[idx] == A[idx - 1]:
        if idx == 0:
            None
        else:
            dp[a] = False
    for j in range(2, A[-1]//a + 1):
        dp[a * j] = False

count = 0
for d in dp:
    if d:
        count += 1
print(count)


Measured memory_bytes: 121988
#include <bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
	int n, x;cin >> n >> x;
	for (int i = 1; i <= n; i++)cin >> a[i];
	int curr = 0, ans = 1;;
	for (int i = 2; i <= n + 1; i++)
	{
		curr += a[i - 1];
		if (curr <= x) ans++;
		else break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)          \
  cerr << #v << ": ";         \
  REP(__i, (v).size())        \
  cerr << ((v)[__i]) << ", "; \
  cerr << endl

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

bool isAtgc(char c) {
  return (c == 'A') or (c == 'T') or (c == 'G') or (c == 'C');
}

int main() {
  ios::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;

  string s;
  cin >> s;

  vi acc(N);
  char prev = 'x';
  for (int i = 0; i < N; ++i) {
    if (i == 0) {
      prev = s[i];
      continue;
    }
    if (prev == 'A' and s[i] == 'C') {
      acc[i] = acc[i - 1] + 1;
    } else {
      acc[i] = acc[i - 1];
    }
    prev = s[i];
  }

  DEBUG_VEC(acc);

  int l, r;
  REP(i, Q) {
    cin >> l >> r;
    int res = acc[r - 1] - acc[l - 1];
    cout << res << endl;
  }
  return 0;
}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s, t;

signed main() {
	cin >> s >> t;
	rep(i,s.size()) {
		if (s==t) return cout << "Yes" << ln, 0;
		s += s[0], s.erase(s.begin());
	}
	cout << "No" << ln;
}

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

int gcd(int a, int b){
  int c, d/* <c */;
  if(a < b){
    c = b;
    d = a;
  } else {
    c = a;
    d = b;
  }
  if(d == 0){
    d = c;
  } else {
    int r = c % d;
    while(r != 0){
      c = d;
      d = r;
      r = c % d;
    }
  }
  return d;
}

int main(void){
  int num;
  scanf("%d", &num);
  int numarray[num];
  int array_f[num+1], array_t[num+1];
  array_f[num] = 0;
  array_t[0] = 0;

  for(int i=0; i<num; i++){
    scanf("%d", &numarray[i]);
  }

  for(int i=0; i<num+1; i++){
    array_f[num-i-1] = gcd(array_f[num-i], numarray[num-i-1]);
    array_t[i+1] = gcd(array_t[i], numarray[i]);
  }


  int gcd_result[num];
  int gcd_max = 0;
  for(int i=0; i<num; i++){
    gcd_result[i] = gcd(array_t[i], array_f[i+1]);
    if(gcd_result[i] > gcd_max){
      gcd_max = gcd_result[i];
    }
  }

    printf("%d", gcd_max);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)

using namespace std;

int main() {
	ll n, p, max = 0;
	cin >> n;
	ll ans = 0;
	REP(i, n){
		cin >> p;
		ans += p;
		if (p > max){max = p;}
	}
	ans -= max/2;
	cout << ans << endl;
}

Measured memory_bytes: 256
from operator import itemgetter
import sys
sys.setrecursionlimit(1000000)
ans=0

n=int(input())
v=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]
for i in range(n):
    k=v[i]-c[i]
    if k>0:
        ans+=k
        
print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <string>
#include <limits.h>
#include <vector>
#include <numeric>

using namespace std;

vector<pair<long long int, long long int>> getPrimeElements(long long int num) {

	long long int firstnum = num;

	vector<pair<long long int, long long int>> result;
	pair<long long int, long long int> wk;

	if (num % 2 == 0) {
		wk.first = 2;
		wk.second = 0;
		while (num % 2 == 0) {
			wk.second++;
			num /= 2;
		}

		result.push_back(wk);
	}

	long long int waru = 3;

	while (true) {

		if (num % waru == 0) {
			wk.first = waru;
			wk.second = 0;
			while (num % waru == 0) {
				wk.second++;
				num /= waru;
			}

			result.push_back(wk);
		}
		waru += 2;

		if (waru * waru > num) break;

	}

	if (num != 1) {
		wk.first = num;
		wk.second = 1;
		result.push_back(wk);

	}

	return result;
}


int getKeta(int num) {

	if (num == 0)return 1;

	int res = 0;

	while (num > 0) {
		num /= 10;
		res++;
	}

	return res;
}

vector<int> bunkai(int num) {

	string str = to_string(num);
	vector<int> res;

	for (int i = 0; i < str.size(); i++) {
		int a = str[i] - '0';
		res.push_back(a);
	}

	return res;

}


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

	vector<long long int> a(m);
	for (auto& i : a)cin >> i;

	vector<long long int> stair(n+1, 0);
	for (auto& i : a) {
		stair[i] = -1;
	}

	stair[0] = 1;
	if (stair[1] == -1) {
		stair[1] = 0;
	}
	else {
		stair[1] = 1;
	}

	for (int i = 2; i <= n; i++) {
		if (stair[i] == -1) {
			stair[i] = 0;
			continue;
		}

		stair[i] = stair[i - 1] + stair[i - 2];
		stair[i] %= 1000000007;
		
	}

	cout << stair[n] << endl;


	return 0;

}




Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int n,h;
  cin>>n>>h;
  vector<int>a(n);
  vector<int>b(n);
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  int MAX_a=0;
  int count=0;
  for(int i=0;i<n;i++)MAX_a=max(MAX_a,a[i]);
  vector<int>copy=b;
  sort(copy.begin(),copy.end());
  reverse(copy.begin(),copy.end());
  vector<int>vec;
  for(int i=0;i<n;i++){
    if(copy[i]>MAX_a)vec.push_back(copy[i]);
  }
  for(int i=0;i<vec.size();i++){
    h-=vec[i];
    count++;
    if(h<=0){
      cout<<count<<endl;
      return 0;
    }
  }
  cout<<count+(h+MAX_a-1)/MAX_a<<endl;
}

Measured memory_bytes: 2044
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define INF 1e9
#define MOD 1000000007;//1e9+7

void solve() {
    int H, A;
    cin >> H >> A;
    cout << (H + A - 1) / A;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
a,b,x=map(int,input().split())
pay=0
if a//2<b:
    if x==1000:
        pay=a
    elif x==500:
        if b>a:
            pay=a
        else:
            pay=b
    else:        
        aa=x//1000
        aaa=x%1000
        if aaa>500:
            pay=(aa+1)*a
        elif aaa==0:
            pay=aa*a
        else:
            pay=aa*a+b
else:
    if x==500:
        pay=b
    else:
        bb=x//500
        bbb=x%500
        if bbb==0:
            pay=bb*b
        else:
            pay=(bb+1)*b
print(pay)


Measured memory_bytes: 5596
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
char ss[210];
queue<int>q;
struct node
{
	int x,y,next;
}a[40010];int len,last[210];
inline void ins(int x,int y)
{
	len++;
	a[len].x=x;a[len].y=y;
	a[len].next=last[x];last[x]=len;
}
int id[210];
bool bk;
inline void dfs(int x,int d)
{
	if(!id[x])id[x]=d;
	else 
	{
		if(id[x]!=d)bk=false;
		return ;
	}
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		dfs(y,3-d);
	}
}
int d[210];
int main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read();
	for(int i=1;i<=n;i++)
	{
		scanf("%s",ss+1);
		for(int j=1;j<=n;j++)if(ss[j]=='1')ins(i,j);
	}
	bk=true,dfs(1,1);
	if(bk==false){puts("-1");return 0;}
	int mx=0;
	for(int st=1;st<=n;st++)
	{
		memset(d,0,sizeof(d));
		q.push(st);d[st]=1;
		while(!q.empty())
		{
			int x=q.front();q.pop();
			for(int k=last[x];k;k=a[k].next)
			{
				int y=a[k].y;
				if(!d[y]){d[y]=d[x]+1,q.push(y);mx=max(mx,d[y]);}
			}
		}
	}pr2(mx);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<51)
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >   
#define vpl vector< pair<ll,ll> >   
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod 1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double
#define all(c) (c).begin(),(c).end()
#define N 3000
int n,k;
int a[N];
int dp[3001][3001][2];
bool vis[3001][3001][2];
int rec(int be,int en,int ch)
{
    if(be > en)
        return 0;
  
    if(vis[be][en][ch] == 0)
    {
        vis[be][en][ch] = 1;
        int ans = 0;
        if(ch)
        {
            ans =  - a[be] + rec(be+1,en,!ch);
            ans = min(ans,-a[en] + rec(be,en-1,!ch));
        }
        else
        {
            ans = a[be] + rec(be+1,en,!ch);
            ans = max(ans,a[en] + rec(be,en-1,!ch));

        }
        dp[be][en][ch] = ans;
        return ans;
    }
    else
        return dp[be][en][ch];
}

int32_t main()
{                
    IOS;
    
   
    memset(dp,-1,sizeof(dp));
    memset(vis,0,sizeof(vis));
    cin>>n;
    for(int i = 0;i < n;i++)
        cin>>a[i];
    cout<<rec(0,n-1,0);
    return 0;

}

Measured memory_bytes: 158720
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list>
#include <unordered_set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define _GLIBCXX_DEBUG
using namespace std;
struct __INIT { __INIT() { cin.tie(nullptr); ios::sync_with_stdio(false); } } __init;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<ll, ll> pair_t;
bool PSecComp(const pair_t& a, const pair_t& b) {
	if (a.second == b.second)return  a.first > b.first;
	else {
		return a.second > b.second;
	}
}

int main() {
	ll n,cnt=0;
	cin >> n;
	vector<ll>l(n);
	rep(i, n)cin >> l[i];
	sort(all(l));
	for (ll i = 0; i < n; i++) {
		for (ll k = 0; k < n; k++) {
			ll a = l[i],b = l[k];
			if (i != k) {
				if (a + b - max(a - b, b - a) >= 2) {
					auto Litr = upper_bound(all(l), max(a - b, b - a));
					auto Ritr = lower_bound(all(l), a + b);
					if (Litr != l.end()) {
						ll Lindex = distance(l.begin(), Litr);
						ll Rindex = distance(l.begin(), Ritr);
						cnt += Rindex - Lindex;
						if (Lindex <= i && i <= Rindex - 1)cnt--;
						if (Lindex <= k && k <= Rindex - 1)cnt--;
					}
				}
			}
		}
	}
	cout << cnt/6 << endl;
}



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

int main(){
	int n, A[100];
	cin >> n;
	for ( int i = 0; i < n; i++ ) cin >> A[i];

	for ( int i = n - 1 ; i >= 0; i-- ){
		if (i != n - 1) cout << " " ;
		cout << A[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3092
<?php
  $s = trim(fgets(STDIN));
  $s = explode(' ',$s);
  $a = $s[0];
  $b = $s[1];
 
  if ($a < $b) {
    echo 'a < b' . PHP_EOL;
  } elseif ($a > $b) {
    echo 'a > b' . PHP_EOL;
  } else {
    echo 'a == b' . PHP_EOL;
  }

Measured memory_bytes: 15392
#include<iostream>
#include<complex>
#include<cmath>
#include<algorithm>
#include<cstdio>

using namespace std;
typedef complex<double> P;
const double EPS = 1e-10;

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
bool is_intersected_ls(P a1, P a2, P b1, P b2) {
  return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < -EPS ) &&
         ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < -EPS );
}
double distance_ls_p(P a, P b, P c) {
  if ( dot(b-a, c-a) < EPS ) return abs(c-a);
  if ( dot(a-b, c-b) < EPS ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}

int main(){
  int count;
  while(true){
    count++;
    int n;
    cin>>n;
    if(!n)break;
    double r,r_min = 1000;
    double sx,sy,ex,ey;
    cin>>sx>>sy>>ex>>ey;
    P s=P(sx,sy),e=P(ex,ey);
    for(int i=0;i<n;i++){
      double x1,y1,x2,y2,h;
      cin>>x1>>y1>>x2>>y2>>h;
      P p[4]={ P(x1,y1),P(x2,y1),P(x2,y2),P(x1,y2)};
      if(is_intersected_ls(s,e,p[0],p[1])
	 ||is_intersected_ls(s,e,p[1],p[2])
	 ||is_intersected_ls(s,e,p[2],p[3])
	 ||is_intersected_ls(s,e,p[3],p[0])
	 ||(x1<min(sx,ex)&&y1<min(sy,ey)&&max(sx,ex)<x2&&max(sy,ey)<y2)){
	r_min = 0;
      }
      if(r_min-EPS>0){
	double l=1000;
	for(int j=0;j<4;j++){
	  l = min(l,distance_ls_p(s,e,p[j]));
	  l = min(l,distance_ls_p(p[j],p[(j+1)%4],s));
	  l = min(l,distance_ls_p(p[j],p[(j+1)%4],e));
	}
	r = h>l?l:(h*h+l*l)/(2*h);
	if(r<r_min)r_min = r;
      }
    }
    printf("%.4f\n",r_min);
  }
  return 0;
}

Measured memory_bytes: 0
def rec(l,x)
  return 1 if l==0
  if x==$s[l]-1
    return $p[l]
  elsif x>$s[l]/2
    return rec(l-1,x-$s[l]/2-1)+$p[l-1]+1
  elsif x==$s[l]/2
    return $p[l-1]+1
  elsif x>0
    return rec(l-1,x-1)
  else
    return 0
  end
end

n,x=gets.split.map(&:to_i)
$p=[1]
$s=[1]
n.times{
  $p << 2*$p.last+1
  $s << 2*$s.last+3
}

puts rec(n,x-1)

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>

using namespace std;

 long long n, k, l, r, c = 0;
 // int q, n;
 int main() {
     
     int a, b;
     cin >> a >> b;
     int* arr = new int[a]; 
     int* brr = new int[a]; 
     int sum = 0;  
     int c = 1; 
     for (int i = 0; i < a; i++) { // 3 3 3 3
         cin >> arr[i];
         sum += arr[i];
         brr[i] = sum; 
     }
     for (int i = 0; i < a; i++)
         if (brr[i] <= b) c++; else break; 
     cout << c; 
 }
    
        
    

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        s: [String; n],
    };
    let mut ans = vec![0; 4];
    for s_i in s.iter() {
        match s_i.as_str() {
            "AC" => ans[0] += 1,
            "WA" => ans[1] += 1,
            "TLE" => ans[2] += 1,
            "RE" => ans[3] += 1,
            _ => unreachable!(),
        }
    }
    println!("AC x {}", ans[0]);
    println!("WA x {}", ans[1]);
    println!("TLE x {}", ans[2]);
    println!("RE x {}", ans[3]);
}


Measured memory_bytes: 7816
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;

class Program
{
    static void Main(string[] args)
    {
        var text1 = ReadLine();
        var text2 = ReadLine();
        int len = text1.Length;
        for(int i = 0; i < len; ++i)
        {
            if (IsMatch(text1, text2, i))
            {
                WriteLine("Yes");
                return;
            }
        }
        WriteLine("No");
    }

    private static bool IsMatch(string text1, string text2, int diff)
    {
        for(int i = 0; i < text1.Length; ++i)
        {
            int j = (i + diff) % text2.Length;
            if (text1[i] != text2[j]) return false;
        }
        return true;
    }
}


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

using namespace std;

typedef vector<int, int> VII;
typedef vector<int> VI;
typedef pair<int, int> PII;

const int MAX_N = 1e6 + 5;
int par[MAX_N];

void init(int n) {
  for (int i = 0; i < n ; i++) {
    par[i] = i;
  }
}

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void merge(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  par[x] = y;
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int main() {
  int N, M;
  cin >> N >> M;
  init(N);
  VI ps;
  for (int i = 0; i < M; i++) {
    ps.push_back(-1);
  }

  for (int i = 0; i < N; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int n;
      cin >> n;
      n--;
      if (ps[n] == -1) {
        ps[n] = i;
      }
      merge(ps[n], i);
    }
  }

  for (int i = 0; i < N-1; i++) {
    if (!same(i, i+1)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
 
#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()
 
#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define nl printf("\n")
#define sp printf(" ")
 
typedef long long int lld;
typedef long double ldb;
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
 
map <char, lld> mpp;
 
main(){
    lld n;
    cin >> n;
    string str;
    for(int i = 0; i < n; ++i){
        cin >> str;
        mpp[str[0]]++;
    }
    lld ans = 0;
    lld m = mpp['M'];
    lld a = mpp['A'];
    lld r = mpp['R'];
    lld c = mpp['C'];
    lld h = mpp['H'];
    vector <lld> vct = {m,a,r,c,h};
    for(int i = 0; i < vct.size(); ++i){
        for(int j = i+1; j < vct.size(); ++j){
            for(int k = j+1; k < vct.size(); ++k){
                ans += vct[i]*vct[j]*vct[k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        Set<Integer> integers = new HashSet<>();
        integers.add(nextInt());
        integers.add(nextInt());
        integers.add(nextInt());
        if (integers.size() == 2) System.out.println("Yes");
        else System.out.println("No");
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

Measured memory_bytes: 21332
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var res = long.MaxValue;
        for (var j = 0; j < 2; j++)
        {
            var isP = j == 0;
            var sum = 0L;
            var r = 0L;
            for (var i = 0; i < num; i++)
            {
                sum += ar[i];
                if (isP&&sum<=0)
                {
                    r += 1 - sum;
                    sum = 1;
                }
                else if (!isP && sum >= 0)
                {
                    r += 1 + sum;
                    sum = -1;
                }
                isP = !isP;
            }
            res = Min(res, r);
        }
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


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

namespace SandboxCSharp
{
    class Solver
    {

        public void Solve()
        {
            int n = io.ScanInt();
            int k = io.ScanInt();
            int total = 0;
            for (int i = 0; i < n; ++i)
            {
                int x = io.ScanInt();
                total += Math.Min(2 * x, 2 * (k - x));
            }
            io.WriteLine(total);
        }

        // =================================================
        // =================================================

        Stdio io;
        bool isjdg;
        static void Main()
        {
            var s = new Solver();
            s.Solve();
            s.io.Flush();
        }
        public Solver(Stdio _io = null)
        {
            isjdg = _io == null;
            io = _io == null ? new Stdio() : _io;
        }

        void Exit()
        {
            if (isjdg)
            {
                io.Flush();
                Environment.Exit(0);
            }
            else
                throw new HaltException();
        }
    }
    class Stdio
    {
        protected string[] stack = new string[0];
        protected int stackptr = 0;
        protected StringBuilder outbuff = new StringBuilder();

        public virtual int ScanInt()
        {
            return Check() ? int.Parse(stack[stackptr++]) : 0;
        }
        public virtual long ScanLong()
        {
            return Check() ? long.Parse(stack[stackptr++]) : 0;
        }
        public virtual string ScanString()
        {
            return Check() ? stack[stackptr++] : string.Empty;
        }
        public virtual double ScanDouble()
        {
            return Check() ? double.Parse(stack[stackptr++]) : 0;
        }
        protected virtual bool Check()
        {
            if (stackptr < stack.Length) return true;
            var l = Console.ReadLine();
            if (l == null) return false;
            stack = l.Split(' ').ToArray(); stackptr = 0;
            return Check();
        }
        public Stdio Write(long v) { return Write($"{v}"); }
        public Stdio WriteLine(long v) { return WriteLine($"{v}"); }
        public Stdio Write(string str)
        {
            outbuff.Append(str);
            return this;
        }
        public Stdio WriteLine(string str = "")
        {
            outbuff.AppendLine(str);
            return this;
        }
        public virtual Stdio Flush()
        {
            Console.Write(outbuff.ToString());
            outbuff.Clear();
            return this;
        }
    }
    class HaltException : Exception { }

}


Measured memory_bytes: 13268
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    long long m;
    cin >> n >> m;
    vector<long long> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    long long ans = 0;
    long long x = 0;
    for(int i=0; i<=40; ++i){
        long long y = (m >> i << i) | x;
        if(y > m)
            y &= ~(1 << i);
        if(y <= m){
            long long tmp = 0;
            for(int j=0; j<n; ++j)
                tmp += a[j] ^ y;
            ans = max(ans, tmp);
        }

        int cnt = 0;
        for(int j=0; j<n; ++j){
            if(a[j] & (1LL << i))
                ++ cnt;
        }
        if(cnt < n - cnt)
            x |= 1LL << i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
    public final static int MAX = (int)1e5;
  // static Scanner sc = new Scanner(System.in);
   static List<Integer>[] edge;
	public static void main(String[] args) {
	   
	 FastReader sc = new FastReader();
	 char[] s = sc.next().toCharArray();
	 char[] t = sc.next().toCharArray();
	 TreeSet<Integer>[] set = new TreeSet[26];
	 for(int i=0;i<26;++i) set[i] = new TreeSet<>();
	 
	 for(int i=0;i<s.length;++i) set[s[i]-'a'].add(i+1);
	 
	 long ans = 0;
	 int last = 0;
	 boolean found = true;
	 for(int i=0;i<t.length && found;++i) {
		 
		 if(set[t[i]-'a'].size() == 0) {
			 found = false;
		 }else if(set[t[i]-'a'].higher(last) != null) {
			       ans+=set[t[i]-'a'].higher(last)-last;
			       last = set[t[i]-'a'].higher(last);
		 }else {
			 ans+=s.length-last + set[t[i]-'a'].first();
			 last = set[t[i]-'a'].first();
		 }
		 
		
	 }
	 if(found) out.println(ans);
	 else out.println(-1);
	 
		out.close();
	}
	
	
}


Measured memory_bytes: 37140
#include <stdio.h>

int main(void)
{
    int x , y , z;
    int temp = 0;

   scanf("%d %d %d" , &x ,&y ,&z);


   if (x > y) {
        temp = x;
        x = y;
        y = temp;
    }

   if (y > z) {
        temp = y;
        y = z;
        z = temp;
    }

   if (x > z) {
        temp = x;
        x = z;
        z = temp;
    }

   if (x > y) {
        temp = x;
        x = y;
        y = temp;
    }

    printf("%d %d %d\n" , x , y , z);

    return 0;

}


Measured memory_bytes: 2080
#include<cstdio>
#include<algorithm>
using namespace std;
class Point{
public:
   int x,y;
   Point(){}
   Point(int _x,int _y){
      x = _x; y = _y;
   }
}ink[13] = {Point(0,-1),Point(-1,0),Point(0,0),Point(1,0),Point(0,1),
            Point(-1,-1),Point(1,-1),Point(-1,1),Point(1,1),
            Point(0,-2),Point(-2,0),Point(2,0),Point(0,2)
            };

int main(void){
   int x,y,sz,blank = 100,ma = 0;
   int field[11][11] = {0};
   while(scanf("%d,%d,%d",&x,&y,&sz) != EOF){
      for(int i = 0;i < 13;i++){
         if(sz == 1 && i >= 5) break;
         if(sz == 2 && i >= 9) break;
         int _x = x + ink[i].x,_y = y + ink[i].y;
         if(0 <= _x&&_x < 10 && 0 <= _y&&_y < 10){
               if(field[_x][_y] == 0) blank--;
               ma = max(++field[_x][_y],ma);
         }
      }
   }
   printf("%d\n%d\n",blank,ma);
   return 0;
}

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


int main(){
	int N;
	cin >> N;
	if(N >= 'A' && N <= 'Z'){
		cout << 1 << endl;
	}
	else if(N >= 'a' && N <= 'z'){
		cout << 2 << endl;
	}
	else{
		cout << 0 << endl;
	}

	return 0;
}



Measured memory_bytes: 3120