akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<cstdlib>
#define range(i,a,b) for(int i = (a); i <= (b); i++)
#define rrange(i,a,b) for(int i = (a); i >= (b); i--)
#define rep(i,b) for(int i = 1; i <= (b); i++)
#define rrep(i,b) for(int i = (b); i >= 1; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long ll;
const int N=1e5+11,INF=~0u>>2;
char s[N],ans[N]="CODEFESTIVAL2016"; 
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	scanf("%s",s);
	int cnt=0;
	range(i,0,15) if(s[i]!=ans[i]) cnt++;
	printf("%d",cnt);
	return 0;
}

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

int main() {
    int N,A;
    cin>>N>>A;
    while (N>=500) {
        N=N-500;
    }
    if (A>=N) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}


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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;
const int SZ = 2;
const int MOD = 1e9 + 7;

ll fact[nax], invfact[nax], inverse[nax];

void pre()
{
	fact[0] = 1;
	forn(i, 1, nax)
	{
		fact[i] = mult(fact[i - 1], i);
	}

	invfact[nax - 1] = mypow(fact[nax - 1], mod - 2);

	ford(i, nax, 1)
	{
		invfact[i - 1] = mult(invfact[i], i);
	}
}

ll ncr(ll n, ll r)
{
	if (r > n)
		return 0;

	ll ans = mult(fact[n], mult(invfact[n - r], invfact[r]));

	return ans;
}



int main()
{
	speedup_IO;
	pre();
	ll n, k;
	cin >> n >> k;

	ll a[n];
	forn(i, 0, n)
	{
		cin >> a[i];
	}

	sort(a, a + n);

	vector<ll>cnt;
	forn(i, 0, n)
	{
		ll j = i;
		ll x = 0;
		while (j < n && a[j] == a[i])
		{
			x++;
			j++;
		}
		cnt.pb(x);
		i = j - 1;
	}

	ll maxi = 0, mini = 0;

	ll upto = 0;
	for (ll j = cnt.size() - 1; j >= 0; j--)
	{
		ll x = cnt[j];
		upto += x;
		forn(i, 1, min(k, x) + 1)
		{
			if (n - upto >= 0 && x - i >= 0 && n - upto - (k - i) >= 0)
			{
				// if (a[n - upto] < 0)
				// {
				// 	a[n - upto] += mod;
				// }
				ll y = ncr(x, i);
				y = mult(y, ncr(n - upto, k - i));
				y = mult(a[n - upto], y);
				maxi = add(maxi, y);
			}
		}
	}

	upto = 0;
	for (ll j = 0; j < (ll)cnt.size(); j++)
	{
		ll x = cnt[j];
		upto += x;
		forn(i, 1, min(k, x) + 1)
		{
			if (n - upto >= 0 && x - i >= 0 && n - upto - (k - i) >= 0)
			{
				// if (a[n - upto] < 0)
				// {
				// 	a[n - upto] += mod;
				// }
				ll y = ncr(x, i);
				y = mult(y, ncr(n - upto, k - i));
				y = mult(a[upto - 1], y);
				mini = add(mini, y);
			}
		}
	}

	ll ans = sub(maxi, mini);
	cout << ans;
	return 0;
}

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

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

    vector<long long> A(n);
    vector<long long> B(n);
    for(long long i=1; i<n; i++){
        cin >> A.at(i);
        B.at(A.at(i)-1)+=1;
    }

    for(long long i=0; i<n; i++){
        cout << B.at(i) << endl;
    }
}


Measured memory_bytes: 6360
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
3
8 3
0 1
4 8
)");
#define cin input
#endif

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

	ll s = 0;
	int m = 1 << 30;
	REP (i, n)
	{
		int a, b;
		cin >> a >> b;
		s += a;
		if (a > b)
			m = min(m, b);
	}

	cout << (m == 1 << 30 ? 0 : s - m) << endl;

	return 0;
}


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

int main() {
  int divisor[100];
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = 0; i < 100; i++)
    divisor[i] = 0;
  
  int min_num = min(A, B);
  int index = 0;
  for (int i = 1; i <= min_num; i++) {
    if (A % i == 0 and B % i == 0) {
      divisor[index] = i;
      index++;
    }
  }
  
  cout << divisor[index-K] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fr ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include<string>
#include<algorithm>
#include<vector>
const long long int maxn = 1e3+2;
const long long int mod = 1e3+2;

int main()
{
	fr
	ll n, w;
	cin>>n>>w;
	ll wei[n+2], v[n+2];
	for(ll i=0;i<n;i++)
		cin>>wei[i]>>v[i];
	ll dp[n+2][w+2];
	memset(dp, 0, sizeof(dp));
	
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<=w;j++)
		{
			if(i==0 || j==0)	
				dp[i][j] = 0;
			else if(wei[i-1] <= j)
				dp[i][j] = max( ( v[i-1]+dp[i-1][j-wei[i-1]] ), dp[i-1][j]);
			else
				dp[i][j] = dp[i-1][j];		
		}
	}
	
	cout<<dp[n][w]<<endl;
	return 0;

}


