akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
  char buf[210];
  int bi,n,eqc,ti;

  cin >> n;

  for (int i=0;i<n;i++){
    bi=0;
    cin >> buf;
    if (buf[bi++]!='>') {
      cout << "NA" << endl;
      continue;
    }
    if (buf[bi]=='\''){
      bi++;
      eqc=0;
      if (buf[bi]!='='){
	cout << "NA" << endl;
	continue;
      }
      while (buf[bi+eqc]=='=')eqc++;
      if (buf[bi+eqc]!='#'){
	cout << "NA" << endl;
	continue;
      }
      bi += eqc+1;
      for (ti=0;ti<eqc;ti++)
	if (buf[bi+ti]!='=')break;
      if (ti <eqc){
	cout << "NA" << endl;
	continue;
      }
      bi+=ti;
      if (buf[bi]=='~'&&buf[bi+1]=='\0')cout << "A" << endl;
      else cout << "NA" << endl;
    }else if(buf[bi]=='^'){
      bi++;
      //cout <<"dbg "<< buf[bi] << buf[bi+1] << endl;
      if(buf[bi]!='Q'||buf[bi+1]!='='){
	cout << "NA" << endl;
	continue;
      }
      bi+=2;
      while (buf[bi]=='Q'&&buf[bi+1]=='=')bi +=2;
      //cout <<"dbg "<< buf[bi] << buf[bi+1] << endl;
      if (buf[bi]=='~'&&buf[bi+1]=='~'){
	if (buf[bi+2]=='\0')cout << "B" << endl;
	else cout << "NA" << endl;
      }else cout << "NA" << endl;
    }else{
      cout << "NA" << endl;
      continue;
    }
  }
  return 0;
}

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

int main(){
    while(true){
        int t, p, r;
        int tid, pid, ptime;
        string message;
        int team[50][2];
        int problem[50][10];
        set<pair<int, pair<int, int> > > score;
        set<pair<int, pair<int, int> > >::iterator it;
        cin >> t >> p >> r;
        if(!(t||p||r)) break;
        for(int i=0;i<t;++i){
            team[i][0]=0;
            team[i][1]=0;
        }
        for(int i=0;i<p;++i){
            for(int j=0;j<t;++j){
                problem[j][i] = 0;
            }
        }
        for(int i=0;i<r;++i){
            cin >> tid >> pid >> ptime >> message;
            if(message=="CORRECT"){
                ++team[tid-1][1];
                team[tid-1][0] += problem[tid-1][pid-1]*1200 + ptime;
            }else{
                ++problem[tid-1][pid-1];
            }
        }
        for(int i=0;i<t;++i){
            score.insert(make_pair(10-team[i][1], make_pair(team[i][0], i)));
        }
        it = score.begin();
        while(it!=score.end()){
            cout << (*it).second.second + 1 << ' ';
            cout << -(*it).first+10 << ' ';
            cout << (*it).second.first << endl;
            ++it;
        }
    }
}

Measured memory_bytes: 1216
#include <stdio.h>

