akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
int main()
{
	while (true)
	{
		double l[10];
		double length = 0;
		char foo;
		for (int i = 0; i < 10; i++)
		{
			std::cin >> l[i] >> foo;
			length += l[i];
		}
		double v1, v2;
		std::cin >> v1 >> foo >> v2;
		if (std::cin.eof())
		{
			break;
		}
		double meetpoint = length * v1 / (v1 + v2);
		length = 0;
		for (int i = 0; i < 10; i++)
		{
			length += l[i];
			if (length >= meetpoint)
			{
				std::cout << i + 1 << std::endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
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();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> A,F;
  REP(i,N){
    ll a;
    cin>>a;
    A.PB(a);
  }
  REP(i,N){
    ll f;
    cin>>f;
    F.PB(f);
  }
  SORT(A);
  SORT(F);
  REVERSE(F);
  
  ll HI=INF,LO=-1;
  while(HI-LO>1){
    ll MID=(HI+LO)/2,it=K;
    bool CAN=true;
    
    REP(i,N){
      it-=max(A[i]-MID/F[i],0LL);
      
      if(it<0){
        CAN=false;
        break;
      }
    }
    
    if(CAN) HI=MID;
    else LO=MID;
  }
  
  co(HI);
  return 0;
}

Measured memory_bytes: 7968
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int str1 = scan.nextInt();
        int str2 = scan.nextInt();
        if(str1==str2){
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }
    }
}

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

int main(){

  short int a[100][100];
  short int b;
  int c[100];
  int n,m;

  cin >> n >> m;

  for(int i=0; i<n; i++)
    c[i]=0;

  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++)
      cin >> a[i][j];
  }

  for(int i=0; i<m; i++){
    cin >> b;
    for(int j=0; j<n; j++)
      c[j] += a[j][i]*b;
  }

  for(int i=0; i<n; i++)
    cout << c[i] << endl;

  return 0;
}

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

using namespace std;
#define int long long
signed main() {
    int n, k;
    cin >> n >> k;
    int arr[n+1];
    int i;
    for(i=1;i<=n;i++)
        cin >> arr[i];
    int prev = arr[1];
    for(i=k+1;i<=n;i++)
    {
        int nnum = arr[i];
        if(nnum > prev)
            cout << "Yes\n";
        else
            cout << "No\n";
        prev = arr[i-k+1];
    }
}

Measured memory_bytes: 5192
#include<bits/stdc++.h>
#include<atcoder/fenwicktree>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)

int main(){
	int n, q;
	scanf("%d %d", &n, &q);
	atcoder::fenwick_tree<ll> bit(n);
	REP(i, 0, n){
		ll a;
		scanf("%ld", &a);
		bit.add(i, a);
	}

	REP(i, 0, q){
		ll t, x, y;
		scanf("%ld %ld %ld", &t, &x, &y);
		if(t==0) bit.add(x, y);
		else printf("%ld\n", bit.sum(x, y));
	}
	return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 998244353ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	auto mod = cMOD;
	auto add = [mod]      ( ll a, ll b ) { return ( a + b ) % mod; };
	auto sub = [mod]      ( ll a, ll b ) { return ( a + mod -b ) % mod; };
	auto mul = [mod]      ( ll a, ll b ) { return a * b % mod; };

	string s; cin >> s;
	ull n = s.size();

	vector<vector<ll>> dp( 2*n+1, vector<ll>( n+2, 0 ) );
	dp[0][0] = 1;

	REP( i, n )
	{
		int b = s[i] - '0';
		REP( j, dp[i].size() )
		{
			if( j+b >= 1 ) dp[i+1][j+b-1] = add( dp[i+1][j+b-1], dp[i][j] );
			if( i+j+b < 2*(i+1) ) dp[i+1][j+b] = add( dp[i+1][j+b], dp[i][j] );
		}
		//REP( j, dp[i].size() ) cout << dp[i][j] << " "; cout << endl;
	}
	REP( k, n )
	{
		int i = k + n;
		REP( j, dp[i].size() )
		{
			if( j >= 1 ) dp[i+1][j-1] = add( dp[i+1][j-1], dp[i][j] );
			if( i + j < 2 * n ) dp[i+1][j] = add( dp[i+1][j], dp[i][j] );
		}
		//REP( j, dp[i].size() ) cout << dp[i][j] << " "; cout << endl;
	}
	
	cout << dp[2*n][0] << endl;
	
	return 0;
}

