akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll X,Y,ans=0;
  cin >> X >> Y;
  while(X<=Y){
    X*=2;
    ans++;
  }
  cout << ans << endl; 
}

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

int bound(int n,vector<int> L,int X,int *index) {
  // ベースケース
  if (n == 0) {
    return 0;
  }
  // 再帰ステップ
  int s = bound(n - 1,L,X,index);
  if(s + L.at(n-1)<=X)*index=n+1;
  return s + L.at(n-1);
}

int main(){
    int N,X;
    cin >> N >> X;
    vector<int> L(N);
    for(int i=0;i<N;i++){
      cin>>L.at(i);
    }
    int ans=0;
    bound(N,L,X,&ans);

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
od = sum(int(x)&1 for x in input().split())
ev = N - od

x = od // 2
od -= 2*x
ev += 2*x
ev = min(ev,1)

rest = od + ev
answer = 'YES' if rest == 1 else 'NO'
print(answer)

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

int main() {
  //input
  int sum = 0;
  int A;
  rep(i,3) {
    cin >> A;
    sum += A;
  }
  //calc
  string answer = sum >= 22 ? "bust" : "win";
  //output
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
//#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
//cout<<setprecision(12)
//fixed
//#include<random>
using namespace std;
typedef long long int llint;
typedef long double lldo;
const int big=1e9+100000;
const int mod=1e9+7;
const lldo eps=1e-9;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
#define dme(in) cout<<in<<endl;return 0
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	int i,j,n,m,k;cin>>n>>m>>k;
	//??????????????????????????????
	vector<int>go(n+m);//??¨?´????
	vector<int>ran(n+m);
	for(i=0;i<n;i++){go[i]=i;ran[i]=0;}
	for(i=n;i<n+m;i++){go[i]=i;ran[i]=114514;}
	for(i=0;i<k;i++){
		int q,a,b;cin>>q>>a>>b;a--;b--;
		if(q==1){
			while(a!=go[a]){a=go[a];}
			while(b!=go[b]){b=go[b];}
			if(a==b){continue;}
			if(a>=n&&b>=n){dme(i+1);}
			if(ran[a]>ran[b]){swap(a,b);}
			if(ran[a]==ran[b]){ran[b]++;}
			go[a]=b;
		}else{
			b+=n;
			while(a!=go[a]){a=go[a];}
			while(b!=go[b]){b=go[b];}
			if(a==b){continue;}
			if(a>=n&&b>=n){dme(i+1);}
			if(ran[a]>ran[b]){swap(a,b);}
			if(ran[a]==ran[b]){ran[b]++;}
			go[a]=b;
		}
	}
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl;
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;



int main() {
  ll n, c, k; cin >> n >> c >> k;
  Vl t(n);
  rep(i, 0, n) cin >> t[i];
  sort(ALL(t));
  ll ans = 1, cnt = 1, T = t[0];
  rep(i, 1, n){
    if(cnt >= c || t[i] > T+k){
      ans++;
      T = t[i];
      cnt = 1;
    }else{
      cnt++;
    }
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

#define pb push_back
#define fi first
#define se second
typedef pair<int, int> ii;

const int N = 2e5 + 5;
int n, m;
vector<ii> intervals[N];

struct It {
    long long node[N << 2], lz[N << 2];
    It () {
        memset(node, 0, sizeof node);
        memset(lz, 0, sizeof lz);
    }
    void trueVal (int nd, int Left, int Right) {
        if (!lz[nd]) return ;
        node[nd] += lz[nd];
        if (Left != Right) {
            lz[nd << 1] += lz[nd];
            lz[nd << 1 | 1] += lz[nd];
        }
        lz[nd] = 0;
    }
    void update (int nd, int Left, int Right, int l, int r, long long val) {
        trueVal(nd, Left, Right);
        if (Right < l || r < Left) return ;
        if (l <= Left && Right <= r) {
            lz[nd] = val; trueVal(nd, Left, Right);
            return ;
        }
        int mid = Left + Right >> 1;
        update(nd << 1, Left, mid, l, r, val); update(nd << 1 | 1, mid + 1, Right, l, r, val);
        node[nd] = max(node[nd << 1], node[nd << 1 | 1]);
    }
    long long get (int nd, int Left, int Right, int l, int r) {
        trueVal(nd, Left, Right);
        if (Right < l || r < Left) return 0;
        if (l <= Left && Right <= r) return node[nd];
        int mid = Left + Right >> 1;
        return max(get(nd << 1, Left, mid, l, r), get(nd << 1 | 1, mid + 1, Right, l, r) );
    }
} it;

int main () {
    scanf("%d %d", &n, &m);
    while (m --) {
        int l, r, a; scanf("%d %d %d", &l, &r, &a);
        intervals[r].pb(ii(l, a) );
    }

    it.update(1, 0, n, 0, 0, 0);
    for (int i = 1; i <= n; ++i) {
        it.update(1, 0, n, i, i, it.get(1, 0, n, 0, i - 1) );
        for (auto _ : intervals[i]) {
            it.update(1, 0, n, _.fi, i, _.se);
        }
    }

    printf("%lld", it.node[1]);

    return 0;
}


Measured memory_bytes: 23680
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(long long I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const ll mod = 998244353;
struct Combinatorics {
  using int64 = long long;
  int64 mod;
  int64 fact[300020];
  int64 invfact[300020];
  Combinatorics(int64 mod):mod(mod) {
    fact[0] = invfact[0] = 1;
    for(int i = 1; i < 300020; ++i) {
      fact[i] = fact[i-1]*i%mod;
      invfact[i] = minv(fact[i]);
    }
  }
  int64 mpow(int64 x, int64 n) const {
    int64 res = 1;
    while(n > 0) {
      if(n&1) res = res*x%mod;
      x = x*x%mod;
      n >>= 1;
    }
    return res;
  }
  int64 minv(int64 x) const {
    return mpow(x, mod-2);
  }
  int64 mfact(int64 x) const {
    return fact[x];
  }
  int64 minvfact(int64 x) const {
    return invfact[x];
  }
  int64 C(int64 n, int64 r) const {
    if(r < 0 || n < r) return 0;
    return fact[n]*invfact[r]%mod*invfact[n-r]%mod;
  }
  int64 P(int64 n, int64 r) const {
    if(r < 0 || n < r) return 0;
    return fact[n]*invfact[n-r]%mod;
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N,A,B,K;
  cin>>N>>A>>B>>K;
  Combinatorics com(mod);
  ll ans = 0;
  FOR(a,0,N+1){
    if((K - a * A) % B == 0){
      ll b = (K - a * A) / B;
      if(b <= N) {
        ans += com.C(N, a) * com.C(N, b);
        ans %= mod;
      }
    }
  }
  cout << ans << endl;
}

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

using lint = long long int;
using Graph = std::vector<std::vector<lint>>;

template<class T>
struct edge
{
	T dist;
	lint to;
	edge(){}
	edge(const T &a_dist,const lint &a_to) : dist(a_dist), to(a_to) {}
	~edge(){}
};

int main(int argc,char *argv[])
{
	lint n;
	std::cin >> n;

	std::string s;
	std::cin >> s;
	
	lint num = 1;
	char check = s[0];
	for(int i = 1;i < n;i++)
	{
		if(check != s[i]){
			check = s[i];
			num++;
		}
	}

	std::cout << num << std::endl;

	return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solution sol = new Solution();
		sol.solve(in, out);
		out.close();
	}

	private static class Solution {
		private void solve(InputReader in, PrintWriter out) {
			long n = Long.parseLong(in.n());
			StringBuilder ans=new StringBuilder();
			while (n > 0) {
				long currentLetterNumber = (n - 1) % 26;
				char currentLetter = (char)(currentLetterNumber + 97);
				ans.append(currentLetter);
				n = (n - (currentLetterNumber + 1)) / 26;
			}
			out.println(ans.reverse().toString());
		}
	}

	private static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		private InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		private String n() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
	}

}


Measured memory_bytes: 25644
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
  ll N,K; cin>>N>>K;
  vector<ll> H(N);
  for(int i=0; i<N; i++){
    cin>>H.at(i);
  }
  sort(H.begin(), H.end());
  ll ans=0;
  for(int i=0; i<N-K; i++){
    ans+=H.at(i);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	prices := make([]int, n)
	for i := 0; i < n; i++ {
		prices[i] = nextInt()
	}
	min := prices[0]
	maxDiff := prices[1] - prices[0]
	for j := 1; j < n; j++ {
		diff := prices[j] - min
		if diff > maxDiff {
			maxDiff = diff
		}
		if prices[j] < min {
			min = prices[j]
		}
	}
	fmt.Println(maxDiff)
}



Measured memory_bytes: 5352
a,b,c,x,y = map(int,input().split())
l = min(x,y)
m = max(x,y)
M = a * x + b * y
for i in range(1,l+1):
  K = a * (x-i) + b * (y-i) + 2 * c * i #これだとマイナスになってしまう
  M = min(M,K)
for i in range(l+1,m+1):
  if x == l:
    K = b * (y-i) + 2 * c * i
  else:
    K = a * (x-i) + 2 * c * i
  M = min(M,K)
print(M)


Measured memory_bytes: 3064
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		long x = parseLong(sc.next());
		long[] a = new long[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.parallelSort(a);
		int cnt=0;
		for (int i = 0; i < a.length; i++) {
			if(x<a[i]) {
				x=0;
				break;
			}
			x-=a[i];
			cnt++;
		}
		if(x>0)cnt--;
		out.println(cnt);
	}
}


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

using namespace std;

const int mod = 1e9 + 7;

string s;
int n;

int main() {
//	freopen("inp.txt", "r", stdin);
	cin >> n;
	
	cin >> s;
	
	int cnt = 0;
	long long ans = 1;
	for (int i = 1; i <= n; i++) {
		ans = ans * i % mod;
	}
	for (int i = 0; i < n * 2; i++) {
		if (i % 2 == 0) {
			if (s[i] == 'W') {
				s[i] = 'B';
			} else {
				s[i] = 'W';
			}
		}
		if (s[i] == 'B') {
			ans = ans * cnt % mod;
			cnt--;
		} else {
			cnt++;
		}
	}
	if (cnt != 0) {
		cout << 0;
		return 0;
	}
	cout << ans;
	
	return 0;
}

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

using namespace std;

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

int main() {
    char str[1001];

    while (1) {
        scanf("%s", str);
        if (str[0] == '0') break;
        int sum = 0;
        REP(i, strlen(str)) sum += str[i] - '0';

        cout << sum << endl;
    }
}

Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

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

    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())

lis = [a, b, c]
lis.sort()
if lis[0] == lis[2]:
    print("1")
elif (lis[0] != lis[1]) and (lis[1] != lis[2]):
    print("3")
else:
    print("2")

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

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

int main() {
  int n,xxxx; cin >>n >>xxxx;
  vector<int> x(n+1); x.at(0) = xxxx;
  for (int i=1; i<n+1; i++) cin >>x.at(i);
  sort(x.begin(), x.end());
  int ans = x.at(1) - x.at(0);
  for (int i=0; i<n-1; i++){
    ans = gcd(ans, x.at(i+2)-x.at(i+1));
  }
  
  cout <<ans;
  cout <<endl;
}


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

#ifdef LOCAL

template<class T, class U>
ostream& operator<<(ostream& os, pair<T, U> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<template<class, class...> class C, class... A>
typename enable_if<!is_same<C<A...>, string>::value, ostream&>::type
operator<<(ostream& os, class C<A...> c) {
	auto i = c.begin();
	while (i != c.end()) {
		os << " {"[i == c.begin()] << *i;
		os << ",}"[++i == c.end()];
	}
	return os;
}

#define debug(x) cerr << #x << " = " << x << endl;
#else
#define debug(...) {}
#endif

const int N = 1e6;
long long infLL = 1e18;
int inf = 1e9;

void zaaplikuj(vector<int>& v, int k) {
	for (int i = v.size() - 1; i >= 0; i --) {
		v.push_back(v[i] % k);
	}
	sort(v.begin(), v.end());
	v.resize(unique(v.begin(), v.end()) - v.begin());
}

bool mozna(pair<int, vector<int>>& p, int k) {
	int cel = p.first;
	vector<int> v = p.second;
	for (int j = k - 1; j >= 1; j --) {
		zaaplikuj(v, j);
	}
	for (int x : v) {
		if (x == cel) return true;
	}
	return false;
}

bool mozna(vector<pair<int, vector<int>>>& v, int k) {
	bool OK = true;
	for (auto& x : v) if (not mozna(x, k)) {
		OK = false;
	}
	return OK;
}

int main() {
	ios_base::sync_with_stdio(false);
	long long res = 0;
	vector<pair<int, vector<int>>> v;
	int n;
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; i ++) {
		int a;
		cin >> a;
		v[i].second.push_back(a);
	}
	for (int i = 0; i < n; i ++) cin >> v[i].first;
	if (not mozna(v, 51)) {
		cout << "-1";
		return 0;
	}
	for (int i = 50; i >= 1; i --) {
		if (not mozna(v, i)) {
			res += 1LL << i;
			for (auto& p : v) {
				zaaplikuj(p.second, i);
			}
		}
	}
	cout << res;
}


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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

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

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int x;
    cin>>x;
    int no = x/500;
    int ans = no*1000;
    x-=no*500;
    no = x/5;
    ans += no*5;
    cout << ans << "\n";
    return 0;
}



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

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;

    stack<char> st;
    string ans = "";

    int need_left = 0;
    int pointer = 0;

    for (int i = 0; i < N; i++) {
        if (S[i] == '(') {
            pointer++;
        }
        else {
            if (pointer == 0) {
                need_left++;
            }
            else {
                pointer--;
            }
        }
    }

    int need_right = pointer;

    string res = "";
    rep(i, need_left) res += '(';
    res += S;
    rep(i, need_right) res += ')';
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int n, flag = 0;
    long long ans = 1, temp;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> temp;
        // cout << i << " " << temp << endl;
        if(!temp) {
            cout << "0\n";
            return 0;
        }
        if(ans > (long long)(1e18)/temp) {
            flag = 1;
        }
        else {
            ans *= temp;
        }
    }
    if(flag) cout << "-1\n";
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <cstdio>  
#include <stack>  
#include <queue>
#include <cmath>  
#include <vector>  
#include <cstring>  
#include<set>
#include<map>
#include<ctime>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef unsigned long long uLL;
const int M = 100005;
const int N = 1000005;
const int mod = 1000000007;
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const LL lINF = 0x3f3f3f3f3f3f3f3fLL;
const int sINF = 0xcfcfcfcf;
#define ls (rt<<1)
#define rs (rt<<1|1)
P a[M];
LL n,m;
bool cmp(P a, P b)
{
	return a.second < b.second;
}
int main()
{
	while (~scanf("%lld%lld",&n,&m))
	{
		for (int i = 0; i < m; i++)
		{
			scanf("%d%d", &a[i].first, &a[i].second);
		}
		sort(a, a + m,cmp);
		int l = 0, cnt = 0;
		for (int i=0; i < m; i++)
		{
			if (a[i].first >= l)
			{
				l = a[i].second;
				cnt++;
			}
		}
		printf("%d\n", cnt);
	}
}

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

