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

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 3050;

int n;
double p[MAXN];
double dp[MAXN][MAXN];

int main() { 

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

  dp[0][1] = p[0];
  dp[0][0] = 1.0 - p[0];

  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= i + 1; j++) {
      dp[i][j] = dp[i - 1][j] * (1.0 - p[i]);
      if (j > 0) {
        dp[i][j] += dp[i - 1][j - 1] * p[i];
      }
    }
  }

  double ans = 0.0;
  for (int i = n / 2 + 1; i <= n; i++) {
    ans += dp[n - 1][i];
  }

  printf("%.12lf\n", ans);

  return 0;
}


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


bool finished(const vector<int> &v) {
	int N = v.size();
	for(int i = 0; i < N; ++i) {
		if(v[i] >= N) {
			return false;
		}
	}
	return true;
}

signed main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	int K = 0;
	while(!finished(a)) {
		int S = 0;
		for(int i = 0; i < N; ++i) {
			S += a[i] / N;
		}
		for(int i = 0; i < N; ++i) {
			a[i] = a[i] - a[i] / N * N + (S - a[i] / N);
		}
		K += S;
	}
	cout << K << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	s := fmt.Sprint(n)
	for i := 0; i < len(s); i++ {
		if s[i] != s[len(s)-1-i] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll W , a, b;
	cin >> W >> a >> b;
	if((a<=b&&b<=a+W)||(a<=b+W&&b+W<=a+W))cout<<0<<endl;
	else cout<<min(abs(b-a-W),abs(a-b-W))<<endl;	
}

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

int main(){
    int  n,x,t,time;
    cin >> n >> x >> t;
    
    if(n <= x) time = t;
    else{
        int bai = n / x;
        if(n % x == 0){
            time = bai * t;
            cout << time << endl;
            return 0;
        }
        time = (bai + 1) * t;
    }
    cout << time << endl;
}    

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
constexpr ll MOD = 1000000007;
int main(void){
  int n;
  cin >> n;
  vector<ll> a(n);
  RPT(i,0,n) cin >> a[i];
  ll ans = 0;
  vector<ll> ones(65,0);
  ll tmp = 1;
  RPT(i,0,62){
    FOR(j,0,n){
      if( ( (a[j]>>i)&1LL)==1 ) ones[i]++;
    }
    ones[i] = ones[i]*((ll)n-ones[i]) % MOD;
    ones[i] *= tmp;
    ones[i] %= MOD;
    ans += ones[i];
    ans %= MOD;
    tmp *= 2;
    tmp %= MOD;
  }
  /*
  FOR(i,0,n){FOR(j,i+1,n){
    ll tmp = (a[i]^a[j]) % MOD;
    ans += tmp;
    ans %= MOD;
  }
  }
  */
  cout << ans << endl;
  return 0;
}

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

int main()
{
    char c;
    cin>>c;

    if(c=='a'|| c=='e'|| c=='i'|| c=='o'|| c=='u')
    {
        cout<<"vowel"<<endl;
    }
    else
    {
        cout<<"consonant"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
#include<cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pii> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++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(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
ll mopow(ll a,ll x,ll mod){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}

int main(){
    int x;cin>>x;
    cout<<1-x<<endl;
    return 0;
}

Measured memory_bytes: 3576
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
ll n,k;
int main(){
    scanf("%lld%lld",&n,&k);
    n%=k;
    printf("%lld\n",min(n,k-n));
    return 0;
}

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

int main()
{
    int sz[2][5];
    int min=0;
    for(int i=0;i<5;i++)
    {
        cin>>sz[0][i];
        sz[1][i]=10-sz[0][i]%10;
        if(sz[1][i]==10)
            sz[1][i]=0;
        if(sz[1][i]>sz[1][min])
        {
            min=i;
        }
    }
/*
    for(int i=0;i<5;i++)
    {
        cout<<sz[0][i]<<" ";
    }
    cout<<endl;
    for(int i=0;i<5;i++)
    {
        cout<<sz[1][i]<<" ";
    }
    cout<<endl;
*/

    int ans=0;
    for(int i=0;i<5;i++)
    {
        if(i!=min)
        ans=ans+sz[0][i]+sz[1][i];
        else
            ans=ans+sz[0][i];
    }
    cout<<ans<<endl;
    return 0;
}

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

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

  int n;
  cin >> n;

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

  vector<int> b(n + 1), c(n + 1);

  for (int i = 1; i <= n; i++) {
    b[i] = i + a[i];
    c[i] = i - a[i];
  }

  sort(b.begin(),b.end());
  sort(c.begin(),c.end());

  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    int x = b[i];
    int cnt = upper_bound(c.begin(),c.end(), x) - lower_bound(c.begin(), c.end(), x);
    ans += cnt;
  }
  cout << ans << endl;
};

