akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
/*----------------------------------------------*/
int n;
int ans[100000];
vector<Edge> g[100000];

void dfs(int x,int p=-1){ //x from parent
  for(auto E:g[x]){       // E.to from x
    if(E.to==p) continue;
    if(E.weight%2) ans[E.to]=(ans[x]+1)%2;
    else ans[E.to]=ans[x];
    dfs(E.to,x);
  }
}


signed main(){
  cin>>n;
  rep(i,n-1){
    int u,v,w;
    cin >> u>>v>>w;
    --u;--v;
    g[v].push_back({u,w});
    g[u].push_back({v,w});
  }
  dfs(0);
  rep(i,n) cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#define int long long int

signed main(){

ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t=1;
//cin>>t;
while(t--){
int r;
cin>>r;

cout<<2*(3.14)*r<<endl;


}


}



Measured memory_bytes: 3804
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N+1, 0);
    for(int n=1; n<=N; n++) {
        cin >> vec[n];
    }
    
    int cur=1;
    int idx=0;
    while(cur!=2 && idx<N) {
        cur = vec[cur];
        idx++;
    }
    
    if(cur==2) {
        cout << idx << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
    
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)
#define all(c) begin(c),end(c)
#define vmax(c) *max_element(all(c))
 
template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9; 

// 多次元配列を作る
// vector<vi> vn(n, vi(m, 0));

// 多次元配列の dump
// for (vector<int> v : vn) {
//     cout << v;
// }

// printf("%d\n", n);
// printf("%lld\n", n);

int main(void){
    int n;
    scanf("%d", &n);
    // printf("%d\n", n);
    int c = 3;
    vector<vi> funs(n, vi(c, 0));
    vector<vi> dp(n + 1, vi(c, 0));

    REP(i, n) {
        REP(j, c) {
            int fun;
            scanf("%d", &fun);
            funs[i][j] = fun;
        }
        // cout << funs[i];
    }
    // cout << endl;
    RREP(i, n) {
        // cout << "=====" << endl;
        // cout << i << endl;
        REP(j, c) {
            vi next_funs;
            REP(k, c) {
                if (j != k) {
                    next_funs.push_back(dp[i + 1][k]);
                }
            }
            // cout << "next_fun is :" << next_funs << endl;
            int next_max_fun = vmax(next_funs);
            // cout << "max is :" << next_max_fun << endl;
            dp[i][j] = funs[i][j] + next_max_fun;
        }
        // cout << dp[i] << endl;
    }
    // cout << dp[0];
    int max_fun = vmax(dp[0]);
    printf("%d", max_fun);
    return 0;
}


Measured memory_bytes: 11264
#include<stdio.h>
#include<math.h>

int koch(double,double,double,double,int);

int n;
 
int koch(double px1,double py1,double px3,double py3,int n){
  double px2=0,py2=0;
  double px=0,py=0,tx=0,ty=0;
     
     
  if(n==0){
    printf("%.8f %.8f\n",px3,py3);
    return 0;
  } 
  else {
 
    px=((px3-px1)/3)+px1;
    py=((py3-py1)/3)+py1;
    
    px2 = (px1+px3)/2 -sqrt(3.0)*(py3-py1)/6;
    py2 = (py1+py3)/2 +sqrt(3.0)*(px3-px1)/6;
    
    tx=((px1-px3)/3)+px3;
    ty=((py1-py3)/3)+py3;
    
    koch(px1,py1,px,py,n-1);
    koch(px,py,px2,py2,n-1);
    koch(px2,py2,tx,ty,n-1);
    koch(tx,ty,px3,py3,n-1);
  }
  return 0;
}

int main(void) {
  int n;
  double x1=0,x3=100;
  double y1=0,y3=0;
     
  scanf("%d",&n);
  printf("%.8f %.8f\n",0.0,0.0);
  koch(x1,y1,x3,y3,n);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k;
  in(n);
  k = 1;
  rep2(i, 1, n + 1)
    k = k * i % mei;
  out(k);
  memi;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<int(n); i++)
using namespace std;
int main(){
	int H, W, d; cin >> H >> W >> d;
	string c = "RYGB";
	if(d%2==0){
		rep(i, H){
			rep(j, W) cout << c[2*(((i+j)/d)%2) + ((i-j+2000*d)/d)%2];
			cout << "\n";
		}
	}else{
		rep(i, H){
			rep(j, W) cout << c[(i+j)%2];
			cout << "\n";
		}
	}
	return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}
