akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define endl "\n"
inline bool EQ(double a, double b)
{
    return fabs(a - b) < 1e-9;
}
const int INF = 1 << 29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n)
{
    int res = 0;
    while (n && ++res)
        n -= n & (-n);
    return res;
}
template <class T>
void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
void chmin(T &a, const T &b) { a = min(a, b); }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, w;
    cin >> n >> w;
    vector<pair<ll, ll>> v;
    vector<pair<ll, ll>>::iterator it;

    ll x, y;
    REP(i, n)
    {
        cin >> x >> y;
        v.push_back(make_pair(x, y));
    }
    sort(v.begin(), v.end());

    ll dp[w + 1][n + 1];
    REP(i, w + 1)
    dp[i][0] = 0;
    REP(i, n + 1)
    dp[0][i] = 0;
    // REP(i, n)
    // cout << " sorrtd " << v[i].first << " " << v[i].second << endl;
    FOR(i, 1, w)
    {
        FOR(j, 1, n)
        {
            if (i >= v[j - 1].first)
            {

                dp[i][j] = max(dp[i - v[j - 1].first][j - 1] + v[j - 1].second, dp[i][j - 1]);
                // cout << "dp " << i << " " << j << " "
                //      << " is set " << dp[i][j] << " with " << dp[i - v[j - 1].first][j - 1] << " v is  " << v[j - 1].second << " with sum " << dp[i - v[j - 1].first][j - 1] + v[j - 1].second << " and " << dp[i][j - 1] << endl;
                // cout << "dp used " << w - v[j - 1].first << " " << j - 1 << endl;
            }
            else
                dp[i][j] = dp[i][j - 1];
        }
    }
    // REP(i, w + 1)
    // {
    //     REP(j, n + 1)
    //     cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    cout << dp[w][n] << endl;
    return 0;
}


Measured memory_bytes: 82488
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> S;
	string y, m, d;
	y = S.substr(0, 4);
	m = S.substr(5, 2);
	d = S.substr(8, 2);
	int yy = stoi(y);
	int mm = stoi(m);
	int dd = stoi(d);
	if (yy < 2019)cout << "Heisei";
	else if (yy == 2019 && mm < 4)cout << "Heisei";
	else if (yy == 2019 && mm == 4 && dd <= 30)cout << "Heisei";
	else cout << "TBD";

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int,int> Pa;