int main()
{
    ll n, y;
    cin >> n >> y;

    rep(i, n+1){
        rep(j, n+1){
            if ((y - 10000 * i - 5000*j) % 1000 == 0){
                ll c = (y - 10000 * i - 5000*j) / 1000;
                if (c >= 0 && i + j + c == n){
                    cout << i << " " << j << " " << c << endl;
                    return 0;
                }
            }
        }
    }

    puts("-1 -1 -1");

    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main() {
	map<char, int> t;
	t['I'] = 1;
	t['V'] = 5;
	t['X'] = 10;
	t['L'] = 50;
	t['C'] = 100;
	t['D'] = 500;
	t['M'] = 1000;
	string str;
	while (cin >> str) {
		int size = str.size();
		int sum = 0;
		for (int i = 0; i < size - 1; i++) {
			if (t[str[i]] < t[str[i + 1]])sum -= t[str[i]];
			else sum += t[str[i]];
		}
		cout << sum + t[str[size - 1]] << endl;
	}
}


Measured memory_bytes: 3028
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iomanip>

using namespace std;

#define EPS (1e-10)

typedef long double ld;

class Point {
public:
	ld x, y;
	Point(ld x, ld y) :
			x(x), y(y) {
	}
	Point operator +(Point p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator -(Point p) {
		return Point(x - p.x, y - p.y);
	}
};

class Segment {
public:
	Point p1, p2;
	Segment(Point p1, Point p2) :
			p1(p1), p2(p2) {
	}
};

ld dot(Point p1, Point p2) {
	return p1.x * p2.x + p1.y * p2.y;
}
ld cross(Point p1, Point p2) {
	return p1.x * p2.y - p1.y * p2.x;
}
ld norm(Point p) {
	return p.x * p.x + p.y * p.y;
}
ld abs(Point p) {
	return sqrt(norm(p));
}
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ON_SEGMENT = 0;
static const int ONLINE_FRONT = -2;

int ccw(Point p0, Point p1, Point p2) {
	Point a = p1 - p0;
	Point b = p2 - p0;
	if (cross(a, b) > EPS)
		return COUNTER_CLOCKWISE;
	if (cross(a, b) < -EPS)
		return CLOCKWISE;
	if (dot(a, b) < -EPS)
		return ONLINE_BACK;
	if (norm(a) < norm(b))
		return ONLINE_FRONT;
	return ON_SEGMENT;
}

bool intersect(Point p1, Point p2, Point p3, Point p4) {
	return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0;
}

bool intersect(Segment s1, Segment s2) {
	return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}

ld getDistanceLp(Segment l, Point p) {
	return abs(cross(l.p2 - l.p1, p - l.p1)) / abs(l.p2 - l.p1);
}

ld getDistanceSp(Segment s, Point p) {
	if (dot(s.p2 - s.p1, p - s.p1) < 0.0)
		return abs(p - s.p1);
	if (dot(s.p1 - s.p2, p - s.p2) < 0.0)
		return abs(p - s.p2);
	return getDistanceLp(s, p);
}

ld getDistance(Segment s1, Segment s2) {
	if (intersect(s1, s2))
		return 0.0;
	return min(min(getDistanceSp(s1, s2.p1), getDistanceSp(s1, s2.p2)), min(getDistanceSp(s2, s1.p1), getDistanceSp(s2, s1.p2)));
}

int main() {

	int q;
	scanf("%d", &q);

	for (int i = 0; i < q; ++i) {
		int p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y;
		scanf("%d %d %d %d %d %d %d %d", &p0x, &p0y, &p1x, &p1y, &p2x, &p2y, &p3x, &p3y);
		Point p1(p0x, p0y);
		Point p2(p1x, p1y);
		Point p3(p2x, p2y);
		Point p4(p3x, p3y);
		Segment s1(p1, p2);
		Segment s2(p3, p4);

		cout << fixed << setprecision(10) << getDistance(s1, s2) << endl;
	}
	return 0;
}

Measured memory_bytes: 3332
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=2750131;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	ll n;
	cin>>n;
	vector<pi> ar(n);
	for(int i=0;i<n;++i)
    {
        cin>>ar[i].first>>ar[i].second;
    }
    sort(ar.begin(),ar.end());
    if(n==1){cout<<"1";return(0);}
    map<pi,ll> m;
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<i;++j)
        {
            ll x=ar[i].first-ar[j].first;
            ll y=ar[i].second-ar[j].second;
            pi p=mp(x,y);
            m[p]+=1;
        }
    }
    pi lol;
    ll ma=INT_MIN,mm=INT_MIN;
    for(auto it:m)
    {
        mm=max(mm,it.second);
        if(it.second>ma)
        {
            ma=it.second;
            lol=it.first;
        }
    }
    cout<<n-mm;

	return(0);
}


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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  
  int cur = 0;
  vector<int> cnts(n, 1);
  vector<bool> can(n, false);
  can[0] = true;
  for (int i =0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    if (can[x]) {
      can[y] = true;
      if (cnts[x] <= 1) can[x] = false;
    }
    cnts[x]--;
    cnts[y]++;
  }
  
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (can[i]) ans++;
  cout << ans << endl;
  return 0;
}

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

