akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define alles(obj) obj.begin(), obj.end()
#define elif else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo std::cout <<
#define read std::cin >>
#define endl std::endl
#define fin << '\n'
#define bash push_back
#define makePair std::make_pair
#define _ << ' ' <<
// type-define
#define Stack std::stack
#define Queue std::queue
#define Set std::set
#define PQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
#define Greater std::greater
using String = std::string;
using llong = long long;
using boolean = bool;
using Pii = Pair<int, int>;
using Vi = Vector<int>;
using Vii = Vector<Pii>;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs ( llong n ) { return ( n < 0 ) ? -n : n; }
    boolean isMovable ( int x, int y, int w, int h ) { 
        return ( x >= 0 && y >= 0 && x < w && y < h ); }
}

#define int long long

namespace Rlyeh {

    int N, W;
    int w[110], v[110];
    int dp[110][100100];

    int dfs(int pos, int left) {
        if ( pos == N ) return 0;
        if ( ~dp[pos][left] ) return dp[pos][left];
        if ( left-w[pos] < 0 ) {
            return dp[pos][left] = dfs(pos+1, left);
        }
        else {
            return dp[pos][left] = std::max(dfs(pos+1, left),
                    dfs(pos+1, left-w[pos])+v[pos]);
        }
    }

    signed call_of_Cthulhu( signed datum ) {

        memset(dp, -1, sizeof(dp));
        read N >> W;
        for ( int i = 0; i < N; i++ ) {
            read w[i] >> v[i];
        }
        echo dfs(0, W) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 86272
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}
func main() {
	var a int
	var S string
	fmt.Scanf("%d\n%s\n", &a, &S)
	if a >= 3200 {
		fmt.Println(S)
	} else {
		fmt.Println("red")
	}
}


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

using namespace std;

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

const ll INF=1e9+7;
ll n,a[200001],ans,l,r,t;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n>>t;
	rep(i,n){
		cin>>a[i];
	}
	r=t-1;
	for(ll i=2;i<=n;i++){
//		cout<<l<<' '<<r;
		if(a[i]>r){
			ans+=r-l+1;
			l=a[i];
			r=a[i]+t-1;
		}
		else{
			r=a[i]+t-1;
		}
	}
//	cout<<l<<' '<<r;
	ans+=r-l+1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
#ABC47 B

w,h,n = map(int,input().split())

m = [[False]*w for _ in range(h)]

for _ in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        for i in range(h):
            for j in range(x):
                m[i][j] = True
    elif a == 2:
        for i in range(h):
            for j in range(x,w):
                m[i][j] = True
    elif a == 3:
        for i in range(y):
            for j in range(w):
                m[i][j] = True
    elif a == 4:
        for i in range(y,h):
            for j in range(w):
                m[i][j] = True
ans = 0
for i in range(h):
    for j in range(w):
        if m[i][j] == False:
            ans += 1
print(ans)


Measured memory_bytes: 41968
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n,k;
  cin >> n >> k;
  double ans = 0;
  for(ll i = 1; i <= n; i++){
    ll j = i;
    int cnt = 0;
    while(j<k){
      j *= 2; cnt += 1;
    }
    ans += 1.0/n/(1<<cnt);
  }
  printf("%.12f\n",ans);
  return 0;
}


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

using ll = long long;
const ll INF = 1e18;

const int MAXN = 5010;
int N;
ll A, B;
int P[MAXN];
ll dp[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> A >> B;
	for (int i = 1; i <= N; i++) {
		cin >> P[i];
	}
	P[0] = 0;
	P[N+1] = N+1;

	dp[0] = 0;
	for (int i = 1; i <= N+1; i++) {
		dp[i] = INF;
		int numBigger = 0;
		for (int j = i-1; j >= 0; j--) {
			if (P[j] < P[i]) {
				dp[i] = min(dp[i], dp[j] + numBigger * A + (i-j-1-numBigger) * B);
			} else {
				numBigger++;
			}
		}
	}
	cout << dp[N+1] << '\n';

	return 0;
}


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

using namespace std;

typedef long long ll;

struct segment_tree
{
    int n;
    vector<ll> st;

    segment_tree(int n) : n(n), st(4 * n) {}

    void update(int b, ll v)
    {
        update(1, 0, n, b, v);
    }