const int MAX = 1e6+1;
int prime[MAX + 1];
void sieve() {
    for (int i = 2; i <= MAX; i++) if (!prime[i]) {
            prime[i] = i;
            for (ll j = 1ll * i * i; j <= MAX; j += i) {
                if (!prime[j]) prime[j] = i;
            }
        }
}
void fact(int n, map<int, int> &f) {
    while (n > 1) {
        f[prime[n]]++;
        n /= prime[n];
    }
}
int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    sieve();
    int n;
    cin >> n;
    vector<int> v(n);
    int g ;
    cin >> g;
    v[0] = g;
    forn(i, n - 1)cin >> v[i + 1], g = __gcd(g, v[i + 1]);
    bool ok = 1;
    map<int, bool> mp;
    for(int i = 0; i < n && ok; i++) {
        map<int, int> factores;
        fact(v[i], factores);
        for(auto x : factores) {
            if(mp[x.F]) {
                ok = 0;
                break;
            }
            mp[x.F] = 1;
        }
    }
    if(ok)cout << "pairwise coprime" << endl;
    else if(g == 1)cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
}


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

int main()
{
      int a,b,k;

      cin>>a>>b>>k;

      int x=k;
      set<int>s;
      set<int> :: iterator it;

      for(int i=a;i<=b && k>0 ;i++){

         s.insert(i);
         k--;

      }

      for(int j=b;j>=a && x>0 ;j--){

         s.insert(j);

         x--;

      }


      for(it=s.begin();it!=s.end();it++){
        cout<<*it<<endl;
      }



      return 0;
}


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	V<string> v;

	v.pb("SUN");
	v.pb("MON");
	v.pb("TUE");
	v.pb("WED");
	v.pb("THU");
	v.pb("FRI");
	v.pb("SAT");

	v.pb("SUN");
	v.pb("MON");
	v.pb("TUE");
	v.pb("WED");
	v.pb("THU");
	v.pb("FRI");
	v.pb("SAT");

	string s;
	cin >> s;

	for (int i = 0; i < sz(v); ++i) {
		if (v[i] == s) {
			for (int j = i + 1; j < sz(v); ++j) {
				if (v[j] == "SUN") {
					cout << j - i << '\n';
					return 0;
				}
			}
		}
	}



	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define NUM 5

int main(void){
    int A[NUM];

    int sum = 0;
    int fraction = 100;

    for(int i = 0; i < NUM; i++){
        scanf("%d", &A[i]);
        sum += (A[i] / 10) * 10;
        int f = A[i] % 10;
        if(f != 0){
            if(f < fraction){
                fraction = f;
            }
            sum += 10;
        }
    }

    if(fraction == 100){
        printf("%d\n", sum);
    }else{
        printf("%d\n", sum - 10 + fraction%10);
    }

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i< (n); ++i)
const long long INF = 1LL<<58;

