akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

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


int main(void){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll e = lcm(c, d);
    cout << b-a+1 - (b/c-(a-1)/c) - (b/d-(a-1)/d) + (b/e-(a-1)/e) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val x = sc.nextInt()
    x
  }


  /**
    * base^n (n>=2, base^n<=upperBound)のリストを返す
    */
  def parfectPowerList(base: Int, upperBound: Int): List[Int] = {
    if (base == 1) {
      return List(1)
    }

    // 初項a、公比baseの等比数列
    def recurrence(a: Int): Stream[Int] = a #:: recurrence(a * base)

    val stream = recurrence(base * base)

    stream.takeWhile(x => x <= upperBound).toList
  }

  def main(args: Array[String]): Unit = {
    val x: Int = read()
    val parfectPowersLessThanX = (1 to x).flatMap(i => parfectPowerList(i, x))
    val result = parfectPowersLessThanX.max
    println(result)
  }
}

Measured memory_bytes: 25912
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


////////////////////////////////////////////////////////////////////


ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}




int main() {
int n,m;
cin>>n>>m;
vector<int> vec[n]{};

rrep(i, m){
	int u,z;
	cin>>u>>z;
	u--;
	z--;
	vec[u].push_back(z);
	vec[z].push_back(u);
}

vector<int> pe{};
for(int i=0;i<n;i++){
	pe.push_back(i);
}

int ans=0;

do{
	for(int i=0;i<=n-2;i++){
	
int u=pe[i];
if(i==0 && u!=0) break;
int z=pe[i+1];
int k=0;
for(int j=0;j<vec[u].size();j++){
if(vec[u][j]==z){k=1;
break;}
	}
if(k==0){
	break;}
if(i==n-2){ans++;

}
	}

}while(next_permutation(pe.begin(),pe.end()));

cout<<ans<<endl;
return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x real()
#define y imag()
#define EPS (1e-8)
using namespace std;
typedef complex <double> point;

namespace std {
  bool operator < (const point& a, const point& b){
    return fabs(real(a)-real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b); //x->y
  }
}
double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}

int ccw(point a,point b,point c){
  point d = b-a;
  point e = c-a;
  if(cross(d,e)>0) return 1;//"COUNTER_CLOCKWISE"
  if(cross(d,e)<0) return -1;//"CLOCKWISE"
  if(dot(d,e)<0) return 2;//"ONLINE_BACK"
  if(abs(d) < abs(e)) return -2;//"ONLINE_FRONT"
  return 0;//"ON_SEGMENT"
}


vector <point> Convex_Hull(vector <point> a){
  vector<point> b,c;
  if(a.size()<3) return a;
  sort(a.begin(),a.end());  
  
  b.push_back(a[0]);
  b.push_back(a[1]);
  for(int i=2;i<a.size();i++){
    //CLOCKWISE or ON_SEGMENT
    for(int j=b.size();j>=2&&ccw(b[j-2],b[j-1],a[i])!=-1&&ccw(b[j-2],b[j-1],a[i])!=-2;j--)b.pop_back();
    b.push_back(a[i]);
  }

  c.push_back(a.back());
  c.push_back(a[a.size()-2]);
  for(int i=a.size()-3;i>=0;i--){
    //CLOCKWISE or ON_SEGMENT
    for(int j=c.size();j>=2&&ccw(c[j-2],c[j-1],a[i])!=-1&&ccw(c[j-2],c[j-1],a[i])!=-2;j--) c.pop_back();
    c.push_back(a[i]);
  }
    reverse(c.begin(),c.end());
  for(int i=b.size()-2;i>=1;i--) c.push_back(b[i]);
  return c;
}

int main(){
  int n;
  cin>>n;
  vector<point> v;
  v.resize(n);
  for(int i=0,a,b;i<n;i++)cin>>a>>b,v[i]=point(a,b);
  v=Convex_Hull(v);
  
  for(int i=0;i<v.size();i++) swap(v[i].x,v[i].y);
  int idx=0;
  for(int i=1;i<v.size();i++) if(v[i]<v[idx]) idx=i;

  cout <<v.size()<<endl;
  for(int i=idx;i<v.size()+idx;i++) cout << v[i%v.size()].y<<" "<<v[i%v.size()].x<<endl;
  return 0;
}

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

