akhauriyash/Code-Regression huggingface dataset:
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __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...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 2e3 + 7;

int n, x, y;
vi add[N];
int ans[N];

void bfs(int s) {
  queue<int> q;
  vi dis(N, 0);
  vi seen(N, 0);
  q.push(s);
  seen[s] = 1;
  dis[s] = 0;
  while (!q.empty()) {
    int x = q.front(); q.pop();
    for (auto i : add[x]) {
      if (!seen[i]) {
        dis[i] = dis[x] + 1;
        q.push(i);
        seen[i] = 1;
      }
    }
  }
  rep1(i, n) {
    ans[dis[i]]++;
  }
}

int32_t main() {
  FAST_IO;
  cin >> n >> x >> y;
  rep(i, n - 1) {
    add[i + 1].pb(i + 2);
    add[i + 2].pb(i + 1);
  }
  add[x].pb(y);
  add[y].pb(x);
  rep1(i, n) {
    bfs(i);
  }
  rep1(i, n - 1) {
    cout << ans[i] / 2 << '\n';
  }
  rtn 0;
}


Measured memory_bytes: 384
#include<stdio.h>

long long p[51];
long long h[51];
long long N,X;

long long niku(long long level,long long X){
	long long K=X;
	if(K<=0)return 0;
	if(K>=h[level]){
		return p[level];
	}
	
	long long ans=0;
	if(K>=1+h[level-1]){
		ans+=niku(level-1,h[level-1]);
		K-=1+h[level-1];
		if(K>0)ans++;
	}
	ans+=niku(level-1,K-1);
	return ans;
}

int main(){
	h[0]=1;
	for(int i=1;i<=50;i++)h[i]=2*h[i-1]+3;
	p[0]=1;
	for(int i=1;i<=50;i++)p[i]=2*p[i-1]+1;
	
	scanf("%lld%lld",&N,&X);
	
	long long ans=niku(N,X);
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()

	x := make([]int, n)
	y := make([]int, n)
	for i := 0; i < n; i++ {
		x[i] = scanInt()
		y[i] = scanInt()
	}

	cnt := make(map[point]int)
	ma := 0

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}

			p := x[i] - x[j]
			q := y[i] - y[j]
			cnt[point{p,q}]++
			ma = max(ma, cnt[point{p,q}])
		}
	}

	fmt.Fprintln(wr, n-ma)
	// fmt.Fprintln(wr, cnt)

}