UL N,M;
ULL A[200000];
ULL dp[200001];
UL P[200000];

int main(){
 scanf("%u%u",&N,&M);
 rep(i,N) scanf("%llu",&A[i]);
 rep(i,N) P[i]=i;
 rep(i,M){
  UL l,r; scanf("%u%u",&l,&r); l--; r--;
  P[r]=min(l,P[r]);
 }
 for(UL i=N-2; i!=~0u; i--) P[i]=min(P[i],P[i+1]);
 dp[0]=0;
 for(UL i=0; i<N; i++){
  dp[i+1]=max(dp[i],dp[P[i]]+A[i]);
 }
 printf("%llu\n",dp[N]);
 return 0;
}



Measured memory_bytes: 7052
use std::vec::Vec;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (n ,k): (f64, f64) = {
      let v = read_vec();
      (v[0], v[1])
    };

    let mut res: f64 = 0.0;

    for i in 1..n as usize + 1 {
      let mut temp: f64 = 1.0 / (n as f64);
      let mut now = i as f64;
      while now < k {
        now *= 2.0;
        temp /= 2.0;
      }
      res += temp;
    }
    println!("{}", res);

}


Measured memory_bytes: 4352
N = int(input())
P = list(map(int,input().split()))

A = [i*(10**4*2+1)+1 for i in range(N)]
B = list(reversed(A))
for i in range(N):
    B[P[i]-1] += i