int main()
{
	int n, m, s, t;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		vector<Pa> vec, vec2;
		for(int i = 0; i < n; i++){
			cin >> s >> t;
			vec.push_back(Pa(s,t));
		}
		sort(vec.begin(), vec.end());
		
		cin >> m;
		for(int i = 0; i < m; i++){
			cin >> s >> t;
			vec2.push_back(Pa(s,t));
		}
		sort(vec2.begin(), vec2.end());
		
		for(int i = 0; i < m; i++){
			s = vec2[i].first - vec[0].first;
			t = vec2[i].second - vec[0].second;
			int c = 1;
			for(int j = i+1; j < m; j++){
				if(s == vec2[j].first - vec[c].first && t == vec2[j].second - vec[c].second){
					c++;
					if(c == n){
						break;
					}
				} else if(s < vec2[j].first - vec[c].first){
					break;
				}
			}
			
			if(c == n){
				cout << s << " " << t << endl;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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 nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,X,Y;
    cin >> N >> X >> Y;X--;Y--;
    graph G(N);
    rep(i,N - 1){
        G[i].push_back(i + 1);
        G[i + 1].push_back(i);
    }
    G[X].push_back(Y);
    G[Y].push_back(X);
    vector<vector<ll>> dist(N,vector<ll>(N,INF));
    rep(i,N){
        queue<ll> que;
        que.push(i);
        dist[i][i] = 0;
        while(que.size()){
            ll n = que.front();que.pop();
            for(auto x : G[n]){
                if(dist[i][x] == INF){
                    que.push(x);
                    dist[i][x] = dist[i][n] + 1;
                }
            }
        }
    }
    vector<ll> ans(N - 1);
    rep(i,N - 1){
        for(ll j = i + 1;j < N;j++){
            ans[dist[i][j] - 1]++;
        }
    }
    rep(i,N - 1)cout << ans[i] << "\n";
}


Measured memory_bytes: 34620
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct Combination{
  const int MOD = 1e9+7;

  vector<int> fact; //　fact[i] = iの階乗
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = i * fact[i-1] % MOD;
    }
  }

  int nCr(int n,int r){ // nCr = n!/r!(n-r)!
    return fact[n] * mod_pow(fact[r]*fact[n-r]%MOD,MOD-2,MOD) % MOD;
  }

  int mod_pow(int n,int p,int MOD){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

}comb;

const int MOD = 1e9 + 7;

signed main(){

  int x, y; cin >> x >> y;

  comb.init(1000001);
  int ans = 0;
  for(int i = 0; i <= x; i++){
    if((x-i)%2 == 1) continue;
    int left = i, right = (x - i) / 2;
    if(left*2 + right == y){
      ans += comb.nCr(left + right, left);
      ans %= MOD;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int N, M, k, s;
  int A[10] = {};
  int P[10];
  cin >> N >> M;
  
  for (int i = 0; i < M; ++i) {
    cin >> k;
    while (k > 0) {
      cin >> s;
      A[i] |= 1 << (s-1);
      --k;
    }
  }

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

  int ans = 0;
  for (int bit = 0; bit < (1<<N); ++bit) {
    bool ok = true;
    for (int i = 0; i < M; ++i) {
      int on = A[i] & bit;
      int sum = 0;
      for (int j = 0; j < N; ++j) {
        sum += (on>>j & 1);
      }
      if (sum % 2 != P[i]) {
        ok = false;
        break;
      }
    }
    if (ok) ++ans;
  } 

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


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

// #include <atcoder/all>

using namespace std;
// using namespace atcoder;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    fio();
    string s;
    cin >> s;
    if (s.back() == 's') s += "es";
    else s += "s";
    cout << s << endl;
}

Measured memory_bytes: 3640
gets
while gets
  x1, y1, x2, y2, x3, y3 = $_.split.map(&:to_f)
  a1 = 2 * (x2 - x1)
  b1 = 2 * (y2 - y1)
  c1 = x1*x1 - x2*x2 + y1*y1 - y2*y2
  a2 = 2 * (x3 - x1)
  b2 = 2 * (y3 - y1)
  c2 = x1*x1 - x3*x3 + y1*y1 - y3*y3
  ansx = (b1*c2 - b2*c1)/(a1*b2 - a2*b1)
  ansy = (c1*a2 - c2*a1)/(a1*b2 - a2*b1)
  ansr = Math.sqrt( (x1-ansx)*(x1-ansx) + (y1-ansy)*(y1-ansy) )
  puts sprintf("%.3f %.3f %.3f", ansx, ansy, ansr)
end


Measured memory_bytes: 6880
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[][1000] G, RG;
int[1000] MEMO;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    foreach (_; 0..M) {
        auto ab = readln.split.to!(int[]);
        auto A = ab[0]-1;
        auto B = ab[1]-1;
        G[A] ~= B;
        RG[B] ~= A;
    }

    int[] walk(int i, int p, int n) {
        foreach (j; RG[i]) if (j != p && MEMO[j] == n) return [];
        int[] js;
        foreach (j; G[i]) if (MEMO[j] == n) js ~= j;
        if (js.length == 1) {
            return [js[0]+1, i+1];
        } else if (js.length > 1) {
            return [];
        }
        foreach (j; G[i]) {
            MEMO[j] = n;
            auto r = walk(j, i, n);
            if (!r.empty) return r ~= i+1;
            MEMO[j] = 0;
        }
        return [];
    }
    
    foreach (i; 0..N) {
        MEMO[i] = i+1;
        auto r = walk(i, -1, i+1);
        if (!r.empty) {
            auto top = r[0];
            int[] rr = [top];
            foreach (p; r[1..$]) {
                if (p == top) break;
                rr ~= p;
            }
            reverse(rr);
            writeln(rr.length);
            writeln(rr.to!(string[]).join(" "));
            return;
        }
    }
    writeln("-1");
}

Measured memory_bytes: 2812
#include<stdio.h>
int main(){
    int n, x, i, r, z, num, tmp = 0;
    for(;scanf("%d%d", &n, &x); tmp = 0){
//        scanf("%d%d", &n, &x);
//        tmp = 0;
        if( n == 0 && x == 0 ){
            break;
        }
        for( i = 1; i <= n; i++ ){
            for( r = i+1 ; r <= n; r++ ){
                for( z = r+1; z <= n; z++ ){
                    num = i + r + z;
                    if( num == x ){
                        tmp += 1;
                    }
                }
            }
        }
        printf("%d\n",tmp);
    }
    return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
#define PI 3.14159265
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    double a,b,x; cin>>a>>b>>x;
    //double ar = a*a;
    //double h = x/ar;
    double quant = (a*a*b)/2;
    double ang;
    if(quant == x)
    {
        double bsdk = (b/a);
        double ang = atan(bsdk);
        ang = (ang*180)/PI;
        cout<<fixed<<setprecision(10)<<ang;
        return 0;
    }
    if(quant > x)
    {
        double d = (2*x)/(a*b);
        double bsdk = (b/d);
        ang = atan(bsdk);
        ang = (ang*180)/PI;
        cout<<fixed<<setprecision(10)<<ang;
        return 0;
    }
    double d = (2*x)/(a*a) - b;
    double cd = b - d;
    double bsdk = (cd/a);
    ang = atan(bsdk);
    ang = (ang*180)/PI;
    cout<<fixed<<setprecision(10)<<ang;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
#include <ctype.h> // isdigit
#include <cassert>
using namespace std;

#define LE(n,m) ((n) < (m) + EPS * (abs(n) + abs(m)))
#define GE(n,m) ((n) + EPS * (abs(n) + abs(m)) > (m))
#define LT(n,m) ((n) + EPS * (abs(n) + abs(m)) < (m))
#define GT(n,m) ((n) > (m) + EPS * (abs(n) + abs(m)))
#define EQ(n,m) (abs((n)-(m)) < EPS * (abs(n) + abs(m)))

typedef long long int ll;
const int INF = (1<<30) - 1;
const double EPS = 1e-9;
const int MOD = 1000000007;

int N;
int table[100100];

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    //cout.setf(ios::fixed);
    
    cin >> N;
    for(int i=0; i<N; i++){
        int a, b; cin >> a >> b;
        table[a]++;
        table[b+1]--;
    }
    table[0]++;
    table[100100-1]--;
    
    for(int i=1; i<100100; i++){
        table[i] += table[i-1];
    }
    
    int ans = 0;
    for(int i=0; i<100100; i++){
        if(i <= table[i])
            ans = i;
    }
    
    cout << ans-1 << endl;
    
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t n, ct[5]={0}, ans=0;
  cin >> n;
  string s;
  for(int i=0; i<n; i++){
    cin >> s;
    if(s[0]=='M')
      ct[0]++;
    else if(s[0]=='A')
      ct[1]++;
    else if(s[0]=='R')
      ct[2]++;
    else if(s[0]=='C')
      ct[3]++;
    else if(s[0]=='H')
      ct[4]++;
  }
    for(int i=0; i<5; i++)
      for(int j=i+1; j<5; j++)
	for(int k=j+1; k<5; k++)
	  ans+=ct[i]*ct[j]*ct[k];
    cout << ans;
    return 0;
  }

Measured memory_bytes: 384
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	rep(i,n+1)rep(j,n+1){
		int t=i*10000+j*5000;
		if(m>=t){
			if(i+j+(m-t)/1000==n){
				cout<<i<<" "<<j<<" "<<(m-t)/1000<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
}











Measured memory_bytes: 256
K, A, B = [int(_) for _ in input().split()]

def main():
    if B - A <= 2:
        print(K + 1)
        return

    if K < A + 1:
        print(K + 1)
        return

    ans = B
    k = K - (A + 1)

    ans += (k // 2) * (B - A) + (k % 2)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
 
a, b, c = inm()
ans = False
if a == b and b != c:
    ans = True
if a == c and c != b:
    ans = True
if b == c and c != a:
    ans = True
print("Yes" if ans else "No")

Measured memory_bytes: 9132
#include <algorithm>
#include <cstdio>

using namespace std;

const long long INF = (1LL << 60);

int main()
{
  int N;
  long long W;
  scanf("%d%lld", &N, &W);
  
  long long w[105] = {};
  int v[105] = {};
  for (int i = 0; i < N; i++)
    scanf("%lld%d", &w[i], &v[i]);
  
  long long dp[105][102000] = {}; // dp[i][v]:i番目まで価値vで最小重量
  for (int i = 0; i < 105; i++)
    for (int j = 0; j < 102000; j++)
      dp[i][j] = INF;
  dp[0][0] = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 102000; j++)
      dp[i+1][j] = min(INF, dp[i][j]);
    for (int j = 0; j <= 100000; j++)
      dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
  }
  
  for (int i = 100000; i > 0; i--)
    if (dp[N][i] <= W) {
      printf("%d\n", i);
      break;
    }
  
  return 0;
}

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

int main()
{
    int n;
    int sum = 0;
    cin >> n;
    int ar[n+10] = {};
    for(int i = 1; i <= n; i++)
    {
        int tem;
        cin >> tem;
        ar[i] = tem;
        sum += tem;
    }
    int midmin = ceil((double)sum/(double)n);
    int midmax = sum/n;
    int res = 0;
    int pp = 0;
    for(int i = 1; i <=  n; i++)
    {
        pp += abs(midmax-ar[i])*abs(midmax-ar[i]);
        res += abs(midmin-ar[i])*abs(midmin-ar[i]);
    }

    cout << min(pp, res) << endl;
    return 0;
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a*n,b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    string s; cin >> s;
    if (s == "ABC"){
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()



int main() {
    int n;
    cin >> n;
    map<int, int> m;
    rep (i, n) {
        int tmp;
        cin >> tmp;
        m[tmp]++;
    }
    int one, two;
    one = two = 0;
    for (auto e: m) {
        if (e.second % 2 == 0) {
            two++;
        } else {
            one++;
        }
    }
    one += two / 2 * 2;
    two %= 2;
    cout << one << endl;
}

Measured memory_bytes: 4992
#include <stdio.h>
int main(){
    int n,k,count=0;
    scanf("%d %d",&n,&k);
    int h[n];
    for (int i=0;i<n;i++){
        scanf("%d",&h[i]);
        if (h[i]>=k){
            count++;
        }
    }

    printf("%d",count);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N;
    cin >> N;

    int res = 0;
    for(int i=1; i*i+i<N; i++) {
        if(N%i==0) {
            res += N/i-1;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
 
int main() {
 
  int a[4];
  int b[4];
 
  int n;
  while(1) {
    cin >> n;
    if(n == 0) break;
 
    for(int k=0;k<n;k++){
 
    for(int j=0;j<4;j++)cin >> a[j];
    for(int j=0;j<4;j++)cin >> b[j];
 
 
    int ans[4] ={};    
 
    ans[0] = a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3];
    ans[1] = a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2];
    ans[2] = a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1];
    ans[3] = a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0];
 
    cout<<ans[0] <<" "<<ans[1]<<" "<<ans[2] <<" "<<ans[3]<<endl;
 
    }
  }
 
  return 0;
}

Measured memory_bytes: 1160
while True:
    try:
        xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split())
    except:
        break
    if abs((ya - yb) * (yc - yd) + (xa - xb) * (xc - xd)) < 1.e-10:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 6748
#include<bits/stdc++.h>
using namespace std;
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937
const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;
#define MOD 1000000007
typedef long long ll;
const int mx=2e5+125;
int ar[mx],br[mx],pos[mx];
#define PB push_back
#define endl '\n'
#define S second
#define F first
void solve()
{
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   vector<ll> v;
   v.PB(a*c);
   v.PB(a*d);
   v.PB(b*c);
   v.PB(b*d);
   sort(all(v));
   cout<<v[3]<<endl;

}
int main()
{
    faster();
    int tc;
    tc=1;
    while(tc--)
        solve();
    return 0;
}



Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;


int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int n;
	scanf("%d",&n);
	int ans = 0;
	while (n) {
		ans += n % 10;
		n /= 10;
	}
	if (ans == 1)ans = 10;
	PRINTD(ans);
}

Measured memory_bytes: 128
N, K, X, Y = map(int, open(0).read().split())

before_fee = 0
after_fee = 0

if N >= K:
    before_fee = K * X
    if N > K:
        after_fee = (N-K) * Y
else: 
    before_fee = N * X

print(before_fee + after_fee)

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

int main() {
int a,b,c,d;
cin>>a>>b>>c>>d;
if(a*b>=c*d){
  cout  <<  a*b  <<  endl;
}
else if(a*b==c*d){
  cout << a*b<<endl;
}
else cout << c*d <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
int main(){
    long long x,y,srx,sum=0;
    scanf("%lld%lld",&x,&y);
    srx=((long long)(y/x));
    while(srx>=1)
    {srx/=2;
    sum++;}
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define M 1000000007
#define N 200016

unsigned long ulget();
inline unsigned long ulget()
{
    register unsigned long t = 0;
    register char c;
    while((c = getchar() - '0') >= 0)
    {
        t = t * 10 + c;
    }
    return t;
}

unsigned int colorlastdp[N];
int main()
{
    unsigned int dp[N];
    unsigned int n = ulget();
    dp[0] = 0; dp[1] = 1;
    unsigned int color, lastcolor = 0;
    for (register unsigned int i = 1; i <= n;)
    {
        color = ulget();
        if (color != lastcolor)
            dp[i] = (dp[i] + colorlastdp[color]) % M;
        dp[++i] = colorlastdp[color] = dp[i];
        lastcolor = color;
        //printf("%d %d %d\n", i, color, dp[i]);
    }
    printf("%u", dp[n]);
}


Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main(void)
{
  int h,w;

  scanf("%d %d",&h,&w);

  int map[h][w];
  char tmp;

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> tmp;
      if(tmp!='\n')
	map[i][j]=tmp-('1'-1);
    }
  }

  /*/
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      printf("%d ",map[i][j]);
    }
    printf("\n");
  }
  //*/
  

  int dp[h][w];
  fill(&dp[0][0],&dp[h-1][w],0);
  dp[0][0]=0;
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i==0 && j==0){continue;}
      else if(i==0){
	dp[i][j]=dp[i][j-1]+map[i][j];
      }
      else  if(j==0){
	dp[i][j]=dp[i-1][j]+map[i][j];
      }
      else{
	dp[i][j]=min(dp[i-1][j]+map[i][j],dp[i][j-1]+map[i][j]);
      }
    }
  }

  /*/
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      printf("%d ",dp[i][j]);
    }
    printf("\n");
  }
  */

  printf("%d\n",dp[h-1][w-1]);

  return 0;
}

    