Measured memory_bytes: 5572
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;

int main() {
  P a[6];
  for(int i=0; i<6; i++) {
    cin >> a[i].F >> a[i].S;
    if(a[i].F>a[i].S) swap(a[i].F,a[i].S);
  }
  sort(a,a+6);
  for(int i=0; i<3; i++) {
    if(a[i*2]!=a[i*2+1]) {
      cout << "no" << endl;
      return 0;
    }
  }
  if(a[0].F==a[2].F&&a[0].S==a[4].F&&a[2].S==a[4].S) cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	ll a[n];
	for(ll i = 0;i < n;i++){
		cin >> a[i];
	}
	if(n == 2){
		cout << abs(a[1] - a[0]) << "\n";
		return 0;
	}
	ll b[n];
	b[n - 1] = 0;
	b[n - 2] = abs(a[n - 1] - a[n - 2]);
	for(ll i = n - 3;i >= 0;i--){
		b[i] = min(abs(a[i] - a[i + 1]) + b[i + 1],abs(a[i] - a[i + 2]) + b[i + 2]);
	}
	cout << b[0] << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>

template<long long sieve_N, long long prime_N>
struct primes
{
	bool sieve[sieve_N + 1];
	long long prime[prime_N + 1];
	long long counter = 0;
	constexpr primes() : sieve(), prime()
	{
		for (long long i = 2; i <= sieve_N; ++i)
		{
			sieve[i] = true;
		}
		sieve[0] = sieve[1] = false;
		for (long long i = 2; i <= sieve_N; ++i)
		{
			if (sieve[i])
			{
				prime[counter++] = i;
				if (counter > prime_N)
				{
					break;
				}
			}
			for (long long j = i * i; j <= sieve_N; j += i)
			{
				sieve[j] = false;
			}
		}
	}
};

primes<150000, 100000> P;

template<long long N>
struct like
{
  long long counts[N + 1];
  constexpr like() : counts()
  {
    counts[0] = 0;
    for (long long i = 1; i <= N; ++i)
    {
      counts[i] = counts[i - 1] + ((i & 1) && P.sieve[i] && P.sieve[(i + 1)/2] ? 1 : 0);      
    }
  }
};

like<150000> L;

int main()
{
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i)
  {
    int l, r;
    scanf("%d%d", &l, &r);
    printf("%lld\n", L.counts[r] - L.counts[l - 1]);
  }
  return 0;
}


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

ll solve(vector<ll> v,ll n,ll k){
	vector<ll> dp(n+1,MOD);
	dp[1]=0;
	for(int i=2;i<=k;i++){
		for(int j=1;j<i;j++){
			dp[i] = min(dp[i],abs(v[1]-v[i]));
		}
	}
	for(int i=k+1;i<=n;i++){
		for(int j=1;j<=k;j++){
			dp[i] = min(dp[i], dp[i-j] + abs(v[i]-v[i-j]));
		}
	}
	return dp[n];
}

