akhauriyash/Code-Regression huggingface dataset:
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			int[][] students = new int[n][n];
			int[][] x = new int[n][n];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					students[i][j] = sc.nextInt();
				}
			}
			
			for(int i = 0; i < n; i++){
				int columnMax = -1;
				for(int j = 0; j < n; j++){
					if(columnMax < students[j][i])
						columnMax = students[j][i];
				}
				for(int j = 0; j < n; j++){
					if(columnMax == students[j][i])
						x[j][i] |= 2;
				}
			}
			for(int i = 0; i < n; i++){
				int rowMin = Integer.MAX_VALUE;
				for(int j = 0; j < n; j++){
					if(rowMin > students[i][j])
						rowMin = students[i][j];
				}
				for(int j = 0; j < n; j++){
					if(rowMin == students[i][j])
						x[i][j] |= 1;
				}
			}
			
			Set<Integer> both = new HashSet<Integer>();
            for(int i = 0;i < n;i++)
                for(int j = 0;j < n;j++)
                    if(x[i][j] == 3)
                        both.add(students[i][j]);
			
            if(both.size() == 1){
            	StringBuilder sb = new StringBuilder();
                for(int v : both){
                    sb.append(v + " ");
                }
                sb.deleteCharAt(sb.length() - 1);
                System.out.println(sb);
            }else{
            	System.out.println(0);
            }
		}
	}
}

Measured memory_bytes: 19564
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;

fn main() {
    input! {
        n: usize, m: usize,
        ab_list: [(usize, usize); m]
    }
    let to_n_set =
        ab_list.iter()
            .filter(|&ab| ab.1 == n)
            .map(|&ab| ab.0)
            .collect::<HashSet<usize>>();
    let is_ok =
        ab_list.iter()
            .filter(|&ab| ab.0 == 1)
            .any(|&ab| to_n_set.contains(&ab.1));
    println!("{}", if is_ok { "POSSIBLE" } else { "IMPOSSIBLE" });
}


Measured memory_bytes: 16564
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<string>
#define mod 1000000007
using namespace std;
typedef long long ll;
inline int mul(int a,int b){ return (a*1ll*b)%mod; }
inline int add(int a,int b){ a+=b;if(a>=mod) a-=mod; return a;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1) rt=rt*a;a=mul(a,a);b>>=1;} return rt;}
//for(int i=0;i<n;i++)

void solve(){
    int n;cin>>n;
    int ans=0;ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++){
       for(int j=i+1;j<n;j++){
          for(int k=j+1;k<n;k++){
             if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
               if(a[i]+a[j]>a[k]) ans++;
        }
      } 
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;//cin>>t;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>


using namespace std;
typedef long long ll;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}







int main() {
  int N;
  cin>>N;
  long long sum[87];
  if(N==0){
    cout<<2<<endl;
  }
  if(N==1){
    cout<<1<<endl;
  }
  sum[0]=2;
  sum[1]=1;
  for(int i=2;i<=N;i++){
    sum[i]=sum[i-1]+sum[i-2];

  }
  if(N>=2){
  cout<<sum[N]<<endl;}

    


  

  
  
  
  
}


  
  

  


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
// #define endl '\n' 
#define pb push_back             
#define fi first 
#define se second 
#define pll pair<long long, long long> 
#define all(v) v.begin(), v.end() 
  
using namespace std; 
   
typedef long long int ll; 
   
mt19937 rnd(1337); 

ostream& operator<< (ostream& a, const pll& b) {
    cout << "{" << b.first << ", " << b.second << "}";
    return a;
}

ostream& operator<< (ostream &a, const vector<ll>& b) {
    for (auto& k : b) cout << k << " ";
    return a;
}

ostream& operator<< (ostream &a, const vector<pll>& b) {
    for (auto& k : b) cout << k << " ";
    return a;
}

#ifdef HOME 
  #define dbg(x) cout << #x << " : " << (x) << '\n';
#else
  #define dbg(x)
#endif                 
   
const ll INF = (ll)1e18; 
const ll MOD = 1000 * 1000 * 1000 + 7, MOD2 = 274876858367;                                                                                    
const ll maxn = (ll)1e5 + 10, L = 10;

ll cnt[4];
  