for i in A:
    print(i,end = " ")
print()
for i in B:
    print(i,end = " ")


Measured memory_bytes: 6008
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000009LL
#define EPS 1e-8

int main()
{
	string S;
	int K;
	cin >> S >> K;
	for( int i = 0; i < S.length(); ++i )
	{
		if( S[ i ] != '1' )
		{
			if( K <= i )
			{
				cout << 1 << endl;
				return 0;
			}
			else
			{
				cout << S[ i ] << endl;
				return 0;
			}
		}
	}
	cout << 1 << endl;
	return 0;
}


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

#define ll long long
const int mx = 2e5;


int main(void){
  
  ll N,X,Y;
  cin >> N >> X >> Y;
  X--;Y--;
  ll ptn[N];
  for(int i=0; i<N; i++){
    ptn[i] = 0;
  }
  
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      ll ans = -1;
      ll a,b;//a:直進 b:近道
      a = j-i;
      b = abs(X-i) + abs(Y-j)+1;
      if(a<b){
        ptn[a] = ptn[a]+1;
      }else{
        ptn[b] = ptn[b]+1;
       }
    }
  }
  
  for(int i=1; i<N; i++){
    cout << ptn[i] << "\n";
  }
  
  return 0;
}

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

int main(){
  int a, b, k;
  bool f = false;
  cin >> k >> a >> b;
  for(int i = a; i <= b; i++){
    if( i % k == 0) 
      f = true;
  }
  if(f)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int n; cin >> n;
	vint a(n); vinput(a);
	sort(all(a));
	rep(i, n-1){
		if(a[i] == a[i+1]){
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n ,sum ;
 string s ;
int main()
{
 //   freopen("C.inp","r",stdin) ;
 //   freopen("C.out","w",stdout);
    cin >> n ;
    cin >> s ;
    sum =1;
    for (int i=1;  i<s.size() ; i ++ )
        if (s[i]!= s[i-1])
            sum ++ ;
    cout << sum ;
    return 0;
}


Measured memory_bytes: 512
import sys

ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))
mod = 10**9 + 7

n = ri()
a = rl()
s = sum(a)
ans = 0
for i in a:
    s -= i
    ans = (ans + s*i)%mod
print(ans)

Measured memory_bytes: 31356
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		int k = sc.nextInt();
		long temp;
		for(int i=0;i<k;i++)
		{
			a = a/2;
			b = b+a;
			temp = a;
			a = b;
			b = temp;
		}
		if(k%2 == 1)
		{
			temp=a;
			a=b;
			b=temp;
		}
		System.out.println(a+" "+b);
	}
}