int main()
{
	ll t=1;
	while(t--){
		ll n,k;
		cin >> n >> k;
		vector<ll> v(n+1,0);
		for(int i=1;i<=n;i++){
			cin >> v[i];
		}
		cout << solve(v,n,k) << endl;
	}
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

struct UnionFind
{
    vector< int > data;
    
    UnionFind(int sz){
        data.assign(sz, -1);
    }
    
    bool unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    
    int root(int k){
        if(data[k] < 0) return(k);
        return (data[k] = root(data[k]));
    }
    
    int size(int k){
        return -data[root(k)];
    }
};

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

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

    int w, h;
    cin >> w >> h;
    while(!(w==0 && h==0)){
        vector< vector<int> > c(h+2, vector<int>(w+2));
        REP(i, h) c[i][0] = 0;
        REP(i, h) c[i][w+1] = 0;
        REP(j, w) c[0][j] = 0;
        REP(j, w) c[h+1][j] = 0;
        FOR(i, 1, h+1)FOR(j, 1, w+1) cin >> c[i][j];

        int num = 10, unite = 0;
        UnionFind UF(500);
        FOR(i, 1, h+1)FOR(j, 1, w+1){
            int tmp = 0;
            if(c[i][j] == 0) continue;
            if(c[i][j] == 1) c[i][j] = ++num;
            for(auto y: dy)for(auto x: dx){
                if(x==1 && y==1) continue;
                if(c[i+y][j+x] == 0) continue;
                if(c[i+y][j+x] == 1){
                    c[i+y][j+x] = c[i][j];
                    tmp++;
                }else if(UF.root(c[i+y][j+x]) != UF.root(c[i][j])){
                    unite++;
                    UF.unite(c[i+y][j+x], c[i][j]);
                }
            }
        }

        //FOR(i, 1, h+1)FOR(j, 1, w+1) cout << c[i][j] << (j==w ? "\n":" ");

        cout << num - 10 - unite << "\n";
        cin >> w >> h;
    }
    return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int N; cin >> N;
  vector<int> T(N);
  int ans = 0;
  rep(i, N) {
    cin >> T[i];
    ans += T[i];
  }

  int M; cin >> M;
  vector<int> P(M), X(M);
  rep(i, M) {
    cin >> P[i] >> X[i];
  }
  rep(i, M) {
    cout << ans - (T[P[i]-1] - X[i]) << endl;
  }
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    a,b,c = MII()
    if a+b>=c: print('Yes')
    else: print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e6+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=1000001;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
//Lordvishnu@almighty
int main()
{
	
	ll int i,j,k,n,m;
     string s;
     cin>>s;
     k=0;
     for(i=0;i<s.size();i++)
     {
     	k+=(s[i]-'0');
     	k=k%9;
     }	
     if(!k)
    cout<<"Yes";
    else
    	cout<<"No";

	
	

}
//Lordvishnu@almighty

Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a[3];
  for(int i=0;i<3;i++) cin >> a[i];
  sort(a,a+3);
  int count=0;
  if((a[2]-a[1])%2!=0){
    a[1]++; a[0]++; count++;
    count += (a[2]-a[1])/2;
    a[1]=a[2];
  }else{
    count += (a[2]-a[1])/2;
    a[1]=a[2];
  }
  
  if((a[1]-a[0])%2!=0){
    a[1]++; count++;
    count += (a[1]-a[0])/2;
  }else{
    count += (a[1]-a[0])/2;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
#define MOD  1000000007

/*
    1D Matching
*/

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    int b[n];
    rep(i,n)cin >> b[i];
    sort(a, a+n);
    sort(b, b+n);
    ll ans = 1;
    int flag = 0;
    ll count = 0;
    int i = 0;
    int j = 0;

    while(true){
        if(i == n){
            if(j == n){
                break;
            }else{
                ans *= count;
                count--;
                j++;
            }
        }else if(j == n){
            ans *= count;
            count--;
            i++;
        }else if(a[i] < b[j]){
            if(count == 0){
                flag = 0;
                count++;
                i++;
            }else{
                if(flag == 0){
                    count++;
                    i++;
                }else{
                    ans *= count;
                    count--;
                    i++;
                }
            }
        }else{
            if(count == 0){
                flag = 1;
                count++;
                j++;
            }else{
                if(flag == 1){
                    count++;
                    j++;
                }else{
                    ans *= count;
                    count--;
                    j++;
                }
            }
        }
        ans %= MOD;
    }

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


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  vector<vector<int>> G(N);
  for (int a, b; cin >> a >> b;) {
    G.at(--a).push_back(--b);
    G.at(b).push_back(a);
  }
  // for (auto g : G) {
  //   for (auto a : g) cout << a << " ";
  //   cout << "\n"; 
  // } 
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (G.at(i).size() == 0) {
      ans++;
      continue;
    }
    int mx = H.at(i);
    for (auto g : G.at(i)) mx = max(mx, H.at(g));
    int cnt = 1;
    for (auto g : G.at(i)) if (H.at(g) == mx) cnt++;
    if (H.at(i) == mx && cnt == 1) ans++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 8716
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int x, a, b;
    cin >> x >> a >> b;

    if(abs(x - a) > abs(x - b)){
        cout << 'B' << endl;
    }else cout << 'A' << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;
double x;
double n;
double sum=1;
int main()
{
    scanf("%lf",&n);
    x=n/3;
    x=x*1000000;
    sum=sum*x*x/1000000*x/1000000/1000000;
    printf("%.12lf",sum);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;

int eraseOverlapIntervals(vector<pair<double,double>> &intervals)
{
    auto comp = [](const pair<double,double> &i1, const pair<double,double> &i2) { return i1.x < i2.x; };
    sort(intervals.begin(), intervals.end(), comp);
    int res = 0, pre = 0;
    for (int i = 1; i < intervals.size(); i++)
    {
        if (intervals[i].x < intervals[pre].y)
        {
            res++;
            if (intervals[i].y < intervals[pre].y)
                pre = i;
        }
        else
            pre = i;
    }
    return res;
}

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), l(n);
    vector<pair<double,double>> inter(n);
    rep(i, n)
    {
        cin >> x[i] >> l[i];
        inter[i] = make_pair(x[i] - l[i]+0.1 , x[i] + l[i]-0.1 );
    }
    int ans=eraseOverlapIntervals(inter);
    //rep(i,n){
       // cout<<inter[i].x<<" "<<inter[i].y<<endl;
    //}
    cout<<max(n-ans,0)<<endl;
}

Measured memory_bytes: 2560
n = int(input())
s = [int(input()) for _ in range(n)]
p = sum(s)
er = 10 ** 6
for i in range(n):
    if s[i] % 10 != 0:
        er = min(s[i], er)
if er == 10 ** 6:
    print(0)
elif p % 10 == 0:
    print(p - er)
else:
    print(p)

Measured memory_bytes: 3064
A, B, C, X, Y = map(int, input().split())
ans = 1 << 30
# ABピザを全探索して考える
for i in range(0, max(2*X,2*Y)+1, 2):
    x = X - i // 2
    y = Y - i // 2
    ans = min(ans, A * max(0,x) + B * max(0,y) + C * i)

print(ans)


Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int a = A;
  int b = B;
  int N = B - A;
  int sum = 0;
  
  // ここにプログラムを追記
  for (int i = 0; i <= N; i++) {
   if (a / 10000 == a % 10 && a / 1000 % 10 == a % 100 / 10) {
     sum +=1; 
   } 
     a += 1; 
  
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]

G = [1]
for i in range(N):
    G.append(A[G[-1]-1])
    
ans = 0
ok = False
for i in range(N+1):
    if G[i]==2:
        ok = True
        break
    ans += 1

if not ok:
    ans = -1
    
print(ans)

Measured memory_bytes: 13776
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7 ;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define vvv64 vector<vv32>
#define vvvv64 vector<vvv32>
 
ll exp(ll n, ll e)
{
    if (e==0)
        return 1;
    ll temp=exp((n*n)%MOD,e/2);
    return e%2==0 ? temp : (temp*n)%MOD;
}
void solve()
{
    ll n,d,a;
    cin>>n>>d>>a;
    vp64 arr(n+1);
    for (int i=1; i<=n; i++)
    {
        ll a,b;
        cin>>a>>b;
        arr[i].fi=a;
        arr[i].se=b;
        // updateRange(1,1,maxi,a,a,b);
    }
    sort(arr.begin()+1,arr.end());
    ll ans=0;
    ll sum=0;
    map<ll,ll> accu;
    map<ll,ll> health;
    for (int i=1; i<=n; i++)
    {
        health[arr[i].fi]=arr[i].se;
    }

    for (int i=1; i<=n; i++)
    {
        accu[arr[i].fi]=0;
    }
    for (auto it=accu.begin(); it!=accu.end(); it++)
    {
        sum+=it->se;
        if (health.find(it->first)!=health.end())
        {
            // cout<<sum<<" "<<health[it->first]<<endl;
            ll temp=health[it->first] - sum;
            if (temp>0)
            {
                ll count=(temp+a-1)/a;
                ans+=(temp+a-1)/a;
                sum+=count*a;
                accu[it->first + 2*d+1]-=count*a;
            }
        }
    }
    cout<<ans<<endl;
}
 
int main() {
    fast_cin();
    ll t=1;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 40832
N = int(input())
H = []
FIRST = []
for i in range(N):
    x,y,h = map(int,input().split())
    if h>=1 and not FIRST:
        FIRST.append([x,y,h])
    else:
        H.append([x,y,h])
        
H = FIRST + H

isok = False
for cx in range(101):
    for cy in range(101):
        notok = True
        top = -1
        for h in H:
            if top==-1:
                top = h[2] + abs(cx-h[0]) + abs(cy-h[1])
            elif h[2] != max([top-abs(h[0]-cx)-abs(h[1]-cy),0]):
                notok = False
                break
        if notok:isok = True
        if isok:break
    if isok:break
        
print(cx,cy,top)

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

//{ SFT
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builitin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end());
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
#define F first
#define S second
#define cauto (const auto &)
template <class A, class B>
using pii = vector<pair<A, B>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod1 = 1e9 + 7;
constexpr long long mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    int cnt = 0;

    int wa = gcd(a, b);
    int ans = wa;

    for (int i = 2; i * i <= wa; ++i)
    {
        if (ans % i == 0)
        {
            ++cnt;
            while (ans % i == 0)
            {
                ans = ans / i;
            }
        }
    }
    if (ans != 1)
    {
        ++cnt;
    }

    cout << cnt + 1 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int H,W;
  int N;
  cin >> H >> W >> N;

  int a[10010]={0};
  for(int i=1;i<=N;i++){
    cin >> a[i];
  }

  int dq[110][110]={0};
  int k=1;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(a[k]==0){
        k++;
      }
      dq[i][j]=k;
      a[k]--;
    }
  }
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(i%2==1){
        cout << dq[i][j];
      }else{
        cout << dq[i][W-j+1];
      }
      if(j!=W){
        cout << " ";
      }else{
        cout << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 384
import math

(a, b, h, m) = map(int, input().split())

pi = math.pi

mrad = 2 * pi * m / 60
mpos = (a * math.sin(mrad), a * math.cos(mrad))

hrad = 2 * pi * (h * 60 + m) / 720
hpos = (b * math.sin(hrad), b * math.cos(hrad))

ans = math.sqrt((mpos[0] - hpos[0]) ** 2 + (mpos[1] - hpos[1]) ** 2)
print(ans)


Measured memory_bytes: 9384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k,co=0;
    cin>>a>>b>>c;
    cin>>k;
    while(a>=b)
    {
        co+=1;
        b*=2;
    }
    while(b>=c)
    {
        co+=1;
        c*=2;
    }
    if(co<=k)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3576
h, w = [int(i) for i in input().split()]
n = int(input())
a = [int(i) for i in input().split()]

c = [[0]*w for _ in range(h)]

i, j = 0, 0
for k, l in enumerate(a):
    for _ in range(l):
        c[i][j] = str(k + 1)
        j += 1
        if j == w:
            j = 0
            i += 1

for i in range(h):
    if i % 2 == 1:
        c[i] = list(reversed(c[i]))

for i in c:
    print(" ".join(i))


Measured memory_bytes: 3828
#include <stdio.h>

int main(void)
{
	int b[6];
	
	scanf("%d %d %d", &b[0], &b[1], &b[2]);
	//printf("%d %d %d\n", b[0], b[1], b[2]);
	
	if (b[0] == 1 && b[1] == 1 || b[2] == 1) printf("Open\n");
	else printf("Close\n");
	
	return (0);
}

Measured memory_bytes: 584
import numpy as np

N = int(input())
A = list(map(int, input().split()))

A = np.array(A)
L = np.sum(A)

l=0
ans = -1

for i in range(N):
    l += A[i]
    if l == L/2:
        ans = 0
        break
    elif l > L/2:
        Am = A[i]
        break

if ans < 0:
    L2 = L - l
    L1 = l - Am
    ans = int(min(L1+Am-L2, L2+Am-L1))

print(ans)

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

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var param = ReadLine().Split(' ').Select(int.Parse).ToArray();
    var n = param[0];
    var q = param[1];
    var s = ReadLine().ToCharArray();

    var table = new int[n];
    for(var i = 0; i < n-1; i++)
    {
      table[i+1] = table[i];
      if(s[i] == 'A' && s[i+1] == 'C')
      {
        table[i+1]++;
      }
    }

    var ans = Enumerable.Range(0, q).Select( i =>
      {
        var lr = ReadLine().Split(' ').Select(int.Parse).ToArray();
        return table[lr.Last()-1] - table[lr.First()-1];
      }
    ).ToArray();

    WriteLine(String.Join("\n", ans));
  }
}