struct BipartiteMatching {
    int n, timestamp;
    vector<vector<int>> graph;
    vector<int> alive, used, match;
    BipartiteMatching(int n) : \
    n(n), timestamp(0), graph(n), alive(n, 1), used(n, 0), match(n, -1) { }
    void add_edge(int u, int v) {
        graph[u].emplace_back(v);
        graph[v].emplace_back(u);
    }
    bool dfs(int idx) {
        used[idx] = timestamp;
        for (auto &to: graph[idx]) if (alive[to]) {
            int to_match = match[to];
            if (to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
                match[idx] = to;
                match[to] = idx;
                return true;
            }
        }
        return false;
    }
    int bipartite_matching(int ret = 0) {
        for (int i = 0; i < n; i++) if (alive[i]) {
            if (match[i] == -1) ++timestamp, ret += dfs(i);
        }
        return ret;
    }
    friend ostream& operator<<(ostream& os, BipartiteMatching& bm) {
        for (int i = 0; i < bm.n; i++) if (i < bm.match[i]) {
            os << i << " - " << bm.match[i] << endl;
        }
        return os;
    }
};

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
    int m, n;
    while (cin >> m >> n, m) {
        BipartiteMatching bm(m + n);
        vector<int> left(m), right(n);
        for (int& li: left) cin >> li;
        for (int& ri: right) cin >> ri;
        for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) {
            if (gcd(left[i], right[j]) > 1) bm.add_edge(i, j + m);
        }
        cout << bm.bipartite_matching() << endl;
    }
    return 0;
}


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

vector<ll> pos, neg, zero;


ll count_below(ll x){
    ll ans = 0, p = pos.size(), n = neg.size(), z = zero.size();

    if(x == 0){
        return p*n;
    }
    else if(x < 0){
        x = -x;
        for(ll y : pos){
            ans += n - (upper_bound(neg.begin(), neg.end(), x/y) - neg.begin());
        }

        return ans;
    }
    else{
        ans += p*n + z * (p+n) + z * (z-1)/2;


        for(int i = 1; i<p ; i++){
            ans += upper_bound(pos.begin(), pos.begin()+i, (x-1)/pos[i]) - pos.begin();
        }

        for(int i = 1; i<n ; i++){
            ans += upper_bound(neg.begin(), neg.begin()+i, (x-1)/neg[i]) - neg.begin();
        }

        return ans;
    }
}

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

    int n;
    ll k;
    cin>>n>>k;
    k--;

    for(int i = 0; i<n; i++){
        ll x;
        cin>>x;
        if(x == 0) zero.push_back(x);
        if(x > 0) pos.push_back(x);
        if(x < 0) neg.push_back(-x);
    }

    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    ll lo = -1e18, hi = 1e18;

    while(lo <= hi){
        ll mid = (lo + hi) / 2;

        if(count_below(mid) <= k)
            lo = mid + 1;
        else
            hi = mid - 1;
    }

    cout<<hi<<endl;

    return 0;
}



Measured memory_bytes: 5524
#include <iostream>

