akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <assert.h>

using namespace std;

int main()
{
	int n;
	cin >> n;
	string ans;
	while (n)
	{
		ans = (n % 2 == 0 ? '0' : '1') + ans;
		n = ceil((double)n / (double)-2);
	}
	if (ans == "")
		cout << 0 << endl;
	else
		cout << ans << endl;

	return 0;
}


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

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  int n;
  cin >>n;
  for(int T=0; T<n; ++T){
    int i,j,k;

    int f[9][9];
    rep(i,9)rep(j,9) scanf(" %d", &f[i][j]);

    char tf[9][9];
    rep(i,9){
      rep(j,9){//f[i][j]??????????????????
        bool ok=true;

        //???
        rep(k,9){
          if(j!=k && f[i][j]==f[i][k]) ok=false;
        }

        //???
        rep(k,9){
          if(i!=k && f[i][j]==f[k][j]) ok=false;
        }

        //????????????
        int sy=3*(i/3), sx=3*(j/3);
        //printf("(%d %d) -> (%d %d)\n",i,j,sy,sx);

        for(int y=sy; y<sy+3; ++y){
          for(int x=sx ; x<sx+3; ++x){
            if(y==i&&x==j) continue;
            if(f[i][j]==f[y][x]) ok=false;
          }
        }

        if(ok) tf[i][j]=' ';
        else tf[i][j]='*';

      }
    }

    if(T) printf("\n");
    rep(i,9){
      rep(j,9){
        printf("%c%d",tf[i][j], f[i][j]);
      }
      printf("\n");
    }

  }
  return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>
#define M 105

int main(void){
    int n,i;
    int x[M];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(i=n-1;i>=0;i--){
        printf("%d",x[i]);
        if(i != 0)printf(" ");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

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

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    int a, b;
    cin >> a >> b;
    if((a%3==0)||(b%3==0)||((a+b)%3==0))cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}
int ans[N],visited[N];
vector<int> adj[N];
int n,m;

void dfs(int node,int p){
	if(visited[node]>0)
		return ;
	visited[node] = 1;	
	for(int i:adj[node]){
		if(i!=p){
			dfs(i,node);
		}
	}
	
	for(int i:adj[node]){
		if(i!=p)
			ans[node] = max(ans[node],ans[i]);
	}
	ans[node]++;
}

int main(){
	boost;
	cin>>n>>m;
	
	for(int i = 0;i<m;i++){
		int a,b;
		cin>>a>>b;
		adj[a].pb(b);
	}
	
	for(int i = 1;i<=n;i++){
		if(visited[i] == 0) {
			//cout<<i<<endl;
			dfs(i,-1);
		}
	}
	
	int an = 0;
	for(int i = 1;i<=n;i++)
		an = max(an,ans[i]);
		
	cout<<an-1;
	return 0;
}

//Total solved problems:- 13



Measured memory_bytes: 9984
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
	ll n;
	cin>>n;
	double d = 0.;
	rep(i,0,n){
		ll a;
		cin>>a;
		double b = 1./a;
		d += b;
	}
	printf("%20.20f\n", 1./d);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    string S, in_s;
    string left_s="", right_s="";
    cin >> S;
    ll Q, t, f;
    sll(Q);
    bool is_reverse = false;
    bool now_order = false;
    rep(i, Q){
        sll(t);
        if(t == 1){
            is_reverse = !is_reverse;
        }else{
            sll(f);
            cin >> in_s;
            now_order = is_reverse;
            if(is_reverse){
                if(f==1){
                    right_s = right_s + in_s;
                }else{
                    left_s = in_s + left_s;
                }
                // right_s[::-1] + S[::-1] + left_s[::-1]
            }else{
                if(f==1){
                    left_s = in_s + left_s;
                }else{
                    right_s = right_s + in_s;
                }
                // left_s + S + right_s;
            }
        }
        // cout << " is reverse:" <<is_reverse << endl;;
    }

    // cout << "left s:" << left_s << " right s " << right_s <<endl;
    string concat="";
    if(now_order){
        // concat = right_s;
        for(ll i=right_s.size()-1;i>=0;i--){
            concat += right_s[i];
        }
        for(ll i=S.size()-1;i>=0;i--){
            concat += S[i];
        }
        for(ll i=left_s.size()-1;i>=0;i--){
            concat += left_s[i];
        }
    }else{
        concat = left_s + S + right_s;
    }

    string ans = "";
    if(is_reverse!=now_order){
        for(ll i=concat.size()-1;i>=0;i--){
            ans += concat[i];
        }
        cout << ans <<endl;
    }else{
        ans = concat;
        cout << ans <<endl;
    }
    


}

