akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc082/tasks/abc082_b

int main() {
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define INF (1LL<<31)-1
//#define MOD 998244353
#define MOD 1000000007

int main(){
    int a,b,h;
  cin>>a>>b>>h;
  cout<<(a+b)*h/2<<endl;
    
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  int n,k; cin >> n >> k; cout << n-k+1<< endl;
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 301;

int n, a;
ld dp[maxN][maxN][maxN];
bool flag[maxN][maxN][maxN];

ld f(int i, int j, int k)
{
    if (i == 0 && j == 0 && k == 0)
    {
        return 0;
    }
    if (flag[i][j][k])
    {
        return dp[i][j][k];
    }
    flag[i][j][k] = 1;
    dp[i][j][k] = 1;
    if (i > 0)
    {
        dp[i][j][k] += f(i - 1, j, k) * i / n;
    }
    if (j > 0)
    {
        dp[i][j][k] += f(i + 1, j - 1, k) * j / n;
    }
    if (k > 0)
    {
        dp[i][j][k] += f(i, j + 1, k - 1) * k / n;
    }
    return dp[i][j][k] /= (ld)(i + j + k) / n;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    vi freq(4);
    for1(i, n)
    {
        cin >> a;
        ++freq[a];
    }
    cout << fixed << setprecision(12) << f(freq[1], freq[2], freq[3]);
    return 0;
}


Measured memory_bytes: 452864
a=int(input())
b=list(map(int,input().split()))
c=[i for i in b if i%2==0]
d=len(c)
e=[j for j in c if j%3==0 or j%5==0]
f=len(e)
if d==f:
       print('APPROVED')
else:
       print('DENIED')

Measured memory_bytes: 3188
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int n,res;
int main(){
	cin>>n;
	for(R int i=10;i;i*=100){
		if(i-1<=n)res+=i-i/10;
		else{
			res+=max(n-i/10+1,0);
			break;
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main()
{
   long long int n, d, a;
   cin >> n >> d >> a;
   vector<pair<long long int, long long int>> v;
   for (int i = 0; i < n; i++)
   {
      long long int x, h;
      cin >> x >> h;
      v.push_back(make_pair(x, h));
   }
   sort(v.begin(), v.end());
   long long int ans = 0;
   long long int cnt[200000] = {};
   for (int i = 0; i < n; i++)
   {
      if (i > 0)
         cnt[i] += cnt[i - 1];
      long long int x = v[i].first;
      long long int h = v[i].second;
      long long int need = h / a;
      if (h % a > 0)
         need++;
      need -= cnt[i];
      if (need <= 0)
         continue;
      cnt[i] += need;
      int idx = lower_bound(v.begin(), v.end(), make_pair(x + 2 * d + 1, (long long int)0)) - v.begin();
      if (idx != v.size())
         cnt[idx] -= need;
      ans += need;
   }
   cout << ans << endl;
}

Measured memory_bytes: 7972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
static const int INF = 1000000000;
static int dp[101][101];

int main(){
	ios_base::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vector<string> field(h);
	for(int i = 0; i < h; ++i){ cin >> field[i]; }
	for(int i = 0; i <= h; ++i){
		for(int j = 0; j <= w; ++j){ dp[i][j] = INF; }
	}
	dp[0][0] = (field[0][0] == '#' ? 1 : 0);
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(j + 1 < w){
				if(field[i][j + 1] == '.'){
					dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
				}else{
					dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (field[i][j] == '#' ? 0 : 1));
				}
			}
			if(i + 1 < h){
				if(field[i + 1][j] == '.'){
					dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
				}else{
					dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (field[i][j] == '#' ? 0 : 1));
				}
			}
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}



Measured memory_bytes: 384
H, W = map(int, input().split())
s_list = [input() for _ in range(H)]
ans = 'Yes'
for i in range(1, H - 1):
	for j in range(1, W - 1):
		if s_list[i][j] == '#' and s_list[i-1][j] == s_list[i+1][j] == s_list[i][j-1] == s_list[i][j+1] == '.':
			ans = 'No'
			break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const int inf = 1000000000; // 10^9
int main()
{
  int N;
  cin >> N;
  vector<int> X(N);
  rep(i, N)
  {
    cin >> X[i];
  }
  int R = X[0];
  int L = X[0];
  rep(i, N)
  {
    L = min(L, X[i]);
    R = max(R, X[i]);
  }

  int ans = inf;
  for (int i = L; i <= R; i++)
  {
    int cost = 0;
    rep(j, N)
    {
      cost += (X[j] - i) * (X[j] - i);
    }
    ans = min(ans, cost);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define REP(var,start,stop,step) for(long long var=start;var<stop;var+=step)
#define fori(a,n) for(long long i=a;i<n;i++)
#define forj(a,n) for(long long j=a;j<n;j++)
#define fork(a,n) for(long long k=a;k<n;k++)
#define ee 1000000007
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
int main() {
	fio;
	ll t = 1;
	//cin >> t;
	while(t--) {
		string s, t1;
		cin >> s >> t1;
		s += t1[t1.size() - 1];
		if(s == t1) cout << "Yes\n";
		else cout << "No\n";
	}
}

Measured memory_bytes: 3624
#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;
 
int main() {
    ll t, x;
    cin >> t >> x;
    cout << setprecision(17) << (double)t / double(x) << endl;
}


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
using Graph = vector<vector<char>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  string S,S2;
  cin >> S >> S2;
  ll p = 1000000000 + 7;
  char cur;//直前の型
  ll ans = 0;

  if(S[0] == S[1]){
    cur = 'Y';
    ans = 6;
  }
  else{
    cur = 'X';
    ans = 3;
  }
  S.push_back('#');
  if(cur == 'X'){
  for(int i = 1;i<N;){
    if(S[i] != S[i+1] && cur == 'X'){
      ans *= 2;
      ans %= p;
      cur = 'X';
      i++;
    }
    if(S[i] != S[i+1] && cur == 'Y'){
      cur = 'X';
      i++;
    }
    if(S[i] == S[i+1] && cur == 'X'){
      ans *= 2;
      ans %= p;
      cur = 'Y';
      i += 2;
    }
    if(S[i] == S[i+1] && cur == 'Y'){
      ans *= 3;
      ans %= p;
      cur = 'Y';
      i += 2;
    }
  }
  cout << ans << endl;
  }
  else{
    for(int i = 2;i<N;){
    if(S[i] != S[i+1] && cur == 'X'){
      ans *= 2;
      ans %= p;
      cur = 'X';
      i++;
    }
    if(S[i] != S[i+1] && cur == 'Y'){
      cur = 'X';
      i++;
    }
    if(S[i] == S[i+1] && cur == 'X'){
      ans *= 2;
      ans %= p;
      cur = 'Y';
      i += 2;
    }
    if(S[i] == S[i+1] && cur == 'Y'){
      ans *= 3;
      ans %= p;
      cur = 'Y';
      i += 2;
    }
  }
  cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int a,b;
  cin >> a >> b;
  int  ans = 0;
  if(a>=13)ans=b;
  else if(a<=5) ans=0;
  else ans=b/2;
  cout << ans << endl;
  return 0;
}

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

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

using namespace std;

class mint{
	static const int MOD=998244353;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

int main(){
	string s; cin>>s;
	int n=s.length();

	vector<int> nr(n+1),nb(n+1);
	rep(i,n){
		if     (s[i]=='0') nr[i+1]=2;
		else if(s[i]=='1') nr[i+1]=1, nb[i+1]=1;
		else               nb[i+1]=2;
	}
	rep(i,n){
		nr[i+1]+=nr[i];
		nb[i+1]+=nb[i];
	}

	static mint dp[4001][4001]; // dp[r][b] = 赤を r 個, 青を b 個並べてできる列の個数
	dp[0][0]=1;
	rep(i,2*n){
		rep(r,i+1){
			int b=i-r;
			if(r<=nr[min(i,n)] && b<=nb[min(i,n)]){
				if(r+1<=nr[min(i+1,n)]) dp[r+1][b]+=dp[r][b];
				if(b+1<=nb[min(i+1,n)]) dp[r][b+1]+=dp[r][b];
			}
		}
	}

	mint ans=0;
	rep(r,2*n+1) ans+=dp[r][2*n-r];
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 62848
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double r = 2.0 * atan(1)*4.0 * (h / 12.0 + m / 720.0 - m / 60.0);
    double ans = sqrt(a * a + b * b - 2.0 * a * b * cos(r));
    
    printf("%.20lf\n", ans);
}


Measured memory_bytes: 4172
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
#define REP(i,b,e) for(int i=b;i<(int)e;i++)
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
ll INF=1e18;
int inf=1e9+1000;

string alpha="abcdefghijklmnopqrstuwvxyz";



ll N;
ll C;
ll D[40][40];
ll c[600][600];

void wf(){
    rep(k,C){
        rep(i,C){
            rep(j,C){
                D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
            }
        }
    }
}

ll a0[32];
ll a1[32];
ll a2[32];
ll c0[32];
ll c1[32];
ll c2[32];


int main(){
    cin>>N>>C;
    rep(i,C) rep(j,C) cin>>D[i][j];
    rep(i,N) rep(j,N) cin>>c[i][j];
    //wf();
    rep(i,C){
        a0[i]=a1[i]=a2[i]=0;
    }
    rep(i,N){
        rep(j,N){
            if((i+j)%3==0){
                a0[c[i][j]]++;
            }
            else if((i+j)%3==1){
                a1[c[i][j]]++;
            }
            else a2[c[i][j]]++;
        }
    }
  
    rep(i,C){
        rep(j,C){
            c0[i]+=(a0[j]*D[j][i]);
            c1[i]+=(a1[j]*D[j][i]);
            c2[i]+=(a2[j]*D[j][i]);
        }
    }
    ll ans=INF;
    rep(i,C){
        rep(j,C){
            rep(k,C){
                if(i!=j&&j!=k&&k!=i){
                    ans=min(ans,c0[i]+c1[j]+c2[k]);
                }
            }
        }
    }
    cout<<ans<<endl;



    return 0;
}

Measured memory_bytes: 2688
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            long[] A = in.Long(N);

            Map<Long, Long> map = new HashMap<>();
            for (int i = 0; i < N; i++) {
                long key = i - A[i];
                map.put(key, map.getOrDefault(key, 0L) + 1);
            }
            long cnt = 0;
            for (int i = 0; i < N; i++) {
                long key = i + A[i];
                cnt += map.getOrDefault(key, 0L);
            }
            out.println(cnt);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public long Long() {
            return Long.parseLong(next());
        }

        public long[] Long(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = Long();
            }
            return a;
        }

    }
}



Measured memory_bytes: 65656
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cstring>
#include <map>
#include <unordered_set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <stack>

typedef long long int ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define linebreak "\n"
#define space " "
#define PI atan(1)*4
#define E 5
#define ACCURATE cout << fixed << setprecision(6)
#define MAX (int)2e5
#define MOD (int)(998244353  )
#define ExpMod (int)(1e9 + 6 )
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define MAT_SIZE 5

//#define _DEBUG
using namespace std;

//#define _DEBUG
//====================================================================================================

int inverse(ll, ll);

//====================================================================================================
//====================================================================================================
//====================================================================================================
int powmod(ll a, ll b, ll mod) {
    //if (b < 0) return inverse(powmod(a, -1 * b));
    a %= mod;
    // b %= (mod - 1);
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = (res * 1ll * a) % MOD;
        }
        a = (a * 1ll * a) % MOD;
        b >>= 1;
    }
    return res % MOD;
}

int inverse(ll a, ll primemod) {
    return powmod(a, 500000002, primemod);
}

int nxt() {
    int x;
    cin >> x;
    return x;
}

int lcm(int a, int b) {
    return a * 1ll / __gcd(a, b) * b;
}

//====================================================================================================
//====================================================================================================
//====================================================================================================
//==================
int main() {
    int n, k;
    cin >> n >> k;
    vi a(k);
    int sum = 0;
    for (int i = 0; i < k; i++) {
        cin >> a[i];
        if (i > 0)
            sum += a[i] - a[i - 1];
    }
    sum += (a[0] - a[k - 1]) % n + n;
    int bet = 0;
    for (int i = 1; i < k; i++) {
        bet = max(bet, a[i] - a[i - 1]);
    }
    bet = max(bet, (a[0] - a[k - 1]) % n + n);
    cout << sum - bet;
    return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
class ModInt {
  static int MOD;
  long long x;

 public:
  static void mod(int m) { MOD = m; }

  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }

  long long val() { return x; }
};
int ModInt::MOD = 1000000007;

int N;
vector<vector<int>> G;
vector<vector<ll>> lpMemo, rpMemo;
vector<unordered_map<int, int>> id;

int subtreeCount(int, int);

// [0, pi)
int leftProduct(int u, int pi) {
  if (lpMemo[u][pi] != -1) return lpMemo[u][pi];

  return lpMemo[u][pi] = subtreeCount(G[u][pi - 1], u) + leftProduct(u, pi - 1);
}

// [pi, G[u].size())
int rightProduct(int u, int pi) {
  if (rpMemo[u][pi] != -1) return rpMemo[u][pi];

  return rpMemo[u][pi] = subtreeCount(G[u][pi], u) + rightProduct(u, pi + 1);
}

int subtreeCount(int u, int p) {
  if (p == -1) return leftProduct(u, G[u].size());

  return leftProduct(u, id[u][p]) + 1 + rightProduct(u, id[u][p] + 1);
}

int main() {
  cin >> N;
  G.resize(N);
  id.resize(N);
  lpMemo.resize(N), rpMemo.resize(N);

  auto addEdge = [&](int u, int v) {
    id[u][v] = G[u].size();
    G[u].push_back(v);
  };

  rep(i, N - 1) {
    int A, B;
    cin >> A >> B;
    --A, --B;
    addEdge(A, B);
    addEdge(B, A);
  }

  rep(i, N) {
    lpMemo[i].resize(G[i].size() + 1, -1);
    rpMemo[i].resize(G[i].size() + 1, -1);
    lpMemo[i][0] = 0;
    rpMemo[i][G[i].size()] = 0;
  }

  ModInt ans = (ModInt(2).pow(N - 1) - 1) * N;
  rep(u, N) {
    for (int v : G[u]) {
      ans -= ModInt(2).pow(subtreeCount(u, v)) - 1;
    }
  }
  ans /= ModInt(2).pow(N);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 79744
h,w=map(int,input().split())
grid=[input() for _ in range(h)]
mod=10**9+7
dp=[0]*w
for  i in range(h):
    for j in range(w):
        if i==j==0:
            dp[j]=1
        elif grid[i][j]=='#':
            dp[j]=0
        elif j>0:
            dp[j]=dp[j]+dp[j-1]
print(dp[w-1]%mod)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_d() {
	ll n;
	string s;
	ll ans = 0;

	cin >> n;
	cin >> s;

	V r, g, b;

	rep(i, n) {
		if (s[i] == 'R') {
			r.push_back(i);
		}
		else if (s[i] == 'G') {
			g.push_back(i);
		}
		else if (s[i] == 'B') {
			b.push_back(i);
		}
	}


	// rgb
	rep(i, r.size())rep(j, g.size()) {
		ll ma = max(r[i], g[j]);
		ll mi = min(r[i], g[j]);
		ll d = abs(r[i] - g[j]);

		// out
		ll cnt = 0;
		auto itr = lower_bound(ALL(b), ma + d);
		if (itr != b.end()) {
			if (*itr == ma + d) {
				cnt ++;
			}
		}

		itr = lower_bound(ALL(b), mi - d);
		if (itr != b.end()) {
			if (*itr == mi - d) {
				cnt++;
			}
		}

		// in
		if (d % 2 == 0) {
			itr = lower_bound(ALL(b), ma - d / 2);
			if (itr != b.end()) {
				if (*itr == ma - d / 2) {
					cnt++;
				}
			}
		}

		ans += max(0LL, (ll)b.size() - cnt);
	}

	cout << ans << "\n";
}

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

	solve_abc_d();

	return 0;
}


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

#define BITP 380000

int main(int argc, char const *argv[])
{
	int n;
	double tmp,yen = 0.00;
	char rate[3];
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		scanf(" %lf %s",&tmp,rate);
		if (strcmp(rate,"BTC") == 0)	tmp *= BITP;
		yen += tmp;
	}
	printf("%.6f\n", yen);
	return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
	char a[3][3];
	for (int i=0;i<3;i++)
	{
		for (int j=0;j<3;j++)
		{
			cin >> a[i][j];
		}
	}
	cout << a[0][0] << a[1][1] << a[2][2] << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll s[25][25];
ll s1[25];
ll min1;
int n,m,x;
void dfs(int g,ll sum)
{
	int flag=1;
	for(int i=1;i<=m;i++)
	{
		if(s1[i]<x)
		{
			flag=0;
			break;
		}
	}
	if(flag)
	{
		min1=min(min1,sum);
	}
	if(g>=n)
	{
		return ;
	}
	dfs(g+1,sum);
	for(int i=1;i<=m;i++)
	{
		s1[i]+=s[g][i];
	}
	dfs(g+1,sum+s[g][0]);
	for(int i=1;i<=m;i++)
	{
		s1[i]-=s[g][i];
	}
	return ;
}
int main()
{
	min1=1000000000000000;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++)
	{
		cin>>s[i][0];
		for(int j=1;j<=m;j++)
		{
			cin>>s[i][j];
		}
	}
	dfs(0,0);
	if(min1!=1000000000000000)
		cout<<min1<<endl;
	else
		cout<<-1<<endl;
	
	return 0;	
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<int> veci;

int N;

int main() {
    cin >> N;
    veci a(N);
    veci b(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];

    veci c(N);

    int res = 0;
    for (int i = 0; i < 29; i++) {
        int t = (1 << (i + 1));
        for (int j = 0; j < N; j++) c[j] = b[j] % t;
        sort(c.begin(), c.end());
        for (int j = 0; j < N; j++) {
            int one = 0;
            if (a[j] % t < (1 << i)) {
                auto r1 = lower_bound(c.begin(), c.end(), (1 << i) - a[j] % t);
                auto r2 = lower_bound(r1, c.end(), t - a[j] % t);
                one = (int)(r2 - r1);
            } else {
                auto r1 = lower_bound(c.begin(), c.end(), t - a[j] % t);
                auto r2 = lower_bound(r1, c.end(), (t + (1 << i)) - a[j] % t);
                one = (int)(r1 - c.begin()) + (int)(c.end() - r2);
            }
            if (one % 2 == 1)
                res ^= (1 << i);
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), c = scanner.nextInt();
			System.out.println((a - b == b - c) ? "YES" : "NO");
		}
	}
}


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