    ll query(int b)
    {
        return query(1, 0, n, 0, b);
    }

private:

        void update(int node, int b, int e, int bb, ll v)
        {
            if(b + 1 == e)
            {
                st[node] = max(st[node], v);
                return;
            }

            int m = (b + e) >> 1, l = node << 1, r = l | 1;

           
            if(bb < m) update(l, b, m, bb, v);
            else update(r, m, e, bb, v);

            st[node] = max(st[l], st[r]);
        }

        ll query(int node, int b, int e, int bb, int ee)
        {
            if(bb <= b && e <= ee)
                return st[node];

            int m = (b + e) >> 1, l = node << 1, r = l | 1;

            ll ans = -1;
            if(bb < m) ans = max(ans, query(l, b, m, bb, ee));
            if(m < ee) ans = max(ans, query(r, m, e, bb, ee));

            return ans;

        }
};

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

	int n;
	cin >> n;

	vector<ll> h(n), a(n), dp(n);

	for(ll &x : h)
		cin >> x;

	for(ll &x : a)
		cin >> x;

	segment_tree st(n + 1);

	dp[0] = a[0];
	st.update(0, 0);
	st.update(h[0], dp[0]);

	for(int i = 1; i < n; i++)
	{
		dp[i] = st.query(h[i]) + a[i];

		st.update(h[i], dp[i]);
	}

	cout << *max_element(dp.begin(), dp.end()) << endl;

	return 0;
}

Measured memory_bytes: 11264
a, b, k = map(int, input().split())

num_limit = b-a+1
if num_limit <= k*2:
    ans_list = [i for i in range(a, b+1, 1)]
else:
    ans_list = []
    for j in range(k):
        low = a+j
        high = b-j
        ans_list.append(low)
        ans_list.append(high)
    ans_list.sort()

for l in ans_list:
    print(l)

Measured memory_bytes: 8956
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define M 10000
#define E 500000
   
typedef struct edge {
    int from, to, cost;
} Ed;
Ed e[E];
int d[M];  
void sp(int,int);
int main(int argc,char* argv[])
{
    int vn, en, an;
    int i, j, vi;
    scanf("%d", &vn);
    en=0;
    for(i=0; i<vn; i++) {
        scanf("%d", &vi);
        scanf("%d", &an);
        for(j=1; j<=an; j++) {
            e[en].from=vi;
            scanf("%d %d", &e[en].to, &e[en].cost);
            en++;
        }
    }      
    sp(vn, en);
    for(i=0; i<vn; i++) {
        printf("%d %d\n", i, d[i]);
    }
    return 0;
}
void sp(int vn, int en)
{
    int i, new=1;
    for(i=1; i<vn; i++) d[i]=INT_MAX;
       
    while(new) {
        new=0;
        for(i=0; i<en; i++) {
            if(d[e[i].from] !=INT_MAX && d[e[i].from]+e[i].cost < d[e[i].to]) {
                d[e[i].to] = d[e[i].from]+e[i].cost;
                new++;
            }
        }
    }
}

Measured memory_bytes: 6456
package main

import "fmt"

