akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  //freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int Q;
  cin >> Q;
  const int L = 30;
  vector<ll> pw(L + 1);
  pw[0] = 1;
  for(int i = 1; i <= L; ++i) pw[i] = pw[i - 1] * 3;
  auto ze1 = [&](ll x) {
    if (x % 3 == 2) return x - 1;
    return x - 2;
  };
  while (Q--) {
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    --x1; --y1; --x2; --y2;
    if (x1 > x2) {
      x1 = pw[L] - x1 - 1;
      x2 = pw[L] - x2 - 1;
    }
    if (y1 > y2) {
      y1 = pw[L] - y1 - 1;
      y2 = pw[L] - y2 - 1;
    }
    ll ans = abs(x1 - x2) + abs(y1 - y2);
    for (int i = L - 1; i >= 0; --i) {
      if (x1 / pw[i] == x2 / pw[i] && (x1 / pw[i]) % 3 == 1 && y1 < ze1(y2 / pw[i]) * pw[i]) {
        ll v = x1 / pw[i];
        ans += 2 * min((v + 1) * pw[i] - x2, x1 - v * pw[i] + 1);
        break;
      }
      if (y1 / pw[i] == y2 / pw[i] && (y1 / pw[i]) % 3 == 1 && x1 < ze1(x2 / pw[i]) * pw[i]) {
        ll v = y1 / pw[i];
        ans += 2 * min((v + 1) * pw[i] - y2, y1 - v * pw[i] + 1);
        break;
      }
    }
    cout << ans << '\n';
  }

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

#define ll long long
#define pb push_back
#define mkp make_pair

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
        cout.tie(0);
	ll n,W;
	cin>>n>>W;
	ll w[n],v[n];
	for(ll i=0;i<n;++i)
		cin>>w[i]>>v[i];
	ll dp[n+1][W+1];
	for(ll i=0;i<=n;++i)
	{
		for(ll j=0;j<=W;++j)
		{
			if(i==0 or j==0)
				dp[i][j]=0;
			else
			{
				dp[i][j]=dp[i-1][j];
				if(j>=w[i-1])
					dp[i][j]= max(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);
			}
		}
	}
	cout<<dp[n][W];
}


Measured memory_bytes: 82480
// #include<algorithm>
// #include<iostream>
// #include<string.h>
// #include<stdio.h>
// using namespace std;
// inline void FR(long long &num)
// {
// 	//long long num=0,f=1;
// 	num=0;
// 	long long f;
// 	char ch=getchar();
// 	while(ch<'0'||ch>'9'){if(ch=='-')f*=-1;ch=getchar();}
// 	while(ch>='0'&&ch<='9'){num=num*10+ch-'0';ch=getchar();}
// 	num*=f;
// 	return ;
// }
// inline void FP(long long x)
// {
// 	if(x<0){putchar('-');x*=-1;}
// 	if(x==0){putchar('0');return;}
// 	long long e;
// 	for(e=1;e<=x/10;e*=10);
// 	for(;e;e/=10)putchar(x/e%10+'0');
// 	return;
// }
// long long A,B,_A,_B,lf,rt,ans,ll,rr;
// int da[110],db[110],LA,LB,L,S;
// int main()
// {
//     FR(A);
// 	FR(B);
// 	_A=A;
// 	_B=B;
//     while(A)
// 	{
// 		LA++;
// 		da[LA]=A&1;
// 		A>>=1;
// 	}
//     while(B)
// 	{
// 		LB++;
// 		db[LB]=B&1;
// 		B>>=1;
// 	}
//     for(register int i=(LA>LB?LA:LB);i;i--)
// 	{
//         if(da[i]!=db[i])
// 		{
// 			L=i;
// 			break;
// 		}
//         _A-=1ll*(da[i]<<(i-1));
//         _B-=1ll*(db[i]<<(i-1));
//     }
//     for(register int i=L-1;i;i--)
// 		if(db[i])
// 		{
// 			S=i;
// 			break;
// 		}
//     lf=_A;
// 	rt=(1ll<<(L-1))+(1ll<<S)-1;
//     ll=(1ll<<(L-1))+_A;
// 	rr=(1ll<<L)-1;
//     FP(ll>rt?(rt+rr-lf-ll+2):(rr-lf+1));
//     putchar('\n');
// }
#include<cstdio>//for complete
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
void read(long long &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=110;
long long a,b,x,y,l,r,ans,ll,rr;
int aa[maxn],bb[maxn],lena,lenb,len,k;
int main(){
    read(a),read(b);x=a,y=b;
    while(a)aa[++lena]=a&1,a>>=1;
    while(b)bb[++lenb]=b&1,b>>=1;
    for(rg int i=max(lena,lenb);i;i--){
        if(aa[i]!=bb[i]){len=i;break;}
        x-=1ll*aa[i]<<(i-1);
        y-=1ll*bb[i]<<(i-1);
    }
    for(rg int i=len-1;i;i--)if(bb[i]){k=i;break;}
    l=x,r=(1ll<<(len-1))+(1ll<<k)-1;
    ll=(1ll<<(len-1))+x,rr=(1ll<<len)-1;
    if(ll>r)ans=r-l+1+rr-ll+1;
    else ans=rr-l+1;
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  int ans = 0;
  string s;

  cin >> N;

  vector<int> p(N);
  vector<int> p2(N);
  for(int i = 0; i < N; i++){
    cin >> p[i];
    p2[i] = p[i];
  }
  sort(p.begin(), p.end());
  // cout << "------" << endl;
  // for(int i = 0; i < N; i++){
  //   cout << p[i] << ",";
  // }
  //   cout << endl;;
  //   cout << "------" << endl;
  // for(int i = 0; i < N; i++){
  //   cout << p2[i] << ",";
  // }
  //   cout << endl;;
  //   cout << "------" << endl;
  for(int i = 0; i < N; i++){
    if(p[i] != p2[i]){
      ans++;
    }
  }

  if(ans == 2 || ans == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

function upperBound(ary,v,l,r){--l;for(var c;1<r-l;)ary[c=l+r>>1]<=v?l=c:r=c;return r;}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var a = next(1), l = a.length, inf = 1e9;
  var map = [l], set = Array(26), cnt;
  for(var i = l; i > 25;){
    set.fill(0), cnt = 0;
    while(i--){
      var t = a[i].charCodeAt()-97;
      if(set[t])continue;
      if(cnt === 25){
        map.push(i);
        break;
      }
      cnt++;
      set[t] = 1;
    }
  }
  var b = xArray("[]",26);
  for(var i = 0; i < l; i++)b[a[i].charCodeAt()-97].push(i);
  for(var i = 0; i < 26; i++)b[i].push(inf);
  var ans = "", x = -1;
  for(var i = map.length; i--;){
    var v = map[i];
    for(var j = 0; j < 26; j++){
      var t = upperBound(b[j],x,0,b[j].length);
      t = b[j][t];
      if(v <= t){
        ans += String.fromCharCode(97+j);
        x = t;
        break;
      }
    }
  }
  return ans;
}

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


int main(){
int n;
cin>>n;
int a[n],b[n];
for(int i=0;i<n;i++){
cin>>a[i];
b[i]=a[i];}
sort(a,a+n);
int cnt=0;
for(int i=0;i<n;i++){
if(a[i]!=b[i]) cnt++;}
if(cnt==2||cnt==0) cout<<"YES";
else cout<<"NO";



 return 0;
}

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

int main(){
    /*席数100000
    団体数N i組目の団体はlからrまでの
    連続した席に座る*/
    int N;
    cin >> N;
    int sum = 0;
    for(int i = 0;i < N; i++){
        int l, r;
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;
}

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

#define ll long long
using namespace std;

string s, t;
int main() {
	cin >> s;
	cin >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<int>());

	int k = min(s.size(), t.size());
	int c = 0;

	for (int i = 0; i < k; i++) {
		if (s[i] - 'a' < t[i] - 'a') {
			cout << "Yes" << endl;
			return 0;
		}
		if (s[i] - 'a' == t[i] - 'a') {
			c++;
		}
	}
	if ((c == s.size()) && (s.size() < t.size())) {
		cout << "Yes" << endl;
		return 0;

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

}


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

#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

#define Debug(x) cout<<(#x)<<" >> "<<(x)<<endl

using namespace std;

ll fastpow(ll angka,ll pangkat,ll MOD){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka)%MOD;
		angka=(angka*angka)%MOD;
		pangkat=pangkat>>1;
	}
	return res;
}

ll fastpow(ll angka,ll pangkat){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka);
		angka=(angka*angka);
		pangkat=pangkat>>1;
	}
	return res;
}

