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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    Vec v(n+1,0);
    Vec p(n+1,-1);
    set<ll> st;
    rep(i,n){
        cin>>p[i];
    }

    ll cnt = 1;
    REP(i,1,n){
        if(p[i]<p[i-1]){
           v[i]=v[i-1]+1;
        }else{
            v[i]=v[i-1];
        }
    }
   // dbg(v);
    ll dupcnt = 0;
    ll ans=1;
    rep(i,k){
        st.insert(p[i]);
    }
    for(ll i=1;i+k-1<=n-1;i++){
        st.erase(p[i-1]);
        ll setfirst = *st.begin();
        ll setlast = *st.rbegin();
        ll &prev = p[i-1];
        ll &now = p[i+k-1];
        if(v[i+k-1]-v[i]==0){
            dupcnt++;
        }
        if(!(prev<setfirst&&now>setlast)){
            if(v[i+k-1]-v[i]!=0||dupcnt<=1){
               // dbg(i);
                ans ++;
            }
        }

        st.insert(p[i+k-1]);
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define lowbit(a) a&(-a)
#define INF 0x3f3f3f3f
using namespace std;

inline int read(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
	return f*sum;
}

const int N=100001;
ll n,a[N];ll s[N];
ll c[N],tot;ll t[(N<<1)+5];

inline ll ask(int x){
	ll ret=0;
	for(int i=x;i;i-=lowbit(i)) ret+=t[i];
	return ret;
}

inline void add(int x,int k){
	for(int i=x;i<=(N<<1);i+=lowbit(i)) t[i]+=k;
}

inline bool check(int mid){
	memset(t,0,sizeof(t));s[0]=0;ll sum=0;
	for(int i=1;i<=n;i++) s[i]=s[i-1]+(a[i]>=mid? 1:-1);
	for(int i=0;i<=n;i++){
		sum+=ask(s[i]+N);add(s[i]+N,1);
	}
	return sum>=n*(n+1)/4;
}

int main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read(),c[i]=a[i];
	sort(c+1,c+n+1);int m=unique(c+1,c+n+1)-c-1;
	for(int i=1;i<=n;i++) a[i]=lower_bound(c+1,c+m+1,a[i])-c;
	int l=1,r=n;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)) l=mid+1;
		else r=mid-1;
	}
	printf("%lld\n",c[r]);
	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  set<string> x;
  x.insert(s);
  
  int l;
  string a, b;
  for(int i=0; i<n-1; i++) {
    cin >> a;
    if(i==0) {
      if(s[s.size()-1] != a[0]) {
        cout << "No" << endl;
        return 0;
      }
    }
    else if(b[b.size()-1] != a[0]) {
      cout << "No" << endl;
      return 0;
    }
    b = a;
    l = x.size();
    x.insert(a);
    if(l == x.size()) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define MAX_V 10000
using namespace std;
struct node{
  int id,parent,left,right,sibling;
  node():id(0),parent(-1),left(-1),right(-1),sibling(-1){}
};
node nodes[MAX_V]{};

int depth(node n){
  if(n.parent==-1) {return 0;}
  return depth(nodes[n.parent])+1;
}
int degree(node n){
  int d=0;
  if(n.left>=0) d++;
  if(n.right>=0) d++;
  return d;
}
int height(node n){
  int l=0,r=0;
  if(n.left>=0)
    l=height(nodes[n.left])+1;
  if(n.right>=0)
    r=height(nodes[n.right])+1;
  return l>r?l:r;
}

string kind(node n){
  if(n.parent==-1){return "root";}
  if(n.left==-1&&n.right==-1){return "leaf";}
  return "internal node";
}

int main(){
  int n; cin>>n;
  REP(i,n){
    int id,left,right;
    cin>>id>>left>>right;
    nodes[id].id=id;
    nodes[id].left=left;
    nodes[id].right=right;
    if(left>=0){
      nodes[left].parent=id;
      nodes[left].sibling=right;
    }
    if(right>=0){
      nodes[right].parent=id;
      nodes[right].sibling=left;
    }
  }
  REP(i,n){
    cout<<"node "<<nodes[i].id
	<<": parent = "<<nodes[i].parent
	<<", sibling = "<<nodes[i].sibling
	<<", degree = "<<degree(nodes[i])
	<<", depth = "<<depth(nodes[i])
	<<", height = "<<height(nodes[i])
	<<", "<<kind(nodes[i])<<"\n";
  }
}

Measured memory_bytes: 1404
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.length(); i+=2) {
    ans = ans + s[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 200010
#define LL long long
int a[N],vis[N];
LL s;
int main()
{
    int i,j,k,n;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    if(a[1]!=0)
    {
        printf("-1\n");
        return 0;
    }
    s=0;
    for(i=2;i<=n;i++)
    {
        if(a[i]>a[i-1]+1)
        {
            printf("-1\n");
            return 0;
        }
        if(a[i]-1==a[i-1])
        s++;
        else
        s=s+a[i];
    }
    printf("%lld\n",s);
    return 0;
}


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

int digit_sum(int n){
	int sum = 0;
	while (n){
		sum += n%10;
		n /=10;
	}
	return sum;
}

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int sum = 0;
	for (int i = 0; i <= n; i++){
		int d = digit_sum(i);
		sum += (d >= a && d <= b) ? i : 0;
	}
	cout << sum;
}


Measured memory_bytes: 256
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
#define vi vector<int>
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      
    x = x % p;  
    while (y > 0) {  
        if (y & 1) 
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;       
    while (y > 0) {    
        if (y & 1) 
            res = (res*x) ;  
        y = y>>1; 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve(){
    ll n;cin>>n;
    if(isPrime(n)){cout<<n-1<<endl;return;}
    //find the highest divisor less than the sqrt
    frr(i,(int)sqrt(n),1){
        if(n%i==0){
            cout<<i-1+n/i-1<<endl;
            return;
        }
    }
    return;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 ll n ;
 cin >> n ;
 vector<ll> A(n) ;
 rep(i,n) cin >>A[i] ;
 ll ans=0 ;
 rep(i,n) if(A[i]%2==1) ans++ ;
  if(ans%2==0) cout<< "YES"<<endl ;
  else cout <<"NO"<<endl ;
      return 0;
}


Measured memory_bytes: 1024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

n, *p = map(int, read().split())

cnt = 0
for i in range(0, n - 1):
    if p[i] == i + 1:
        p[i], p[i + 1] = p[i + 1], p[i]
        cnt += 1
if p[n - 1] == n:
    cnt += 1

print(cnt)


Measured memory_bytes: 12388
#include<bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi; 
typedef pair<int,int> pi;
typedef long long ll;
#define F first 
#define S second 
#define PB push_back 
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)

ll n,k,ini;
vector<ll> a;

vector< vector<bool> > dp;
bitset<1000000> visto;

bool see(ll here, bool moment){
	
	visto[here] = 1;
		
	if(here < ini ){
		dp[here][moment] = !moment;
		dp[here][!moment] = moment;
		
		return !moment;
	}
	
	
	bool can = true;
	
	if(moment){
		can = false;
		
		for(ll i = 0; i < n; i++){
					
			if( here - a[i] >= 0 ){
				if(!visto[here - a[i]]) see(here- a[i], !moment);
				can = (can || dp[ here- a[i] ][ !moment ]  );
			}
			
		}
				
	}
	else{
		
		can = true;
		
		for(ll i = 0; i < n; i++){
					
			if( here - a[i] >= 0 ){
				if(!visto[here - a[i]]) see(here- a[i], !moment);
				can = (can && dp[ here- a[i] ][ !moment ]  );
			}
			
		}
		
	}
	
	dp[here][moment] = can;
	dp[here][!moment] = !can;
	
	return can;
	
}

int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	
	
	cin >> n >> k; 
	
	dp.assign(k+1, vector<bool>(2,0) );
	a.assign(n, 0);
	
	for(ll i = 0; i < n; i++){
		cin >> a[i];
	}
	
	ini = a[0];
	
	bool can = see(k, 1);
	
	if(can ){
		cout << "First" << endl;
	}
	else{
		cout << "Second" << endl;
	}
	 
	return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

template < typename T >
void min_self (T & a, T b) {
	if (a > b) a = b;
}

const int mx = 1e5 + 13;
const ll inf = 1e18;

int main() {
	int n, W, w, v;
	scanf ("%d %d", &n, &W);
	vector < ll > dp (mx + 1, inf);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		scanf ("%d %d", &w, &v);
		for (int value = mx; value >= v; value--) {
			min_self (dp[value], dp[value - v] + w);
		}
	}
	ll answer = 0;
	for (int i = mx; i >= 0; i--) { //  W; i++) {
		if (dp[i] <= W) {
			answer = i;
			break;
		}
	}
	printf ("%lld\n", answer);
	return 0;
}


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

int main(){
  int N;
  vector<int> card;
  cin >> N;
  
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    card.push_back(tmp);
  }
  
  sort(card.begin(),card.end(),greater<int>());
  
  int alice, bob = 0;
  
  for(int i=0;i<N;i++){
	if(i%2==0) alice += card[i];
    else bob += card[i];
  }
  cout << alice - bob << endl;
}

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

