akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define f first
#define s second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 3e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));


ll n, a[maxn], ans;

int main() {
//    fin("t.in");
    sync;
    cin >> n;
    fi(1, 3 * n) {
        cin >> a[i];
    }
    sort(a + 1, a + 3 * n + 1);
    reverse(a + 1, a + 3 * n + 1);
    int r = 3 * n + 1;
    for (int i = 2; i < r; i += 2) {
        ans += a[i];
        --r;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
/*
* @Author: _dp95
* @Date:   2019-11-09 01:31:22
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*100 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

ll dp[ MAX ][ 100 ], w[ MAX ], v[ MAX ], n, m ;

int main( ){
  timesaver ;
  cin >> n >> m ;
  for( int i = 0 ; i < n ; i++ )
    cin >> w[i] >> v[i] ;
  for( int i = 0 ; i < n ; i++ ){
    for( int j = 0 ; j <= m ; j++ ){
      if( j>=w[i])
        dp[j][i] = max( dp[j][i-1], v[i]+dp[j-w[i]][i-1]);
      else
        dp[j][i]=dp[j][i-1];
    }
  }
  cout << dp[m][n-1]<<nl;
}

Measured memory_bytes: 80128
n, y = map(int, input().split())

for i in range(n+1):
   for j in range(n-i+1):
      if (10000 * i + 5000 * j + 1000 * (n - i - j) == y):
         print(i, j, n - i - j)
         exit()

print(-1, -1, -1)


Measured memory_bytes: 2940
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  string s;
  std::cin >> s;
  if(s[0]==s[2]) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

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

    int l[n];
    rep(i, n) { cin >> l[i]; }

    int d[n + 1] = {0};
    int count = 1;
    for(int i = 1; i < n + 1; ++i) {
        d[i] = d[i - 1] + l[i - 1];
        if(d[i] <= x)
            count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 3548
from collections import deque

s = input()
d = deque()
for i in s:
    d.append(i)
q = int(input())

state = 0


for i in range(q):
    In = input()
    if In == '1':
        state = (state + 1)%2
    else:
        t,f,c = In.split()
        k = (f=='2')
        if (k+state)%2==0:
            d.appendleft(c)
        else:
            d.append(c)
if state==0:
    print(*list(d),sep='')
else:
    t = list(d)[::-1]
    print(*t, sep='')


Measured memory_bytes: 14056
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
// ver1.8
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n,k;
  string s;
  cin >> n >> k >> s;
  int ans = 0;
  rep(i,0,n-1){
    if(s[i]==s[i+1]) ans++;
  }
  int len = n-ans;
  rep(i,0,k){
    ans += 2;
  }
  cout << min(ans,n-1) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

class union_find {
public:
vector<int> par,rank,lsize;
union_find(int n): par(n),rank(n),lsize(n){
   for (int i=0;i < n;i++){
      par[i]=i;
      rank[i]=0;
      lsize[i]=1;
   }
}

int find(int x){
   if (par[x]==x){
      return x;
   }
   else{
      return par[x] = find(par[x]); 
   }
}

void unite(int x ,int y){
   x=find(x);
   y=find(y);
   if (x==y) return;
   if (rank[x] < rank[y]){
      lsize[y] += lsize[x];
      lsize[x] = -1;
      par[x] = y;
   }else{
      lsize[x] += lsize[y];
      lsize[y] = -1;
      par[y]=x;
      if (rank[x]==rank[y]) rank[x]++;
   }   
}

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

int size(int x){
   if (lsize[x] == -1){
      x=find(x);
   }
   return lsize[x];
}
};

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> v(n);
    rep(i,n){
       cin >> v[i];
    }
    union_find tree(n);

    rep(i,m){
       int x,y;
       cin >> x >> y;
       x--;y--;
       tree.unite(x,y);
    }
    int ans = 0;
    rep(i,n){
       if (tree.same(i,v[i]-1)) ans++;
    }
    cout << ans << endl;

    
    return 0;

}

Measured memory_bytes: 1792
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF=9223372036854775807ll;
ll n,s,ans=INF;
ll GetS(ll x)
{
	ll f=n,ret=0;
	while(f)
		ret+=f%x,f/=x;
	return ret;
}
int main()
{
	scanf("%lld%lld",&n,&s);
	if(n==s) {printf("%lld\n",n+1ll);return 0;}
	ll T=n-s;
	for(ll i=1;i<=sqrt(T);i++)
		if(T%i==0)
		{
			ll x=i+1ll,y=T/i+1ll;
			if(GetS(x)==s) ans=min(ans,x);
			if(GetS(y)==s) ans=min(ans,y);
		}
	for(ll i=2;i<=sqrt(n);i++)
		if(GetS(i)==s)
		{
			ans=min(ans,i);
			break;
		}
	printf("%lld\n",ans==INF? -1ll:ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
//    int n;
//    cin>>n;
//    char a[10];
//    for(int i=0;i<10;i++) cin>>a[i];
//    sort(a,a+10);
//    for(int i=0;i<10;i++) cout<<a[i]<<" ";
    int a,b,c;
    cin>>a>>b>>c;
   if(c-(a-b)>=0) cout<<c-(a-b);
  else cout<<0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
    ll n,m;
    scanf("%lld%lld",&n,&m);
    ll t=m/n;
    ll ans=0;
    for(ll i=t;i>=0;i--)
    {
        if(m%i==0) {ans=i;break;}
    }
    printf("%lld\n",ans);
}


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

using namespace std;
typedef long long ll;

int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int res=0;
    res+=min(k,a);
    k-=min(k,a);
    if(k>0) k-=min(k,b);
    res-=min(c,k);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define Phuong ios_base::sync_with_stdio(0); cin.tie(0);
typedef unsigned long long ll;
using namespace std;
typedef pair<int,int> pii;
#define mpp make_pair
#define pb push_back


int main()
{
#ifndef RICARDO
    //freopen("input.inp", "r", stdin);
#endif // RICARDO
    Phuong;
    int n;
    cin >> n;
    int head = 1;
    int tail =n;
    int ans =-1;
    while (head <=tail)
    {
        int mid = head + (tail-head)/2;
        int res = floor(mid*1.08);
        if (res<n)
            head= mid  +1;
        else if (res>n)
            tail = mid -1;
        else
        {
            ans = mid;
            break;
        }
    }
    if (ans ==-1) cout << ":("; else cout << ans;
    return 0;
}


Measured memory_bytes: 256
A, B, C, D = input().rstrip().split(' ')
A = int(A)
B = int(B)
C = int(C)
D = int(D)

res_A = A
res_C = C
count_A = 0
count_C = 0

while res_A > 0:
  res_A -= D
  count_A += 1

while res_C > 0:
  res_C -= B
  count_C += 1

if count_C <= count_A:
  print('Yes')
elif count_C > count_A:
  print('No')

Measured memory_bytes: 9132
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
ll dp[3005][3005];// dp(x,y) = when sequence [x,y] remains, the number of x-y
int n;
ll a[3005];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i];
	for (int i=1;i<=n;++i)// have taken n-1 numbers, 1 number left
		if (n&1) dp[i][i]=a[i];
		else dp[i][i]=-a[i];
	for (int l=1;l<n;++l){// have taken n-l-1 numbers, l+1 numbers left
		bool flag=(n-l-1)&1;// flag=0: Taro's turn; flag=1: Jiro's turn
		for (int x=1;x+l<=n;++x){
			if (flag==0) dp[x][x+l]=max(dp[x][x+l-1]+a[x+l],dp[x+1][x+l]+a[x]);
			else dp[x][x+l]=min(dp[x][x+l-1]-a[x+l],dp[x+1][x+l]-a[x]);
		}
	}
	cout<<dp[1][n]<<endl;
	return 0; 
}

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

#define ll long long
string s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>s;
	s = s.substr(0, s.size() - 1);
	while(true){
		if(s.size() % 2 != 0)
			s = s.substr(0, s.size() - 1);
		else{
			string x,y;
			x = s.substr(0, s.size() / 2);
			y = s.substr(s.size() / 2, s.size());
			if(x == y)
				break;
			else
				s = s.substr(0, s.size() - 1);
		}
	}
	cout<<s.size();
	return 0;
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, K;

signed main() {
  cin >> N >> K;
  vec A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

  int ret = 0;
  for (int i = 0; i < N; i++) {
    bool flag = true;
    for (int l = 0; l < 30; l++) {
      if (bitcheck(A[i], l) && !(bitcheck(K, l))) {
        flag = false;
        break;
      }
    }
    if (flag) ret += B[i];
  }

  int ans = ret;
  for (int i = 0; i < 30; i++) {
    if (!bitcheck(K, i)) continue;

    int k = K & ~(1LL << i);
    k |= (1LL << i) - 1;

    int sum = 0;
    for (int j = 0; j < N; j++) {
      bool flag = true;
      for (int a = 0; a < 30; a++) {
        if (bitcheck(A[j], a) && !bitcheck(k, a)) {
          flag = false;
          break;
        }
      }
      if (flag) sum += B[j];
    }

    chmax(ans, sum);
  }

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n'
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
	ll n, m;
	cin>>n>>m;
	vector<ll> fac;
	ll lim = (ll)sqrt(m);
	ll i;
	FOR(i, 1, lim+1)
	{
		if(m%i==0)
		{
			fac.pb(i);
			fac.pb(m/i);
		}
	}
	ll si = fac.size();
	ll ans = 1;
	FOR0(i, si)
	{
		if(m/fac[i] >= n)
			ans = MAX2(ans, fac[i]);
	}
	cout<<ans;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

A, B, C, D, E, F =  MAP()
A *= 100
B *= 100
# 溶ける最大濃度
limit = E / (100+E)

# dp[i][j] := 水i、砂糖jの状態を実現可能か
dp = list2d(F+1, F+1, 0)
dp[0][0] = 1
for i in range(F+1):
    for j in range(F+1):
        # 枝刈り
        if i+j > F:
            break
        # 実現可能な状態なら、4つの行動を遷移させる
        if dp[i][j]:
            if i+A <= F:
                dp[i+A][j] = 1
            if i+B <= F:
                dp[i+B][j] = 1
            if j+C <= F:
                dp[i][j+C] = 1
            if j+D <= F:
                dp[i][j+D] = 1

ans1 = ans2 = 0
mx = -1
for a in range(F+1):
    for b in range(F+1):
        if a == b == 0:
            continue
        if a+b > F:
            break
        if dp[a][b]:
            x = b / (a+b)
            # 濃度が濃すぎて溶け切らない
            if x > limit:
                continue
            # 最大濃度の更新
            if mx < x:
                mx = x
                ans1 = a + b
                ans2 = b
print(ans1, ans2)


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

int main(){
  long long N, M;
  cin >> N >> M;
  
  long long res = 0;
  for (long mi = 0; mi < M; mi++){
    long long tmp;
    cin >> tmp;
    res += tmp;
  }
  
  if (res > N){
    cout << -1 << endl;
  } else {
    cout << N - res << endl;
  }
  
  return 0;
}


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

using namespace std;

typedef long long LL;

LL d[200000], a[200000], cnt, ans[200000], b[200000], n, s, t;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s += a[i];
		b[i] = a[i];
		t += i + 1;
	}
	
	if (s % t != 0) {
		cout << "NO";
		return 0;
	}
	LL k = s / t;
	b[n] = b[0];
	
	if (n <= 1000000) {
	
	for (int i = 0; i < n; i++) {
		if (k + (b[i] - b[i + 1]) > 0) {
			LL x = k + (b[i] - b[i + 1]);
			x /= n;
			d[(i + 1) % n] += x;
		}
		
		
	}
	LL v = 0, s = 0, cur = 0, cnt = 0;
	
	for (int i = 0; i < n + n; i++) {
		v = i % n;
		s += cur;
		
		if (i < n) {
			cur += d[v];
			s += d[v];
		} else {
			s -= d[v] * (n + 1);
			cur -= d[v];
		}
		ans[v] += s;
	}
	
	for (int i = 0; i < n; i++) {
		if (ans[i] != a[i]) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	
	return 0;
	} else {
	
	}
}

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

using namespace std;

const int N = 200005;
const int inf = 1e9;

int a[2][N * 4], b[N], n;

void build(int l, int r, int p) {
  if (l == r) {
    a[0][p] = a[1][p] = inf;
    if (l & 1) {
      a[1][p] = b[l];
    } else {
      a[0][p] = b[l];
    }
    return;
  }
  int m = (l + r) / 2;
  build(l, m, p * 2);
  build(m + 1, r, p * 2 + 1);
  a[0][p] = min(a[0][p * 2], a[0][p * 2 + 1]);
  a[1][p] = min(a[1][p * 2], a[1][p * 2 + 1]);
}

pair<int, int> query(int l, int r, int p, int L, int R) {
  //  cout << l << " " << r << endl;
  if (l >= L && r <= R) {
    return {a[0][p], a[1][p]};
  }
  int m = (l + r) / 2;
  auto ret = make_pair(inf, inf);
  if (L <= m) {
    auto t = query(l, m, p * 2, L, R);
    ret.first = min(ret.first, t.first);
    ret.second = min(ret.second, t.second);
  }
  if (m + 1 <= R) {
    auto t = query(m + 1, r, p * 2 + 1, L, R);
    ret.first = min(ret.first, t.first);
    ret.second = min(ret.second, t.second);
  }
  return ret;
}

void update(int l, int r, priority_queue<pair<int, pair<int, int>>>& q) {
  if (l > r) return;
  auto ret = query(1, n, 1, l, r);
  if (l & 1) {
    q.push({-ret.second, {l, r}});
  } else {
    q.push({-ret.first, {l, r}});
  }
}

int main(int argc, char *argv[]) {
  cin >> n;
  vector<int> a(n + 1), c;
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    a[b[i]] = i;
  }
  build(1, n, 1);
  auto ret = query(1, n, 1, 1, n);
  priority_queue<pair<int, pair<int, int>>> q;
  update(1, n, q);
  while (!q.empty()) {
    auto u = q.top();
    q.pop();
    c.push_back(-u.first);
    int p1 = a[-u.first], l = u.second.first, r = u.second.second;
    auto tt = query(1, n, 1, p1 + 1, r);
    int p2;
    if (l & 1) {
      c.push_back(tt.first);
      p2 = a[tt.first];
    } else {
      c.push_back(tt.second);
      p2 = a[tt.second];
    }
    //    cout << p1 << " " << p2 << endl;
    update(l, p1 - 1, q);
    update(p1 + 1, p2 - 1, q);
    update(p2 + 1, r, q);
  }
  for (auto x : c) {
    cout << x << " ";
  }
  return 0;
}


Measured memory_bytes: 9868
#include <iostream>
using namespace std;
int main() {
  int h,n;
  cin >> h;
  cin >> n;
  int cal_tmp;
  int ma[n][2];
  long tmp;
  for(int i=0;i<n;i++){
      cin>>ma[i][0];
      cin>>ma[i][1];
  }
  /*
  for(int i=0;i<n;i++){
      cout<<ma[i][0];
      cout<<ma[i][1];
      cout<<"\n";
  }
  */
  long dp[n][h+1];
  for(int i=0;i<n;i++){
      for(int j=0;j<h+1;j++){
          if(i==0){dp[i][j]=0;}
          else{dp[i][j]=10e+9;}
      }
  }
  for(int i=1;i<h+1;i++){
      cal_tmp=((i+ma[0][0]-1)/ma[0][0])*ma[0][1];
      dp[0][i]=cal_tmp;
      //cout<< dp[0][i];
  }
  //cout<< "\n";

  for(int i=1;i<n;i++){
      for(int j=1;j<h+1;j++){
          if(j<=ma[i][0]){cal_tmp=ma[i][1];}
          else{cal_tmp=ma[i][1]+dp[i][j-ma[i][0]];}
          tmp=cal_tmp;
          dp[i][j]=min(dp[i-1][j],tmp);
          //cout<< dp[i][j];
      }
      //cout<< "\n";
  }
  cout<< dp[n-1][h]<<endl;
  return 0;
}

Measured memory_bytes: 78336
n,m=(int(i)for i in input().split())
g=[]
t=[]
for i in range(n):
    g.append([int(i)for i in input().split()])
for i in range(m):
    t.append([int(i)for i in input().split()])
for i in range(n):
    kyr=400000001
    min=-1
    for j in range(m):
        kr=abs(g[i][0]-t[j][0])+abs(g[i][1]-t[j][1])
        if kr<kyr:
            kyr=kr
            min=j+1
    print(min)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int A[] = new int[n];
    for(int i = 0; i < n; i++){
      A[i] = sc.nextInt();
    }
    int q = sc.nextInt();
    for(int i = 0; i < q; i++){
      int m = sc.nextInt();
      int sum = 0;
      for(int j = 0; j < (1 << n); j++){
        sum = 0;
        for(int k =0; k < n; k++){
          if((1 & j>>k) == 1) sum += A[k];
        }
        if(sum == m) break;
      }
      if(sum == m) System.out.println("yes");
      else System.out.println("no");
    }
    sc.close();
  }
}