func main() {
	var (
		a, b, c, x, result int
	)

	fmt.Scan(&a, &b, &c, &x)

	for i := 0; i < a+1; i++ {
		for j := 0; j < b+1; j++ {
			for k := 0; k < c+1; k++ {
				if 500*i+100*j+50*k == x {
					result++
				}
			}
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",if (a-b).abs()>(a-c).abs(){"B"}else{"A"})
}

Measured memory_bytes: 4352
M=2**64-1
eval"N,*A="+`dd`.split*?,
C=[0,N].map{|z|y,*a=A[z,N]*3;a.map{y^y=_1}}
e,f=C.map{|z|z[b=0,N].map{b=b*9+_1&M};b}
q=1-9**N&M
N.times{|i|e==f&&p(i,A[i]^A[N])
e=e*9+C[0][i]*q&M}

Measured memory_bytes: 92708
a, b, k = map(int, input().split())
result = []
if a > b:
    for i in range(1, b+1):
        if a % i == 0 and b % i == 0:
            result.append(i)
else:
    for i in range(1, a+1):
        if a % i == 0 and b % i == 0:
            result.append(i)
print(result[len(result) - k])


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

bool travel(int cx, int cy, int ct, int x, int y, int t)
{
    ct += abs(x - cx) + abs(y - cy);
    if (ct > t) {
        return false;
    }
    if ((t - ct) % 2 == 0) {
        return true;
    } else {
        return false;
    }
}

int main()
{
    int n;
    int t, x, y;
    cin >> n;
    int cx, cy, ct;
    cx = cy = ct = 0;
    bool yes = true;
    for (int i = 0; i < n; i++) {
        cin >> t >> x >> y;
        if (!travel(cx, cy, ct, x, y, t)) {
            yes = false;
            break;
        }
        cx = x;
        cy = y;
        ct = t;
    }
    if (!yes) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

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

#define ll long long
#define ok puts("ok");

using namespace std;

const int N = (int)47;
const int mod = (int)1e9 + 7;

int add(int a, int b) {
	return (a + b) % mod;
}

int mul(int a, int b) {
	return (a * 1LL * b) % mod;
}

int n, x[4];
int dp[N][1 << 17];

main() {
	scanf("%d %d %d %d", &n, &x[1], &x[2], &x[3]);
	dp[0][0] = 1;
	int tot = x[1] + x[2] + x[3];
	int msk = (1 << (x[1] - 1)) | (1 << (x[1] + x[2] - 1)) | (1 << (x[1] + x[2] + x[3] - 1));
	for (int i = 0; i < n; i++) {
		for (int curmask = 0; curmask < (1 << tot); curmask++) {
			for (int k = 1; k <= 10; k++) {
				int nxt = ((curmask << k) | (1 << (k - 1))) & ((1 << tot) - 1);
				if ((msk & nxt) == msk) continue;
				dp[i + 1][nxt] = add(dp[i + 1][nxt], dp[i][curmask]);
			}
		}
	}
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		ans = mul(ans, 10);
	}
	for (int i = 0; i < (1 << tot); i++) {
		ans = add(ans, mod - dp[n][i]);
	}
	printf("%d", ans);
}


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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

ll X0(int N, vector<ll> A)
{
    ll ans = 0;
    for(int i=0;i<N;i++)
    {
        if(i%2==0)
        {
            ans += A[i];
        }
        else
        {
            ans -= A[i];
        }
    }
    return ans;
}

vector<ll> Xs(ll X0, int N, vector<ll> A)
{
    X0 /= 2;
    vector<ll> ans(N,0);
    ans[0] = X0;
    for(int i=1;i<N;i++)
    {
        ans[i] = A[i-1] - ans[i-1];
    }
    for(auto& x : ans)
    {
        x *= 2;
    }
    return ans;
}

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

    vector<ll> A(N);
    for(auto& x : A)
    {
        cin >> x;
    }

    vector<ll> ans = Xs(X0(N,A),N,A);

    for(int i=0;i<N;i++)
    {
        cout << ans[i];
        if(i!=N-1)
        {
            cout << ' ';
        }
    }
    cout << endl;

    return 0;
}

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

using namespace std;

int n, m;
int p;
int ac, wa;
int status[100005];
int wrong[100005];
string verdict;

int main() {
    cin >> n >> m;
    while (m--) {
        cin >> p >> verdict;
        if (verdict == "WA" && status[p] == 0) {
                ++wrong[p];
        }
        if (verdict == "AC" && status[p] == 0) {
            ++ac;
            status[p] = 1;
            wa += wrong[p];
        }
    }
    cout << ac << ' ' << wa << '\n';
    return 0;
}

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

using namespace std;



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

  //
  vector<int> C(N, 0);
  C[1] = abs(H[0] - H[1]);
  for (int i = 2; i < N; ++i) {
    int c1 = abs(H[i]-H[i-1]) + C[i-1];
    int c2 = abs(H[i]-H[i-2]) + C[i-2];
    C[i] = min(c1, c2);
  }

  cout << C[N-1] << endl;


  return 0;
}




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

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    input! (
        n: usize,
        m: usize,
        s: [[usize1]; m],
        p: [usize; m]
    );
    let mut count = 0;
    let mut x = vec![0; n];
    'out: for k in 0..1 << n {
        let mut k = k;
        for i in 0..n {
            x[i] = k % 2;
            k /= 2;
        }
        for i in 0..m {
            if s[i].iter().map(|&j| x[j]).sum::<usize>() % 2 != p[i] {
                continue 'out;
            }
        }
        count += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
	
	static List<Integer> U=new ArrayList<>(); 
	static int m;
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		int n=in.nextInt();
		for(int i=0;i<n;i++)U.add(Integer.parseInt(in.next()));
		
		int q=in.nextInt();
		for(int i=0;i<q;i++){
			m=in.nextInt();
			System.out.println((solve(0,0))? "yes":"no");
		}
	}
	
	static boolean solve(int sum,int i){
		//System.out.println(sum);
		if(sum==m)return true;
		else if(sum>m)return false;
		
		for(int j=i;j<U.size();j++){
			if(solve(sum+U.get(j),j+1))return true;
		}
		return false;
	}


}