int main() { 
  #ifdef HOME 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
  #else 
    ios_base::sync_with_stdio(0); cin.tie(0); 
    //freopen("olympiad.in", "r", stdin); 
    //freopen("olympiad.out", "w", stdout); 
  #endif                      
  ll n, m, k;
  cin >> n >> m >> k;
  vector<vector<bool>> a(n, vector<bool>(m));
  ll tot = 0;
  for (ll i = 0; i < n; ++i) {
    for (ll j = 0 ; j < m; ++j) {
      char c;
      cin >> c;
      if (c == '.')
        a[i][j] = 0;
      else
        a[i][j] = 1, ++tot;
    }
  }
  vector<ll> h(n), w(m);
  for (ll i = 0; i < n; ++i) {
    ll cnt = 0;
    for (ll j = 0; j < m; ++j)
      cnt += a[i][j];
    h[i] = cnt;
  }
  for (ll i = 0; i < m; ++i) {
    ll cnt = 0;
    for (ll j = 0; j < n; ++j)
      cnt += a[j][i];
    w[i] = cnt;
  }
  ll cnt = 0;
  for (ll x = 0; x < (1ll << n); ++x) {
    for (ll y = 0; y < (1ll << m); ++y) {
      /*ll a = 0, b = 0;
      for (ll i = 0; i < n; ++i) {
        if ((x >> i) & 1)
          a += h[i];
      }
      for (ll j = 0; j < m; ++j) {
        if ((y >> j) & 1)
          b += w[j];
      }*/
      ll com = 0;
      for (ll i = 0; i < n; ++i) {
        for (ll j = 0; j < m; ++j) {
          if (((x >> i) & 1) == 0 && ((y >> j) & 1) == 0 && a[i][j])
            ++com;
        }
      }
      if (com == k) {
        ++cnt;
      }
    }
  }
  cout << cnt;
  return 0;                    
} 















                  

Measured memory_bytes: 3660
#include<iostream>
#include<stdlib.h>
#include<stack>
using namespace std;

int main()
{
  stack<int> S;
  int a, b, x;
  string s;
  while(cin >> s){
    if(s[0] == '+') {
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a + b);
    } else if (s[0] == '-') {
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a - b);
    } else if (s[0] == '*') {
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a * b);
    } else {
      S.push(atoi(s.c_str()));
    }
  }

  cout << S.top() << endl;

  return 0;
}



Measured memory_bytes: 3216
inp = [int(i) for i in input().split()]
aa = []
for d in range(inp[1],inp[1]+inp[0]):
    aa.append(d)

if 0 in aa:
    pass
elif aa[-1] <= 0:
    aa.pop(-1)
else:
    aa.pop(0)

print(sum(aa))

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int a[3][3];
bool t[3][3];
int n;
int k;