Measured memory_bytes: 22740
#include<stdio.h>

#define CMAX 100000
#define N 100
#define NIL -1
static const int INF=(1<<21);

int n,u,k,v,c;
int A[N][N],key[N],pi[N];

void SSSP(void){
  int i,j,flag[N],minv=0;
  
  for(i=0;i<n;i++){
    key[i]=INF;
    pi[v]=NIL;
    flag[i]=0;
  }
  
  key[0]=0;
  
  for(i=0;i<n;i++){
    u=NIL;  
    minv=INF;
    for(j=0;j<n;j++){
      if(!flag[j] && key[j]<minv){
	u=j;
	minv=key[j];  //the minimum cost
      }
    }
    
    if(u==NIL) break;
    flag[u]=1;
    
    for(v=0;v<n;v++){
      if(key[v]>=key[u]+A[u][v]){
	key[v]=key[u]+A[u][v];
      }
    }
  }
}

int main(){
  int i,j;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=INF;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      A[u][v]=c; 
    }
  }
  
  SSSP();
  
  for(i=0;i<n;i++){
    printf("%d %d\n",i,(key[i]==INF?-1:key[i]));
  }  
  return 0;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
    int n;
    s(n);

    vector<int> prizes(3, 0);
    vector<int> dp(3, 0);
    vector<int> next_dp(3, 0);
    for(int i = 0; i < n; i++){
        f(l, 0, 3){
            s(prizes[l]);
        }
        f(i, 0, 3){
            next_dp[i] = 0;
        }
        for(int curr = 0; curr < 3; curr++){
            int max_prev_plus_prize = 0;
            for(int prev = 0; prev < 3; prev++){
                if(curr == prev){continue;}
                max_prev_plus_prize = max(max_prev_plus_prize, dp[prev] + prizes[prev]);
            }
            next_dp[curr] = max_prev_plus_prize;
        }
        dp = next_dp;
    }
    int maxx = *max_element(dp.begin(), dp.end());
    p(maxx);
    return;
}