int main() {

    std::string ans = "no";
    int arr[4];

    for (int i = 0; i < 4; i++) {
        std::cin >> arr[i];
    }
    std::sort(arr, arr+4);

    (arr[0] == arr[1] && arr[2] == arr[3]) ? std::cout << "yes" << std::endl : std::cout << "no" << std::endl;


}



Measured memory_bytes: 3212
S = input()
c0 = S[len(S)//2]
r = S.find("1" if c0 == "0" else "0", len(S)//2)
if r < 0: r = len(S)
l = S.rfind("1" if c0 == "0" else "0", 0, len(S)//2)
l += 1
K = min(r, len(S)-l)
#print(l, r, K)
print(K)


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

using namespace std;

int main() {
    string t;
    int h,w;
    cin>>h>>w;
    int mp[h+2][w+2]={0};

    for(int i=1;i<=h;i++){
        cin>>t;
        for(int j=1;j<=w;j++){
            if(t[j-1]=='#')
                mp[i][j]=-1;
        }
    }
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++){
            if(mp[i][j]==-1){
                if(mp[i-1][j-1]!=-1)mp[i-1][j-1]++;
                if(mp[i][j-1]!=-1)mp[i][j-1]++;
                if(mp[i+1][j-1]!=-1)mp[i+1][j-1]++;

                if(mp[i-1][j]!=-1)mp[i-1][j]++;
                if(mp[i+1][j]!=-1)mp[i+1][j]++;

                if(mp[i-1][j+1]!=-1)mp[i-1][j+1]++;
                if(mp[i][j+1]!=-1)mp[i][j+1]++;
                if(mp[i+1][j+1]!=-1)mp[i+1][j+1]++;
            }
        }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(mp[i][j]==-1)
                cout<<"#";
            else
                cout<<mp[i][j];
        }
        cout<<endl;
    }

	return 0;
}


Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,m = lr()
count = [[0 for i in range(n)] for h in range(n)]
for i in range(m):
    a,b  = lr()
    a-=1
    b-=1
    a,b = min(a,b), max(a,b)
    count[a][b] += 1
    count[b][a] += 1