Measured memory_bytes: 80000
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    int n, z, w, a[2005];
    cin >> n >> z >> w;
    for (int i = 0; i < n; i++) cin >> a[i];
    if (n == 1)cout << abs(w-a[0]);
    else cout << max(abs(w-a[n-1]), abs(a[n-1]-a[n-2]));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define SYOKIKA 0
int main (){
int N,M,sub[51][4]={0};
cin>>N>>M;
for (int i=1;i<=N;i++){for (int j=1;j<=M;j++){
char tmp; cin>>tmp;
if (tmp!='W'){sub[i][1]++;}
if (tmp!='B'){sub[i][2]++;}
if (tmp!='R'){sub[i][3]++;}
}
}
int WHITEsum=SYOKIKA,BLUEsum=SYOKIKA,REDsum=SYOKIKA,ALLsum=50*50;

for (int i=1;i<=N-2;i++){WHITEsum+=sub[i][1]; BLUEsum=SYOKIKA;
   for (int j=i+1;j<=N-1;j++){BLUEsum+=sub[j][2]; REDsum=SYOKIKA;
      for (int k=j+1;k<=N;k++){REDsum+=sub[k][3];}
     ALLsum=min(ALLsum,WHITEsum+BLUEsum+REDsum);
}}

cout<<ALLsum<<endl;

return 0;
}



Measured memory_bytes: 3088
//13 kagami mochi
#include<bits/stdc++.h>
using namespace std;

int main(){
  int num;
  cin>>num;
  vector<int> mochi(num);
  for(int i=0; i<num; i++){
    cin>>mochi.at(i);
  }
  sort(mochi.begin(),mochi.end());
  int x=1;
  for(int i=1; i<num; i++){
    if(mochi.at(i) > mochi.at(i-1)){
      x++;
    }
  }
  cout<<x<<endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)



int main() {
	int i=0,j=0,n,a,b,an=0,bn=0,cn=0;
	cin >> n>>a>>b;
	vector<char>s(n);
	rep(i, n) {
		cin >> s.at(i);
		if (s.at(i) == 'a') {
			an++;
			
		}
		else if (s.at(i) == 'b') {
			bn++;
			
		}
		else if (s.at(i) == 'c') {
			cout << "No" << endl;
		}
		if (s.at(i) == 'a') {
			if (an + bn <= a + b) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (s.at(i) == 'b') {
			if (an + bn <= a + b && b >= bn) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
				bn--;
			}
		}

	}
	return 0;
}