Measured memory_bytes: 63484
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int a, b, x;
    cin >> a >> b >> x;

    int c = a / x + 1;
    int d = b / x + 1;

    if (a % x == 0) c--;

    cout << d - c << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((int)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;




////////////////////////////////////////////////////////


int main() {
    ll H, N; cin >> H >> N;
    ll a, b;
    Vl dp(20000, -1);
    dp[0]=0;
    rep(i, 0, N){
        cin >> a >> b;
        rep(j, a, 20000){
            if(dp[j-a] == -1){
            }else{
                if(dp[j] == -1){
                    dp[j] = dp[j-a]+b;
                }else{
                    dp[j] = min(dp[j], dp[j-a]+b);
                }
            }
        }
    }
    ll ans = INF;
    rep(i, H, 20000){
        if(dp[i] != -1) chmin(ans, dp[i]);
    }
    co(ans);

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll a,b;
	cin>>a>>b;
	cout<<(a+b)%24<<endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[103];
    int d[103] {0};
    int lar = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        lar = max(lar, a[i]);
        d[a[i]]++;
    }
    for(int i = 0; i <= lar; i++){
        int k = max(i, lar - i);
        if(d[k] <= 0){
            cout << "Impossible" << endl;
            return 0;
        }
        d[k]--;
    }
    for(int i = 0; i < n; i++){
        if(d[i] != 0 && (i > lar || i <= (lar + 1) / 2)){
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[200001],b[200001];
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	int tmp;
	if(n%2) tmp=b[n/2]-a[n/2];
	else tmp=b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1];
	cout<<tmp+1<<endl;
	return 0;
}


Measured memory_bytes: 5196
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

lli dp[15][10][3];

lli tot[] = {0, 9, 26, 75, 217, 629, 1826, 5307, 15438, 44941, 130900, 381444};

lli count(lli M) {
  REP(i, 15) REP(j, 10) REP(k, 3) dp[i][j][k] = 0;
  string s = to_string(M);
  FOR(n,1,9) {
    dp[0][n][1+cmp3(n,s[0]-'0')] = 1;
  }
  REP(i, s.size()-1) {
    int D = s[i+1] - '0';
    REP(n, 10) FOR(d,max(0,n-1),min(9,n+1)) REP(c, 3) {
      dp[i+1][d][(c&1)?1+cmp3(d,D):c] += dp[i][n][c];
    }
  }
  lli sum = tot[s.size()-1];
  REP(n, 10) {
    sum += dp[s.size()-1][n][0] + dp[s.size()-1][n][1];
  }
  return sum;
}

int main() {
  REP(i, sizeof(tot)/sizeof(tot[0])-1) {
    tot[i+1] += tot[i];
  }

  lli K;
  cin >> K;
  lli lb = 0, ub = 3234566680LL;
  while (lb + 1 < ub) {
    lli mid = (lb + ub) / 2;
    lli cnt = count(mid);
    if (cnt >= K) {
      ub = mid;
    } else {
      lb = mid;
    }
  }
  cout << ub << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int n, k, ans; cin >> n >> k;
    ans = 0;
    for (int i = 0; i < n; i++)
    {
        int xi;
        cin >> xi;
        ans += (min(xi,k-xi) * 2);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n;
  cin>>n;
  ll t,a;
  cin>>t>>a;
  for(int i=0;i<n-1;i++){
    ll x,y;
    cin>>x>>y;
    ll z=max((t+x-1)/x,(a+y-1)/y);
    t=x*z;a=y*z;
  }
  cout<<t+a<<endl;
  return 0;
}



Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main(){

	int n;
	int k[10000];
	int i=0;
	int j=0;
	int min=0;
	int no=0;
	int result[10000];

	for(j=0;true;j++){
	
		min=0;
		no=0;
	
		cin>>n;
		
		if(n==0){
			break;
		}

		for(i=0;i<n;i++){
			cin>>k[i];
		
			if(k[i]!=0){
				min+=1;
			}
			if((k[i]==1)||(k[i]==0)){
				no+=1;
			}
		
			if(no==n){
				result[j]=-1;
			}else{
				result[j]=min+1;
			}
		}
	}
	
	for(i=0;i<j;i++){
		if(result[i]==-1){
			cout<<"NA";
		}else{
			cout<<result[i];
	        }
		
		cout<<endl;
	}
}

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

using namespace std;
#define pb push_back
#define ll long long
#define fast std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
 
 //string ans="";
/*ll solve(ll n )
 {
     if(n<12)
        return n;
     if(mp[n]==0)
            mp[n]=max(solve(n/2)+solve(n/3)+solve(n/4),n);
     return mp[n];
        
 }
*/
int main(){
   fast;
    ll x;
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
using namespace std;
long long GCD(long long a , long long b)
{
    if(a % b == 0)
    {
        return b;
    }
    return GCD(b, a%b);
}
long long lcm(long long a, long long b)
{
    return (a * b) / GCD(a, b);
}
int main()
{
    long long a , b;
    cin >> a >> b;
    cout << lcm(a,b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define Boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void Crack() {
	int n;
    cin >> n;
	if(n>=30) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

int main()
{
	Boost;
    Crack();
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=100000;
int n,m;
vector<int> nei[N+1];
int dp[N+1];
bool vis[N+1];//是否访问过 
int ans;
void dfs(int x){//记忆花搜索 
	if(vis[x])return;
	vis[x]=true; 
	for(int i=0;i<nei[x].size();i++)dfs(nei[x][i]),dp[x]=max(dp[x],dp[nei[x][i]]+1);//转移 
	ans=max(ans,dp[x]);//目标 
}
int main(){
	cin>>n>>m;
	while(m--){
		int x,y;
		cin>>x>>y;
		nei[x].pb(y);
	}
	for(int i=1;i<=n;i++)dfs(i);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8192
import itertools

N, C = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

memo = [[0 for i in range(C)]for j in range(3)]

for i in range(N):
    for j in range(N):
        cij = c[i][j]
        a = (i + j + 2) % 3
        for k in range(C):
            memo[a][k] += d[cij-1][k]

ans = float('inf')

for c1, c2, c3 in itertools.permutations(range(C), 3):
    ans = min(ans, memo[0][c1] + memo[1][c2] + memo[2][c3])

print(ans)

Measured memory_bytes: 45532
#include<stdio.h>
int main(void){
int i,n;
int number;
long long int sum=0;
int min=0;
int max=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&number);
if(i==0){
 
min=number;
max=number;
}
if(number<min)min=number;
if(number>max)max=number;
sum+=number;
}
printf("%d %d %lld\n",min,max,sum);
return 0;
}

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

int main() {
    int N;
    std::cin >> N;
    std::vector<int> arr(N);

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

    std::sort(arr.begin(), arr.end());

    for (int i = 0; i < N - 1; ++i) {
        if (arr[i] == arr[i + 1]) {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }

    std::cout << "YES" << std::endl;
    return 0;
}

Measured memory_bytes: 1024
L=int(input());S=bin(L);N=len(S)-2;print(N,2*N+S.count("1")-3)
for i in range(N-1):
 print(i+1,i+2,0,"\n"+str(i+1),i+2,2**i)
 if S[N+1-i]=="1":L-=2**i;print(i+1,N,L)

Measured memory_bytes: 3064
n = int(input())

if n == 111:
    print(999)
elif n == 119:
    print(991)
elif n == 191:
    print(919)
elif n == 199:
    print(911)
elif n == 911:
    print(199)
elif n == 919:
    print(191)
elif n == 991:
    print(119)
else:
    print(111)

Measured memory_bytes: 3060
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

a, b, c, d = lr()
bl = abs(a - c) <= d
if abs(a - b) <= d and abs(b - c) <= d:
    bl = True
print('Yes' if bl else 'No')


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[5];
    int i;
    int k, min = 9;
    int time = 0;
    for (i = 0; i < 5; i++)
    {
        scanf("%d", &a[i]);
        if (a[i] % 10 < min && a[i] % 10 != 0)
        {
            min = a[i] % 10;
            k = i;
        }
    }
    for (i = 0; i < 5; i++)
    {
        if (i != k)
        {
            if (a[i] % 10 != 0)
            {
                time += a[i] - (a[i] % 10) + 10;
            }
            else
            {
                time += a[i];
            }
        }
        else
        {
            time += a[i];
        }
    }
    printf("%d\n", time);
    return 0;
}

Measured memory_bytes: 128
d = {}
for _n in range(int(input())):
  s = input()
  d[s] = d.get(s,0) + 1
print("AC x", d.get("AC", 0))
print("WA x", d.get("WA", 0))
print("TLE x", d.get("TLE",0))
print("RE x", d.get("RE", 0))

Measured memory_bytes: 74464
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        String ans;
        while (true) {
            c -= b;
            if (c <= 0) {
                ans = "Yes";
                break;
            }
            a -= d;
            if (a <= 0) {
                ans = "No";
                break;
            }
        }


        
        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 35744
#include <iostream>
using namespace std;
int max(int a,int b){
	if(a>b)
		return a;
	else
		return b;
}
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int n = 0;
	cin>>n;
	int largest = max(a,max(b,c));
	int sum = a+b+c-largest;
	for(int i = 0;i<n;i++){
		largest = 2*largest;
	}
	sum +=largest;
	cout<<sum;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	ll a[100];
	fill(a,a+2, 1);
	FOR(i,2,n+1)
	{
		a[i] = a[i - 1] + a[i - 2];
	}
	cout << a[n] << endl;
}

Measured memory_bytes: 3196
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String S = in.nextLine();
            ArrayList<Integer> list = new ArrayList<>();
            for (int i = 0; i < S.length(); i++) {
                list.add(S.charAt(i) - '0');
            }

            int count = 0;
            for (int i = 0; i + 1 < list.size(); i++) {
                if (list.get(i) != list.get(i + 1)) {
                    list.remove(i);
                    list.remove(i);
                    count += 2;
                    i += -2;
                    if (i < -1) {
                        i = -1;
                    }
                    continue;
                }
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 26464
#include <bits/stdc++.h>
using namespace std;
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int h,n,sum = 0;
	cin >> h >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		sum += a;
	}
	isYes(sum >= h);
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
    a_,b_=map(int,input().split())
    a.append(a_)
    b.append(b_)

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

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

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

uf = UnionFind(n)
for i in range(m):
    uf.union(a[i]-1,b[i]-1)

print(uf.group_count()-1)

Measured memory_bytes: 86612
#include <bits/stdc++.h>
using namespace std;
int n,m,a[5],b[5];
void run()
{
	if (n==1)
	{
		cout<<0<<endl;
	}
	else
	{
		cout<<1;
		for(int i=1;i<n;i++)
			cout<<0;
		cout<<endl;
	}
	return;
}
int main()
{
	a[1]=1;
	bool flag=0;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int s,c;
		cin>>s>>c;
		if (!b[s])
		{
			a[s]=c;
			b[s]=1;
		}
		else
		{
			if (a[s]!=c)
			{
				flag=1;
			}
		}
	}
	if (flag)
	{
		cout<<-1<<endl;
		return 0;
	}
	if (m==0)
	{
		run();
	}
	else
	{
		if (a[1]==0)
		{
			if (n==1)
				cout<<0<<endl;
			else
				cout<<-1<<endl;
			return 0;
		}
		for(int i=1;i<=n;i++)
			cout<<a[i];
		cout<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
def main():
    data = input()
    data = data.replace('BC', 'D')
    count_a = 0
    ans = 0
    for i in range(len(data)):
        now_str = data[i]
        if now_str == 'A':
            count_a += 1
        elif now_str == 'D':
            ans += count_a
        else:
            count_a = 0

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 41840
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)
		cin>>h[i];
	int min_cost[n];
	min_cost[0]=0;
	min_cost[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++)
		min_cost[i]=min((min_cost[i-1]+abs(h[i]-h[i-1])), (min_cost[i-2]+abs(h[i]-h[i-2])));
	cout<<min_cost[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int N,M;
cin >> N >> M;

if(N  > M){
  cout << "No";
  return 0;
}
cout << "Yes";










	return 0;

}



Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

ABCD = [int(_) for _ in ns().strip()]

for i in range(8):
    t = ABCD[0]
    
    for j in range(3):
        if i>>j&1:
            t += ABCD[j+1]
        else:
            t -= ABCD[j+1]
  
    if t == 7:
        print("{}{}{}{}{}{}{}=7".format(
            ABCD[0], "+" if i>>0&1 else "-",
            ABCD[1], "+" if i >> 1 & 1 else "-",
            ABCD[2], "+" if i >> 2 & 1 else "-",
            ABCD[3],         
        ))
        break
        


Measured memory_bytes: 3064
#include <stdio.h>

int main() {
  
  int a,b,gcd;
  
  scanf("%d%d",&a,&b);

  if(a<b) {
    a=a+b;
    b=a-b;
    a=a-b;
  }
  
  while(b>0) {

    gcd = a%b;
    a = b;
    b = gcd;
  }

  printf("%d\n",a);

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int cost(int b, int /*t*/, int s) {
	return __builtin_popcount(b&((1<<s)-1));
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> A[2] = {vector<int>(N), vector<int>(N)};
	for(int k = 0; k < 2; k++)
		for(int i = 0; i < N; i++) cin >> A[k][i];
	vector< vector<int> > dp(1<<N, vector<int>(N, 100000));
	for(int i = 0; i < N; i++) dp[(1<<N)-1-(1<<i)][i] = i;
	for(int l = 1; l < N; l++)
		for(int i = 0; i < (1<<N); i++) if(__builtin_popcount(i) == N-l)
			for(int j = 0; j < N; j++) if(((i>>j)&1) == 0)
			for(int k = 0; k < N; k++) if((i>>k)&1)
				if(A[(l+k)&1][k] >= A[(l-1+j)&1][j])
					dp[i-(1<<k)][k] = min(dp[i-(1<<k)][k], dp[i][j]+cost(i,l,k));
	int ans = 100000;
	for(int i = 0; i < N; i++) ans = min(ans, dp[0][i]);
	if(ans == 100000) ans = -1;
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 28928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

void solve(istream& cin, ostream& cout) {
  string s, t;
  cin >> s >> t;
  bool flag = true;
  REP(i, t.size() - 1) {
    if (s[i] != t[i]) {
      flag = false;
      break;
    }
  }
  if (flag) cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

template <class T>
class FenwickTree {
public:
	void init(int nn) {
		this->n = nn;
		bit.assign(n + 1, 0);
	}

	void init(const std::vector<T> &a) {
		n = a.size();
		bit.assign(n + 1, 0);
		for(int i = 1; i <= n; i++) {
			bit[i] += a[i - 1];
			if(i + (i & -i) <= n) {
				bit[i + (i & -i)] += bit[i];
			}
		}
	}

	T qry(int x) {
		x = std::min(x, (int)bit.size() - 1);
		T ans = 0;
		for(; x > 0; x -= x & -x) {
			ans += bit[x];
		}
		return ans;
	}

	void upd(int x, T v) {
		if(x <= 0) return;
		for(; x <= n; x += x & -x) {
			bit[x] += v;
		}
	}
private:
	int n;
	std::vector<T> bit;
};

const int MOD = 998244353;
template <class T>
T fexp(T x, long long e) {
	T ans(1);
	for(; e > 0; e /= 2) {
		if(e & 1) ans = ans * x;
		x = x * x;
	}
	return ans;
}

template <int mod = MOD>
struct modBase {
	modBase(int v = 0) : val(v < 0 ? v + mod : v) {}
	int val;
 
	void operator += (modBase<mod> o) { *this = *this + o; }
	void operator -= (modBase<mod> o) { *this = *this - o; }
	void operator *= (modBase<mod> o) { *this = *this * o; }
	modBase<mod> operator * (modBase<mod> o) { return (int)((long long) val * o.val % mod); }
	modBase<mod> operator / (modBase<mod> o) { return *this * fexp(o, mod - 2); }
	modBase<mod> operator + (modBase<mod> o) { return val + o.val >= mod ? val + o.val - mod : val + o.val; }
	modBase<mod> operator - (modBase<mod> o) { return val - o.val < 0 ? val - o.val + mod : val - o.val; }

	friend std::ostream& operator << (std::ostream &os, const modBase<mod> &p) {
		return os << p.val;
	}
	friend std::istream& operator >> (std::istream &is, modBase<mod> &p) {
		return is >> p.val;
	}
};


int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, k;
	std::cin >> n >> k;
	FenwickTree<modBase<>> tree;
	tree.init(n);
	FenwickTree<int> freq;
	freq.init(n);
	modBase<> prob = modBase<>(k-1) / k;
	modBase<> ans(0);
	for(int i = 0; i < n; i++) {
		int x;
		std::cin >> x;
		auto curProb = fexp(prob, std::max(0, i - k + 1));
		modBase<> low = tree.qry(x);
		modBase<> high = tree.qry(n) - low;
		low = low * curProb;
		high = high * curProb;
		// for low to be an inversion, it needs to pass the probability
		ans += low / 2;
		// fow high to be an inversion, it needs to either pass the probability or continue there
		ans += high / 2;
		ans += (modBase<>(i) - freq.qry(x) - high);
		tree.upd(x, modBase<>(1) / curProb);
		freq.upd(x, 1);
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 4780
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N, vector<int>());
    vector<int> in(N);
    rep(i, N + M - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        in[b]++;
    }
    vector<int> res(N);
    stack<int> st;
    for(int i = 0; i < in.size(); i++)
        if(in[i] == 0)
            st.push(i);
    while(st.size()) {
        int v = st.top();
        st.pop();
        for(auto &nv : G[v]) {
            in[nv]--;
            if(in[nv] == 0) {
                st.push(nv);
                res[nv] = v + 1;
            }
        }
    }
    rep(i, N) cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 7040
from collections import defaultdict
dd = defaultdict(str)

n, m = map(int, input().split())
keys = []
atcoder = [[] for _ in range(n)]
for i in range(m):
    p, y = map(int, input().split())
    key_p = str(p).zfill(6)
    key_y = str(y).zfill(10)
    keys.append(key_p + key_y)
    p -= 1
    atcoder[p].append(y)
for i in range(n):
    atcoder[i].sort()
    key_i = str(i + 1).zfill(6)
    for index, j in enumerate(atcoder[i]):
        key_index = str(index + 1).zfill(6)
        key_j = str(j).zfill(10)
        dd[key_i + key_j] = key_i + key_index
for k in keys:
    print(dd[k])

Measured memory_bytes: 47272
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
#define oset tree<pi, null_type,greater<pi>, rb_tree_tag,tree_order_statistics_node_update>


int main()
{
    lli n, m, k;
    cin >> n >> m >> k;
    vector<lli> a, b;
    lli sum = 0;
    for(int i=0; i<n; i++){
        lli x;
        cin >> x; a.push_back(x);
        sum += x;
    }
    for(int i=0; i<m; i++){
        lli x;
        cin >> x;
        b.push_back(x);
    }
    int mx = 0;
    int j = 0;
    for(int i=n-1; i>=0 ; i--){
        while(j<m && sum+b[j] <= k){
            if(sum+b[j] > k) break;

            sum += b[j];
            j++;
        }
        if(sum <= k)
            mx = max(mx, i+1+j);
        sum -= a[i];
    }
    sum = 0;
    int cnt = 0;
    for(int i=0; i<m; i++){
        sum += b[i];
        if(sum > k){
            break;
        }
        cnt++;
    }
    mx = max(mx, cnt);
    cout << mx << "\n";

    return 0;
}


Measured memory_bytes: 7988
import java.io.*;
import java.util.*;

/**
 * Bounding
 */
public class Main {

    public static void main(String[] args) {
        
        // 標準入力から2行読み取り
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input1 = null;
        String input2 = null;
        try {
            input1 = br.readLine();
            input2 = br.readLine();
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        // 入力されたデータを使用できる形に加工
        int n = Integer.parseInt(input1.split(" ")[0]);   int x = Integer.parseInt(input1.split(" ")[1]);
        List<Integer> boundDistance = new ArrayList();
        for(String s : input2.split(" ")){
            boundDistance.add(Integer.parseInt(s));
        }

        /* n+1回のバウンドで、跳ねた時の座標がx以下である回数をカウントする。 */
        int boundPoint, countUnderX;
        boundPoint = 0;
        countUnderX = 0;
        for(int i = 0; i <= n; i++){
            if(boundPoint <= x) countUnderX++;
            if(i != n) boundPoint += boundDistance.get(i);
        }

        // 結果の出力
        System.out.println(countUnderX);
    }
}

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

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

    vector<long long int> a(n+1);
    for(int i=1; i<=n; i++){
        cin >> a[i];
        a[i] -= 1;
    }

    // cumulative sum
    for(int i=1; i<=n; i++){
        a[i] += a[i-1];
        a[i] %= k;
    }

    // solve
    long long int ans = 0;
    map<int, int> rem;
    queue<int> q;
    for(int i=0; i<n+1; i++){
        ans += rem[a[i]];
        rem[a[i]] += 1;
        q.push(a[i]);

        if(q.size() == k){
            rem[q.front()] -= 1;
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12032
class BinaryTree {
  constructor() {
    this.root = null;
    BinaryTree.Node = BinaryTree.Node || BinaryTree._Node;
  }

  static get _Node() {
    return class Node {
      constructor(key, parent = null, left = null, right = null) {
        this.key = key;
        this.parent = parent;
        this.left = left;
        this.right = right;
      }

      getChildrenNumber() {return Number(this.left !== null) + Number(this.right !== null);}

      isLeftChild() {
        if (this.parent === null) return null;
        return this.parent.left === this;
      }

      getLeftOrRight() {return this.isLeftChild() ? 'left' : 'right';}

      getSuccessor() {
        let n;
        if (this.right !== null) {
          n = this.right;
          while (n.left !== null) n = n.left;
        } else {
          n = this.parent;
          while (!n.isLeftChild && n.parent != null) n = n.parent;
        }
        return n;
      }
    }
  }

  insert(key) {
    if (this.root === null) {
      this.root = new BinaryTree.Node(key);
      return;
    }
    let x = this.root, y;
    let newNode = new BinaryTree.Node(key);
    while (x !== null) {
      y = x;
      x = x[key < x.key ? 'left' : 'right'];
    }
    newNode.parent = y;
    y[key < y.key ? 'left' : 'right'] = newNode;
  }

  find(key, n = this.root) {
    if (n === null || n.key === key) return n;
    return this.find(key, n[key < n.key ? 'left' : 'right']);
  }

  delete(key) {
    const n = this.find(key);
    const leftOrRight = n.getLeftOrRight();
    switch (n.getChildrenNumber()) {
    case 0:
      n.parent[leftOrRight] = null;
      break;
    case 1:
      n.parent[leftOrRight] = n.left || n.right;
      n.parent[leftOrRight].parent = n.parent;
      break;
    default:
      const skey = n.getSuccessor().key;
      this.delete(skey);
      n.key = skey;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.forEach(function(cmd) {
    switch (cmd.charAt(0)) {
    case 'i': tree.insert(Number(cmd.split(' ')[1])); break;
    case 'f': console.log(tree.find(Number(cmd.split(' ')[1])) ? 'yes' : 'no'); break;
    case 'd': tree.delete(Number(cmd.split(' ')[1])); break;
    default: tree.print();
    }
  });
})();



Measured memory_bytes: 203440
package main
import "fmt"

func main(){
	var n int
	ans := true
	fmt.Scan(&n)
	var a []int = make([]int, n)
	for i:=0;i < n; i += 1 {
		fmt.Scan(&a[i]);
		if i != 0{
			if a[i-1] < a[i] {
				a[i] -= 1;
			} else if a[i-1] > a[i] {
				ans = false
			}
		}
	}
	if ans {
		fmt.Printf("Yes")
	} else {
		fmt.Printf("No")
	}
}


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

int main(){
  int a, b;
  cin >> a >> b;
  
  if ((a * b) % 2 == 0) {
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n,x,y; cin >> n >> x >> y;
    x--;
    y--;
    int dist[n][n];

    for(int i=0;i<n-1;i++) for(int j=i+1;j<n;j++){
        dist[i][j] = min(j-i,abs(x-i)+abs(y-j)+1); 
    }
    int ans[n+3];rep(i,n+1) ans[i] = 0;
    for(int i=0;i<n-1;i++) for(int j=i+1;j<n;j++) ans[dist[i][j]]++;
    
    for(int k=1;k<n;k++) cout << ans[k] << endl;
    return 0;
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int INF = 1000000007;

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

  int N, M;
  cin >> N >> M;
  char A[N][N], B[M][M];
  rep(i, N){
    rep(j, N){
      cin >> A[i][j];
    }
  }
  rep(i, M){
    rep(j, M){
      cin >> B[i][j];
    }
  }
  int sa = N - M;
  bool ans = false, ans1 = true;
  for(int l=0;l<=sa;l++){
    for(int k=0;k<=sa;k++){
      ans1 = false;
      for(int i=0;i<M;i++){
        if(ans1) break;
        for(int j=0;j<M;j++){
          if(A[i+l][j+k] != B[i][j]){
            ans1 = true;
            break;
          }
        }
      } 
      if(!ans1) ans = true;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
x = [[0]*50 for i in range(11)]
for i in range(0, 2**10):
    B = format(i,'b')[::-1]
    s,c,j = 0,0,0
    for e in B:
        if e=="1": s,c = s+j, c+1
        j += 1
    x[c][s]+=1

while 1:
    n, s=map(int, raw_input().split())
    if n==0 and s==0: break
    print 0 if s>=50 else x[n][s]

Measured memory_bytes: 4252
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int cnt = 0;
  rep(a, 0, A+1) {
    rep(b, 0, B+1) {
      rep(c, 0, C+1) {
        if (a * 500 + b * 100 + c * 50 == X) ++cnt;
      }
    }
  }

  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner o = new Scanner(System.in);
        int n = o.nextInt();
        int m = o.nextInt();
        int x = o.nextInt();
        int[][] arr = new int[n][m+1];

        for ( int i = 0 ; i < n ; i++ )
        {
            for ( int j = 0 ; j < m+1 ; j++ )
            {
                arr[i][j] = o.nextInt();
            }
        }

        int l = 0;
        int r = (1<<n) - 1;
        int ans = 1000000001;
        while( l <= r )
        {
            int[] c = new int[m+1];
            Arrays.fill(c,0);
            for ( int j = 0 ; j < n ; j++ )
            {
                if ( (l & (1<<j)) == (1<<j) )
                {
                    for ( int k = 0 ; k < m+1 ; k++ )
                    {
                        c[k] += (arr[j][k]);
                    }
                }
            }
            boolean ok = true;
            for ( int i = 1 ; i < m+1 ; i++ )
            {
                if ( c[i] < x )
                {
                    ok = false;
                    break;
                }
            }
            if(ok)
            {
                ans = Math.min(ans,c[0]);
            }
            l++;
        }

        if ( ans == 1000000001 )
        {
            System.out.print("-1");
        }
        else
        {
            System.out.print(ans);
        }
    }
}

Measured memory_bytes: 37636
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

ll IN(){
	int c,f;ll x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=100000+19;

db x[N],tmp;
int P[60][N],Q[N];
int A[N];
int n,m,u;
ll K;

int main(){
	n=IN();
	For(i,1,n+1) x[i]=IN();
	m=IN(),K=IN();
	For(i,1,n){
		P[0][i]=i;
		Q[i]=i;
	}
	For(i,1,m+1){
		u=IN();
		swap(P[0][u],P[0][u-1]);
	}
	For(t,1,60){
		For(i,1,n) P[t][i]=P[t-1][P[t-1][i]];
	}
	For(t,0,60) if (K>>t&1){
		For(i,1,n) Q[i]=P[t][Q[i]];
	}
	tmp=x[1];
	printf("%.10lf\n",tmp);
	For(i,1,n){
		tmp+=x[Q[i]+1]-x[Q[i]];
		printf("%.10lf\n",tmp);
	}
}

Measured memory_bytes: 27008
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(max(a + b, a - b), a * b);
    return 0;
}

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

int main() {
    ll n;
    cin >> n;
    n;
    vector<char> V;
    while(n>0) {
        if (n%26==0) {
            V.push_back('z');
            n/=26;
            n--;
        }
        else {
            V.push_back('a'+n%26-1);
            n/=26;
        }
    }

    for (int i=V.size()-1;i>=0;i--)
        cout << V[i];
    cout << endl;

}


Measured memory_bytes: 3624