// aを常に小さい値にする　大きい値にする
template<class T> bool chmin(T &a, T b){
    if(a>b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> void chmax(T &a, T b){ if(a<b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

// 最大公約数を求める GCD
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


/*
 *
 * 区間に対するフリップ操作に関する問題で考えると良さそうなこととして
    ・区間が互いに交差しないものとして扱えないか (他に区間の終端でソートして考えるなども)
    ・いもす法変換によって、区間に対する操作を 2 点に対する操作として扱えないか
 *
 *
 * 「0 の個数」と「1 の個数」を交互に書き出してみる。紛らわしさを防ぐために、
 * 両端が「1」じゃないならば、両端に「0 個の 1」があるものとみなして 0 を書いておく。すると
 *
    0, 2, 4, ... 番目の値は「連続する 1 の個数」
    1, 3, 5, ... 番目の値は「連続する 0 の個数」
    と考えることができ、「0, 2, 4, ... 番目から始まる連続する 2K+1 個 (以下) の整数の和の最大値」を求めればよい。
 * */

int main() {

    int N, K; cin >> N >> K;
    string S; cin >> S;

    // 「1 の個数」「0 の個数」を交互に記録していく
    vector<int> nums;
    if (S[0] == '0') nums.push_back(0); // 先頭が 0 だったら
    for (int i = 0; i < S.size();) {
        int j = i;
        while (j < S.size() && S[j] == S[i]) ++j; // S[i] の数値がどこまで続くか
        nums.push_back(j - i);
        i = j;
    }
    if (S.back() == '0') nums.push_back(0); // 最後尾が 0 だったら

    // 累積和
    vector<int> sums((int)nums.size() + 1, 0);
    for (int i = 0; i < nums.size(); ++i) sums[i+1] = sums[i] + nums[i];

    // 偶数番目の添字から始まる、長さ 2K+1 (以下) の区間の総和のうち、最大値を求める
    int res = 0;
    for (int left = 0; left < sums.size(); left += 2) {
        int right = left + K*2+1;
        if (right >= sums.size()) right = (int)sums.size() - 1;
        res = max(res, sums[right] - sums[left]);
    }
    cout << res << endl;
}

Measured memory_bytes: 1272
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    N = II()
    if N == 1:
        print(1)
        return

    if N % 2 == 0:
        print(0.5)
    else:
        print(((N-1)//2 + 1) / N)

solve()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <sstream>

using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;

int main() {
  int n,m,c;
  cin >> n >> m >> c;
  int b[m];
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int count = 0;
  int a;
  for(int i = 0; i < n; i++) {
    int sum = 0;
    for(int j = 0; j < m; j++) {
      cin >> a;
      sum += a*b[j];
    }
    sum += c;
    if(sum > 0) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int tmpN = N;
	int digit = 1;
	while(1) {
		if(N / pow(10, digit) < 1) break;
		digit += 1;
	}
	int tmp = 0;
	int d = digit;
	for(int i = 0; i < d; i++) {
		//cout << int(N / pow(10, digit - 1)) << endl;
		tmp += int(N / pow(10, digit - 1));
		N = N % int(pow(10, digit - 1));
		digit -= 1;
	}
	if(tmpN % tmp == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>

using namespace std;

int main()
{ 
    using i64 = int64_t;
    
    const i64 mod = 1000000000 + 7;

    i64 n, m, k;
    
    cin >> n >> m >> k;
    
    vector<i64> inv(n * m + 1);
    vector<i64> fact(n * m + 1);
    vector<i64> fact_inv(n * m + 1);

    for (i64 i = 1; i < n * m + 1; i++) {
        inv[i] = (i == 1) ? 1 : (mod - (mod / i) * inv[mod % i] % mod);
    }

    fact[0] = 1;
    fact_inv[0] = 1;

    for(int i = 1; i < n * m + 1; ++i) {
        fact[i] = fact[i - 1] * i % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }

    auto comb = [&](int n, int k) {
        if (n < 0 || n < k) {
            return i64(0);
        }

        return fact[n] * fact_inv[n - k] % mod * fact_inv[k] % mod;
    };
    
    i64 ans = 0;
    
    i64 c = comb(n * m - 2, k - 2);
    
    for (i64 i = 0; i < n; i++) {
        for (i64 j = 0; j < m; j++) {
            ans += ((m - j - 1) * (m - j) / 2) % mod * c % mod * n % mod;
            ans %= mod;
            ans += (j * (j + 1) / 2) % mod * c % mod * n % mod;
            ans %= mod;
            
            ans += ((n - i - 1) * (n - i) / 2) % mod * c % mod * m % mod;
            ans %= mod;
            ans += (i * (i + 1) / 2) % mod * c % mod * m % mod;
            ans %= mod;
        }
    }
    cout << ans * inv[2] % mod << endl;
}


Measured memory_bytes: 4992
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2020/7/5 19:54
# @Version : 1.1
# @Author  : Jade
# @File    : a.py
# @Software: PyCharm
#

def main():
    n = int(input())
    print((1000 - n%1000)%1000)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9148
s=list(input())
c1=0
c2=0
a="0"
d="1"
for i in range(len(s)):
  if a=="0":
    a="1"
    if s[i]=="0":
      c1+=1
  elif a=="1":
    a="0"
    if s[i]=="1":
      c1+=1
  if d=="0":
    d="1"
    if s[i]=="0":
      c2+=1
  elif d=="1":
    d="0"
    if s[i]=="1":
      c2+=1
print(min(c1,c2))

Measured memory_bytes: 3956
mod = 10**9+7

# コンビネーション
def cmb(n, r, mod=mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NN = 10**6 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m=mod):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

# modを取りながらべき乗する
def power_func(a,n,mod=mod):
    bi=str(format(n,"b"))#2進表現に
    res=1
    for i in range(len(bi)):
        res=(res*res) %mod
        if bi[i]=="1":
            res=(res*a) %mod
    return res


N, A, B, C = map(int, input().split())
p1 = A*mod_inv(A+B)%mod
p2 = B*mod_inv(A+B)%mod

s1 = 0
s2 = 0
a1 = 1
a2 = 1
for k in range(N):
    s1 = (s1 + a1*(N+k)*cmb(N+k-1, k)) % mod
    s2 = (s2 + a2*(N+k)*cmb(N+k-1, k)) % mod   
    a1 = a1*p1%mod
    a2 = a2*p2%mod

p = (power_func(p1, N)*s2 % mod + power_func(p2, N)*s1 % mod) % mod
p = (p * mod_inv(A+B) * 100) % mod
print(p)

Measured memory_bytes: 121872
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let mut s: String = read();
    let mut ans: bool;

    let hyphen: String = s.drain(a..a + 1).collect();

    ans = match s.parse::<u32>() {
        Ok(_n) => true,
        Err(_err) => false,
    };

    if ans && hyphen == "-" {
        ans = true;
    } else {
        ans = false;
    }

    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rint register int 
#define ll long long 
using namespace std;
int N,A[1010000],idx[1010010],rk[1000010];
inline bool cmp(int i,int j){return A[i]<A[j];}
int main(){
	int n;
	cin>>n;
	int ans=0;
	
	for(rint i=1;i<=n;++i) {
		cin>>A[i];idx[i]=i;
	//	if((i&1)!=(A[i]&1)) 
	}sort(idx+1,idx+n+1,cmp);
	for(rint i=1;i<=n;++i) rk[idx[i]]=i;
	for(rint i=1;i<=n;++i)if((i&1)!=(rk[i]&1)) ans++;
	cout<<ans/2; 
	return 0;
}

Measured memory_bytes: 4816
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

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

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	rep(i, s.size()) {
		int tmp = (int)s[i];
		tmp += n;
		if (tmp > 90) tmp -= 26;
		cout << (char)tmp;
	}
} 

Measured memory_bytes: 256
#include<iostream>
const char vow[]={'a','e','i','o','u'};
int main()
{
    char tin;
    std::cin>>tin;
    for(int i=0;i<5;i++){
        if(tin==vow[i]) {
            std::cout<<"vowel";
            return 0;
        } 
//what the fuck
    }
    std::cout<<"consonant";
    return 0;
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto & in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int64_t N,X;
int64_t B[100000];
int64_t L[100000];
int64_t U[100000];
int64_t dp_score[100010];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	int64_t behind = 0;
	std::set<std::pair<int64_t, int>> sorted;
	in >> N>>X;
	for (int32_t i = 0; i < N; i++)
	{
		in >> B[i] >> L[i] >> U[i];
		int64_t score = L[i] * B[i] + U[i] * (X - B[i]);
		sorted.emplace(score, i);
		behind += L[i] * B[i];
	}
	dp_score[0] = 0;
	{
		auto dp_iter = &dp_score[1];
		for (auto iter = sorted.rbegin(); iter != sorted.rend(); ++iter,++dp_iter)
		{
			*dp_iter = dp_iter[-1] + iter->first;
		}
	}


	using BS_INT = int64_t;
	BS_INT ok_range = X*N, ng_range = -1;
	while (std::abs(ok_range - ng_range) > 1) {
		BS_INT mid = (ok_range + ng_range) / 2;
		bool is_ok = false;

		//ここに書く
		BS_INT rem = mid;
		BS_INT count = rem / X;
		BS_INT score = dp_score[count + 1];
		rem %= X;
		BS_INT rem_max = -1000000000000;
		auto iter = sorted.rbegin();
		for (int32_t COUNT = 0; COUNT < count; COUNT++, ++iter)
		{
			BS_INT tmp = 0;
			int j = iter->second;
			if (rem <= B[j]) {
				tmp = L[j] * rem;
			}
			else {
				tmp = L[j] * B[j] + U[j] * (rem - B[j]);
			}
			tmp -= (iter->first);
			rem_max = std::max(rem_max, tmp);
		}
		for (int32_t COUNT = count; COUNT < N; COUNT++,++iter)
		{
			BS_INT tmp = 0;
			int j = iter->second;
			if (rem <= B[j]) {
				tmp = L[j] * rem;
			}
			else {
				tmp = L[j] * B[j] + U[j] * (rem - B[j]);
			}
			tmp -= dp_score[count + 1] - dp_score[count];
			rem_max = std::max(rem_max, tmp);
		}

		score += rem_max;

		is_ok = score >= behind;
		if (is_ok) {
			ok_range = mid;
		}
		else {
			ng_range = mid;
		}
	}
	out << ok_range << endl;

	return 0;
}
#endif


Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int num,ans,move;
    int H[100000];
    cin >> num;
    REP(i,num){
        cin >> H[i];
    }
    ans=0;
    move=0;
    REP(i,num-1){
        if(H[i]>=H[i+1]){
            move++;
        }else{
            if(move > ans){
                    ans=move;
            }
            move=0;
        }

    }
    if(move > ans){
        ans=move;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890l
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#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 < ee; ii++)
#define space " "
#define cbr cout << "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 p2(x) (1LL<<(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
ll n, m,ans;
priority_queue <pi,vector<pi>,greater<pi>> pq;
int main()
{
	cin>>n>>m;
	for(ll i = 0 ;i < n ;i++) { ll a, b; cin>>a>>b; pq.ph(pi(a,b)); }
	while(pq.size())
	{
		pi x = pq.top();
		pq.pop();
		if(x.s >= m) { ans += (x.f * m); break; }
		else { ans += x.s*x.f; m -= x.s; }
	}
	cout<<ans<<'\n';
}


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

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i=0;i<H;i++)
    cin >> S.at(i);

  //cout << S.at(1).at(1);

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

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S.at(i).at(j) == '#')
        ;
      else{
        int count =0;
        for(int k=0;k<8;k++){
          if(j + dx[k] <W && j +dx[k] >=0 && i+dy[k] < H && i +dy[k] >=0)
            if(S.at(i+dy[k]).at(j+dx[k]) == '#')
              count ++;
        }
        S.at(i).at(j) = char(count + '0');
      }
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++)
      cout << S.at(i).at(j);
    cout << endl;
  }
}
      


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

struct Node_t
{
  Node_t() {
    id_ = left_ = right_ = parent_ = depth_ = height_ = -1;
    deg_ = 0;
    type_ = -1;
    sibling_ = -1;
  }

  int id_, left_, right_, parent_, depth_, height_, deg_, type_;
  int sibling_;
};

const char* types[] = { "root", "internal node", "leaf" };

void print_node(Node_t& node)
{
  fprintf(stdout, "node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",
          node.id_, node.parent_, node.sibling_, node.deg_, node.depth_, node.height_, types[node.type_]);
}

void set_depth(vector<Node_t>& nodes, int id, int depth)
{
  nodes[id].depth_ = depth;
  int l = nodes[id].left_, r = nodes[id].right_;
  if (l != -1) { set_depth(nodes, l, depth + 1);}
  if (r != -1) { set_depth(nodes, r, depth + 1); }
  return;
}

int set_height(vector<Node_t>& nodes, int id)
{
  int l = nodes[id].left_, r = nodes[id].right_;
  if (l == -1 && r == -1) { nodes[id].height_ = 0; }
  else if (l == -1) {
    nodes[id].height_ = 1 + set_height(nodes, r);
  }
  else if (r == -1) {
    nodes[id].height_ = 1 + set_height(nodes, l);
  }
  else {
    nodes[id].height_ = 1 + max(set_height(nodes, l), set_height(nodes, r));
  }
  return nodes[id].height_;
}

void set_sibling(vector<Node_t>& nodes)
{
  int n = nodes.size();
  for (int i = 0; i < n; ++i) {
    if (nodes[i].deg_ == 2) {
      nodes[nodes[i].left_].sibling_ = nodes[i].right_;
      nodes[nodes[i].right_].sibling_ = nodes[i].left_;
    }
  }
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<Node_t> nodes(n);
  for (int i = 0; i < n; ++i) {
    int id, l, r, deg;
    fscanf(stdin, "%d %d %d", &id, &l, &r);
    nodes[id].id_ = id;
    nodes[id].left_ = l;
    nodes[id].right_ = r;
    if (l != -1) { nodes[l].parent_ = id; }
    if (r != -1) { nodes[r].parent_ = id; }
    deg = (l != -1) + (r != -1);
    nodes[id].deg_ = deg;
  }
  int root_id = -1;
  for (int i = 0; i < n; ++i) {
    if (nodes[i].parent_ == -1) {
      root_id = i;
      break;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (i == root_id) { continue; }
    if (nodes[i].deg_ == 0) { nodes[i].type_ = 2; }
    else { nodes[i].type_ = 1; }
  }
  nodes[root_id].type_ = 0;
  set_depth(nodes, root_id, 0);
  set_height(nodes, root_id);
  set_sibling(nodes);
  for (int i = 0; i < n; ++i) {
    print_node(nodes[i]);
  }
  return 0;
}

Measured memory_bytes: 1192
#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>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define MOD 1e9 + 7
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265359

void Main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int start = h1 * 60 + m1;
    int end = h2 * 60 + m2;
    cout << end - start - k << endl;
    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3700
/**
*    author:  Dooloper
*    created: 27.06.2020 20:58:18
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s,t;
  cin >> s >> t;
  int ans = 0;
  for(int i = 0; i < s.length(); i++){
    if(s[i] != t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<ll> calc(vector<Pll> a){
    ll n = a.size();
    sort(a.begin(), a.end());
    vector<vector<ll>> dp(n+1, vector<ll>(n+1, 1e18));
    vector<ll> res(n+1, 1e18);
    dp[0][0] = 0;
    rep(l,n){
        REP(r,l+1,n+1){
            ll now = 1e18;
            REP(k,l,r){
                ll s = 0;
                REP(i,l,r){
                    s += abs(a[i].first - a[k].first)*a[i].second;
                }
                cmin(now, s);
            }
            //cmin(dp[i+1][j], dp[i][j]);
            rep(j,n) cmin(dp[r][j+1], dp[l][j]+now);
            
            now = 0;
            REP(i,l,r){
                now += abs(a[i].first)*a[i].second;
            }
            rep(j,n+1) cmin(dp[r][j], dp[l][j] + now);
        }
    }
    return dp[n];
    /*
    rep(s,(1LL << n)){
        vector<ll> p(1,0);
        rep(i,n){
            if((s>>i)&1LL){
                p.push_back(a[i].first);
            }
        }
        ll now = 0;
        rep(i,n){
            ll m = 1e18;
            rep(j,p.size()) cmin(m, abs(a[i].first - p[j]));
            now += m*a[i].second;
        }
        ll b = p.size() - 1;
        cmin(res[b], now);
    }*/
    //return res;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> X(N),Y(N),P(N);
    rep(i,N){
        cin >> X[i] >> Y[i] >> P[i];
    }
    vector<ll> ans(N+1,1e18);
    rep(s, (1LL << N)){
        vector<Pll> ax, ay;
        rep(i, N){
            if((s >> i)&1LL){
                ax.push_back(Pll(X[i], P[i]));
            }else{
                ay.push_back(Pll(Y[i], P[i]));
            }
        }
        vector<ll> dx = calc(ax);
        vector<ll> dy = calc(ay);
        rep(i,dx.size()){
            rep(j,dy.size()){
                cmin(ans[i+j], dx[i]+dy[j]);
            }
        }
    }
    rep(i,N+1){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main(){
	int n,x,y,z,num;
	cin >> n;
	int work[4][3][10];
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				work[i][j][k] = 0;
			}
		}
	}
	for(int i = 0;  i < n; i++){
		cin >> x >> y >> z >> num;
		work[x - 1][y - 1][z - 1] += num;
	}
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				cout << " " << work[i][j][k];
			}
			cout << endl;
		}
		if(i < 3){
			cout << "####################" << endl;
		}
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k; cin>>n>>k;
	vll v(n);
	rep(i, n) cin>>v[i];

	ll ans = 0;
	priority_queue<ll, vll, greater<ll>> que;
	for(int i=1; i<=min(n, k); i++){
		for(int a=0; a<=i; a++){
			ll sum = 0;
			rep(j, a) que.push(v[j]);
			rep(j, i-a) que.push(v[n-j-1]);
			rep(l, k-i){
				if (!que.size()) break;
				if (que.top()<0){
					que.pop();
				}
			}
			while(que.size()){
				sum += que.top(); que.pop();
			}
			ans = max(ans, sum);
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<string>
#include<cstdio>
#include<cstring>
#define rep(i,a) for(int i=0;i<(a);++i)
#define repd(i,a) for(int i=(a);i>=0;--i)
#define clr(a,v) memset((a),(v),sizeof(a))

char A[502], B[502];
int M;

int dp[501][2][10][3][501];

int rec( const std::string &br, int i, bool smaller, int prv, short up, int mod )
{
	if( i == br.size() )
		return !mod;

	int &ret = dp[i][smaller][prv][up][mod];
	if( ~ret )
		return ret;

	ret = 0;
	rep( d, smaller?10:br[i]-'0'+1 ) if( !d||d!=prv )
		if( up==2 || up==1&&d<prv || !up&&d>prv )
			ret = (ret + rec( br, i+1, smaller|d!=br[i]-'0', d, up==2&&!prv?2:d>prv, (mod*10+d)%M )) % 10000;

	return ret;
}

int main()
{
	scanf( "%s%s%d", A, B, &M );
	
	int c = 1, e = strlen(A)-1;
	repd( i, e )
	{
		A[i]-=c;
		c=0;

		if( A[i]-'0' < 0 )
			A[i]+=10, c=1;
	}

	clr( dp, -1 ); int upr = rec( B, 0, false, 0, 2, 0 );
	clr( dp, -1 ); int lwr = rec( A, 0, false, 0, 2, 0 );
	printf( "%d\n", (upr-lwr+10000)%10000 );

	return 0;
}

Measured memory_bytes: 59948
#![allow(unused_imports, unused_macros, non_snake_case)]
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

//{{{ macros missing in 1.15.1
#[macro_use]
mod macros {
    macro_rules! eprint {
        ($($t:tt)*) => {{
            use ::std::io::Write;
            let _ = write!(::std::io::stderr(), $($t)*);
        }};
    }
    macro_rules! eprintln {
        () => { eprintln!(""); };
        ($($t:tt)*) => {{
            use ::std::io::Write;
            let _ = writeln!(::std::io::stderr(), $($t)*);
        }};
    }
    macro_rules! dbg {
        ($val:expr) => {
            match $val {
                tmp => {
                    eprintln!(
                        "[{}:{}] {} = {:#?}",
                        file!(),
                        line!(),
                        stringify!($val),
                        &tmp
                    );
                    tmp
                }
            }
        };
    }
}
//}}}

fn run() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    let n: usize = sc.read();
    println!("{}", n * n);
}

fn main() {
    std::thread::Builder::new()
        .name("run".to_string())
        .stack_size(1024 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap()
}

//{{{ Scanner
pub struct Scanner<R> {
    reader: R,
}

impl<R> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner { reader: r }
    }
}

fn is_whitespace(b: u8) -> bool {
    b == b' ' || b == b'\n' || b == b'\r' || b == b'\t'
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        let buf = std::io::Read::bytes(self.reader.by_ref())
            .map(|b| b.expect("Read failed"))
            .skip_while(|&b| is_whitespace(b))
            .take_while(|&b| !is_whitespace(b))
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error")
    }

    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
//}}}


Measured memory_bytes: 8572
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int n=1,x=1;
  while(1){
    cin>>n>>x;
    if(n+x==0)break;
    int cnt=0;
    REP(i,1,n+1)REP(j,i+1,n+1)REP(k,j+1,n+1)if(i+j+k==x)cnt++;
    cout<<cnt<<endl;
  }
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}


Measured memory_bytes: 3100
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

typedef long long ll;

int main()
{
    ll n;
    //>>n;
    //int a[5];
    ll x;
    for(int i=0;i<5;i++)
    {
        cin>>n;
        if(n==0)
        {
            x=i;
            break;
        }
    }
    cout<<x+1;

    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){

    ll n;
    cin >> n;
    int a,b,c;
    a = n%10;
    b = (n/10)%10;
    c = (n/100)%10;
    if(a==7||b==7||c==7) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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


Measured memory_bytes: 3648
#define NDEBUG
NDEBUG


#include <algorithm>
#include <cassert>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <random>

#define FOR(i, n) for (int i = 0; i < (n); ++i)


using namespace std;

/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);


namespace template_util {


    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    /// caide keep
    template<int N>
    struct bytetype {

    };

    /// caide keep
    template<>
    struct bytetype<4> {

    };

    /// caide keep
    template<>
    struct bytetype<3> {

    };

    /// caide keep
    template<>
    struct bytetype<2> {

    };

    /// caide keep
    template<>
    struct bytetype<1> {

    };

    /// caide keep
    template<>
    struct bytetype<0> {

    };

    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


void solve(istream& in, ostream& out) {
    string s = next<string>(in);
    int delta1 = 0, delta2 = 0;
    FOR(i, s.length()) {
        if (s[i] == 'S') {
            delta1 |= 1;
        }
        if (s[i] == 'N') {
            delta1 |= 2;
        }
        if (s[i] == 'E') {
            delta2 |= 1;
        }
        if (s[i] == 'W') {
            delta2 |= 2;
        }
    }
    if (delta1 == 0) delta1 = 3;
    if (delta2 == 0) delta2 = 3;
    if (delta1 == 3 && delta2 == 3) {
        out << "Yes\n";
    } else {
        out << "No\n";
    }

}


int main() {
    solve(cin, cout);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define MAX_N 40
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
const long long int MOD = 1000000007;
const long long int INF = 100000000000000;

string str;

bool dfs(string s){
    if(s == "ABC") return true;
    if(s.size() <= 4) return false;
    string pre;
    int vari = 0;
    rep(i,s.size()){
        if(i+2 >= s.size()){
            pre.push_back(s[i]);
            vari |= (1<<(s[i]-'A'));
            continue;
        }
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            pre.push_back('_');
            i += 2;
        } else{
            pre.push_back(s[i]);
            vari |= (1<<(s[i]-'A'));
        }
    }
    if(vari == 3) vari = 2;
    else if(vari == 5) vari = 1;
    else if(vari == 6) vari = 0;
    else return false;
    string now;
    rep(j,pre.size()){
        if(pre[j] != '_'){
            now.push_back(pre[j]);
        } else{
            if(vari == 0) now.push_back('A');
            if(vari == 1) now.push_back('B');
            if(vari == 2) now.push_back('C');
        }
    }
    return dfs(now);
}

int main(){
    cin >> str;
    if(dfs(str)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 34032
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using P = pair<int,int>;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int x; cin >> x;
    if(x >= 30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3524
N = int(input())
A = list(map(int,input().split(" ")))
box = [0] * N

for i in range(N, N//2, -1):
    if A[i-1] == 1:
        box[i-1] = 1
for i in range(N//2, 0, -1):
    s = 0
    for j in range(2, N//i + 1):
        s += box[(i*j)-1]
    if A[i-1] != s % 2:
        box[i-1] = 1
print(sum(box))
for i in range(N):
    if box[i] == 1:
        print(i+1)


Measured memory_bytes: 62672
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

int main(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    if(b<d) puts("0");
    else puts("1");
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,i;
	long long int b[10000],max,min,sum;
	sum=0;
	max=-10000000;
	min=10000000;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%lld",&b[i]);
		}
	for(i=0;i<a;i++){
		sum=sum+b[i];
		}
	for(i=0;i<a;i++){
		if(max<b[i]){
			max=b[i]; 
		}
	}
	for(i=0;i<a;i++){
		if(min>b[i]){
			min=b[i];
		}
	}
	printf("%lld %lld %lld\n",min,max,sum);
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    
    int a[100001];
    int i;
    for(i = 1; i <= n; i++){
        cin >> a[i];
    }
    
    bool v[100001] = {false, true};
    int cnt = 0;
    i = 1;
    
    while(i != 2){
        i = a[i];
        if(v[i] == true){
            cout << -1 << endl;
            return 0;
        }
        v[i] = true;
        cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 768
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    if(x % y == 0){
        cout << -1 << '\n';
    }else{
        cout << x << '\n';
    }
}


Measured memory_bytes: 256
import queue

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

A = sorted(A,reverse=True)

ans = 0
q = queue.Queue()
q.put(A[0])
for i in range(1,N):
    ans += q.get()

    q.put(A[i])
    q.put(A[i])

print(ans)




Measured memory_bytes: 101284