Measured memory_bytes: 3736
#include<cstdio>
#include<algorithm>
using namespace std;
int n, w[201000];
long long sum;
int main() {
	int i;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
	}
	if (w[1] != 0) {
		puts("-1");
		return 0;
	}
	for (i = 1; i < n; i++) {
		if (w[i + 1] > w[i] + 1) {
			puts("-1");
			return 0;
		}
	}
	for (i = 1; i <= n + 1; i++) {
		if (w[i] != w[i - 1] + 1)sum += w[i-1];
	}
	printf("%lld\n", sum);
}

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

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N + 1), b(N + 1);
    rep(i, N) cin >> a[i + 1];
    for(int i = N; i >= 1; i--) {
        int cnt = 0;
        for(int j = N / i; j >= 1; j--) {
            if(b[i * j]) {
                cnt++;
            }
        }
        if(a[i] != cnt % 2) {
            b[i] = 1;
        }
    }
    int sum = accumulate(b.begin(), b.end(), 0);
    cout << sum << endl;
    if(sum) {
        for(int i = 1; i <= N; i++) {
            if(b[i]) {
                cout << i << " ";
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 6288
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 1e7 + 5;
ll sumdiv[N], ans, n;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    for(ll i = 1; i < N; ++i)
        for(ll j = i;j < N; j += i)
            ++sumdiv[j];
    cin >> n;
    for(ll i = 1;i <= n;++i)
        ans += sumdiv[i] * i;
    cout << ans;
    return 0;
}


Measured memory_bytes: 81720
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

string ans = "xxoxxxabcxdefghxijkxxxoxx";

class board{
public:
  int h,c;
  string s;
  board(int x,int y,string z){ h=x; c=y; s=z;}
  const bool operator<(const board x)const{return h+c>x.h+x.c; }
};

int score(string s){
  int res=0,m;
  for(int i=0;i<25;i++){
    if(s[i]!='x' && s[i]!='o'){
      for(int j=0;j<25;j++){
	if(s[i]==ans[j]){
	  m = abs(i/5-j/5) + abs(i%5-j%5);
	  break;
	}
      }
      res += m;
    }
  }
  return res;
}

char trans(int x){
  if(!x)return 'o';
  else return 'a'+x-1;
}

int main(){
  string s = "xxxxxxxxxxxxxxxxxxxxxxxxx";
  int tmp,cost;

  for(;;){
    cin >> tmp;
    if(tmp<0)break;

    s[2] = trans(tmp);
    for(int i=0;i<3;i++){
      cin >> tmp;
      s[6+i] = trans(tmp);
    }
    for(int i=0;i<5;i++){
      cin >> tmp;
      s[10+i] = trans(tmp);
    }
    for(int i=0;i<3;i++){
      cin >> tmp;
      s[16+i] = trans(tmp);
    }
    cin >> tmp;
    s[22] = trans(tmp);

    priority_queue<board> q;
    q.push(board(score(s),0,s));

    //map<string,bool> m;
    //m[s] = true;
    while(q.size()){
      board p = q.top();q.pop();
      int dx[] = {-5,1,5,-1};

      cost = p.c;
      if(p.s == ans)break;
      if(p.h+cost>20){
	cost = 21;
	break;
      }

      //m[p.s] = true;
      for(int i=0;i<25;i++){
	if(p.s[i]=='o'){
	  for(int j=0;j<4;j++){
	    int sx = i + dx[j];
	    string str = p.s;
	    if(sx<0 || 25<=sx)continue;
	    if(str[sx] == 'x' || str[sx] == 'o')continue;
	    swap(str[i],str[sx]);
	    /*if(!m[str])*/q.push(board(score(str),cost+1,str));
	  }
	}
      }
    }

    if(cost>20)cout << "NA\n";
    else cout << cost << endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		if(A==1) {
			if(B==2) {
				System.out.println(3);
			}else {
				System.out.println(2);
			}
		}else {
			if(A==2) {
				if(B==1) {
					System.out.println(3);
				}else{
					System.out.println(1);
				}
			}else {
				if(B==1) {
					System.out.println(2);
				}else {
					System.out.println(1);
				}
			}
		}
	}
}

Measured memory_bytes: 25428
import math

A, B, H, M = map(int, input().split())

hour = H
if H <= 12:
  hour = H
else:
  hour = H - 12

minute = M;

# 短針の角度取得
rShort = (hour * (360 / 12)) + minute * 1/2;

# 長針の角度取得
rLong = minute * (360 / 60);

# 角度取得
ang = abs(rLong - rShort);
# 角度が小さいほうを表示
kakudo = min(ang,(360 - ang))

cos = math.cos(math.radians(kakudo))

x = A**2 + B**2 - 2 * A * B * cos

print(x ** 0.5)

Measured memory_bytes: 9584
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

const int MAX = 5100000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll com(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x, y;
comb_init();
  cin >> x >> y;
  ll cnt = 0;
  ll res = 0;
  while(true){
    ll x1 = 0;
    ll x2 = 0;
    ll y1 = 0, y2 = 0;
    // if(x % 2 == 0){
      x2 = cnt;
      x1 = x - (x2 * 2);
      y2 = x1;
      y1 = x2;
    // }

    if(x1 + x2*2 == x && y1 + y2*2 == y) {
      res += com(x1+x2, x1);
      res %= MOD;
    }else if(cnt > x && cnt > y) break;
    cnt++;
  }
  cout << res << endl;
}


Measured memory_bytes: 119808
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
	  String[] forecast = sc.nextLine().split("");
      String[] ans = sc.nextLine().split("");
      int count = 0;
	  for (int i = 0; i < 3; i++) {
        if (forecast[i].equals(ans[i])) {
          count++;
        }
      }

      System.out.println(count);
    }
}

Measured memory_bytes: 23124
<?php
fscanf(STDIN,"%d %d",$L,$R);
if($R-$L>=2019){
  //$R-$Lが2019以上なら間に2019の倍数を含むので最小剰余は必ず0
  $result = 0;
}elseif($R*($R-1)<2019){
  //$L*$Rが2019以上でない場合、最小剰余は$L*($L+1)
  $result = $L*($L+1);
}else{
  //1組目を初期値にする
  $result = (($L%2019)*(($L+1)%2019))%2019;
  //総当り
  for($i=$L;$i<=$R-1;$i++){
    if($result === 0) break;
    for($j=$i+1;$j<=$R;$j++){
      if($result === 0) break;
      //最小値更新
      if($result > (($i%2019)*($j%2019))%2019) $result = (($i%2019)*($j%2019))%2019;
    }
  }
}
echo $result;


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  int n,m;
  cin>>n>>m;
  int a;
  priority_queue<int> que;
  for(int i=0;i<n;i++){
    cin>>a;
    que.push(a);
  }
  for(int i=0;i<m;i++){
    a=que.top();
    que.pop();
    que.push(a/2);
  }
  a=0;
  while(!que.empty()){
    a+=que.top();
    que.pop();
  }
  cout<<a;
  return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int C = sc.nextInt();
    int[] B = new int[M];
    int[][] A = new int[N][M];
    for(int i=0; i<M; i++){
      B[i] = sc.nextInt();
    }
    for(int i=0; i<N; i++){
      for(int j=0; j<M; j++){
        A[i][j] = sc.nextInt();
      }
    }
    int count = 0;
    for(int i=0; i<N; i++){
      int wa = C;
      for(int j=0; j<M; j++){
        wa += B[j] * A[i][j];
      }
      if(wa > 0){
        count++;
      }
    }
    System.out.print(count);
  }
}


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