ll gcd(ll angka1,ll angka2){
	while(angka2){
		swap(angka1,angka2);
		angka2=angka2%angka1;
	}
	return angka1;
}

ll lcm(ll angka1,ll angka2){
	return (angka1/gcd(angka1,angka2))*angka2;
}



void solve(){
	int n;
	string s;
	
	cin>>n;
	cin>>s;
	
	int l,r;
	l=0;
	r=n-1;
	
	int ct=0;
	while(l<=r){
		if(s[l]=='W' && s[r]=='R'){
			ct++;
			swap(s[l],s[r]);
		}
		while(l<n && s[l]!='W') l++;
		while(r>=0 && s[r]!='R') r--;
	}
	cout<<ct<<endl;
}

int main(){
	
	fastio();
	
	int t=1;
//	cin>>t;
	
	for(int tt=0;tt<t;tt++){
//		cout<<"Case #"<<tt+1<<": ";solve();
//		if(solve()) cout<<""<<endl;
		solve();
	}
	
	return 0;
}




Measured memory_bytes: 3744
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
    
        int n = Integer.parseInt(br.readLine());
        String[] asaikoro = br.readLine().split(" ");
        int[][] as = new int[n][6];
        for (int i = 0; i < 6; i++)
        {
        	as[0][i] = Integer.parseInt(asaikoro[i]);
        }
        int count = 0;
        int[] bs = new int[6];
        
        for (int j = 0; j < n; j++)
        {
        	if (j != 0)
        	{
        		String[] bsaikoro = br.readLine().split(" ");
            	int a =  0;
            	for (int i = 0; i < 6; i++)
            	{
            		bs[i] = Integer.parseInt(bsaikoro[i]);
            	}
            	
            	for (int k = 0; k < j; k++)
            	{
            		if ((as[k][0] == bs[2] || as[k][0] == bs[3]) && (as[k][5] == bs[2] || as[k][5] == bs[3]))
                	{
                		a = bs[1];
            			bs[1] = bs[2];
            			bs[2] = bs[4];
            			bs[4] = bs[3];
            			bs[3] = a;
                	}
                	
                	for (int i = 0; i < 3; i++) //????????¢????????¢????????£???????????????
            		{
            			if (as[k][0] ==bs[0] && as[k][5] ==bs[5])
            				break;
            			a = bs[0];
            			bs[0] = bs[1];
            			bs[1] = bs[5];
            			bs[5] = bs[4];
            			bs[4] = a;
            		}
                	
                	for (int i = 0; i < 3; i++) //?¨??????¢????¨???¢????????£???????????????
            		{
            			if (as[k][1] ==bs[1] && as[k][4] ==bs[4])
            				break;
            			a = bs[1];
            			bs[1] = bs[2];
            			bs[2] = bs[4];
            			bs[4] = bs[3];
            			bs[3] = a;
            		}
                	if (as[k][0] == bs[0] && as[k][1] == bs[1] && as[k][2] == bs[2] && as[k][3] == bs[3] && as[k][4] == bs[4] && as[k][5] == bs[5])
                		count++;
            	}
            	for (int i = 0; i < 6; i++)
            	{
            		as[j][i] = bs[i];
            	}
        	}
        }
        if (count == 0)
        	System.out.println("Yes");
        else if (count >= 1)
        	System.out.println("No");
	}
}