class CVacation {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(0);out.tie(0);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    CVacation solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

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

int main(){
	int a, b;
	bool first = true;

	while( cin >> a >> b && !( a == 0 && b == 0 ) ){
		if( first ){
			first = false;
		}else{
			cout << endl;
		}
		bool exist = false;
		for( int i = a + ( 4 - a%4 ) % 4; i <= b; i += 4 ){
			exist = true;
			if( i % 400 != 0 && i % 100 == 0 ){
				continue;
			}
			cout << i << endl;
		}
		if( !exist ){
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

int main()
{
 int a[9], b[9];
 int i;

 cin >> a[0] >> b[0];

 for (i = 1; i < b[0]; i++) {
	 a[i] = a[0];
 }

 for (i = 1; i < a[0]; i++) {
	 b[i] = b[0];
 }

 
 if (a[0] < b[0]) {
	 for (i = 0; i < b[0]; i++) {
		 cout << a[i];
	 }

 }
 else {
	 for (i = 0; i < a[0]; i++) {
		 cout << b[i];
	 }
 }

}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    vector<ll> a;
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        if (x >= K) continue;
        a.push_back(x);
    }
    sort(a.begin(), a.end());

    n = a.size();
    vector< vector<int> > dpl(n + 1, vector<int>(K, false));
    dpl[0][0] = true;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < K; j++) {
            dpl[i + 1][j] = dpl[i][j];
            if (j >= a[i] && dpl[i][j - a[i]]) dpl[i + 1][j] = true;
        }
    }