int main(){
  
  string s,t;
  cin>>s>>t;
  int n;
  n=int(s.size());
  
  
  string answer="No";

  
  for (int i=0;i<n;i++){
    
    bool flag=true;
    
    for (int j=0;j<n;j++){
      if (s.at(j)!=t.at((i+j)%n)){
        flag=false;
        break;
      }
    }
    
    if (flag==true){
      answer="Yes";
      break;
    }
  }

  cout<<answer<<endl;
    
}
  













Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
long long const p=1000000007;
long long prod(long long a,long long b,long long step=1){
    long long ans=1;
    for(long long i=a;i<=b;i+=step){
        ans=(ans*i)%p;
    }
    return ans;
}
inline long long factorial(long long n){
    return prod(1,n);
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    if(std::abs(n-m)>1){
        printf("0");
        return 0;
    }
    printf("%lld",(factorial(n)*factorial(m)%p)*((n==m)?2:1)%p);
    return 0;
}

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

using namespace std;

typedef long long ll;

#define  kak 1000000000000;



int main(){
    ll N;
    cin >> N;
    vector<int> a(N);
    map<int,int> X;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        X[a[i]]++;
        X[a[i] + 1]++;
        X[a[i] - 1]++;
    }

    int max = 0;
    int key = 0;
    for (auto it = X.cbegin(); it != X.cend(); ++it) {
        //cout<<it->first<<","<<it->second<<endl;
        if (max <= it->second) {
            max = it->second;
            key = it->first;
        }
    }

    cout << X[key]<<endl;


    return 0;
}




Measured memory_bytes: 5120
from collections import Counter

input()
t = Counter([int(i) for i in input().split()])
ans = []
for k, v in t.items():
  if v >= 2:
    if v >= 4:
      ans.extend([k, k])
    else:
      ans.append(k)
ans.sort()
if len(ans) < 2:
  print(0)
else:
  print(ans[-1]*ans[-2])


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    vec A(3);
    cin >> A[0] >> A[1] >> A[2];

    ll ans = 0;
    while(!(A[0] == A[1] and A[1] == A[2])){
        sort(ALL(A));
        ++ans;
        if(A[0] == A[1]) ++A[0], ++A[1];
        else A[0] += 2;
    }

    print(ans);

    return 0;
}

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

int main(void)
{
  int n;
  char taca[101];
  char haca[101];
  int tapo=0;
  int hapo=0;
  int i;
  int result;
  
  scanf("%d",&n);

  for(i=0; i<n; i++){
    memset(taca,'\0',101);
    memset(haca,'\0',101);
    scanf("%s",taca);
    scanf("%s",haca);

    result=strncmp(taca,haca,101);
    if(result==0){
      tapo++;
      hapo++;
    }
    else if(result>0){
      tapo = tapo +3;
    }
    else{
      hapo = hapo +3;
    }
  }

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

Measured memory_bytes: 608
#include<bits/stdc++.h>
#define maxn 200050
using namespace std;
 
int n;
int a[maxn];
 
void init()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
        scanf("%d",a+i);
}
 
int N,pos[maxn],ch[maxn];

bool judge(int ans)
{
	N=0;
	for (int i=1;i<=n;++i)
	{
	    if (a[i]<=a[i-1])
	    {
	        while (pos[N]>a[i]) --N;
 
	        int last=a[i];
	        while (last==pos[N]&&ch[N]==ans)
	            --N,--last;
	            
			if (!last)	return 0;
				 
	        if (pos[N]==last)
	            ++ch[N];
	        else
	            ++N,pos[N]=last,ch[N]=2;
	        assert(ch[N]<=ans);
//		        cout<<ans<<":"<<N<<" "<<pos[N]<<" "<<ch[N]<<endl;
	    }
	}
	return 1;
}
 
void solve()
{
	int flag=1;
	for (int i=2;i<=n;++i)
		flag&=a[i-1]<a[i];
	if (flag)
		puts("1");
	else
	{
		int l=2,r=200050;
		while (l<r)
		{
			int mid=(l+r)>>1;
			if (judge(mid))
				r=mid;
			else
				l=mid+1;
		}
		printf("%d\n",l);
	}
}
 
int main()
{
    init();
    solve();
    return 0;
}

Measured memory_bytes: 1024
/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long double DEL = 1e-12;
const int mod =  1000000007;
const int LIM = 100005;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define ss second
#define ff first
 
int fpow(int x, int n)
{
    int res = 1;
    while(n){
          if(n&1){
                res = res * x % mod;
          }
          x = x * x % mod;
          n>>=1;
    }
    return res;
}
int gcd(int a,int b)
{
    if(b == 0)
    {
          return a;
    }
    return gcd(b,a % b);
}
void sieve(int n)
{
      bool prime[5*LIM];
      memset(prime, true, sizeof(prime));
      int rootn = (int)sqrt(n);
      for (int p = 2; p <= rootn; p++)
      {
            if (prime[p] == true)
            {
                  for (int i = p*p; i <= n; i += p)
                  {
                        prime[i] = false;
                  }
            }
      }
      prime[1] = 0;
}
int cnt, sum, mid, mx, mn, ans, a[2*LIM];
int n, m, d, p, q, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;

//******************************************* CHECK CONSTRAINTS **************************************************