Measured memory_bytes: 24624
n = int(input())
w_in = input().split()
w = []
for i in range(n):
    w.append(int(w_in[i]))


def list_sum(list):
    result = 0
    for i in range(len(list)):
        result = result+list[i]
    return result


def zettaichi(n):
    if n > 0:
        return n
    else:
        return -1 * n


def sub_devided_at_t(list,t):
    left = list[0:t+1]
    right = list[t+1:]
    sum_left = list_sum(left)
    sum_right = list_sum(right)
    return zettaichi(sum_left - sum_right)


min_result = 100000
for i in range(n):
    if sub_devided_at_t(w,i) < min_result:
        min_result = sub_devided_at_t(w,i)

print(min_result)



Measured memory_bytes: 3064
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(i;0..n){t[i]=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t)v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  a = 0 ~ a ~ 0;
  auto s = 0;
  foreach (i; 0..n+1) s += (a[i+1]-a[i]).abs;

  foreach (i; 0..n)
    writeln(s-(a[i+1]-a[i]).abs-(a[i+2]-a[i+1]).abs+(a[i+2]-a[i]).abs);
}


Measured memory_bytes: 4344
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTA(a,n) sort(a,a+n)
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    ll n;
    cin >> n;
    ll t[1100],a[1100];
    REP(i,0,n) cin >> t[i] >> a[i];
    ll anst=0;
    ll ansa=0;
    
    //処理
    REP(i,0,n){
        if(anst<=t[i] && ansa<=a[i]){
            anst=t[i];
            ansa=a[i];
        }else{
            ll tmp = max(RUP(anst,t[i]),RUP(ansa,a[i]));
            anst=tmp*t[i];
            ansa=tmp*a[i];
        }
    }
    
    //出力
    cout << anst+ansa << ENT;
    return 0;
}

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


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

int main(){
  int N;
  cin >> N;
  int a[N];
  rep(i,N){cin >> a[i];a[i]--;}
  int ans=0;
  rep(i,N)if(i==a[a[i]]) ans++;
  ans/=2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nk = br.readLine().split(" ");
        
        int N = Integer.parseInt(nk[0]);
        int K = Integer.parseInt(nk[1]);
        
        String[] input = br.readLine().split(" ");
        int[] h = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(input[i]);
        }
        
        System.out.println(getMinCost(h, K));
    }

    private static int getMinCost(int[] h, int k) {
        int[] cost = new int[h.length];
        
        for (int i = 1; i < h.length; i++) {
            cost[i] = Integer.MAX_VALUE;
            for(int j = k; j > 0; j--) {
                if(i-j < 0) continue;
                cost[i] = Math.min(cost[i], cost[i-j] + Math.abs(h[i] - h[i-j]));
            }
        }

        return cost[h.length-1];
    }
}

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

typedef long long ll;

int main () {
    ll N;
    string c;
    cin >> N;
    cin >> c;
    ll ans = 0;
    int left = 0;
    int right = N-1;

    while (left < right) {
        if (c[left] == 'W' && c[right] == 'R') {
            ans++;
            left++;
            right--;
        } else if (c[left] == 'R') {
            left++;
        } else if (c[right] == 'W') {
            right--;
        }
    }

    printf("%lld\n", ans);
}

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