int main () {
    int w, h, n, x, y, a;
    std::cin >> w >> h >> n;
    int s[110][110] = {0};
    for(int i = 0; i < n; ++i){
        std::cin >> x >> y >> a;
        if(a == 1){
            for(int j = 0; j < x; ++j){
                for(int k = 0; k < h; ++k){
                    s[j][k] = 1;
                }
            }
        }
        if(a == 2){
            for(int j = x; j < w; ++j){
                for(int k = 0; k < h; ++k){
                    s[j][k] = 1;
                }
            }
        }
        if(a == 3){
            for(int j = 0; j < y; ++j){
                for(int k = 0; k < w; ++k){
                    s[k][j] = 1;
                }
            }
        }
        if(a == 4){
            for(int j = y; j < h; ++j){
                for(int k = 0; k < w; ++k){
                    s[k][j] = 1;
                }
            }
        }
        
    }
    int ans = 0;
    for(int i = 0; i < w; ++i){
        for(int j = 0; j < h; ++j){
            if(s[i][j] == 0) ++ ans;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(3*n);
  rep(i,3*n)cin>>a[i];
  sort(all(a));
  ll ans=0;
  if(n%2){
    for(i=n;i<3*n;i++)if(i%2)ans+=a[i];
  }else{
    for(i=n;i<3*n;i++)if(i%2==0)ans+=a[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1408
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    int N;
    cin >> N;
    vector<int> Ais; // 負のときはゼロが続く個数
    int zero_cnt = 0;
    for (int i = 0; i < N; i++) {
        int Ai;
        cin >> Ai;
        if (Ai == 0) {
            zero_cnt++;
        } else {
            if (zero_cnt > 0) {
                Ais.push_back(-zero_cnt);
                zero_cnt = 0;
            }
            Ais.push_back(Ai);
        }
    }
    if (zero_cnt > 0) {
        Ais.push_back(-zero_cnt);
        zero_cnt = 0;
    }
    ll ans = 0;
    for (int i = 0; i < Ais.size(); i++) {
        int exor = 0;
        int sum = 0;
        int pos_cnt = 0;
        int j = i;
        while (j < Ais.size() && pos_cnt <= 20) {
            if (Ais[j] > 0) {
                exor ^= Ais[j];
                sum += Ais[j];
                pos_cnt++;
            } else {
                exor ^= 0;
                sum += 0;
            }
            if (exor == sum) {
                if (i == j && Ais[i] < 0) {
                    ll abs = -Ais[i];
                    ans += abs * (abs + 1) / 2;
                } else {
                    ll start_mult = (Ais[i] < 0) ? (-Ais[i]) : 1;
                    ll end_mult = (Ais[j] < 0) ? (-Ais[j]) : 1;
                    ans += (start_mult * end_mult);
                }
            }
            j++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let T = read![[i64]; N];

    let mut dp = vec![vec![0; 3]; N + 1];

    for i in 0..N {
        for k in 0..3 {
            for l in 0..3 {
                if k == l {
                    continue;
                }
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][l] + T[i][k])
            }
        }
    }

    let m = dp[N].iter().cloned().max().unwrap();

    println!("{}", m)
}


Measured memory_bytes: 18684
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
}


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

#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,v) memset(a,v,sizeof(a))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define INF 0x3f3f3f3f//infinity for integers
#define JJ ios_base::sync_with_stdio(0); cin.tie(0)//input fast
#define MOD 1000000007
#define hash(n) unordered_map<int,int>mp(n)

int main()
{
	JJ;
	string s,t; cin>>s>>t;
	int n=s.length();
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]!=t[i])
			ans++;
	}
	cout<<ans<<endl;
	


	return 0;
}


Measured memory_bytes: 3800
#include <cstdio>
#include <string>
using namespace std;
int n,m;
const int MOD=1000000007;
const string inverse_pow="111011100110101100101000000101";
//yes this is 1000000005 in binary
inline int inv(int i){
long long ans=1;
for (int x=0;x<inverse_pow.size();x++){
ans=(ans*ans)%MOD;
if (inverse_pow[x]=='1') ans=(ans*i)%MOD;
}
return ans;
}

int main(){
    scanf("%d%d",&n,&m);
    int diag=n+m;
    if (diag%3){
        printf("0\n");
        return 0;
    }

    int row=diag/3;
    int column=min(n,m)-row;

    //printf("%d %d\n",row,column);

    if (column<0){
        printf("0\n");
        return 0;
    }

    long long res=1;
    for (int x=row-column+1;x<=row;x++){
        res=(res*x)%MOD;
    }

    for (int x=1;x<=column;x++){
        res=(res*inv(x))%MOD;
    }

    printf("%lld\n",res);
}


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

using namespace std;

bool u(const string &s)
{
  for (int i = 1; i < s.length(); i++)
    if (s[0] != s[i]) return false;
  return true;
}