main()
{
  int j, i, length, key;
  int A[100];
  
  scanf("%d", &length);
  
  for(i = 0; i < length; i++)
    {
      scanf("%d", &A[i]);
    }

  for(j = 0; j < length; j++)
    {
      if(j == length - 1)
	{
	  printf("%d\n", A[j]);
	}
      else
	{
	  printf("%d ", A[j]);
	}
    }

  for(i = 1; i < length; i++)
    {
      key = A[i];
      j = i - 1;
      while(j >= 0 && A[j] > key)
	{
	  A[j + 1] = A[j];
	  j = j - 1;
	}
      A[j + 1] = key;
      for(j = 0; j < length; j++)
	{
	  if(j == length - 1)
	    {
	      printf("%d\n", A[j]);
	    }
	  else
	    {
	      printf("%d ", A[j]);
	    }
	}
    }
  return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

//B

#define MAX 2000
int n;
ll L[MAX];

void solve() {

}

int main() {
  cin >> n;
  rep(i,n) cin >> L[i];
  sort(L,L+n);
  int cnt = 0;
  rep(i,n) {
    REP(j,i+1,n) {
      REP(k,j+1,n) {
	set<ll> S;
	S.insert(L[i]);
	S.insert(L[j]);
	S.insert(L[k]);
	if( S.size() != 3 ) {
	  continue;
	}
	ll a = L[i];
	ll b = L[j];
	ll c = L[k];

	if( a + b > c && b + c > a && c + a > b ) {
	  ++cnt;
	}
	
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int main() {
    int A;
    int B;
    cin >> A >> B;
    if ( (A + B)%2 != 0) {
        cout << "IMPOSSIBLE" << endl;
    } else  {
        cout << (A + B)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pairs;

 priority_queue <ll> pq ;
 
int main()
{
    //freopen("problem_name.out", "w", stdout) ;
    //freopen("problem_name.in", "r", stdin) ;
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
 
    //int t ; cin >> t ; while(t--){}
    ll n , m ; cin >> n >> m ;
    for ( int i = 0 ; i < n ; i++ )
    {
      ll a ; cin >> a ;
      pq.push(a) ;
    }
    while(m--)
    {
      ll x = pq.top() ;
      x/=2 ;
      pq.pop() ;
      pq.push(x) ;
    }
    ll sum = 0 ;
    while( pq.size() )
    {
      sum+= pq.top() ;
      pq.pop() ;
    }
    cout << sum ;
}

Measured memory_bytes: 1400
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

type state func(int) state

func main() {
	defer stdout.Flush()
	n, a := readLengthAndSlice()
	ans := 1
	var increasing, decreasing, undetermined state
	increasing = func(i int) state {
		if a[i-1] > a[i] {
			ans++
			return undetermined
		}
		return increasing
	}
	decreasing = func(i int) state {
		if a[i-1] < a[i] {
			ans++
			return undetermined
		}
		return decreasing
	}
	undetermined = func(i int) state {
		if a[i-1] < a[i] {
			return increasing
		} else if a[i-1] > a[i] {
			return decreasing
		}
		return undetermined
	}
	f := undetermined
	for i := 1; i < n; i++ {
		f = f(i)
	}
	println(ans)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 3072
macro_rules! input {
        (source = $s:expr, $($r:tt)*) => {
            let mut iter = $s.split_whitespace();
            let mut next = || { iter.next().unwrap() };
            input_inner!{next, $($r)*}
        };
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }
     
    macro_rules! input_inner {
        ($next:expr) => {};
        ($next:expr, ) => {};
     
        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }
     
    macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };
     
        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };
     
        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };
     
        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };
     
        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }
     
    fn main() {
        use std::cmp;
        input! {
            n: i64,
            a: [i64; n + 1],
            b: [i64; n]
        };
        let mut total_monsters_defeated = 0;
        for i in 0..n as usize {
            if b[i] == 0 {
                continue;
            }
     
            if b[i] <= a[i] {
                total_monsters_defeated += b[i];
                continue;
            }
     
            if b[i] <= a[i] + a[i + 1] {
                total_monsters_defeated += b[i];
                b[i] -= a[i];
                a[i + 1] -= b[i];
                continue;
            }
     
            total_monsters_defeated += a[i] + a[i + 1];
            a[i + 1] = 0;
        }
        println!("{}", total_monsters_defeated);
    }

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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

void solve () {
	int n,p;
	cin >> n >> p;
	string str;
	cin >> str;
	ll ans = 0;
	if (p == 2 || p == 5) {
		for (int i = 0;i < n;++i) {
			int digit = str[i]-'0';
			if (digit%p == 0) ans += i+1;
		}
		cout << ans << '\n';
		return;
	}
	ll suf = 0;
	ll powerOf10 = 1;
	vi cnt(p,0);
	cnt[suf]++;
	for (int i = n-1;i >= 0;--i) {
		int digit = str[i]-'0';
		suf = (suf+digit*powerOf10)%p;
		powerOf10 = (powerOf10*10)%p;
		ans += cnt[suf];
		cnt[suf]++;
	}
	cout << ans << '\n';
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}



Measured memory_bytes: 3720
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_imports)]
use std::cmp;

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
    }
    let mut n = [a, b, c];
    n.sort();
    // println!("{:?}", n);
    println!("{}", n[2] * 10 + n[1] + n[0]);
}


Measured memory_bytes: 4352
n=int(input())
A=list(map(int,input().split()))
if A[0]>0:
  S=A[0]
  ans_1=0
else:
  S=1
  ans_1=1-A[0]
for i in A[1:]:
  if S*(S+i)<0:
    S+=i
  else:
    ans_1+=abs(S+i)+1
    if S<0:
      S=1
    else:
      S=-1
if A[0]<0:
  S=A[0]
  ans_2=0
else:
  S=-1
  ans_2=A[0]+1
for i in A[1:]:
  if S*(S+i)<0:
    S+=i
  else:
    ans_2+=abs(S+i)+1
    if S<0:
      S=1
    else:
      S=-1
print(min(ans_1,ans_2))

Measured memory_bytes: 14468
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*

*/


ll p2[100010];
//p2[i]:2のi乗
/*

string all1(string s){
    string tmp="";
    rep(i,s.size()-1){
        tmp += "1";
    }
    return tmp;
}

string headcut(string s){
    if(s=="0") return "0";
    else{
        string tmp="";
        bool b=false;
        for(ll i=1; i<s.size(); i++){
            if(!b && s[i]=='1'){
                b=true;
                tmp = tmp + '1';
            }
            else if(b){
                tmp = tmp + s[i];
            }
        }
        if(!b) tmp = '0';
        return tmp;
    }
    
}

ll dp(string s){
    bool b=true;
    rep(i,s.size()){
        if(s[i]!='1') b=false;
    }
    if(b) return p2[s.size()];
    else if(s=="0") return 1;
    else{
        return ( dp(all1(s)) + 2*dp(headcut(s)) )%MOD;
    }
    
}
*/

