akhauriyash/Code-Regression huggingface dataset:
typedef  long long ll;
#include <bits/stdc++.h>
using namespace std;

int main() {
    ll n;
    std::cin >> n;
    
    if(n<=8){
        if(n==3){
            std::cout << "2 5 63" << std::endl;
        }else{
            std::cout << "2 3 4 9 ";
            for (int i = 0; i < n-4; i++) {
                std::cout << 12*i+12<<" ";
            }
            std::cout << std::endl;
        }
        return 0;
    }

    for (int i = 0; i < n/8; i++) {
        std::cout << i*12+2<<" "<<i*12+3<<" "<<i*12+4<<" " <<i*12+6 << " ";
        std::cout << i*12+8<<" "<<i*12+9<<" "<<i*12+10<<" "<<i*12+12 << " ";
    }
    ll offset = n/8;
    
    if(n%8==0){
        std::cout << std::endl;
        return 0;
    }
    if(n%2==1){
        std::cout << offset*12+12<<" ";
    }
    for (int i = 0; i < (n%8)/2; i++) {
        std::cout << offset*12+2+i <<" "<< offset*12+10-i <<" ";
    }
    std::cout << std::endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <iostream>
using namespace std;
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define fi first
#define se second
long long a[10010];
long long b[10010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%lld",&b[i]);
	}
	long long l=0,r=0;
	for(int i=1;i<=n;i++){
		if(a[i]>b[i]){
			r+=a[i]-b[i];
		}
		if(a[i]<b[i]){
			l+=(b[i]-a[i]+1)/2;
			r+=(b[i]-a[i])%2;
		}
	}
	if(r<=l){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cctype>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

#define ll long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MD 1000000007

char sep[3] = " \n";
int i, j, k, l, m, n;
double PI = acos(-1);


class Dice{
  int t;
 public:
  int s[6];

  Dice() {
    rep(i,6) cin >> s[i];
  }

  void N() { t=s[0], s[0]=s[1], s[1]=s[5], s[5]=s[4], s[4]=t; }
  void S() { t=s[0], s[0]=s[4], s[4]=s[5], s[5]=s[1], s[1]=t; }
  void E() { t=s[0], s[0]=s[3], s[3]=s[5], s[5]=s[2], s[2]=t; }
  void W() { t=s[0], s[0]=s[2], s[2]=s[5], s[5]=s[3], s[3]=t; }
};

int pat[7][5] = {
  {1, 2, 4, 3, 1},
  {0, 3, 5, 2, 0},
  {0, 1, 5, 4, 0},
  {0, 4, 5, 1, 0},
  {0, 2, 5, 3, 0},
  {2, 1, 3, 4, 2}
};
int d[6];

int idx(int x) {
  int i;
  rep(i,6) if (d[i]==x) return i;
  exit(255);
}

int main() {
  rep(i,6) cin >> d[i];
  cin >> n;
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    a = idx(a), b = idx(b);
    rep(j,4) if (pat[a][j] == b) {
      cout << d[pat[a][j+1]] << endl;
    }
  }
  
  return 0;
}
  

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
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;
}
int main() {
    string S;
    int K;
    cin >> S >> K;
    vector<string> v;
    rep(i, 0, S.size()) {
        rep(j, 1, K + 1) {
            string tmp = S.substr(i, j);
            // if(j > S.size()) {
            //     //substrの二番目の引数は範囲外でもいけるのか！
            //     cout << i << "," << j << ",tmp:" << tmp << endl;
            // }
            v.push_back(tmp);
        }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v[K - 1] << endl;
}


Measured memory_bytes: 1660
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
	int a,b,c;
	while(1){
		scanf("%d %d",&a,&b);
		if(a+b==0) break;
		if(a>b){
			c=b;
			b=a;
			a=c;
		}
		printf("%d %d\n",a,b);
	}
	return 0;
}

Measured memory_bytes: 1028
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    a: i64,
    b: i64,
    c: i64,
    }
    let mut v = Vec::new();
    v.push(a);
    v.push(b);
    v.push(c);
    v.sort();
    println!("{} {} {}", v[0], v[1], v[2]);
}
//nを入力後ctrl+Z


Measured memory_bytes: 5036
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long x,long y){
    if(y==0)return x;

    return gcd(y,x%y);
}
long long lcm(long x,long y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

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

    cout<<S.substr(0,4)+" "+S.substr(4)<<endl;

    return 0;
}