Measured memory_bytes: 1224
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int check1[5001][5001], check2[5001][5001];

int num[10000];

int main(){
	
	int N, K;
	
	cin >> N >> K;
	
	for(int i = 0; i < N; i++){
		cin >> num[i];
	}
	
	for(int i = 0; i < 5001; i++){
		for(int j = 0; j < 5001; j++){
			check1[i][j] = false;
			check2[i][j] = false;
		}
		check1[i][0] = true;
		check2[i][0] = true;
	}
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= K; j++){
			if(check1[i][j]){
				check1[i + 1][j] = true;
			}
			if(j + num[i] > K){
				continue;
			}
			if(check1[i][j]){
				check1[i + 1][j + num[i]] = true;
			}
		}
	}
	
	for(int i = N; i > 0; i--){
		for(int j = 0; j <= K; j++){
			if(check2[i][j]){
				check2[i - 1][j] = true;
			}
			if(j + num[i - 1] > K){
				continue;
			}
			if(check2[i][j]){
				check2[i - 1][j + num[i - 1]] = true;
			}
		}
	}
	
	for(int i = 0; i <= N; i++){
		int sum = 0;
		for(int j = 0; j <= K; j++){
			if(check1[i][j]){
				sum++;
			}
			check1[i][j] = sum;
		}
		sum = 0;
		for(int j = 0; j <= K; j++){
			if(check2[i][j]){
				sum++;
			}
			check2[i][j] = sum;
		}
	}
	/*
	for(int i = 0; i <= N; i++){
		for(int j = 0; j < 21; j++){
			cout << check1[i][j] << " ";
		}
		cout << endl;
	}
	
	cout << endl;
	
	for(int i = 0; i <= N; i++){
		for(int j = 0; j < 21; j++){
			cout << check2[i][j] << " ";
		}
		cout << endl;
	}
	*/
	int ans = 0;
	
	for(int i = 0; i < N; i++){
		bool flag = false;
		int pre = 0;
		if(num[i] >= K){
			flag = true;
		}
		for(int j = 0; j <= K; j++){
			if(K - num[i] - j - 1< 0){
				break;
			}
			if(pre != check1[i][j]){
				pre = check1[i][j];
				if(check2[i + 1][K - j - 1] - check2[i + 1][K - num[i] - j - 1] > 0){
					flag = true;
				}
			}
		}
		pre = 0;
		for(int j = 0; j <= K; j++){
			if(K - num[i] - j - 1 < 0){
				break;
			}
			if(pre != check2[i + 1][j]){
				pre = check2[i + 1][j];
				if(check1[i][K - j - 1] - check1[i][K - num[i] - j - 1] > 0){
					flag = true;
				}
			}
		}
		if(!flag){
			//cout << num[i] << " ";
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 195712
#include<stdio.h>

int main(void){
  int n,a[100],i,j,count=0,min,temp,flag;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);

  for(i=0;i<n;i++){
    min=i;
    flag=0;
    for(j=i;j<n;j++){
      if(a[j]<a[min]) {
        min=j;
        flag=1;
      }
    }
    if(flag==1){
    temp=a[min];
    a[min]=a[i];
    a[i]=temp;
    count++;
    }
  }
  for(i=0;i<n;i++){
    if(i==n-1) printf("%d\n",a[i]);
    else printf("%d ",a[i]);
  }
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Arr = array<ll, 2>;

const int N = 131072;
const ll INF = ll(N) * N * 2;

int n;
vector<int> ch[N];
ll c[N];

vector<Arr> f[N];

bool check(ll md) {
    for (int v = n - 1; v >= 0; v--) {
        if (ch[v].empty()) {
            f[v] = {{0, 0}};
            continue;
        }

        assert(2 == ch[v].size());
        auto& l = f[ch[v][0]];
        auto& r = f[ch[v][1]];
        ll cl = c[ch[v][0]];
        ll cr = c[ch[v][1]];

        for (auto& p: l) {
            p[0] += cl;
            p[1] += cl;
        }
        for (auto& p: r) {
            p[0] += cr;
            p[1] += cr;
        }

        vector<Arr> buf0, buf1;
        for (size_t i = 0, j = 0; i < l.size(); i++) {
            while (j < r.size() && l[i][1] + r[j][0] <= md) {
                j++;
            }
            if (j > 0) {
                buf0.push_back({l[i][0], r[j - 1][1]});
            }
        }
        for (size_t i = 0, j = 0; i < r.size(); i++) {
            while (j < l.size() && r[i][1] + l[j][0] <= md) {
                j++;
            }
            if (j > 0) {
                buf1.push_back({r[i][0], l[j - 1][1]});
            }
        }

        buf0.push_back({INF, 0});
        buf1.push_back({INF, 0});
        vector<Arr> buf;
        int tot = int(buf0.size()) + int(buf1.size()) - 2;
        for (int i = 0, p0 = 0, p1 = 0; i < tot; i++) {
            if (buf0[p0] < buf1[p1]) {
                buf.push_back(buf0[p0++]);
            } else {
                buf.push_back(buf1[p1++]);
            }
        }

        if (buf.empty()) {
            return false;
        }

        f[v].clear();
        ll t = INF;
        for (auto& p: buf) {
            if (p[1] < t) {
                t = p[1];
                f[v].push_back(p);
            }
        }
    }

    return true;
}

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

    cin >> n;
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p >> c[i];
        p--;
        ch[p].push_back(i);
    }

    ll l = -1, r = INF;
    while (r - l > 1) {
        ll md = (l + r) / 2;
        if (check(md)) {
            r = md;
        } else {
            l = md;
        }
    }

    cout << r << endl;
}