    vector< vector<int> > dpr(n + 1, vector<int>(K, false));
    dpr[n][0] = true;
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < K; j++) {
            dpr[i][j] = dpr[i + 1][j];
            if (j >= a[i] && dpr[i + 1][j - a[i]]) dpr[i][j] = true;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int k = K - 1;
        int cnt = 0;
        while (k >= 0) {
            cnt += dpr[i + 1][k];
            if (k + a[i] == K) break;
            k--;
        }
        //cerr << k << " " << cnt << endl;
        if (cnt > 0 && dpl[i][0]) break;
        bool f = true;
        for (int j = 1; j < K; j++) {
            cnt -= dpr[i + 1][K - j];
            while (k >= 0) {
                if (j + a[i] + k == K) break;
                cnt += dpr[i + 1][k];
                k--;
            }
            if (k < 0) break;
            if (cnt > 0 && dpl[i][j]) {
                //cerr << j << " " << k << endl;
                f = false;
                break;
            }
        }
        ans += f;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 196096
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


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


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

    g = A[0]
    for i in range(1, N):
        g = gcd(g, A[i])

    print(g)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14636
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
while True:
   try:
      a,b,c,d,e,f = map(float, input().split())
      x = (c*e - b*f) / (a*e - b*d)
      y = (a*f - c*d) / (a*e - b*d)
      if x==-0:
         x=int(x)
      if int(y)==-0:
         y=int(y)
      X = Decimal(x).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP)
      Y = Decimal(y).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP)
      print(f'{X:.3f} {Y:.3f}')
   except EOFError:
      break


Measured memory_bytes: 6404
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int n;
int[] a;
int[] b;

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

    b = new int[](n);

    foreach (i ; 0 .. n) {
        while (a[i] % 2 == 0) {
            b[i]++;
            a[i] /= 2;
        }
    }

    b.sort!"a > b"();

    debug {
        writeln("b:", b);
    }

    auto c = new int[](n);

    if (n & 1) {
        foreach (i ; 0 .. n) {
            if (i < n / 2) {
                c[2*i + 1] = b[i];
            }
            else {
                c[n - 1 - 2*(i - n/2)] = b[i];
            }
        }
    }
    else {
        foreach (i ; 0 .. n) {
            if (i < n / 2) {
                c[2*i + 1] = b[i];
            }
            else {
                c[n - 2 - 2*(i - n/2)] = b[i];
            }
        }
    }

    debug {
        writeln("c:", c);
    }

    foreach (i ; 0 .. n - 1) {
        if (c[i] + c[i + 1] < 2) {
            writeln("No");
            return;
        }
    }

    writeln("Yes");
}



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


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

Measured memory_bytes: 4276
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>

