akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll m(ll a,ll b)
{
   if(a-b>0)
    return a-b;
   return b-a;
}
int main()
{
    ll n;
    cin>>n;
    ll ar[100005];
    for(int i=0;i<n;i++)
        cin>>ar[i];
    ll dp[100005];
    dp[n-2]=m(ar[n-1],ar[n-2]);
    dp[n-1]=0;
    for(int i=n-3;i>=0;i--)
    {
        dp[i]=min(dp[i+1]+m(ar[i+1],ar[i]),m(ar[i+2],ar[i])+dp[i+2]);
    }
  //  for(int i=0;i<n;i++)
     //   cout<<dp[i]<<" ";
    cout<<dp[0];
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main()
{
    fast();
    ll n;
    cin>>n;
    vi a(n);
    cin>>a;
    vi sum=a;
    for(ll i=1;i<n;i++)
        sum[i]+=sum[i-1];

    ll ans=inf;
    for(ll i=0;i<n-1;i++)
    {
        ll s1=sum[i];
        ll s2=sum[n-1]-sum[i];
        ans=min(ans,abs(s1-s2));
        //i+1..n-1
    }
    cout<<ans<<nl;
}


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

typedef long long ll;

const int MAX_H = 100000;
const int MAX_W = 100000;

const int MAX_N = 200000;
const int MOD = 1000000007;

ll factorial[MAX_N+1];
ll inverse[MAX_N+1];

// 繰り返し２乗法による冪乗計算 O(log(n))
int exponentiation(ll x, int n) {
	int res = 1;
	while (0 < n) {
		if (n & 1) {
			res = x * res % MOD;
		}
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

// 組み合わせ nCr の計算 O(1)
ll combination(int n, int r) {
	if (n - r == 0 || r == 0) return 1;
	return factorial[n] * inverse[n-r] % MOD * inverse[r] % MOD;
}

int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;

	// 階乗の初期化 O(n)
	factorial[0] = 1; inverse[0] = 1;
	for (int i=1; i<=H+W; i++) {
		factorial[i] = factorial[i-1] * i % MOD;
		inverse[i] = exponentiation(factorial[i], MOD-2);
	}

	int ans = 0;
	for (int x=B+1; x<=W; x++) {
		ans += combination(x+H-A-2, x-1) * combination(W-x+A-1, A-1) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int h, w, k = 0, o = 0;
  cin >> h >> w;
  vector<vector<int>> H(h, vector<int>(w));
  vector<vector<char>> s(h, vector<char>(w));
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cin >> s.at(i).at(j);
      if(s.at(i).at(j) == '.')
        k++;
      else if(k) {
        for(int l = j - k; l < j; l++)
          H.at(i).at(l) = k;
        k = 0;
      }
    }
    if(k) {
      for(int l = w - k; l < w; l++)
        H.at(i).at(l) = k;
      k = 0;
    }
  }
  for(int j = 0; j < w; j++) {
    for(int i = 0; i < h; i++) {
      if(s.at(i).at(j) == '.')
        k++;
      else if(k) {
        for(int l = i - k; l < i; l++)
          o = max(H.at(l).at(j) + k - 1, o);
        k = 0;
      }
    }
    if(k) {
      for(int l = h - k; l < h; l++)
        o = max(H.at(l).at(j) + k - 1, o);
      k = 0;
    }
  }
  cout << o << endl;
}

Measured memory_bytes: 19968
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	ll sum = 0;
	int r = 0;
	ll ans = 0;
	for(int l = 0; l < n; l++) {
		while(((sum ^ a[r]) == (sum + a[r])) && (r < n)){
			sum += a[r];
			r++;
		}
		ans += (r - l);
		if (l == r){//左が右を追い越さない
			r++;
		}
		else{//左端を削除
			sum -= a[l];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
	int a[3],i,ans=0,sum=0;
	for(i=0;i<3;i++){
		scanf("%d",&a[i]);
		if(a[i]==5){
			ans++;
		}else if(a[i]==7){
			sum++;
		}
	}
	if(ans==2&&sum==1){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    string num[] = {"0111111", "0000110", "1011011", "1001111", "1100110",
                    "1101101", "1111101", "0100111", "1111111", "1101111"};

    for(;;){
        int n;
        cin >> n;
        if(n == -1)
            return 0;

        bitset<7> bs(0);
        for(int i=0; i<n; ++i){
            int a;
            cin >> a;
            cout << (bs ^ bitset<7>(num[a])).to_string() << endl;
            bs = bitset<7>(num[a]);
        }
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    const int N = (int)1e5;
    vi a(n), cnt(N); for(auto& e : a) cin >> e, e--, cnt[e]++;
    int res = 0;
    int cnt2 = 0;
    for(auto& e : cnt){
        if(e == 0) continue;
        e = (e - 1) % 2 + 1;
        if(e == 2) cnt2++;
        else res++;
    }

    res += cnt2 / 2 * 2;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 100001;
int arr[mxN];
ll sumx[mxN];
int rsum[mxN];
ll sumxmod[mxN];
int lsummod[mxN];
int n;
vector<int> divs[mxN];
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n;
    owo(i, 0, n) {
        cin>>arr[i];
    }
    owo(i, 1, n) {
        for(int j=i; j<n; j+=i) {
            divs[j].senpai(i);
        }
    }
    owo(i, 1, n) {
        for(int j=0; j<n; j+=i) {
            sumx[i]+=arr[j];
            rsum[i] = j;
        }
        int rem = n-1;
        while(rem-i>0) {
            rem-=i;
        }
        for(int j=rem; j<n; j+=i) {
            sumxmod[i]+=arr[j];
        }
        lsummod[i] = rem;
        //cout<<i<<" "<<sumx[i]<<" "<<sumxmod[i]<<"\n";
    }
    ll ans = 0;
    owo(A, 1, n) {
        int pos = n-1-A;
        for(int k: divs[pos]) {
            if(k>=A)continue;
            if(A%k==0) {
                if(pos>=A)continue;
                while(lsummod[k]<A) {
                    sumxmod[k]-=arr[lsummod[k]];
                    lsummod[k]+=k;
                }
                while(rsum[k]>pos) {
                    sumx[k]-=arr[rsum[k]];
                    rsum[k]-=k;
                }
                //cout<<A<<" "<<pos<<" "<<k<<" "<<rsum[k]<<" "<<lsummod[k]<<"\n";
                ans = max(ans, sumx[k] + sumxmod[k]);
            }else {
                int lastpos = pos+A-k;
                while(lsummod[k]<A) {
                    sumxmod[k]-=arr[lsummod[k]];
                    lsummod[k]+=k;
                }
                while(rsum[k]>pos) {
                    sumx[k]-=arr[rsum[k]];
                    rsum[k]-=k;
                }
                ans = max(ans, sumx[k] + sumxmod[k]);
            }
            //cout<<A<<" "<<pos<<" "<<k<<" "<<ans<<"\n";
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 16748
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

bool operator<(const tuple<int64_t, int64_t, int64_t> &lhs, const tuple<int64_t, int64_t, int64_t> &rhs)
{
    return get<0>(lhs) > get<0>(rhs);
}

int main() {
    int64_t n, k;
    cin >> n >> k;
    vector<int64_t> a(n);
    vector<int64_t> f(n);
    int64_t asum = 0 , fsum = 0;
    for (int64_t i = 0; i < n; ++i) {
        cin >> a[i];
        asum += a[i];
    }
    for (int64_t i = 0; i < n; ++i) {
        cin >> f[i];
    }
    if (k >= asum) {
        cout << 0 << endl;
        return 0;
    }

    sort(a.begin(), a.end(), greater<int64_t>());
    sort(f.begin(), f.end());

    auto left = -1ll;
    auto right = a[0] * f[n-1];

    int64_t used;
    int64_t mid = 0;
    while (left + 1 < right) {
        mid = (left + right) / 2;
        // cerr << "left is " << left << ", right is " << right << ", mid is " << mid << endl;
        // check all cost (-k value) <= mid
        used = 0;
        for (int64_t i = 0; i < n; ++i) {
            auto cost = a[i] * f[i];
            if (mid < cost) {
                used += a[i] - mid/f[i];
            }
        }
        if (used <= k) {
            right = mid;
        } else {
            left = mid;
        }
    }
    cout << right << endl;
}


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

#define maxn 100005

char s[maxn];
ll k;

int main()
{
    scanf("%s", s);
    cin >> k;
    int len = strlen(s);
    ll cnt = 1;
    vector<ll> v;
    for (int i = 1; i <= len; i++)
    {
        if (s[i] == s[i - 1])
            cnt++;
        else
        {
            v.push_back(cnt);
            cnt = 1;
        }
    }
    ll ans = 0;
    if (s[0] != s[len - 1])
    {
        for (int i = 0; i < v.size(); i++)
            ans += v[i] / 2;
        ans *= k;
    }
    else
    {
        if (v.size() == 1)
            ans = v[0] * k / 2;
        else
        {
            for (int i = 1; i + 1 < v.size(); i++)
                ans += v[i] / 2;
            ans *= k;
            ans += v[0] / 2;
            ans += v.back() / 2;
            ans += (v[0] + v.back()) / 2 * (k - 1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]";
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

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

    // input
    int N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    // 累積和
    vector<ll> AC(N);
    AC[0] = A[0];
    FOR(i, 1, N){
        AC[i] = A[i] + AC[i-1];
    }

    ll minDiff = AC[N-1];
    ll lastLeftCut = 0;
    ll lastRightCut = 2;

    // c : 中央カット位置
    FOR(c, 1, N-2){
        ll P, Q, R, S;
        // pn(c); ///

        // l : 左カット位置
        FOR(l, lastLeftCut, c){
            ll leftSum = AC[l];
            ll rightSum = AC[c] - AC[l];
            ll sumDiff = abs(leftSum - rightSum);
            
            // 一歩先を見る
            ll leftSumNext = leftSum + A[l+1];
            ll rightSumNext = rightSum - A[l+1];
            ll sumDiffNext = abs(leftSumNext - rightSumNext);

            // diffが減るなら続ける
            if(sumDiff > sumDiffNext){
                continue;
            }else{
                // pn(l); /// 
                P = leftSum;
                Q = rightSum;
                lastLeftCut = l;
                break;
            }
        }

        // r : 右カット位置
        FOR(r, lastRightCut, N-1){
            ll leftSum = AC[r] - AC[c];
            ll rightSum = AC[N-1] - AC[r];
            ll sumDiff = abs(leftSum - rightSum);

            // 一歩先を見る
            ll leftSumNext = leftSum + A[r+1];
            ll rightSumNext = rightSum - A[r+1];
            ll sumDiffNext = abs(leftSumNext - rightSumNext);

            // diffが減るなら続ける
            if(sumDiff > sumDiffNext){
                continue;
            }else{
                // pn(r); ///
                R = leftSum;
                S = rightSum;
                lastRightCut = r;
                break;
            }
        }


        // cを決めたときにl, rを最適化した
        // ここで
        // cout << "PQRS " << P << " " << Q << " " << R << " " << S << endl; ///
        vector<ll> temp;
        temp.push_back(P);
        temp.push_back(Q);
        temp.push_back(R);
        temp.push_back(S);
        sort(ALL(temp));
        ll diff = temp[3] - temp[0];
        // pn(diff); ///
        if(diff < minDiff){
            minDiff = diff;
        }

        //p(""); /// 
    }

    p(minDiff);
    
    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a=0,b,c,d;
  string s;
  cin >>a>>b>>c;
  a-=b;
  cout <<a%c<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int N,K;
  int min=1;
  int i;
  scanf("%d",&N);
  scanf("%d",&K);
  for(i=0;i<N;i++){
    if(min*2<min+K){
      min=min*2;
    }
    else{
      min=min+K;
    }
  }
  printf("%d",min);

  return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

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 (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n,-1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main() {
    int n, m,K;
    cin >> n >> m>>K;
    UnionFind uf(n);
    vector<int>frie(n);
    vector<int>block[n];
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        frie[a]++;
        frie[b]++;
        uf.unite(a,b);
    }
    rep(i,K){
        int c,d;
        cin>>c>>d;
        c--;d--;
        block[c].push_back(d);
        block[d].push_back(c);
    }
    rep(i,n){
        int count=uf.size(i)-1-frie[i];
        for(auto u : block[i])if(uf.same(i,u))count--;
        cout<<count<<" ";
    }
    p();
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int pow(int x,int n){
	int res = 1;
	for(int i = 0; i < n; i++) res *= x;
	return res;
}

int main(){
	int n;
	cin >> n;
	vector<int> dp(100100,INF),num6,num9;
	for(int i = 1; pow(6,i) < 100010; i++) num6.emplace_back(pow(6,i));
	for(int i = 1; pow(9,i) < 100010; i++) num9.emplace_back(pow(9,i));
	dp[0] = 0;
	for(int i = 0; i < 100010; i++){
		dp[i+1] = min(dp[i+1],dp[i]+1);
		for(auto x: num6){
			if(i+x >= 100010) break;
			dp[i+x] = min(dp[i+x],dp[i]+1);
		}
		for(auto x: num9){
			if(i+x >= 100010) break;
			dp[i+x] = min(dp[i+x],dp[i]+1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 640
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();
      sc.close();
      
      String answer = new String();
      
      if (A <= 8 && B <= 8) {
        answer = "Yay!";
      } else {
        answer = ":(";
      }

      System.out.println(answer);
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <string>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int a = 0;
  cin >> s;
  for (int i = 0; i < s.size()-1; i++){
    if(s[i]=='A' and s[i+1]=='C'){
      a = 1;
    }
  }
  if(a==1){
    cout << "Yes" << endl;
  }else cout << "No" << endl;
}


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

using namespace std;

class Item {
public:
    string s;

    bool isNum() const {
        return s[0] <= '9' && s[0] >= '0';
    }

    bool operator<(const Item &x) const {
        if (isNum() && x.isNum()) return atoi(s.c_str()) < atoi(x.s.c_str());
        if (isNum()) return true;
        if (x.isNum()) return false;
        return s < x.s;
    }

};

bool isNum(char c) {
    return c >= '0' && c <= '9';
}

vector<Item> conv(string s) {
    if (s.size() == 0) return {};
    vector<Item> res;
    for (int i = 0; i < s.size(); i++) {
        if (isNum(s[i]) != isNum(s[0])) {
            res.push_back(Item{s.substr(0, i)});
            auto tmp = conv(s.substr(i));
            res.insert(res.end(), tmp.begin(), tmp.end());
            return res;
        }
    }
    res.push_back({s});
    return res;

}

int main() {
    int n;
    cin >> n;
    string s0;
    cin >> s0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (conv(s) < conv(s0)) {
            cout << "-";
        } else {
            cout << "+";
        }
        cout << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<double> A(N);
  for (int i=0; i<N; i++) {
    cin >> A.at(i);
  }
  double r;
  r=1/A.at(0);
  if (N>=2) {
    for (int j=1; j<N; j++) {
      r=r+(1/(A.at(j)));
    }
  }
  cout << 1/r << endl;
}

Measured memory_bytes: 3724
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e16)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (3006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
ll n,a,b;
void solve() {
	// split into A non empty buckets each with <= b elements
	if(a*b<n){
		cout<<"-1\n";return;
	}
	ll ls=0;ll left=n-a; // reserve 1 for each bkt
	for(ll i=0;i<a;++i){
		ll tocout=1+min(b-1,left);
		for(ll i=ls+tocout;i>ls;--i){
			cout<<i<<' ';
		}
		ls+=tocout;
		left-=(tocout-1);
	}
	return;
}
int main()
{
	FAST
	// freopen("out1","w",stdout);
	cin>>n>>a>>b;
	if(a+b<n){
		if(a==1||b==1){
			cout<<"-1\n";
			return 0;
		}
		solve();
		return 0;
	}
	if(a+b>n+1||a+b<n){
		cout<<"-1\n";return 0;
	}
	if(a+b==n+1){
		ll start=n-a+1;
		FOR(i,start,n+1)cout<<i<<' ';
		start--;
		while(start){
			cout<<start<<' ';start--;
		}
	}else{
		if(a==1||b==1){
			cout<<"-1\n";
			return 0;
		}
		ll start=n-a+1;
		FOR(i,start,n+1)cout<<i<<' ';
		start--;
		while(start>2){
			cout<<start<<' ';start--;
		}
		cout<<1<<' '<<2<<'\n';
	}
}
/*
 * 
143766 3908 5617
*/ 


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

typedef long long ll;
ll mod = 1000000007;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int arr[n];
    int sum = 0, mn = INT_MAX;
    for(int i=0; i<n; i++){
        cin >> arr[i];
        sum+=arr[i];
        mn=min(mn, arr[i]);
    }
    cout << n + (m - sum)/mn << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int su,leg;
  cin >> su >> leg;
  if(leg%2 == 1){
    cout << "No" << endl;
    return 0;
  }
  int t = (2 * su - leg)/(-2);
  if(t>=0 && t<=su) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int W,H,i,j,k;
    cin>>H>>W;
    int minimum[10][10];
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            cin>>minimum[i][j];
        }
    }
    
    for(k=0;k<10;k++){
        for(j=0;j<10;j++){
            for(i=0;i<10;i++){
                minimum[i][j]=min(minimum[i][j],minimum[i][k]+minimum[k][j]);
            }
        }
    }
    int answer=0;
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            int d;
            cin>>d;
            if(d!=1&&d!=-1){
                answer=answer+minimum[d][1];
            }
        }
    }
    cout<<answer<<endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>
#include <stack>
#include <queue>
#include <vector>
#define MAX_N 100
#define INF 10000000

using namespace std;

int i;

void solve() {
	if (i % 2 == 1) cout << i * 2 << endl;
	else cout << i << endl;
}

int main() {
	cin >> i;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

ll dp[110][100100];
const int INF = 1<<30;

int main(){
    int N,W;cin >> N >> W;
    vector<int> w(N),v(N);
    rep(i,N)cin >> w[i] >> v[i];
    rep(i,N+1)rep(j,100100)dp[i][j]=INF;
    dp[0][0]=0;
    for(int i=1;i<=N;i++){
        for(int j=0;j<=100010;j++){
            if(j-v[i-1]>=0)dp[i][j]=min(dp[i-1][j-v[i-1]]+w[i-1],dp[i][j]);
            dp[i][j]=min(dp[i-1][j],dp[i][j]);
        }
    }   
    int value = 100000;
    while(dp[N][value]>W)value--; 
    cout << value << endl;
    return 0;
    return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
	
  	if(a * c <= b)
    	cout << c << endl;
	else
		cout << b / a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100000
using namespace std;
vector<int> v;

int main(){
  int n,a[N],c=0,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    c++;
    if(i&&a[i]==a[i-1]){
      v.push_back(c-1);
      c=1;
    }
  }
  v.push_back(c);
  for(int i=0;i<5;i++)v.push_back(0);
  for(int i=0;i<v.size();i++)
    ans=max(ans,v[i]+v[i+1]+v[i+2]);
  cout<<ans<<endl;
  return 0;
}

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

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

    int i,j;
    long long int n,W;
    cin>>n>>W;
    vector<long long int> w(n),v(n);
    for(i=0;i<n;i++)
        cin>>w[i]>>v[i];
    int maxval=100001;
    vector<vector<long long int>> ks(n+1);
    vector<vector<long long int>> maxhap(n+1);
    for(i=0;i<=n;i++)   
    {
        ks[i]=vector<long long int> (maxval);
        maxhap[i]=vector<long long int> (maxval);
        for(j=0;j<maxval;j++)
        {
            if(i==0||j==0)
            {
                ks[i][j]=0;
                maxhap[i][j]=0;
            }
            else
            {
                if(j-v[i-1]>=0)
                {
                    if(w[i-1]+ks[i-1][j-v[i-1]] <=W)
                    {
                        if(maxhap[i-1][j-v[i-1]]+v[i-1]<=j)
                        {
                            if(maxhap[i-1][j-v[i-1]]+v[i-1] > maxhap[i-1][j] )
                            {
                                ks[i][j]=w[i-1]+ks[i-1][j-v[i-1]];
                                maxhap[i][j]=maxhap[i-1][j-v[i-1]]+v[i-1];
                            }
                            else
                            {
                                if(maxhap[i-1][j-v[i-1]]+v[i-1] == maxhap[i-1][j])
                                {
                                    if(w[i-1]+ks[i-1][j-v[i-1]]<ks[i-1][j])
                                    {
                                        ks[i][j]=w[i-1]+ks[i-1][j-v[i-1]];
                                        maxhap[i][j]=maxhap[i-1][j-v[i-1]]+v[i-1];
                                    }
                                    else
                                    {
                                        ks[i][j]=ks[i-1][j];
                                        maxhap[i][j]=maxhap[i-1][j];
                                    }
                                    
                                }
                                else
                                {
                                    ks[i][j]=ks[i-1][j];
                                    maxhap[i][j]=maxhap[i-1][j];
                                }
                                
                            }
                            
                        }
                        else
                        {
                            ks[i][j]=ks[i-1][j];
                            maxhap[i][j]=maxhap[i-1][j];
                        }
                        
                    }
                    else
                    {
                        ks[i][j]=ks[i-1][j];
                        maxhap[i][j]=maxhap[i-1][j];
                    }
                    
                }
                else
                {
                    ks[i][j]=ks[i-1][j];
                    maxhap[i][j]=maxhap[i-1][j];
                }
            }
            
        }
    }
    int max=0;
    for(j=0;j<maxval;j++)
    {
        if(maxhap[n][j]>max)
            max=maxhap[n][j];
    }
    cout<<max<<endl;
}

Measured memory_bytes: 158720
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




int main()
{
    int N;
    cin >> N;
    vector<vector<int>> vec(10,vector<int>(10));

    rep2(i,1,N+1){
        int num = i;
        int head = 0;
        int foot = 0;
        int keta = 0;
        int count = 0;
        while(num > 0){
            keta = num%10;
            if(count == 0) foot = keta;
            num /= 10;
            count++;
        }
        head = keta;
        vec[head][foot]++;
    }

    int ans = 0;
    rep2(i,1,10){
        rep2(j,1,10){
            if( i == j) ans += pow(vec[i][j] , 2);
            else ans += vec[i][j] * vec[j][i];
        }
    }

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

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

int main() {
	int n, m;
	cin >> n >> m;
	int a[m];
	int ans = n;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		ans -= a[i];
	}

	if (ans < 0) {
		ans = -1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define SIZE 200

struct stack{
    int top;
    int elem[SIZE];
};

void initstack(struct stack *p){
    p->top=-1;
}

int stackempty(struct stack *p){
    return p->top<0;
}

int pop(struct stack *p){
    int val;
    if(p->top<0){
        printf("Underflow.\n");
        exit(1);
    }else{
        val=p->elem[p->top];
        p->top--;
        return val;
    }
}

void push(struct stack *p,int val){
    p->top++;
    if(p->top>=SIZE){
        printf("Overflow.\n");
        exit(1);
    }else{
        p->elem[p->top]=val;
    }
    return;
}

int main(void){
    struct stack s;
    char buf[200];
    int a,b;
    
    initstack(&s);
    
    while(scanf("%s",buf)!=EOF){
        if(buf[0]=='+'){
            a=pop(&s);
            b=pop(&s);
            push(&s,a+b);
        }
        else if(buf[0]=='-'){
            a=pop(&s);
            b=pop(&s);
            push(&s,b-a);
        }
        else if(buf[0]=='*'){
            a=pop(&s);
            b=pop(&s);
            push(&s,a*b);
        }else{
            push(&s,atoi(buf));
        }
    }
    
    printf("%d\n",pop(&s));
    return 0;
}

Measured memory_bytes: 1784
import math

def is_good_distance(i, j):
    sum = 0

    for k in range(d):
        sum += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k])

    return math.sqrt(sum).is_integer()




n, d = [int(i) for i in input().split()]

points = []

for i in range(n):
    points.append([int(j) for j in input().split()])

count = 0

for i in range(n):
    for j in range(i+1, n):
        if(is_good_distance(i, j)):
            count += 1

print(count)

Measured memory_bytes: 3064
n=gets.to_i
t,a=gets.split.map &:to_i
h=gets.split.map(&:to_i)
min=1000
mini=0
n.times do|i|
  temp=(a-(t-h[i]*0.006)).abs
  if min > temp
    min = temp
    mini = i
  end
end
puts mini+1


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  string s;
  cin>>s;
  ll count=0;
  bool judge=false;
  for(int i=2;i<s.size()-1;i++){
    if(s[i]=='C'){
      count++;
    }
  }
  if(count==1) judge=true;
  if(s[0]!='A'){
    judge=false;
  }
  for(int i=0;i<s.size();i++){
    for(int j=0;j<26;j++){
      if(s[i]!='A'&&s[i]!='C'&&s[i]==ALP[j]){
        judge=false;
      }
    }
  }
  if(judge) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n;
	cin >> n;
	ll ans = 0;
	int x = n / 500;
	ans += 1ll * x * 1000;
	n %= 500;
	x = n / 5;
	ans += 1ll * x * 5;
	cout << ans;
}


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

int main(){
    ll n,k,q;cin>>n>>k>>q;
    vl a(q);rep(i,q)cin>>a.at(i);

    vl p(n);
    vector<string> ans(n);
    rep(i,q)p.at(a.at(i)-1)++;

    rep(i,n){
        if(k-q+p.at(i)>0){
            cout<<"Yes"<<endl;
        }
        else{cout<<"No"<<endl;}
    }

}

Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
       ll a, b, c;
       cin >> a >> b>> c;
    ll ans = a+b+c;
    if(ans>=22) cout << "bust\n";
    else cout << "win\n";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
 
int main(){
 
    int A[3][3], x , B[10], check[3][3];
 
    for(int i = 0 ; i < 3 ; i++ ) {
        scanf("%d %d %d",&A[i][0],&A[i][1],&A[i][2]);
    }
 
    scanf("%d",&x);
    
    for(int j = 0 ; j < x ; j++ ){
        scanf("%d",&B[j]);
 
        for(int  l = 0 ; l < 3 ; l++ ) {
            for(int k = 0 ; k < 3 ; k++ ){
                if( B[j] == A[l][k] ) {
                    check[l][k] = 1;
                }
            }   
        }
    }   
    
    if( (check[1][1] == 1 && check[2][2] == 1 && check[0][0] == 1  )
    || (check[2][0] == 1 && check[1][1] == 1 && check[0][2] == 1  )
    || (check[0][0] == 1 && check[0][1] == 1 && check[0][2] == 1  )
    || (check[1][0] == 1 && check[1][1] == 1 && check[1][2] == 1  )
    || (check[2][0] == 1 && check[2][1] == 1 && check[2][2] == 1  )
    || (check[0][0] == 1 && check[1][0] == 1 && check[2][0] == 1  )
    || (check[0][1] == 1 && check[1][1] == 1 && check[2][1] == 1  )
    || (check[0][2] == 1 && check[1][2] == 1 && check[2][2] == 1  )
    ) {   
        printf("Yes\n");
    } else {
        printf("No\n");
    }
 
        return 0;
}

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

int main(){
  int n, r; cin >> n;
  r = n % 10;
  cout << ((r == 2 or r == 4 or r == 5 or r == 7 or r == 9) ? "hon" :
          (r == 0 or r == 1 or r == 6 or r == 8) ? "pon" : "bon") << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
 
int main(void){
	char sha1,sha2;
    int year,month,day;
    
    scanf("%d%c%d%c%d", &year, &sha1, &month, &sha2, &day);
    
    if(month <= 4){
    	printf("Heisei\n");
    }else{
    	printf("TBD\n");
    }
	return 0;    
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#include <bitset>
#define LL long long

using namespace std;

int main() {
    int n;
    LL k, sum = 0;
    cin >> n >> k;
    vector<pair<int, int>> v;
    for (size_t i = 0; i < n; i++)
    {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        v.emplace_back(make_pair(tmp1, tmp2));
    }
    sort(v.begin(), v.end());
    for (size_t i = 0; i < n; i++)
    {
        sum += v[i].second;
        if (k <= sum)
        {
            cout << v[i].first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1400
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class SegmentTree(object):
	#N:処理する区間の長さ
	def __init__(self, N):
		self.N = N
		self.N0 = 2 ** (N - 1).bit_length()
		self.initVal = 0
		self.data = [self.initVal] * (2 * self.N0)

	# 区間クエリの種類
	def calc(self, a, b):
		return a + b

	# k番目の値にxを加算
	def add(self, k, x):
		k += self.N0 - 1
		self.data[k] += x
		while k > 0:
			k = (k - 1) // 2
			self.data[k] = self.calc(self.data[2 * k + 1], self.data[2 * k + 2])

	#区間[l, r]の演算値
	def query(self, l, r):
		L = l + self.N0; R = r + self.N0 + 1
		m = self.initVal
		while L < R:
			if R & 1:
				R -= 1
				m = self.calc(m, self.data[R - 1])
			if L & 1:
				m = self.calc(m, self.data[L - 1])
				L += 1
			L >>= 1; R >>= 1

		return m

#処理内容
def main():
	N, K = getlist()
	A = []
	for i in range(N):
		a = int(input())
		A.append(a)

	# K引く
	for i in range(N):
		A[i] -= K
	
	# 累積和
	B = [0]
	for i in range(N):
		B.append(B[-1] + A[i])

	# 座圧
	C = list(set(B))
	C.sort()
	D = defaultdict(int)
	for i in range(len(C)):
		D[C[i]] = i

	# 座標変換
	for i in range(N + 1):
		B[i] = D[B[i]]

	# セグ木
	ans = 0
	Seg = SegmentTree(N + 1)
	for i in range(N + 1):
		b = B[i]
		val = Seg.query(0, b)
		ans += val
		Seg.add(b, 1)

	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 166000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 200005;

int f[maxn][2];

void pd(int&ret,int val){
  if(ret==-1||ret>val)ret=val;
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  int n;
  string s;
  cin>>n>>s;
  memset(f,-1,sizeof(f));
  f[0][0]=0;
  f[0][1]=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        if(k==0&&j==1)continue;
        pd(f[i+1][k],f[i][j]+(s[i]=='.'&&k==1)+(s[i]!='.'&&k==0));
      }
    }
  cout<<min(f[n][0],f[n][1])<<endl;
  return 0;
}

Measured memory_bytes: 2180
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i <= n; i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define RREP1(i, n) for (ll i = n; i >= 1; i--)
#define FOR(i, a, b, c) for (ll i = a; i <= b; i += c)
#define RFOR(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define INF 1145141919
typedef long long ll;

int main() {
    int w, a, b;
    scanf("%d %d %d", &w, &a, &b);
    
    int ans;
    if (a + w < b) ans = b - (a + w);
    else if (b + w < a) ans = a - (b + w);
    else ans = 0;

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	long long A,B,LCM;
	cin>>A>>B;
	for(long i=A;i>=1;i--){
		if(B%i==0&&A%i==0){LCM=i;break;}
	}
	cout<<A*B/LCM;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

typedef long long ll;
typedef pair<long long, long long> pll;

int main(){
	int A, B;
	cin >> A >> B;
	if (A == 1 && B != 1){
		cout << "Alice" << endl;
	}
	else if (A != 1 && B == 1){
		cout << "Bob" << endl;
	}
	else if (A == 1 && B == 1){
		cout << "Draw" << endl;
	}
	else if (A > B){
		cout << "Alice" << endl;
	}
	else if (A < B){
		cout << "Bob" << endl;
	}
	else{
		cout << "Draw" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	int tmp = 1;
	for (int i = 0; i < m; i++) {
		tmp *= 2;
	}
	int ans = (1900 * m + 100 * (n - m))* tmp;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

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

int cmpstr(const void* a, const void* b) {
    const char* aa = (const char*)a;
    const char* bb = (const char*)b;
    return strcmp(aa, bb);
}

int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(c>=a && b>=c) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll N;
ll X[100];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> X[i];
    }
    ll ans = 1e+10;
    for(int i = 0; i <= 100; i++){
        ll tmp = 0;
        for(int j = 0; j < N; j++){
            tmp += (X[j]-i)*(X[j]-i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256