Measured memory_bytes: 27252
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
  LL N;
  cin >> N;
  vector<LL> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;  
    }
  }

  LL m = pow(10, 18);
  LL res = 1;
  for (int i = 0; i < N; i++) {
    if (A[i] <= m / res) {
      res *= A[i];
    }
    else {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 4064
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define ll long long
#define mset(s, _) memset(s, _, sizeof s)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main(void) {
  int L;
  cin >> L;

  double x = L / 3.0;
  double y = L / 3.0;
  double z = L / 3.0;

  printf("%.10lf", x * y * z);
  return 0;
}


Measured memory_bytes: 3692
#include <stdio.h>

int main()
{

    long s;
    scanf("%ld", &s);

    long z = 100;

    int i;
    for (i = 1; z < s; i++)
    {
        z = z * 1.01;
        if(z>=s)
            break;
    }

        printf("%d",i);
    

    printf("\n");
}


Measured memory_bytes: 2152
#include<iostream>
using namespace std; 
int main () 
{
int a,b,c; 
cin>>a>>b>>c; 

if(a==b&&b!=c||a!=b&&b==c||a!=b&&b!=c&&a==c)
{
	cout<<"Yes"<<endl;
}
else
{
    cout<<"No";
}

return 0;
}

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

int main(){
  long long int n;
  cin >> n;
  vector<int> a(n+1), b(n);
  rep(i,n+1,0) cin >> a[i];
  rep(i,n,0) cin >> b[i];
  long long int ans = 0;
  rep(i,n,0){
    long long int p, q;
    p = min(a[i],b[i]);
    ans += p;
    b[i] -= p;
    q = min(a[i+1], b[i]);
    ans += q;
    a[i+1] -= q;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int H = sc.nextInt();
        int A = sc.nextInt();
        int ans = 0;
        ans = H / A;
        if(H % A != 0){
            ans++;
        }

        System.out.println(ans);
    }

}






Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdint>

using namespace std;

struct Card {
	char suit;
	int value;
	Card() : suit(), value() { }
  bool operator==(const Card& rhs) const {
    return this->suit == rhs.suit && this->value == rhs.value;
  }
  bool operator!=(const Card& rhs) const {
    return !(this->operator==(rhs));
  }
};

static bool isStable(Card in[], Card out[], int num) {
  for (int i = 0; i < num; i++) {
    if (in[i] != out[i]) {
      return false;
    }
  }
  return true;
}

static void inputArray(Card A[], int num) {
  for (int i = 0; i < num; i++) {
    cin >> A[i].suit >> A[i].value;
   }
}

static void printArray(Card A[], int num) {
  for (int i = 0; i < num; i++) {
    cout << A[i].suit << ' ' << A[i].value << endl;
  }
}

static vector<Card> L(50000 + 1);
static vector<Card> R(50000 + 1);

static inline void merge(Card A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;

  L.assign(&A[left], &A[left + n1]);
  R.assign(&A[mid], &A[mid + n2]);
  L[n1].value = R[n2].value = INT32_MAX;

  for (int i = 0, j = 0, k = left; k < right; k++) {
    if (L[i].value <= R[j].value) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  } 
}

static inline void mergeSort(Card A[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  } 
}

static int partition(Card A[], int p, int r) {
  int x = A[r].value;
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j].value <= x) {
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i + 1], A[r]);
  return i + 1; 
}