int32_t main()
{     fio;
      cin>>n>>d;
      cnt = 0;
      while(n--)
            
      {
            cin>>x>>y;
            if(sqrt(sqr(x)+sqr(y))<=d)
            {
                  cnt++;
            }
      }
      cout<<cnt;
     
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    bool hantei=true;
    vector<int>t(n);
    vector<int>x(n);
    vector<int>y(n);
    rep(i,n){
        cin >> t[i];
        cin >> x[i];
        cin >> y[i];
    }
    if(n==1){
            if(t[0] < x[0]+y[0]) hantei=false;
            if(t[0]%2 != x[0]+y[0]) hantei=false;
        }
    rep(i,n-1){
        
        int move=t[i+1] - t[i];
        int x_kyori = abs(x[i] - x[i+1]);
        int y_kyori = abs(y[i] - y[i+1]);
        ll kyori = x_kyori+y_kyori;
        if(kyori > move) hantei =false;
        if(move%2 != kyori%2) hantei =false;
    }
    if(hantei) cout <<"Yes" <<endl;
    else cout <<"No" <<endl;
    return 0;
}

Measured memory_bytes: 1408
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}

bool comp(ll a,ll b)
{
	return a>b;
}

int main()
{
	speed;
	
	ll n,m;
	cin>>n>>m;

	ll arr[3][n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[0][i]>>arr[1][i]>>arr[2][i];
	}

	ll brr[n],a,b,c;
	ll mmax=INT_MIN;
	ll sum;
	for(ll k=0;k<8;k++)
	{
		a=((1)&k?1:-1);
		b=((1<<1)&k?1:-1);
		c=((1<<2)&k?1:-1);

		for(ll i=0;i<n;i++)
		{
			brr[i]=a*arr[0][i]+b*arr[1][i]+c*arr[2][i];
		}
		sort(brr,brr+n,comp);
		sum=0;
		for(ll i=0;i<m;i++)
		{
			sum+=brr[i];
		}
		mmax=max(sum,mmax);
	}
	cout<<mmax;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int n;cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;++i){
    int t;cin>>t;
    a[t-1] = i+1;
  }
  for(int i=0;i<n;++i){
    cout << a[i] << " ";
  }
  return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
int func(int s){
	int i=1,t[100000]={};

	while(1){
		t[s]+=i;
		if(t[s]>i){
			return i;
		}
		if(s%2==0)
			s=s/2;
		else
			s=3*s+1;
		i++;
	}
}

int main()
{
	int s,a;

	scanf("%d",&s);
	a=func(s);
	printf("%d",a);
	return 0;
}
/*
int func(int s){
	int i=0,f=0,c=0,t[1000]={};

	while(f==0){
		t[i]=s;
		if(s%2==0)
			s=s/2:
		else
			s=3*s+1;
		i++;
	}
}*/

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

    int main() {
        set<string> st;
        string tmp;
        int N;
        cin >> N;
        for(int i=0;i<N;i++){
            cin >> tmp;
            st.insert(tmp);
        }        
        cout << st.size() << endl;
        return 0;
    }


Measured memory_bytes: 19124
#include<bits/stdc++.h>
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int k,a,b;cin>>k>>a>>b;int c=0;
   for(int i=a;i<=b;i++)
   {
       if(i%k==0)
        {cout<<"OK";c++;
        break;
        }

   }
   if(c==0)
    cout<<"NG";

   return 0;

}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<vector<ll>> ab(n,vector<ll>());
    map<Pll,ll> mp;
    rep(i,n-1){
        ll a,b; cin >> a >> b;
        a--;b--;
        ab[a].emplace_back(b);
        ab[b].emplace_back(a);
        mp[Pll(a,b)] = i;
    }
    vector<ll> c(n-1,0);
    queue<Pll> que;
    que.push(Pll(-1,0));
    vector<ll> is_move(n,0);
    
    ll pre_color = -1;
    ll max_c = 0;
    // ll pre = -1;
    while(que.size()){
        Pll te = que.front();que.pop();
        ll t = te.second;
        pre_color = te.first;
        is_move[t] = 1;
        max_c = max(max_c,ll(ab[t].size()));
        ll next_color = 1;
        for(auto i : ab[t]){
            if(is_move[i])continue;
            ll temp = mp[Pll(t,i)];
            if(c[temp] == 0){
                if(next_color != pre_color){
                    c[temp] = next_color;
                }
                else{
                    c[temp] = next_color+1;
                    next_color++;
                }
                next_color++;
            }
            que.push(Pll(next_color-1,i));
        }
        
    }

    cout << max_c << endl;
    rep(i,n-1){
        cout << c[i] << "\n";
    }

}

Measured memory_bytes: 14592
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
const int INF=0x3f3f3f3f;
int book[maxn];

bool cmp(int a,int b) {return a>b;}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k,num=0,x;
    cin>>n>>k;
    memset(book,0,sizeof(book));
    for(int i=1;i<=n;i++) {
        cin>>x;
        book[x]++;
    }
    sort(book,book+maxn,cmp);
    for(int i=0;i<k;i++) num+=book[i];
    num=n-num;
    cout<<num<<endl;
    return 0;
}


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

