akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a = 0;
  int b = 0;
  string p;
  cin >> p;
  for(int i = 0; i < 3; i++){
    if(p.at(i) == 'A'){
      a++;}
    if(p.at(i) == 'B'){
      b++;}
  }
  if(a > 0 && b > 0){
    cout << "Yes" << endl;}
  else{
    cout << "No"  << endl;}
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    if (N % 2 == 1) {
        cout << 0 << '\n';
    } else {
        ll ans = 0;
        rep2(i, 1, 26) {
            ll tmp = N;
            ll cnt = 0;
            ll d = 2 * (ll) pow(5, i);
            ans += tmp / d;
        }
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 1000003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define sumall(v) accumulate(all(v),(ll)0)
#define sum accumulate
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
#define sp " "
#define zero (ll)0
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"\n" ;}
/*vbool isprime(N,true);
vll spf(N,0);
vll prime;
void sieve()
{
    isprime[0] = isprime[1] = false;
    for(ll i = 2 ; i<N ; i++)
    {
        if(isprime[i])
        {
            for(ll j=2*i ; j<N ; j+=i)
            {
                isprime[j] = false;
                if(spf[j]==0)
                {
                    spf[j] = i;
                }
            }
            prime.pb(i);
        }
    }
}*//*
ll nck(ll n , ll k ,ll m=1e18+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}*/
long long power(long long k , long long n , long long m=mod)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
ll n,m,k;
int main()
{
    FastIO ;
    PRECISION(10) ;
    ll a,b,c,d,i,j,t,x,y,z;//,x1,y1,z1,e,f;
    db p,q,r,u,w ;
    char ch,chr ;
    string str,st,str1,str2,str3,str4;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    cin>>k>>n;
    vll v;
    READ(v,n);
    x = inf;
    y = (k-v[n-1]) + (v[0]);
    vll pref(n,0);
    pref[0] = 0;
    for(i=1 ; i<n ; i++)
    {
        pref[i] = pref[i-1] + v[i] - v[i-1];
    }
    x = pref[n-1];
    for(i=1 ; i<n ; i++)
    {
        d = pref[n-1] - pref[i] + pref[i-1] + y;
        //cout<<d<<" ";
        x = min(x,d);
    }
    cout<<x;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vector<P> p;
  rep(i, n) {
    ll x, l;
    cin >> x >> l;
    p.push_back({x + l, x - l});
  }
  ll ans = 0, now = -4e18;
  sort(all(p));
  rep(i, n) {
    if(p[i].second >= now)
      now = p[i].first;
    else
      ans++;
  }
  cout << n - ans << endl;
}

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

int main( void ){
	int N, base = 0;
	cin >> N;
	vector <int> vec( N );
	rep( i, 0, N ) cin >> vec[ i ], base ^= vec[ i ];
	rep( i, 0, N ) cout << ( base ^ vec[ i ] ) << " ";
	cout << endl;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll mod = 998244353;

template<class T>
class SegTree{
	int n;                       //葉の数
	vector<T> data;              //格納するデータ
	T def;                       //単位元
	function<T(T, T)> operation; //区間クエリで使う処理
	function<T(T, T)> update;    //点更新で使う処理

	//区間[a, b)の総和
	T _query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l)return def;
		if(a <= l && r <= b)return data[k];
		T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
		T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
		return operation(c1, c2);
	}
public:
	
	//_n : 要素数, _def : 単位元, _operation : クエリ関数, _update : 更新関数
	SegTree(int _n, T _def, function<T(T,T)> _operation, function<T(T,T)> _update) : def(_def), operation(_operation), update(_update){
			n = 1;
			while(n < _n)n *= 2;
			data = vector<T> (2 * n - 1, def);
	}

	//[a, b)の区間クエリを実行
   T query(int a, int b){
		return _query(a, b, 0, 0, n);
	}

	void change(int i, T x){
		i += n - 1;
		data[i] = update(data[i], x);
		while(i  > 0){
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}

	T operator[] (int i){
		return data[i + n - 1];
	}
};

//_n : 要素数, _def : 単位元, _operation : クエリ関数, _update : 更新関数

int main()
{
	ll n, q;
	cin >> n >> q;
	SegTree<ll> tree(
		n,1e10,
		[](ll a, ll b){return min(a, b);},
		[](ll a, ll b){return b;}
	);

	for(int i = 0; i < n; i++)tree.change(i, (1LL << 31) - 1);
	vector<ll> ans;

	for(int i = 0; i < q; i++){
		int f; cin >> f;
		if(f){
			int a, b; cin >> a >> b;
			ans.push_back(tree.query(a, b + 1));
		}else{
			int a, b; cin >> a >> b;
			tree.change(a, b);
		}
	} 
	for(auto i : ans){
		cout << i << endl;
	}
}