bool f = false;
int main(){
    REP(i,3)
    {
        REP(j,3)
        {
            cin >> a[i][j];
        }
    }
    cin >> n;
    REP(i,n+1)
    {
        int b;
        cin >> b;
        REP(j,3)
        {
            REP(k,3)
            {
                if(a[j][k]==b)t[j][k]=true;
            }
        }
        REP(j,3)
        {
            if(t[j][0]==true && t[j][1]==true && t[j][2]==true){
                cout << "Yes" << endl;
                return 0;
            }
            else if(t[0][j]==true && t[1][j]==true && t[2][j]==true)
            {
                cout << "Yes" << endl;
                return 0;
            }
            else if(t[0][0]==true && t[1][1]==true && t[2][2]==true)
            {
                cout << "Yes" << endl;
                return 0;
            }
            else if(t[0][2]==true && t[1][1]==true && t[2][0]==true)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/*
        ######## ##   ## #######          ##########
           ##    ##   ## ##                 ##    ##
           ##    ####### ######             ##    ##
           ##    ##   ## ##                 ##    ##
           ##    ##   ## ####### ######## ##########
    */
    #include<bits/stdc++.h>
    #include <iomanip>
    #define int         long long
    #define ll             long long
    #define pb          push_back
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         std::vector<vector<int> > v;
    #define all(a)      (a).begin(),(a).end()
    #define F           first
    #define S           second
    #define sz(x)       (int)x.size()
    #define hell        1000000007
    #define rep(i,a,b)    for(int i=a;i<b;i++)
    #define lbnd        lower_bound
    #define ubnd        upper_bound
    #define bs          binary_search
    #define mp          make_pair
    #define maxc(v)     max_element(all(v))
    #define minc(v)     min_element(all(v))
    #define endl        "\n"
    using namespace std;
    #define N  100005
    //#define M  1000003
    #define rn return
    #define B 100000000
    int modularExponentiation(int x,int n,int M = hell)
	{
    	if(n==0)
        	return 1;
    	else if(n%2 == 0)
        	return modularExponentiation((x*x)%M,n/2,M);
    	else
        	return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

	}
	int abs(int a, int b){
        if(a>b) return a-b;
        else return b-a;
    }
    void solve();
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int TESTS=1;
        //cin>>TESTS;
        while(TESTS--)
        {
            solve();
        }
        return 0;
    }
    void solve(){
    	int n, W;
    	cin>>n>>W;
    	int a[n], v[n];
    	rep(i,0,n) cin>>a[i]>>v[i];
    	int dp[n+1][W+1];
    	rep(i,0,n+1){
    		rep(w,0,W+1){
    			if(i==0 || w==0) dp[i][w] = 0;
    			else{
    				if(w>=a[i-1]) dp[i][w] = max(v[i-1]+dp[i-1][w-a[i-1]],dp[i-1][w]);
    				else dp[i][w] = dp[i-1][w];
    			}
    		}
    	}
    	cout<<dp[n][W]<<endl;
    }

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

int main()
{  
  int n;
  cin >> n;
  int p[n];
  for(int i=0;i<n;++i){
    cin >> p[i];
  }
  int ans=0;
  for(int i=1;i<n-1;++i){
    if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1])){
      ++ans;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll d, g, min=1e18;

	cin>>d>>g;

	vll p(d), c(d), sum(d);

	rep(i, d){
		cin>>p[i]>>c[i];
		sum[i]=100*(i+1)*p[i]+c[i];
	}

	rep(i, 1<<d){
		ll sumsc=0, dif, ans=0;
		rep(j, 10){
			if(i&(1<<j)){
				sumsc+=sum[j];
				ans+=p[j];
			}
		}
		//cout<<sumsc<<endl;
		dif=g-sumsc;
		if(dif<=0){
			if(min>ans) min=ans;
		}else{
			ll j=d-1;
			while(dif>0){
				if(j<0) break;
				if(!(i&(1<<j))){
					ll num=ceil((double)dif/(double)(100*(j+1)));
					if(num>p[j]) num=p[j]-1;
					dif-=100*(j+1)*num;
					ans+=num;
				}
				j--;
			}
			if(dif<=0&&min>ans) min=ans;
			//cout<<ans<<endl;
		}
	}
	cout<<min<<endl;
}


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


int main(){

    // スイッチの状態は2のn乗通り、最大で1024通り
    //bit全探索というものをやってみる

    int n,m; cin>>n>>m;

    vector<vector<int>> mo(m);

    for(int i=0; i<m; i++){
        int k; cin>>k;

        for(int j=0; j<k; j++){
            int sw; cin>>sw;
            sw--; //bit演算をするために、数を0か1にする
            mo[i].push_back(sw);
        }
    }

    vector<int> p(m);

    for(int i=0; i<m; i++)cin>>p[i];

    ll ans = 0;

    for(int i=0; i< (1<<n); i++){
        bool flag = true;
        for(int j=0; j<m; j++){
            int count=0;
            for(auto v : mo[j]){
                if(i & (1<<v)) count++;
            }
            if(count % 2 != p[j]) flag = false;   
        }
        if (flag) ans++;    
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
#define MAX_V 300001
#define INF 1000000000000000
using namespace std;
typedef long long ll;
struct edge {
  int to;
  ll cost;
  int coin;
};
typedef pair<ll, int> P;

int V;
vector<edge> G[MAX_V];
ll d[MAX_V], c[50], dd[50];

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d + V, INF);
  d[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    int from = v;
    int vv = v % 5001;
    v = v / 5001;
    if (d[from] < p.first) continue;
    int to;
    to = 5001 * v + min(5000LL, vv + c[v]);
    if (d[to] > d[from] + dd[v]) {
      d[to] = d[from] + dd[v];
      que.push(P(d[to], to));
    }
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (vv - e.coin >= 0 && d[e.to * 5001 + vv - e.coin] > d[from] + e.cost) {
        d[e.to * 5001 + vv - e.coin] = d[from] + e.cost;
        que.push(P(d[e.to * 5001 + vv - e.coin], e.to * 5001 + vv - e.coin));
      }
    }
  }
}
#define MOD 1000000007
using namespace std;