for i in range(n):
    print(sum(count[i]))

Measured memory_bytes: 77292
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------



int main() {
    while(1){
       int n,x,ans=0;
       cin>>n>>x;
       if(n==0&&x==0)break;
       rep2(i,1,n-1){
           rep2(j,i+1,n){
               rep2(k,j+1,n+1){
                   if(i+j+k==x)ans++;
               }
           }
       }
       cout<<ans<<endl;
    }
   
}



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

int main() {

int n,x;
cin >> n >> x;
while (n!=0||x!=0)
{ int ans=0;

    rep(i,n+1)
    {
      rep(j,i)
      {
        rep(k,j)
        {
          if(i+j+k==x&&k*i*j!=0)
          {ans++; //cout <<i<<":"<<j<<":"<<k<<endl;
          }
        }

      }
    }
  cout<<ans<<endl;
  //printf("%d\n",ans);
  cin >> n >>x;
}


return 0;

}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/


Measured memory_bytes: 3092
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
using namespace std;
int main () { 
	int x,a,b,y;
	cin >> x;
	if(x == 1){
		cout << "Hello World" << endl;
	}else if (x==2){
		cin >> a >> b;
		y = a + b;
		cout << y << endl;
	}
}
	

Measured memory_bytes: 764
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner t=new Scanner(System.in);
		int x;
		x=t.nextInt();
		boolean ok=false;
		for(int i=0;i<=9;i++) {
			for(int j=0;j<=9;j++) {
				if(i*j==x) {ok=true; break;}
			}
		}
		if(ok==true) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		t.close();
	}
}

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