int main(){
    long long N, M;
    cin >> N >> M;
    if(N == 1 && M == 1){
        cout << 1 << endl;
        return 0;
    }
    if(N == 1 || M == 1){
        cout << max(N, M) - 2 << endl;
        return 0;
    }
    cout << (N-2) * (M-2) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=20;
int n;
int main()
{
	cin>>n;
	vector<int> last(maxn,-1);
	int bound=0;
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		for(int j=0;j<maxn;j++)
			if(x&(1<<j))
			{
				bound=max(bound,last[j]);
				last[j]=i+1;
			}
		ans+=i-bound+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <map>
#define MAX 100001
typedef unsigned long long ull;
using namespace std;

int main(int argc, char *argv[])
{
    double res = 0;

    unsigned int N;
    double W;
    scanf("%d %lf", &N, &W);
    double *value = new double[N] {0};
    double *weight = new double[N]{0};

    map<double, int> vmap;
    for (unsigned int i = 0; i < N; i++)
    {
        scanf("%lf %lf", &value[i], &weight[i]);
        double t = value[i] / weight[i];
        vmap[t] = i;
    }

    map<double, int>::reverse_iterator itr = vmap.rbegin();
    for (; itr != vmap.rend(); itr++)
    {
        int index = itr->second;
        if (W - weight[index] >= 0)
        {
            res += value[index];
            W -= weight[index];
        }
        else
        {
            res += value[index] * (W / weight[index]);
            break;
        }
    }
    printf("%.8lf\n", res);
    return 0;
}



Measured memory_bytes: 10844
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            {for(ll i=0;i<size;i++) cout<<w[i]<<" ";cout<<"\n";}
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a,ll m=MOD){if(m==1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}

int main()
{
	fastIO
	ll h,a;
	cin>>h>>a;
	cout<<(h+a-1)/a;
	return 0;
}




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

int main() {
    int n;
    cin>>n;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    for (int i=n-2; i>=0; --i) {
        if (h[i]>h[i+1]) {
            if (h[i]-h[i+1]==1) {
                h[i]--;
            } else {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
n, k = map(int, input().split())
aa = [int(i) for i in input().split()]

asum = [0]
for i in range(n):
    asum.append(asum[i] + aa[i])

def getsum(l, r):
    return asum[r + 1] - asum[l]

active = []
for l in range(n):
    for r in range(l, n):
        active.append(getsum(l, r))

ans = 0
for i in range(40, -1, -1):
    ans *= 2
    bit = 1 << i
    cnt = 0
    nxt = []
    for num in active:
        if num & bit:
            cnt += 1
            nxt.append(num)
    if cnt >= k:
        ans += 1
        active = nxt

print(ans)

Measured memory_bytes: 67196
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        double r = scanner.nextDouble();

        PrintStream printf;
        printf = System.out.printf("%.5f %.5f\n", (r * r * Math.PI), (r * 2 * Math.PI));
    }
}




Measured memory_bytes: 28088
#include <iostream>
#include <vector>
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define pii pair <int, int>
#define print(x) for(auto it : x) cout << it << ' ';
#define endl "\n" // TODO: remove
#define int long long

const int N = (1e6) + 322;
const int inf = (int)(2e9);
const int mod = (int)(1e9) + 7; // check modulo

int a[N];

void solve() {
    int n, k; cin >> n >> k;
    int cntneg = 0;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        cntneg += (a[i] < 0);
    }
    sort(a + 1, a + n + 1, greater<int>());
    if (cntneg == n || n == k) {
        int ans = 1;
        if (k % 2 == 0) {
            reverse(a + 1, a + n + 1);
        }
        for(int i = 1; i <= k; ++i) {
            ans = (ans * a[i]) % mod;
        }
        cout << (ans + mod) % mod;
        return;
    }
    int pos = 0, neg = n + 1, lim = n;
    for(int i = 1; i < n; ++i) {
        if (a[i] >= 0 && a[i + 1] < 0) {
            lim = i;
            break;
        }
    }
    pos = min(k, lim);
    neg = n - (k - pos) + 1;
    if ((n - neg) % 2 == 0) {
        neg--;
        pos--;
    }
    while (pos >= 2 && neg - 2 > lim && a[pos] * a[pos - 1] < a[neg - 1] * a[neg - 2]) {
        pos -= 2;
        neg -= 2;
    }
    int ans = 1;
    for(int i = 1; i <= n; ++i) {
        if (i <= pos || i >= neg) {
            ans = (ans * a[i]) % mod;
        }
    }
    cout << (ans + mod) % mod;


}

signed main () {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    int test; cin >> test;
//    for(int t = 1; t <= test; ++t) {
        solve();
//    }
    return 0;
}


Measured memory_bytes: 4704
use proconio::{fastout, input, marker::Usize1};
#[fastout]
fn main() {
    input!(n: usize, m: usize, ab: [[Usize1; 2]; m]);

    let mut unionf = UnionFind::new(n);
    for v in ab {
        unionf.unite(v[0], v[1]);
    }

    println!("{}", (0..n).map(|x| unionf.size(x)).max().unwrap());
}

#[derive(Debug, Clone)]
enum Node {
    Root(usize),
    Child(usize),
}
#[derive(Clone, Debug)]
pub struct UnionFind {
    uf: Vec<Node>,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {
            uf: vec![Node::Root(1); n],
        }
    }

    pub fn root(&mut self, target: usize) -> usize {
        match self.uf[target] {
            Node::Root(_) => target,
            Node::Child(par) => {
                let root = self.root(par);
                self.uf[target] = Node::Child(self.root(par));
                root
            }
        }
    }
    pub fn unite(&mut self, x: usize, y: usize) -> bool {
        let rx = self.root(x);
        let ry = self.root(y);
        if rx == ry {
            return false;
        }
        let size_x = self.size(x);
        let size_y = self.size(y);

        let (i, j) = if size_x > size_y { (rx, ry) } else { (ry, rx) };
        self.uf[i] = Node::Root(size_x + size_y);
        self.uf[j] = Node::Child(i);

        true
    }
    pub fn is_same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }
    pub fn size(&mut self, x: usize) -> usize {
        let root = self.root(x);
        match self.uf[root] {
            Node::Root(size) => size,
            Node::Child(_) => 0,
        }
    }
}


Measured memory_bytes: 18700
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2
int N;
int a[100];
int main() {
	cin >> N;
	rep(i, 0, N) cin >> a[i];
 
	int ans = INF;
	rep(x, -100, 101) {
		int sm = 0;
		rep(i, 0, N) sm += abs(x - a[i])*abs(x - a[i]);
		ans = min(ans, sm);
	}
	cout << ans << endl;
}


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()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ans;
	if (k % 2)
		ans = b - a;
	else
		ans = a - b;
	if (ans > 1000000000000000000)
		cout << "Unfair" << endl;
	else
		cout << ans << endl;
}