Measured memory_bytes: 21816
//Binaty Tree
#include <iostream>
#include <algorithm>

using namespace std;

static const int MAX = 10000;
static const int NIL = -1;

struct Node {
    int parent = NIL, left = NIL, right = NIL;
};

Node N[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
    if(u == NIL) return;
    D[u] = d;
    setDepth(N[u].left, d+1);
    setDepth(N[u].right, d+1);
}

int setHeight(int u) {
    int h1 = 0, h2 = 0;
    if(N[u].left != NIL)
        h1 = setHeight(N[u].left) + 1;
    if(N[u].right != NIL)
        h2 = setHeight(N[u].right) + 1;
    H[u] = max(h1, h2);
    return H[u];
}

int getDegree(int u) {
    return (N[u].left != NIL) + (N[u].right != NIL);
}

int getSibling(int u) {
    if(N[u].parent == NIL) return NIL;
    if(N[N[u].parent].left != u && N[N[u].parent].left != NIL)
        return N[N[u].parent].left;
    if(N[N[u].parent].right != u && N[N[u].parent].right != NIL)
        return N[N[u].parent].right;
    return NIL;
}

int main() {
    int id, left, right;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> id >> left >> right;
        N[id].left = left;
        N[id].right = right;
        if(left != NIL) N[left].parent = id;
        if(right != NIL) N[right].parent = id;
    }

    int root;
    for(int i=0; i<n; i++)
        if(N[i].parent == NIL) root = i;

    setDepth(root, 0);
    setHeight(root);

    for(int i = 0; i < n; i++) {
        cout << "node " << i
             << ": parent = " << N[i].parent
             << ", sibling = " << getSibling(i)
             << ", degree = " << getDegree(i)
             << ", depth = " << D[i]
             << ", height = " << H[i];
        if(N[i].parent == NIL) cout <<", root" << endl;
        else if(getDegree(i) == 0) cout << ", leaf" << endl;
        else cout << ", internal node" << endl;
    }
}


Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans, N;
ll X[100005], L[100005];