int main(){
	int w[10], k[10], w_ans, k_ans;
	for(int i = 0; i < 10; i++){
		cin >> w[i];
	}
	sort(w,w+10,greater<int>());
	w_ans = w[0] + w[1] + w[2];

	for(int i = 0; i < 10; i++){
		cin >> k[i];
	}
	sort(k,k+10,greater<int>());
	k_ans = k[0] + k[1] + k[2];

	cout << w_ans << " " << k_ans << endl;


}

Measured memory_bytes: 1176
import math
H,W=map(int,input().split())
if H%3==0 or W%3==0:
  print(0)
  exit(0)
S=[0]*3
s=H*W/3
w0=math.ceil(s/H)
h0=math.ceil(s/W)

S[0]=w0*H
w1=W-W/3
w0=math.ceil(s/H)
h0=math.ceil(s/W)

S[0]=w0*H
w1=W-w0
if w1%2==0 or H%2==0:
  S[1]=(H*w1)//2
  S[2]=(H*w1)//2
else:
  s1=H*w1/2
  w10=math.ceil(s1/H)
  h10=math.ceil(s1/w1)
  S[2]=max((w1-w10)*H,(H-h10)*w1)
ans=abs(S[0]-S[2])

S[0]=W*h0
h1=H-h0
if h1%2==0 or W%2==0:
  S[1]=(W*h1)//2
  S[2]=(W*h1)//2
else:
  s1=h1*W/2
  w11=math.ceil(s1/h1)
  h11=math.ceil(s1/W)
  S[2]=max((W-w11)*h1,(h1-h11)*W)
ans=min(ans,abs(S[0]-S[2]))


S=[0]*3
s=H*W/3
w0=math.floor(s/H)
h0=math.floor(s/W)

S[0]=w0*H
w1=W-w0
if w1%2==0 or H%2==0:
  S[1]=(H*w1)//2
  S[2]=(H*w1)//2
else:
  s1=H*w1/2
  w10=math.floor(s1/H)
  h10=math.floor(s1/w1)
  S[2]=max((w1-w10)*H,(H-h10)*w1)
ans=min(ans,abs(S[0]-S[2]))

S[0]=W*h0
h1=H-h0
if h1%2==0 or W%2==0:
  S[1]=(W*h1)//2
  S[2]=(W*h1)//2
else:
  s1=h1*W/2
  w11=math.floor(s1/h1)
  h11=math.floor(s1/W)
  S[2]=max((W-w11)*h1,(h1-h11)*W)
ans=min(ans,abs(S[0]-S[2]))

print(ans)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define LL long long
 
const int N = 2e5 + 5;
 
LL n, ans, a[N], cnt[N];
 
int main() {
	scanf("%lld", &n);
	for (int i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]);
        ++cnt[a[i]];
    }
	for (int i = 1; i <= n; ++i) ans += 1LL * cnt[i] * (cnt[i] - 1) / 2;
	for (int i = 1; i <= n; ++i)
		printf("%lld\n", ans - cnt[a[i]] + 1);
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint h, w, k;
char c[10][10];


int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> h >> w >> k;
	for(int y = 0; y < h; y++){
		for(int x = 0; x < w; x++){
			cin >> c[x][y];
		}
	}
	
	llint H = 1<<h, W = 1<<w, ans = 0;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			llint cnt = 0;
			for(int y = 0; y < h; y++){
				for(int x = 0; x < w; x++){
					if(!(i & (1<<y)) && !(j & (1<<x)) && c[x][y] == '#') cnt++;
				}
			}
			if(cnt == k) ans++;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3644
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(1, N+1):
    d[i] = int(input())
used = defaultdict(bool)
i = 1
ans = 0
while True:
    i = d[i]
    ans += 1
    if used[i]:
        ans = -1
        break
    if i == 2:
        break
    used[i] = True
print(ans)