Measured memory_bytes: 256
using System;

class Program
{
	static void Main()
	{
		string D1;
		while ((D1 = Console.ReadLine()) != "-1 -1 -1")
		{
			string[] D2 = D1.Split(' ');
			int m = int.Parse(D2[0]), f = int.Parse(D2[1]), r = int.Parse(D2[2]);
			if (m == -1 || f == -1 || m + f < 30)
			{
				Console.WriteLine("F");
			}
			else
			{
				if (m + f >= 80)
				{
					Console.WriteLine("A");
				}
				if (m + f >= 65 && m + f < 80)
				{
					Console.WriteLine("B");
				}
				if (m + f >= 50 && m + f < 65)
				{
					Console.WriteLine("C");
				}
				if (m + f >= 30 && m + f < 50)
				{
					if (r >= 50)
					{
						Console.WriteLine("C");
					}
					else
					{
						Console.WriteLine("D");
					}
				}
			}
		}
	}
}

Measured memory_bytes: 5296
#include<iostream>
using namespace std;
int main(){
	int N;
  	cin >> N;
  	int a = 0;
  	int b = 0;
  	int c = 0;
    int d = 0;
 	for(int i = 0; i < N; i++){
    string S;
    cin >> S;
      
      if(S == "AC"){
      a++;
      }
      else if(S == "WA"){
      b++;
      }
      else if(S == "TLE"){
      c++;
      }
      else if(S == "RE"){
      d++;
      }
     
    }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;

  }



Measured memory_bytes: 3628
N = int(input())
X, Y, H = zip(*[tuple(map(int, input().split(" "))) for _ in range(N)])

for i in range(N):
	if H[i] <= 0:
		continue
	std = i
	break
# print(X[std], Y[std])
for cy in range(101):
	for cx in range(101):
		ch = H[std] + abs(cx-X[std]) + abs(cy-Y[std])
		flag = True
		for i in range(N):
			if max(0, ch - abs(cx-X[i]) - abs(cy-Y[i])) != H[i]:
				flag = False
				# break
			# print(ch, cx, cy, X[i], Y[i], ch - abs(cx-X[i]) - abs(cy-Y[i]), H[i])
		if flag:
			print(cx, cy, ch)
			exit()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.matches("^(?=.*a)(?=.*b)(?=.*c).*")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    string x; cin >> x;

    stack<char> st;
    char t1, t2;
    for(int i=0; i<x.size(); i++){
        if(st.size() == 0){
            st.push(x[i]);
            continue;
        }

        t1 = st.top();
        t2 = x[i];
        if(t1 == 'S' && t2 == 'T'){
            st.pop();
        }
        else{
            st.push(t2);
        }
    }

    cout << st.size();

    return 0;
}

Measured memory_bytes: 644
#include<stdio.h>
#include<iostream>
#include<string>
#include<memory>
#include<cmath>
#include<algorithm>
#include<vector>
#include<unordered_map>
double min_double(double a,double  b){
    if(a<b) return a;
    else return b;
}
void swap(int *x,int *y){
    int tmp;
    tmp=*x;
    *x=*y;  
    *y=tmp;
}
int gcd(int a,int b){
    if(a<b) swap(&a,&b);
    if(b<1) return -1;

    if(a%b==0) return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a * b / gcd(a,b);
}