int main()
{
  string s;
  cin >> s;
  int m = INT_MAX;
  for (int i = 0; i < 26; i++) {
    int c = 0;
    string t = s;
    while (s.length() > 0) {
      if (u(t)) break;
      string u = "";
      for (int j = 0; j < t.length()-1; j++) {
        if (t[j] == i+'a' || t[j+1] == i+'a')
          u.push_back(i+'a');
        else
          u.push_back(t[j]);
      }
      t = u;
      c++;
    }
    m = min(m, c);
  }
  cout << m << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	vector<int> a(m);
	int ans = 0;

	for (int i = 0;i < m;i++)
	{
		cin >> b[i];
	}

	for (int i = 0;i < n;i++)
	{
		for (int i = 0;i < m;i++)
		{
			cin >> a[i];
			a[i] *= b[i];
		}
		if (accumulate(a.begin(), a.end(), 0)  + c> 0)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,a,b=map(int, input().split())
    l=[]
    for i in range(1,n+1):
        cnt=0
        for j in range(len(str(i))):
            cnt+=int(str(i)[j])
        if a<=cnt<=b:
            l.append(i)
    print(sum(l))
resolve()

Measured memory_bytes: 3404
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
long long x;
int main()
{
	scanf("%lld",&x);
	for (long long i=-200;i<=200;i++)
	 for (long long j=-200;j<=200;j++)
	  if (i*i*i*i*i-j*j*j*j*j==x) {printf("%lld %lld\n",i,j); return 0;}
return 0;
}

Measured memory_bytes: 3816
import java.io.*;
import java.util.*;

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args){
        int N, M; {int[] a = in.ii(); N = a[0]; M = a[1];}
        
        ArrayList<City> city = new ArrayList<>(M);
        for(int i = 0; i < M; i++){
            int[] a = in.ii();
            city.add(new City(i, a[0], a[1]));
        }
        
        city.sort((x, y) -> {
            int d = x.info[1]-y.info[1];
            if(d != 0) return d;
            else return x.info[2]-y.info[2];
        });
        
        int[] id = new int[M];
        
        City c = city.get(0);
        for(int i = 0; i < M; ){
            int tmp = c.info[1];
            int j = 1;
            do {
                id[c.info[0]] = i;
                c.number = String.format("%06d%06d", tmp, j++);
            } while(++i < M && (c = city.get(i)).info[1] == tmp);    
        }
        
        for(int i = 0; i < M; i++)
            out.println(city.get(id[i]).number);        
        
        out.flush();
    }
    
    static class City {
        int[] info;
        String number;
        City(int i, int p, int y){
            info = new int[]{i, p, y};
        }
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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

namespace ABC089C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var count = new Dictionary<char, long>();
            count.Add('M', 0);
            count.Add('A', 0);
            count.Add('R', 0);
            count.Add('C', 0);
            count.Add('H', 0);
            foreach (var i in Enumerable.Range(0, n))
            {
                var currentName = Console.ReadLine();
                var initialChar = currentName.First();
                if (initialChar == 'M' ||
                    initialChar == 'A' ||
                    initialChar == 'R' ||
                    initialChar == 'C' ||
                    initialChar == 'H')
                {
                    count[initialChar]++;
                }
            }
            var pattern = new List<string>();
            pattern.Add("MAR");
            pattern.Add("MAC");
            pattern.Add("MAH");
            pattern.Add("MRC");
            pattern.Add("MRH");
            pattern.Add("MCH");
            pattern.Add("ARC");
            pattern.Add("ARH");
            pattern.Add("ACH");
            pattern.Add("RCH");
            var result = 0L;
            foreach( var currentPattern in pattern)
            {
                result += count[currentPattern[0]] * count[currentPattern[1]] * count[currentPattern[2]];
            }
            Console.WriteLine(result);



        }
    }
}