void solve(){

    
    ll p=1;
    p2[0]=1;
    for(ll i=1; i<100010; i++){
        p2[i]=(p2[i-1]*3) % MOD;
    }
    
    string l;
    cin >> l;

    //cout << all1("1001001") << " " << headcut("1000") << endl;

    //cout << p2[0] << " " << p2[1] << " " << p2[2] << endl;
    /*
    ll ans = dp(l)%MOD;
    cout << ans << endl;
    */

    ll tmp = 1;
    ll siz = l.size();

    for(ll i=siz-1; i>=0; i--){
        if(l[i]=='1') tmp = (p2[siz-1-i] + tmp*2) % MOD;
    }

    cout << tmp << endl;
    
}

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

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vint;
int main() {
  ll n;
  string s;
  cin >> n>>s;
  vint countw(n),countb(n);
  ll cb=0,cw=0;
  for (ll i=0;i<n;i++) {
    if (s[i]=='.') {
      cw++;
    }
    else {
      cb++;
    }
    countw[i]=cw;
    countb[i]=cb;
  }
  
  ll min=countw[n-1];
  for (ll i=1;i<n+1;i++) {
    if (min>countb[i-1]+countw[n-1]-countw[i-1]) {
      min = countb[i-1]+countw[n-1]-countw[i-1];
    }
  }
  
  cout << min << endl;
}

Measured memory_bytes: 3716
package main

import (
	"fmt"
)

const MaxN = 110000

var memo [MaxN]int

func main() {
	var N int
	fmt.Scan(&N)
	for i := 0; i < MaxN; i++ {
		memo[i] = -1
	}
	fmt.Println(rec(N))
}
func rec(n int) int {
	if n == 0 {
		return 0
	}
	if memo[n] != -1 {
		return memo[n]
	}
	res := n
	//for x := 1; x <= n; x++ {
	//	res = Min(res, rec(n-1)+1)
	//}

	for x := 1; x <= n; x *= 6 {
		res = Min(res, rec(n-x)+1)
	}
	for x := 1; x <= n; x *= 9 {
		res = Min(res, rec(n-x)+1)
	}
	memo[n] = res
	return res
}
func Min(a, b int) int {
	if b < a {
		return b
	}
	return a
}

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

using namespace std;

int selectionSort(vector<int> &a) {
	int n = (int)a.size();
	int mini;
	int count = 0;
	for (int i = 0; i < n; i++) {
		mini = i;
		for (int j = i; j < n; j++) {
			if (a[j] < a[mini]) mini = j;
		}
		if (i != mini) {
			swap(a[i], a[mini]);
			count++;
		}
	}
	return count;
}

void printVector(vector<int> a) {
	int n = (int)a.size();
	for (int i = 0; i < n; i++) {
		cout << a[i];
		if (i != n-1) cout << " ";
	}
	cout << endl;
}