int main(){
    int N;
    std::cin>>N;
    std::vector<int> B(N);
    for(int i=0;i<N-1;i++) std::cin>>B[i];
    long ans=B[0]+B[N-2];

    for(int i=0;i<N-2;i++) ans+=std::min(B[i],B[i+1]);
    std::cout<<ans<<std::endl;


    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const int inf=7+1e9,maxn=5+2e4;
typedef unsigned long long ll;
ll dp[maxn];
ll qpow(ll a,ll p){
	ll ans=1,tmp=a;
	while(p){
		if(p&1)
			ans=ans*tmp%inf;
		tmp=tmp*tmp%inf;
		p>>=1;	
	}
	return ans;
}
ll C(ll m,ll n){
	return dp[n]*qpow(dp[m]*dp[n-m]%inf,inf-2)%inf;
}
int main(){
	ll n,k;
	cin>>n>>k;
	//BLUE:C(i-1,k-1);RED:C(i,n-k+1);T0TAL:C(i,k-1)*C(i,n-k+1)
	//5 3
	//1:C(0,2)*C(1,3)=3;2:C(1,2)*C(2,3)=2*3=6;C(2,2)*C(3,3)=1
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	for(ll i=1;i<=2005;i++)
		dp[i]=dp[i-1]*i%inf;
	/*
	for(ll i=1;i<=2000;i++)
		cout<<"dp["<<i<<"]="<<dp[i]<<endl;		
	*/
	for(ll i=1;i<=k;i++){
		if(i-1>n-k)
			cout<<"0\n";
		else	
			cout<<C(i-1,k-1)*C(i,n-k+1)%inf<<endl;
	}
		
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
#define PI 3.14159265359
#define MOD 998244353
const int MAX = 510000;


int main() {
  int N,K;
  cin>>N>>K;
  vector<ll>V(N);
  rep(i,N){
   	cin>>V[i];
  }
  ll maxvalue=0;
  for(int a=0;a<=K;a++){
    for(int b=0;b<=K-a;b++){
    	if(a+b>N){continue;}
    	int p=K-a-b;
      	priority_queue<ll, vector<ll>, greater<ll>> pq;
      	rep(i,a){
        	pq.push(V[i]);
        }
      	rep(i,b){
        	pq.push(V[N-1-i]);
        }
      	rep(i,p){
        	if(!pq.empty()&&pq.top()<0){pq.pop();}
        }
      	ll memo=0;
      	while(!pq.empty()){memo+=pq.top();pq.pop();}
      	maxvalue=max(maxvalue,memo);
    }
  }
  cout<<maxvalue;
}

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

using namespace std;

typedef long long ll;

const int INF = (1<<29);
const int INFF = 0x7fffffff;
const ll LINF = (1ll<<60);
const ll LINFF = 0x7fffffffffffffff;
const long double PI = 3.14159265359;

#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define prec(x) cout << fixed << setprecision(x)
#define sz(x) (int)x.size()
#define _log2(x) 31-__builtin_clz(x)

#define hash sodnf9843bsd
#define right iadjfof23n3okd
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define len length
#define endl '\n'

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a, ll b){return uniform_int_distribution<ll>(a, b)(rng);}

int n;
double dp[333][333][333] = {};
bool vis[333][333][333] = {};

double solve(int a, int b, int c){
    if (a < 0 || b < 0 || c < 0) return 0;
    if (a == 0 && b == 0 && c == 0) return 0;

    if (!vis[a][b][c]){
        vis[a][b][c] = true;

        double z = n-a-b-c;
        double waste = 1./(1-z/n);
        dp[a][b][c] = waste;
        dp[a][b][c] += (double)a/n*solve(a-1, b, c)*waste;
        dp[a][b][c] += (double)b/n*solve(a+1, b-1, c)*waste;
        dp[a][b][c] += (double)c/n*solve(a, b+1, c-1)*waste;
    }
    return dp[a][b][c];
}

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

    cin>>n;
    int cnt[5] = {};
    _fi(n){
        int x;cin>>x;
        cnt[x]++;
    }

    prec(10);
    cout << solve(cnt[1], cnt[2], cnt[3]) << endl;

    return 0;
}


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

int main() {

    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    int N, K;
    cin >> N >> K;
    vector<int> vec(N,0);
    for(int i=0; i<K; i++){
        int d;
        cin >> d;
        for(int j=0; j<d; j++){
            int a;
            cin >> a;
            vec[a-1]++;
        }
    }
    
    int cnt = 0;
    for(int i=0; i<N; i++){
        if(vec[i] == 0){
            cnt++;
        }
    }
    
    cout << cnt << endl;

}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX_T 50
#define WIDTH 9600
pair<int, vector<vector<int>>> E[MAX_T][WIDTH], D[WIDTH];
vector<vector<int>>X;
int hantei(vector<vector<int>>a) {
	int sum = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			int Num = (a[i][j] + 15) % 16; if (a[i][j] == 0)continue;
			sum += abs(i - (Num / 4)) + abs(j - (Num % 4));
		}
	}
	return sum;
}
int main() {
	for (int i = 0; i < 4; i++) {
		vector<int>FF; for (int j = 0; j < 4; j++) { int p; cin >> p; FF.push_back(p); }
		X.push_back(FF);
	}
	E[0][0] = make_pair(hantei(X), X);
	for (int i = 0; i < MAX_T; i++) {
		int CNT = 0;
		if (E[i][0].first == 0) { cout << i << endl; break; }
		for (int j = 0; j < WIDTH; j++) {
			if (E[i][j].second.size() == 0)break;
			int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
			vector<vector<int>>H = E[i][j].second; int I = E[i][j].first;
			int C = 0;
			for (int k = 0; k < 16; k++) {
				if (H[k / 4][k % 4] == 0) {
					C = k;
				}
			}
			for (int k = 0; k < 4; k++) {
				vector<vector<int>>J = H;
				int Ex = (C / 4) + dx[k], Ey = (C % 4) + dy[k];
				if (Ex < 0 || Ex > 3 || Ey < 0 || Ey > 3)continue;
				swap(J[C / 4][C % 4], J[Ex][Ey]);
				D[CNT] = make_pair(hantei(J), J); CNT++;
			}
		}
		sort(D, D + CNT); E[i + 1][0] = D[0]; int cnt2 = 1;
		for (int k = 1; k < CNT; k++) {
			if (D[k - 1] == D[k])continue;
			E[i + 1][cnt2] = D[k]; cnt2++;
		}
	}
	return 0;
}

Measured memory_bytes: 106732
a,m=map(int, input().split())
b,n=map(int, input().split())
c,l=map(int, input().split())
d,o=map(int, input().split())
 
def cal(e,p):
    if e==1:
        x=p*6000 
        return x
        
    elif e==2:
        x=p*4000
        return x
        
    elif e==3:
        x=p*3000
        return x
        
    else:
        x=p*2000
        return x

x1=cal(a,m)
x2=cal(b,n)
x3=cal(c,l)
x4=cal(d,o)

print(x1)
print(x2)
print(x3)
print(x4)


Measured memory_bytes: 5600
#include <stdio.h>

void build_sum_table(int *L, int *R);
int get_sum_range(int L, int R);

int N, M, Q;
int sum[500 + 1][500 + 1] = {0};