int main(){
    Main();
}

Measured memory_bytes: 1568
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;
ll MOD = ll(1e9)+7LL;
vector<int> FIB(8);

int calc(int a, int b, int w){
  int s, t;if(a>b)swap(a, b);
  s=max(0, a-1);t=max(0, (w-1)-b-1);
  return FIB[s]*FIB[t];
}

int main(){
  FIB[0]=1;FIB[1]=2;
  for(int i=2;i<8;i++){
  	FIB[i]=FIB[i-1]+FIB[i-2];
  }
  int h, w, k;cin>>h>>w>>k;k--;
  vector<vector<ll>> dp(h+1, vector<ll>(w, 0LL));
  dp[0][0]=1LL;
  rep(i, h){
  	rep(j, w){
      for(int dw=-1;dw<2;dw++){
        if(j+dw<0 || w<=j+dw)continue;
      	dp[i+1][j+dw]+=dp[i][j]*calc(j, j+dw, w)%MOD;
        dp[i+1][j+dw]%=MOD;
      }
    }
  }
  cout<<dp[h][k]<<endl;
}


Measured memory_bytes: 256
a, b = gets.split.map(&:to_i)
ans = 0
if a >= 2 && b >= 2
  ans = (a-2) * (b-2)
elsif a == 1 && b >= 2
  ans = b-2
elsif a >= 2 && b == 1
  ans = a-2
elsif a == 1 && b == 1
  ans = 1
end
p ans

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef long long ll;

int compare_asc(const void *a, const void *b)
{
    return (*(char *)a - *(char *)b);
}

int compare_str(const void *a, const void *b)
{
    return strcmp((char *)a, (char *)b);
}

int main(void)
{
    ll ans = 0;
    int n;
    int i;

    scanf("%d", &n);
    char s[n][11];
    for (i = 0; i < n; i++)
    {
        scanf("%s", s[i]);
        qsort(s[i], 10, sizeof(char), compare_asc);
    }
    qsort(s, n, sizeof *s, compare_str);

    int flag = 0, tmp = 0;
    for (i = 1; i < n; i++)
    {
        if (strcmp(s[i - 1], s[i]) == 0)
        {
            tmp++;
            flag = 1;
        }
        else
        {
            ans += (ll)(tmp + 1) * (ll)(tmp) / 2;
            tmp = 0;
            flag = 0;
        }
    }
    if (tmp > 0)
        ans += (ll)(tmp + 1) * (ll)(tmp) / 2;

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

    return 0;
}

Measured memory_bytes: 2300
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define f(i,a,b) for(int i=a;i<=b;++i)
int dot[1000005],num[200005];
int main()
{
	int n,Max=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&num[i]),Max=max(num[i],Max);
	sort(num+1,num+1+n);
	for(int i=1;i<=n;++i)
	{
		if(num[i]==num[i-1]) {
			dot[num[i]]=1;
			continue;
		}
		for(int j=2*num[i];j<=Max;j+=num[i])
			dot[j]=1;
	}
	//for(int i=1;i<=Max;++i) cout<<dot[i]<<" ";
	int ans=0;
	for(int i=1;i<=n;++i)
		if(!dot[num[i]]) ++ans;
	cout<<ans;
	return 0;
 } 

Measured memory_bytes: 8452
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( '\n' );
  var n = parseInt( data[0] );
  var x = data[1].split( ' ' ).map( Number );
  var y = data[2].split( ' ' ).map( Number );
  var Dxy = 0;
  var Dxy2 = 0;
  var Dxy3 = 0;
  var Dmax = 0;
  var txy = [];
  for( var i=0; i<n; i++ ) {
    txy.push( Math.abs( x[i]-y[i] ) );
    Dxy += txy[i];
    Dxy2 += Math.pow( txy[i], 2 );
    Dxy3 += Math.pow( txy[i], 3 );
    Dmax = Math.max( Dmax, txy[i] );
  }
  console.log( Dxy );  
  console.log( Math.sqrt( Dxy2 ) );
  console.log( Math.pow( Dxy3, 1/3 ) );
  console.log( Dmax );
});