int main() {

	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	int ans = selectionSort(a);
	printVector(a);
	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 3152
main(i,j){
  char s[11];
  for(;~scanf("%s",&s);printf("%c\n",*s))
    for(i=9;i--;)
      for(j=0;j<9;j++)
        s[j]=(s[j]+s[j+1]-2*'0')%10+'0';
  return 0;
}

Measured memory_bytes: 540
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <map>
using namespace std;
const int MaxN = 1e5;
typedef long long LL;

int n, c, k;
int a[MaxN + 5];
map<LL, LL>t, num;
int main()
{
	while(scanf("%d %d %d", &n, &c, &k) != EOF)
	{
		LL ans = 0, sum = 0;
		for(int i = 1; i <= n; i++) 
		{
			scanf("%d", &a[i]);
			t[a[i]]++;
		}
		sort(a + 1, a + n + 1);
		int l = 1, r = 1;
		for(int i = 1; i <= n; i++)
		{
			if(a[i] - a[l] > k || i - l + 1 > c)
			{
				ans++;
				l = i;
			}
		}
		printf("%lld\n", ans + 1);
		memset(a, 0, sizeof(a));
		num.clear();
		t.clear();
	}
}

Measured memory_bytes: 6912
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {
	ll n, k;
	cin >> n >> k;
	
	FOR(i, k - n + 1, k + n) {
		cout << i << " ";
	}BR;
}

Measured memory_bytes: 256
def compute():
    from sys import stdin
    N, A, B, C = list(map(int, stdin.readline().split()))
    l = list(int(stdin.readline().split()[0]) for _ in range(N))

    dp = {}
    abclist = [A, B, C]
    def f(bamboo, remain, abc):
        if remain == 0:
            if abc >= 2:
                return 0
            # print(bin(bamboo), remain, abc)
            return f(bamboo, abclist[abc+1], abc+1)

        args = (bamboo, remain, abc)
        if args in dp:
            return dp[args]
        dp[args] = 10000

        for x in range(N):
            if (bamboo & (1<<x)) == 0:
                nexbam = (bamboo | (1<<x))
                mp = abs(remain-l[x])
                dp[args] = min(dp[args], mp + f(nexbam, 0, abc))
                dp[args] = min(dp[args], 10 + f(nexbam, remain-l[x], abc))

        return dp[args]

    print(f(0, abclist[0], 0))


if __name__ == "__main__":
    compute()


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

int main() {
  int weightA, weightB, weightC, weightD;
  cin >> weightA >> weightB >> weightC >> weightD;
  int weightL = weightA + weightB;
  int weightR = weightC + weightD;

  if(weightL> weightR){
    cout <<"Left"<<endl;
  }
  else if(weightL< weightR){
    cout <<"Right"<<endl;
  }else{
    cout <<"Balanced"<<endl;
  }

}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>

using namespace std;

char a[1024][1024];
int ret[1024][1024] = {{0}};

double Pmem[7000];

int main() {
	int N;
	scanf("%d", &N);
	double * P = Pmem + 3500;
	P[0] = 1;
	for(int i=0; i<N; ++i) {
		double p;
		scanf("%lf", &p);
		double prev = 0;
		for(int j=-1-i; j<=i+1; ++j) {
			double now = P[j];
			P[j] = prev * p + P[j+1] * (1-p);
			prev = now;
		}
	}
	double p = 0;
	for(int i=1; i<=N; ++i) {
		p += P[i];
	}
	printf("%.20f\n", p);
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()
#define ll long long
#define mod 1000000007

using namespace std;

int main()
{
  vector<pair<string, int>> s(3);
  map<int, char> player;

  rep(i, 3) {
    cin >> s[i].first;
    player[i] = 65 + i;
  }

  int next = 0;
  while (1) {
    if (s[next].second == s[next].first.size()) {
      cout << player[next] << endl;
      break;
    }
    next = s[next].first[s[next].second++] - 97;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <climits>
#define Sheryang main
typedef long long ll;
#pragma GCC optimize(3)
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
int read()
{
    int x=0,f=1;	char c=getchar();
    while(c<'0'||c>'9')	{if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9')	{x=x*10+c-'0';c=getchar();}
    return x*f;
}
struct ios
{
	inline char gc()
	{
		static const int IN_LEN=1<<18|1;
		static char buf[IN_LEN],*s,*t;
		return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
	}
	template <typename _Tp> inline ios & operator >> (_Tp&x)
	{
		static char ch,sgn; ch = gc(), sgn = 0;
		for(;!isdigit(ch);ch=gc())
		{	
			if(ch==-1)return *this;sgn|=ch=='-';
		}
		for(x=0;isdigit(ch);ch=gc())x=(((x<<2)+x)<<1)+(ch^'0');
		sgn&&(x=-x); return *this;
	}
}io;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
/** keep hungry and keep calm! **/

int n,a[maxn];
ll ans;
int main(){
	n = read();
	for(int i=1;i<=n;i++)
		cin >> a[i];
	for(int i=1;i<=n;i++)
	{
		ans += a[i]/2;//相同面值的先配对 
		a[i] = a[i]%2;//可能会有剩余 
		if(i<n && a[i] && a[i+1])
		//当前剩余一张恰巧下一张也有一张 
		{
			ans++;
			a[i]--;	a[i+1]--;	
		} 
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#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 DEBUG(x) cout << #x << ": " << x << endl

void solve(long long A, long long B, long long N) {
  auto f = [&](ll x) { return A * x / B - A * (x / B); };
  cout << f(min(N, B - 1)) << endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long N;
  scanf("%lld", &N);
  solve(A, B, N);
  return 0;
}


Measured memory_bytes: 3232
#include <iostream>

using namespace std;

int main(void)
{
    long long K, A, B;
    cin >> K >> A >> B;
    long long ans = 0;
    if (A >= K + 1) ans = K + 1;
    else if (B - A <= 2) ans = K + 1;
    else
    {
        K -= (A - 1);
        ans = A;
        ans += (K / 2) * (B - A) + (K % 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[100];
int kaibun(int a,int b){
	int i,pr=1;
	for(i=a;i<=b/2;i++){
		pr*=s[i]==s[b-i-1];
	}
	return pr;
}
int main(void){
	int len,ans;
	scanf("%s",s);
	len=strlen(s);
	ans=kaibun(0,len)*kaibun(0,len/2)*kaibun(len/2+1,len+len/2+1);
	printf(ans?"Yes":"No");
	return 0;
}

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

int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int ans = A*X + B*Y;
  if(A+B>2*C){
    ans-= min(X, Y)*(A+B-2*C);
  }
  
  ans=min(ans, (max(X, Y)*2*C));
  cout << ans << endl;
}

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

int miyukiti(const void* asumisu, const void* mizuhasu) {
	int isihasu = *(const int*)asumisu, matukisu = *(const int*)mizuhasu;
	return isihasu < matukisu ? -1 : isihasu > matukisu;
}

int N;
int A[114514];

int yukinnko;
int tomatu[114514];

int mikakosi[114514];

int sumipe(int hayaminn) {
	int satorina = 0, zaasan = yukinnko - 1;
	while (satorina <= zaasan) {
		int yukati = satorina + (zaasan - satorina) / 2;
		if (tomatu[yukati] == hayaminn) return yukati;
		else if (tomatu[yukati] < hayaminn) satorina = yukati + 1;
		else zaasan = yukati - 1;
	}
	return 114513;
}

int main(void) {
	int inorinn;
	int emirinn = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (inorinn = 0; inorinn < N; inorinn++) {
		if (scanf("%d", &A[inorinn]) != 1) return 1;
		tomatu[inorinn] = A[inorinn];
	}
	qsort(tomatu, N, sizeof(*tomatu), miyukiti);
	yukinnko = 1;
	for (inorinn = 1; inorinn < N; inorinn++) {
		if (tomatu[inorinn] != tomatu[yukinnko - 1]) {
			tomatu[yukinnko++] = tomatu[inorinn];
		}
	}
	for (inorinn = 0; inorinn < N; inorinn++) {
		int kugyu = sumipe(A[inorinn]);
		mikakosi[kugyu] = !mikakosi[kugyu];
	}
	for (inorinn = 0; inorinn < yukinnko; inorinn++) {
		if (mikakosi[inorinn]) emirinn++;
	}
	printf("%d\n", emirinn);
	return 0;
}


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

int main() {
	int N;
	static long long A[200000], B[200000], BIT[30] = {}, ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < 29; i++) {
		vector<int> X, Y;
		int P = pow(2, i);
		for (int j = 0; j < N; j++) X.emplace_back(A[j] % (P * 2)), Y.emplace_back(B[j] % (P * 2));
		sort(Y.begin(), Y.end());
		for (int j = 0; j < N; j++) {
			BIT[i] += (lower_bound(Y.begin(), Y.end(), 2 * P - X[j]) - lower_bound(Y.begin(), Y.end(), P - X[j]));
			BIT[i] += (lower_bound(Y.begin(), Y.end(), 4 * P - X[j]) - lower_bound(Y.begin(), Y.end(), 3 * P - X[j]));
		}
	}
	for (long long i = 0; i < 30; i++) {
		ans += pow(2, i) * (BIT[i] % 2);
	}
	cout << ans;
}

Measured memory_bytes: 6356
# Author: cr4zjh0bp
# Created: Sat Mar 14 11:41:56 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from collections import Counter

a = na()
c = Counter(a)
print(c.most_common()[-1][0])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )

typedef pair<int,int> P;
typedef long long ll;

const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {

    ll R,G,B,N;
    cin >> R >> G >> B >> N;

    ll a,b,c,ans;
    ans = 0;
    a=b=c=0;
    while(a<=N) {
        b=0;
        while(a+b<=N) {
            if((N-a-b)%B==0) {
                ans++;
            }
            b+=G;
        }
        a+=R;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		String S = sc.next();

		if(S.length() <= K)
			System.out.println(S);
		else
			System.out.println(S.substring(0, K) + "...");

	}
}


Measured memory_bytes: 38544
# all()が標準でない言語だとできない。
# ただ、リスト内包表記が美しい
n = int(input())
a = list(map(int, input().split()))
cnt = 0
while all(i%2 == 0 for i in a):	#all()はすべてiterがtrueならtrueを返す
  a = [i/2 for i in a]			#式"i%2==0"を評価するとbool型が帰る
  cnt += 1
  
print(cnt)


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

const ll MXN=200;
ll d[MXN][MXN];
vl r;
ll N,M,R;

ll dfs(vl r){
  ll x=0;
  rep(i,R-1){
    x+=d[r[i]][r[i+1]];
  }
  return x;
}

int main() {
  cin >> N >> M >> R;
  r.resize(R);
  rep(i,R){
    cin >> r[i];
    r[i]--;
  }
  sort(r.begin(),r.end());
  rep(i,N){
    rep(j,N){
      d[i][j]=INF;
    }
  }
  ll ans=INF;
  rep(i,M){
    ll A,B,C;
    cin >> A >> B >> C;
    A--;B--;
    d[A][B]=C;
    d[B][A]=C;
  }
  rep(k,N){
    rep(i,N){
      rep(j,N){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  ans=dfs(r);
  while(next_permutation(r.begin(),r.end())){
    ans=min(ans,dfs(r));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(int i = 0;i<n;++i)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[3][n+1];
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
    for(int i = 1;i<n;++i)
    {
        dp[0][i] = a[i] + max(dp[1][i-1], dp[2][i-1]);
        dp[1][i] = b[i] + max(dp[0][i-1],dp[2][i-1]);
        dp[2][i] = c[i] + max(dp[0][i-1] , dp[1][i-1]);
    }
    cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}

Measured memory_bytes: 5560
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
  int n;
  cin >>n;
  ll a[n],sum=0;
  for(int i=0;i<n;i++) {
    cin >>a[i];
    sum+=(a[i]-1);
  }
  cout <<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
int n, k, r, s, p;
char t[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> k;
 	cin >> r >> s >> p;
 	cin >> (t+1);
 	ll sum = 0;
 	for(int i=1;i<=k;i++)
 	{
 		int j = i;
 		char pre = 0;
 		while(j<=n)
 		{
 			if(t[j]=='r') 
 			{
 				if(pre=='r') pre = 0;
 				else sum += p, pre = 'r';
 			}
			else if(t[j]=='s') 
			{
				if(pre=='s') pre = 0;
 				else sum += r, pre = 's';
			}
			else if(t[j]=='p') 
			{
				if(pre=='p') pre = 0;
 				else sum += s, pre = 'p';
 			}
			j += k;
		}
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mp make_pair
#define sqr(x) (x)*(x)
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int maxn=200007;
const ll inf=0x3f3f3f3f;
const int mod=998244353;
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
vector<int> g[maxn];
int aa[maxn],pre[maxn];
int a[maxn];
int lowbit(int x){return  x&(-x);}
int ans[maxn];
map<int,int> aaa;
void dfs(int u,int fa){
    for(int i=0;i<g[u].size();i++){
        int v=g[u][i];
        if(v^fa){
           ans[v]=1;
           queue<int> G;
           for(int i=a[v];i;i-=lowbit(i)) ans[v]=max(ans[v],aa[i]);
           int x=ans[v];aaa[ans[v]]++;
           for(int i=a[v]+1;i<=200000;i+=lowbit(i))
           G.push(aa[i]),aa[i]=max(aa[i],ans[v]+1); 
           for(int i=200000;i;i-=lowbit(i)) ans[v]=max(ans[v],aa[i]-1);
           dfs(v,u);    
           aaa[x]--;
           if(!aaa[x]) aaa.erase(x);        
           for(int i=a[v]+1;i<=200000;i+=lowbit(i))
           aa[i]=G.front(),G.pop();
        }
    }
}
int A[maxn];
int main(){
    int n=read();
    for(int i=1;i<=n;i++) A[i]=read(),a[i]=A[i];
    sort(A+1,A+n+1);
    int len=unique(A+1,A+n+1)-A-1;
    for(int i=1;i<=n;i++) a[i]=lower_bound(A+1,A+len+1,a[i])-A;
    for(int i=1;i<n;i++){
        int u=read(),v=read();
        g[u].push_back(v);
        g[v].push_back(u);
    }
    ans[1]=1;
    for(int i=a[1]+1;i<=200000;i+=lowbit(i)) aa[i]=max(aa[i],ans[1]+1);
    aaa[1]++;
    dfs(1,0);
    for(int i=1;i<=n;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 169696
#include <vector>
#include <limits>
#include <algorithm>

using namespace std;

//  RMQ
template<class T>
class RMQ
{
    int n;
    vector<T> A;

    T q(int l, int r)
    {
        T a = min(A[l], A[r-1]);
        if ((l+1)/2 < r/2)
            a = min(a, q((l+1)/2, r/2));
        return a;
    }

public:
    RMQ(int n_)
    {
        n = 1;
        while (n < n_)
            n *= 2;
        A = vector<T>(2*n, numeric_limits<T>::max());
    }

    void set(int i, T v)
    {
        A[i+n] = v;
        for (int p=(i+n)/2; p>0; p/=2)
            A[p] = min(A[2*p], A[2*p+1]);
    }

    //  [l, r)
    //  if l>=r return invalid
    T query(int l, int r, T invalid)
    {
        if (l<r)
            return q(l+n, r+n);
        else
            return invalid;
    }

    T get(int p)
    {
        return A[p+n];
    }
};

#include <iostream>

int main()
{
    int N, M;
    cin>>N>>M;
    vector<vector<int>> R(N);
    vector<vector<long long>> C(N);
    for (int i=0; i<M; i++)
    {
        int l, r;
        long long c;
        cin>>l>>r>>c;
        l--;
        r--;
        R[l].push_back(r);
        C[l].push_back(c);
    }

    RMQ<long long> D(N);
    D.set(0, 0LL);

    long long oo = numeric_limits<long long>::max();

    for (int i=0; i<N; i++)
    {
        long long d = D.query(i, N, 0LL);
        if (d<oo)
            for (int j=0; j<(int)R[i].size(); j++)
            {
                int r = R[i][j];
                long long c = C[i][j];
                if (d+c < D.get(r))
                    D.set(r, d+c);
            }
    }
    long long ans = D.get(N-1);
    cout<<(ans<oo ? ans : -1)<<endl;
}


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

int dp[41][410][410];

int main(){
	int n, ma, mb;
	cin >> n >> ma >> mb;
	vector<int>a(n), b(n), c(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	for (int k = 0;k <= 40;k++) {
		for (int i = 0;i <= 400;i++) {
			for (int j = 0;j <= 400;j++) {
				dp[k][i][j] = 1e9;
			}
		}
		dp[k][0][0] = 0;
	}
	for (int i = 0;i < n;i++) {
		for (int j = a[i];j <= 400;j++) {
			for (int k = b[i];k <= 400;k++) {
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j - a[i]][k - b[i]] + c[i]);
			}
		}
		for (int j = 0;j <= 400;j++) {
			for (int k = 0;k <= 400;k++) {
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
			}
		}
	}
	int ans = 1e9;
	for (int i = 1;i*ma <= 400 && i*mb <= 400;i++) {
		ans = min(ans, dp[n][i*ma][i*mb]);
	}
	if (ans == 1e9) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 27136
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define d double
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
   
  int k,x;
  cin>>k>>x;
  k=k*500;
  if(k>=x)
    cout<<"Yes"<<endl;
   
  else
    cout<<"No"<<endl;
    
  return 0;
}  

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#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> P;
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;
  string s;
  cin >> s;
  ll K;
  cin >> K;
  
  set<string> st;
  for(i=0; i<s.size(); i++) {
    for(j=1; j<=K; j++) {
      st.insert(s.substr(i, j));
    }
  }
  
  ll t=0;
  auto it=st.begin();
  for(ll _=0; _<K-1; _++, it++);
  pt(*it);
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
	int o=0;
	int n;
	string s;
	cin>>s;
	int sum=0;
	for(int i=0;i<3;i++){
		if(s[i]=='o'){
			sum++;
		}
	}
	cout<<sum*100+700<<endl;
}
//伊勢田=sanadayukimura"73"
//伊勢田=48
//73=48
//両方から23を引いて
//50=25
//2=1


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef vector <int> VI;
int main( void )
{
	VI a(10), b(10);
	for ( int i = 0; i < 10; i++ ) cin >> a[i];
	for ( int i = 0; i < 10; i++ ) cin >> b[i];
	sort( a.rbegin(), a.rend() );
	sort( b.rbegin(), b.rend() );
	int sa = 0, sb = 0;
	for ( int i = 0; i < 3; i++ )
	{
		sa += a[i];
		sb += b[i];
	}
	cout << sa << " " << sb << endl;
	return 0;
}

Measured memory_bytes: 0
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    vs x(3);
    rep(i,3) cin>>x[i];
    int now=0,t;
    for(;;){
        if(x[now].size()==0) break;
        t=x[now][0]-'a';
        x[now].erase(begin(x[now]));
        now=t;        
    }
    cout<<(char)(now+'A')<<endl;
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

C = 999
for i in H:
  tmp = T - 0.006 * i
  a = abs(tmp - A)
  if a < C:
    C = a
    x = int(H.index(i))+1
print(x)

Measured memory_bytes: 9284
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(long long N, long long K, std::vector<long long> p){
  sort(all(p));ll ans = 0;
  for (int i = 0; i < K; i++) {
    ans += p[i];
  }
  cout << ans << endl;
}

int main(){
    long long N;
				scanf("%lld",&N);
				long long K;
				scanf("%lld",&K);
				std::vector<long long> p(N);
				for(int i = 0 ; i < N ; i++){
								scanf("%lld",&p[i]);
				}
    solve(N, K, std::move(p));
      return 0;
}


Measured memory_bytes: 3708
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int Maxn=200000+20;
int n,ans;
char a[Maxn],b[Maxn];
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
int main()
{
	scanf("%s",a+1);
	scanf("%s",b+1);
	n=strlen(a+1);
	for(int i=1;i<=n;++i)
	if(a[i]!=b[i])++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4200
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

int main() {
	double a, b, x;
	cin >> a >> b >> x;
	x = x/a;
	double ang;
	if(x > a*b/2) {
		double c = b - (x-a*b/2) / a * 2;
		ang = atan2(c,a) * 180.0 / (atan(1) * 4);
	}
	else {
		double c = x / b * 2;
		ang = atan2(b,c) * 180.0 / (atan(1) * 4);
	}
	printf("%.10f\n", ang);
	return 0;
}


Measured memory_bytes: 512
def bits(int)
    res=0
    while 0<int
        res+=1 if int%2==1
        int/=2
    end
    return res
end
N,A,B,C=gets.split.map(&:to_i)
ls=N.times.map{gets.to_i}
ans=Float::INFINITY
[0,1,2].repeated_permutation(N) do |es|
    as=Array.new
    bs=Array.new
    cs=Array.new
    N.times do |i|
        as.push(i) if es[i]==0
        bs.push(i) if es[i]==1
        cs.push(i) if es[i]==2
    end
    next if as.empty? || bs.empty? || cs.empty?
    res=0
    cnt=Float::INFINITY
    (2**(as.size)).times do |i|
        next if i==0
        ii=i
        jd=0
        (as.size).times do |j|
            jd+=ls[as[j]] if ii%2==1
            ii/=2    
        end
        jd=(A-jd).abs+(bits(i)-1)*10
        cnt=jd<cnt ? jd : cnt
    end
    res+=cnt

    cnt=Float::INFINITY
    (2**(bs.size)).times do |i|
        next if i==0
        ii=i
        jd=0
        (bs.size).times do |j|
            jd+=ls[bs[j]] if ii%2==1
            ii/=2    
        end
        jd=(B-jd).abs+(bits(i)-1)*10
        cnt=jd<cnt ? jd : cnt
    end
    res+=cnt

    cnt=Float::INFINITY
    (2**(cs.size)).times do |i|
        next if i==0
        ii=i
        jd=0
        (cs.size).times do |j|
            jd+=ls[cs[j]] if ii%2==1
            ii/=2    
        end
        jd=(C-jd).abs+(bits(i)-1)*10
        cnt=jd<cnt ? jd : cnt
    end
    res+=cnt
    ans=res<ans ? res : ans
end
puts ans

Measured memory_bytes: 2044
#include <iostream>
using namespace std;
int main(void)
{
	int a,b,c[31]={0},d,e;
	for (a=0;a<28;a++)
	{
		cin>>b;
		c[b]=1;
	}
	for (a=1;a<31;a++)
	{
		if (c[a]!=1)
		{
			cout<<a<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
#define MAXN 200000
int N;


int A[MAXN],B[MAXN];


void solve(){
    pair<int,int> C[MAXN];
    rep(i,N)C[i] = make_pair(B[i],A[i]);
    sort(C,C+N);
    int time =0;
    rep(i,N){
        time += C[i].second;
        if(time>C[i].first){
            puts("No");
            return;
        }
    }
    puts("Yes");
}
int main(){
    cin >> N ;
    rep(i,N) cin >> A[i] >> B[i];
    solve();
    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] x = new int[N];
		int[] y = new int[N];
		
		double sum = 0;
		
		for(int i=0;i<2;i++) {
			for(int j=0;j<N;j++) {
				if(i==0) {
					x[j] = sc.nextInt();
				}else {
					y[j] = sc.nextInt();
				}
			}
		}
		
		for(int i=0;i<N;i++) { //p=1
			sum += Math.abs((x[i] - y[i]));
		}
		System.out.printf("%6f\n",sum);
		sum = 0;
		
		for(int i=0;i<N;i++) { //p=2
			sum += Math.pow(Math.abs(x[i] - y[i]),2);
		}
		sum = Math.sqrt(sum);
		
		System.out.printf("%6f\n",sum);
		sum = 0;
		
		for(int i=0;i<N;i++) { //p=3
			sum += Math.pow(Math.abs(x[i] - y[i]),3);
		}
		sum = Math.cbrt(sum);
		
		System.out.printf("%6f\n",sum);
		sum = 0;
		
		double max = -7000;
		
		for(int i=0;i<N;i++) { //p = infinity
			sum = Math.abs((x[i] - y[i]));
				if(sum > max) max = sum;
		}
		System.out.printf("%6f\n",max);
	}

}


Measured memory_bytes: 26668
import math

def lcm(a,b):
    return a*b//math.gcd(a,b)

a, b, c, d = map(int, input().split())

l = lcm(c, d)
ans = (b-a+1) - ((b//c + b//d - b//l) - ((a-1)//c + (a-1)//d - (a-1)//l))
print(ans)

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

using namespace std;
using ll = long long;

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

  int n;
  ll w;
  cin >> n >> w;
  vector<ll> ws(n);
  vector<ll> vs(n);
  for (int i = 0; i < n; i++)
    cin >> ws[i] >> vs[i];

  int m = 1e5;
  vector<vector<ll>> dp(n + 1, vector<ll>(m + 1, w + 1));
  dp[0][0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= m; j++) {
      if (j - vs[i] >= 0)
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - vs[i]] + ws[i]);
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    }
  }

  for (int i = m; i >= 0; i--) {
    if (dp[n][i] <= w) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 83164