Measured memory_bytes: 39828
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int count=0;
  for(int i=0;i<N;i++){
    int b=A.at(i);
    if((i+1)%2==1 && b%2==1)count++;
  }
  cout << count << endl;

}

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

int main() {
	long long int n;
	cin>>n;

	vector<char> res(27);
    res[0]='z';
	for(int i=0;i<26;i++)
	{
	    res[i+1]='a'+i;
        
	}
	string ans;
	while(n>0)
	{
	    ans=res[(n%26)]+ans;
	    n=n-26;
	    double temp=n;
	    n=ceil(temp/26);
	    
	}
	    
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3772
using System;
using System.Collections.Generic;
using System.Linq;



namespace CSharpSample01
{

    

    class Program
    {
        const long MOD = 1000000007;

        
        static long DP(int N)
        {
            //dp[n, t, s, f] := n文字の文字列の通りで、最後がf、最後-1がs、最後-2がtとなっている
            long[,,,] dp = new long[N + 1, 5, 5, 5];

            dp[0, 0, 0, 0] = 1;

            for(int n = 0; n < N; n++)
            {
                for (int t = 0; t < 5; t++)
                {
                    for(int s = 0; s < 5; s++)
                    {
                        for(int f = 0; f < 5; f++)
                        {
                            //dp[n, t, s, f]を使って、n+1文字目の文字nextを決める
                            for (int next = 1; next < 5; next++)
                            {
                                if (t == 1 && s == 2 && next == 3) continue;
                                if (t == 1 && f == 2 && next == 3) continue;
                                if (s == 1 && f == 2 && next == 3) continue;
                                if (s == 2 && f == 1 && next == 3) continue;
                                if (s == 1 && f == 3 && next == 2) continue;
                                dp[n + 1, s, f, next] += dp[n, t, s, f];
                                dp[n + 1, s, f, next] %= MOD;
                            }
                        }               
                    }
                }
            }

            long ans = 0;

            for(int t = 1; t < 5; t++)
            {
                for(int s = 1; s < 5; s++)
                {
                    for(int f = 1; f < 5; f++)
                    {
                        ans += dp[N, t, s, f];
                        ans %= MOD;
                    }
                }
            }

            return ans;
        }

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            Console.WriteLine(DP(N));
        }
    }
}