using ll = long long;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W));
    rep(i, H) {
        rep(j, W) {
            cin >> a[i][j];
        }
    }
    vector<vector<int>> ans;
    rep(i, H) {
        rep(j, W - 1) {
            if (a[i][j] % 2) {
                ans.push_back({i + 1, j + 1, i + 1, j + 2});
                a[i][j]--;
                a[i][j + 1]++;
            }
        }
    }
    rep(i, H - 1) {
        if (a[i][W - 1] % 2) {
            ans.push_back({i + 1, W, i + 2, W});
            a[i][W - 1]--;
            a[i + 1][W - 1]++;
        }
    }
    cout << ans.size() << "\n";
    rep(i, ans.size()) {
        rep(j, 3) cout << ans[i][j] << " ";
        cout << ans[i][3] << "\n";
    }
}

Measured memory_bytes: 9904
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int v = ni(), e = ni();
        long[][] dist = new long[v][v];
        for (int i = 0; i < v; i++) {
            Arrays.fill(dist[i], INF);
        }
        for (int i = 0; i < v; i++) {
            dist[i][i] = 0;
        }

        for (int i = 0; i < e; i++) {
            int s = ni(), t = ni(), d = ni();
            dist[s][t] = d;
        }

        warshallFloyd(dist);

        for (int i = 0; i < v; i++) {
            if (dist[i][i] < 0) {
                out.println("NEGATIVE CYCLE");
                return;
            }
        }

        int BIG = (int) 1e12;
        for (int i = 0; i < v; i++) {
            for (int j = 0; j < v; j++) {
                if (j > 0) out.print(" ");
                out.print(dist[i][j] > BIG ? "INF" : dist[i][j]);
            }
            out.println();
        }
    }

    long INF = Long.MAX_VALUE / 3;
    void warshallFloyd(long[][] d) {
        int n = d.length;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    d[j][k] = Math.min(d[j][k], d[j][i] + d[i][k]);
                }
            }
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 35636
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct{
  int parent,left,right;
}family;
family t[MAX];