Measured memory_bytes: 5604
import numpy as np
N, M = map(int, input().split())
array = np.array([list(map(int, input().split())) for i in range(N)])

A_array = array[:, 0]
B_array = array[:, 1]

buy_total = 0
money_count = 0
buy_order = np.argsort(A_array)
# print(buy_order)
for buy_index in buy_order:
    buy_count = min(M - buy_total, B_array[buy_index])
    buy_total += buy_count
    money_count += buy_count * A_array[buy_index]
    if buy_total == M:
        break
print(money_count)

Measured memory_bytes: 37836
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int sum = 0;
	int maxn = 0;
	for(int i = 0;i < n; ++i)
	{
		int x;
		cin>>x;
		sum += x;
		maxn = max(maxn,x);
	}
	if(sum - maxn > maxn)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

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

int main() {
  stack<int> stk;
  int a;
  while(cin >> a) {
    if(a == 0) {
      cout << stk.top() << endl;
      stk.pop();
    } else {
      stk.push(a);
    }
  }
  return 0;
}

Measured memory_bytes: 1200
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def divisors(n):
    lower = []
    upper = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            lower.append(i)
            if i != n // i:
                upper.append(n // i)

    lower.extend(reversed(upper))
    return lower


def main():
    N, *A = map(int, read().split())

    B = [False] * (N + 1)
    C = [0] * (N + 1)

    for i, a in reversed(list(enumerate(A, 1))):
        if a == C[i] % 2:
            continue
        B[i] = True
        divs = divisors(i)
        for d in divs:
            C[d] += 1

    ans = [i for i in range(1, N + 1) if B[i]]
    print(len(ans))
    if len(ans) > 0:
        print(' '.join(map(str, ans)))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 109168
#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 ans = 0;

  int plus = 0;
  int minus = 0;

  rep(i,n){
    int d;
    cin >> d;
    plus += d;
    minus += d*d;
  }

  ans = (plus*plus - minus)/2;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,m;

    scanf("%d %d", &n, &m);
    if (n > 1)
        n = (n * (n - 1)) / 2;
    else
        n = 0;
    if (m > 1)
        m = (m * (m - 1)) / 2;
    else
        m =0;
    printf("%d", n + m);
    return (0);
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){

    double a;
    int b;
    cin >> a >> b;

    int bs = b*10, be = b*10+10;

    int ans;
    for(int i = bs;i<be;i++){
        if(a*25/2<=i&&(a+1)*25/2>i){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}  

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

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
    int v_n, h_n, start;
    while(cin >> v_n >> h_n >> start, v_n|h_n|start){
        vector<vector<pii>> lines(v_n + 1);
        REP(i, h_n){
            int h, p, q;
            cin >> h >> p >> q;
            lines[p].push_back({h, q});
            lines[q].push_back({h, p});
        }

        REP(i, v_n + 1) {
            RSORT(lines[i]);
        }

        vi lineidx(v_n + 1, 0);

        int now_h = 10000;
        int now_v = start;
        while(1){
            bool update = false;
//            for(auto h_line:lines[now_v]){
            FOR(i, lineidx[now_v], lines[now_v].size()){
                auto h_line = lines[now_v][i];
                if(now_h > h_line.first){
//                    LOG("move to %d -> %d\n", now_v, h_line.second);
                    lineidx[now_v] = i + 1;
                    now_h = h_line.first;
                    now_v = h_line.second;
                    update = true;
                    break;
                }
            }
            if(!update) break;
        }

        cout << now_v << endl;
    }
}

Measured memory_bytes: 1240
package main

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

func main() {
	rdr := NewReader(20)
	n := ReadInt()
	m := int64(0)
	a := int64(0)
	r := int64(0)
	c := int64(0)
	h := int64(0)

	p1 := []int{0, 0, 0, 0, 0, 0, 1, 1, 1, 2}
	p2 := []int{1, 1, 1, 2, 2, 3, 2, 2, 3, 3}
	p3 := []int{2, 3, 4, 3, 4, 4, 3, 4, 4, 4}

	for i := 0; i < n; i++ {
		name := ReadLine(rdr)
		if name[0:1] == "M" {
			m++
		}
		if name[0:1] == "A" {
			a++
		}
		if name[0:1] == "R" {
			r++
		}
		if name[0:1] == "C" {
			c++
		}
		if name[0:1] == "H" {
			h++
		}
	}

	l := []int64{m, a, r, c, h}
	res := int64(0)

	for i := range p1 {
		res += l[p1[i]] * l[p2[i]] * l[p3[i]]
	}

	fmt.Println(res)
}

type Reader struct {
	rdr  *bufio.Reader
	size int
}

func NewReader(size int) *Reader {
	return &Reader{
		bufio.NewReaderSize(os.Stdin, size),
		size,
	}
}

func ReadInt() (i int) {
	fmt.Scan(&i)
	return
}

func ReadLine(r *Reader) string {
	buf := make([]byte, 0, r.size)
	for {
		line, isPrefix, err := r.rdr.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}


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

using namespace std;

int main(){
	int N; cin >> N;
	
	vector<int> monsters, savers;
	for(int i = 0; i < N + 1; i++){
		int monsterNum; cin >> monsterNum;
		monsters.push_back(monsterNum);
	}
	for(int i = 0; i < N; i++){
		int saverNum; cin >> saverNum;
		savers.push_back(saverNum);
	}

	long long ans = 0;
	for(int i = 0; i < N; i++){
		if(monsters[i] >= savers[i]){
			ans += savers[i];
		}
		else{
			savers[i] = savers[i] - monsters[i];
			ans += monsters[i];

			if(monsters[i + 1] >= savers[i]){
				ans += savers[i];
				monsters[i + 1] = monsters[i + 1] - savers[i];
			}
			else{
				ans += monsters[i + 1];
				monsters[i + 1] = 0;
			}
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
#define mod 1000000007
// int findLowerBound(
//     vector<pair<int, int>> &arr,
//     pair<int, int> &p)
// {

//     auto low = lower_bound(arr.begin(),
//                            arr.end(), p);

//     return low - arr.begin();
// }
// int findUpperBound(
//     vector<pair<int, int>> &arr,
//     pair<int, int> &p)
// {
//     auto up = upper_bound(arr.begin(),
//                           arr.end(), p);

//     return up - arr.begin();
// }
// bool vis[200005];
// vector<int> vec[2000005];
// int child[2000005];
// int parent[2000005];
// int div1[100005];
// void dfs(int node)
// {
//     vis[node] = 1;
//     for (int i = 0; i < vec[node].size(); i++)
//     {
//         if (!vis[vec[node][i]])
//         {
//             parent[vec[node][i]] = node;
//             dfs(vec[node][i]);
//             //   child[node] += child[vec[node][i]];
//         }
//     }
// }
// void bfs(int node)
// {
//     queue<int> qu;
//     qu.push(node);
//     vis[1] = 1;
//     while (!qu.empty())
//     {
//         int top = qu.front();
//         //cout << qu.front() << "\n";
//         qu.pop();
//         vis[top] = 1;
//         for (int i = 0; i < vec[top].size(); i++)
//         {
//             if (!vis[vec[top][i]])
//             {
//                 parent[vec[top][i]] = top;
//                 qu.push(vec[top][i]);
//                 vis[vec[top][i]] = 1;
//             }
//         }
//     }
// }
// void belman(int n, int m, vector<pair<int, pair<int, int>>> vec, int dis[])
// {
//     for (int i = 0; i <= n + m - 1; i++)
//     {
//         for (int j = 0; j < vec.size(); j++)
//         {
//             int u = vec[j].second.first;
//             int v = vec[j].second.second;
//             int w = vec[j].first;

//             if (dis[u] + w < dis[v])
//             {
//                 dis[v] = dis[u] + w;
//             }
//         }
//     }
// }
// int fun(int a, int b)
// {
//     if (a > b)
//         return 0;
//     if (a == b)
//         return 1;
//     else
//     {
//         return fun(a + 1, b) + fun(a, b - a);
//     }
// }

// Required function
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    //string str;
    //cin >> str;
    //  int n = str.length();
    int n;
    cin >> n;
    // int ans = 0;
    int arr[n];
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    vector<int> vec;
    int carry = 0;
    for (int i = 0; i <= 100; i++)
    {
        int one = 0;

        for (int j = 0; j < n; j++)
        {
            if (arr[j] & 1)
                one++;
            arr[j] /= 2;
        }
        int p = one * (n - one);
        // ans = (ans + (((int)pow(2, 61 - i) % mod) * p) % mod) % mod;
        int sum = p + carry;
        vec.push_back(sum % 2);
        carry = sum / 2;
    }
    int ans = 0;
    int sum = 1;
    for (int i = 0; i < vec.size(); i++)
    {
        ans = (ans + vec[i] * sum) % mod;
        sum = (sum * 2) % mod;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 5956
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

int main(){
    string s; cin >> s;
    int ans = s.size() - 2;
    cout << s[0] << ans << s[s.size()-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    long long *A;
    cin >> n;
    A = new long long[n];
    for (int i = 0; i < n; i++)
        cin >> A[i];
    int  f = 0;
    int ans = 1;
    for (int i = 0; i < n-1; i++) {
        if (f == 0) {
            if (A[i] < A[i+1])
                f = 1;
            else if (A[i] > A[i+1])
                f = -1;
        }
        else if (f == -1 && A[i] < A[i+1]) {
            ans++;
            f = 0;
        }
        else if (f == 1 && A[i] > A[i+1]) {
            ans++;
            f = 0;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
a=[int(input()) for _ in range(n)]
ans=[-a[0]]
ansl=1
from bisect import bisect_right
for ai in a[1:]:
  tmp=bisect_right(ans,-ai)
  if tmp<ansl:
    ans[tmp]=-ai
  else:
    ans.append(-ai)
    ansl+=1
print(ansl)

Measured memory_bytes: 85188
#include <cstdio>
#include <algorithm>
using namespace std;
int an, bn;
int a[5000], b[5000];
int c(int num, int s) {
    for (int i=s; i<an; i++) {
        if (a[i]==num) return i;
    }
    return -1;
}
int main() {
    scanf("%d%d",&an,&bn);
    for (int i=0; i<an; i++) scanf("%d",&a[i]);
    for (int i=0; i<bn; i++) scanf("%d",&b[i]);
    int res=0;
    for (int i=0; i<an; i++) {
        for (int j=0; j<bn; j++) {
            if (a[i]==b[j]&&j==bn-1) {
                res=max(res, 1);
            } else if (a[i]==b[j]) {
                int pos=j+1, s=i+1;
                while (true) {
                    int ans=c(b[pos],s);
                    if (ans==-1) {
                        res=max(res,pos-j);
                        break;
                    } else {
                        pos++;
                        s=ans+1;
                    }
                }
            }
        }
    }
    printf("%d\n",res);
}

Measured memory_bytes: 752
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int num[5];
    cin >> num[0] >> num[1] >> num[2] >> num[3] >> num[4];
    sort(num, num+5, greater<int>());
    printf("%d %d %d %d %d\n", num[0], num[1], num[2], num[3], num[4]);
}


Measured memory_bytes: 3256
"use strict";

function Main(input) {
  let lines = input.trim().split("\n");
  let monstarInfo = lines[0].split(" ").map(x => x - 0);
  let monsterPower = monstarInfo[0];
  let attackNum = monstarInfo[1];
  let araInfo = lines[1].split(" ").map(x => x - 0).sort().reverse();
  let ans = "No";
  let sum = 0;
  for(let i = 0; i < attackNum; i++){
    sum += araInfo[i];
   	if( sum  >= monsterPower){
      ans = 'Yes';
      break;
  	}
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

int a[222222];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", a + i), a[i] -= i;
	sort(a, a + n);
	long r = 0;
	for (int i = 0; i < n; i++)
		r += abs(a[i] - a[n / 2]);
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

int main() {
	int n, r;
	while(cin >> n >> r, n || r) {
		vector<int> v(n);
		iota(v.rbegin(), v.rend(), 1);
		
		for(int i = 0; i < r; ++i) {
			int p, c;
			cin >> p >> c;
			p--;
			auto temp = v;
			for(int j = 0; j < c; ++j) {
				temp[j] = v[p + j];
			}
			
			for(int j = 0; j < p; ++j) {
				temp[c + j] = v[j];
			}
			
			swap(v, temp);
		}
		cout << v[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll a;
    cin >> a;
    ll ans = 0;
    for (ll i = 2; i < sqrt(a) + 2; i++) {
        ll zans = 0;
        while (a % i == 0) {
            a /= i;
            zans++;
        }
        ll t = 1;
        while (zans >= t) {
            zans -= t;
            t++;
            ans++;
        }
    }
    if (a != 1)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
typedef long long ll;
long long a[2100],b[2100],c[2100];
ll p(ll a,ll b,ll mod)
{
    ll ans=0;
    for(;b;b>>=1)
    {
        if(b&1)
        {
            ans=ans+a%mod;
        }
        a=a*2%mod;
    }
    return ans%mod;
}
int main(){
	long long n,m;long long ans=0,s=0,ss=0;
	cin>>n>>m;
	for(long long i=0;i<n;i++) cin>>a[i];
	for(long long i=0;i<n-1;i++) {
		for(long long j=i+1;j<n;j++) {
			if(a[i]>a[j]) b[i]++; 
		}
	}
	for(long long i=0;i<n;i++) {
		for(long long j=0;j<n;j++) {
			if(a[i]>a[j]) c[i]++;
		}
	}
	for(int i=0;i<n;i++){
		ans=(ans+b[i]*m+p(m*(m-1)/2,c[i],mod));
	}
	cout<<ans%mod<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  vll ps(n);
  vll rev(n);
  rep(i, n) {
    cin >> ps[i];
    ps[i]--;
    rev[ps[i]] = i;
  }
  ll cnt = 1;
  ll mv = 0;
  rep(i, n - 1) {
    if (rev[i] > rev[i + 1]) {
      chmax(mv, cnt);
      cnt = 1;
    } else
      cnt++;
  }
  chmax(mv, cnt);

  cout << n - mv << endl;

  return 0;
}


Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		int[] a=fs.readArray(n);
		long money=1000;
		for (int start=0; start+1<n; start++) {
			int end=start+1;
			if (a[end]<=a[start]) continue;
//			while (end<n && a[end]>a[start]) {
//				end++;
//			}
			long times=money/a[start];
			money%=a[start];
			money+=a[end]*times;
//			start=end-1;
		}
		System.out.println(money);
	}
	
	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}

}


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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e20;
const int INF = 1e9;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  priority_queue<ll, VL, greater<ll> > r;
  priority_queue<ll> l;
  VL c(n);
  ll ans, sumr, suml;
  sumr = suml = 0;
  REP(i, n){
    ll a;
    cin >> a;
    r.push(a);
    sumr += a;
  }
  REP(i, n){
    cin >> c[i];
  }
  REP(i, n){
    ll a;
    cin >> a;
    l.push(a);
    suml += a;
  }

  VL rsum(n+1, sumr), lsum(n+1, suml);
  REP(i, n){
    ll t = r.top();
    if(t < c[i]){
      r.pop();
      r.push(c[i]);
      sumr += c[i] - t;
      rsum[i+1] = sumr;
    }
  }

  REP(i, n){
    ll t = l.top();
    if(t > c[n-i-1]){
      l.pop();
      l.push(c[n-i-1]);
      suml += c[n-i-1] - t;
      lsum[n-i-1] = suml;
    }
  }

  ans = rsum[0] - lsum[0];
  REP(i, n+1){
    ans = max(ans, (ll)(rsum[i] - lsum[i]));
  }

  out(ans);
  return 0;
}


Measured memory_bytes: 4340
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <iterator>

using namespace std;
const long long INF = 1e18;

class UnionFind
{
public:
    static UnionFind Create(int iTotalNumber)
    {
        return UnionFind(iTotalNumber);
    }

    void Init(const int iTotalNum)
    {
        mParent.resize(iTotalNum);
        mRank.resize(iTotalNum);
        mSize.resize(iTotalNum);
        for (int i = 0; i < iTotalNum; i++)
        {
            mParent[i] = i;
            mRank[i] = 0;
            mSize[i] = 1;
        }
    }

    int FindParent(const int iRoot)
    {
        if (iRoot == mParent[iRoot])
        {
            return iRoot;
        }
        else
        {
            mParent[iRoot] = FindParent(mParent[iRoot]);
            return mParent[iRoot];
        }
    }

    void UniteGroup(const int iRoot1, const int iRoot2)
    {
        int parent1 = this->FindParent(iRoot1);
        int parent2 = this->FindParent(iRoot2);
        if (parent1 == parent2) return;

        if (mRank[parent1] < mRank[parent2])
        {
            mParent[parent1] = parent2;
            mSize[parent2] = mSize[parent1] + mSize[parent2];
        }
        else if (mRank[parent2] < mRank[parent1])
        {
            mParent[parent2] = parent1;
            mSize[parent1] = mSize[parent1] + mSize[parent2];
        }
        else if (mRank[parent2] == mRank[parent1])
        {
            mParent[parent2] = parent1;
            mSize[parent1] = mSize[parent1] + mSize[parent2];
            mRank[parent2]++;
        }
        //else should never happen
    }

    bool AreInTheSameGroup(const int iRoot1, const int iRoot2)
    {
        return FindParent(iRoot1) == FindParent(iRoot2);
    }

    int GetGroupSize(int iRoot)
    {
        int parent = FindParent(iRoot);
        return mSize[parent];
    }

    int GetMaxTreeSize() 
    {
        int maxSize = -1;
        for (const auto& parent : mParent)
        {
            maxSize = max(maxSize, GetGroupSize(parent));
        }
        return maxSize;
    }

private:
    UnionFind(int iTotalNumber)
    {
        this->Init(iTotalNumber);
    }


    std::vector<int> mParent;
    std::vector<int> mRank;
    std::vector<int> mSize;
};

int main(void)
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    vector<int> B(M);
    UnionFind uf = UnionFind::Create(N);
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        A[i] = a-1;
        B[i] = b-1;
        uf.UniteGroup(A[i], B[i]);
    }

    cout << uf.GetMaxTreeSize() << endl;
   
    return 0;
}

Measured memory_bytes: 7140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; cin >> N;
    int AC = 0;
    int WA = 0;
    int TLE = 0;
    int RE = 0;
    vector<string> data(N);
    for(int i = 0; i < N; i++){
        string tmp; cin >> tmp;
        data[i] = tmp;
    }
    sort(data.begin(), data.end());

    int j = 0;
    while(true){
        if(j == N) break;
        string tmp = data[j];
        if(tmp == "AC"){
            AC ++;
            j ++;
        }
        else break;
    }
    while(true){
        if(j == N) break;
        string tmp = data[j];
        if(tmp == "RE"){
            RE ++;
            j ++;
        }
        else break;
    }
    while(true){
        if(j == N) break;
        string tmp = data[j];
        if(tmp == "TLE"){
            TLE ++;
            j ++;
        }
        else break;
    }
    while(true){
        if(j == N) break;
        string tmp = data[j];
        if(tmp == "WA"){
            WA ++;
            j ++;
        }
        else break;
    }

    cout << "AC" << " " << "x" << " " << AC << endl;
    cout << "WA" << " " << "x" << " " << WA << endl;
    cout << "TLE" << " " << "x" << " " << TLE << endl;
    cout << "RE" << " " << "x" << " " << RE << endl;
}

Measured memory_bytes: 6432
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;
vector<int> prime, res;
const int VMAX = 55555;

bool is_prime(int num){
    if (num < 2) return false;
    else if (num == 2 || num == 3) return true;
    rep(i,prime.size()){
        if (num%prime[i] == 0) return false;
    }
    int temp = prime.back();
    while (temp < num){
        if (num%temp == 0) return false;
        ++temp;
    }
    return true;
}

void make_primes(){
    rep(i,VMAX+1){
        if (is_prime(i)) prime.push_back(i);
    }
}



 
int main() {
    int n;
    cin >> n;
    make_primes();
    int i = 0;
    while (n > 0){
        string s = to_string(prime[i]);
        char s_back = s[s.length()-1];
        if (s_back == '1'){
            cout << s << " ";
            n -= 1;
        }
        ++i;
    }

    return 0;
}

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

const int N = 200005;
const int INF = 1000000000;
typedef long long i64;

int a[N], b[N], wa[N], wb[N], bit[35];

int main ()
{
    int n, l, r, mid, L;
    int ans = 0;
    i64 res;
    scanf("%d", &n);
    bit[0] = 1; for (int i = 1; i <= 30; ++i) bit[i] = bit[i - 1] << 1;
    for (int i = 1; i <= n; ++i) scanf("%d", a + i);
    for (int i = 1; i <= n; ++i) scanf("%d", b + i);
    for (int i = 1; i <= 28; ++i) {
        res = 0;
        for (int j = 1; j <= n; ++j) wa[j] = a[j] % bit[i], wb[j] = b[j] % bit[i];
        sort(wb + 1, wb + n + 1);
        for (int j = 1; j <= n; ++j) {
            l = 1; r = n + 1;
            while (l < r) {
                mid = (l + r) >> 1;
                if (l == mid) break;
                if (wb[mid] < bit[i] + bit[i - 1] - wa[j]) l = mid;
                else r = mid;
            }
            if (wb[l] < bit[i] + bit[i - 1] - wa[j]) res += n - l;
            else res += n;
            //if (i <= 3) printf("H %d %d\n", i, bit[i] + bit[i - 1] - wa[j]);
            l = 1; r = n + 1;
            while (l < r) {
                mid = (l + r) >> 1;
                if (l == mid) break;
                if (wb[mid] < bit[i - 1] - wa[j]) l = mid;
                else r = mid;
            }
            if (wb[l] < bit[i - 1] - wa[j]) L = l + 1;
            else L = 1;
            if (L > n || wb[L] >= bit[i] - wa[j]) continue;

            l = 1; r = n + 1;
            while (l < r) {
                mid = (l + r) >> 1;
                if (l == mid) break;
                if (wb[mid] < bit[i] - wa[j]) l = mid;
                else r = mid;
            }
            res += (l - L + 1);
        }
        //if (i <= 3) printf("%d %d\n", i, res);
        if (res & 1) ans |= bit[i - 1];
    }
    res = 0;
    for (int i = 1; i <= n; ++i) {
        l = 1; r = n + 1;
        while (l < r) {
            mid = (l + r) >> 1;
            if (l == mid) break;
            if (wb[mid] < bit[28] - wa[i]) l = mid;
            else r = mid;
        }
         if (wb[l] < bit[28] - wa[i]) res += n - l;
        else res += n;
    }
    if (res & 1) ans |= bit[28];
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#include <queue>

#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Mabs(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define Abs(a) (a)>0?(a):(-(a))
template <typename QvQ> inline QvQ Min2(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max2(QvQ a,QvQ b){if(a>b) return a;return b;}
template <typename QvQ> inline QvQ Abs2(QvQ a){if(a>0) return a;return -a;}

#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f
#define lldinf 0x3f3f3f3f3f3f3f3f

#define ll long long
#define us unsigned
#define rei register int
#define inv inline void
#define inb inline bool
#define ini inline int

#define bl putchar(' ')
#define ed putchar('\n')
#define test std::cout<<"this:"
#define card system("pause")

#define read2(a,b) read(a),read(b)
#define read3(a,b,c) read(a),read(b),read(c)

#define MAXN 100005

//char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)

template <typename QvQ>inv read(QvQ &x)
{
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
using namespace std;
char a[1000005];
int main()
{
	scanf("%s",a+1);int len=strlen(a+1);
	putchar(a[1]),write(len-2),putchar(a[len]);
	return 0;
}

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

int main() {
  long long int n,k,answer=1;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    if(i==0){
      answer*=k;
    }
    if(i>0){
      answer*=k-1;
    }
  }
  cout<<answer<<endl;
}

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

int main(){
    string s, t;
    cin >> s >> t;
    
    if (s == t.substr(0, (int)s.length())) {
        if(s.length() + 1 == t.length()){
            cout << "Yes" << endl;
            return 0;
        }
    }


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

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	private static List<Node> T = new ArrayList<Main.Node>();

	private static class Node {
		public int key;
		public Node left;
		public Node right;
	}

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String command = br.readLine().trim();

			if (command.equals("print")) {
				print();
			} else {
				Node node = new Node();
				node.key = Integer.parseInt(command.split(" ")[1]);
				insert(node);
			}
		}

		if (br != null) {
			br.close();
			br = null;
		}
	}

	private static void print() {
		Node root = T.size() == 0 ? null : T.get(0);

		List<Integer> tmp = new ArrayList<Integer>();
		inorder(root, tmp);
		for (int i : tmp) {
			System.out.print(" " + i);
		}
		System.out.println();

		tmp = new ArrayList<Integer>();
		preorder(root, tmp);
		for (int i : tmp) {
			System.out.print(" " + i);
		}
		System.out.println();
	}

	private static void inorder(Node node, List<Integer> ret) {
		if (node == null) {
			return;
		}

		inorder(node.left, ret);
		ret.add(node.key);
		inorder(node.right, ret);
	}

	private static void preorder(Node node, List<Integer> ret) {
		if (node == null) {
			return;
		}

		ret.add(node.key);
		preorder(node.left, ret);
		preorder(node.right, ret);
	}

	private static void insert(Node z) {
		Node y = null;
		Node x = T.size() == 0 ? null : T.get(0);
		while (x != null) {
			y = x;
			if (z.key < x.key) {
				x = x.left;
			} else {
				x = x.right;
			}
		}
		if (y == null) {
			T.add(z);
		} else if (z.key < y.key) {
			y.left = z;
		} else {
			y.right = z;
		}
	}
}

Measured memory_bytes: 249212
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String sl[] = s.split(" ");
            final int num = sl.length;

            int a[] = new int[num];

            for (int i = 0; i < num; i++) {
                a[i] = Integer.parseInt(sl[i]);
            }

            Arrays.sort(a);

            int sum = 0;
            for (int i = 0; i < 2; i++) {
                sum += a[i];
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 22484
#include <iostream>
#include <cmath>
using namespace std;
int isprime(int a)
{
    int tmp=a/10;

    if(a==1||a==2) return 1;
    else
        for(int i=2;i<=int(sqrt(a))+1;i++)
        {   if(a%i==0) return 0;
            else if(i==int(sqrt(a))+1) return 1;
        }
}
int main()
{
    int num;
    cin >>num;
    int a,sum=0;
    for(int i=0;i<num;i++)
    {
        cin>>a;
        sum+=isprime(a);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3100
program main
	implicit none
    integer::a,b
    read(*,*)a,b
    if(a==b)then
    	write(*,*)'Draw'
    else if(a==1)then
    	write(*,*) 'Alice'
    else if(b==1)then
    	write(*,*) 'Bob'
    else if(a>b)then
    	write(*,*) 'Alice'
    else
    	write(*,*) 'Bob'
    end if
    stop
end program main

Measured memory_bytes: 2856
#include <iostream>
#include <cstring>
#include <cmath>

using namespace std;

int check(char s[])
{
    char str[]="zyxwvutsrqponmlkjihgfedcba";
    for (int i=0;i<strlen(s);i++)
        if (s[i]!=str[i]) return 0;
    return 1;
}

int main()
{
    int via[30];
    char s[100];

    memset(via,0,sizeof(via));
    scanf("%s",s);
    int l=strlen(s);
    if (l==26 && check(s)) printf("-1");
    else
    {
        int temp;
        for (int x=0;x<l;x++)
        {
            temp=s[x];
            via[temp-'a']=1;
        }
        temp=0;
        while (via[temp] && temp<26) temp++;
        if (temp<26)
        {
            printf("%s%c",s,temp+'a');
            return 0;
        }
        else
        for (int i=l-1;i>=0;i--)
        {
            temp=s[i]-'a';
            while (via[temp] && temp<26) temp++;
            via[s[i]-'a']=0;
            if (temp<26 && !via[temp])
            {
                for (int j=0;j<i;j++) printf("%c",s[j]);
                printf("%c",temp+'a');
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000
using namespace std;
typedef long long ll;

int main(){
  ll x; cin >> x;
  ll n = ceil((-1+sqrt(8*x+1))/2);
  cout << n << endl;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s: Vec<char> = itr.next().unwrap().chars().collect();
    let n = s.len();
    let mut t = vec![0u64; n + 1];
    for i in 0..n {
        if s[i] == 'B' {
            t[i] += 1;
        }
        t[i + 1] += t[i];
    }
    let mut ans = 0u64;
    for i in 0..n {
        if s[i] == 'W' {
            ans += t[i];
        }
    }
    println!("{}", ans);
}


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

struct P
{
    int x,y,z;
    bool operator<(const P &a)const{
              return x>a.x;
    }
};

vector<int> v[211];
//bitset<4001000> b;
int a,c,i,b,k,n,d,e,m;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int o[1111][1220];
int l[110];
int j[2112];
int dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};


long long x,y,mod=1000000007;
long long z;

P u[100550];
stack<int> s;

//set<int> s;
queue<int> q;


//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p[11];
//list<int> l;

string r;
//char r[33];
//deque<int> de;
bool as(int a,int b)
{
    return b<a;
}

int f(int a)
{
    if(a%2) return 0;
    return f(a/2)+1;
}

int main()
{
    scanf("%d %d %d",&a,&l[1],&l[2]);
    a*=2;
    for(int i=1;i<3;i++)
    {
        n=f(l[i])/2;
        for(int t=0;t<a;t++)
            for(int w=0;w<a;w++)
        {
            if(t%(2<<n)<(1<<n)&&w%(2<<n)<(1<<n))
                o[t][w]+=i;
            if(f(l[i])%2&&t%(2<<n)<(1<<n)&&w%(2<<n)>=(1<<n))
                o[t][w]+=i;
            if(f(l[i])%2==0&&t%(2<<n)>=(1<<n)&&w%(2<<n)>=(1<<n))
                o[t][w]+=i;
        }
    }
    for(int t=0;t<a;t++)
        for(int w=0;w<a;w++)
        {
            //printf("%d ",o[t][w]);
        j[o[t][w]]++;
        }
    for(int i=0;i<4;i++)
        if(j[i]>=a*a/4)
    {
        int p=0;
        for(int t=0;t<a;t++)
            for(int w=0;w<a;w++)
            if(o[t][w]==i)
            {printf("%d %d\n",t,w);
                p++;
                if(p==a*a/4)
                return 0;
            }
    }
}








Measured memory_bytes: 3840