Measured memory_bytes: 27524
N = int(input())
s = [input() for i in range(N)]
k = [0,0,0,0]
for i in range(N):
  if s[i] == 'AC':
    k[0] += 1
  if s[i] == 'WA':
    k[1] += 1
  if s[i] == 'TLE':
    k[2] += 1
  if s[i] == 'RE':
    k[3] += 1
print(
  'AC x '+str(k[0])+'\n'
  'WA x '+str(k[1])+'\n'
  'TLE x '+str(k[2])+'\n'
  'RE x '+str(k[3]))

Measured memory_bytes: 16324
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    string s;
    cin>>s;
    string t="keyence";
    int n=s.size();
    for(int i=0;i<7;i++){
        string u={},v={};
        for(int j=0;j<7;j++){
            if(j<i+1)u.push_back(t[j]);
            else v.push_back(t[j]);
        }
        bool l=true,r=true,lst=false,rst=false;
    for(int j=0;j<n;j++){
        if(!lst&&s[j]==u[0]){
            bool c=true;
             for(int k=0;k<u.size();k++){
                 if(j+k>=n||s[j+k]!=u[k]){c=false;break;}
             } 
           if(c){
               if(j+u.size()!=n-1)r=false;
               lst=true;
               j+=u.size()-1;
           }
        }
        else if(lst&&s[j]==v[0]){
            bool c=true;
             for(int k=0;k<v.size();k++){
                 if(j+k>=n||s[j+k]!=v[k]){c=false;break;}
             }
             if(c){
               if(l&&j+v.size()-1==n-1){
                    cout<<"YES"<<endl;
                    return 0;
               }
           }
        }
        if(j==0&&!lst)l=false;
        if(v.size()==0&&lst&&(l||r)){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    }
    cout<<"NO"<<endl;
}



Measured memory_bytes: 256
N,K= list(map(int, input().split()))
A= list(map(int, input().split()))
AA=sorted(A)
num=0
before=0
for i in A:
    num+=AA.index(i)
num2=0
for i in range(N-1):
    for j in range(i+1,N):
        if A[i]>A[j]:
            num2+=1
hoge=(K-1)*K//2%1000000007
hoge=hoge*num%1000000007
hoge2=num2*K%1000000007
hoge=(hoge+hoge2)%1000000007
print(hoge)


Measured memory_bytes: 3188
from collections import deque


def main():
    input()  # n
    friendliness = [int(x) for x in input().split()]
    friendliness.sort()
    friendliness = deque(friendliness)
    edges = deque()
    popped = friendliness.pop()
    edges.append(popped)
    ans = 0
    while friendliness:
        ans += edges.popleft()
        popped = friendliness.pop()
        edges.append(popped)
        edges.append(popped)
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (abs(c-a) <= d || (abs(b-a) <= d && abs(c-b) <= d)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3604
def abc175_b():
    n = int(input())
    l = list(map(int, input().split(' ')))
    cnt = 0

    for i in range(0, n - 2):
        for j in range(i + 1, n):
            for k in range(j + 1, n):

                # 辺の長さが同じ場合は却下
                if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                    continue
                # 三角形になるにはa+b>c
                if (l[i] + l[j] > l[k]) and (l[j] + l[k] > l[i]) and (l[k] + l[i] > l[j]):
                    cnt += 1
    print(cnt)

if __name__ == '__main__':
    abc175_b()

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    double N;
    cin >> N;
    int m = floor(log2(N));
    cout << pow(2, m);
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i,n) cin >> p[i];
    int ans = 0;

    for(int i=0;i<n-2;i++){
        int m1 = min(p[i],min(p[i+1],p[i+2]));
        int m2 = max(p[i],max(p[i+1],p[i+2]));
        if(m1!=p[i+1]&&m2!=p[i+1])ans++;
    }

    cout << ans << endl;
    return 0;

}



Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