Measured memory_bytes: 28124
#include<bits/stdc++.h>
using namespace std;
char s[100100];
int n,k;
inline int Firstpos()
{
	int res=1;
	for(int i=2;i<=n+1;i++) for(int j=1;j<=n;j++) if(s[res+j-1]^s[i+j-1])
		{if(s[res+j-1]>s[i+j-1]) res=i;break;}
	return res;
}
int main()
{
	scanf("%d%d%s",&n,&k,s+1);k--;
	for(int i=1;i<=n;i++) s[n+i]=s[n-i+1];
	int cnt=1,now=Firstpos();
	while(s[now+1]==s[now]&&cnt+1<=n) now++,cnt++;
	while(k--){cnt=min(n,cnt*2);if(cnt==n) break;}
	for(int i=1;i<=cnt;i++) putchar(s[now]);
	for(int i=1;i<=n-cnt;i++) putchar(s[now+i]);
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
const int maxn=200+5;
const int inf=99999999;
int a[4];
bool dfs(int d,vector<int>&ans,int sum){
    if(d==4){
        if(sum==7){
            for(int i=0;i<ans.size();i++)
                printf("%d%c",a[i],ans[i]?'+':'-');
            printf("%d=7\n",a[3]);
            return true;
        }
        return false;
    }
    ans.push_back(1);
    if(dfs(d+1,ans,sum+a[d])) return true;
    ans.pop_back();ans.push_back(0);
    if(dfs(d+1,ans,sum-a[d])) return true;
    ans.pop_back();
    return false;
}
int main()
{
    char s[maxn]={};
    scanf("%s",s);
    for(int i=0;i<4;i++) a[i]=s[i]-'0';
    vector<int>ans;
    dfs(1,ans,a[0]);
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  long ans=0;
  int sgn=1;
  for(int i=0;i<N;i++){
    if(a[i]<0) sgn*=-1;
  }

  vector<int> b(N);
  for(int i=0;i<N;i++) b[i]=abs(a[i]);

  sort(b.begin(),b.end());

  if(sgn>0){
    for(int i=0;i<N;i++){
      ans+=b[i];
    }
  }

  if(sgn<0){
    for(int i=1;i<N;i++){
      ans+=b[i];
    }
    ans-=b[0];
  }

  cout<<ans<<endl;




  }


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll a, p; cin >> a >> p;
  cout << (a*3+p)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
X = [0] * N
#iとi+1について式が成り立つ場合、漸化式がつくれる
X[0] = S - 2 * sum(A[1::2])
for i in range(1, N):
    X[i] = 2 * A[i-1] - X[i-1]
print(*X)


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

int solution() {
    string s;
  	cin >> s;
  	if (s == "ABC") cout << "ARC";
  	else cout << "ABC";
    return 0;
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cin >> TN;
    for (ll i = 0; i<TN; ++i) solution();
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	string s;
	cin >> s;
	ll res=0;
	for(char x:s) res+=x-'0';
	if(res%9==0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3744
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static Node[] nodes = new Node[30];
    static final int NONE = -1;

    public static void main(String[] args) {
        new Main().run();
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        nodes = new Node[N];
        IntStream.range(0, N).forEach(i -> nodes[i] = new Node());
        IntStream.range(0, N).forEach(i -> {
            int num = sc.nextInt();
            Node node = nodes[num];
            node.number = num;
            node.left = sc.nextInt();
            node.right = sc.nextInt();
            if(node.left != NONE) nodes[node.left].parent = node.number;
            if(node.right != NONE) nodes[node.right].parent = node.number;
        });

        int rootNum = findRoot().number;
        System.out.println("Preorder");
        preParse(rootNum);
        System.out.println("\nInorder");
        inParse(rootNum);
        System.out.println("\nPostorder");
        postParse(rootNum);
        System.out.print("\n");
    }

    class Node {
        int number, left = NONE, right = NONE , parent = NONE;
    }

    public Node findRoot() {
        return Arrays.stream(nodes)
                .filter(s -> s.parent == NONE)
                .findFirst()
                .orElse(null);
    }

    public void preParse(int number) {
        if(number == NONE) return;
        System.out.print(" " + number);
        preParse(nodes[number].left);
        preParse(nodes[number].right);
    }

    public void inParse(int number) {
        if(number == NONE) return;
        inParse(nodes[number].left);
        System.out.print(" " + number);
        inParse(nodes[number].right);
    }

    public void postParse(int number) {
        if(number == NONE) return;
        postParse(nodes[number].left);
        postParse(nodes[number].right);
        System.out.print(" " + number);
    }
}






Measured memory_bytes: 32660
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long M = sc.nextLong();
            int V = sc.nextInt();
            int P = sc.nextInt();
            long[] A = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextLong();
            }

            Arrays.sort(A);

            long[] S = new long[N];
            for (int i = 0; i < N; i++) {
                if (i == 0) {
                    S[i] = A[i];
                } else {
                    S[i] = S[i - 1] + A[i];
                }
            }

            //System.out.println(Arrays.toString(A));

            long ans = -1;

            for (int i = 0; i < N; i++) {
                long K = A[i] + M;

                if (K < A[N - P]) {
                    continue;
                }

                long x = M * (V - i - 1);
                if (x <= 0) {
                    ans = N - i;
                    break;
                }

                int pos = Arrays.binarySearch(A, K + 1);
                if (pos < 0) {
                    pos = -(pos + 1);
                }

                //System.out.println(i + " x : " + x + " pos : " + pos);

                x -= K * (pos - i - 1) - (S[pos - 1] - S[i]);
                if (x <= 0) {
                    ans = N - i;
                    break;
                }

                x -= M * (N - pos);
                if (x <= 0) {
                    ans = N - i;
                    break;
                }

                x -= M * (pos - (N - P) - 1) - (K * (pos - (N - P) - 1) - (S[pos - 1] - S[N - P]));
                if (x <= 0) {
                    ans = N - i;
                    break;
                }
                
                //System.out.println(i + " x : " + x);
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 62220
#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 N; cin >> N;
  
  int p, m, c = 0;
  REP(i, N){
    cin >> p;
    if(i == 0){
      m = p;
      c++;
      continue;
    }
    if(m >= p) {
      m = p;
      c++;
    }
  }
  
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        List<String> list = new ArrayList<>();
        StringBuilder p = new StringBuilder();
        StringBuilder q = new StringBuilder();
        for (int i = 0; i < n; i++) {
            p.append(Integer.parseInt(sc.next()));
        }
        for (int i = 0; i < n; i++) {
            q.append(Integer.parseInt(sc.next()));
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= n; i++) {
            sb.append(i);
        }
        nextPermutation(list, sb.toString(), "");
        int a = list.indexOf(p.toString());
        int b = list.indexOf(q.toString());
        System.out.println(Math.abs(a - b));

    }

    private static void nextPermutation(List<String> list, String s, String ans) {
        if (s.length() == 0) {
            list.add(ans);
        } else {
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                String temp = s.substring(0, i) + s.substring(i + 1);
                nextPermutation(list, temp, ans + c);
            }
        }
    }
}