int main (void)
{
    int L[200000], R[200000], p[100000], q[100000];
    int i;

    scanf("%d %d %d", &N, &M, &Q);
    for (i = 0; i < M; i++) {
        scanf("%d %d", &L[i], &R[i]);
    }
    for (i = 0; i < Q; i++) {
        scanf("%d %d", &p[i], &q[i]);
    }

    build_sum_table(L, R);

    for (i = 0; i < Q; i++) {
        printf("%d\n", get_sum_range(p[i], q[i]));
    }
}

void build_sum_table(int *L, int *R)
{
    int i, j;

    for (i = 0; i < M; i++) {
        sum[L[i]][R[i]]++;
    }

    for (i = 1; i <= N; i++) {
        for (j = 1; j <= N; j++) {
            sum[i][j] += sum[i - 1][j];
            sum[i][j] += sum[i][j - 1];
            sum[i][j] -= sum[i - 1][j - 1];
        }
    }
}

int get_sum_range(int L, int R)
{
    int ans = sum[R][R] - sum[R][L - 1] - sum[L - 1][R] + sum[L - 1][L - 1];
    return ans;
}


Measured memory_bytes: 4224
def f(i):
    global ans
    if i == n:
        t = []
        cost = 0
        for j in range(n):
            if s[j] == 1:
                t.append(j)
        for j in range(1, m + 1):
            c = 0
            for k in t:
                c += a[k][j]
            if not c >= x:
                return
        for j in t:
            cost += a[j][0]
        ans = min(ans, cost)
        return
    f(i + 1)
    s[i] = 1
    f(i + 1)
    s[i] = 0
 
n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
s = [0] * n
ans = pow(10, 10)
f(0)
print(ans if not ans == pow(10, 10) else -1)