Measured memory_bytes: 16208
#include<stdio.h>
int main(){
  int w,n,i,j,k,a,b,max,mi;
  for(k=1;scanf("%d",&w),w;k++){
    int d[1001][1001]={0};
    scanf("%d",&n);
    for(i=1;i<=n;i++){
      scanf("%d,%d",&a,&b);
      for(j=0;j<=w;j++){
	d[i][j]=d[i-1][j];
	if(j<b)continue;
	if(d[i][j]<d[i-1][j-b]+a)d[i][j]=d[i-1][j-b]+a;
      }
    }
    for(i=max=0;i<=w;i++){
      if(max<d[n][i]){
	max=d[n][i];
	mi=i;
      }
    }
    printf("Case %d:\n%d\n%d\n",k,max,mi);
  }
  return 0;
}

Measured memory_bytes: 4520
import java.util.Scanner;

public class Main {
		static int CARD_MAX=1000;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] taro =new String[n];
		String[] hana =new String[n];
		int taro_score=0;
		int hana_score=0;
		
		for(int i=0;i<n;i++){
			 taro[i] = scan.next();
			 hana[i] = scan.next();
			if(taro[i].compareTo(hana[i])==0){
				taro_score++;
				hana_score++;
			}else if(taro[i].compareTo(hana[i])>0){
				taro_score=taro_score +3;
			}else{
				hana_score= hana_score+3;
		}
		
			
		}

		System.out.println(taro_score+" "+hana_score);
		
	}



public static String shutffleString(String str,int h){
		String before = new String();
		String after = new String();

		for(int i = 0 ; i<h ; i++){
			before = before + str.charAt(i);
		}
		for(int i=h ; i < str.length() ;i++){
			after = after + str.charAt(i);
		}
			str = after + before;

	return str;
}

}

Measured memory_bytes: 29252
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=(1ll<<31)-1ll;
const ll MOD=1e9+7;

template <typename T>
class SegmentTree {
  ll n;
  vector<T> node;
  function<T(T, T)> fun, fun2;
  bool customChange;
  T outValue, initValue;
public:
  void init(ll num, function<T(T, T)> resultFunction, T init, T out, function<T(T, T)> changeFunction = NULL) {
    // changeFunction: (input, beforevalue) => newvalue
    fun = resultFunction;
    fun2 = changeFunction;
    customChange = changeFunction != NULL;
    n = 1;
    while (n < num) n *= 2;
    node.resize(2 * n - 1);
    fill(node.begin(), node.end(), init);
    outValue = out;
    initValue = init;
  }
  void valueChange(ll num, T value) {
    num += n-1;
    if (customChange) node[num] = fun2(value, node[num]);
    else node[num] = value;
    while (num > 0) num = (num - 1) / 2, node[num] = fun(node[num * 2 + 1], node[num * 2 + 2]);
  }
  T rangeQuery(ll a, ll b, ll l = 0, ll r = -1, ll k = 0) { // [a, b)
    if (r == -1) r = n;
    if (a <= l && r <= b) return node[k];
    if (b <= l || r <= a) return outValue;
    ll mid = (l + r) / 2;
    return fun(rangeQuery(a, b, l, mid, 2*k+1), rangeQuery(a, b, mid, r, 2*k+2));
  }
};

ll N,Q;
ll Min(ll a,ll b){
    return min(a,b);
}
int main(){
    cin>>N>>Q;
    SegmentTree<ll> segT;
    segT.init(N,Min,INF,INF);
    for(ll i=0;i<Q;i++){
        ll com,x,y;
        cin>>com>>x>>y;
        if(com){
            cout<<segT.rangeQuery(x,y+1)<<endl;
        }else{
            segT.valueChange(x,y);
        }
    }

    return 0;
}


Measured memory_bytes: 4968
a, b, m = input().split(' ')
m = int(m)
reizouko_list = [int(n) for n in input().split(' ')]
renji_list    = [int(n) for n in input().split(' ')]
yasui = min(reizouko_list) + min(renji_list)

for i in range(m):
  x, y, c = input().split(' ')
  x = int(x) - 1
  y = int(y) - 1
  c = int(c)
  if reizouko_list[x] + renji_list[y] - c < yasui:
    yasui = reizouko_list[x] + renji_list[y] - c
print(yasui)
  

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

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

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	ll S, C; cin >> S >> C;
	if (S >= C / 2) {
		print(C / 2);
	} else {
		print(S +  (C - 2 * S) / 4);
	}
}

Measured memory_bytes: 256
A,B=map(int,input().split())                            # 1行2列

A_TAX = 0.08
B_TAX = 0.10