int main(){

	int A,B,C,D,E;

	 cin >> A >> B >> C >> D >> E;
	//cin >> A;
	int a,b,c,d,e;
	a = 10*((A-1)/10)+10;
	b = 10*((B-1)/10)+10;
	c = 10*((C-1)/10)+10;
	d = 10*((D-1)/10)+10;
	e = 10*((E-1)/10)+10;

	int aa,bb,cc,dd,ee;
	aa = A%10;
	bb = B%10;
	cc = C%10;
	dd = D%10;
	ee = E%10;
	vector<int> v;
	v.push_back(aa);
	v.push_back(bb);
	v.push_back(cc);
	v.push_back(dd);
	v.push_back(ee);
	sort(v.begin(),v.end());
	int i = 0;
	int ans = 10;
	while(v[i]==0){
		i++;
		if (i == 5){
			break;
		}
	}
	if (i==5){
		ans = 10;
	}else{
		ans = v[i];
	}
	
	//cout << v[2] << endl;
	cout << a+b+c+d+e - 10 + ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

void main()
{
    auto N = readln.chomp.to!long;
    auto CS = readln.split.to!(long[]);
    sort!"a > b"(CS);
    auto ds = new long[](N);
    ds[0] = pow(2, N*2-1);
    foreach (long i; 1..N) ds[i] = (ds[0] + (((ds[0] * 500000004) % P) * i) % P) % P;
    long r;
    foreach (i; 0..N) r = (r + (CS[i] * ds[i]) % P) % P;
    writeln(r);
}

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

int main() {
    int A, B, C, K;
    map<int, int> m;
    cin >> A >> B >> C >> K;
    m[1] = A, m[0] = B, m[-1] = C;
    if (K <= A) {
        cout << K << endl;
    } else if (K > A && K <= A + B) {
        cout << A << endl;
    } else {
        cout << A - (K - A - B) << endl;
    }
    return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n; string s;
  cin >> n >> s;
  vector<int> r,g,b;
  set<int> rs,gs,bs;
  rep(i,n){
    if(s[i]=='R')r.emplace_back(i);
    else if (s[i]=='G')g.emplace_back(i);
    else b.emplace_back(i);
  }
  ll ans = 0;
  rep(i,n-2){
    for(int j = i+1; j < n-1; ++j){
      if(s[i]==s[j])continue;

      vector<int> x; char c;
      if((s[i]=='R'&&s[j]=='G')||(s[i]=='G'&&s[j]=='R')){
        x = b; c = 'B';
      }else if((s[i]=='G'&&s[j]=='B')||(s[i]=='B'&&s[j]=='G')){
        x = r; c = 'R';
      }else{
        x = g; c = 'G';
      }
      int ng = (j-i) + j;
      auto itr = upper_bound(x.begin(),x.end(),j);
      ans += x.end() - itr;
      if(ng<n && s[ng]==c && *itr <= ng) --ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
int main() {
  int a, b;
  cin >> a >> b;
  char A;
  int mp[a][b], dp[a][b];
  rep(i, a) rep(j, b) {
    cin >> A;
    mp[i][j] = A - '0';
    dp[i][j] = INF;
  }
  dp[0][0] = 0;
  rep(i, a) rep(j, b) {
    if (j != 0)
      dp[i][j] = min(dp[i][j], dp[i][j - 1] + mp[i][j]);
    if (i != 0)
      dp[i][j] = min(dp[i - 1][j] + mp[i][j], dp[i][j]);
  }
  cout << dp[a - 1][b - 1] << endl;
  ;
  return 0;
}

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

int main()
{
    ll N;
    cin >> N;

    ll D[N][N];
    for (ll i = 0; i < N; i++)
    {
        cin >> D[i][0] >> D[i][1];
    }

    for(ll i = 2; i < N; i++){
        if(D[i][0] == D[i][1] && D[i-1][0] == D[i-1][1] && D[i-2][0] == D[i-2][1]){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int ctoi(char);
int main(){
  int n;
  cin >> n;
  for(int I=0;I<n;I++){
    vector<char> ha(2);
    int c=0;
    int ac=0;
    vector<char> ya(8);
    for(int i=0;i<2;i++){
      cin >> ha[i];
      if(ha[i]=='A'){
	ac++;
      }
      c+=ctoi(ha[i]);
    }
    for(int i=0;i<8;i++){
      cin >> ya[i];
    }
    int i=0;
    while(1){
      if(i==0&&c==11&&ac){
	cout << "blackjack" << endl;
	break;
      }
      int c2=-1;
      if(ac&&c+10<=21)c2=c+10;
      if((c<=16&&c2<=16)||(c==7&&ac)){
	c+=ctoi(ya[i]);
	if(ya[i]=='A'){
	  ac++;
	}
	i++;
      }
      else{
	if(c>21){
	  cout << "bust" << endl;
	  break;
	}
	else {
	  cout << max(c,c2) << endl;
	  break;
	}
      }
    }
  }
  return 0;
}

int ctoi(char x){
  if(x>='0'&&x<='9'){
    return x-'0';
  }
  if(x=='A')return 1;
  return 10;
}

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

int main() {
  string N;
  cin >> N;
  if(N.at(0) == N.at(1) && N.at(1) == N.at(2)){
    cout << "Yes" << endl;
  }else if(N.at(1) == N.at(2) && N.at(2) == N.at(3)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a, b(N);
  rep(i,0,N-1) cin >> b[i];

  for (int i = 0; i < N; ++i) {
    for (int j = N - i - 1; 0 <= j; --j) {
      if (b.at(j) == j + 1) {
        a.push_back(b.at(j));
        b.erase(b.begin() + j);
        break;
      }
    }
  }

  if (0 < b.size())
  {
    cout << -1 << endl;
    return 0;
  }

  for (auto it = a.rbegin(); it != a.rend(); ++it)
    cout << *it << endl;

  return 0;
}


Measured memory_bytes: 3632
n, k = list(map(int, input().split()))
d = list(map(int, input().split()))
if 0 in d:
    zero = True
else:
    zero = False

n_ok = {0} | set([0,1,2,3,4,5,6,7,8,9]) - set(d)
n_oks = sorted(n_ok)
#print(n_oks)

def lowest():
    for i in n_oks:
        for j in n_oks:
            for k in n_oks:
                for l in n_oks:
                    for m in n_oks:
                        money = 10000*i +1000*j + 100*k + 10*l + m
                        if money >= n:
                            if zero:
                                if 0 in [i,j,k,l,m] and i != 0:
                                    continue
                                elif 0 in [j,k,l,m] and j != 0:
                                    continue
                                if 0 in [k,l,m] and k != 0:
                                    continue
                                if 0 in [l,m] and l != 0:
                                    continue
                            print(money)
                            return

lowest()

Measured memory_bytes: 3064
import itertools as it
import collections as col

import sys
sys.setrecursionlimit(10000)

def main():
    x = [int(x) for x in input().split()]
    x = sorted(x)
    
    s = 0
    for i in range(1, len(x)):
        s += x[i] - x[i-1]
    
    print(s)

if __name__ == '__main__':
    main()

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

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; i <= R; i++)
#define int long long

const int N = 2e5 + 2, inf = 1e18;

int n, k, dp[N], a[N];

int go(int rem) {
    int &ans = dp[rem];
    if (~ans)
        return ans;
    ans = 0;

    // Each player tries to find atleast one losing state for his opponent

    FOR(i,1,n) if (rem - a[i] >= 0) {
        int get = go(rem - a[i]);
        ans |= get == 0;
    }
    return ans;
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> k;

    FOR(i,1,n) {
        cin >> a[i];
    }    

    memset(dp, -1, sizeof(dp));

    cout << (go(k) ? "First" : "Second") << '\n';
}


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

int main(){
    int N;  cin >> N;
    vector<double> p(N+1);
    for(int i=1; i<=N; i++) cin >> p[i];

    vector<vector<double>> dp;
    dp = vector<vector<double>>(N+1, vector<double>(N+1, 0));
    dp[0][0] = 1;
    for(int i=1; i<=N; i++){
        dp[i][0] = 1;
        for(int j=1; j<=i; j++){
            dp[i][0]*= (1 - p[j]);
        }
    }

    for(int i=1; i<=N; i++){
        for(int j=1; j<=N; j++){
            dp[i][j] = (1-p[i])*dp[i-1][j] + p[i]*dp[i-1][j-1];
        }
    }
    
    double ans = 0;
    for(int i=N/2+1; i<=N; i++){
        ans += dp[N][i];
    }
    cout << setprecision(12) << ans << endl;
}

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

typedef long long ll;

string s,t;
int c;

int main(){
  cin>>s;
  if(s[0]!='A'){
    cout<<"WA"<<endl;return 0;
  }
  
  for(int i=1;i<s.size();i++){

    if(s[i]=='C'){
      if(i>=2&&i<=s.size()-2){
        c++;
        if(c==2){
          cout<<"WA"<<endl;return 0;
        }else{
          continue;
        }
      }
    }
    
    else if(s[i]>='a'&&s[i]<='z'){
      continue;
    }

    else{
      cout<<"WA"<<endl;return 0;
    }
    
  }
  if(c==0)cout<<"WA"<<endl;
  else cout<<"AC"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll a, b, c;
  cin >> a >> b >> c;

  ll ans = 0;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
    ans = 0;
  } else {
    // evenが一個もない
    ll m = max({a, b, c});
    ll l = m / 2;
    ll r = m - l;

    vector<ll> arr = {a, b, c};
    sort(all(arr));

    l *= arr[0] * arr[1];
    r *= arr[0] * arr[1];

    ans = abs(l - r);
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int prime[100005] = {1, 1};
int sum[100005];

int main()
{
    int q;
    int l, r;

    for (int i = 2; i * i <= 100000; i++) {
        for (int j = i + i; j <= 100000; j += i) {
            prime[j] = 1;
        }
    }

    for (int i = 3; i <= 100000; i++) {
        sum[i] = sum[i - 1] + (prime[i] == 0 && prime[(i + 1) / 2] == 0 ? 1 : 0);
    }

    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> l >> r;

        cout << sum[r] - sum[l - 1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1408
r,g,b,n = map(int,input().split())

i,j,k = 0,0,0

ans = 0



while True:
	temp = i * r
	j,k = 0,0
	if(temp > n):
		break
	while True:
		temp = i * r + j * g
		k = 0
		if(temp > n):
			break
		if((n - temp)%b == 0):
			ans+= 1
		j+= 1
	i += 1

print(ans)

Measured memory_bytes: 40556
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

	int n, k;
	cin >> n >> k;

	vector<int> a(n);
	rep(i, n) cin >> a[i];

	rep(i, n - k){
		if(a[i+k] > a[i]){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 3992
#include<iostream>

using namespace std;

int main(void){

  int n,p[3][200],ans[200];
  bool fg[3][200];

  
  
  while(cin >> n){

      for(int i=0;i<n;i++){
	ans[i]=0;
	for(int j=0;j<3;j++){
	  cin >> p[j][i];
	  fg[j][i]=false;
	}
      }

    
    for(int i=0;i<3;i++){
      for(int j=0;j<n;j++){
	for(int k=0;k<n;k++){
	  if(j!=k && p[i][j]==p[i][k]){
	    fg[i][j]=fg[i][k]=true;
	    break;
	  }
	}
      }
    }
    
    for(int i=0;i<3;i++){
      for(int j=0;j<n;j++){
	if(fg[i][j]==false){
	  ans[j]+=p[i][j];
	}
      }
    }


    for(int i=0;i<n;i++){
      cout << ans[i] << endl;
    }
  }

  return 0;
}

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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int price = 0;
  
  if (n <= k)
    price = n*x;
  else
    price = k*x + (n-k)*y;
  cout << price << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m,x,y,s,max;

  cin >>n >>m;
  max = m;
  for(int i=0;i<n;++i){
    cin >>x >>y;
    s = m-y+x;
    if(s<0) {
      cout << "0\n";
      return 0;
    }
    m = s;
    if(s>max) max = s;
  }
  cout << max << endl;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
typedef long long ll;
typedef unsigned long long ull;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = (a); i < (ll) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define MOD 1000000007

int main() {
    FIN;
    int a, b, c;
    cin >> a  >> b >> c;
    if(a+b+c>=22) cout << "bust \n";
    else cout << "win \n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
int main() {
  ll a=0,n,b=1,ans=0;
  string word;
  bool flag;
  cin>>n;
  if(n%2!=0)n=0;
  else {n=(ll)(n/10);n*=5;}
  while(n!=0){
    ans+=(ll)(n/5);ll(n/=5);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : AOJ.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>

using namespace std;

int w,h,n;
int d[100001]={};

int main() {
	int H,R;
	cin>>H>>R;
	if(R+H>0){
		cout<<"1"<<endl;
	}else if(R+H==0){
		cout<<"0"<<endl;
	}else {
	cout<<"-1"<<endl;
}
	return 0;
}

Measured memory_bytes: 3120
#include<iostream>
#include<vector>

int main(){

	int n, m;

	while (std::cin >> n >> m){

		if (n == 0 && m == 0)break;

		int now = 0;
		std::vector<int>v(n, 0);

		for (int i = 0; i < n; i++)std::cin >> v[i];

		bool flg = true;
		int ans;
		for (int i = 1, a; i <= m; i++){
			std::cin >> a;
			now += a;

			if (now < n - 1)now += v[now];

			if (now >= n - 1){
				if (flg){
					ans = i;
					flg = false;
				}
			}
		}
		std::cout << ans << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
using namespace std;
 
int main(){
    int n,m,l;
    cin >> n >> m >> l;
     
    long long a[100][100], b[100][100];
    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++){
        for(int j=0; j<l; j++){
            cin >> b[i][j];
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            long long elem=0;
            for(int k=0; k<m; k++){
                elem += a[i][k]*b[k][j];
            }
            if(j==0) cout << elem;
            else cout << " " << elem;
        }
        cout << endl;
    }
    return 0;
}



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

using namespace std;

int d[10];
int main() {
    memset(d, -1, sizeof d);
    int n,m;
    cin >> n >> m;

    for (int i = 0; i < m; ++i) {
        int s,c;
        cin >> s >> c;
        s--;
        if(d[s] != -1 and d[s] != c) return puts("-1"), 0;
        d[s] = c;
    }
    
    for (int i = 0; i < 1000000; ++i) {
        string x = to_string(i);
        if(x.size() != n) continue;
        bool flag = 1;
        for (int j = 0; j < (int)x.size(); ++j) 
            flag &= (x[j] == d[j] + '0' or d[j] == -1);
        if(flag) return cout << i << "\n", 0;
    }
    cout << -1 << "\n";
    return 0;
}


Measured memory_bytes: 256
/*
javac Main.java && java Main
*/

import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
	public static void main(String[] args) { new Main(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);

	char[] s;
	int[] f;
	
	Main() {
		s = in.next().toCharArray();
		f = new int[2];
		for (char c : s) f[c - 'A']++;
		if (f[0] == 0 || f[0] == 3)	out.println("No");
		else out.println("Yes");
		out.close();
	}

	
	
	int abs(int x) { if (x < 0) return -x; return x; }
	long abs(long x) { if (x < 0) return -x; return x; }
	int max(int x, int y) { if (x < y) return y; return x; }
	int min(int x, int y) { if (x > y) return y; return x; }
	long max(long x, long y) { if (x < y) return y; return x; }
	long min(long x, long y) { if (x > y) return y; return x; }
	int gcd(int x, int y) { while (y > 0) { x = y^(x^(y = x)); y %= x; } return x; }
	long gcd(long x, long y) { while (y > 0) { x = y^(x^(y = x)); y %= x; } return x; }
	long lcm(int x, int y) { return ((long) x) * (y / gcd(x, y)); }
	long lcm(long x, long y) { return x * (y / gcd(x, y)); }

	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

vector<ll> factorize(ll x){
    vector<ll> res;
    for(ll i=1;i*i<=x;i++){
        if(x%i==0){
            if(i!=1)res.push_back(i);
            if(x/i!=i) res.push_back(x/i);
        }
    }
    return res;
}

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

  ll N;
  cin>>N;

  vector<ll> num=factorize(N);
  vector<ll> v=factorize(N-1);
  map<ll,int> mp;
  rep(i,v.size()) mp[v[i]]=1;
  mp[1]=1;
  ll ans=v.size();

  for(int i=0;i<num.size();i++){
      ll val=num[i];
      ll M=N;
      while(M%val==0) M/=val;
      if(M%val==1&&mp.count(val)==false){
          ans++;
      }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

int main(void) {
	int n;
	string N,S;
	cin >> N;
	n = stoi(N);
	
	for (int i = 0; i < log10(n); i++) {
		if(stoi(N.substr(i,1))==1)S +="9";
		else S += "1";
	}
	cout << S;
}

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

int abs(int x, int y){
  if(x >= y)
    return x - y;
  else
    return y - x;
}

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  cout << (abs(x, a) < abs(x, b) ? "A" : "B") << endl;
}


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

int main(){
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    rep(i,n){
        ll x , y;
        cin >> x >> y;
        if(x*x + y*y <= d*d) ans++;
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
	int a[3][3];
	for(int i=0;i<3;++i)
		for(int j=0;j<3;++j)
			cin>>a[i][j];
	int n;
	cin>>n;
	while(n--){
		int x;
		cin>>x;
		for(int i=0;i<3;++i)
			for(int j=0;j<3;++j)
				if(a[i][j]==x){
					a[i][j]=0;
					bool flag=false;
					for(int k=0;k<3;++k)
						if(a[k][j]!=0)
							flag=true;
					if(flag==false){
						cout<<"Yes"<<endl;
						return 0;
					}
					flag=false;
					for(int k=0;k<3;++k)
						if(a[i][k]!=0)
							flag=true;
					if(flag==false){
						cout<<"Yes"<<endl;
						return 0;
					}
					if(i==j){
						flag=false;
						for(int k=0;k<3;++k)
							if(a[k][k]!=0)
								flag=true;
						if(flag==false){
							cout<<"Yes"<<endl;
							return 0;
						}
					}
					if(2-i==j){
						flag=false;
						for(int k=0;k<3;++k)
							if(a[2-k][k]!=0)
								flag=true;
						if(flag==false){
							cout<<"Yes"<<endl;
							return 0;
						}
					}
				}
	}
	cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>>A(n,vector<int>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> A.at(i).at(j);
        }
    }
    vector<int>b(m);
    for(int i=0;i<m;i++){
        cin >> b.at(i);
    }
    vector<int>c(n,0);
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            c.at(i)+= A.at(i).at(j) * b.at(j);
        }
        cout << c.at(i) << endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3208
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cum_a = [0]
for i in range(n):
    cum_a.append(cum_a[i] + a[i])

cum_b = [0]
for i in range(m):
    cum_b.append(cum_b[i] + b[i])

ans = 0
val = m
for i in range(n + 1):
    if cum_a[i] > k:
        break

    while cum_b[val] > k - cum_a[i]:
        val -= 1

    ans = max(ans, i + val)

print(ans)


Measured memory_bytes: 47440
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  def shuffle(cnt:Int, w:String):String =
    if(cnt == 0) w else { val m = readInt;shuffle(cnt-1, (w drop m)+(w take m)) }

  def exec(w:String):Unit =
    if(w=="-") return else { val n = readInt;println(shuffle(n,w));exec(readLine) }

  exec(readLine)
}

Measured memory_bytes: 43964
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  ll ans=0;
  ans+=min(a,k);
  k-=a;
  if(k>0){
    k-=b;
  }
  if(k>0){
    ans-=k;
  }

  prt(ans);

}


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

const int inf = 1e9;
const ll linf = 1e18;

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

    int h, w; cin >> h >> w;
    auto m = vector<vector<int>>(10, vector<int>(10));
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            cin >> m[i][j];
        }
    }
    map<int, int> a;
    for (int i = 0; i < h * w; i++) {
        int x; cin >> x;
        if (x != -1) a[x]++;
    }

    for (int k = 0; k <= 9; k++) {
        for (int i = 0; i <= 9; i++) {
            for (int j = 0; j <= 9; j++) {
                m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
            }
        }
    }

    int ans = 0;
    for (auto &e: a) {
        ans += m[e.first][1] * e.second;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int N = 200'010, M = 1e9 + 7;
vector<int> g[N];
int n, sz[N];
ll dp[N];

ll qpow(ll a, ll p) {
    ll res = 1;
    while (p) {
        if (p & 1) res = res * a % M;
        a = a * a % M, p >>= 1;
    }
    return res;
}

void dfs1(int v, int p = -1) {
    sz[v] = 1;
    for (auto to : g[v]) {
        if (to == p) continue;
        dfs1(to, v);
        sz[v] += sz[to];
    }
    dp[1] = dp[1] * sz[v] % M;
}

void dfs2(int v, int p = -1) {
    int tmp;
    for (auto to : g[v]) {
        if (to == p) continue;
        dp[to] = dp[v] * ((n - sz[to]) * qpow(sz[to], M - 2) % M) % M;
        tmp = sz[to], sz[to] = n, sz[v] = n - tmp;
        dfs2(to, v);
        sz[to] = tmp, sz[v] = n;
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v), g[v].push_back(u);
    }
    dp[1] = 1;
    dfs1(1);
    dfs2(1);
    ll f = 1;
    for (int i = 1; i <= n; i++) f = f * i % M;
    for (int i = 1; i <= n; i++) printf("%lld\n", f * qpow(dp[i], M - 2) % M);
}


Measured memory_bytes: 16244
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  vector<pair<double,int> > vv(18);
  REP(i,3){
    vector<pair<double,int> > v(8);
    REP(j,8)
      cin>>v[j].s>>v[j].f;
    sort(v.begin(),v.end());
    REP(j,6) vv[i*6 + j] = v[j+2];
    printf("%d %.2f\n",v[0].s,v[0].f);
    printf("%d %.2f\n",v[1].s,v[1].f);
  }
  sort(vv.begin(),vv.end());
  printf("%d %.2f\n",vv[0].s,vv[0].f);
  printf("%d %.2f\n",vv[1].s,vv[1].f);
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    if(fabs(x-a)>fabs(x-b))
    cout<<"B"<<endl;
    else
    cout<<"A"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
int a[3];
int i,j,t;

for(i=0;i<3;i++)
scanf("%d",&a[i]);

for(i=0;i<2;i++)
for(j=i+1;j<3;j++)
if(a[i]<a[j])
{
  
t=a[i];
a[i]=a[j];
a[j]=t;
}

printf("%d\n",a[0]-a[2]);
return 0;
}


Measured memory_bytes: 128
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);

    int ans = 100;

    foreach (ai ; a) {
        int cnt;
        
        while (ai % 2 == 0) {
            ai /= 2;
            cnt++;
        }

        ans = min(ans, cnt);
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		String s = kb.next();
		String t = kb.next();
		String u = "";
		for (int i = 0; i < n; i++) {
			u += s.charAt(i);
			u += t.charAt(i);
		}
		System.out.println(u);
		kb.close();

	}

}


Measured memory_bytes: 23764
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;

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

  ll n,l;
  std::cin>>n>>l;

  struct Node;
  using node_ptr=std::shared_ptr<Node>;

  struct Node{
    node_ptr zero,one;
    ll depth;
    Node(ll i):zero(),one(),depth(i){}
  };

  node_ptr root=std::make_shared<Node>(0);

  rep(i,0,n){
    std::string s;
    std::cin>>s;
    ll m=s.size();
    node_ptr now(root);
    rep(j,0,m){
      if(s[j]=='0'){
        if(!now->zero)now->zero=std::make_shared<Node>(now->depth+1);
        now=now->zero;
      }else{
        if(!now->one)now->one=std::make_shared<Node>(now->depth+1);
        now=now->one;
      }
    }
  }

  ll ans=0;

  auto f=[&](auto f,node_ptr now)->void{
    if(((bool)now->zero)^((bool)now->one)){
      ll temp=l-now->depth;
      ll grundy=1;
      while(!(temp&1)){
        grundy<<=1;
        temp>>=1;
      }
      ans^=grundy;
    }
    if(now->zero)f(f,now->zero);
    if(now->one)f(f,now->one);
  };

  f(f,root);

  if(ans==0)std::cout<<"Bob\n";
  else std::cout<<"Alice\n";

  return 0;
}

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

public class Main {	
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int k = ni();
		int s = ni();
		for(int i = 0; i < k; i++) {
			System.out.print(s + " ");
		}
		for(int i = k; i <n; i++) {
			if(s < 1000_000_000) {
				System.out.print((s + 1) + " ");
			} else {
				System.out.print(1 + " ");
			}			
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 44412
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scan = new Scanner(System.in);
        
        int number = scan.nextInt();
        int bstart = scan.nextInt();
        int ball = 0;
        
        int count;
        int ans = 0;
        for(count = 0 ; count < number ; count++){
            
            ball = scan.nextInt();
            
            if(ball <= bstart / 2){
                ans += ball * 2;
            }else{
                ans += (bstart - ball) * 2;
            }
        }
 
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 22868
#include<iostream>
#include<cmath>
#include<cstdio> 
using namespace std;
int n,k,sum,maxn=0,summ[100010];
double ans=0;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		sum=i;
		summ[i]=0;
		while(sum<k){
			sum*=2;
			summ[i]++;
		}
		if(summ[i]>maxn)
			maxn=summ[i];
	}
	for(int i=1;i<=n;i++){
		summ[i]=pow(2,maxn-summ[i]);
		ans+=summ[i];
	}
	printf("%.12lf\n",ans/(pow(2,maxn)*n));
	return 0;
}

Measured memory_bytes: 640
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int n,x,ans=0;
    cin >> n >> x;

    int a[102];
    for(int i=0;i<n;i++) cin >> a[i];

    sort(a,a+n);

    for(int i=0;i<n;i++){
        x-=a[i];
        if((x>=0 && i!=n-1) || (x==0 && i==n-1)) ans++;
        else break;
    }

    //cout << (flag ? "Yes" : "No") << endl;
    cout << ans << endl;
    //printf("%.10f",ans_d);cout<<endl;
}


Measured memory_bytes: 256
h,w,i,j,x,y;
char m[110][110];
main()
{
  while(1)
    {
      scanf("%d%d",&w,&h);
      if(w==0&&h==0)
	exit(0);
      for(i=0;i<w;i++)
	  scanf("%s",m[i]);
      //  printf("loop-end\n");
      x=-1;
      k(0,0,w*h);
      if(x<0)
	puts("LOOP");
      else
	printf("%d %d\n",x,y);
    }
}

k(a,b,c)
{
  //  printf("new k a=%d b=%d c=%d\n",a,b,c);
  if(c>0)
    {
      if(m[a][b]=='.')
	{
	  //printf("OK\n");
	  x=b;
	  y=a;
	}
      else
	{
	  if(m[a][b]=='>')
	    {	    
	      k(a,b+1,c-1);
	    }
	  if(m[a][b]=='<')
	    k(a,b-1,c-1);
	  if(m[a][b]=='v')
	    k(a+1,b,c-1);
	  if(m[a][b]=='^')
	    k(a-1,b,c-1);
	}
    }
}

Measured memory_bytes: 0