Measured memory_bytes: 256
d,n=map(int,input().split())

if d==0:
    if n==100:
        print("101")
    else:
        print(n)
elif d==1:
    if n==100:
        print("10100")
    else:
        print(100*n)
else:
    if n==100:
        print("1010000")
    else:
        print(10000*n)

Measured memory_bytes: 3060
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a > b){
        printf("a > b\n");
    }else if(a < b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
}



Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> vull;
typedef vector<ll> vll;
typedef vector<ui> vui;
typedef vector<long> vl;
typedef vector<int> vi;

typedef pair<ull, ull> pull;
typedef pair<ll, ll> pll;
typedef pair<ui, ui> pui;
typedef pair<long, long> pl;
typedef pair<int, int> pi;

int main() {
    int n; cin >> n;
    vi x, y, h;
    x.resize(n);
    y.resize(n);
    h.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> h[i];
    }

    bool ok = false;
    for (int cx = 0; cx <= 100; ++cx ) {
        for (int cy = 0; cy<= 100; ++cy) {
            bool ok = true;
            int height = -1;
            for (int i = 0; i < n; ++i) {
                if (h[i] > 0) {
                    int temp = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
                    if (height == -1) {
                        height = temp;
                    } else {
                        if (height != temp) {
                            ok = false;
                            break;
                        }
                    }
                }
            }

            if (!ok) continue;
            
            for (int i = 0; i < n; ++i) {
                if (h[i] == 0) {
                    int temp = abs(cx - x[i]) + abs(cy - y[i]);
                    if (height > temp) {
                        ok = false;
                        break;
                    }
                }
            }

            if (!ok) continue;

            cout << cx << " " << cy << " " << height << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    int cnt=0;
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll husoku=0;
    vector<int> huriwake;

    rep(i,n){
        ll c = a[i] - b[i];
        if(c < 0){
            husoku += -c;
            cnt++;
        }
        else if(c>0){
            huriwake.push_back(c);
           // cout << c << endl;
        }
    }
    sort(huriwake.rbegin(),huriwake.rend());
    
    //cout << husoku <<endl;
    rep(i,huriwake.size()){
        if(husoku> 0){
            husoku -= huriwake[i];
            cnt++;
        }
    }
    // cout << husoku  <<endl;
    if(husoku <= 0)cout << cnt << endl;
    else cout << -1 <<endl;
    return 0;
    
    
    

}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll n, k;
ll a[51], b[51];
ll rec(ll y, ll x) {
  if(x == 1) return y == 0 ? 1 : 0;
  else if(a[y] <= x) return b[y];
  else if(a[y] / 2 + 1 == x) return b[y - 1] + 1;
  else if(a[y] / 2 + 1 < x && x < a[y]) return b[y - 1] + 1 + rec(y - 1, x - (a[y] / 2 + 1));
  else return rec(y - 1, x - 1);
}

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

  cin >> n >> k;
  a[0] = 1; b[0] = 1;
  FOR(i, 1, n + 1) {
    a[i] = 2LL * a[i - 1] + 3;
    b[i] = 2LL * b[i - 1] + 1;
  }

  cout << rec(n, k) << endl;
}


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

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A, B, C;

    cin >> A >> B >> C;
    if (A+B >= C){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,dist[100005];
vector<int>g[100005];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >pq;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	scanf("%d",&k);
	memset(dist,-1,sizeof(dist));
	for(int i=0;i<k;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		dist[a]=b;
		pq.push(make_pair(b,a));
	}
	while(!pq.empty())
	{
		pair<int,int> p=pq.top();pq.pop();
		for(int i=0;i<g[p.second].size();i++)
		{
			if(dist[g[p.second][i]]==-1)
			{
				dist[g[p.second][i]]=p.first+1;
				pq.push(make_pair(dist[g[p.second][i]],g[p.second][i]));
			}
			else if(dist[g[p.second][i]])
			{
				if(abs(dist[g[p.second][i]]-p.first)!=1)
				{
					puts("No");
					return 0;
				}
			}
		}
	}
	puts("Yes");
	for(int i=0;i<n;i++)printf("%d\n",dist[i]);
}

Measured memory_bytes: 7924
s = sorted(input())
t = sorted(input(), reverse=True)
len_s = len(s)
len_t = len(t)
n_passed = 0