Measured memory_bytes: 47100
n, q = map(int, input().split())
s = list(input())

s.append("")

cusum = [0]*(len(s))
for i in range(len(s)-1):
    if s[i] == "A" and s[i+1] == "C":
        cusum[i+1] = cusum[i] + 1
    else:
        cusum[i+1] = cusum[i]

for _ in range(q):
    l, r = map(int, input().split())
    print(cusum[r-1] - cusum[l-1])


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

int main(){
  int x,h;

  while(1){
    double s;
    scanf("%d%d",&x,&h);
    if(!(x|h)) break;
    s = x * sqrt(x * x / 4.0 + h * h) * 2.0 + x * x;
    printf("%f\n",s);
  }

  return 0;
}

Measured memory_bytes: 0
n=int(input())
a=list(map(int, input().split()))

a_new=[0]*n
for i in range(n):
    a_new[i]=a[i]-i
a_new.sort()
b=a_new[(n-1)//2]
ans=0
for i in range(n):
    ans+=abs(a[i]-i-b)

print(int(ans))


Measured memory_bytes: 26128
#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
using namespace std;

#ifndef MDEBUG
#define NDEBUG
#endif

#define x first
#define y second
#define ll long long
#define d double
#define ld long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define pss pair<string,string>
#define psi pair<string,int>
#define pis pair<int,string>
#define psl pair<string,ll>
#define pls pair<ll,string>
#define wh(x) (x).begin(),(x).end()
#define ri(x) int x;cin>>x;
#define rii(x,y) int x,y;cin>>x>>y;
#define rl(x) ll x;cin>>x;
#define rv(v) for(auto&_cinv:v) cin>>_cinv;
#define wv(v) for(auto&_coutv:v) cout << _coutv << ' '; cout << endl;
#define ev(v) for(auto&_cerrv:v) cerr << _cerrv << ' '; cerr << endl;
#define MOD 1000000007

namespace std { 
template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
// auto fraclt = [](auto&a,auto&b) { return (ll)a.x * b.y < (ll)b.x * a.y; };
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }
template<typename T> void fracn(pair<T,T>&a) {auto g=gcd(a.x,a.y);a.x/=g;a.y/=g;}
template<typename T> struct Index { int operator[](const T&t){auto i=m.find(t);return i!=m.end()?i->y:m[t]=m.size();}int s(){return m.size();} unordered_map<T,int> m; };

int main(int,char**) {
    ios_base::sync_with_stdio(false);

    ri(N); ri(X);
    vector<int> A(N); rv(A);

    vector<int> C(N); C = A;
    ll ans = 1000000000000000LL;
    for (int i = 0; i < N; i++) {
        ll cur = i * X;
        for (int j = 0; j < N; j++) {
            cur += C[j];
            C[j] = min(C[j], A[(2*N+j-i-1)%N]);
        }
        ans = min(ans, cur);
    }
    cout << ans << endl;
}

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

#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define FOR(I,N) for(I=0;I<N;++I)

queue<ll> que;

void solve(vector<ll> adj[],ll ind[],ll dist[])
{
	ll x=que.front();	que.pop();
	ll i,s=adj[x].size();
	FOR(i,s)
	{
		ind[adj[x][i]]--;
		if(ind[adj[x][i]]==0)
		{
			dist[adj[x][i]] = dist[x]+1;
			que.push(adj[x][i]);
		}
	}
}

int main()
{
	ll n,m,i,x,y;
	cin>>n>>m;

	if(m==1)
		{cout<<1; return 0;}

	vector<ll> adj[n+1];
	ll ind[n+1], outd[n+1];
	memset(ind,0,sizeof(ll)*(n+1));
	memset(outd,0,sizeof(ll)*(n+1));
	FOR(i,m)
	{
		cin>>x>>y;
		adj[x].pb(y);
		ind[y]++;
		outd[x]++;
	}
	ll dist[n+1];
	memset(dist,0,sizeof(ll)*(n+1));
	for(i=1;i<=n;++i)
	{
		if(ind[i]==0)
			que.push(i);
	}
	while(que.empty()==0)
	{
		solve(adj,ind,dist);
	}
	ll ans=0;
	for(i=1;i<=n;++i)
		ans=max(ans,dist[i]);
	cout<<ans;
}

Measured memory_bytes: 8064
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    for(int i = 0; i < N; i++) cin >> D[i];
    sort(all(D));
    cout << D[D.size()/2] - D[D.size()/2 - 1] << endl;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
signed main(){
  fast;
  //usefile;
  //test
  {
    float l;
    cin>>l;
    float d=l/3.0;
    cout<<fixed<<setprecision(7)<<(d*d*d); 
  }
  //time("");
  return 0;
}

Measured memory_bytes: 256