akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    vector<int> two_pow(60, 1);
    REP(i, 60) two_pow[i] = two_pow[i - 1] * 2;
    int ans = 0;
    rep(i, 60) {
        int cnt = 0;
        rep(j, N) {
            if (A[j] & two_pow[i]) ++cnt;
        }
        cnt *= N - cnt;
        cnt %= 1000000007;
        ans += two_pow[i] % 1000000007 * cnt % 1000000007;
        ans %= 1000000007;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
    long long  a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    
    long long cnt1 = 0;
    long long tx = x, ty = y;
    cnt1 += min(tx, ty) * 2 * c;
    long long tmp = min(tx, ty);
    tx -= tmp;
    ty -= tmp;
    if(tx > 0){
        cnt1 += tx * a;
    }else if(ty > 0){
        cnt1 += ty * b;
    }
    long long cnt2 = 0;
    tx = x, ty = y;
    cnt2 += max(tx, ty) * 2 * c;
    tmp = max(tx, ty);
    tx -= tmp;
    ty -= tmp;
    if(tx > 0){
        cnt2 += tx * a;
    }else if(ty > 0){
        cnt2 += ty * b;
    }

    long long cnt3 = 0;
    cnt3 = a * x + b * y;
    cout << min(cnt1, min(cnt2, cnt3)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,k,q,a[100005]={},s[100005]={},poz;
    cin>>n>>k>>q;

    for(int i=1;i<=q;i++){
        cin>>poz;
        a[poz]++;
    }
    for(int i=1;i<=n;i++){
        if(k-(q-a[i])>0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}
int n,u,v;
vector<int> tree[100001];
int ne;
vector<int> ut(1000001,0);
vector<int> vt(1000001,0);



void dfs(int t,int pare,int deep,int w){
    deep++;
    for(int i=0;i<tree[t].size();i++){
        if(tree[t][i]!=pare){
            if(w==0){
                vt[tree[t][i]]=deep;
                dfs(tree[t][i],t,deep,w);
            }else{
                ut[tree[t][i]]=deep;
                dfs(tree[t][i],t,deep,w);
            }
        }
    }

}


int main(){
    cin>>n>>u>>v;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    vector<int> ao(n);
    vector<int> ta(n);

    dfs(v,-1,0,0);
    dfs(u,-1,0,1);

    int h = 0;
    int hl=0;
    for(int i=1;i<=n;i++){
        if(ut[i]<=vt[i]&&i!=v){
            if(hl<vt[i]){
                h=i;
                hl=vt[i];
            }

        }
    }

    if(h==0){
        cout<<0<<endl;
        return 0;
    }
//    cout<<h<<endl;
//    cout<<vt[h]<<endl;
    cout<<vt[h]-1<<endl;







return 0;
}


Measured memory_bytes: 20736
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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

string in;
int pos;
bool over;

void check(PI&p){
  over|=p.F>10000 || p.S>10000 || p.F<-10000 || p.S<-10000;
}


PI operator*(const PI&l,const PI&r){
  PI ret=mp(l.F*r.S+r.F*l.S,l.S*r.S-l.F*r.F);
  check(ret);
  return ret;
}

PI operator+(const PI&l,const PI&r){
  PI ret=mp(l.F+r.F,l.S+r.S);
  check(ret);
  return ret;
}

PI operator-(const PI&l,const PI&r){
  PI ret=mp(l.F-r.F,l.S-r.S);
  check(ret);
  return ret;
}

void pr(const PI&ans){
  if(over)cout<<"overflow"<<endl;
  else{
    if(ans.S){
      cout<<ans.S;
      if(ans.F>0)cout<<'+';
    }
    if(ans.F){
      cout<<ans.F<<'i';
    }
    if(ans.F==0 && ans.S==0)cout<<0;
    cout<<endl;
  }
}

PI expr();

PI getnum(){
  if(in[pos]=='i'){
    ++pos;
    return mp(1,0);
  }
  PI ret=mp(0,0);
  bool minus=false;
  if(in[pos]=='-'){
    minus=true;
    ++pos;
  }else if(in[pos]=='+'){
    minus=false;
    ++pos;
  }
  while(pos<in.size() && isdigit(in[pos])){
    ret.S=ret.S*10+in[pos++]-'0';
    check(ret);
  }
  return ret;
}

PI expr(){
  PI ret;
  if(in[pos]=='('){
    ++pos;
    ret=expr();
  }else{
    ret=getnum();
  }
  deque<PI> st;
  st.pb(ret);
  deque<char> op;

  while(pos<in.size() && in[pos]!=')'){
    char cop=in[pos];
    ++pos;
    PI tt;
    if(in[pos]=='('){
      ++pos;
      tt=expr();
    }else tt=getnum();
    
    switch(cop){
    case '+':
      op.pb(cop);
      st.pb(tt);
      break;
    case '-':
      op.pb(cop);
      st.pb(tt);
      break;
    case '*':
      ret=st.back()*tt;
      st.pop_back();
      st.pb(ret);
      break;
    }
  }

  ret=st.front();st.pop_front();

  while(!st.empty()){
    char cop=op.front();op.pop_front();
    PI tt=st.front();st.pop_front();
    if(cop=='+')ret=ret+tt;
    else ret=ret-tt;
  }
  ++pos;
  return ret;
}


main(){
  while(cin>>in){
    over=pos=0;
    PI ans=expr();
    check(ans);
    pr(ans);
  }
}

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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;


int main() {
    fast;
    cin.tie(0);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w" , stdout);
#endif*/
    lld i, n, m;
    cin >> n >> m;
    lld a[m];
    lld sum = 0;
    for (i = 0; i < m; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum > n) {
        cout << "-1" << endl;
    }
    else {
        cout << n - sum << endl;
    }
}

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

int main(){
	int n;
	int taro=0,hanako=0;
	string T,H;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> T >> H;
		if(T>H) taro+=3;
		else if(H>T) hanako+=3;
		else{
			taro++; hanako++;
		}
	}
	cout << taro << " " << hanako <<endl;
	return 0;
}


Measured memory_bytes: 3172
#pragma warning(disable:4996)；
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <new>
#include <set>
#include <map>

using namespace std;

typedef long long int LL;
const double pi = (acos(-1));
const int maxn = 1000;
int link[maxn], g[maxn][maxn];
bool used[maxn];
int nx, ny, n, m;
int bx[1005],by[1005],rx[1005],ry[1005];

bool dfs (int u) {
	for (int v = 1; v <= ny; v++) {
		if (!used[v] && g[u][v]) {
			used[v] = true;
			if (link[v] == -1 || dfs (link[v])) {
				link[v] = u;
				return true;
			}
		}
	}
	return false;
}

int maxmatch () {
	int res = 0;
	memset (link, -1, sizeof (link));//link[i]=-1表示i不在匹配中，否则(link[i],i)这条边在匹配中
	for (int i = 1; i <= nx; i++) {
		memset (used, false, sizeof (used));
		if (dfs (i)) res++;
	}
	return res;
}

int main()
{
	//freopen("D:\\Test_in.txt", "r", stdin);
	//freopen("D:\\Test_out.txt", "w", stdout);
	scanf ("%d", &n);
		nx = ny = n;
		for(int i=1;i<=n;i++)
        {
            scanf("%d%d", &rx[i], &ry[i]);
        }
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d", &bx[i], &by[i]);
        }
		memset (g, 0, sizeof (g));
		for (int i = 1; i <= n; i++) {
			for(int j=1;j<=n;j++)
			{
			    if(rx[i]<bx[j] && ry[i]<by[j])
                {
                    g[i][j]=1;
                }
			}
		}
		printf ("%d\n", maxmatch ());
	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#define int unsigned long long
using namespace std;

int gcd(int a,int b){
	if(a < b) swap(a,b);
	while(b){
		a %= b;
		swap(a,b);
	}
	return a;
}

int lcm(int a,int b){
	return a / gcd(a,b) * b;
}

signed main(){
	int n;
	while(cin >> n,n){
		int d[10],v[10],ld = 1,lv = 1;
		for(int i = 0;i < n;i++) {
			cin >> d[i] >> v[i];
			ld = lcm(ld,d[i]);
			lv = lcm(lv,v[i]);
		}
		for(int i = 0;i < n;i++) {
			if(!i) lv = ld / d[i] * v[i];
			else lv = gcd(lv,ld / d[i] * v[i]);
		}
		for(int i = 0;i < n;i++) cout << ld / d[i] * v[i] / lv << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
/**
 *    Author:  "Robin Singh" !!!
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0
#define rtn return 
#define nl "\n"      // avoid endl
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const ll INF = (1LL<<61);
const int inf = (1<<30);
//-------------------------------------------------------------------------------------------------------------
#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }
//-------------------------------------------------------------------------------------------------------------

int cnt[100005];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    
    // 2 possibility : (num % k) == 0, for all a,b,c
    // (a + b) % k == 0 => a%k + b%k == 0 or k, for the triplet, a%k must be 0 or k/2
    // k/2 only in even as in odd k/2 + k/2 != k
    
    ll x = n/k;           // cnt of num % k == 0
    ll ans = x * x * x;
    
    if(k % 2 == 0 && n >= k/2){
        // cnt of num % k == k/2,
        // k/2, k/2 + k, k/2 + 2*k ..
        // k/2 + x*k <= n,  cnt = 0...x
        x  = (n - k/2)/k + 1;
        ans += x * x * x;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    long long N;
    cin>>N;
    vector<string> S(N);
    
    for(long long i=0;i<N;i++)
    {
      cin>>S[i];
    }
    //ソート
    sort(S.begin(),S.end());
    //重複削除
    S.erase(unique(S.begin(),S.end()),S.end());
    
    cout<<S.size()<<endl;  
    
    return 0;
}

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

int main(void)
{
	long long  n, a;
	long long count = 0;
	long long  maxans;
	long long  minans;
	long long  sum = 0;
	cin >> n;
	do{
		cin >> a;
		
		if(count == 0){
			maxans = a;
			minans = a;
		}
		maxans = max(a, maxans);
		minans = min(a, minans);
		sum += a;
		count++;
	} while (n > count);

	cout << minans << ' ' << maxans << ' ' << sum << endl;

	return 0;
}

Measured memory_bytes: 1156
{-# LANGUAGE BangPatterns, OverloadedStrings #-}

import Control.Monad
import Data.Array.Unboxed
import Data.Bits
import Data.Char
import Data.Coerce
import Data.Function
import Data.Int 
import Data.IORef
import Data.List
import Data.Maybe
import qualified Data.Map.Strict as M
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  n <- getInt
  xs <- getIntList
  let (a:as) = reverse $ sort xs
  print . sum . take (n-1) $ a : concatMap (\x -> [x, x]) as
  
  
  

-- Input

getInt :: IO Int
getInt = readLn

second :: (b -> c) -> (a, b) -> (a, c)
second f (a, b) = (a, f b)

readInt :: BS.ByteString -> Maybe (Int, BS.ByteString)
readInt = fmap (second BS.tail) . BS.readInt

getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

getIntegerList :: IO [Integer]
getIntegerList = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

getIntPair :: IO (Int, Int)
getIntPair = do
  v <- getIntVec 2
  return (v V.! 0, v V.! 1)

-- Search

bisearch :: (Int -> Bool) -> (Int, Int) -> (Int, Int)
bisearch check = bis
  where
    bis (l, r)
      | l + 1 == r = (l, r)
      | check mid  = bis (mid, r)
      | otherwise  = bis (l, mid)
      where
        mid = l + (r - l) `div` 2

-- Modular Arithmetic
--
 
modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined
---
 
exEuclid :: (Eq a, Integral a) => a -> a -> (a, a, a)
exEuclid !f !g = loop 1 0 0 1 f g
  where loop !u0 !u1 !v0 !v1 !f 0 = (f, u0, v0)
        loop !u0 !u1 !v0 !v1 !f g =
          case divMod f g of
            (q,r) -> loop u1 (u0 - q * u1) v1 (v0 - q * v1) g r
 
recipM :: Int64 -> Int64
recipM !x = case exEuclid x modulo of
             (1,a,_) -> a `mod` modulo
             (-1,a,_) -> (-a) `mod` modulo
divM :: Int64 -> Int64 -> Int64
divM !x !y = x `mulMod` recipM y
 
instance Fractional N where
  (/) = coerce divM
  recip = coerce recipM
  fromRational = undefined

Measured memory_bytes: 35416
#include <bits/stdc++.h>
#define rep( i, begin, end) for( int i = begin; i < end; i++ )
using namespace std;
 
struct coverage {
    double x1, x2, y1, y2;
    coverage( double x1, double x2, double y1, double y2 ) : x1( x1 ), x2( x2 ), y1( y1 ), y2( y2 ) { }
};

bool confirm( const coverage &region1, const coverage &region2 )
{
    return( region1.x1 < region2.x2 && region2.x1 < region1.x2 && region1.y1 < region2.y2 && region2.y1 < region1.y2 );
}
 
int main() {
    int n, order = 0;
    double x, y, r, area;
    while( cin >> n ) {
        if( n == 0 )
            break;
        vector<coverage> square;
        vector<double> sx, sy;
        rep ( i, 0, n ) {
            cin >> x >> y >> r;
            square.push_back( coverage( x - r, x + r, y - r, y + r) );
            sx.push_back( x - r );
            sx.push_back( x + r );
            sy.push_back( y - r );
            sy.push_back( y + r );
        }
        area = 0;
        sort( sx.begin(), sx.end() );
        sort( sy.begin(), sy.end() );
 
        int a, b, c, flag;
        for( a = 0; a < sx.size() - 1; a++ )
            for( b = 0; b < sy.size() - 1; b++ )
                for( c = flag = 0; c < square.size(); c++) {
                    if( confirm( square[c], coverage( sx[ a ], sx[ a + 1 ], sy[ b ], sy[ b + 1 ] ) ) )
                        if( flag == 0 ) {
                            area += ( sx[ a + 1 ] - sx[ a ] ) * ( sy[ b + 1 ] - sy[ b ] );
							flag++;
						}
                }
        cout << ++order << " " << fixed << setprecision(2) << area << endl;
    }
    
    return 0;
}

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

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

    int a, b, n = 0;
    cin >> a >> b;
    if (a < b)
    {
        rep(i, b) n += a * pow(10, i);
    }
    else
    {
        rep(i, a) n += b * pow(10, i);
    }
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    int x;
    cin>>x;
    cout<<(x==7||x==5||x==3 ? "YES" : "NO")<<endl;
}


Measured memory_bytes: 256
N, *C = $<.read.split.map(&:to_i)

C << 0
s, i, h = [nil]*N+[0,1], -1, Hash.new(-2)
until (i+=1) == N
	next s[i] = s[i-1] if C[i] == C[i-1]
	s[i] = (s[i-1] + s[h[C[i]]]) % 1000000007
	h[C[i]] = i
end
p s[N-1]


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

int main() {
  string n;
  cin >> n;
  for(int i = 0; i < 3; i++){
    char c = n.at(i);
    if(c == '1')
      cout << 9;
    else if(c == '9')
      cout << 1;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
ll n;
vi num;
ll rui[222222];
bool check(ll po){
  ll sum=rui[po+1];
  for(int i=po+1;i<n;i++){
    if(sum*2<num[i])return false;
    sum+=num[i];
  }
  return true;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  num.resize(n);
  for(int i=0;i<n;i++)cin>>num[i];
  sort(ALL(num));
  for(int i=0;i<n;i++)rui[i+1]+=rui[i]+num[i];
  ll le=-1,ri=n;
  while(ri-le>1){
    ll mid=(le+ri)/2;
    //cout<<le<<" "<<ri<<" "<<mid<<endl;
    if(check(mid)){
      ri=mid;
    }else{
      le=mid;
    }
    //cout<<le<<" "<<ri<<" "<<mid<<endl<<endl;
  }
  cout<<n-ri<<endl;
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
  if(A<=12) B/=2;
  if(A<=5) B=0;
    cout << B << endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	string S;
	cin >> S;
	int a;
	REP(i, S.length())
	{
		if (S[i] == '+')a++;
		if (S[i] == '-')a--;
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
n, h = gets.chomp.split(' ').map(&:to_i)
arr1 = []
arr2 = []
n.times do
  a, b = gets.chomp.split(' ').map(&:to_i)
  arr1 << a
  arr2 << b
end
arr1.sort!
arr1.reverse!
arr2.sort!
arr2.reverse!
k1 = arr1.first
count = 0
arr2.each do |i|
  break if k1 >= i || h <= 0
  h -= i
  count += 1
end
if h <= 0
  puts count
else
  count += h % k1 == 0 ? h / k1 : h / k1 + 1
  puts count
end

Measured memory_bytes: 4568
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S[110];
    int t[110];
    rep(i, N) cin >> S[i] >> t[i];
    string T; cin >> T;
    bool flag = false;
    int ans = 0;
    rep(i, N) {
        if (flag) ans += t[i];
        if (S[i] == T) flag = true;
    }
    cout << ans << endl;

    return 0;
}


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

int main(void){
	int n;
	while(cin>>n,n){
	valarray<int> a(n);
		for(int i=0;i<n;i++)cin>>a[i];
		cout<<(a.sum()-a.max()-a.min())/(a.size()-2)<<endl;
	}
}

Measured memory_bytes: 3088
import sys
N = int(input())
A = list(map(int, input().split()))
B = []
C = 0
try:
    for i in range(N):
        if A[i] >= A[i + 1]:
            None
        else:
            B.append(A[C:i+1])
            C = i+1
except:
    try:
        if A[-2] >= A[-1]:
            B.append(A[C:])
        else:
            B.append(A[C:-1])
    except:
        print(0)
        sys.exit()
X = [len(B[j]) for j in range(len(B))]
print(max(X)-1)


Measured memory_bytes: 18020
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

// 文字列s内に文字列tがいくつ含まれるか
int count(string s, string t) {
  int size_s = s.size();
  int size_t = t.size();
  if (size_s < size_t) return 0;
  int ret = 0;
  for (int i = 0; i < size_s - size_t + 1; i++) {
    if (s.substr(i, size_t) == t) ret++;
  }
  return ret;
}

void solve() {
  string s; cin >> s;
  int k = s.size();
  int win = count(s, "o");

  if (15 - k + win >= 8) YES();
  else NO();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 380
def solve():
    a=-1;b=-1;c=-1
    n,Y=map(int, input().split())
    for x in range(n+1):
        for y in range(n+1):
            if 10000*x+5000*y+1000*(n-x-y)==Y and 0<=n-x-y<=n:
                a,b,c= [x,y,n-x-y]
    return a,b,c

a,b,c=solve()
print(a,b,c)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
#include<map>
#include<sstream>
using namespace std;
typedef pair<vector<int>,int> P;

string getVal(string message)
{
  stringstream ss;
  ss << message;
  string a,b;
  ss >> a >> b;
  return b.substr(0,b.size()-1);
}

int main()
{
  int N;
  cin >> N;
  int G[N+1][N+1];
  
  for(int i=0;i<N+1;i++)
    for(int j=0;j<N+1;j++)
      G[j][i] = (1<<29);
  map<string,P> index;
  cin.ignore();
  for(int i=0;i<N;i++)
    {
      string line;
      getline(cin,line);

      if(line.substr(0,4) == "goto")
	index[getVal(line)].first.push_back(i);
      else 	
	index[line.substr(0,line.size()-1)].second = i;
    }

  for(map<string,P>::iterator it = index.begin();it != index.end();it++)
    {
      for(int i=0;i<(*it).second.first.size();i++)
	{
	  G[((*it).second.first)[i]][(*it).second.second] = 0;
	  G[((*it).second.first)[i]][((*it).second.first)[i]+1] = min(G[(*it).second.first[i]][(*it).second.first[i]+1],1);
	}
      G[(*it).second.second][(*it).second.second+1] = 0;
    }

  for(int k=0;k<N+1;k++)
    for(int i=0;i<N+1;i++)
      for(int j=0;j<N+1;j++)
	G[i][j] = min(G[i][j],G[i][k]+G[k][j]);

  cout << G[0][N] << endl;
  return 0;
}

Measured memory_bytes: 1304
#include<iostream>
using namespace std;
const unsigned long long MAX = 1000000000;

int main(){
  int n, totalValues = 0;
  long long w;
  cin>>n>>w;
  int values[n];
  unsigned long long weights[n];
  
  for(int i=0;i<n;++i){
  	cin>>weights[i]>>values[i];
  	totalValues += values[i];
  }
  unsigned long long dp[n+1][totalValues+1];
  
  for(int i=0;i<=n;++i)
  	for(int j=0;j<=totalValues;++j)
  		dp[i][j] = MAX;
  
  for(int i=0;i<=n;++i)
  	dp[i][0] = 0;
  
  for(int i=1;i<=n;++i)
  	for(int j=0;j<=totalValues;++j)
  		if(j<values[i-1])
  			dp[i][j] = dp[i-1][j];
  		else
  			dp[i][j] = min(dp[i-1][j-values[i-1]]+weights[i-1], dp[i-1][j]);
  
  for(int i=totalValues; i>-1;--i)
  	if(dp[n][i]<=w){
    	cout<<i;
      	break;
    }
return 0;
}

Measured memory_bytes: 79104
//#define _GLIBCXX_DEBUG

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


int main(){
  int h,w;
  cin>>h>>w;
  char field[110][110];
  vector<bool>gyo(h,false);
  vector<bool>retu(w,false);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>field[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(field[i][j]=='#')gyo[i]=true;
    }
  }
  for(int j=0;j<w;j++){
    for(int i=0;i<h;i++){
      if(field[i][j]=='#')retu[j]=true;
    }
  }
  for(int i=0;i<h;i++){
    if(gyo[i]){
      for(int j=0;j<w;j++){
        if(retu[j])cout<<field[i][j];
      }
      cout<<endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <random>
#define int long long
#define double long double
#define endl "\n" 
const int INF = (int) 1e18 + 7;
const int maxn = (int) 1e6 + 6;
//const md = (int) 1e9 + 7;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;


// r R W r R W w w

// W R W W R W R R
// R R R R W W W W
// R R W W W W R R
// w r r w w r w r w
// r r r r w w w w w

//rrr (W R) rrr (W W R) rrr (W R) R
// 
signed main() {

    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;

    string temp = s;
    sort(temp.begin(), temp.end());
    for(int i = 0; i < n; i++) {
        if(s[i] != temp[i]) ans++;
    }
    cout << ans/2 << endl;

    return 0;
}



Measured memory_bytes: 3844
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
#define PI 3.1415926534
const ll MOD= 1e9 + 7;

//
void solve(long long a, long long b, long long x){
  if((double)2*(double)x/((double)a*(double)b)<=a){
  double ans=atan((double)2*(double)x/((double)a*(double)b)/(double)b);
  opf(90.0-ans*180/PI)
  }else{
    double ans=atan((double)2*((double)(a*a*b)-(double)x)/((double)a*(double)a)/(double)a);
    opf(ans*180/PI)
  }
}

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


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



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

ll x,y;

void cal(int s,int t){
    ll k=max((x+s-1)/s,(y+t-1)/t);
    x=k*s;
    y=k*t;
}

int main(){
    int n;cin>>n;
    int a[n][2];for(int i=0;i<=n-1;i++)cin>>a[i][0]>>a[i][1];
    x=a[0][0],y=a[0][1];
    for(int i=1;i<=n-1;i++){
        cal(a[i][0],a[i][1]);
    }
    cout<<x+y<<endl;
    return 0;
}


Measured memory_bytes: 256
N,M,X,Y=map(int,input().split())

x=list(map(int,input().split()))
y=list(map(int,input().split()))

x.append(X)
y.append(Y)

x_max=max(x)
y_min=min(y)

if x_max<y_min:
    print("No War")
else:
    print("War")

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

int main() {
    int N, D;
    cin >> N >> D;

    long X, Y;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> X >> Y;
        if (sqrt(X*X + Y*Y) <= D) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n,k;
int h[200005];
int main(){
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&h[i]);
    sort(h,h+n);
    ll sum=0;
    for(int i=0;i<n-k;i++)
        sum+=h[i];
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;

namespace ABC104A
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int r = ConsoleInput.Int();
            if (r < 1200)
            {
                Console.WriteLine("ABC");
                return;
            }

            if (r < 2800)
            {
                Console.WriteLine("ARC");
                return;
            }
            Console.WriteLine("AGC");
        }
    }
    
    internal static class ConsoleInput
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int> v(n);
rep(i,n)cin>>v[i];
vector<map<int,int>> cnt(2);
rep(i,n/2){
    cnt[0][v[2*i]]++;
    cnt[1][v[2*i+1]]++;
}
vector<pair<int,int>> rank_odd,rank_even;
for (auto  val: cnt[0]){
    rank_odd.pb({val.second,val.first});
}
for (auto  val: cnt[1]){
    rank_even.pb({val.second,val.first});
}
sort(rank_odd.begin(),rank_odd.end(),greater<pair<int,int>>());
sort(rank_even.begin(),rank_even.end(),greater<pair<int,int>>());
auto odd1=rank_odd[0];
auto even1=rank_even[0];
auto odd2=rank_odd[1];
auto even2=rank_even[1];
int ans;

if(odd1.second!=even1.second){
        ans = n - odd1.first - even1.first;
}
else{
    if(rank_odd.size()==1||rank_even.size()==1){
        ans=n/2;
    }
    else{
        ans = min(n - odd2.first - even1.first,
                  n - odd1.first - even2.first);
    }
}
cout<<ans<<endl;
//system("pause");
return 0;
}


Measured memory_bytes: 6524
n = int(input())
if n >= 64:
  print("64")
elif n >= 32:
  print("32")
elif n >= 16:
  print("16")
elif n >= 8:
  print("8")
elif n >= 4:
  print("4")
elif n >= 2:
  print("2")
else:
  print("1")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a;cin>>a;
    cout<<a+a*a+a*a*a;
    return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    int a[1010];
    int sum = 0;
    rep(i, N) {
        cin >> a[i];
        sum += a[i];
    }
    int k = 1, tmp = sum;
    int r = 0;
    while(tmp > 1) {
        k *= 2;
        r++;
        tmp /= 2;
    }
    vector<int> v;
    rep(i, N) {
        int tmp1 = 0;
        REP(j, i, N - 1) {
            tmp1 += a[j];
            v.push_back(tmp1);
        }
    }
    //cout << sum << " " << v.size() << " " << k << " " << r << endl;
    int ans = 0;
    while(r >= 0){
        vector<int> v2;
        rep(i, v.size()) {
            if (v[i] & ((int)1 << r) && v[i] >= 0) v2.push_back(v[i]);
        }
        if (v2.size() >= K) {
            ans += k;
            //cout << k << ":";
            rep(j, v2.size()) {
                //cout << v2[j] << " ";
                v2[j] -= ((int)1 << r);
            }
            //cout << endl;
            v = v2;
        }
        k /= 2;
        r--;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6256
N=int(input())
a=list(map(int,input().split()))
maxi=max(a)
mini=min(a)
ans1=(maxi**2)*N
for i in range(mini,maxi+1):
    ans=0
    for j in a:
        ans+=abs(j-i)**2
    if ans<ans1:
        ans1=ans
print(ans1)


Measured memory_bytes: 39152
//region trash
#ifndef LOCAL
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#define DB(x){if(cond)cerr<<__LINE__<<" "<<#x<<" " <<x<<endl;}
#else
#define DB(x){}
#endif
#define REP(i,b)for(auto i=0;i<(b);++i)
#define FOR(i,a,b)for(auto i=(a);i<=(b);++i)
#define FORD(i,a,b)for(auto i=(a);i>=(b);--i)
#define FORDE(rit,x)for(auto rit=(x).rbegin();rit!=(x).rend();rit++)
#define VV vector
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
template<typename X, typename Y>bool MA(X&a,Y b){if(a<b){a=b;return true;} return false;}
template<typename X, typename Y>bool MI(X&a,Y b){if(a>b){a=b;return true;} return false;}
typedef long long LL,ll;typedef long double LD,ld;
typedef array<int,2>I2,i2;typedef VV<int>VI,vi;
using namespace std;
int cond=0;
//endregion

int mode=0;

struct Solver {
  int N;
  VV<VV<int>>NEI;

  array<int,2> go(int u, int p) {
    array<int,2> res = {0,u};

    DB(u<<" "<<p);
    for(auto v:NEI[u]){
      if (v == p) continue;
      auto tmp = go(v, u);
      tmp[0] += 1;
      res = max(res, tmp);
    }
    return res;
  }

  void solve() {
    cin>>N;
    NEI.resize(N);
    REP(n,N-1) {int a,b;cin>>a>>b;a--;b--;
      NEI[a].push_back(b);
      NEI[b].push_back(a);
    }
    auto tmp = go(0,-1);
    auto tmp2 = go(tmp[1], 0);
    DB(tmp2[0]<<" "<<tmp2[1]+1);
    if ((tmp2[0] +1) % 3 != 2) {
      cout<<"First\n";
    }
    else cout << "Second\n";
  }
};


int main(int argc,char** argv){
  struct Solver2 {
    void gen() {}
    void brute() {}
  };
  random_device rd{};
  uint64_t seed = (uint64_t)rd()
      ^ (uint64_t)std::chrono::steady_clock::now().time_since_epoch().count()
      ^ (uint64_t)__builtin_ia32_rdtsc()
      ^ (uint64_t)make_unique<char>().get();
  srand(seed); mt19937 rng(seed);

  ios::sync_with_stdio(false),cin.tie(nullptr);
  FOR(a,1,argc-1){if(argv[a][0]=='g') { Solver2 solver; solver.gen(); return 0; }}
  FOR(a,1,argc-1){if(argv[a][0]=='q') cond=1U<<30U;}
  cout.setf(ios::fixed),cout.precision(10);
  int t{};if(mode >= 1)cin>>t;else t=1;
  bool isBrute=false;FOR(a,1,argc-1)if(argv[a][0]=='b')isBrute=true;
  FOR(i,1,t){if(cond)cerr<<__LINE__<<" "<<i<<endl;if(mode == 2)cout<<"Case #"<<i<<": ";
    auto solver = make_unique<Solver>();
    auto solver2 = make_unique<Solver2>();
    if (isBrute)
      solver2->brute();
    else
      solver->solve();
  }
  return 0;
}


Measured memory_bytes: 19584
#include<iostream>
using namespace std;
int main()
{
	int x;
	int y;
	cin>>x>>y;
	if(x==2)
    {
        if(y==2){
		cout<<"Yes\n";
        }
        else
            cout<<"No\n";
    }
else if(x==4||x==6||x==9||x==11)
{
	if(y==4||y==6||y==9||y==11)
	cout<<"Yes\n";
else
cout<<"No\n";
}

else if(x==1||x==3||x==5||x==7||x==8||x==10||x==12)
{
	if(y==1||y==3||y==5||y==7||y==8||y==10||y==12)
	cout<<"Yes\n";
else
cout<<"No\n";
}

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	for(int64 ii = 0;ii < tx - sx;ii++)
	{
		cout << 'R';
	}
	for(int64 ii = 0;ii < ty - sy;ii++)
	{
		cout << 'U';
	}
	for(int64 ii = 0;ii < tx - sx;ii++)
	{
		cout << 'L';
	}
	for(int64 ii = 0;ii < ty - sy;ii++)
	{
		cout << 'D';
	}
	cout << 'D';
	for(int64 ii = 0;ii <= tx - sx;ii++)
	{
		cout << 'R';
	}
	for(int64 ii = 0;ii <= ty - sy;ii++)
	{
		cout << 'U';
	}
	cout << "LU";
	for(int64 ii = 0;ii <= tx - sx;ii++)
	{
		cout << 'L';
	}
	for(int64 ii = 0;ii <= ty - sy;ii++)
	{
		cout << 'D';
	}
	cout << 'R' << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main()
{
int A1;
int A2;
int A3;
scanf("%d",&A1);
scanf("%d",&A2);
scanf("%d",&A3);
if(A1>A3&&A2>A3&&A1>A2){
    printf("%d",A1-A3);
}else if(A1>A3&&A2<A3){
    printf("%d",A1-A2);
}else if(A2>A1&&A2>A3&&A1>A3){
    printf("%d",A2-A3);
}else if(A2>A1&&A2>A3&&A1<A3){
    printf("%d",A2-A1);
}else if(A3>A1&&A3>A2&&A1>A2){
    printf("%d",A3-A2);
}else if(A3>A1&&A3>A2&&A1<A2){
    printf("%d",A3-A1);
}else if((A1==A2)&&A1<A3){
    printf("%d",A3-A1);
}else if((A1==A2)&&A1>A3){
    printf("%d",A1-A3);
}else if((A1==A3)&&A1<A2){
    printf("%d",A2-A1);
}else if((A1==A3)&&A1>A2){
    printf("%d",A1-A2);
}else if((A2==A3)&&A2<A1){
    printf("%d",A1-A2);
}else if((A2==A3)&&A2>A1){
    printf("%d",A2-A1);
}else{
    printf("0");
}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define REP(i, n) for (i64 (i) = 0; (i) < (n); ++(i))
#define FOR(i, a, b) for (i64 (i) = (a); (i) < (b); ++(i))

const int MOD = (int)1e9 + 7;
int N, X, Y, Z;
i64 res;
i64 dp[41][1 << 17];
int mask, banned;

signed main() {

    cin >> N >> X >> Y >> Z;

    res = 1;
    REP(i, N) (res *= 10) %= MOD;

    mask = (1 << 16) - 1;
    banned = (1 << (X + Y + Z - 1)) | (1 << (Y + Z - 1)) | (1 << (Z - 1));

    dp[0][0] = 1;

    REP(i, N) REP(j, 1 << 16) {
        FOR(n, 1, 11) {
            // 次の数字をbitとしてpushしたもの
            int nxt = (j << n) | (1 << (n - 1));
            // X, Y, Zが成立してしまう
            if ((banned & nxt) == banned) continue;
            (dp[i + 1][nxt & mask] += dp[i][j]) %= MOD;
        }
    }

    REP(i, 1 << 17) {
        res -= dp[N][i];
        if (res < 0) res += MOD;
    }

    cout << res << endl;

}

Measured memory_bytes: 40192
#include <iostream>
#include <utility>
#include <algorithm>
#define llint long long
#define inf ((llint)1e18)

using namespace std;

llint R, C, N;
pair< pair<llint, llint>, llint > RC[100005], CR[100005];

llint row_parent[100005], row_dif[100005];
llint col_parent[100005], col_dif[100005];
llint min_row[100005], min_col[100005];

llint root(llint parent[], llint dif[], int i)
{
	if(parent[i] == i) return i;
	
	root(parent, dif, parent[i]);
	dif[i] = dif[parent[i]] + dif[i];
	return parent[i] = parent[parent[i]];
}

bool same(llint parent[], llint dif[], int i, int j)
{
	return root(parent, dif, i) == root(parent, dif, j);
}

void unite(llint parent[], llint dif[], int i, int j, llint val)
{
	int root_i = root(parent, dif, i), root_j = root(parent, dif, j);
	if(root_i == root_j) return;
	
	llint x = dif[j] - val - dif[i];
	parent[root_i] = root_j;
	dif[root_i] = x;
}

int main(void)
{
	cin >> R >> C >> N;
	llint r, c, a;
	for(int i = 0; i < N; i++){
		cin >> r >> c >> a;
		RC[i] = make_pair(make_pair(r, c), a);
		CR[i] = make_pair(make_pair(c, r), a);
	}
	sort(RC, RC + N);
	sort(CR, CR + N);
	
	for(int i = 1; i <= R; i++) row_parent[i] = i;
	for(int i = 1; i <= C; i++) col_parent[i] = i;
	
	int prev = -1;
	for(int i = 0; i < N; i++){
		if(RC[i].first.first == prev){
			int pc = RC[i-1].first.second, cc = RC[i].first.second;
			if(same(col_parent, col_dif, pc, cc)){
				if(col_dif[cc] - col_dif[pc] != RC[i].second - RC[i-1].second){
					cout << "No" << endl;
					return 0;
				}
			}
			unite(col_parent, col_dif, pc, cc, RC[i].second - RC[i-1].second);
		}
		prev = RC[i].first.first;
	}
	prev = -1;
	for(int i = 0; i < N; i++){
		if(CR[i].first.first == prev){
			int pr = CR[i-1].first.second, cr = CR[i].first.second;
			if(same(row_parent, row_dif, pr, cr)){
				if(row_dif[cr] - row_dif[pr] != CR[i].second - CR[i-1].second){
					cout << "No" << endl;
					return 0;
				}
			}
			unite(row_parent, row_dif, pr, cr, CR[i].second - CR[i-1].second);
		}
		prev = CR[i].first.first;
	}
	
	for(int i = 1; i <= R; i++) min_row[i] = inf;
	for(int i = 1; i <= R; i++){
		root(row_parent, row_dif, i);
		min_row[row_parent[i]] = min(min_row[row_parent[i]], row_dif[i]);
	}
	for(int i = 1; i <= C; i++) min_col[i] = inf;
	for(int i = 1; i <= C; i++){
		root(col_parent, col_dif, i);
		min_col[col_parent[i]] = min(min_col[col_parent[i]], col_dif[i]);
	}
	
	for(int i = 0; i < N; i++){
		if(RC[i].second - row_dif[RC[i].first.first] + min_row[row_parent[RC[i].first.first]] - col_dif[RC[i].first.second] + min_col[col_parent[RC[i].first.second]] < 0){
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>
int main()
{
    int n,a,b,c,i;
    while(scanf("%d",&n)==1){
        for(i=0;i<n;i++){
            scanf("%d%d%d",&a,&b,&c);
            if(((a*a+b*b)==c*c)||((c*c+b*b)==a*a)||((a*a+c*c)==b*b))
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void)
{
	long long N;
	cin >> N;

	int a, b;

	for (int i = 1; i < sqrt(N) + 1; ++i) {
		if (N % i == 0) {
			a = i;
			b = N / i;
		}
	}
	
	stringstream ss1;
	ss1 << a;
	stringstream ss2;
	ss2 << b;
	cout << max(ss1.str().length(), ss2.str().length()) << endl;

	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

pos = 0
visit = [0] * N
move = []
roop = []

while visit[pos] != 2:
    if visit[pos] == 0:
        move.append(pos)
    else:
        roop.append(pos)

    visit[pos] += 1
    pos = A[pos] - 1

if len(move) > K:
    print(move[K] + 1)
else:
    print(roop[(K- (len(move) - len(roop))) % len(roop)] + 1)


Measured memory_bytes: 32680
import java.util.*;

public class Main {    
    
   public static void main(String[] args){
       
       Scanner sc = new Scanner(System.in);
    
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      
      if(A == B && B == C){
          System.out.println(1);
      }else if(A == B && A != C || A != B && B == C || C == A && A != B){
          System.out.println(2);
      }else{
          System.out.println(3);
      }
      
       
   }
}
        
        

Measured memory_bytes: 21972