akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
//#include <pair>
#include <map>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c * x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
	~debug() { cerr << endl; }
	eni(!= ) cerr << boolalpha << i; ris;
}
eni(== ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


const double pi = 3.141592653589793238462643383279502884197169399;

typedef long long ll;
const ll INF = 1e9 + 7;

void solve() {
	int n;
	cin >> n;
//int c = (n - 1);
	vector<int>test(n);
	for (int i = 0; i < n - 1; ++i) {
		int element;
		cin >> element;
		test[--element]++;
	}
	for (int s : test) {
		cout << s << endl;

	}
}

	



int main() {
	//cout << fixed << setprecision(20) << endl;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("test.txt", "r", stdin);

	solve();
	return 0; 
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

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

signed main(){
	//IOS();
	vector<pint>ans;
	while(1){
		int h,w;
		cin>>h>>w;
		if(w+h==0)break;
		string s[w];
		rep(i,0,w)cin>>s[i];
		vector<vector<int>>used(w,vector<int>(h,0));
		int B=0,W=0;
		rep(i,0,w)rep(j,0,h){
			if(used[i][j]==0&&s[i][j]=='.'){
				stack<pair<int,int>>st;
				st.push({i,j});
				int black = 0,white = 0,cnt = 0;
				while(!st.empty()){
					int I = st.top().fi;
					int J = st.top().se;
					st.pop();
					if(used[I][J])continue;
					used[I][J] = true;
					cnt++;
					rep(k,0,4){
						int ni = I+dx[k];
						int nj = J+dy[k];
						if(ni<0||nj<0||w<=ni||h<=nj)continue;
						if(used[ni][nj])continue;
						if(s[ni][nj]=='B'){
							black = 1;
							continue;
						}
						if(s[ni][nj]=='W'){
							white = 1;
							continue;
						}
						st.push({ni,nj});
					}
				}
				if(black&&white)continue;
				if(black)B+=cnt;
				if(white)W+=cnt;
			}
		}
		ans.push_back({B,W});
	}
	for(auto e:ans){
		cout<<e.fi<<" "<<e.se<<endl;
	}
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(ll n){
    stringstream ss;
    ss << bitset<8>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
int main()
{
    string s;
    cin >> s;
    reverse(all(s));
    while(s.size() > 0){
        bool ok = false;
        string t, u, v;
        if(s.size() >= 5)t = s.substr(0, 5);
        if(s.size() >= 6)u = s.substr(0, 6);
        if(s.size() >= 7)v = s.substr(0, 7);
        if(t == "maerd" || t == "esare"){
            s.erase(0, 5);
            ok = true;
        }
        if(u == "resare"){
            s.erase(0, 6);
            ok = true;
        }
        if(v == "remaerd"){
            s.erase(0, 7);
            ok = true;
        }
        if(!ok){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
} 

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;

int main()
{
	int n;
	cin >> n;
	ll ans = 0LL;
	int high = 0;
	cin >> high;
	for(int i = 1; i < n; ++i){
		int a;
		cin >> a;
		if(a < high){
			ans += (high - a);
		} else{
			high = a;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    ll x;
    cin >> x;
    ll now = 100;
    int ans = 0;
    while(now < x) {
        now += now/100;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3692
#include <stdio.h>


int n, A[50];

int solve(int i, int m) {
	if (m == 0) return 1;
	if (i >= n) return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main() {
	int q, M, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &A[i]);
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &M);
		if (solve(0, M)) printf("yes\n");
		else printf("no\n");
	}

	return 0;
}

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

using namespace std;

int main()
{

    int n;  cin >> n;
    int k;  cin >> k;

    int* arr = new int[n];
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }

    sort(arr, arr+n);

    int sum = 0;
    for (int i = 0; i < k; i++){
        sum += arr[i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3604
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    }
    println!("{}",if max(a,max(b,c))==7&&min(a,b)==5&&a+b+c==17 {"YES"}else{"NO"})
}

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

int main(void){
    int N;
    long long K;
    cin >> N >> K;
    long long p[210000];
    int i;
    long long A[210000];
    for(i=0; i<N; i++){
        cin >> p[i];
    }
    A[0]=accumulate(p, p+K, 0LL);
    for(i=1; i<N-K+1; i++){
        A[i] = A[i-1] - p[i-1] + p[K-1+i];
    }
    sort(A, A+N-K+1, greater<int>());
    long long Ans = (A[0]+K)/2;
    cout << Ans;
    if((A[0] + K)% 2 == 1){
        cout << ".5" << endl;
    }else{
        cout << endl;
    }    return 0;
}

Measured memory_bytes: 3456
while(1):
    n=int(raw_input())
    if n==0:
        break
    else:
        m=int(raw_input())
        s=[0 if c=='O' else 1 for c in raw_input()]
        startc=0
        cur=0
        cnt=0
        ans=0
        for c in s:
            if startc==0 and c==1:
                startc=1
                cur=1
            elif startc:
                if c!=cur:
                    cnt+=1
                    cur=c
                else:
                    startc=c
                    ans+=max(0,(cnt/2-n)+1)
                    cnt=0
        ans+=max(0,(cnt/2-n)+1)
        print ans

Measured memory_bytes: 15148
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <unordered_map>

#define BIG 1000000007

using namespace std;

int main() {
    int n;
    cin >> n;
    int max = 0;
    int a = 0;
    for(int i = 0;i < n;++i){
        int h;
        cin >> h;
        if(h >= max){
            ++a;
            max = h;
        }
    }
    cout << a << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n,k,r,s,p,sum=0;
	string t,ta;
	cin>>n>>k;
	cin>>r>>s>>p;
	cin>>t;
	for(int i=0;i<k;i++) {
		if(t[i]=='s') sum+=r,ta+='r';
		else if(t[i]=='p') sum+=s,ta+='s';
		else sum+=p,ta+='p';
	}
	for(int i=k;i<n;i++) {
		if(t[i]!=t[i-k] || t[i]==t[i-k]&&ta[i-k]==t[i-k]) {
			if(t[i]=='s') sum+=r,ta+='r';
			else if(t[i]=='p') sum+=s,ta+='s';
			else sum+=p,ta+='p';
		} else ta+=t[i];
	}
	cout<<sum<<endl; 
	return 0;
} 

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N, M;  cin >> N >> M;

	cout << (1900 * M + 100 * (N - M)) * pow(2, M) << endl;
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i, n)
    cout << s[i] << t[i];
  puts("");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long ll;

int main(){
    int N;cin >> N;
    int a[N], b[10];
    rep(i, 10)b[i] = 0;
    rep(i, N)cin >> a[i];
    for(int i = 0;i < N;++i){
        for(int j = 1;j <= 9;++j){
            if(j == 9){
                b[j] += 1;
                break;
            }
            if(a[i] < 400 * j){
                b[j] = 1;
                break;
            }
        }
    }
    int minans = 0, maxans = 0;
    for(int i = 1;i <= 8;++i)if(b[i])minans += 1;
    if(minans == 0)cout << ((b[9] > 0) ? 1 : 0);
    else cout << minans;
    cout << ' ' << minans + b[9];
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int a, b, c, d, e;
  string s, t;
  rep(i, 5){
    cin >> a;
    if(a == 0){
      cout << i +1<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws IOException {

        BigDecimal x1 = new BigDecimal("1");
        BigDecimal y = new BigDecimal("30");
        BigDecimal z = new BigDecimal("10");

        //足し算
        //        BigDecimal z1 = x.add(y);
        //        //引き算
        //        BigDecimal z2 = x.subtract(y);
        //        //掛け算
        //        BigDecimal z3 = x.multiply(y);
        //割り算
        BigDecimal z4 = x1.divide(y, 5, BigDecimal.ROUND_FLOOR);
        //割り算
        BigDecimal z5 = x1.divide(z, 5, BigDecimal.ROUND_FLOOR);

        BigDecimal z1 = new BigDecimal("1");
        BigDecimal z6 = z1.add(z4);

        //        System.out.println(z1);
        //        System.out.println(z2);
        //        System.out.println(z3);
        //        System.out.println(z4);
        //        System.out.println(z5);
        //        System.out.println(z6);

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }
        String arr01[] = mylist.get(0).split(" ");

        Integer k = Integer.valueOf(arr01[0]);
        Integer n = Integer.valueOf(arr01[1]);

        int mindata = n - k + 1;
        int maxdata = n + k - 1;

        List<String> res = new ArrayList<>();
        for (int i = mindata; i <= maxdata; i++) {
            res.add(String.valueOf(i));
        }

        String strdata = String.join(" ", res);

        System.out.println(strdata);

    }

}

Measured memory_bytes: 21332
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	B := make([]int, N-1)
	for i := 0; i < N-1; i++ {
		B[i] = scanInt()
	}

	ans := B[0] + B[N-2]
	for i := 0; i < N-2; i++ {
		ans += intMin(B[i], B[i+1])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 int main(){
      int n;
      cin >> n;
      vector<int> s(n);
      int ans=0;
      for(int i=0;i<n;i++){
          cin >> s.at(i);
        ans+=s.at(i);
      }
      sort(s.begin(),s.end());
      for(int i=0;i<n;i++){
        
        if(ans%10!=0){
          cout << ans << endl;
       break;
        }
        if(s.at(i)%10!=0){
        ans-=s.at(i);
        cout << ans << endl;
        break;
        }
        
      }
      if(ans%10==0){
          cout << 0 << endl;
      }

      return 0;
 }

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


int main(){
    long long x;
    cin >> x;
    
    long long ans=0;
    
    ans+=(x/11)*2;
    x%=11;
    
    if(x>=6){
        ans++;
        x-=6;
    }
    
    if(x>0){
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int n, m;
    std::cin >> n >> m;
    std::priority_queue<long long> a;

    for (int i  = 0; i < n; i++) {
        long long tmp;
        std::cin >> tmp;
        a.push(tmp);
    }

    for (int i  = 0; i < m; i++) {
        long long max = a.top();
        a.pop();
        a.push(max /2);
    }

    long long ans = 0;
    while (!a.empty()) {
        ans += a.top();
        a.pop();
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N];

int main() {
  int n; ll k;
  cin >> n >> k;
  REP(i, n) {
    cin >> to[0][i];
    to[0][i]--;
  }
  REP(i, D-1) {
    REP(j, n) {
      to[i+1][j] = to[i][to[i][j]];
    }
  }

  int v = 0;
  rREP(i, D) {
    ll l = 1ll<<i;
    if (l <= k) {
      v = to[i][v];
      k -= l;
    }
  }
  cout << v+1 << endl;

  return 0;
}

Measured memory_bytes: 50484
#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(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  cout<<(a<0?-a*c:0)+(a<=0?d:0)+(b-max(0, a))*e<<endl;
}


Measured memory_bytes: 3124
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
    while(1){
        int n,taro=0,hana=0,nowcard,card[201]={0},next=1;
        scanf("%d",&n);
        if(n==0)
            break;
        for(int i=0;i<n;i++){
            scanf("%d",&nowcard);
                card[nowcard]=1;
        }

        /*
        for(int i=1;i<n*2+1;i++)
            printf("%d",card[i]);
        */

        for(int i=1;;i++){
            if(i==n*2+1){
                i=1;
                if(next==1)
                    next=0;
                else
                    next=1;
            }
            if(next==1&&card[i]==1)
                next=0,card[i]=2,taro++;
            else if(next==0&&card[i]==0)
                next=1,card[i]=2,hana++;
            if(taro==n||hana==n){
                printf("%d\n%d\n",n-hana,n-taro);
                break;
            }
        }
    }
    return 0;
}

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

const int maxn = 200005;

int n, a, ans;
multiset < int > b;

signed main () { 
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a);
        b.insert(a);
    }
    while (!b.empty()) {
        int x = *prev(b.end());
        b.erase(prev(b.end()));
        int to = (1 << (int(double(log(double(x))) / log(2.0)) + 1));
        auto it = b.find(to - x);
        if (it != b.end()) {
            b.erase(it);
            ++ans;
        }
    }
    printf("%d\n", ans);
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bool chkmax(int &x,int y){return x<y?x=y,true:false;}
bool chkmin(int &x,int y){return x>y?x=y,true:false;}

int readint(){
	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;
}

const int cys=1000000007;
int n,k;
ll d[2005][2005],fac[4000005],inv[4000005];

ll mod(ll x){return x>=cys?x-cys:x;}
ll C(ll x,ll y){return x<y?0:fac[x]*inv[y]%cys*inv[x-y]%cys;}

ll qpow(ll x,ll p){
	ll ret=1;
	for(;p;p>>=1,x=x*x%cys) if(p&1) ret=ret*x%cys;
	return ret;
}

int main(){
	n=readint(); k=readint();
	if(k==1) return printf("1\n"),0;
	fac[0]=inv[0]=1;
	for(int i=1;i<=n*k;i++) fac[i]=fac[i-1]*i%cys;
	inv[n*k]=qpow(fac[n*k],cys-2);
	for(int i=n*k-1;i>=1;i--) inv[i]=inv[i+1]*(i+1)%cys;
	d[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++)
			d[i][j]=mod(d[i-1][j]*C((i-1)*(k-1)+j+k-2,k-2)%cys+(j>0?d[i][j-1]:0));
	cout<<d[n][n]*fac[n]%cys<<endl;
	return 0;
}

Measured memory_bytes: 94080
s = input()
k = int(input())
if len(set(list(s))) == 1:
  print(len(s)*k//2)
  exit()
l = list()
t = 0
c = s[0]
for x in s:
  if x == c:
    t += 1
  else:
    c = x
    l.append(t)
    t = 1
l.append(t)
ans = 0
if s[0]==s[-1]:
  ans += l[0]//2 + l[-1]//2 - (l[0]+l[-1])//2
  l[0] += l[-1]
  l.pop()
for x in l:
  ans += (x//2)*k
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cfloat>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define norm(X) ((X) * (X))
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n;
double sum;
double cnt;
vector<pair<double, double> > v;

int main() {

    cin >> n;
    for (int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        v.push_back({x, y});
    }

    sort(v.begin(), v.end());
    do {
        for (int i = 0; i < v.size() - 1; i++) {
            sum += sqrt(norm(v[i + 1].first - v[i].first) +
                        norm(v[i + 1].second - v[i].second));
        }
        
        cnt++;
    } while (next_permutation(v.begin(), v.end()));

    printf("%.*lf\n", DBL_DIG, sum / cnt);

    return 0;
}


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

int main() {
    int count[26];
    fill(count, count + 26, 0);

    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        count[s[i] - 'a']++;
    }

    for (int i = 0; i < 26; i++) {
        if (count[i] == 0) {
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 512
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, k;
    scan(n, k);
    auto c = new long[](k);
    foreach (i ; 1 .. n + 1) {
        c[i % k]++;
    }
    long ans;
    foreach (i ; 0 .. k) {
        if (2*i % k == 0) {
            ans += c[i]^^3;
        }
    }
    writeln(ans);
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    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);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 2556
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Programminng
{
    class AOJ_Volume0007
    {
        public static void Main(string[] args)
        {
            int debt = 100000;
            var input = Console.ReadLine();
            int i = int.Parse(input);

            for (int j = 0; j < i; j++)
            {
                debt = f_debt(debt);
            }
            Console.WriteLine(debt);
        }

        private static int f_debt(int n)
        {
            n = (int)(n * 1.05);
            if (n % 1000 != 0)
            {
                n = n - (n % 1000) + 1000;
            }
            return n;
        }
    }
}

Measured memory_bytes: 5604
#include <iostream>
#include <string>

using namespace std;

int main(){
	string s;
	cin >> s;
	int len = s.size(), answer = 0;
	for(int i = 0; i < (len + 1) / 2; ++i){
		if(s[len - i - 1] != (s[i] != '(' ? s[i] != ')' ? s[i] : '(' : ')')){
			++answer;
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<climits>
#include<cmath>
#include<iomanip>
using namespace std;

double recur(vector<double> &v,int i,int h,double m)
{
    if(i<0 && h > v.size()-h)
        return m;
    if(i<0)
        return 0;
    double head = recur(v,i-1,h+1,m*v[i]);
    double tail = recur(v,i-1,h,m*(1-v[i]));
    return head+tail;
}

void bottomup(vector<double> &v,int n)
{
    vector<vector<double>> dp(n+1,vector<double>(n+1,0));
    dp[0][0] = 1;
    for(int i= 1; i<=n;++i)
    {
        dp[i][0] = dp[i-1][0] *(1-v[i-1]);
        for(int j=1;j<=i;j++)
            dp[i][j] = dp[i-1][j-1] *v[i-1]  + dp[i-1][j]*(1-v[i-1]);
    }
    double ans = 0;
    for(int i=n/2+1;i<=n;i++)
        ans = ans + dp[n][i];
    cout<<setprecision(10)<<ans;
}

int main()
{
    int n{};
    cin>>n;
    vector<double> v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];
    // double ans = recur(v,v.size()-1,0,1);
    // cout<<ans;
    bottomup(v,n);

    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>

#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	
	ll x[5];

	cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

	int g = 0;
	for (int i = 0; i < 5; i++) {
		if (x[i] == 0) {
			g = i;
			break;
		}
	}
	cout << g + 1 << endl;




	return 0;
}

Measured memory_bytes: 3596
(let* ((n (read))
       (lst nil))
  (defun f (str)
    (if (or (equal str "") (<= (parse-integer str) n))
        (progn
          (push str lst)
          (f (format nil "~A3" str))
          (f (format nil "~A5" str))
          (f (format nil "~A7" str)))))
  (f "")
  (princ (count-if (lambda (a) (and (position #\3 a :test #'char=)
                                    (position #\5 a :test #'char=)
                                    (position #\7 a :test #'char=)))
                   lst)))

Measured memory_bytes: 55656
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
	double x1, y1, x2, y2;

	cin >> x1 >> y1 >> x2 >> y2;
	double distance;

	distance = sqrt((y1 - y2) * (y1 - y2) + (x1 - x2) * (x1 - x2));

	cout << fixed << setprecision(6) << distance << endl;
}


Measured memory_bytes: 3300
import java.util.Scanner;
import java.util.Random;
import java.io.PrintWriter;

public class Main{
    public static Random rand = new Random();
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        long start = System.currentTimeMillis();
        int D = Integer.parseInt(sc.next());
        int[] C = new int[26];
        int[] L = new int[26];
        for (int i = 0; i < 26; i++){
            C[i] = Integer.parseInt(sc.next());
            L[i] = 0;
        }
        int[][] S = new int[D][26];
        for (int i = 0; i < D; i++){
            for (int j = 0; j < 26; j++){
                S[i][j] = Integer.parseInt(sc.next());
            }
        }
        int[] Ans = new int[D];
        for (int i = 0; i < D; i++){
            Ans[i] = (i % 26) + 1;
        }
        int maxPoint = calcPoint(Ans, S, C, L, D);
        

        while (System.currentTimeMillis() - start < 1850){
            maxPoint = change(Ans, S, C, L, D, maxPoint, 1900 - (System.currentTimeMillis() - start));
        }

        for (int i = 0; i < D; i++){
            out.print(Ans[i]);
            out.print("\n");
        }
        //template
        sc.close();
        out.flush();
    }

    public static int calcPoint(int[] Ans, int[][] S, int[] C, int[] L, int D){
        int point = 0;
        for (int i = 0; i < 26; i++){
            L[i] = 0;
        }
        for (int i = 0; i < D; i++){
            point += S[i][Ans[i] - 1];
            L[Ans[i] - 1] = i + 1;
            for (int j = 0; j < 26; j++){
                point -= C[j] * (i + 1 - L[j]);
            }
        }
        return point;
    }

    public static int change(int[] Ans, int[][] S, int[] C, int[] L, int D, int maxPoint, long t){
        int ci = rand.nextInt(D);
        int before = Ans[ci];
        Ans[ci] = rand.nextInt(26) + 1;
        int newPoint = calcPoint(Ans, S, C, L, D);
        if (newPoint < maxPoint){
            if (rand.nextInt(1900) < t){
                return newPoint;
            }
            else{
                Ans[ci] = before;
            return maxPoint;
            }    
        }
        else{
            return newPoint;
        }
    }
}

Measured memory_bytes: 42140
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int get_digits(ll x) {
  int res = 0;
  while (x > 0) {
    res++;
    x /= 10;
  }
  return res;
}

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

  int n;
  cin >> n;
  int ans = 0;
  rep(i, 1, n + 1) {
    if (get_digits(i) % 2 == 1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace tst
{
    class Program
    {
        static bool IsEmpty(int top)
        {
            //スタックが空かどうかどうか調べる
            bool judge = top ==0 ? true : false;
            return judge;
        }
        static bool IsFull(int top, int max) 
        {
            //スタックが満杯かどうか調べる
            bool judge = top >= max - 1 ? true : false;
            return judge;
        }
        static void Push(int x,ref int[]S, ref int top, int max)
        {   //スタックの先頭(頂点)に要素xを追加する
            if (IsFull(top, max))
            {   
                //スタックが満杯だとエラー
                Console.WriteLine("エラー（オーバーフロー）");
            }
            top++;
            S[top] = x;
        }
        static int Pop(ref int top, int[]S)
        {
            //スタックの先頭(頂点)から要素を取り出す
            if (IsEmpty(top))
            {
                //スタックが空だとエラー
                Console.WriteLine("エラー（アンダーフロー）");
            }
            top--;
            return S[top + 1];
        }
        static void Main(string[] args)
        {
            //input//1 2 +//1 2 + 3 4 - *
            string str = Console.ReadLine();
            string[] dt = str.Split(' ');//string型
            //dt=[1,2,+]みたいに入る
            int max = 100 + 1;
            int[] S = new int[max];
            int top = 0;
            for (int i=0; i<dt.Length; i++)
            {
                if (dt[i] == "+"|| dt[i] == "-" || dt[i] == "*" )
                {
                    //演算子ならスタックの上から２つを計算に入れる
                    int x = Pop(ref top, S);//一番上
                    int y = Pop(ref top, S);//その次
                    int p = 0;
                    switch (dt[i])
                    {
                        case "+":
                            p = x + y;
                            break;
                        case "-":
                            p = y - x;
                            break;
                        case "*":
                            p = x * y;
                            break;
                    }
                    Push(p, ref S, ref top, max);
                    IsEmpty(top);
                }
                else
                {   
                    Push(int.Parse(dt[i]), ref S, ref top, max);
                }
            }
            Console.WriteLine(S[1]);

        }
    }
}


Measured memory_bytes: 17976
n=int(input())
h=list(map(int,input().split()))
count=0
while h.count(0)!=len(h):
  stack=[]
  substack=[]
  for i in range(len(h)):
    if h[i]!=0:
      substack.append(h[i])
    else:
      if len(substack)>0:
        stack.append(substack)
      stack.append([0])
      substack=[]
  if len(substack)>0:
    stack.append(substack)
  h=[]
  for i in range(len(stack)):
    if max(stack[i])==0:
      h+=stack[i]
      continue
    x=min(stack[i])
    count+=x
    for j in range(len(stack[i])):
      stack[i][j]-=x
    h+=stack[i]
print(count)

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

typedef long long LL;
const int N = 200005, inf = 0x3f3f3f3f, mod = 1000000007;

int n, x, y, c[N], w[N], min[N], f[N], sum[N];

std::map<int, int> map[N];

int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
void link(int x, int y) { f[find(x)] = find(y); }

int factor[N], ifactor[N];
int pow(int x, int y, int ans = 1) {
	for (; y; y >>= 1, x = (LL) x * x % mod)
		if (y & 1) ans = (LL) ans * x % mod;
	return ans;
}

void init(int n) {
	factor[0] = 1;
	for (int i = 1; i <= n; ++i)
		factor[i] = (LL) factor[i - 1] * i % mod;
	ifactor[n] = pow(factor[n], mod - 2);
	for (int i = n; i; --i)
		ifactor[i - 1] = (LL) ifactor[i] * i % mod;
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> x >> y, init(n);
	w[0] = inf;
	for (int i = 1; i <= n; ++i) {
		f[i] = i, std::cin >> c[i] >> w[i];
		if (w[i] < w[min[c[i]]]) min[c[i]] = i;
	}
	int p = 0, q = 0;
	for (int i = 1; i <= n; ++i) {
		if (w[min[i]] < w[p]) q = p, p = min[i];
		else if (w[min[i]] < w[q]) q = min[i];
	}
	for (int i = 1; i <= n; ++i)
		if (w[i] + w[min[c[i]]] <= x) link(i, min[c[i]]);
	for (int i = 1; i <= n; ++i) {
		if (c[i] != c[p] && w[i] + w[p] <= y) link(i, p);
		if (c[i] != c[q] && w[i] + w[q] <= y) link(i, q);
	}
	for (int i = 1; i <= n; ++i) ++map[find(i)][c[i]];
	int ans = 1;
	for (int i = 1; i <= n; ++i) if (i == find(i)) {
		int sum = 0;
		for (auto p : map[i])
			sum += p.second, ans = (LL) ans * ifactor[p.second] % mod;
		ans = (LL) ans * factor[sum] % mod;
	}
	std::cout << ans << '\n';
	return 0;
}

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

typedef complex<double> P;

double cross(P a,P b){
	return imag(a*conj(b));
}
double area(P a,P b,P c){
	return abs(cross(a-c,b-c));
}
bool on(P a,P b,P p){
	return abs(a-p) + abs(p-b) - abs(a-b) < 1e-9;
}


P in(){
	double x,y;
	if(cin >> x >> y)
		return P(x,y);
	else exit(0);
}
int main(){
	P a,b,c,d;
	while(true){
		a = in();
		b = in();
		c = in();
		d = in();
		if( !on(a,b,d) and !on(b,c,d) and !on(c,a,d) and area(a,b,d) + area(b,c,d) + area(c,a,d) - area(a,b,c) < 1e-9 )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

Measured memory_bytes: 3100
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
	int N; cin >> N;
	int sum = 0;
	vector<int> s(N);
	for (auto& si : s){
		cin >> si;
		sum += si;
	}
	if (sum % 10) cout << sum << endl;
	else{
		sort(s.begin(), s.end());
		for (int i = 0; i < N; ++i){
			if (s[i] % 10){
				cout << (sum - s[i]) << endl;
				return 0;
			}
		}
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		boolean[] submit = new boolean[30];
		Arrays.fill(submit, false);
		
		for(int i = 0; i < 28 ; i++){
			submit[Integer.parseInt(br.readLine()) - 1] = true;
		}
		
		for(int i = 0; i < 30; i++){
			if(submit[i] == false){
				System.out.println(i + 1);
			}
		}
	}

}

Measured memory_bytes: 24072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  cout << (N-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    data = input()
    if data == ".": break

    inqrt1 = []
    outqrt1 = []

    nowqrt = False
    stringin = ""
    stringout = ""
    count = 0
    for char in data:
        if nowqrt:
            if char != '"' and count != len(data) - 1:
                stringin += char
            else:
                if count == len(data) - 1: stringin += char
                inqrt1.append(stringin)
                stringin = ""
                nowqrt = False
        else:
            if char != '"' and count != len(data) - 1:
                stringout += char
            else:
                if count == len(data) - 1: stringout += char
                nowqrt = True
                outqrt1.append(stringout)
                stringout = ""
        count += 1

    data = input()
    inqrt2 = []
    outqrt2 = []

    nowqrt = False
    stringin = ""
    stringout = ""
    count = 0
    for char in data:
        if nowqrt:
            if char != '"' and count != len(data) - 1:
                stringin += char
            else:
                if count == len(data) - 1: stringin += char
                inqrt2.append(stringin)
                stringin = ""
                nowqrt = False
        else:
            if char != '"' and count != len(data) - 1:
                stringout += char
            else:
                if count == len(data) - 1: stringout += char
                nowqrt = True
                outqrt2.append(stringout)
                stringout = ""
        count += 1

    difcount = 0
    if len(inqrt1) != len(inqrt2) or outqrt1 != outqrt2:
        print("DIFFERENT")
    elif inqrt1 == inqrt2:
        print("IDENTICAL")
    else:
        for i in range(len(inqrt1)):
            if inqrt1[i] != inqrt2[i]: difcount += 1
        if difcount <= 1: print("CLOSE")
        else: print("DIFFERENT")
            



Measured memory_bytes: 5584
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main(){
  	char s[3];
	cin >> s;
  	// cout << s << '\n';

  	if(strncmp (s,"ABC",3) == 0)
      cout << "ARC" << endl;
  	else
      cout << "ABC" << endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    
    int n,m;
    cin>>n>>m;
    vi v(n,-1);
    rep(i,m){
        int s,c;
        cin>>s>>c;
        s--;
        if(v[s]==-1||v[s]==c){
            v[s]=c;
        } else {
            fin(-1);
            return 0;
        }
    }
    if(v[0]==-1&&n==1)v[0]=0;
    else if(v[0]==-1)v[0]=1;
    rep(i,n)if(v[i]==-1)v[i]=0;

    if(n!=1&&v[0]==0){
        fin(-1);
        return 0;
    }

    rep(i,n)cout<<v[i];
    cout<<endl;
}


Measured memory_bytes: 256
n = int(input())
xy1 = []
xy2 = []
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        continue
    cos = x / (x ** 2 + y ** 2) ** 0.5
    sin = y / (x ** 2 + y ** 2) ** 0.5
    if sin >= 0:
        xy1.append([x, y, cos])
    else:
        xy2.append([x, y, cos])
xy1.sort(key = lambda x: x[2], reverse = True)
xy2.sort(key = lambda x: x[2])
xy = xy1 + xy2
xy = xy + xy
max_vector = 0
for i in range(len(xy) // 2):
    for j in range(i, i + len(xy) // 2):
        x, y = 0, 0
        for k in range(i, j + 1):
            x += xy[k][0]
            y += xy[k][1]
        max_vector = max(max_vector, (x ** 2 + y ** 2) ** 0.5)
print(max_vector)

Measured memory_bytes: 3188
open Batteries
let n, k = Scanf.scanf "%d %d" (fun x y -> x, y)
let arr = Array.make 100010 0
let () =
  (1--n) |> Enum.iter begin fun _ ->
    Scanf.scanf " %d %d" (fun a b -> arr.(a) <- arr.(a) + b)
  end;
  (1--100000) |> Enum.iter begin fun i ->
    arr.(i) <- arr.(i) + arr.(i-1)
  end;
  Array.findi (fun v -> v >= k) arr
  |> Printf.printf "%d\n"


Measured memory_bytes: 5504
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 1000009
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db double
#define noop
#define flu fflush(stdout)
#define imp {cout<<"No\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}
#define debug_vecvec(vec,n) {rep(idxi,n) {for(auto idxi2:vec[idxi]) cout<<idxi2<<" "; cout<<"\n";}}
 
// LOOK AT THESE BEFORE SUBMISSION
// LOOK AT THESE BEFORE SUBMISSION
// ============================================================
// Nmax value and is index access offset taking it beyond Nmax.
// Precision error in case of real numbers.
// N vs N2 chosen correctly.
// Modulo applied everywhere.
// Flush in case of interactive.
// Don't erase value in multiset.
// Check for array indices out of bound (in pre or suff sums).
// Correct return value for functions.
// Confirm the letter case of yes and no.
// ============================================================

ll solve(ll n) {
    if(n==1) return 1;
    ll a = solve(n/2);
    return 2*a+1;
    // else 
}

int main() {
        
    get(n);
    printf("%lld\n", solve(n));

    return 0;  
}   

Measured memory_bytes: 256
import sys

N, M = map(int, sys.stdin.readline().split())
AB = sorted([list(map(int, sys.stdin.readline().split())) for _ in range(N)])

ans = 0
count = 0
i = 0
for _ in range(M):
    if count + AB[i][1] < M:
        count += AB[i][1]
        ans += AB[i][0] * AB[i][1]
        i += 1
    else:
        ans += AB[i][0] * (M - count)
        break

print(ans)

Measured memory_bytes: 28572
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair

int main(){
    int n;
    while(cin>>n,n){
        vs c(n,"");
        int ml=0;
        rep(i,n){
            string s;
            cin>>s;
            int f=1;
            for(auto x:s){
                if(f==1)c[i]+=x;
                f=0;
                if("aiueo"s.find(x)!=string::npos)f=1;
            }
            ml=max(ml,(int)c[i].length());
        }
        bool isOK=true;
        range(i,1,ml+1){
            isOK=true;
            set<string> st;
            for(auto x:c){
                string str=x.substr(0,i);
                //cout<<str<<endl;
                if(st.find(str)!=st.end()) {isOK=false;break;}
                st.insert(str);
            }
            if(isOK){
                cout<<i<<endl;
                break;
            }
        }
        if(!isOK)cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[200000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    
    if (n % 2 == 0)
    {
        for (int i = n - 1; i >= 0; i -= 2)
            cout << a[i] << ' ';
        for (int i = 0; i < n; i += 2)
            cout << a[i] << ' ';
    }
    else
    {
        for (int i = n - 1; i >= 0; i -= 2)
            cout << a[i] << ' ';
        for (int i = 1; i < n; i += 2)
            cout << a[i] << ' ';
    }
}


Measured memory_bytes: 2944