int main(void) {
    scanf("%d", &N);
    rep(i, 0, N) scanf("%lld %lld", &X[i], &L[i]);

    vector<pair<ll, ll> > p;
    rep(i, 0, N) {
        p.pb(mp(X[i]+L[i], X[i]-L[i]));
    }
    sort(p.bg, p.en);

    ll t = -10000000000;
    rep(i, 0, N) {
        if (t <= p[i].second) {
            ans++;
            t = p[i].first;
        }
    }

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

	return 0;
}


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

bool Ok(vector<pair<char, char> >& Q, string& N, int cur) {
  int n = N.size(), n_q = Q.size();
  for (int i = 0; i < n_q; i++) {
    if (Q[i].first == N[cur]) {
      cur += (Q[i].second == 'L') ? -1 : 1;
    }
    if (cur < 0 || cur >= n) {
      return true;
    }
  }
  return false;
}

int SearchLeft(vector<pair<char, char> >& Q, string& N) {
  int left = 0, right = N.size();
  while (left < right - 1) {
    int mid = (left + right) / 2;
    if (Ok(Q, N, mid)) {
      left = mid;
    }
    else {
      right = mid;
    }
  }
  return left;
}

int SearchRight(vector<pair<char, char> >& Q, string& N) {
  int left = 0, right = N.size();
  while (left < right - 1) {
    int mid = (left + right) / 2;
    if (Ok(Q, N, mid)) {
      right = mid;
    }
    else {
      left = mid;
    }
  }
  return left;
}
int main() {
  ios::sync_with_stdio(false);
  int n, q;
  string N;
  vector<pair<char, char> > Q;
  cin >> n >> q >> N;
  for (int i = 0; i < q; i++){
    char l, r;
    cin >> l >> r;
    Q.push_back(make_pair(l, r));
  }
  int left = SearchLeft(Q, N);
  int right = SearchRight(Q, N);
  if (left >= right) {
    cout << 0;
  }
  else {
    if (Ok(Q, N, right)) {
      cout << right - left - 1;
    }
    else {
      cout << right - left;
    }
     
  }
  return 0;
}