int main() {
  int n, m, s, a, u, v;
  ll b;
  cin >> n >> m >> s;
  V = n * 5001;
  s = min(s, 5000);
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> a >> b;
    u--;
    v--;
    G[u].push_back({v, b, a});
    G[v].push_back({u, b, a});
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i] >> dd[i];
  }
  dijkstra(s);
  for (int i = 1; i < n; i++) {
    ll ans = 10000000000000000;
    for (int j = 0; j <= 5000; j++) {
      ans = min(ans, d[i * 5001 + j]);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 16396
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <utility>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unisgned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define pii pair<int, int>
#define tii triple<int, int, int>
#define e 1e-7
#define PI acos(-1)
#define sz(a) (int)(a.size())
#define inf 1e17
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define int long long
#define problem ""

template<typename A, typename B, typename C>
struct triple{
    A X;
    B Y;
    C Z;
    triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0){
    return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b){
    if (a.X != b.X)
        return a.X < b.X;
    if (a.Y != b.Y)
        return a.Y < b.Y;
    return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p){
    ofs << "( " << p.F << " , " << p.S << " )";
    return ofs;
}
template<typename T>
void print(T a){
    for (auto i : a)
        cout << i << ' ';
    cout << '\n';
}
template<typename T>
T max(T a, T b, T c){
    return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c){
    return min(a, min(b, c));
}
template<typename T, typename D>
D min(T a){
    return *min_element(all(a));
}
template<typename T, typename D>
D max(T a){
    return *max_element(all(a));
}
struct custom_hash{
    static uint64_t splitmix64(uint64_t x){
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void solve(){
    int n; cin >> n;
    vi a(n); rngi(i, n) cin >> a[i];
    int ans = 0;
    SORT(a);
    rngi(i, n) for(int j = i + 1; j < n; j++){
        int s = a[i] + a[j];
        int v = lower_bound(all(a), s) - a.begin() - 1;
        ans += v - j;
    }
    cout << ans << '\n';
};
signed main()
{
    if(0){
        freopen(problem".in", "r", stdin);
        freopen(problem".out", "w", stdout);
    }
    srand(time(NULL));
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int t = 1; //cin >> t;
    rng(t) solve();
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,n=0;
    cin >> a >> b>> c;
    for(int i=a;i<=b;i++){
        if(c%i==0)n++;
    }
    cout << n << endl;
}


Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <algorithm>
#include <set>

typedef long long ll;

using namespace std;

int main()
{
    ll n, Y;
    ll x, y, z;
    ll rx = -1, ry = -1, rz = -1;

    cin >> n >> Y;

    for (z=0; z<=n; z++)
    {
        for (y=0; z + y<=n; y++)
        {
            x = n - y - z;

            if (10000*x + 5000*y + 1000*z == Y) 
            {
                rx = x;
                ry = y;
                rz = z;
            } 
        }
    }

    cout << rx << " " << ry << " " << rz << endl; 

    return 0;
}


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



int main(){
  ll H,count=1,kaisu=0;
  cin>>H;
  while(H>=1){
    H/=2;
    kaisu=pow(2,count)-1;
    count++;
  }
  cout<<kaisu<<endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> P;

vector<pll> v[100000];
ll d[100000] = {};

void dfs(ll u)
{

    for (int i = 0; i < v[u].size(); i++)
    {
        pll t = v[u][i];
        if (d[t.first] != -1)
            continue;
        d[t.first] = d[u] + t.second;
        dfs(t.first);
    }
}

int main()
{
    rep(i, 100000) d[i] = -1;

    int n;
    cin >> n;
    rep(i, n - 1)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        v[a].push_back(pll(b, c));
        v[b].push_back(pll(a, c));
    }

    int q, k;
    cin >> q >> k;

    k--;
    d[k] = 0;
    dfs(k);
    rep(i, q)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        OP(d[x] + d[y]);
    }

    return 0;
}

Measured memory_bytes: 14336
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc= new Scanner(System.in);
		
		int R= sc.nextInt();
		
		sc.close();
		
		double ans= 2* R *Math.PI;
		
		System.out.println(ans);
		
		
		
	}

}


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

int main(void){

	int k;
	char s[110];
	char l[110];
	int n;

	scanf("%d",&k);
	scanf("%s",s);

	n = strlen(s);

	if(n <= k){
		printf("%s\n",s);
	}else{
		strncpy(l,s,k);
		l[k] = '\0';
		printf("%s...\n",l);
	}





	
	return 0;
}

Measured memory_bytes: 1732
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
moto = a.size
a = a.unshift(0)
aa = 0
nn = n + 1
nn.times do |i|
    if a[i] != i - aa
        a[i] = " "
        aa += 1
    end
end
if moto == aa
    puts "-1"
else
    puts aa
end

Measured memory_bytes: 37804
#include <bits/stdc++.h>
 
using namespace std;
 
using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;
 
#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define LL long long
#define ULL unsigned long long
 
// n개중에서 k 를 고르는 Combination table을 미리 세팅한다.
// C[n][k] -> nCk
ULL Comb[51][51];
void combination_table(int n)
{
    for(int i = 0; i <= n; ++i)
        for(int j = 0; j <= i; ++j)
        {
            if(j == 0 || j == i)
                Comb[i][j] = 1ll;
            else
                Comb[i][j] = Comb[i - 1][j - 1] + Comb[i - 1][j];
        }
}
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    int N, A, B;
    cin >> N >> A >> B;
 
    VL items(N, 0);
    REP(i, 0, N) cin >> items[i];
 
    combination_table(N);
    sort(items.begin(), items.end(), greater<LL>());
 
    double max_avg = (double)accumulate(items.begin(), items.begin() + A, 0ll) / A;
    
    LL smallest = items[A - 1];
    int numSmallest = count(items.begin(), items.end(), smallest);
    
    LL cnt = 0ll;
    // 1. items[0] == items[A - 1] 인 경우    
    if(items[0] == smallest)
        cnt += accumulate(Comb[numSmallest] + A, Comb[numSmallest] + B + 1, 0ll);
    else {
        int numSub = count(items.begin(), items.begin() + A, smallest);
        cnt += Comb[numSmallest][numSub];
    }
 
    cout.precision(10);
    cout << fixed << max_avg << endl << cnt << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int c=0;
    for(int i;i<6;i++){

         if(a[2]==a[3] && a[4]==a[5]) c++;
    }
                 if(c>=1) cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
}


Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  200005
vi a[N];
ll ans[N],dis[N];
int main()
{
	ios
	ll n,i,j,x,y,m;
	cin>>n>>m;
	for(i=2;i<=n;i++)
		dis[i]=hell;
	for(i=0;i<m;i++){
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	queue<ll>q;
	q.push(1);
	while(!q.empty()){
		ll t=q.front();
		q.pop();
		for(auto i:a[t]){
			if(dis[i]>dis[t]+1){
				q.push(i);
				dis[i]=dis[t]+1;
				ans[i]=t;
			}
		}
	}
	for(i=2;i<=n;i++)
		if(ans[i]==hell){
			cout<<"No";return 0;
		}
	cout<<"Yes\n";
	for(i=2;i<=n;i++)cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 16136
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        String ans = "Yes";
        HashSet<String> set = new HashSet<>();
        String s = sc.next();
        set.add(s);
        char end = s.charAt(s.length()-1);
        
        for(int i = 1; i < n; i++){
            s = sc.next();
            if(set.contains(s) || s.charAt(0) != end){
                ans = "No";
                break;
            }
            set.add(s);
            end = s.charAt(s.length()-1);
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 23508
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>

using namespace std;

typedef unsigned long long ull;

ull n, ans = 0, y = 1;
string s;
vector<string> v;

int main()
{

  ios::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  //freopen(".in", "r", stdin);
  //freopen(".out", "w", stdout);
  
  cin >> n;
  for (int i = 0; i < n; i ++)
  {
  	cin >> s;
  	sort(s.begin(), s.end());
  	v.push_back(s);
	}
	
	sort(v.begin(), v.end());
//	for (int i = 0; i < n; i++)
//		cout << v[i] << endl;
	
	for (int i = 1; i < n; i++)
	{
		if (v[i] == v[i - 1]) y++;
		else if (y != 1) ans += y * (y - 1) / 2, y = 1;
	}
	if (y != 1) ans += y * (y - 1) / 2;
	cout << ans << endl;
  
  return 0;
  
}


Measured memory_bytes: 5748
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long m = sc.nextLong();
    long ans = 0;
    if(m > (2 * n)) {
      ans = n;
      m -= (2 * n);
      ans += (m / 4);
    } else {
      ans = (m / 2);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35580
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  long n;
  scanf("%ld", &n);
  if (n == 2) {
    printf("1\n");
    return 0;
  }
  long ans = 2;
  for (long i=2; i*i<=n; i++) {
    if (i*i == n-1)
      ans++;
    else if ((n-1)%i == 0)
      ans += 2;
    if (n%i != 0)
      continue;
    long p = n / i, m = n;
    while (m%i == 0)
      m /= i;
    if (m%i == 1)
      ans++;
    m = n;
    while (m%p == 0)
      m /= p;
    if (m%p == 1 && i!=p)
      ans++;
  }
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define endl '\n';
const int maxn=2e5+5;
int32_t main(){
	ios::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0);
	int a[3];
	for (int i = 0; i < 3; ++i)
	{
		cin>>a[i];
	}
	int ans=0;
	int k;
	cin>>k;
	for (int i = 0; i < 3; ++i)
	{
		int rem = min(k,a[i]);
		if(i==0) ans+=rem;
		else if(i==2) ans-=rem;
		k-=rem;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int paid;
  bool flag = false;
  while ( cin >> paid, paid ) {
    if ( flag ) cout << endl;
    flag = true;    

    int c10, c50, c100, c500;
    cin >> c10 >> c50 >> c100 >> c500;

    int min10 = 21, min50 = 21, min100 = 21, min500 = 21;
    int a10, a50, a100, a500;
    int sum = 84;  
    for ( int i = 0; i <= c10; i++ ) {
      for ( int j = 0; j <= c50; j++ ) {
	for ( int k = 0; k <= c100; k++ ) {
	  for ( int l = 0; l <= c500; l++ ) {
	    int tmp = 10*i+50*j+100*k+500*l;
	    if ( paid > tmp ) continue;	  
	    int dif = tmp-paid;
	    int t10 = c10-i, t50 = c50-j, t100 = c100-k, t500 = c500-l;
	    if ( dif ) t500 += dif/500;
	    dif %= 500;
	    if ( dif ) t100 += dif/100;
	    dif %= 100;
	    if ( dif ) t50 += dif/50;
	    dif %= 50;
	    if ( dif ) t10 += dif/10;	  
	    tmp = t10+t50+t100+t500;
	    if ( tmp < sum ) {
	      min10  = t10;
	      min50  = t50;
	      min100 = t100;
	      min500 = t500;
	      a10  = i;
	      a50  = j;
	      a100 = k;
	      a500 = l;
	      sum = tmp;
	    }
	  }
	}
      }
    }
  
    if ( a10 )  cout << 10 << " " << a10 << endl;
    if ( a50 )  cout << 50 << " " << a50 << endl;
    if ( a100 ) cout << 100 << " " << a100 << endl;
    if ( a500 ) cout << 500 << " " << a500 << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  string s;
  int C = 98989, F = -11111;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] == 'C')
      C = i;
    if (s[i] == 'F')
      F = i;
  }
  if (C < F)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
 
#define int                     long long
#define file(s)                 freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a)          for(int i = (b); i >=(a); i--)
#define forn(i, a, b)           for(int i = (a); i <= (b); i++)
#define speed                   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
using namespace std;
 
typedef long long ll;
typedef double db;
typedef long double ldb;
 
const ldb pi = 3.14159265358979323846264;
const int maxn = 2e5 + 1;
const int mod = 1e9 + 7;
  
int n;
int h[maxn];
int dp[maxn];
    
main(){
    //file("");
    speed;
    cin >> n;
    forn(i, 1, n)cin >> h[i];
    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    forn(i, 3, n){
        dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i]));
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 5152
text = list(input())
first = text[0]
firstCount = 1
second = ""
secondCount = 0
error = False
for i in range(1, 4):
    moji = text[i]
    if moji == first:
        firstCount += 1
        if firstCount > 2:
            error = True
            break
    else:
        if second == "" or second == moji:
            second = moji
            secondCount += 1
            if secondCount > 2:
                error = True
                break
        else:
            error = True
            break
if error == True:
    print("No")
else:
    print("Yes")

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int64 N, A, B, C, X;
	while(cin >> N >> A >> B >> C >> X && (N || A || B || C || X)){
		vector<int64> y(N);
		REP(i, N) cin >> y[i];
		int32 in = 0;
		int32 cnt = 0;
		while(in < N){
			if(X == y[in]){
				in++;
				if(in == N) break;
			}
			X = (X*A+B)%C;
			cnt++;
			if(cnt > 10000) break;
		}
		if(cnt > 10000) cout << -1 << endl;
		else cout << cnt << endl;
		
	}

}


Measured memory_bytes: 3008
n=gets.to_i
a=gets.chomp.split(" ").map(&:to_i)

d=a.map{|x|x.abs}
min=d.min
cnt=0
n.times{|i|
  if a[i]<=0
    cnt+=1 
  end
}
puts (cnt%2).zero? ? d.inject(:+) : d.inject(:+)-min*2


Measured memory_bytes: 10500
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	int h,w,n;
	cin >> h >> w >> n;
	cout<<(n+max(h,w)-1)/max(h,w)<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let A = read::<i32>();
    let B = read::<i32>();
    let C = read::<i32>();
    let D = read::<i32>();

    if A*B >= C*D {
        println!("{}", A*B);
    } else {
        println!("{}", C*D);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int A = 0, B = 0;
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    if (a < X) {
      A++;
    }
    else {
      B++;
    }
  }
  cout << min(A, B) << endl;
}