N, M = map(int, input().split())
adj = [[] for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

seen = [0] * (N+1)
que = deque()
que.append(1)
seen[1] = 1
finish = 0
flag = 0
cnt = 1
while que:
    if finish == 1:
        flag = 1
        break
    v = que.pop()
    for u in adj[v]:
        if seen[u] == 0:
            que.append(u)
            seen[u] = seen[v] * -1
            if seen[u] == 1:
                cnt += 1
        else:
            if seen[u] == seen[v]:
                finish = 1
                break

if flag == 1:
    print((N * (N - 1)) // 2 - M)
else:
    print(cnt * (N - cnt) - M)


Measured memory_bytes: 56684
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int max=100001;
  vector<int> a(max,1);
  a[0]=0;
  a[1]=0;
  for(int i=2;i<max;i++){
    if(!a[i]) continue;
    for(int j=i*2;j<max;j+=i) a[j]=0;
  }
  
  vector<int> b(max,0);
  for(int i=0;i<max;i++){
     if(i%2==0) continue;
    if(a[i]&&a[(i+1)/2]) b[i]=1;
  }
  
  vector<int> s(max+1,0);
  for(int i=0;i<max;i++) s[i+1]=b[i]+s[i];
  
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    r++;
    
    cout<<s[r]-s[l]<<endl;
  }
   return 0;
}


Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int n=ir.nextInt();
		out.println(Integer.highestOneBit(n));
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

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

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

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
#define ll long long
const int maxn = 1e6+5;
const ll u = 1e18+1;
long long arr[maxn];
bool com(ll a,ll b){
    return a>b;
}
ll gcd(ll a,ll b)
{
    ll c;
    c = a%b;
    if(c == 0){
        return b;
    }
    else{
        a = b;
        b = c;
        gcd(a,b);
    }
}
int main(){
    ll i,f,e;
    int a,b,c,d,n;
    cin>>n;

    for(i = 0;i < n;i++){
        cin>>arr[i];
    }
    if(n==1){
        cout<<arr[0];
        return 0;
    }
    f = gcd(arr[0],arr[1]);
    f = arr[0]/f*arr[1];
    for(i = 2;i < n;i++){
        e = f;
        f = gcd(f,arr[i]);
        f = e/f*arr[i];
    }
    cout<<f;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);

        int value = s.nextInt();
        int coin = s.nextInt();

        int rest = value % 500;

        String result = "Yes";
       
        if (coin < rest) {
          result = "No";
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

ll a[10010], b[10010];

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll A = 0, B = 0, diff1 = 0, diff2 = 0;
    rep(i, n){
        A += a[i];
        B += b[i];
        diff1 += max((b[i] - a[i] + 1)/2, 0ll);
        diff2 += max(a[i] - b[i], 0ll);
    }
    ll cnt = B - A;
    bool flag = true;
    
    if (cnt < 0) flag = false;
    else if (cnt < max(diff1, diff2)) flag = false;
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long> a(3*N);
  for (int i=0; i < 3*N ; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end(), greater<int>());
  
  vector<vector<long>> team(N,vector<long> (3));
  int k=0;
  for (int i = 0; i < N; i++){
    for (int j=0; j < 2 ; j++){
      team.at(i).at(j) = a.at(k);
      k++;
    }
  }
  
  long ans =0;
  for (int i=0; i<N ; i++){
    ans += team.at(i).at(1);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 11096
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  int x[4],y[4];
  cin>>x[0]>>y[0]>>x[1]>>y[1];

  int vecx = x[1]-x[0];
  int vecy = y[1]-y[0];

  x[2] = x[0] - vecy;
  y[2] = y[0] + vecx;
  x[3] = x[2] + vecx;
  y[3] = y[2] + vecy;

  cout<<x[3]<<" "<<y[3]<<" "<<x[2]<<" "<<y[2]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9 + 7;
const ll inf = 1e12;
const double pi = 3.141592;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a+2), t(b+2);
    rep(i, a) cin >> s[i+1];
    rep(i, b) cin >> t[i+1];
    s[0] = -inf;
    t[0] = -inf;
    s[a + 1] = inf;
    t[b + 1] = inf;
    rep(i, q)
    {
        ll x;
        cin >> x;
        int si = lower_bound(s.begin(), s.end(), x) - s.begin();
        int ti = lower_bound(t.begin(), t.end(), x) - t.begin();
        ll tmp1 = max(s[si] - x, t[ti] - x);
        ll tmp2 = max(x - s[si - 1], x - t[ti-1]);
        ll tmp3 = s[si] - t[ti - 1] + min(s[si] - x, x - t[ti - 1]);
        ll tmp4 = t[ti] - s[si - 1] + min(t[ti] - x, x - s[si - 1]);
        ll tmpans = min({tmp1, tmp2, tmp3, tmp4});
        cout << tmpans << "\n";
    }
    return 0;
}


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