Measured memory_bytes: 17376
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<deque>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
	ll K; cin >> K;
	vector<int> A(N); 
	map<int, int> mp;
	vector<int> vec(N);
	rep(i, N) {
		cin >> A[i];
	}
	bool check[200200];
	rep(i, N) check[i] = false;
	rep(i, 2 * N) {
		int j = i % N;
		if((mp.find(A[j]) != mp.end()) && check[mp[A[j]]] == false) {
			vec[mp[A[j]] % N] = i - mp[A[j]] + 1;
			check[mp[A[j]]] = true;
		}
		mp[A[j]] = i;
	}
    bool c[200200];
	rep(i, N) c[i] = false;
	vector<ll> d;
	set<ll> e;
	d.pb(0);
	e.insert(0);
	ll k = -1LL;
	while(c[(k + 1) % N] != true) {
		c[(k + 1) % N] = true;
		k += vec[(k + 1) % N];
		d.pb(k + 1);
		e.insert(k + 1);
	}
	ll X = k + 1;
	ll M = (N * K - 1) % X;
	ll Y = *(lower_bound(all(d), M) - (e.find(M) != e.end() ? 0 : 1));
	ll Z = M - Y + 1;
	map<int, int> mp2;
	vector<int> ans;
	for(ll i = Y; i <= M; i++) {
		if(mp2[A[i % N]] != 0) {
          while(ans.back() != A[i % N]) {
              mp2[ans.back()] --;
				ans.pop_back();
			}
			ans.pop_back();
			mp2[A[i % N]] --;
		} else {
			ans.push_back(A[i % N]);
			mp2[A[i % N]] ++;
		}
	}
	for(int r = 0 ; r < ans.size(); r++) {
		cout << ans[r] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 33904
#include <cstdio>
#include <cassert>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

typedef long long i64;

struct BIT {

	vector<int> data;
	int size;

	void init(int n)
	{
		size = n;
		data.resize(size + 1);
		fill(data.begin(), data.end(), 0);
	}

	void add(int pos, int x)
	{
		pos += 1;
		while(pos < size + 1) {
			data[pos] += x;
			pos += pos & -pos;
		}
	}

	int sum(int pos)
	{
		pos += 1;
		int s = 0;
		while(pos > 0) {
			s += data[pos];
			pos -= pos & -pos;
		}
		return s;
	}
};

const i64 mod = 998244353;

int main()
{
	int n;
	vector<pair<int, int>> ps;
	vector<int> xs, ys;

	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		ps.push_back({x, y});
		xs.push_back(x);
		ys.push_back(y);
	}

	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());

	for(int i = 0; i < n; i++) {
		int ox = ps[i].first, oy = ps[i].second;
		int x = lower_bound(xs.begin(), xs.end(), ox) - xs.begin();
		int y = lower_bound(ys.begin(), ys.end(), oy) - ys.begin();
		ps[i] = {x, y};
	}

	i64 ans = 0;
	BIT bit;

	sort(ps.begin(), ps.end());
	bit.init(n);

	vector<i64> modpow2(n + 1, 0);

	modpow2[0] = 1;
	for(int i = 1; i < n + 1; i++) {
		modpow2[i] = modpow2[i - 1] * 2;
		while(modpow2[i] >= mod) {
			modpow2[i] -= mod;
		}
	}

	for(int i = 0; i < n; i++) {

		int x = ps[i].first;
		int y = ps[i].second;

		int xl = x, xr = n - 1 - x;
		int yl = y, yr = n - 1 - y;
		int xlyl = bit.sum(y);
		int xlyr = i - xlyl;
		int xryl = yl - xlyl;
		int xryr = yr - xlyr;

		assert(xlyl + xlyr == xl);
		assert(xryl + xryr == xr);

		bit.add(y, 1);

		i64 a = 0;

		a += modpow2[n] - 1;
		a -= modpow2[xl] - 1;
		a -= modpow2[xr] - 1;
		a -= modpow2[yl] - 1;
		a -= modpow2[yr] - 1;
		a += modpow2[xlyl] - 1;
		a += modpow2[xlyr] - 1;
		a += modpow2[xryl] - 1;
		a += modpow2[xryr] - 1;

		ans += a;

		//printf("%d (%d,%d) -> %d + %d + %d + %d, %lld\n", i, x, y, xlyl, xlyr, xryl, xryr, a);
	}

	ans = (ans + 5 * n * mod) % mod;

	printf("%lld\n", ans);

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  int A, B; cin >> A >> B;
  if (1 <= A && A <= 9 && 1 <= B && B <= 9) cout << A * B << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
        int w, h, x, y, r;

        scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

        if( w>=x+r && h>=y+r && x-r>=0 && y-r>=0 )
                puts("Yes");
        else
                puts("No");

        return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm.*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