Measured memory_bytes: 3584
S = gets.chomp
N = (S.size-1) / 2
F =->(s){
  n = (S.size-1) / 2
  s[0,n] == s[-n,n].reverse
}
x = F[S]
x &&= F[S[0,N]]
x &&= F[S[N+1..-1]]
puts x ? :Yes : :No

Measured memory_bytes: 1788
<?php
  
$n = trim(fgets(STDIN));

for($i=1; $i<=$n; $i++){
  $a = trim(fgets(STDIN));
  for($j=1; $j<=$a; $j++){
    $tes = explode(' ', trim(fgets(STDIN)));
  	$t[$i][$j] = $tes;
  }
}

for($i=2**$n-1; $i>=0; $i--){
  
    $p = str_pad(decbin($i), $n, 0, STR_PAD_LEFT);
    
    $pt = array_count_values(str_split($p));
    isset($pt[1])? $pc = $pt[1] : $pc = 0;
      
    $hc = 0;
    for($j=1; $j<=$n; $j++){      
      $jj = $j-1;
      if ($p[$jj] == 1){        
        $tc = 0;        
        foreach($t[$j] as $k=>$v){
          $vp = $v[0]-1;
          $vv = $v[1];          
          if ($p[$vp] == $vv) $tc++;          
        }        
        if ($tc == count($t[$j])) $hc++;         
      }      
    }
  
    if ($hc == $pc) break;
    
}