//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum,a[210000],d[210000];
string str;
bool f[110000];
//char c;
int main() {
	cin >> p >> q >> s;
	cout << p + q + s - max({ p,q,s }) << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

vector<ll> a, p;

ll f(int n, ll x){
//    if(x == 1) return 0;
//    else if(x <= 1+a[n-1]) return f(n-1, x-1);
//    else if(x <= 2+a[n-1]) return p[n-1]+1;
//    else if(x <= 2+2*a[n-1]) return 1 + p[n-1] + f(n-1, x-2-a[n-1]);
//    else return 2*p[n-1]+1;
    if(n == 0){
        if(x <= 0) return 0;
        else return 1;
    }else if(x <= 1 + a[n-1]) return f(n-1, x-1);
    else return p[n-1] + 1 + f(n-1, x-2-a[n-1]);
}

int main() {
    int n;
    ll x;
    cin >> n >> x;
    a.resize(n); p.resize(n);
    
    rep(i, n){
        if(i == 0){
            a[0] = 1;
            p[0] = 1;
        }else{
            a[i] = a[i-1]*2+3;
            p[i] = p[i-1]*2+1;
        }
    }
    
    cout << f(n, x) << endl;
}




Measured memory_bytes: 256
import java.util.*;
public class Main {
	static final int team = 3;
	static final int player = 8;
	
	public static void Swap(Player[] a, int r, int c) {
		Player temp = a[r];
		a[r] = a[c];
		a[c] = temp;
		temp = null;
		//System.out.println("Swapped");
	}
	
	public static void SortOneDimention(Player[] ary) {
		for(int r = 0; r < player - 1; r++) {
			for(int c = ary.length - 1; c > r; c--) {
				if(ary[c - 1].getTime() > ary[c].getTime())
					Swap(ary, c - 1, c);
			}
		}
	}
	
	public static void Sort(Player[][] judge) {
		for(int r = 0; r < team; r++) {
			SortOneDimention(judge[r]);
		}
		//System.out.println("OneDimention");
	}
	
	public void doIt() {
		Scanner stdIn = new Scanner(System.in);
		Player[][] judge = new Player[3][8];
		
		for(int r = 0; r < team; r++) {             //データ読み込み
			for(int c = 0; c < player; c++) {
				int number = stdIn.nextInt();
				double time = stdIn.nextDouble();
				judge[r][c] = new Player(number, time);
			}
		}
		//System.out.println("BEFORE SORT SUBROUTINE");
		
		Sort(judge); //諸悪の根源
		//System.out.println("judge is sorted.");
		
		Player[] temp = new Player[18];
		int count = 0;
		for(int r = 0; r < team; r++) {
			for(int c = 2; c < player; c++) {
				temp[count++] = judge[r][c];
			}
			//System.out.println("r is " + r);
		}
		SortOneDimention(temp);
		
		for(int r = 0; r < team; r++) {
			for(int c = 0; c < 2; c++) {
				System.out.println(judge[r][c].getNumber() + " " + judge[r][c].getTime());
			}
		}
		for(int r = 0; r < 2; r++) {
			System.out.println(temp[r].getNumber() + " " + temp[r].getTime());
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

	class Player {
		private int number;
		private double time;
		
		public Player(int number, double time) {
			this.number = number;
			this.time = time;
		}
		
		public int getNumber() {
			return(number);
		}
		public double getTime() {
			return(time);
		}
		
		public void setNumber(int number) {
			this.number = number;
		}
		public void setTime(double time) {
			this.time = time;
		}
	}
	
}

Measured memory_bytes: 20028
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] s = new int[m];
		int[] p = new int[m];
		int num = 0;
		for(int i = 0 ; i < m  ; i++) {
			int allS = 0;
			int k = sc.nextInt();
			for(int j = 0 ; j < k ; j++) {
				allS = allS | 1 << (sc.nextInt() - 1); // & And  | Or ^  Xor ~  Not(ビット反転)
			}
			s[i] = allS;
		}
		for(int i = 0 ; i < m  ; i++) {
			p[i] = sc.nextInt();
		}
		for (int i = 0; i < 1 << n ; i++) {
			boolean flag = true;
			for(int j = 0 ; j < m ; j++) {
				int k = s[j] & i;
				if(Integer.bitCount(k) % 2 != p[j]) {
					flag = false;
					continue;
					}
			}
			if(flag)
				num++;
		}

		sc.close();
			System.out.println(num);


	}

}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef pair<int, int> P;

void print_line(vector<int> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

class Heap {
    int n;
    vector<ll> heap;
public:
    Heap(int n) : n(n), heap(n + 1, 0) {}

    void set(int i, ll v) {
        heap[i + 1] = v;
    }

    ll get(int i) {
        return heap[i + 1];
    }

    ll parent_value(int i) {
        if (i == 0) return -INF;
        int j = (i + 1) / 2;
        return heap[j];
    }

    ll left_value(int i) {
        int j = 2 * (i + 1);
        if (j > n)return -INF;
        return heap[j];
    }

    ll right_value(int i) {
        int j = 2 * (i + 1) + 1;
        if (j > n) return -INF;
        return heap[j];
    }


};

int main() {

    int n;
    cin >> n;

    Heap heap(n);

    rep(i, n) {
        ll v;
        cin >> v;
        heap.set(i, v);
    }

    rep(i, n) {
        printf("node %d: key = %lld, ", (int) i + 1, heap.get(i));
        ll parent = heap.parent_value(i);
        ll left = heap.left_value(i);
        ll right = heap.right_value(i);
        if (parent != -INF) {
            printf("parent key = %lld, ", parent);
        }
        if (left != -INF) {
            printf("left key = %lld, ", left);
        }
        if (right != -INF) {
            printf("right key = %lld, ", right);
        }
        cout << endl;
    }

}




Measured memory_bytes: 3224