Measured memory_bytes: 1100
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;
    cin >> n >> x;
    if(x==1||x==2*n-1){
        puts("No");
        return 0;
    }
    vint ans(2*n-1);
    if(n==2){
        REP(i,3){
            ans[i] = i+1;
        }
    }else{
        if(x<=n){
            ans[n-1]=x;
            ans[n-3]=x+1;
            ans[n-2]=x-1;
            ans[n]=x+2;
            int now = 1;
            REP(i,n-3){
                if(now==x-1){
                    now=x+3;
                }
                ans[i]=now;
                now++;
            }
            for(int i=n+1;i<2*n-1;++i){
                if(now==x-1){
                    now=x+3;
                }
                ans[i]=now;
                now++;
            }
        }else{
            ans[n-1]=x;
            ans[n-3]=x-2;
            ans[n-2]=x+1;
            ans[n]=x-1;
            int now = 1;
            REP(i,n-3){
                ans[i]=now;
                now++;
                if(now==x-2){
                    now=x+2;
                }
            }
            for(int i=n+1;i<2*n-1;++i){
                ans[i]=now;
                now++;
                if(now==x-2){
                    now=x+2;
                }
            }
        }
        
    }
    cout << "Yes\n";
    REP(i,2*n-1){
        cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <vector>

struct edge {
  int32_t parent;
  int32_t child;
  int32_t id;
  edge() : parent(0), child(0), id(0) {}
  edge(int32_t p, int32_t c, int32_t id) : parent(p), child(c), id(id) {}
};

using node_col_type = std::pair<int32_t, int32_t>;

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

  int32_t N;
  std::cin >> N;
  std::vector<std::vector<edge>> graph(N);
  int32_t k = 0;
  for(int32_t i = 0; i< N - 1; i++){
    int32_t a, b;
    std::cin >> a >> b;
    graph[a-1].push_back(edge(a-1, b-1, i));
    graph[b-1].push_back(edge(b-1, a-1, i));
    k = std::max(k, (int32_t)graph[a-1].size());
    k = std::max(k, (int32_t)graph[b-1].size());
  }

  std::queue<node_col_type> nodeq;
  nodeq.push(std::make_pair(0,0));
  int32_t edge_color[N-1] = {};
  while(!nodeq.empty()){
    //pop
    node_col_type node = nodeq.front();
    nodeq.pop();

    int32_t col = node.second;
    //coloring
    for (auto edge : graph[node.first]){
      int32_t next_node = edge.parent == node.first ? edge.child : edge.parent;
      if (edge_color[edge.id] == 0){
        col = col >= k ? 1 : col + 1;
        edge_color[edge.id] = col;
        nodeq.push(std::make_pair(next_node,col));
      }
    }
  }

  std::cout << k << std::endl;
  for (int32_t i = 0; i < N - 1; i++){
    std::cout << edge_color[i] << std::endl;
  }


  return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF const ll INF = 1001001001;
#define PI const ld PI = 3.14159265358979323846;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<vector<long long>> comb(int n, int r) {
  vector<vector<long long>> v(n + 1,vector<long long>(n + 1, 0));
  ll div=(ll)powl(10,9)+7;
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k])%div;
    }
  }
  return v;
}
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    ll N,M;
    cin >> N>>M;
    //pairの書き換えが煩雑であるので、素数リストと指数連想配列に分ける
   map<ll,ll> prime_count;
   vector<ll> prime_list;
   
    //resに素数のペア(素数、その素数の指数）の配列が入る
    const auto  &res = prime_factorize(M);
    
   rep(i,res.size()){
       if(prime_count[res[i].first]==0){
           prime_list.push_back(res[i].first);
       }
       prime_count[res[i].first]+=res[i].second;
   }
   // 前処理
    COMinit();
    

    ll ans=1;
    rep(i,prime_list.size()){
        ans*=COM(N+prime_count[prime_list[i]]-1,N-1);
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12160
N = int(input())
A = list(map(int, input().split()))
Alice = []
Bob = []
A.sort(reverse=True)

for i in range(N):
    if i%2 == 0:
        Alice.append(A[i])
    elif i%2 == 1:
        Bob.append(A[i])

ans = sum(Alice) - sum(Bob)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <utility>
#define ll long long
using namespace std;

ll coin[100010][3];
int choice[100010];
priority_queue<pair<ll, int>> xy, xz, yz;

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	for(int i=0; i<X+Y+Z; ++i){
	    cin >> coin[i][0] >> coin[i][1] >> coin[i][2];
	    xy.push(make_pair(coin[i][1]-coin[i][0], i));
	}
	for(int i=0; i<Y; ++i){
	    choice[xy.top().second]=1;
	    xy.pop();
	}
	for(int i=0; i<X+Y+Z; ++i){
	    if(choice[i]==1) yz.push(make_pair(coin[i][2]-coin[i][1], i));
	    else xz.push(make_pair(coin[i][2]-coin[i][0], i));
	}
	for(int i=0; i<Z; ++i){
	    while(choice[xy.top().second]>0) xy.pop();
	    while(choice[xz.top().second]>0) xz.pop();
	    if(xy.top().first+yz.top().first<xz.top().first){
	        choice[xz.top().second]=2;
	        xz.pop();
	    }
	    else{
	        choice[yz.top().second]=2;
	        yz.pop();
	        int h=xy.top().second;
	        choice[h]=1;
	        yz.push(make_pair(coin[h][2]-coin[h][1], h));
	        xy.pop();
	    }
	}
	ll ans=0;
	for(int i=0; i<X+Y+Z; ++i) ans += coin[i][choice[i]];
	cout << ans << endl;
	return 0;
}


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