int main() {
  int a,b,c,x=0;
  cin >> a >> b >> c;
  for(int i=a; i<=b; i++){
    if(c%i==0){
      x++;
    }
    
  }
  
  cout << x <<endl;
  
}
 


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(S, T);
  int flag = -1;
  REP(i, S.size() - T.size() + 1) {
    bool ok = true;
    REP(j, T.size()) {
      if (S[i + j] == '?') {
        ok &= true;
      } else if (S[i + j] != T[j]) {
        ok &= false;
      }
    }
    if (ok) {
      flag = i;
    }
  }
  
  if (flag < 0) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  REP(i, T.size()) {
    S[i + flag] = T[i];
  }
  
  REP(i, S.size()) {
    if (S[i] == '?') {
      cout << 'a';
    } else {
      cout << S[i];
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
    using System.Net;

     
    public class Program
    {

        public void Proc() {
            int pointCount = int.Parse(Reader.ReadLine());
            int currentTime = 0;
            int currentX = 0;
            int currentY = 0;
            bool canReach = true;
            for(int i=0; i<pointCount; i++) {
                int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();
                int timeDiff = inpt[0]-currentTime;
                int move = Math.Abs(currentX-inpt[1])+Math.Abs(currentY-inpt[2]);
                if(timeDiff<move) {
                    canReach = false;
                    break;
                }
                if((timeDiff-move)%2!=0) {
                    canReach = false;
                    break;
                }
                currentTime = inpt[0];
                currentX = inpt[1];
                currentY = inpt[2];
            }
            string ans = "No";
            if(canReach) {
                ans = "Yes";
            }
            Console.WriteLine(ans);
        }






        public class Reader {
            public static bool IsDebug = false;
            private static System.IO.StringReader SReader;
            private static string InitText = @"




2
3 1 2
6 1 1






";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            #if DEBUG
            Reader.IsDebug = true;
            #endif
            Program prg = new Program();
            prg.Proc();
        }
    }

Measured memory_bytes: 17452
#include <bits/stdc++.h>
#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 w, a, b;
    cin >> w >> a >> b;
    if (a > b) swap(a, b);
    int ans = max(b - (a+w), 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAXN = 100000;
static const int MAX = 1000000000;

int main(){
    string S;
    cin >> S;
    if(S == "ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }

    return 0;
}

Measured memory_bytes: 3572
N = int(input())
A = list(map(int, input().split()))

r = 0
ans = 0

current_sum = A[0]

for l in range(N):
    ans += r - l + 1
    while r < N-1:
        if current_sum + A[r+1] == current_sum ^ A[r+1]:
            current_sum += A[r+1]
            ans += 1
            r += 1
        else:
            current_sum -= A[l]
            break

print(ans)


Measured memory_bytes: 77772
#include <iostream>
#include <vector>
#include <iterator>

using namespace std;

// ShowData
void showData(vector<int>::iterator start,vector<int>::iterator end)
{
	vector<int>::iterator iter;
	for( iter = start; iter != end; iter++ )
	{
		cout << *iter;
		if( iter != (end-1) )
		{
			cout << " ";
		}
	}
	cout << endl;
	return;
}

// BubbleSort
int bubbleSort(vector<int>::iterator start,vector<int>::iterator end)
{
	int swapCnt = 0;
	vector<int>::iterator count, swap_a, swap_b;
	
	for(count = start; count != end; count++)
	{
		for(swap_a = end-1; swap_a != count; swap_a--)
		{
			swap_b = swap_a;
			advance( swap_b , -1 );
			if( *swap_b > *swap_a )
			{
				iter_swap( swap_a, swap_b );
				swapCnt++;
			}
		}
	}
	return swapCnt;
}

int main(void){
	int numData;
	cin >> numData;
	
	// Input
	vector<int> vectorInt;
	vectorInt.reserve(100);
	int input;
	while( cin >> input )
	{
		vectorInt.push_back( input );
	}
	
	// swap
	int swapCnt = bubbleSort( vectorInt.begin(), vectorInt.end() );
	showData( vectorInt.begin(), vectorInt.end() );
	cout << swapCnt << endl;
	
	return 0;
}

Measured memory_bytes: 3076
/***************************************************
 * Problem Name : C.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-04-19
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.rbegin(), v.rend())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 200005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm ( ll a, ll b ) {
    return ( a / __gcd ( a, b ) ) * b;
}
/************************************ Code Start Here ******************************************************/
vector<int>adj[MAX];

int nod[MAX];


int main () {
    __FastIO;
    //~ cout << setprecision (10) << fixed;
    int n;
    cin >> n;
    for (int i = 2; i <= n; i++) {
		int u;
        cin >> u;
        nod[u]++;
    }
    for(int i = 1; i<=n; i++){
		cout << nod[i] << "\n";
	}
    return 0;
}


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


int main(void){
    int x, y, a, b;
    cin >> x >> y;
    a = -x, b = -y;
    
    int p, q, r, s, inf = 2e9;
    
    if (x <= y) p = y - x;
    else p = inf;
    if (a <= y) q = y - a +1;
    else q = inf;
    if (x <= b) r = b - x +1;
    else r = inf;
    if (a <= b) s = b - a +2;
    else s = inf;
    
    cout << min(p, min(q, min(r, s))) << endl;
    
    
}


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

using namespace std;

vector<int> checked(100000, -1);
vector<vector<int>> to(100000);

void dfs(int n)
{
    checked[n] = 1;
    for (int i = 0; i < to[n].size(); i++)
    {
        int next = to[n][i];
        if (checked[next] == 1)
            continue;
        checked[next] = 1;
        dfs(next);
    }
    return;
}

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

    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (checked[i] == 1)
        {
            continue;
        }
        dfs(i);
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9216
#include<stdio.h>

int main()
{
	int n, m;
	
	scanf("%d %d", &n, &m);
	
	int inputan[n];
	
	for(int i = 0; i < n; i++){
		scanf("%d", &inputan[i]);
	}
	int term = n - m;
	
	for(int i = 0; i < term; i++){
		if(inputan[i] < inputan[i + m]){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
}

Measured memory_bytes: 2392
n=gets.to_i
b=gets.split.map &:to_i

res=[]

until b.empty?
	f=false
	(b.size-1).downto(0){|i|
		if i+1==b[i]
			res<<b[i]
			b.delete_at(i)
			f = true
			break
		end
	}
	if !f && !b.empty?
		puts -1
		exit
	end
end

puts res.reverse

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int x[4] = {-1,0,1,0};
int y[4] = {0,-1,0,1};

int main() {
    int H,W;cin >> H >> W;
    vector<vector<int>> ch(H,vector<int>(W,-1));
    queue<pair<int,int>> q;
    rep(i,H)rep(j,W){
        char c;cin >> c;
        if(c == '#'){
            q.push({i,j});
            ch[i][j] = 0;
        }
    }   
    while(!q.empty()){
        int a = q.front().F;
        int b = q.front().S;
        q.pop();
        rep(i,4){
            int dx = x[i];
            int dy = y[i];
            if(a+dy >= 0 && a+dy <= H-1 && b+dx >= 0 && b+dx <= W-1 && ch[a+dy][b+dx] == -1){
                ch[a+dy][b+dx] = ch[a][b] + 1;
                q.push({a+dy,b+dx});
            }
        }
    }

    int ans = 0;
    rep(i,H)rep(j,W)chmax(ans,ch[i][j]);

    cout << ans << endl;
}

Measured memory_bytes: 12432