bl = 0
for i in range(0,10000):
	if int(i*A_TAX) == A and int(i*B_TAX) == B:
		bl = 1
		print(i)
		break

if bl == 0:
	print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
void dfs(string s, char mx, int N) {
    if(s.length() == N) {
        cout << s.c_str() << endl;
    } else {
        for(char c = 'a'; c <= mx; c++) {
            dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx), N);
        }
    }
}
int main() {
    int N;
    cin >> N;
    string s = "";
    char head = 'a';
    dfs(s, head, N);
    return 0;
}

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

int main() {
	int N, M;
	scanf("%d %d", &N, &M);
	
	vector<vector<int>> light(M);
	for(int i = 0; i < M; i++) {
		int k;
		scanf("%d", &k);
		light[i].resize(k);
		for(int j = 0; j < k; j++) {
			int s;
			scanf("%d", &s);
			light[i][j] = s - 1;
		}
	}
	
	vector<int> p(M);
	for(int i = 0; i < M; i++) scanf("%d", &p[i]);
		
	int comb = 0;
	for(int i = 0; i < (1 << N); i++) {
		bool on = true;
		for(int j = 0; j < M; j++) {
			int sum = 0;
			for(auto k : light[j]) {
				if(i & (1 << k)) sum++;
			}
			if(sum % 2 != p[j]) on = false;
		}
		if(on) comb++;
	}
	
	printf("%d", comb);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;

    ll best = s.size();
    ll mid = s.size()/2-1;
    int flag = 0;

    while (mid > 0){
        flag = 0;
        REP(i, mid){
            if (s[i] != s[mid+i]){
                mid--;
                flag = 1;
            }
        }
        if (flag == 1) continue;
        if (best == s.size()) best = mid * 2;
        mid--;
        
    }

    cout << best << endl;

}

Measured memory_bytes: 384
//In the name of God
#include<bits/stdc++.h>

using namespace std ;

const int N = (int)1e5 + 10 ;

int n ;
pair < int , int > a[N] ;

int32_t main() {
	cin >> n ;
	for(int j = 0 ; j < n ; ++j) {
		cin >> a[j].first ;
		a[j].second = j ; 
	}
	sort(a , a + n) ;
	int res = 0 ;
	for(int i = 0 ; i < n ; i += 2)
		(res += a[i].second % 2 != i % 2) ;
	cout << res << endl ; 
}


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

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse);

            var a = input.ElementAt(0);
            var b = input.ElementAt(1);

            var coin = 0;

            if (a >= b)
            {
                coin += a;
                a--;
            }
            else
            {
                coin += b;
                b--;
            }

            if (a >= b)
            {
                coin += a;
                a--;
            }
            else
            {
                coin += b;
                b--;
            }

            Console.WriteLine(coin);
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    if(N % 2 == 0)cout << 1.0 / 2.0 << endl;
    else cout <<( (double) (N + 1) / 2.0) / (double) N << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n, m, **a, *b;
	cin >> n >> m;
	a = new int*[n];
	b = new int[m];
	for (int i = 0; i < n; i++) {
		a[i] = new int[m];
		for (int j = 0; j < m; j++)
			cin >> a[i][j];
	}
	for (int i = 0; i < m; i++)
		cin >> b[i];

	for (int i = 0; i < n; i++) {
		int ans = 0;
		for (int j = 0; j < m; j++)
			ans += a[i][j] * b[j];
		cout << ans << endl;
	}

	for (int i = 0; i < n; i++)
		delete[] a[i];
	delete[] a;
	delete[] b;
	return 0;
}

Measured memory_bytes: 1236
/// HuDzG
#include <bits/stdc++.h>
#define reset(a) memset(a,0,sizeof(a))
#define ll long long
#define ld long double
#define endl '\n'
#define AutoAC int main()
#define OO 1000000000000000000
#define F first
#define S second
#define pii pair <ll, ll>
#define pb push_back
#define nmax 1000005
#define HUNGIT ""
#define MOD 1000000007

using namespace std;

ll n, q, par[nmax];

ll Find(ll u)
{
    if(u != par[u]) par[u] = Find(par[u]);
    return par[u];
}

bool Join(ll u, ll v, ll t)
{
    u = Find(u); v = Find(v);
    if(u == v) return 0;
    if(!t) par[v] = u;
    return 1;
}

AutoAC
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen (HUNGIT".inp", "r", stdin);
    //freopen (HUNGIT".out", "w", stdout);
    cin >> n >> q;
    for(ll i = 1; i <= n; i++)
        par[i] = i;
    while(q--)
    {
        ll u, v, t, h;
        cin >> t >> u >> v;
        h = Join(u, v, t);
        if(t) cout << !h << endl;
    }
    return 0;
}