static inline void quickSort(Card A[], int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

static vector<Card> A(100000);
static vector<Card> B(100000);

int main() {
  int n;
  cin >> n;

  inputArray(&A[0], n);
  B = A;

  quickSort(&A[0], 0, n - 1);
  mergeSort(&B[0], 0, n);
  
  bool stable = isStable(&A[0], &B[0], n);
  cout << (stable ? "Stable" : "Not stable") << endl;
  
  printArray(&A[0], n);
    
  return 0;
}



Measured memory_bytes: 5024
n = int(input())
a = list(map(int, input().split(' ')))
 
def merge_sort(arr):
    if len(arr) <= 1:
        return arr
 
    mid = len(arr) // 2
    # ここで分割を行う
    left = arr[:mid]
    right = arr[mid:]
 
    # 再帰的に分割を行う
    left = merge_sort(left)
    right = merge_sort(right)
 
    # returnが返ってきたら、結合を行い、結合したものを次に渡す
    return merge(left, right)
 
 
def merge(left, right):
    merged = []
    l_i, r_i = 0, 0
 
    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i] >= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1
 
    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged
 
s = merge_sort(a)
ans=s[0]
for i in range(1,n//2):
    ans += s[i]*2
if n%2 == 1:
    ans += s[n//2]
 
print(ans)

Measured memory_bytes: 31624
#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20];
void mypr(int n)
{
	int w;
	if (!n) { pc('0'); return; }
	w = 0; while (n) buf[w++] = n%10 + '0', n/=10;
	while (w--) pc(buf[w]);
}

#define MAX_N 500002
#define INF   0x7f7f7f7f

int a[MAX_N];
int w[MAX_N/2+2];
int cnt;

void merge_sort(int low, int high) 
{ 
	int i, j, k, p, mid; 

	if (low < high) {
		mid = (low + high) >> 1;
		merge_sort(low,   mid);
		merge_sort(mid+1, high);

cnt += high-low+1;

		p = mid-low+1;
		memcpy(w, a+low, p << 2);
		i = mid+1, j = 0; k = low;

		w[p] = INF;
		while (i <= high) {
			if (w[j] <= a[i]) a[k++] = w[j++];
			else              a[k++] = a[i++];
		}
		memcpy(a+k, w+j, (p-j) << 2);
	}
}

int main()
{
	int n, i;
	
	n = in(); for (i = 0; i < n; i++) a[i] = in();

	cnt = 0;
	merge_sort(0, n-1);

	mypr(a[0]); for (i = 1; i < n; i++) pc(' '), mypr(a[i]); pc('\n');
	mypr(cnt); pc('\n');
	return 0;
}



Measured memory_bytes: 4548
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  rep(i, N){
    cin >> S.at(i);
  }
  sort(all(S));
  string ans = "";
  rep(i, N){
    ans += S.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  long N,count=0,X,Y;
  double D;
  cin>>N>>D;
  for(long i=1;i<=N;i++){
    cin>>X>>Y;
    if(sqrt((X*X)+(Y*Y))<=D)
      count++;
  }
  cout<<count;
  return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

long long modinv(long long a) {
    long long b = MOD, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD; 
    if (u < 0) u += MOD;
    return u;
}

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

const int MAX_A = 1000000;
bool isprime[MAX_A + 5];
vector<int> prime;

void prime_init(){
    fill(isprime, isprime + MAX_A, true);
    for(int k = 2; k <= MAX_A; k++){
        if(!isprime[k]) continue;
        prime.push_back(k);
        for(int l = k * 2; l <= MAX_A; l += k){
            isprime[l] = false;
        }
    }
}

map<int, int> fac;
void factorize(int x, int i){
    map<int, int> m;
    for(int& k : prime){
        if(k*k > x) break;
        while(x % k == 0){
            m[k]++;
            x /= k;
        }
    }
    if(x != 1) m[x]++;

    for(auto& p : m){
        fac[p.fi] = max(fac[p.fi], p.se);
    }
}

int main(){
    prime_init();
    int n; cin >> n;
    vector<lint> a;
    rep(i, n){
        lint x; cin >> x; a.push_back(x);
        factorize(x, i);
    }

    lint lcm = 1;
    for(auto & p : fac){
        lcm *= modpow(p.fi, p.se);
        lcm %= MOD;
    }

    lint ans = 0;
    rep(i, n){
        lint b = (lcm * modinv(a[i])) % MOD;
        ans += b;
        ans %= MOD;
    }
    cout << ans << endl;
}


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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 100000;
int n,h;
vector<int> bs;

int ceil_div(int a, int b)
{
  return a / b + (a % b != 0 ? 1 : 0);
}

int main()
{
  int a,b;
  cin >> n >> h;
  int max_a = -1;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a > max_a) max_a = a;
    bs.push_back(b);
  }

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

  int res = 0;
  int i = bs.size()-1;
  while (h > 0 && i >= 0 && bs[i] >= max_a) {
    h -= bs[i--];
    res++;
  }

  if (h > 0) res += ceil_div(h,max_a);

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[205];
    cin>>s;
    for(int i=strlen(s)-3;i>=0;i-=2)
    {
        int x=(i+1)/2;
        bool flag=true;
        for(int j=0;j<x;j++)
        {
            if(s[j]!=s[j+x])
            {
                flag=false;
                break;
            }
        }
        if(flag)
        {
            cout<<i+1<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	static ArrayList<Edge>[] tree;
	static int[] color;
	static int max;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		tree = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			tree[i] = new ArrayList<Edge>();
		}
		for (int i = 0; i < n - 1; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			tree[a].add(new Edge(i, b));
			tree[b].add(new Edge(i, a));
		}
		color = new int[n - 1];
		dfs(0, 0);
		System.out.println(max);
		for (int i = 0; i < n - 1; i++) {
			System.out.println(color[i]);
		}
	}
	static void dfs(int n, int par) {
		int col = 1;
		for (Edge edge:
			 tree[n]) {
			if (color[edge.n] == 0) {
				if (col == par) {
					col++;
				}
				color[edge.n] = col;
				dfs(edge.to, col);
				max = Math.max(col, max);
				col++;
			}
		}
	}
}

class Edge {
	int n;
	int to;
	Edge(int n, int to) {
		this.n = n;
		this.to = to;
	}
}



class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 59460
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long a, b, c, ra, rb, rc, g;
    cin >> a >> b >> c;
    if (c - a - b < 0) {
        no();
        return 0;
    }
    if (long(4 * a * b < (c - a - b) * (c - a - b))) {
        yes();
    } else {
        no();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>
#include <bitset>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    constexpr uint num_timezone{10};
    uint N;
    cin >> N;
    vector<bitset<num_timezone>> fs{};
    for (auto &&i: irange(0U, N)){
        string s{};
        for (auto &&j: irange(0U, num_timezone)){
            char c;
            cin >> c;
            s.push_back(c);
        }
        fs.emplace_back(bitset<num_timezone>(s));
    }

    vector<vector<int>> ps(N, vector<int>(num_timezone+1, 0));
    for (auto &&i: irange(0U, N)){
        for (auto &&j: irange(0U, num_timezone+1)){
            cin >> ps.at(i).at(j);
        }
    }
    uint two_mul_10{1};

    for (auto &&i: irange(0U, num_timezone)){
        two_mul_10 *= 2;
    }

    int profit_max{numeric_limits<int>::min()};
    for (auto &&i: irange(1U, two_mul_10)){
        bitset<num_timezone> b(i);
        int profit{0};
        for (auto &&j: irange(0U, N)){
            bitset<num_timezone> s = b & fs.at(j);
//            if (b == 1){
//                cout << "j: " << j << " s: " << s << " ps.at(j).at(s.count()): " <<  ps.at(j).at(s.count()) << endl;
//            }
            profit+=ps.at(j).at(s.count());
        }
        profit_max = max(profit_max, profit);
    }
    cout << profit_max;
    return 0;
}

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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void solve(){
    uint32_t N, K;
    cin >> N >> K;
    std::vector<uint32_t> A;
    A.reserve(N);
    for(int i = 0 ; i < N ; i++){
        uint32_t a;
        cin >> a;
        A.push_back(a);
    }
    std::sort(A.begin(), A.end());
    uint32_t sum = 0;
    for(int i = 0 ; i < K; i++){
        sum += A[i];
    }
    cout << sum << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, i, j, k, d[3], ans=0; string S; cin >> N >> S;
for(i=0; i<1000; i++){
d[2]=i%10; d[0]=i/100; d[1]=(i-100*d[0]-d[2])/10;
for(j=k=0; j<N; j++){ if('0'+d[k]==S[j]){k++; if(k==3){ans++;break;} } }
}
cout << ans << "\n";
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main() {
	long long x;
	cin >> x;

	long long money = 100;
	if (x <= money) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = 1;i <= 3760;i++) {
		money = money + money / 100;
		if (x <= money) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3636
// abc138_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<pair<int, int>> P(N);
    REP(i, N) {
        cin >> P[i].first;
        P[i].second = i;
    }
    sort(ALL(P), greater<pair<int, int>>());

    multiset<int> st{-1, -1, N, N};

    ll ans = 0;
    REP(i, N){

        ll v = P[i].first;
        ll idx = P[i].second;
        auto it = st.lower_bound(idx);

        ll l2, l1, r2, r1;

        r1 = *it;
        it++;
        r2 = *it;
        it--;
        it--;
        l1 = *it;
        it--;
        l2 = *it;

        ans += v * ((l1 - l2) * (r1 - idx) + (r2 - r1) * (idx - l1));

        st.insert(idx);
    }

    print(ans);

//    N = 5;
//    P = {5, 2, 1, 4, 3};
//    print(P);
//    int ans = 0;
//    REP(i, N-1) REPN(j, i+1, N){
//        auto x = P;
//        sort(x.begin() + i, x.begin() + j+1);
//        print(i, j, x, x[j-1]);
//        ans += x[j-1];
//    }
//    print(ans);


    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>
int search(int key,int S[],int n)
{
	int low=0,high=n,mid;
	while(low<=high)
	{
		mid=(low+high)/2;
		if(S[mid]==key)	
		return 1;
		else if(S[mid]<key)
		low=mid+1;
		else
		high=mid-1;
	}
	return 0;
}
int main(int argc, char *argv[])
{
	int S[100000],n,k,q,i,count=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&S[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&k);
		if(search(k,S,n))
		count++; 
	}
	printf("%d\n",count);
	return 0;
}




Measured memory_bytes: 2108
d,g = map(int,input().split())
p = []
c = []
for i in range(d):
    x,y = map(int,input().split())
    p.append(x)
    c.append(y)

ans = 10**3+1
for i in range(2**d):
    tmp = 0
    tmp_ans = 0
    t = [0]*d
    for j in range(d):
        if (i>>j)&1:
            tmp += 100*(j+1)*p[j] + c[j]
            tmp_ans += p[j]
            t[j] = 1
    if tmp < g:
        for k in range(d-1,-1,-1):
            if t[k] == 0:
                if tmp+100*(k+1)*(p[k]-1) < g:
                    tmp_ans += 10**3+1
                else:
                    if (g-tmp)%(100*(k+1)) == 0:
                        tmp_ans += (g-tmp)//(100*(k+1))
                    else:
                        tmp_ans += (g-tmp)//(100*(k+1))+1
                break
    ans = min(tmp_ans,ans)

print(ans)


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

def kaijou(x):
    result = 1
    for i in range(1, x+1):
        result *= i
    return result

def nokori(X, y):

    X = sorted(X)
    idx = 0
    for i in X:
        if i == y:
            return idx
        idx += 1
a = 1
tmp_P = P.copy()
for idx, i in enumerate(P):
    if idx < len(P):
        a = a + (nokori(tmp_P,i))*kaijou(N-idx-1)
        tmp_P.remove(i)
b = 1
tmp_Q = Q.copy()
for idx, i in enumerate(Q):
    if idx < len(Q):
        b += (nokori(tmp_Q,i))*kaijou(N-idx-1)
        tmp_Q.remove(i)
if a > b:
    print(a-b)
else:
    print(b-a)

Measured memory_bytes: 3064
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    constexpr int64_t div = 1000000007LL;
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    for (size_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    std::sort(std::begin(A), std::end(A));

    size_t pairNum = 0;
    if (A.size() % 2 == 1 && A[0] == 0) {
        // 全体奇数の場合 0, 2,2  4,4 ...       N-1,N-1
        //            i: 0  1 2  3 4           N-2,N-1
        pairNum = (N-1)/2;
        for (int64_t i = 2; i < N; i += 2) {
            if (A[i-1] != A[i] || A[i] != i)  {
                std::cout << 0 << std::endl;
                return 0;
            }
        }
    }
    else if (A.size() % 2 == 0 && A[0] == 1) {
        // 全体偶数の場合 1,1, 3,3, 5,5, ..., N-1,N-1
        //            i: 0 1  2 3  4 5       N-2 N-1
        pairNum = N/2;
        for (int64_t i = 1; i < N; i += 2) {
            if (A[i-1] != A[i] || A[i] != i)  {
                std::cout << 0 << std::endl;
                return 0;
            }
        }
    }
    else {
        std::cout << 0 << std::endl;
        return 0;
    }

    int64_t ret = 1;
    for (size_t i = 0; i < pairNum; ++i) {
        ret *= 2;
        ret %= div;
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

ll power(ll a,ll b,ll mod)
{
    return b?power(a*a%mod,b/2,mod)*(b%2?a:1)%mod:1;
}

ll cal(ll n)
{
    ll cnt=1;
    while(n)
	{
        n=n%__builtin_popcount(n);
        cnt++;
    }
    return cnt;
}

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
    int n;
	cin>>n;
	
    string x;
	cin>>x;
	
    ll ans1=0,ans2=0,cnt=0,ans;
    
    for(int i=0;i<n;i++)
	{
        if(x[i]=='1')
            cnt++;
    }
    
    if(cnt>1)
	{
        for(int i=0;i<n;i++)
        {
            if(x[i]=='1')
			{
            	ans1=(ans1+power(2,n-i-1,cnt+1))%(cnt+1),ans2=(ans2+power(2,n-i-1,cnt-1))%(cnt-1);
        	}
        }
        
        for(int i=0;i<n;i++)
		{
            if(x[i]=='1')
			{
                ans=(ans2+((cnt-1)-power(2,n-i-1,cnt-1)%(cnt-1))%(cnt-1))%(cnt-1);

                cout<<cal(ans)<<endl;
            }
            else
			{
                ans=(ans1+power(2,n-i-1,cnt+1)%(cnt+1))%(cnt+1);
                cout<<cal(ans)<<endl;
            }
        }
    }
    else if(cnt)
	{
        for(int i=0;i<n;i++)
        {
            if(x[i]=='1')
            {
                ans1=power(2,n-i-1,cnt+1)%(cnt+1);
            }
        }
        
        for(int i=0;i<n;i++)
		{
            if(x[i]=='0')
			{
            	ans=(ans1+power(2,n-i-1,cnt+1)%(cnt+1))%(cnt+1);
            	cout<<cal(ans)<<endl;
            }
            else
			{
                cout<<'0'<<endl;
            }
        }
    }
    else
	{
        for(int i=0;i<n;i++)
            cout<<'1'<<endl;
    }
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
int main(){
  long h, n;
  cin >> h >> n;

  vector<int> a;
  for(int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  long sum = accumulate(a.begin(), a.end(), 0);
  if(h <= sum){
    cout << "Yes" << endl;
  } else{
    cout << "No" <<endl;
  }
  return 0;
}



Measured memory_bytes: 3908
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    int n; cin>>n;
    string s1,s2; cin>>s1>>s2;
    
    REP(i,s1.size()){
        for(int j=i;j<s1.size();j++){
            if(s1[j]!=s2[j-i])goto nextf;
        }
        cout<<n+i<<endl;
        return 0;
    nextf:;
    }
    
    cout<<2*n<<endl;
    
    return 0;
}



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

using namespace std;

int main() {

	int a, b, c;
	int ans = 0;

	cin >> a >> b >> c;

	for (int i = 0; i < 10000; i++) {
		ans += a;
		if (ans % b == c) {
			cout << "YES" << endl; 
			return 0;
		}
	}

	cout << "NO" << endl;
	return 0;

}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;




//ここから編集する



int main() {
    int K,T;
    cin >> K >> T;
    vector<int> v(T+1,0);
    REP(i,1,T+1){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());

    cout << max(0,v[0]-1-(K - v[0])) << endl;
//    cout << v[0]-1-(K - v[0]) << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 27 20:59:13 2019

@author: yuta
"""

ABT = list(map(int,input().split()))

def main(abt):
    a = abt[0]
    b = abt[1]
    t = abt[2]
    count = int(t/a)*b
    print(count)
main(ABT)

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

int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b||b==c||a==c){
        if(a==b&&b==c) puts("No");
        else puts("Yes");
    }else{
        puts("No");
    }
}


Measured memory_bytes: 256