type point struct {
	x,y int
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int q;
    cin>>q;
    vector<int> t(q);
    for(int i=0;i<q;i++){
        cin>>t[i];
    }
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    int ans=0;
    for(int i=0;i<q;i++){
        int l=0,r=n;
        while(r-l>1){
            int c=(l+r)/2;
            if(t[i]<s[c])r=c;
            else if(t[i]>=s[c])l=c;
        }
        if(s[(l+r)/2]==t[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n,a,b; cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string str;
  cin>>str;
  int mxcnt=0;
  char ans;
   
  int i=0;
  while(i<str.size()){
    int cnt=0;
    char mae = 0;
    while(i<str.size()&&str[i]!=mae) {
      cnt++;
      mae=str[i];
      if(str[i]=='e') i+=3;
      else i+=7;
    }
    if(mxcnt<cnt) ans=mae,mxcnt=cnt;
  }
 
  if(ans=='e') cout <<"egg"<<endl;
  else cout << "chicken"<<endl;
 
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
struct triple{ll   x=0;ll   y=0;ll   z=0;void mt(ll   a,ll   b, ll   c){x=a;y=b;z=c;} void holify(){x=69;y=420;z=911;}};
#define pb push_back
#define x first 
#define y second
#define vec vector
#define pf(vec,val) vec.insert(vec.begin(),val)
#define mp make_pair
#define pii pair<ll  ,ll  >
#define maxll  69696991169
#define minll  -69696942069
#define sz(vec) (ll )vec.size()
#define speedup ios_base::sync_with_stdio(0); cin.tie(NUll ); cout.tie(NUll );
#define loop(mep) for(auto it = mep.begin();it!=mep.end();++it)
//#define usaco_crap(str)ifstream cin((string)str + (string)".in"); ofstream cout ((string)str+(string)".out");
#define range(n) =0;i<(n);i++
#define prll  (vec) for(auto it=vec.begin();it!=vec.end();++it)cerr<<*it<<" ";cerr<<endl;
// mt make triple // triple.mt(a,b,c) //
int  main(){
	ll  n; cin>>n;
	for(int i = sqrt(n)+1 ; i >= 1 ; i--){
		if(n%i==0){cout<<i-1 + (n/i)-1;return 0;}
	}
}


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

int main() {
  string s, t; cin >> s >> t;
  bool che = true;
  if(s.size() +1 !=t.size())
    che = false;
  for(int i=0; i<s.size(); i++){
    if(s.at(i) != t.at(i))
      che = false;
  }
  if(che)
    cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

void fail(){puts("-1"); exit(0);}

int main(){
   int n; cin>>n;
   vector<ll> a(n);
   rep(i,0,n)cin>>a[i];
   ll s=a[0]+a[1],g=0;
   rep(i,2,n)g^=a[i];
   if(s<g or (s-g)%2==1)fail();
   ll And=(s-g)>>1;
   ll a0=And;
   if(a0>a[0])fail();
   for(int k=50;k>=0;k--){
      if(And>>k&1 or (g>>k&1)==0)continue;
      if(a0+(1LL<<k)<=a[0])a0+=1LL<<k;
   }
   if(a0==0 or (a0^(s-a0))!=g)fail();
   else cout<<a[0]-a0<<endl;
   return 0;
}

Measured memory_bytes: 3620
while True:
    l = list(input().split())
    a,op,b =int(l[0]), l[1], int(l[2])
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    else:
        break


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>

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

using namespace std;
struct Prob {
    int num;
    long long bonus;
    long long point;
    int id;
    Prob(){};
    Prob(int num, long long bonus, int number){
        this->num = num;
        this->bonus = bonus;
        point = (number+1)*100;
        id = number;
    }
};

bool operator<(const Prob& p1, const Prob& p2){
    return p1.id < p2.id;
}

int main(){
    long long d,g; cin >> d >> g;
    long long p,c;
    vector<Prob> v(d);
    rep(i, d) { cin >> p >> c;
        v[i] = Prob(p,c,i);
    }
    int max = 1001;
    do {
        // cout << "New permutation " << v[0].id << " " << v[1].id << " " << v[2].id << " " << v[3].id << endl;
        int tmp = 0;
        long long  rest = g;
        for(int i = 0; i< v.size();i++){
            if(v[i].num * v[i].point >= rest) {
                // cout << "case1" << endl;
                tmp += (rest%v[i].point) ? rest/v[i].point+1 : rest/v[i].point;
                // cout << "korekara tasu " << rest/v[i].point << " rest " << rest <<endl;
                // tmp += rest/v[i].point;
                // cout << tmp << endl;
                if(max > tmp) {
                    max = tmp;
                    break;
                }
            } else {
                // cout << "case2" << endl;
                rest -= v[i].num * v[i].point;
                tmp += v[i].num;
                rest -= v[i].bonus;
                // cout << tmp << endl;
                if(rest <=0){
                    if(max > tmp) {
                        max = tmp;
                    }
                    break;
                }
            }
        }
        // cout << max << endl;
    } while(next_permutation(v.begin(), v.end()));
    cout << max << endl;
}



Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	string s;
	cin >> s;
	int ans = 700;
	REP(i, 3) {
		if (s[i] == 'o') ans += 100;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define CAKE 4 //ケーキは4ドル
#define DONUT 7 //ドーナツは7ドル

int main(void)
{
	//変数を定義
	int n, flag = 0;
	//入力
	scanf("%d", &n);

	//変数flagがカウントされたらYes。されなかったらNo。
	for (int i = 0; i <= 100 ;i++) {
		for (int j = 0; j <= 100 ; j++) {
			//購入の全通りを試す
			if (n == CAKE * i + DONUT * j) {
				flag++;
				break;
			}
			//入力した値段を超えたらbreak
			else if(n < CAKE * i + DONUT * j){
				break;
			}
		}
	}

	//変数flagが0かどうかで出力を分岐
	if (flag) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
using namespace std;

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

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

vector <pair <int,int> >A;
int N;

int main(){

	cin >> N;
	REP(i,N){
		pair<int,int>temp;
		cin >> temp.first;
		temp.second = i;
		A.push_back(temp);
	}
	sort(A.begin(),A.end());
	int ans = 0;
	REP(i,N){
		if(i%2 != A[i].second%2)
			ans++;
	}
	cout << ans/2 << endl;
}


Measured memory_bytes: 1400
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;

int main() {
	int n, q;
	int a, b;
	int p, x;
	int i, j, k;

	cin >> n >> q;
	vector< vector<int> > connect(n+1);
	vector<int> plus(n+1);
	vector<int> ans(n + 1);

	for (i = 0; i < n - 1; i++) {
		cin >> a >> b;
		connect[a].push_back(b);
	}

	for (i = 0; i < q; i++) {
		cin >> p >> x;
		plus[p] += x;
	}
	
	for (i = 1; i <= n; i++) {
		ans[i] += plus[i];
		for (j = 0; j < connect[i].size(); j++) {
			ans[connect[i][j]] += ans[i];
		}
		if (i == 1) {
			cout << ans[i];
		}
		else {
			cout << " " << ans[i];
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 14848
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    // Your code here!
    int t, h, m, s ;
    scanf("%d", &t) ;
    h = t / 3600 ;
    m = ( t % 3600 ) / 60 ;
    s = ( t % 3600 ) % 60 ;
    cout << h <<":" << m << ":" << s << endl;
    
    return 0;
}



Measured memory_bytes: 3108
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main() {
    int X;
    cin >> X;
    ll s = 0;
    rep(i, 100005) {
        s += i;
        if (X <= s) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s[101];
  int len,i,count=0;
  scanf("%s",s);
  len=strlen(s);
  for(i=0;i<len/2;i++)
    if(s[i]!=s[len-i-1])
      count++;
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
K, S = gets.split.map(&:to_i)

count = 0
for x in 0..K
    if S - x > K * 2
        next
    end
    for y in 0..([S-x, K].min)
        z = S - x - y
        if 0 <= z && z <= K
            count += 1
        end
    end
end

puts count

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

#define lli long long int
#define pb push_back
#define f first
#define sec second

main()
{
    lli n,i,a,t,j,k,b,c,x,y,sum=0;

    cin>>n;
    lli brr[n-1],arr[n];

    for(i=0;i<n-1;i++)
    {
        cin>>brr[i];
    }
    sum += brr[0];
    for(i=1;i<n;i++)
    {
        sum += min(brr[i-1],brr[i]);
    }

    cout<<sum;
}


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

int main() {
  int n,k;
  cin>>n>>k;
  int count=1;
  for(int i=0;i<100;i++){
    n=n/k;
    if(n>0){
      
      count+=1;
      continue;
    }else{
      break;
    }
  }
  cout<<count<<endl;


}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
ii0 = lambda: ii() - 1
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    N = ii()
    for i in range(1,10):
        if (N%i)==0 and N//i <= 9:
            print('Yes')
            return
    print('No')



main()


Measured memory_bytes: 3060
var selectionSort = function(arr, n) {
  var numSwapped = 0;
  for (var i = 0; i < n; i += 1) {
    var minj = i;
    for (var j = i; j < n; j += 1) {
      if (arr[j] < arr[minj]) {
        minj = j;
      }
    }
    if (minj !== i) {
      var temp = arr[i];
      arr[i] = arr[minj];
      arr[minj] = temp;
      numSwapped += 1;
    }
  }
  return numSwapped;
};

var n = 0;
var arr = [];
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input.split('\n').forEach(function(line, i) {
  if (line !== '') {
    if (i % 2 === 0) {
      n = parseInt(line, 10);
    } else {
      arr = line.trim().split(' ').map(Number);
      var num = selectionSort(arr, n);
      console.log(arr.join(' '));
      console.log(num);
    }
  }
});

Measured memory_bytes: 15572
package main

import(
    "fmt"
)



func main() {
    var a int
    fmt.Scan(&a)
    ans := 48 - a
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 512
#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 ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

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

#define FOR(i,j,k,in) for(int i=(j); i < (k);i+=in)
#define FORD(i,j,k,in) for(int i=(j); i >=(k);i-=in)
#define REP(i,b) FOR(i,0,b,1)
#define REPD(i,b) FORD(i,b,0,1)
#define pb push_back 
#define mp make_pair
#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.1415926535 

int main(){
 	ios_base::sync_with_stdio(false);
 	cin.tie(NULL); cout.tie(NULL);
 	int n; cin >> n;
 	vi arr(n+2, 0);
 	vi arr2; arr2.pb(0);
 	REP(i,n-1){
 	  int a; cin >> a;
 	  arr[a]++;
 	}
 	FOR(i, 1, n+1 ,1){
 	 	cout << arr[i] << endl;
 	}
 	return 0;
}

Measured memory_bytes: 3976
#include<stdio.h>
using namespace std;

int main(){
    int a,b,c,d=0;
    scanf("%d %d %d\n", &a,&b,&c);
    for(int x=a; x<=b; x++){
        if(c%x == 0){
            d++;
        }
    }
    printf("%d\n", d);
}



Measured memory_bytes: 2764
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        string a = cin.next();
        string b = cin.next();

        if ((a == "H" && b == "H") || (a == "D" && b == "D")) Console.WriteLine("H");
        else Console.WriteLine("D");
        Console.Read();
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

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

signed main(){
  
  string s;
  
  while(1){
    
    cin>>s;
    if( s == "#" ) break;
    
    int y, m, d;
    cin>>y>>m>>d;
    
    if( y < 31 ) cout<<s<<' '<<y<<' '<<m<<' '<<d<<endl;
    else if( y == 31 ){
      
      if( m <= 4 ) cout<<s<<' '<<y<<' '<<m<<' '<<d<<endl;
      else{
	cout<<"? "<<y-31+1<<' '<<m<<' '<<d<<endl;
      }
      
    }
    else{
      cout<<"? "<<y-31+1<<' '<<m<<' '<<d<<endl;
    }
    
  }
  
  return 0;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a[3];
  string ans;
    for(int i=0; i<3; i++) cin >> a[i];
    sort(a, a+3);
    if(a[0]+a[1] == a[2]){
      ans = "Yes";
    }else{
      ans = "No";
    }
    cout << ans << endl;
}

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

int main(){
  int n,ans=0,k=0;cin>>n;
  vector<int> v(n);
  rep(i,n)cin>>v.at(i);
  rep(i,n-1){
    if(v.at(i)>=v.at(i+1)){
      k++;
      if(k>ans)ans=k;
    }
    else k=0;
  }
  cout<<ans<<endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  string y="YAKI";
  bool ok=true;
  for(int i=0;i<4;i++)if(s[i]!=y[i])ok=false;
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
char T[200010];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	scanf("%s",T+1);int n=strlen(T+1);
	for(int i=1;i<=n;++i)if(T[i]=='?')T[i]='D';
	printf("%s",T+1);
	return 0;
}


Measured memory_bytes: 4028
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
 
 
 
int main()
{
    fast;
    int n,k,q;
    cin>>n>>k>>q;
    unordered_map<int,int> mp;
    for(int i=0; i<q; i++){
        int x;
        cin>>x;
        mp[x]++;
    }
    for(int i=0; i<n; i++){
        if(mp[i+1]-q+k>0) cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp




int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n,m;
    cin >> n >> m;
    vector<long long> vec(n);
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
    }

    vector<ll> ans(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        if(vec[a] > vec[b]){
            ans[b] = 1;
        }else if(vec[a] == vec[b]){
            ans[a] = 1;
            ans[b] = 1;
        }else{
            ans[a] = 1;
        }
    }
    ll count = 0;
    rep(i,n){
        if(ans[i] == 0){
            count++;
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 4840
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
x=dict()
for i in range(N):
    val=A[i]
    if val in x:
        x[val]+=1
    else:
        x[val]=1

S=sum(A)
#print(S)
for i in range(Q):
    b,c=map(int,input().split())
    if b in x:
        pass
    else:
        x[b]=0
    p=c*x[b]
    d=b*x[b]
    if c in x:
        pass
    else:
        x[c]=0
    x[c]+=x[b]
    x[b]=0
    S=S+p-d
    print(S)

Measured memory_bytes: 23692
<?php
$s = trim(fgets(STDIN));
$arr = str_split($s);
$ans = 'Good';
$arr = [];
for ($i = 0; $i < strlen($s); $i++) {
    $arr[] = $s[$i];
    if ($i === 0) {
        continue;
    }
    if ($arr[$i - 1] === $arr[$i]) {
        $ans = 'Bad';
        break;
    }
}
echo $ans . PHP_EOL;


Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int A=4,B=7,C=28;
    string ans;
    bool memo[101] = {false};
    for(int i=0;i<=100;i+=A){
        for(int j=i;j<=100;j+=B){
            memo[j] = true;
        }
    }
    
    if(memo[N]){
        ans = "Yes";
    }
    else{
        ans = "No";
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3168
#include<iostream>
#include<vector>
#include<algorithm>
//#include<bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<algorithm>
//#include<map.h>
//#include<string.h>
//#include<climits>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define vec vector<int>
#define rep for(int i=0;i<n;i++)
#define rrep for(int i=n-1;i>=0;i--)
#define repj for(int j=0;j<n;j++)
#define MAX_INT 2000000000


int main()
    {
     IOS;
    int t;
    cin>>t;
while(t--){
    cout<<"ACL";}}
    
        
        
        
       

Measured memory_bytes: 3608
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

def gcd(a, b):  # a >= b
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


T = int(input())

for turn in range(1, T+1):
    init, sell, base, add = map(int, input().split())

    hoge = gcd(sell, add)

    ans = "Yes"
    if init < sell or sell > add:
        ans = "No"
    elif base+hoge >= sell:
        if init % sell > base:
            ans = "No"
    else:
        ans = "No"

    print(ans)


Measured memory_bytes: 46448
#include<stdio.h>

int main(void){
    int m,f,r;
    
    do{
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1&&f==-1&&r==-1){
            break;
        }else{
            if(m==-1||f==-1){
                printf("F\n");
            }else{
                if(m+f>=80){
                    printf("A\n");
                }else if(m+f>=65){
                    printf("B\n");
                }else if(m+f>=50){
                    printf("C\n");
                }else if(m+f>=30){
                    if(r>=50){
                        printf("C\n");
                    }else{
                        printf("D\n");
                    }
                }else{
                    printf("F\n");
                }
            }
        }
    }while(1);
    
    return 0;
}


Measured memory_bytes: 2028
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from functools import reduce
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

val = lcm_list(A)-1
res = 0
for a in A:
    res += val%a

print(res)


Measured memory_bytes: 74832
#include <bits/stdc++.h>
#include <string>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PL;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  
  ll N, C;
  cin >> N >> C;
  ll x[MAX], v[MAX];
  ll s[MAX]={}, t[MAX]={};
  
  x[0]=0; v[0]=0;
  x[N+1]=C; v[N+1]=0;
  for(i=1; i<=N; i++) cin >> x[i] >> v[i];
  for(i=1; i<=N; i++) s[i]=s[i-1]+v[i];
  for(i=N; i>=1; i--) t[i]=t[i+1]+v[i];
  
  ll ans=0;
  ll m=-INF, mm=-INF;
  for(i=0; i<=N; i++) {
    chmax(m, s[i]-x[i]);
    chmax(mm, s[i]-x[i]*2);
    
    chmax(ans, m+t[i+1]-(C-x[i+1])*2); //OA+OB*2
    chmax(ans, mm+t[i+1]-(C-x[i+1])); //OA*2+OB
  }
  
  pt(ans);
}


Measured memory_bytes: 3456
#include<stdio.h>
int main(void)
{
	int a,b,i,c,cnt;
	cnt=0;
	scanf("%d %d",&a,&b);
	while(a!=0&&b!=0){
		c=0;
		for(i=a;i<=b;i++){
			if(i%4==0 && i%100!=0){
				cnt++;
				printf("%d\n",i);
				c=1;
			}
			else if(i%400==0){
				cnt++;
				printf("%d\n",i);
				c=1;
			}
		}
		if(c==0){
			printf("NA\n");
		}
		
		scanf("%d %d",&a,&b);
		if(cnt>=0 && a!=0 && b!=0){
			printf("\n");
		}
	}
	return 0;
}

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

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(ref v;t){v=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 readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  long n, m; readV(n, m);

  if (n > m) swap(n, m);
  if (n == 1) {
    if (m == 1)
      writeln(1);
    else
      writeln(m-2);
  } else {
    writeln((n-2)*(m-2));
  }
}


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

int main() {
  int a, b, c, d, e;
  cin >> a;
  
  b = a % 100;
  c = b % 10;
  d = a / 100;
  e = b / 10;
  
  cout << c + d + e << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 998244353LL
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    ll S; cin >> S;

    if (S == 1000000000000000000) {
        cout << 0 << ' ' << 0 << ' ';
        cout << 1000000000 << ' ' << 0 << ' ';
        cout << 0 << ' ' << 1000000000 << ' ';
        return 0;
    }
    cout << 0 << ' ' << 0 << ' ';
    cout << 1000000000 << ' ' << 1 << ' ';
    cout << 1000000000LL*(S/1000000000+1)-S << ' ' << (S/1000000000+1);
}

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

ll mod = 1000000007;
ll modsize = 200010;
vector<ll> fac(modsize);
vector<ll> inv(modsize);
vector<ll> facinv(modsize);

void modcalc(){
    if(modsize == 0) abort();
    fac[0] = 1; fac[1] = 1; inv[1] = 1;
    facinv[0] = 1; facinv[1] = 1;
    for(ll i = 2 ; i < modsize ; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        facinv[i] = facinv[i-1] * inv[i] % mod;
    }
}

ll modinv(ll a){
    if(a==0) abort();
    ll b = mod, u = 1, v = 0;
    while(b){
        ll t = a/b;
        a -= t * b; swap(a,b);
        u -= t * v; swap(u,v);
    }
    u %= mod;
    if(u<0) u += mod;
    return u;
}

ll modcomb(ll n, ll k){
    if(n<0||k<0||n<k) return 0;
    return fac[n] * facinv[k] % mod * facinv[n-k] % mod;
}

int main(){
  modcalc();

  int n,k; cin>>n>>k;
  ll ans = 0;
  k = min(k,n-1);
  rep(i,k+1){
    ans += modcomb(n,i) * modcomb(n-1,n-i-1);
    ans %= mod;
  }
  cout << ans << endl;
}

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

int main(){
  int D, G;
  cin >> D >> G;
  vector<int> A(D);
  vector<int> B(D);
  rep(i, D){
    int a, b;
    cin >> a >> b;
    A[i] = a;
    B[i] = b;
  }
  
  int min_count = 1000;
  for (int bit = 0; bit < (1 << D); ++bit){
    int count = 0;
    int sum = 0;
    int rest_max = -1;
    rep(i, D){
      if (bit & (1 << i)){
        sum += 100 * (i+1) * A[i] + B[i];
        count += A[i];
      }
      else {
        rest_max = i;
      }
    }
    if (sum < G){
      int s1 = 100 * (rest_max + 1);
      int need = (G - sum + s1 -1) / s1;
      if (need >= A[rest_max]){
        continue;
      }
      count += need;
    }
    min_count = min(min_count, count);
  }
  cout << min_count << endl;
}
   

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

int main(){
  int n,d;
  cin >> n >> d;
  d=2*d+1;
  if(n<=d){
    cout << 1 << endl;
  }else if(n%d != 0){
    cout << n/d+1 << endl;
  }else{
    cout << n/d << endl;
  }
}

Measured memory_bytes: 256
#include"iostream"
using namespace std;
struct node
{
	char data[3];
};
void Selectionsort(node num[], int n);
void Bubblesort(node num[], int n);
int main()
{
	int n;
	cin >> n;
	node*num = new node[n];
	node* num1 = new node[n];
	int i;
	for (i = 0; i < n; ++i)
	{
		cin >> num[i].data;
		num1[i] = num[i];
	}
	Bubblesort(num, n);
	cout << "Stable" << endl;
	Selectionsort(num1, n);
	int flag = 1;
	for (i = 0; i < n; ++i)
		if (num[i].data[0] != num1[i].data[0]) {
			flag = 0; break;
		}
	if (flag == 0)cout << "Not stable"<<endl;
	else cout << "Stable"<<endl;
	delete[]num;
	delete[]num1;
	return 0;
}
void Selectionsort(node num[], int n)
{
	int i,j,mini;
	node t;
	for (i = 0; i < n; ++i)
	{
		mini = i;
		for (j = i; j < n; ++j)
			if (num[j].data[1] < num[mini].data[1])mini = j;
			t = num[i];
			num[i] = num[mini];
			num[mini] = t;
	}
	cout << num[0].data;
	for (i = 1; i < n; ++i)
		cout << ' ' << num[i].data;
	cout << endl;
}
void Bubblesort(node num[], int n)
{
	int i, j;
	node t;
	for (i = 0; i < n; ++i)
		for (j = n - 1; j > i; --j)
			if (num[j].data[1] < num[j - 1].data[1])
			{
				t = num[j];
				num[j] = num[j - 1];
				num[j - 1] = t;
			}
	cout << num[0].data;
	for (i = 1; i < n; ++i)
		cout << ' ' << num[i].data;
	cout << endl;
}


Measured memory_bytes: 3120
N, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for i in range(N)]

dp = [[0] * (W + 1)] + [[0] * (W + 1) for i in range(N)]


def wi(i):
    return wv[i - 1][0]


def vi(i):
    return wv[i - 1][1]


def value(i, w):
    if w - wi(i) >= 0:
        return max(dp[i - 1][w], dp[i - 1][w - wi(i)] + vi(i))
    else:
        return dp[i - 1][w]


for i in range(1, N + 1):
    dp[i] = [value(i, w) for w in range(W + 1)]

print(dp[-1][-1])


Measured memory_bytes: 253816
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	string wi, last_word;
	map<string, bool> used;
	cin >> last_word;
	used[last_word] = true;
	for (int i = 1; i < n; ++i) {
		cin >> wi;
		if (last_word[last_word.size() - 1] != wi[0] || used.find(wi) != used.end()) {
			cout << "No\n";
			return 0;
		}
		last_word = wi;
		used[last_word] = true;
	}

	cout << "Yes\n";

	return 0;

}

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

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

#define rep(a,n) for(int a = 0;a < n;a++)

struct custom_compare
{
	inline bool operator() (const P& p1, const P& p2)
	{
		if (p1.first == p2.first) {
			return p1.second < p2.second;
		}
		return p1.first < p2.first;
	}
};

int main(void)
{
	const ll LARGE = (ll)1e15;
	int n;
	cin >> n;
	vector<P> range;
	ll value = 0;
	rep(i, n) {
		ll l, r;
		cin >> l >> r;
		range.emplace_back(l, r);
	}
	sort(range.begin(), range.end(), custom_compare());
	vector<ll> lefts(n);
	ll m = LARGE;
	rep(i, n) {
		m = min(m, range[i].second);
		lefts[i] = m;
	}
	m = LARGE;
	vector<ll> rights(n);
	for (int i = n - 1; i >= 0; i--) {
		m = min(m, range[i].second);
		rights[i] = m;
	}
	rep(i, n - 1) {
		ll l1 = range[i].first;
		ll r1 = lefts[i];
		ll l2 = range[n - 1].first;
		ll r2 = rights[i + 1];
		ll la = max(0LL, r1 - l1 + 1);
		ll ra = max(0LL, r2 - l2 + 1);
		value = max(value, la + ra);
	}
	for (int i = 1; i < n - 1;i++) {
		ll l1 = range[i].first;
		ll r1 = range[i].second;
		ll l2 = range[n-1].first;
		ll r2 = min(rights[i + 1], lefts[i - 1]);
		ll la = max(0LL, r1 - l1 + 1);
		ll ra = max(0LL, r2 - l2 + 1);
		value = max(value, la + ra);
	}
	cout << value << endl;
	return 0;
}

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

const int N = 1e4, MOD = 1e9 + 7;

char c[N];
int val[N][N];

signed main() {
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    val[0][0] = 1;
    int n; cin >> n;
    for(int i = 0; i < n; i++)
        cin >> c[i];
    
    for(int i = 1; i < n; i++) {
        int i1 = i-1;
        if(c[i1] == '<') {
            for(int j = 0; j < i; j++)
                val[i][j+1] = (val[i][j] + val[i1][j]) % MOD;
        } else {
            for(int j = i-1; j > -1; j--)
                val[i][j] = (val[i1][j] + val[i][j+1]) % MOD;
        }
    }
    int t = 0;
    for(int i = 0; i < n; i++)
        t = (t + val[n-1][i]) % MOD;
    cout << t;
}

Measured memory_bytes: 233856
import java.util.*;
public class Main {
	static Scanner s = new Scanner(System.in);
	public static void main(String __[]){
		String t="CODEFESTIVAL2016",in=s.next();
		int count=0;
		for(int i=0;i<t.length();i++)
			if(t.charAt(i)!=in.charAt(i))
				count++;
		System.out.println(count);
	}
}


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

def count_ab(start, end):
    l = len(str(n))
    if start == 0:
        return 0
    if l == 1:
        if start == end:
            if n >= start:
                return 1
            else:
                return 0
        else:
            return 0
    else:
        if start == end:
            cnt = 1
        else:
            cnt = 0
        if int(str(n)[0]) > start:
            for i in range(1, l):
                cnt += 10 ** i // 10
        if int(str(n)[0]) == start:
            for i in range(1, l - 1):
                cnt += 10 ** i //10
            cnt += int(str(n)[1:]) // 10
            if int(str(n)[-1]) >= end:
                cnt += 1
        if int(str(n)[0]) < start:
            for i in range(1, l - 1):
                cnt += 10 ** i //10
        return cnt

ans = 0
for i in range(10):
    for j in range(10):
        A = count_ab(i, j)
        B = count_ab(j, i)
        ans += A * B

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
	bool x = false;
	if((a.second*a.first) < b.second*b.first){
		x = true;
	}
    return x;
}
int main(){
	
	int a,b;
	cin>>a>>b;
    if((a*b)%2 == 0) cout<<"Even"<<"\n";
    else cout<<"Odd"<<"\n";
}









Measured memory_bytes: 256
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
void fo (){fflush(stdout);}
using namespace std;
int a[3][3];
int A[3] , B[3];
bool check ()
{
  for (int i =0 ; i < 3; i++)
  {
    for (int j =0 ; j < 3; j++)
    {
      if (a[i][j] != A[i] + B[j])
      return false;
    }
  }
  return true ;
}
int main ()
{
  for (int i =0 ; i < 3 ;i++)for (int j =0 ; j < 3 ;j++)cin >>a[i][j];
  for (int a1 = 0 ; a1 <= 100 ; a1++)
  {
    for (int a2 = 0 ; a2 <= 100 ; a2++)
    {
      for (int a3 = 0 ; a3 <= 100 ;a3++)
      {
        B[0] = a[0][0] - a1 ;
        B[1] = a[1][1] - a2 ;
        B[2] = a[2][2] - a3 ;
        A[0] = a1 ;
        A[1] = a2 ;
        A[2] = a3 ;
        if ( check() )
        {
          cout <<"Yes\n";
          return 0 ;
        }

      }
    }
  }
  cout <<"No\n"; 

  //cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int res;bool f[10];
bool valid(int x){
	while(x){
		if(f[x%10])return false;
		x/=10;
	}
	return true;
}
int main(){
	int k,x;
    cin >> res >> k;
	while(k--){
		cin >> x;
		f[x] = true;
	}
	while(!valid(res))res++;
	cout << res << endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

int a[200005],b[200005];
int main() {
    int n;
    cin>>n;
    ii cin>>a[i];
    b[n]=1;for(int i=1;i<n;++i) b[i]=2;
    sort(al(a));
    ll s=0;
    int pos=n;
    for(int i=1;i<n;++i) {
        s+=a[pos];
        b[pos]--;
        if(!b[pos]) pos--;
    }
    cout<<s<<endl;
}

Measured memory_bytes: 5128