// #define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
const int inf = 2e9;
int max(int a,int b){	if(a > b)return a; else return b; }
int min(int a, int b){	if(a < b)return a; else return b; }
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;	// You should not be writing p1.ss <= p2.ss !!!
	else if(p1.ff == p2.ff){ if(p1.ss < p2.ss)return true; return false; }
	return false;
}
/*		1. Take all the inputs
		4. Whenever you do multiplication and division in the same line, beware.
*/
void solve(){
	// int main  or  int32_t main ...
	int n;
	cin >> n;
	cout << (n+1)/2 << endl;
}
/*	memset() can be used to set all values as 0 or -1 for integer data types.*/

int main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(15); std::cout << std::fixed;
	int t; t = 1;
	// cin >> t;
	while(t--){ solve(); }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>

using namespace std;

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

#define inf 0x3f3f3f3f
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		int N; input_returnner(int N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(int N) { return std::move(input_returnner(N)); }
}

void solve();
/// ---template---
signed main(void) {
	SETUP;
	solve();
	return 0;
}

const int MOD = 1e9 + 7;

ull res = 0;
void dfs(string S, ull sum) {
	REP(i, S.size()-1) {
		dfs(S.substr(i+1), sum + stoull(S.substr(0, i+1)));
	}
	res += stoull(S)+sum;
}

void solve() {
	string S; cin >> S;
	dfs(S, 0);
	cout << res << endl;
}

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