Measured memory_bytes: 69724
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
constexpr int maxn = 5010;
vector<ll> d(maxn), sum(maxn), cnt(maxn);
int k, q, n, x, m;
int main(void)
{
    scanf("%d%d", &k, &q);
    for (int i = 0; i < k; ++i)
        scanf("%lld", &d[i]);
    for (int i = 0; i < q; ++i)
    {
        scanf("%d%d%d", &n, &x, &m);

        vector<ll> dm(d);
        sum[0] = 0;
        cnt[0] = 0;
        for (int j = 0; j < k; ++j)
        {
            dm[j] %= m;
            sum[j + 1] = sum[j] + dm[j];
            cnt[j + 1] = cnt[j] + (dm[j] == 0);
        }

        ll loop = (n - 1) / k;
        ll remain = (n - 1) % k;
        ll ans = (n - 1) -
                 (loop * cnt[k] + cnt[remain]) -
                 (loop * sum[k] + sum[remain] + x) / m + x / m;
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 484
#include<bits/stdc++.h>
using namespace std;
signed main(void){
	int a[5];
	for(int i=0;i<5;i++)
		cin>>a[i];
	sort(a,a+5);
	cout<<a[4];
	for(int i=3;i>=0;i--)
		cout<<" "<<a[i];
	cout<<endl;
}

Measured memory_bytes: 1176
fn main() {
    let a: i32 = read();
    println!("{}", a + (a * a) + (a * a * a))
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 2076
def BubbleSort(a, n):
    for i in range(n):
        for j in range(n-1, i, -1):
            if int(a[j][1]) < int(a[j - 1][1]):
                a[j], a[j-1] = a[j-1], a[j]
    return a


def SelectionSort(a, n):
    for i in range(n):
        mini = i
        for j in range(i, n):
            if int(a[j][1]) < int(a[mini][1]):
                mini = j
        a[i], a[mini] = a[mini], a[i]
    return a


n = int(input())
a = input().split()


b = a[:]
a = BubbleSort(a, n)
b = SelectionSort(b, n)


print(*a)
print("Stable")
print(*b)

if a == b:
    print("Stable")
else:
    print("Not stable")
    

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

int main() {
    int a, b;
    cin >> a >> b;
    
    if (a < b) {
        cout << "a < b" << endl;
    }
    
    else if (a > b) {
        cout << "a > b" << endl;
    }
    
    else {
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3108
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main(void) {
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll mn = min(a, min(b, min(c, min(d, e))));
  cout << (n % mn == 0 ? n / mn + 4 : n / mn + 5) << endl;
  return 0;
}


Measured memory_bytes: 3568
/**
 * Author: Behradm
 * Created: 04-04-2020 13:47:53
**/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())

#ifdef LOCAL
	#define debugi(x) cerr << "{" << #x << "}: " << (x) << '\n'
	#define debug(v, begin, end) cerr << "{ | "; for(auto i = begin; i < end; i++){cerr << #v << "[" << i << "]: " << v[i] << " | ";} cerr << " }\n"
	#define debugp(a, b) cerr << "\n{ " << a << " " << b << " }\n"
#else
	#define debugi(x) 42
	#define debug(v, begin, end) 42
	#define debugp(a, b) 42 
#endif

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout.precision(6);
	cout << fixed;
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5])
		cout << "Yes\n";
	else
		cout << "No\n";

	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;

int main() {
  string s;
  cin >> s;

  int c = -1;

  rep(i, s.size()) {
    if (c == -1 && s[i] == 'C') {
      c = i;
      continue;
    }

    if (c != -1 && s[i] == 'F') {
      cout << "Yes" << endl;
      return 0;
    }
  }

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

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

int main(){
  int N;
  cin>>N;
  int H[N];
  for(int i=0;i<N;i++){
  	cin>>H[i];
  }
  int move=0;
  int moveMax=0;
  int jump=0;
  for(int i=N-2;i>=0;i--){
  	if(H[i]>=H[i+1]){
    	move++;
    }else {
    	if(move>moveMax){
        	jump=i;
          moveMax=move;
        }
      move=0;
    }
  }
  if(move>moveMax){
  	moveMax=move;
  }
  
  cout<<moveMax;
  
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
  int x=0,y=0,ans=0;
  scanf("%d %d",&x ,&y);
  if(x==1 && y==1)ans=1000000;
  else if(x==1 && y==2)ans=500000;
  else if(x==1 && y==3)ans=400000;
  else if(x==2 && y==1)ans=500000;
  else if(x==2 && y==2)ans=400000;
  else if(x==2 && y==3)ans=300000;
  else if(x==3 && y==1)ans=400000;
  else if(x==3 && y==2)ans=300000;
  else if(x==3 && y==3)ans=200000;
  else if(x==1 && y>3)ans=300000;
  else if(x==2 && y>3)ans=200000;
  else if(x==3 && y>3)ans=100000;
  else if(x>1 && y==1)ans=300000;
  else if(x>2 && y==2)ans=200000;
  else if(x>3 && y==3)ans=100000;
  printf("%d\n", ans);
}


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

int sectionsort(int aa[], int n) {
	int sw = 0;
	int minv=1000000001;
	int minj=0;
	for (int i = 0; i<n; ++i) {
		minj=i;
		for (int j = i; j<n; j++) {
			if(aa[j]<aa[minj]){
				minj=j;
			}
		}
			swap(aa[i], aa[minj]);
			if(i!=minj)sw++;
		}
	return sw;
}

int main() {
	int n, sw;
	cin >> n;
	int aa[n];
	for (int i = 0; i < n; ++i) {
		cin >> aa[i];
	}
	sw = sectionsort(aa, n);
	for (int i = 0; i < n; ++i) {
		if(i)cout<<" ";
		cout<<aa[i];
	}
		cout<<endl;
		cout<<sw<<endl;
}

Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;
 
int n;
string w[100];
map<string,int> words;
bool f = true;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>w[i];
		words[w[i]]++;
		if((i > 0 && w[i-1][w[i-1].size()-1] != w[i][0]) || (i > 0 && words[w[i]] > 1))
			f = false;
	}
	if(f)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)
int a[MAX+1];
int n;
void maxHeapify(int *A,int i){
    int l=2*i;
    int r=2*i+1;
    int largest;
    if(l<=n&&A[l]>A[i]){
        largest=l;
    }
    else {
        largest=i;
    }
    if(r<=n && A[r] > A[largest]){
        largest = r;
    }
    if (largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(A, largest);
    }
}
void ii(int *A,int i,int k){
    if(k<A[i])return;
    A[i]=k;
    while(i>1&&A[i/2]<A[i]){
        swap(A[i],A[i/2]);
        i=i/2;
    }
}
void insert(int *A,int k){
    n++;
    A[n]=-INFTY;
    ii(A,n,k);
}

int extract(int *A){
    if(n<1)return -INFTY;
    int m=A[1];
    A[1]=A[n--];
    maxHeapify(A,1);
    return m;
}
int main(){
    string com;
    while(1){
        cin>>com;
        if(com=="insert"){
            int key;
            cin>>key;
            insert(a,key);
        }
        else if(com=="extract"){
            cout<<extract(a)<<endl;
        }
        else{
            break;
        }
    }
    return 0;
}






Measured memory_bytes: 6960
#include <stdio.h>

/* http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0256 */

int main(void) {
	int sum = 0, input;
	int i;
	
	for (i = 0; i < 10; ++i) {
		scanf("%d", &input);
		sum += input;
	}
	
	printf("%d\n", sum);
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

using namespace std;

void Fast_Read_Out()
{
	ios_base::sync_with_stdio(0);
	cin.tie(), cout.tie();
}

void Random()
{
	unsigned int seed;
	asm("rdtsc" : "=A" (seed));
	srand(seed);        
}

unsigned int Time()
{
	 unsigned int time = clock() / 1000.00;
	 return time;
}

const long long inf = (1e9) + 123;
const int N = (1e5) + 123;
const int MN = (1e7);
const int mod = (1e9) + 7;

int sum(int j)
{
	int res = 0;
	while(j)
	{
		res += j % 10;
		j /= 10;
	}
	return res;
}

main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif 
	Random();
	Fast_Read_Out();
	int n;
	cin >> n;
	int mini = inf;
	for(int i = 1; i < n; i++)
	{
		mini = min(mini, sum(i) + sum(n - i));
	}
	cout << mini;
	#ifdef JUDGE
//		cout << Time() << endl;
	#endif
}
// Easy Peasy Lemon Squeezy   a

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b,c;
    cin>> a>> b>> c;
    bool frag=false;
    int cnt=0;
    while(1){
      if(a && b && c){
	cnt++;
	a--; b--; c--;
      }
      else if(a>1 && b){
	cnt++;
	a-=2; b--;
      }
      else if(a>2){
	cnt++;
	a-=3;
      }
      else break;
    }

    cout<< cnt<< endl;
  }
}

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

int main(){
  int N;cin >> N;
  int sum=0,ans;
  vector<int> A(N);
  vector<int> B(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sum += A[0];
  for(int i=0;i<N;i++){
    cin >> B[i];
    sum += B[i];
  }
  ans = sum;
  for(int i=1;i<N;i++){
    sum = sum + A[i] - B[i-1];
    ans = max(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604