int main() {
  int p, q, r;
  cin >> p;
  cin >> q;
  cin >> r;
  if (p > q) {
    if (p > r) {
      cout << q + r << endl;
    } else {
      cout << p + q << endl;
    }
  } else {
    if (q > r) {
      cout << p + r << endl;
    } else {
      cout << p + q << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[][]			np  = new int[5][4001];
		int				num = -1;
		int				max = -1;
		Stack<Integer>	stk = new Stack<Integer>();

		np[0][0] = 1;

		while((num = parseNum()) != -1) {
			max = Math.max(max, num);
			stk.push(num);
		}

		if (stk.size() > 0) {
			for(int i = 1;i <= 4;i++){
				for(int j = 0;j <= max;j++){
					for(int k = 0;k <= 1000 && j-k >= 0;k++){
						np[i][j] += np[i-1][j-k];
					}
				}
			}

			for (int i = 0; i < stk.size(); i++) {
	            System.out.println(np[4][stk.get(i)]);
			}
		}
	}

	private static int parseNum() {
		int		param = -1;
		String	strin = null;

		if ((strin = parseStdin()) != null) {
			param = Integer.parseInt(strin);
		}
 
		return param;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 20876
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD (100000009)
#define INF (100000009)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

string s[MAXN];

unordered_map <string,map <char,int>> mp;
map <map<char,int>,int> cts;

ll C(ll x)
{
	return (x*(x-1))/2;
}

void add(string a)
{
	map <char,int> ct;
	for (int i = 0; i < a.size(); ++i)
		ct[a[i]]++;

	mp[a] = ct;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> s[i];
		add(s[i]);
	}

	for (auto str:mp)
		cts[str.second]++;
	ll res = 0;
	for (auto t:cts)
		res += C(t.second);

	cout << fixed << res << endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int N; cin >> N;
    map<string, int> mp;
    rep(i, N) {
      string s; cin >> s;
      mp[s]++;
    }
    int ma = 0;
    vector<string> vs;
    for(auto it = mp.begin(); it != mp.end(); it++) {
      ma = max(ma, it->se);
    }
    for(auto it = mp.begin(); it != mp.end(); it++) {
      if (it->se == ma) vs.pb(it->fi);
    }
    sort(all(vs));
    rep(i, vs.size()) cout << vs[i] << endl;
    return 0;
}

Measured memory_bytes: 25584