echo $hc;

?>

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

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

  long long ans = 0;

  vector<vector<long long>> d(n, vector<long long>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> d[i][j];
      ans += d[i][j];
    }
  }

  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      if (i == k || d[i][k] == -1)
        continue;
      for (int j = 0; j < n; ++j) {
        if (j == k || d[k][j] == -1)
          continue;
        if (d[i][j] == -1)
          continue;
        if (d[i][j] > d[i][k] + d[k][j]) {
          // printf("%d -[%d]> %d > %d -[%d]> %d -[%d]> %d\n", i, d[i][j], j, i,
          //        d[i][k], k, d[k][j], j);
          cout << -1 << endl;
          return 0;
        } else if (d[i][j] == d[i][k] + d[k][j]) {
          ans -= 2 * d[i][j];
          d[i][j] = d[j][i] = -1;
        }
      }
    }
  }

  cout << ans / 2 << endl;
  //
  // for (int i = 0; i < n; ++i) {
  //   for (int j = 0; j < n; ++j) {
  //     cout << d[i][j] << (j + 1 == n ? "\n" : " ");
  //   }
  // }
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <queue>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;

#define pb emplace_back
#define forn(i, x, n) for(int i = (int)x; i < (int)n; ++i)

struct init {
    init() {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout << fixed << setprecision(10);
    }