void preParse(int);
void inParse(int);
void postParse(int);

int main(){
  int i,id,lef,rig,root,n;
  scanf("%d",&n);
  for(i = 0;i < n;i++) t[i].parent = NIL;

  for(i = 0;i < n;i++){
    scanf("%d%d%d",&id,&lef,&rig);
    t[id].left = lef;
    t[id].right = rig;
    if(lef != NIL) t[lef].parent = id;
    if(rig != NIL) t[rig].parent = id;
  }
  for(i = 0;i < n;i++) if(t[i].parent == NIL) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  return 0;
}

void preParse(int u){
  if(u == NIL) return;
  printf(" ");
  printf("%d",u);
  preParse(t[u].left);
  preParse(t[u].right);
}

void inParse(int u){
  if(u == NIL) return;
  inParse(t[u].left);
  printf(" ");
  printf("%d",u);
  inParse(t[u].right);
}

void postParse(int u){
  if(u == NIL) return;
  postParse(t[u].left);
  postParse(t[u].right);
  printf(" ");
  printf("%d",u);
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int cnt=0,ans=0;
    rep(i,n-1) {
        if (h[i+1]>h[i]) cnt=0;
        else ++cnt;
        ans=max(ans,cnt);
    }
    
    cout << ans << endl;

    return 0;   
}

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