Measured memory_bytes: 4988
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    if (a<=0&&b>=0) cout << "Zero\n";
    else if (a>0 || ((a^b)&1)==1) cout << "Positive\n";
    else cout << "Negative\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807

signed main()
{
  int x=0,y=0,z=0,w=0,n=1,m=0;
  string s;
std::cin >> s;
rep(i,s.size()/2){
  if(s[i]!=s[s.size()-1-i])x++;
}
std::cout << x << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
int main(void){
	
	int n,i,x;
	int min=INT_MAX,max=INT_MIN;
	long sum=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&x);
		sum+=x;
		if(max<x){
			max=x;
		}
		if(min>x){
			min=x;
		}
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 600
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception {
    	InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

       String input = br.readLine();
       double r = Double.parseDouble(input);
       double men = (double) r * r * Math.PI;
       double nagasa = (double) r * 2 * Math.PI;
       System.out.printf("%.6f %.6f" ,men,nagasa);
    }
}

Measured memory_bytes: 24680
x,y,a,b,c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
sum = 0
P.sort(reverse = True)
Q.sort(reverse = True)
for i in range(x):
    R.append(P[i])
for i in range(y):
    R.append(Q[i])
R.sort(reverse = True)
for i in range(x + y):
    sum += R[i]
print(sum)

Measured memory_bytes: 23328
# AOJ 1617: Almost Identical Programs
# Python3 2018.7.13 bal4u

s = {0:"IDENTICAL", 1:"CLOSE", 2:"DIFFERENT"}
while True:
	s1 = input();
	if s1 == '.': break
	s1 = list(s1)
	s2 = list(input())
	w1, w2 = len(s1), len(s2)
	i = j = 0
	ans, k = -1, 0
	while i < w1 and j < w2:
		if s1[i] != s2[j]: ans = 2; break
		if s1[i] == '"':
			i, j = i+1, j+1
			wi, wj = i, j
			while s1[i] != '"': i += 1
			while s2[j] != '"': j += 1
			if s1[wi:i] != s2[wj:j]: k += 1
			if k > 1: ans = 2; break
		i, j = i+1, j+1
	if ans < 0:
		if (i < w1 and j < w2 and s1[i] == s2[j]) \
		    or (i == w1 and j == w2): ans = k
		else: ans = 2
	print(s[ans])


Measured memory_bytes: 5592
def main():
    K=int(input())
    A,B=map(int,input().split())
    
    for i in range(1,1001):
        if A<=K*i and K*i<=B:
            print("OK")
            exit()
    
    print("NG")
    exit()

if __name__=="__main__":
    main()


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