Measured memory_bytes: 13232
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
   //cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        
      ll n;
      cin>>n;
      ll m;
      cin>>m;
      ll a[n+2];
      for(int i=1;i<=n;i++)
      {
      	  cin>>a[i];
      }
      map<ll,ll>lol;
      std::vector<ll> v[n+2];
      for(int i=1;i<=m;i++)
      {
      	 ll x,y;
      	 cin>>x>>y;
      	 v[x].pb(y);
      	 v[y].pb(x);
      }
      ll ans=n;
        for(int i=1;i<=n;i++)
        {
        	ll w=0;
        	for(auto j:v[i])
        	{
               if(a[i]<=a[j])
               	w=1;
        	}
        	if(w)
        		ans--;
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 10280
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  vi a(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  sort(all(a));
  int ans = 0;
  rep (i, n-1) {
    if (x >= a[i]) {
      x -= a[i];
      ans += 1;
    }
  }
  if (x == a[n-1]) {
    ans += 1;
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
char s[N];
int len,ans;
int main(){
	scanf("%s",s+1);
	len = strlen(s+1);
	ans = len;
	for (int i = 2; i <= len; ++i)
		if (s[i] != s[i-1])  ans = min(ans, max(i-1, len - i + 1));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
//hoax submission
    #include<bits/stdc++.h>
     
    using namespace std;
     
    #define ff first
    #define ss second
    #define pb push_back
    #define mp make_pair
    #define all(x) x.begin(),x.end()
    #define sz(x) ((int)x.size())
     
    const int MOD = 1e9+7;
     
    typedef long long ll;
    typedef pair<int,int> pii;
    const int MAXN = 5e3+3;
    ll dp[MAXN][MAXN];
    char str[MAXN];
    int n,len;
    ll power(ll a, ll b) {
    	ll ret=1;
    	while(b) {
    		if(b&1) ret*=a;
    		a*=a;
    		b>>=1;
    		a%=MOD;
    		ret%=MOD;
    	}
    	return ret;
    }
    int main() {
    //	freopen("TASK.in","r",stdin);freopen("TASK.out","w",stdout);
    	cin>>n;
    	scanf("%s",str+1);
    	len=strlen(str+1);
    	dp[0][0]=1;
    	for(int i=1;i<=n;i++) {
    		for(int j=0;j<=max(len,n);j++) {
    			if(j) dp[i][j]=2LL*dp[i-1][j-1];
    			if(dp[i][j]>=MOD) dp[i][j]%=MOD;
    			dp[i][j]+=dp[i-1][j+1];
    			if(dp[i][j]>=MOD) dp[i][j]-=MOD;
    			if(!j) dp[i][j]+=dp[i-1][j];
    			if(dp[i][j]>=MOD) dp[i][j]-=MOD;
    		}
    	}
    	ll den = power(2,len);
    	den = power(den,MOD-2);
    	ll ans=dp[n][len];
    	ans*=den;
    	ans%=MOD;
    	cout<<ans<<endl;
    	return 0;
    }

Measured memory_bytes: 195712
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: i64, k: i64,
    }
    let mut tot = 0;
    for i in k..n + 2 {
        let lo = (i - 1) * i / 2;
        let hi = n * i - lo;
        tot += hi - lo + 1;
        tot %= 1_000_000_007;
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    int n;
    cin >> n;
    vector<llint>a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a.begin(),a.end());
    if(n%3){
        if(a[0]==0 && a[n-1]==0){
            cout << "Yes" << endl;
            return;
        }
        else{
            cout << "No" << endl;
            return;
        }
    }
	if(a[0]==a[n/3-1] && a[n/3]==a[n/3*2-1] && a[n/3*2]==a[n-1] && (a[0]^a[n/3]^a[n/3*2])==0){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

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


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

int main(){
    int H, W;


    while(1){
        cin >> H >> W;
        if(0 == H && 0 == W){
            break;
        }

        // cout << H << " " << W << endl;

        for(int j = 0; j < H; j++){
            for(int i = 0; i < W; i++){
                // if(0 != j && (H - 1) != j && 0 != i && (W - 1) != i){
                //     cout << ".";
                // } else {
                //     cout << "#";
                // }

                // cout << j + i;

                if(0 == (j + i) % 2){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x; cin>>a>>b>>c>>x;
  x /= 50;
  int count = 0;
  for( int i= x/10; i>=0; --i){
    if( a < i ) continue;
    else {
      for ( int j = (x - 10*i) / 2; j>=0; --j){
        if( b < j) continue;
        else if( (x - 10*i - 2*j) <= c ){
          count++;
//          cout << i << ' ' << j << ' ' << (x - 10*i - 2*j) << endl;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (505)
#define MOD (1'000'000'007ll)
#define OO (1'050'000'000)
#define OOL (1'100'000'000'000'000'000ll)

//global
string ar[N];
string a1[N];
string a2[N];

int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	int n,m;
	cin >> n >> m;
	rep(i,0,n){
		cin >> ar[i];
		a1[i] = ar[i];
		a2[i] = ar[i];
	}
	rep(i,1,m-1){
		a1[0][i] = '#';
		a2[n-1][i] = '#';
	}
	rep(i,1,n-1){
		rep(j,1,m-1){
			if(j&1) a1[i][j] = '#';
			else a2[i][j] = '#';
		}
	}
	rep(i,0,n){
		cout << a1[i] << endl;
	}cout << endl;
	rep(i,0,n){
		cout << a2[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1536