int main() {
    long long h, sum=0;
    cin >> h;
  
    long long prod = 1;
    while(prod <= h) {
        sum += prod;
        prod *= 2;
    }
    
  	cout << sum << endl;
  
    return 0;
}


Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())

    ans = 0
    for i in range(1, N+1):
        cnt = 0
        while i * 2**cnt < K:
            cnt += 1

        ans += 1 / N * (0.5)**cnt

    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 9316
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
s= input()
t = input()
ans = []
for j in range(len(s)-len(t)+1):
    cnt = 0
    moji = s[j:j+len(t)]
    for k in range(len(t)):
        if moji[k] != t[k]:
            cnt += 1
    ans.append(cnt)
print(min(ans))

Measured memory_bytes: 9944
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

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

//int gcd(LL x, LL y) { if (!y)return x; return g(y, x % y); }
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
int _lcm(int a, int b);
int _lcm(int a, int b) {
	return( (int)( (long)(a * b) / (long)_gcd(a, b) ));
}
	
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}


#pragma endregion

//131 C-Anti-Division
ll ll_gcd(ll a, ll b);
ll ll_gcd(ll a, ll b) {
	if (!b)return a; 
	return ll_gcd(b, a % b);
}
ll ll_lcm(ll a, ll b);
ll ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b) ;
}

int main(void) {
	ll  a, b, cnt = 0;
	ll c, d;
	
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	a -= 1;
	ll cc, dd,cd,lcm,ans;

	cc = b / c - a / c;
	dd = b / d - a / d;
	lcm = ll_lcm(c, d);
	cd = b / lcm - a / lcm;
	ans = (b-a)-((cc + dd) - cd);

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





Measured memory_bytes: 2120
#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()
{	while(1){
		string str;
		cin>>str;
		if(cin.eof()) return 0;
		for(int i=0;i<str.size();i++){
			if(str[i]=='@'){
				int n=str[i+1]-'0';
				for(int j=0;j<n;j++) cout<<str[i+2];
				i=i+2;
			}else cout<<str[i];
		}
		cout<<endl;		
	}
	return 0;
}

Measured memory_bytes: 1176