int main() {
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    int max_x = X;
    int min_y = Y;
    int x,y;
    for(int i=0;i<N;i++) {
        cin >> x;
        if (max_x < x) max_x = x;
    }
    for(int i=0;i<M;i++) {
        cin >> y;
        if (min_y > y) min_y = y;
    }
    if(min_y > max_x) cout << "No War" << endl;
    else cout << "War" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <bitset>

#define ll long long

int main()
{
    ll N;
    std::cin >> N;

    std::map<ll, ll> mp;
    for(ll i=2; i*i <= N; i++) {
        if(N%i==0) {
            mp[i]++;
            N/=i;
            i--;
        }
    }

    if(N != 1) {
        mp[N]++;
    }

    ll ans =0 ;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
        //std::cout << itr->first << ", " << itr->second << std::endl;
        for(int i=1; itr->second>=i; i++) {
            //std::cout << itr->second << ", " << i << std::endl;
            ans++;
            itr->second -= i;
        }
        //std::cout << std::endl;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3632
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

A = int(sys.stdin.readline())
B = int(sys.stdin.readline())
C = int(sys.stdin.readline())
D = int(sys.stdin.readline())

ret = A if A < B else B
ret += C if C < D else D

print(str(ret))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main() {
	long long x, a, b;
	cin >> x;
	a = x / 11;
	if (x % 11 == 0) {
		b = 0;
	}
	else if(x % 11 <= 6){
		b = 1;
	}
	else {
		b = 2;
	}
	cout << a * 2 + b << endl;
	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

string s;
int n;

bool Rec(int i){
  static bool mem[100001];
  static bool usd[100001];
  if(i == n)return true;
  if(i > n)return false;
  if(usd[i])return mem[i];
  usd[i] = true;
  string t = s.substr(i,5);
  if(t == "dream" || t == "erase") mem[i] |= Rec(i+5);
  t = s.substr(i,6);
  if(t == "eraser") mem[i] |= Rec(i+6);
  t = s.substr(i,7);
  if(t == "dreamer") mem[i] |= Rec(i+7);
  return mem[i];
}

int main(){
  cin >> s;
  n = (int)s.size();
  cout << (Rec(0)?"YES":"NO") << endl;
  return 0;
}


Measured memory_bytes: 6832
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if((a>=1 && a<=9) && (b>=1 && b<=9)){
    printf("%d\n",a*b);
  }else{
    printf("-1\n");
  }
  return 0;
}

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

int main() {
  int N; // 都市の数
  int M; // 道の数
    
  cin >> N >> M;
  
  vector<int> road(N+1); // 都市Nに接続している道の数
  vector<int> city(2); // ある道がつなぐ2都市
  
  int i,j,k; //カウンタ変数
  
  for (i=0; i<M; i++) {
    cin >> city.at(0) >> city.at(1);
    for (j=1; j<=N; j++){
      if(city.at(0)==j){
        road.at(j) ++;
      }
      if(city.at(1)==j){
        road.at(j) ++;
      }
    }
  }
  
  for (k=1; k<=N; k++) {
    cout << road.at(k) << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int dl[]={-1,0,1,0};
int dc[]={0,1,0,-1};

int n,m,pa;
bool a[60][60];
char c;

int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
      cin>>c,
      a[i][j]=(c=='#');
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
      if(a[i][j]){
        pa=0;
        for(int d=0;d<4;d++)
          if(a[i+dl[d]][j+dc[d]])pa++;
        if(pa==0){
          cout<<"No\n";
          return 0;
        }
      }
    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

using vl   = vector<long long>;
using vvl  = vector<vl >;
using vvvl = vector<vvl >;

/*Binary Indexed Tree*/
template<typename Type>
struct BIT{//区間和クエリ（RSQ:Range Sum Query）をO(log N)で行う.
	int n;				//n:=(要素数).
	vector<Type> dat;	//i:=[1,n].
	
	/*constructor.*/
	BIT(int n_):n(n_),dat(n_+1,0){}
	BIT(const vector<Type> &v_):n(v_.size()),dat(v_.size()+1){
		copy(ALL(v_),dat.begin()+1);
		build();
	}
	
	void build(){//木を構築する. O(N).
		for(int i=1;i<n;++i){
			if(i+(i&-i)<=n) dat[i+(i&-i)]+=dat[i];
		}
	}
	void init(Type x=0){//全要素をxで初期化する. O(N).
		fill(dat.begin()+1,dat.end(),x);
		if(x==0) return;
		build();
	}
	void add(int i,Type x){//i番目の要素にxを足す. O(log N).
		assert(1<=i and i<=n);
		for(;i<=n;i+=(i&-i)) dat[i]+=x;
	}
	Type sum(int i){//[1,i]間の和を求める. O(log N).
		if(i<1 or n<i) return 0;
		Type res=0;
		for(;i>0;i-=(i&-i)) res+=dat[i];
		return res;
	}
	Type range_sum(int l,int r){//[l,r]間の和を求める(RSQ).
		if(l>r) return 0;
		return sum(r)-sum(l-1);
	}
};

int main(){
	llong n,x,m;
	cin>>n>>x>>m;
	
	vl v;
	vi seen(m,-1);//seen[i]:=(iが最初に出てくる順番).
	for(int i=1;;++i){
		v.push_back(x);
		seen[x]=i;
		x=x*x%m;
		if(seen[x]>=0) break;
	}
	
	BIT<llong> tree(v);
	
	llong ans=0LL;
	if(n<=v.size()) ans+=tree.range_sum(1,n);
	else{
		int range=v.size()-seen[x]+1;//ループ範囲の長さ.
		ans+=tree.range_sum(1,seen[x]-1);
		n-=seen[x]-1;
		ans+=tree.range_sum(seen[x],v.size())*(n/range);
		ans+=tree.range_sum(seen[x],seen[x]+n%range-1);
	}
	
	cout<<ans<<endl;
}

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

#define N 100000

int main(void){
    /*エラトステネスの篩*/
    bool prime[N+1];
    prime[0]=prime[1]=!false;
    for (size_t i = 2; i*i <= N; i++)if (!prime[i]) for (size_t j = 2; i*j <= N; j++) prime[i*j]=!false;
    /*累積和*/
    int likeCnt[N+1];
    for (size_t i = 3; i <= N; i+=2) likeCnt[i+1]=likeCnt[i]=likeCnt[i-1]+(!prime[i]&&!prime[(i+1)/2]);
    /*やるだけ*/
    int q;
    scanf("%d", &q);
    int l,r;
    for (size_t i = 0; i < q; i++)
    {
        scanf("%d%d", &l, &r);
        printf("%d\n", likeCnt[r] - likeCnt[l-1]);
    }
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

// 桁数を求めるプログラム
unsigned GetDigit(unsigned num)
{
  return log10(num) + 1;
}

int main() {
  int a, b, c;
  cin >> a >> b;
  c = a*pow(10, GetDigit(b)) + b;
  if(sqrt(c) == int(sqrt(c))) print("Yes");
  else print("No");
}


Measured memory_bytes: 256
#  --*-coding:utf-8-*--

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    
    B = [None]*N
    firstPos = {}
    lastPos = {}

    for p, a in enumerate(A):
        if a in lastPos:
            B[lastPos[a]] = p
            B[p] = firstPos[a]
        else:
            firstPos[a] = p
            B[p] = p

        lastPos[a] = p

    C = [None]*N
    for p, b in enumerate(B):
        c = (b - p)%N
        if c == 0:
            c = N

        C[p] = c + 1

    cycle = C[0]
    nextPos = cycle%N

    while nextPos != 0:
        cycle += C[nextPos]
        nextPos = (nextPos + C[nextPos])%N

    r = N*K%cycle
    ans = []

    while r > 0:
        while r >= C[(-r)%N]:
            r -= C[(-r)%N]

        if r > 0:
            ans.append(A[(-r)%N])
            r -= 1
        
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 66728
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

#include<bits/stdc++.h>
using namespace std;

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main(){
	NINJA;

	int a,b,c; cin >> a >> b >> c;
	if(a+b+c >=22) cout << "bust" << endl;
	else cout << "win" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>

using namespace std;

typedef long long ll;

namespace comb {
	ll fact[1000001];
	ll fact_inv[1000001];
	const ll MOD = 1000000007;

	ll modpow(ll a, ll b) {
		ll base = 1, kakeru = a;
		while (b > 0) {
			if (b & 1)base *= kakeru, base %= MOD;
			kakeru *= kakeru, kakeru %= MOD;
			b >>= 1;
		}
		return base;
	}

	void setup() {
		fact[0] = 1, fact[1] = 1;
		for (int i = 2; i <= 1000000; i++) {
			fact[i] = (fact[i - 1] * i) % MOD;
		}

		fact_inv[1000000] = modpow(fact[1000000], MOD - 2);

		for (int i = 999999; i >= 0; i--) {
			fact_inv[i] = fact_inv[i + 1] * (i + 1);
			fact_inv[i] %= MOD;
		}

	}

	ll combination(int a, int b) {
		if (a - b < 0)return 0;
		ll ret = fact[a];
		ret *= fact_inv[b], ret %= MOD;
		ret *= fact_inv[a - b], ret %= MOD;
		return ret;
	}

	ll permutation(int a, int b) {
		if (a - b < 0)return 0;
		ll ret = fact[a];
		ret *= fact_inv[a - b], ret %= MOD;
		return ret;
	}

	ll homogeneous(int a, int b) {
		return combination(a + b - 1, b);
	}

}

int main() {
	int X, Y;
	cin >> X >> Y;

	if ((X + Y) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}

	comb::setup();

	ll ans = 0;

	for (int i = 0; i <= X && i * 2 <= Y; i++) {
		int restX = X - i, restY = Y - 2 * i;
		if (restX != restY * 2) {
			continue;
		}
		ans += comb::combination(i + restY, i);
		ans %= comb::MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15872
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}


void solve(long long N, std::vector<std::string> S){
    char list[10][3]={
        {'M','A','R'},
        {'M','R','C'},
        {'M','C','H'},
        {'M','A','C'},
        {'M','A','H'},
        {'M','R','H'},
        {'A','R','C'},
        {'A','R','H'},
        {'A','C','H'},
        {'R','C','H'}
    };
    
    LL ans = 0;
    REP(i, 10){
        LL cnt[3] ={0,0,0};
        REP(j, 3){
            char coi = list[i][j];
            REP(k, N){
                if(S[k][0]==coi)cnt[j]++;
            }
        }
        ans+= cnt[0]*cnt[1]*cnt[2];
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 6144
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int H, W;
    cin >> H >> W;
    string *s;
    s = new string[H];
    for (int i = 0; i < H; i++)
    {
        cin >> s[i];
    }
    for (int i = 0; i < W + 2; i++)
    {
        cout << "#";
    }
    cout << endl;
    for (int i = 0; i < H; i++)
    {
        cout << "#" << s[i] << "#" << endl;
    }
    for (int i = 0; i < W + 2; i++)
    {
        cout << "#";
    }
    cout << endl;
    return 0;
}


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

int main()
{
  int L, R, d;
  cin >> L >> R >> d;

  vector<int> v;
  for (int i=L; i<=R; i++)
  {
    if (i % d == 0) {
      v.push_back(i);
    }
  }
  cout << v.size() << endl;
  return 0;
}

Measured memory_bytes: 3580
ls = list(map(int,input().split()))
n = ls[0]
y = ls[1]

for i in range(n+1):
  for j in range(n+1-i):
    k = n-i-j
    if 10000*i + 5000*j + 1000*k == y:
      print(str(i) + " " + str(j) + " " + str(k))
      exit()

print("-1 -1 -1")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<stdlib.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define prf pair<ld,ld>
#define vct vector<ll>
#define vpt vector<pr>
#define vcf vector<ld>
#define vpf vector<prf>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define all(x) x.begin(),x.end()
#define F(i, n) for(i = 0; i < (1LL*n); i++)
#define Fr(i, n) for(i = n - 1; i >= 0; i--)
 
struct custom_hash{
    static uint64_t splitmix64(uint64_t x){
        x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
 
void prv(vct v){for (ll i=0;i<v.size();i++)cout<<v[i]<<" ";cout << "\n";}
void prn(ll n){cout<<n<<"\n";}
void prs(string n){cout<<n<<"\n";}
void deb(string s, ll n){cout<<s<<" : "<<n<<"\n";}
void prmt(mat m){for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);}
 
mat getRzMat(ll m,ll n, ll ini=0){mat mt;mt.assign(m,vector<ll>(n,ini));return mt;}
 
ll poww(ll x, ll y, ll m){
    ll res = 1;
    while (y){
        if (y%2 == 0){x = (x * x) % m;y = y / 2;}
        else{res = (res * x) % m;y--;}
    }
    return res;
}
 
vct divsors(ll n){
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++){if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
mat mt;
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c, d, w;
ll mod = 1000000007;
ld epi = 0.00000001;
ll cas=0;
void solve(){
    
    cin>>n;
    ans=0;
    vct v(n,0);
    F(i,n)cin>>v[i];

    ll su=0;
    F(i,n)su+=v[i];

    su=su%mod;
    // prn(su);
    F(i,n){
        su-=v[i];
        if(su<0)su+=mod;
        ans=(ans+((v[i]*su)%mod))%mod;
    }
    prn(ans);

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout<<fixed<<setprecision(10);
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    ll t = 1;
    // cin >> t;
    cas=1;
    while (t--){
        solve();
        cas++;
    }
    return 0;
}
 


Measured memory_bytes: 4784
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        h: usize, a: usize,
    }
    println!("{}", (h + (a - 1)) / a);
}


Measured memory_bytes: 4352
import numpy as np

X, N = map(int, input().split())
if N == 0:
    p_list = [X]
else:
    p_list = np.array(list(map(int, input().split()))) - X
sorted_p_list = np.array(sorted(list(p_list)))
idx = np.abs(sorted_p_list).argmin()
p_list_kai = list(sorted_p_list)
tansaku_list = []
if p_list_kai[idx] == 0:
    hidari = idx - 1
    migi = idx + 1
    if hidari != -1:
        tansaku_list.append(p_list_kai[hidari])
    if migi != len(p_list_kai):
        tansaku_list.append(p_list_kai[migi])
    for i in range(1, 101):
        _i = i * (-1)
        if i in tansaku_list and _i in tansaku_list:
            migi += 1
            hidari -= 1
            if hidari != -1:
                tansaku_list.append(p_list_kai[hidari])
            if migi != len(p_list_kai):
                tansaku_list.append(p_list_kai[migi])
            continue
        elif i in tansaku_list:
            ans = X + _i
            break
        elif _i in tansaku_list:
            ans = X + i
            break
        else:
            ans = X + _i
            break
else:
    ans = X
print(ans)

Measured memory_bytes: 27212