    ~init() {
        cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n";
    }
} init;

const int N = 100500 * 1, MOD = 1000 * 1000 * 1000 + 7;
//const ldb EPS = 5e-12, HALF = 0.5;

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

    int sum = 0;
    bool fl = 0;

    while (n) {
        if (n % 10 > 1 || n % 10 && sum != 0) {
            fl = 1;
        }
        sum += n % 10;
        n /= 10;
    }

    if (fl) {
        cout << sum;
    } else {
        cout << sum + 9;
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    A=list(range(1,4))
    A.remove(int(input()))
    A.remove(int(input()))
    print(A[0])
resolve()

Measured memory_bytes: 38384
let n = Scanf.scanf " %d" (+) 0
let rec f n = if n mod 2 <> 0 then 0 else 1 + f (n / 2)
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" f
let z, o, t = Array.fold_left (fun (z, o, t) -> function 0 -> z + 1, o, t | 1 -> z, o + 1, t | _ -> z, o, t + 1) (0, 0, 0) a_s
let g b = print_endline @@ if b then "Yes" else "No"
let _ = g @@ if o > 0 then z <= t else z - 1 <= t

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string,int,int>> A(N);
  for (int i=0; i<N; i++) {
    string city;
    int rank;
    cin >> city >> rank;
    A.at(i) = make_tuple(city, 101-rank, i+1);
  }
  sort(A.begin(), A.end());
  for (int i=0; i<N; i++) {
    string x;
    int a, b;
    tie(x, a, b) = A.at(i);
    cout << b << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int m, k;
	scanf("%d %d", &m, &k);
	if (m == 0) {
		if (k == 0)
			puts("0 0");
		else
			puts("-1");
	}
	else if (m == 1) {
		if (k == 0)
			puts("0 0 1 1");
		else
			puts("-1");
	}
	else {
		if (k < (1 << m)) {
			for (int i = 0; i < (1 << m); i++)
				if (i != k)
					printf("%d ", i);
			printf("%d ", k);
			for (int i = (1 << m) - 1; i >= 0; i--)
				if (i != k)
					printf("%d ", i);
			printf("%d\n", k);
		}
		else
			puts("-1");
	}
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int long long n,k;
  cin>>n>>k;
  int long long h[n];
  for(int i=0;i<n;i++)
    cin>>h[i];
  sort(h,h+n);
  /*for(int i=0;i<n;i++)
    cout<<h[i]<<endl;*/
  for(int i=n-1;i>n-1-k;i--)
    h[i]=0;
  int long long ans=0;
  for(int i=0;i<n;i++)
    ans+=h[i];
  cout<<ans<<endl;
}

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

int main() {
  int counter;
  string num;
  cin >> num;
  
  for( int i = 0; i < 3; i++ ) {
    if( num.at(i) == '1' ) {
      counter++;
    }
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;


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

int main(){
	ll n;
	cin>>n;
	for(ll i=1; i<=n; i++){
		if(i%3!=0 && i%5!=0) ans +=i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3192
#include <iostream>

using namespace std;

int main()
{
   int  x;
   cin>>x;
   string s;
   cin>>s;
   int len=s.size();
   for(int i=0;i<len;i++)
{
    cout<<(char)('A'+((s[i]-'A')+x)%(26));
}

    return 0;
}


Measured memory_bytes: 256
#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 k,x;
 cin >> k >> x;
 if (500*k>=x){
     cout << "Yes" << endl;
 }
 else{
     cout << "No" << endl;
 }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        
using namespace std;
        
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
        
#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
        
ll next(){ll x; cin >> x; return x;}
const int maxn = 1e3 + 5, intf = 2e9;
const ll inf = 1e18, mod = 998244353;
const ld eps = 1e-6;

void solve(){
	ll a , b , c , k;
	cin >> a >> b >> c >> k;
	cout << min(a , k) - min(c , max(0LL , k - a - b)) << '\n';
}
    
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
            
    for (int t = 1; t--;) {
        solve();
    }
        
    return 0;
}
/*
        
        
*/

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

int main(){
    int n; cin >> n;
    vector<int> h(n); 
    for(int i=0; i<n; i++) cin >> h[i];

    vector<long long> dp(n);
    dp[1] = abs(h[0] - h[1]);

    for(int i=2; i<n; i++){
        dp[i] = min(dp[i-1]+abs(h[i] - h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>alphabet['z'-'a'];

int main(){
    long long i,j,r=0LL,c;
    string s,t;
    cin>>s>>t;
    for(i=0LL;i<s.size();i++)alphabet[s[i]-'a'].push_back(i);

    for(i=0LL,c=-1LL;i<t.size();i++){
        if(alphabet[t[i]-'a'].size()==0){cout<<-1<<endl;return 0;}
        auto p=upper_bound(alphabet[t[i]-'a'].begin(),alphabet[t[i]-'a'].end(),c);
        if(p==alphabet[t[i]-'a'].end()){
            c=-1LL;
            p=upper_bound(alphabet[t[i]-'a'].begin(),alphabet[t[i]-'a'].end(),c);
            r++;
        }
        c=*p;
    }
    cout<<c+1LL+r*s.size()<<endl;
    return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
int n;
int a[10000001];
int i,j;

int main(){
  a[0]=0;
  a[1]=0;
  for(i=2;i<=10000000;i++)a[i]=1;
  
  for(i=2;i*i<=10000000;i++){
    if(a[i]==1){
      for(j=i*i;j<=10000000;j+=i){
        a[j]=0;
      }
    }
  }

  for(i=10000000;i>=13;i--){
    if(a[i]==1&&a[i-2]==1&&a[i-6]==1&&a[i-8]){
      a[i]=i;
    }else{
      a[i]=0;
    }
  }

  for(i=14;i<=10000000;i++){
    if(a[i]==0)a[i]=a[i-1];
  }

  while(1){
    scanf("%d",&n);
    if(n==0)break;
    printf("%d\n",a[n]);
  }
  
  return 0;
}

Measured memory_bytes: 40088
INF = 10 ** 9
MOD = 10 ** 9 + 7
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  math import factorial


def main():
    s = input()
    K = 'keyence'
    if s[:7] == K or s[-7:] == K:
        print('YES')
        return
    ans = 'NO'
    for i in range(7):
        a = K[:i]
        b = K[i:]
        if s[:i] == a and s[-7+i:] == b:
            ans = 'YES'
            break
    print(ans)
if __name__ == '__main__':
    main() 

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

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

    int m=0;
    for(int i=0; i<N; i++){
        m = max(m, A[i]);
    }

    int dp[H+m];
    dp[0] = 0;
    for(int i=1; i<H+m; i++){
        dp[i] = 100000000;
        for(int j=0; j<N; j++){
            int l = max(0, i-A[j]); 
            dp[i] = min(dp[l]+B[j], dp[i]);
        }
    }

    int ans = dp[H];
    for(int i=H; i<H+m; i++){
        ans = min(ans, dp[i]);
    } 
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;


int main()
{
	iostream::sync_with_stdio(false);
	int N;
	int fuses = 0;
	string S;
	cin >> N >> S;
	for (int i = 0; i < N-1; ++i)
	{
		if (S[i] == S[i + 1])
		{
			fuses += 1;
		}
	}

	int slimes_left = N - fuses;






	cout << slimes_left;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

vector<ll> ret;
void divisor(ll n)
{
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, tmp = INF;
    vector<ll> lis;
    cin >> N;
    string ans;

    divisor(N);

    for (ll i = 0; i < ret.size(); i++)
    {
        for (ll j = 0; j < ret.size(); j++)
        {
            if (ret[i] * ret[j] == N)
            {
                ans = "Yes";
                tmp = min(tmp, ret[i] + ret[j] - 2);
            }
        }
    }

    if (ans == "Yes")
    {
        cout << tmp << endl;
    }
    else
    {
        cout << N - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 384