min_len = min(len_s, len_t)
for i in range(min_len):
    if s[i] < t[i]:
        print("Yes")
        exit()

if len_s < len_t:
    t = sorted(t)
    for i in range(len_s):
        if s[i] == t[i]:
            n_passed += 1
    if n_passed == len_s:
        print("Yes")
        exit()
        
print("No")

Measured memory_bytes: 3064
N = int(input())
v = list(map(int,input().split()))

for i in range(N):
    if len(v) == 1:
        pass
    else:
        if min(v) in v:
            aaa =min(v)
            v.remove(min(v))
        if min(v) in v:
            bbb =min(v)
            v.remove(min(v))
            ccc =(aaa + bbb)/2
            v.append(ccc)
print(v[0])

Measured memory_bytes: 3060
S = list(input())
N = len(S)

for i in range(N // 2):
    if S[i] != S[-i - 1]:
        print("No")
        quit()

S2 = S[: (N - 1) // 2]
N2 = len(S2)
for i in range(N2 // 2):
    if S2[i] != S2[-i - 1]:
        print("No")
        quit()

S3 = S[(N + 3) // 2 - 1:]
N3 = len(S3)
for i in range(N3 // 2):
    if S3[i] != S3[-i - 1]:
        print("No")
        quit()

print("Yes")


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	int X;
	cin >> X;
	if (X >= 30)cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
#include<string>
#include<map>

using namespace std;


#define mod(cans) cans%10**9+7
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define pl_twin(x,y,z) for(int i=0;i<x;i++){cin>>y[i]>>z[i];}
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define st(s) size_t size = s.length()
#define prians(Answer) cout<<Answer<<"\n"
#define make_pair mp;
#define com_div(x,Co) for(int i=1;i<x+1;i++){if(x%i==0){Co++;}}
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;
typedef greater<int> gi;

int main()
{   
    int a,b;
    cin>>a>>b;
    if(a<=5){cout<<0;}
    else if(a>=13) cout<<b;
    else cout<<b/2;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 01.01.2020 21:06:30       
**/
#include <bits/stdc++.h>

using namespace std;

template <typename T>
class fenwick {
 public:
  vector<T> fenw;
  int n;

  fenwick(int _n) : n(_n) {
    fenw.resize(n);
  }

  void modify(int x, T v) {
    while (x < n) {
      fenw[x] += v;
      x |= (x + 1);
    }
  }

  T get(int x) {
    T v{};
    while (x >= 0) {
      v += fenw[x];
      x = (x & (x + 1)) - 1;
    }
    return v;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> grid(3, vector<int>(n));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < n; j++) {
      cin >> grid[i][j];
      --grid[i][j];
    }
  }
  vector<int> a(n);
  vector<int> flip(2);
  for (int i = 0; i < n; i++) {
    if (grid[0][i] / 3 != grid[1][i] / 3 || grid[1][i] / 3 != grid[2][i] / 3 || grid[1][i] % 3 != 1) {
      cout << "No" << '\n';
      return 0;
    }
    a[i] = grid[0][i] / 3;
    if (a[i] % 2 != i % 2) {
      cout << "No" << '\n';
      return 0;
    }
    flip[i % 2] ^= (grid[0][i] % 3 == 2);
  }
  for (int r = 0; r < 2; r++) {
    fenwick<int> fenw(n);
    for (int i = r; i < n; i += 2) {
      flip[r ^ 1] ^= (fenw.get(n - 1) - fenw.get(a[i])) % 2;
      fenw.modify(a[i], 1);
    }
  }
  cout << (flip[0] + flip[1] == 0 ? "Yes" : "No") << '\n';
  return 0;
}


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

using namespace std;

const int64_t INF = 1LL << 60;

template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  int64_t T;
  cin >> N >> T;
  vector<int64_t> A, B, C;
  for (int i = 0; i < N; i++) {
    int64_t a, b;
    cin >> a >> b;
    if (a == 0) {
      C.emplace_back(b + 1);
    } else {
      A.emplace_back(a);
      B.emplace_back(b);
    }
  }
  vector<int> idx(A.size());
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(),
       [&](int a, int b) { return A[b] * (B[a] + 1) < A[a] * (B[b] + 1); });
  vector<int64_t> NA, NB;
  for (int i : idx) {
    NA.emplace_back(A[i]), NB.emplace_back(B[i]);
  }
  A = NA, B = NB;
  sort(C.begin(), C.end());
  vector<int64_t> dp(31, T + 1);
  dp[0] = 0;
  for (int i = 0; i < (int)A.size(); i++) {
    for (int j = (int)dp.size() - 2; j > -1; j--) {
      if (dp[j] > T) continue;
      chmin(dp[j + 1], (A[i] + 1) * (dp[j] + 1) + B[i]);
    }
  }
  int res = 0;
  for (int i = 0; i < (int)dp.size(); i++) {
    if (dp[i] > T) continue;
    int64_t r = T - dp[i];
    int p = 0;
    while (p < (int)C.size() && r >= C[p]) {
      r -= C[p++];
    }
    res = max(res, i + p);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 9188
use std::io;


fn main() {
    let s = read_one::<String>()
        .chars().collect::<Vec<char>>();
    let mut flg = true;
    for i in 0..s.len() {
        if s[i] == ' ' {
            if s[i - 1] != s[i + 1] { flg = false; }
        }
    }

    if flg { println!("YES"); }
    else { println!("NO"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	void run() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			
			long ans = 0;
			long sumAll = (long) (n + 1) * n / 2;
			for (int i=k;i<=n+1;i++) {
				long min = (long) i * (i - 1) / 2;
				int z = n - i;
				long max = sumAll;
				if (z >=0) {
					long zz = (long) (z + 1) * z / 2;
					max = sumAll - zz;
				}

				// System.err.println(z + " " + min + " " + max);
				
				ans += (max - min + 1);
			}

			ans %= 1000000007;
			
			System.out.print(ans);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}


Measured memory_bytes: 35828
N = input()

buff = int(N)
N = list(N)
# N = N[::-1]
keta = len(N)
ans = 0
if keta % 2 == 0:
    gain = 1
    for i in range(0, keta-1, 2):
        ans += (9*gain)
        gain = gain * 100

    print(ans)

else:
    if keta == 1:
        print(N[0])
        exit()

    gain = 1
    for i in range(0, keta-1, 2):
        ans += (9*gain)
        gain = gain * 100

    gg = 9
    for i in range(keta-2):
        gg *= 10
        gg += 9
    # print(gg)
    ans += buff-gg
    print(ans)

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    string s;
    cin >> s;

    int ans = 0;
    int one = 0, two = 0;
    for(int i = 0; i < s.size(); i++){
        
        if(s[i] == '0') one++;
        if(s[i] == '1') two++;
        
        if(0 < one && 0 < two){
            ans += 2;
            one--; two--;
        }
    }

    cout << ans << endl;

    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root=NIL;
Node treeMinimum(Node );
Node treeMaximum(Node );
Node treeSearch(Node , int );
Node treeSuccessor(Node );
void treeDelete(Node );
void insert(int );
void inorder(Node );
void preorder(Node );

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Node treeMinimum(Node x){
  if(x->left == NIL) return x;

  else treeMinimum(x->left);

  return x;
}

Node treeMaximum(Node x){
  if(x->right == NIL) return x;

  else treeMaximum(x->right);

  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL) return u;

  else if(k == u->key) return u;

  else if(k < u->key) return treeSearch(u->left,k);

  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node a;


  if(x->right != NIL) return treeMinimum(x->right);
  a = x->parent;

  while(1){
    if(a == NIL && x->key != a->right->key) break;
    x = a;
    a = a->parent;
  }

  return a;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y


  if(z->left == NIL) y=z;
  else if(z->right == NIL) y=z;
  else y = treeSuccessor(z);


  if(y->left!=NIL) x=y->left;
  else x = y->right;


  if(x!=NIL) x->parent = y->parent;


  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y!=z) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right;

  }
  z->parent = y;

  if(y == NIL) root = z;

  else if(z->key < y->key) y->left = z;

  else y->right = z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u==NIL) return ;

  printf(" %d",u->key);

  preorder(u->left);

  preorder(u->right);;
}



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

int main()
{
	bool flag = true;
	int count = 0;
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++)
	{
		if ((i==0)&&(S[i]!='A')){
			flag = false;
		}
		if ((i>1)&&(i<S.size()-1)&&(S[i]=='C')){
			if (count>0){
				flag = false;
			}
			count = i;
		}
		if ((i>0)&&(i!=count)&&(S[i]<'a')||(i>0)&&(i!=count)&&(S[i]>'z')){
			flag = false;
		}
	}
	if (count==0){
		flag = false;
	}
	if (flag){
		cout << "AC" << endl;
	}else{
		cout << "WA" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const int MX = 1e5+7;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	int r=n%10;
	if(r==2 or r==4 or r==5 or r==7 or r==9)cout<<"hon\n";
	else if(r==0 or r==1 or r==6 or r==8)cout<<"pon\n";
	else cout<<"bon\n";
	
	return 0;
}


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

int main(){
  string s,ans = "";
  cin >> s;
  //cout << s << endl;
  int n = s.size();
  //cout << n << endl;
  int n_ans = 0;
  int i;
  for(i = 0;i<n;i++){
    if(s.at(i) == 'A' || s.at(i) == 'T' ||s.at(i) == 'G' ||s.at(i) == 'C'){
    ans = ans + s.at(i);
      //cout << ans << endl;   
    }
    else{
       if(ans.size()> n_ans){
        n_ans = ans.size();
      }
      ans = "";
    }
  }
   if(ans.size()> n_ans){
        n_ans = ans.size();
      }
  cout << n_ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5+5;


char buf[N];
int n,vis[N];
ll bit[N];
vector<int> pos[26];

void add(int x, ll v){
	++x;
	while(x <= n){
		bit[x] += v;
		x += x&-x;
	}
}

ll ask(int x){
	++x;
	ll res = 0;
	while(x){
		res += bit[x];
		x -= x&-x;
	}
	return res;
}

int main(){
	scanf("%s", buf);
	n = strlen(buf);
	for(int i=0;i<n;++i){
		pos[buf[i]-'a'].push_back(i);
		add(i, 1);
	}
	for(int i=0,x=0;i<26;++i){
		if(pos[i].size() & 1){
			if(++x > 1){
				puts("-1");
				return 0;
			}
		}
	}
	ll ans = 0;
	for(int i=0;i<n;++i){
		if(vis[i]) continue;
		auto &v = pos[buf[i]-'a'];
		int j = v.back();
		v.pop_back();
		ll k = ask(n-1) - ask(j);
		if(i!=j) ans += k;
		else ans += k/2;
		vis[j] = 1;
		add(j, -1);
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 3448
#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 CEVCOUT(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 M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  string s;  cin >> s;
  ll move[4];
  fill(move, move + 4, 0);
  for(int i = 0 ; i < s.size() ; i++){
    switch(s[i]){
    case 'N': move[0] += 1;  break;
    case 'S': move[1] += 1;  break;
    case 'E': move[2] += 1;  break;
    case 'W': move[3] += 1;  break;
    }
  }

  if(move[0] != 0 && move[1] == 0 || move[1] != 0 && move[0] == 0)
    cout << "No" << endl;
  else if(move[2] != 0 && move[3] == 0 || move[3] != 0 && move[2] == 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var S = cin.next;
        var T = cin.next;
        var D = new Dictionary<char, char>();
        var E = new Dictionary<char, char>();
        for (int i = 0; i < S.Length; i++)
        {
            if (D.ContainsKey(T[i]))
            {

                if (D[T[i]] != S[i])
                {
                    WriteLine("No");
                    return;
                }
            }
            else
            {
                D[T[i]] = S[i];
            }

            if (E.ContainsKey(S[i]))
            {
                if (E[S[i]] != T[i])
                {
                    WriteLine("No");
                    return;
                }
            }
            else
            {
                E[S[i]] = T[i];
            }
            
        }
        WriteLine("Yes");
    }
}
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 16096
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

double Abs(double a, double b) {
  if (a > b) {
    return a - b;
  } else {
    return b - a;
  }
}

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  sort(a.begin(), a.end());

  long long ans_n = a[n - 1];

  double epsilon = 10000000000;
  long long ans_r;
  for (int i = 0; i < n; i++) {
    if (Abs(a[i] * 1.0, ans_n * 1.0 / 2) < epsilon) {
      epsilon = Abs(a[i] * 1.0, ans_n * 1.0 / 2);
      ans_r = a[i];
    }
  }

  cout << ans_n << " " << ans_r << "\n";

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<int> L(2*N);
  REP(i,2*N)cin>>L[i];
  sort(ALL(L));
  int ans=0;
  REP(i,N){
    ans+=L[i*2];
  }
  cout<<ans<<endl;
}


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


int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int w = tx - sx;
    int h = ty - sy;
    for (int i = 0; i < w; i++) {
        printf("R");
    }
    for (int i = 0; i < h; i++) {
        printf("U");
    }
    for (int i = 0; i < w; i++) {
        printf("L");
    }
    for (int i = 0; i < h+1; i++) {
        printf("D");
    }
    for (int i = 0; i < w+1; i++) {
        printf("R");
    }
    for (int i = 0; i < h+1; i++) {
        printf("U");
    }
    printf("L");
    printf("U");
    for (int i = 0; i < w+1; i++) {
        printf("L");
    }
    for (int i = 0; i < h+1; i++) {
        printf("D");
    }
    printf("R\n");
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;

void main()
{
    string s = readln().chomp;
    if (s[$ - 1] == '0' ||
        s[$ - 1] == '2' || 
        s[$ - 1] == '4' ||
        s[$ - 1] == '6' ||
        s[$ - 1] == '8' ) {
        writeln(s);
    } else {
        writeln(s.to!(int) * 2);
    }
}


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

int main(){
  int W,H,N; cin >> W >> H >> N;
  int w1=0,w2=W,h1=0,h2=H;
  int x,y,a;
  for(int i=0; i<N; i++){
    cin >> x >> y >> a;
    switch(a){
      case 1:
        w1=max(w1,x); break;
      case 2:
        w2=min(w2,x); break;
      case 3:
        h1=max(h1,y); break;
      case 4:
        h2=min(h2,y); break;
    }
  }
  cout << max(w2-w1,0)*max(h2-h1,0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int n,m,l;
  cin >> n >> m >> l;
  long long mat1[n][m],mat2[m][l],ans[n][l];
  REP(i,n){
    REP(j,m){
      cin >> mat1[i][j];
    }
  }
  REP(i,m){
    REP(j,l){
      cin >> mat2[i][j];
    }
  }
  //行列の計算
  REP(i,n){
    REP(j,l){
      ans[i][j]=0;
      REP(k,m){
        ans[i][j] +=mat1[i][k]*mat2[k][j];
      }
    }
  }

  REP(i,n){
    REP(j,l){
      cout << ans[i][j];
      if(j==l-1)
        cout << endl;
      else
        cout <<' ';
    }
  }
}

Measured memory_bytes: 1396
a, b = list(map(int, input().split()))
l = list(range(1, 1001))
s = int(b / 0.1)
t = int(a / 0.08)
temp_a = int(a / 0.08)
temp_b = int(b / 0.1)
ans_8 = []
ans_10 = []
for i in l:
    if i >= t:
        temp = int(i * 0.08)
        if temp == a:
            ans_8.append(i)
for i in l:
    if i >= s:
        temp = int(i * 0.1)
        if temp == b:
            ans_10.append(i)
s = set(ans_8) & set(ans_10)
if s:
    print(min(s))
else:
    print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll N;
  cin >> N;
  vll C(N - 1);
  vll S(N - 1);
  vll F(N - 1);
  rep(i, N - 1) {
    cin >> C[i] >> S[i] >> F[i];
  }

  rep(i, N) {
    if (i == N - 1) {
      COUT(0);
      return 0;
    }
    ll time = S[i];
    time += C[i];
    rep2(j, i + 1, N - 1) {
      time = max(time, S[j]);
      if (time % F[j] != 0) {
        time += F[j] - time % F[j];
      }
      time += C[j];
    }
    COUT(time);
  }

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using    namespace std;
typedef  long double ld;
#define  int long long
typedef  pair<int,int> pii;
#define  RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  rep(i,n) for(i=0; i <n; i++)
#define  repv(i,k,n) for(int i=k; i<=n; i++)
#define  pb push_back
#define  mp make_pair
#define  F  first
#define  S  second
#define  sz(x)  (int)x.size()
#define  all(v) v.begin(),v.end()
#define  endl '\n'
#define  deb(x) c out<<#x<<" = "<<x<<endl
#define  gcd   __gcd
#define  inf   LLONG_MAX
#define  minf  LLONG_MIN 
#define  gi  greater<int> 
#define  gpi greater<pii>  
#define  sp(n) fixed<<setprecision(n)
const int mod = (int)(1e9+7);
int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
int pct(int x)
{   return __builtin_popcountll(x);}
int  lcm(int a,int b){return a*b/gcd(a,b);}
bool is_power_2(int n){ return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}
void db()
{   
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void timeit()
{  
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " <<sp(5)<< 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}
int     dx []    =  {-1 , 0 , 1 , 0 ,-1,-1, 1,  1};
int     dy []    =  { 0 , 1 , 0 ,-1 ,-1, 1, 1, -1};
char    dir[]    =  {'U','R','D','L'};
/* ---------------------- ar.cpp --------------------------------- */
const int maxn = 1e5+5;
void solve(int tc)
{
    //  cout<<"Case #"<<tc<<": ";
    int n,i,j,p,k,m,q,l,r;
    cin>>n;
    int dp[n][3];
    rep(i,n)
    {   
        int a,b,c;
        cin>>a>>b>>c;
        if(i)
        {
            dp[i][0] = max({a , a + dp[i-1][1] , a + dp[i-1][2]});
            dp[i][1] = max({b , b + dp[i-1][0] , b + dp[i-1][2]});
            dp[i][2] = max({c , c + dp[i-1][0] , c + dp[i-1][1]});
        }
        else
            dp[i][0] = a , dp[i][1] = b , dp[i][2] = c;
    }
    cout<<max({dp[n-1][0] , dp[n-1][1] , dp[n-1][2]});
}       
signed main()
{
    // ar.cpp
    RAGE;
 //   db();    
    int t=1;
    //cin>>t;
    for(int i=1; i<=t; i++)
    {
        solve(i);
    }
//    timeit();
    return 0;
}


Measured memory_bytes: 5944
#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned int ui;
using namespace std;
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll arr[4]={a*c,a*d,b*c,b*d};
    ll ans=*max_element(arr,arr+4);
    cout<<ans<<endl;
}


Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int a, b, c, cnt_7, cnt_5;

int main()
{
	cin >> a >> b >> c;
	if(a == 5) cnt_5 ++;
	if(a == 7) cnt_7 ++;
	if(b == 5) cnt_5 ++;
	if(b == 7) cnt_7 ++;
	if(c == 5) cnt_5 ++;
	if(c == 7) cnt_7 ++;

	if(cnt_7 == 1 && cnt_5 == 2){
		cout << "YES" << endl;
		return 0;
	} else {
		cout << "NO" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	char c;
	cin >> c;
	c++;
	cout << c << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>

using namespace std;
static const int MAX = 100;
static int changeCt = 0;

void selectionSort(int T[], int n) {
	for (int i = 0; i <= n - 1; i++) {
		int min = i;
		for (int j = i; j < n; j++) {
			if (T[min] > T[j]) {
				min = j;
			}
		}
		if(i != min) {
			swap(T[i], T[min]);
			changeCt++;
		}
	}
}


int main()
{
	int n;
	cin >> n;
	int A[MAX];
	std::string readbuff;
	cin.get();
	getline(cin, readbuff);
	stringstream ss(readbuff);
	string str;
	for (int i = 0; i < n; i++) {
		getline(ss, str, ' ');
		A[i] = stoi(str);
	}
	selectionSort(A, n);
	for (int ct = 0; ct < n - 1; ct++) cout << A[ct] << ' ';
	cout << A[n - 1] << endl;
	cout << changeCt << endl;

	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
    long long x,k,d;
    cin >> x >> k >> d;
    if(abs(x/d) > k){
        cout << abs(x)-k*d << endl;
    }else{
        int t = abs(x)/d;
        if((k-t)%2==0){
            cout << abs(x)-d*t << endl;
        }else{
            cout << d*(t+1) - abs(x) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


N = int(input())
c_raw = lmi()
ab = llmi(N - 1)

adj = collections.defaultdict(list)
for a, b in ab:
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)

total = N * (N + 1) // 2

visited = [False] * N

visited[0] = True
stacks = [[[0, 0]] for i in range(N)]
ans = [0] * N
curr = 1

# dfs = [0]
# while dfs:
#     node = dfs[-1]
#     prev, rem = stacks[c[node]][-1]
#     diff = curr - prev - rem
#     ans[c[node]] += (diff * (diff + 1)) // 2
#     stacks[c[node]][-1][1] += diff
#     if adj[node]:
#         next_node = adj[node].pop()
#         if not visited[next_node]:
#             visited[next_node] = True


color_stack = [[0, N] for _ in range(N)]
# color_groups = [[] for _ in range(N)]


class Tree:
    def __init__(self, i, _c):
        self.i = i
        self.color = _c
        self.child_count = 0
        self.children = []

    def set_child_count(self, parent=-1):
        for node_index in adj[self.i]:
            if node_index == parent:
                continue
            self.children.append(node_index)
            trees[node_index].set_child_count(self.i)
            self.child_count += trees[node_index].child_count + 1

    def dfs(self):
        color_stack[self.color][-1] -= self.child_count + 1
        for node_index in self.children:
            color_stack[self.color].append(trees[node_index].child_count + 1)
            trees[node_index].dfs()
            ans[self.color] -= get_path_count(color_stack[self.color].pop())
            # color_groups[self.color].append(color_stack[self.color].pop())


trees = [Tree(i, c - 1) for i, c in enumerate(c_raw)]


def get_path_count(x):
    return x + x * (x - 1) // 2


ans = [get_path_count(N)] * N
trees[0].set_child_count()
trees[0].dfs()

for color in range(N):
    # v = color_groups[color] + [color_stack[color][-1]]
    # print(N + N * (N - 1) // 2 - sum(map(lambda x: x + x * (x - 1) // 2, )))
    print(ans[color]-get_path_count(color_stack[color][-1]))


Measured memory_bytes: 518192
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int INF=2000000000;
  int i,j,k,n,m,c[20],x[20010],dp[20010][260];
  while(1){
  scanf("%d %d\n",&n,&m);
    if(n==0 && m==0){
      break;
    }
  for(i=0;i<m;i++){
    scanf("%d\n",&c[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d\n",&x[i]);
  }
  for(i=0;i<=n;i++){
    for(j=0;j<=255;j++){
      dp[i][j]=INF;
    }
  }
  dp[0][128]=0;
  for(i=0;i<n;i++){
    for(j=0;j<=255;j++){
      for(k=0;k<m;k++){
        int a;
        if(j+c[k]<0){
          a=0;
        }
        else if(j+c[k]>255){
          a=255;
        }
        else{
          a=j+c[k];
        }
        dp[i+1][a]=min(dp[i+1][a],dp[i][j]+(x[i]-a)*(x[i]-a));
      }
    }
  }
  int ans=2000000000;
  for(i=0;i<=255;i++){
    ans=min(ans,dp[n][i]);
  }
  printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 23556
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:50:51 2020
"""

import sys
#import numpy as np
import itertools

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

N,M,X = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(N)]

ans = 10 ** 9
for i in range(1,N+1):
    for C in itertools.combinations(ca,i):
#        print(C)
        tmp = 0
        m = [0 for _ in range(M)]
        for c in C:
            tmp += c[0]
            for i in range(M):
                m[i] += c[1+i]
        flg = True
        for mm in m:
            if mm < X:
                flg = False
        
        if flg:
            ans = min(ans,tmp)

if ans> 10**8:
    ans = -1
print(ans)




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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int main()
{
    ll K,T;
    cin >> K >> T;
    vector<ll> a(T);
    rep(i, T) cin >> a[i];

    sort(a.begin(), a.end());

    ll sum = accumulate(a.begin(), a.end(), 0LL);

    ll m = *(a.end() - 1);
    ll r = sum - m;
    ll ans = max(0LL, m - r - 1);

    cout << ans << endl;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t n,i,c=0;
  cin>>n;
  vector<int64_t> a(n+1),b(n);
  for(i=0;i<n+1;i++) cin>>a.at(i);
  for(i=0;i<n;i++){
    cin>>b.at(i);
    if(a.at(i)+a.at(i+1)<=b.at(i)){
      c+=a.at(i)+a.at(i+1);
      b.at(i)-=a.at(i)+a.at(i+1);
      a.at(i)=0;
      a.at(i+1)=0;
    }
    else if(a.at(i)<=b.at(i)){
      c+=b.at(i);
      b.at(i)-=a.at(i);
      a.at(i)=0;
      a.at(i+1)-=b.at(i);
      b.at(i)=0;
    }
    else if(b.at(i)<a.at(i)){
      c+=b.at(i);
      a.at(i)-=b.at(i);
      b.at(i)=0;
    }
  }
  cout<<c<<endl;
}

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

int main(){
    int X;
    cin >> X;
    int ans=0;
    ans+=X/500*1000;
    X=X%500;
    ans+=X/5*5;

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

Measured memory_bytes: 3680
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    long N, D;
    cin >> N >> D;
    long D2 = D * D;
    long X, Y;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> X >> Y;
        if (X * X + Y * Y <= D2){
            count++;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 3632