int main(){
    int n, y;
    cin >> n >> y;
    int a = -1, b = -1, c = -1, a_check, b_check, c_check;
    for(a_check = 0; a_check <= n; a_check++){
        if((y - 1000 * n - 9000 * a_check) % 4000 == 0){
            b_check = (y - 1000 * n - 9000 * a_check) / 4000;
            c_check = n - a_check - b_check;
            if(b_check >= 0 && c_check >= 0){
                a = a_check;
                b = b_check;
                c = c_check;
                break;
            }
        }
    }

    //printf("%d %d %d %d\n", a, b, c, y - (10000 * a + 5000 * b + 1000 * c));
    printf("%d %d %d\n", a, b, c);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, long long K){
    cout << N%K << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int n;
    cin >> n;
    vector<int> d(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    for (int i = 1; i < n + 1; ++i) {
        if ((i & 1) && d[i] != 0)
            d[i] = 24 - d[i];
    }
    int ans = inf;
    for (int i = 0; i < n + 1; ++i) {
        for (int j = i + 1; j < n + 1; ++j) {
            ans = min({ans, abs(d[i] - d[j]), 24 - abs(d[i] - d[j])});
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int num;
	char c;
	double w, h, bmi;
	pair<int, double> p;
	while(cin >> num >> c >> w >> c >> h){
		bmi = w / (h*h);
		p.first = num;
		p.second = bmi;

		if(p.second >= 25) cout << p.first << endl;
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

constexpr ll th = 1024;

void dfs(ll n, const vector<tuple<ll,ll>>& vt, vector<vector<tuple<ll,ll>>>& table, ll i) {
  if (i > n) return;
  if (i >= th) return;
  if (i == 1) {
    table[1].emplace_back(0, 0);
    table[1].push_back(vt[0]);
    sort(ALL(table[1]));
  } else {
    ll p = i / 2;
    vector<tuple<ll,ll>> nx = table[p];
    auto [wi,vi] = vt[i-1];
    for(auto&&[w,v]:table[p]) {
      nx.emplace_back(w+wi, v+vi);
    }
    sort(ALL(nx));
    table[i] = nx;
  }
  dfs(n, vt, table, 2*i);
  dfs(n, vt, table, 2*i+1);
}

ll dfs2(const vector<tuple<ll,ll>>& vt, const vector<vector<tuple<ll,ll>>>& table, ll i, const vector<tuple<ll,ll>>& t2, ll l) {
  if (i < th) {
    ll ans = 0;
    ll mxv = 0;
    auto jtr = begin(table[i]);
    for(auto itr = rbegin(t2); itr != rend(t2); ++itr) {
      auto&&[w2,v2] = *itr;
      if (w2 > l) continue;
      while (jtr != end(table[i])) {
        auto[w,v] = *jtr;
        if (w2 + w > l) break;
        ++jtr;
        mxv = max(mxv, v);
      }
      ans = max(ans, v2 + mxv);
    }
    return ans;
  }
  auto nx = t2;
  auto [wi, vi] = vt[i-1];
  for (auto&&[w,v]:t2) {
    nx.emplace_back(w+wi, v+vi);
  }
  sort(ALL(nx));
  return dfs2(vt, table, i/2, nx, l);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  vector<tuple<ll,ll>> vt;
  REP(i,n) {
    ll v,w;
    cin>>v>>w;
    vt.emplace_back(w,v);
  }
  ll tsize = min(n+1, th);
  vector<vector<tuple<ll,ll>>> table(tsize);
  dfs(n, vt, table, 1);
  ll q;
  cin>>q;
  REP(i,q) {
    ll v,l;
    cin>>v>>l;
    vector<tuple<ll,ll>> t2 = {{0, 0}};
    auto ans = dfs2(vt, table, v, t2, l);
    cout<<ans<<"\n";
  }
  return 0;
}


Measured memory_bytes: 19812
s = input()
a, b = int(s[0:2]), int(s[2:4])
if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
elif 1 <= a <= 12:
    print("MMYY")
elif 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 38256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;

int main() {
    ll A, B;
    cin >> A >> B;

    if (A <= 8 && B <= 8)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;

    return 0;
}

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

int main(){
	int n;
	cin>>n;
	//cout<<"J"<<endl;
	int step[n+3];
	for(int i=1;i<=n;i++) cin>>step[i];
	vector<int> cost(n+3,1e9+5);
	cost[1]=0;
	//cout<<"Hi\n";
	for(int i=1;i<n;i++){
		cost[i+1]=min(cost[i+1],abs(step[i+1]-step[i])+cost[i]);
		cost[i+2]=min(cost[i+2],abs(step[i+2]-step[i])+cost[i]);
	}
	cout<<cost[n]<<endl;
return 0;
}


Measured memory_bytes: 1024
N,K=map(int,input().split())
S=input()

run=[]
import itertools
for key,g in itertools.groupby(S):
  run.append(len(list(g)))
  
import numpy as np
run=np.cumsum(run)

ans=0
if S[0]=="0":
  left=0
  while left<len(run):
    if left==0:
      zone=min(2*K-1,len(run)-1)
      val=run[zone]
      left+=1
    else:
      zone=min(left+2*K,len(run)-1)
      val=run[zone]-run[left-1]
      left+=2
    ans=max(ans,val)
elif S[0]=="1":
  left=0
  while left<len(run):
    if left==0:
      zone=min(2*K,len(run)-1)
      val=run[zone]
      left+=2
    else:
      zone=min(left+2*K,len(run)-1)
      val=run[zone]-run[left-1]
      left+=2
    ans=max(ans,val)
print(ans)


Measured memory_bytes: 14856
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int n;
        cin>>n;
        int a[n];
        set<int> s;
        map<int,int> m;
        fori(i,n) {
            cin>>a[i];
            s.insert(a[i]);
            m[a[i]]++;
        }
        sort(a, a+n);
        reverse(a, a+n);
        int ans = a[0];
        m[a[0]]--;
        auto it = s.rbegin();
        if(!m[a[0]]) s.erase(*s.rbegin());
        int ct = n-2;
        while(ct) {
            int x = min(ct, 2ll*m[*s.rbegin()]);
            ans += x* (*s.rbegin());
            ct -= x;
            s.erase(*s.rbegin());
        }
        cout<<ans;
    }
    
    return 0;
}

Measured memory_bytes: 27096
#include <stdio.h>

int main(){
    char c[3][3];
    int i, j;

    for(i=0; i<3; i++){
        scanf("%s", &c[i]);
    }

    for(i=0; i<3; i++){
        printf("%c", c[i][i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
  int n;cin>>n;
  int arr[n][2];
  
  for(int i=0;i<n;i++)
  cin>>arr[i][0]>>arr[i][1];
  
  int flag=0;
  for(int i=0;i<n-2;i++)
  {
      if(arr[i][0]==arr[i][1] &&arr[i+1][0]==arr[i+1][1] &&arr[i+2][0]==arr[i+2][1])
      {
          flag++;break;
      }
  }
  
  
  if(flag)
  cout<<"Yes";
  else
  cout<<"No";
    return 0;
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(std::vector<long long> x){
    rep(i, 5){
        if(x[i] == 0) cout << i + 1 << endl;
    }
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    std::vector<long long> x(5);
    for(int i = 0 ; i < 5 ; i++){
        scanf("%lld",&x[i]);
    }
    solve(std::move(x));
    return 0;
}


Measured memory_bytes: 3692
/* 
 * Author: pawanmsr
 */

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //

// Functions //

// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    
    /* code */
    int n;
    set<string> p;
    string s;

    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> s;
        p.insert(s);
    }

    cout << p.size() << endl;

    return 0;
}


Measured memory_bytes: 19172
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
struct UnionFind{
    vl par;
    UnionFind(ll N):par(N,-1){}
    void init(ll N){par.assign(N,-1);}
    ll root(ll x){
        if(par[x]<0)return x;
        return par[x]=root(par[x]);
    }
    bool issame(ll x,ll y){
        return root(x)==root(y);
    }
    bool merge(ll x,ll y){
        x=root(x),y=root(y);
        if(x==y)return false;
        if(par[x]>par[y])swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }
    ll size(ll x){
        return -par[root(x)];
    }
};
int main(){
    ll N,M;cin>>N>>M;
    int a[M],b[M];
    rep(i,M)cin>>a[i]>>b[i],a[i]--,b[i]--;
    int ans=0;
    rep(i,M){
        UnionFind tree(N);
        rep(j,M){
            if(i!=j)tree.merge(a[j],b[j]);
        }
        rep(p,N)rep(q,N){
            if(!tree.issame(p,q)){
                ans++;
                p=N;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
//const ll mod=1000000007;
ll mod;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=210;
int dp[N][N];
int n,k;
void upd(int &a,int b) {
	a+=b; if (a>=mod) a-=mod;
}
int solve(int x,int y) {
	if (y<0) return 0;
	if (y==0) return x<=1;
	int ans=0;
	for (int a=2;a<=y+1;a++) {
		int b=x-a;
		if (b<1||b>y+1) continue;
		for (int i=0;i<a;i++) for (int j=0;j<=b;j++) {
			if (i==0&&j==0) { dp[i][j]=1; continue; }
			dp[i][j]=0;
			if (i==0&&j==b) continue;
			if (b-y-1>j-i||j-i>y+1-a) continue;
			if (i>0) upd(dp[i][j],dp[i-1][j]);
			if (j>0) upd(dp[i][j],dp[i][j-1]);
		}
		upd(ans,dp[a-1][b]);
	}
	return ans;
}

int main() {
	scanf("%d%d%lld",&n,&k,&mod);
	int ans=0;
	for (int deg=0;deg<=n-2;deg++) {
		ans=(ans+(ll)solve(n-deg,k-deg)*powmod(n-deg,mod-2))%mod;
	}
	if (k>=n-1) {
		ans=(ans+1)%mod;
	}
	rep(i,1,n+1) ans=(ll)ans*i%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 3900
#include<iostream>
#include<math.h>
using namespace std;

int main(){
long long int ans=0;
long long int n;
cin>>n;
if(n==2){cout<<0<<endl;return 0;}
long long int k=sqrt(n);
if(k*k!=n and n%k==0 and k*(k+1)!=n){ans+=(n/k)-1;}
for(long long int i=1;i<k;i++){
if(n%i==0 and i*(i+1)!=n){ans+=(n/i)-1;}
}
cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void)
{
	int n, i;
	double sum = 0, b[1000], av;
	while (1)
	{
		scanf("%d", &n);
		if (n == 0)
		{
			return 0;
		}
		for (i = 0; i < n; i++)
		{
			scanf("%lf", &b[i]);
			sum = sum + b[i];
		}
		av = sum / n;

		sum = 0;

		for (i = 0; i < n; i++)
		{
			sum = sum + (b[i] - av)*(b[i] - av);
		}
			printf("%f\n", sqrt(sum / n));
		sum = 0;

		
	}
}


Measured memory_bytes: 2052