akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: chars
    }

    let cp = compress(&n);
    println!("{}", if cp.into_iter().fold(0, |acc,(c,_)| std::cmp::max(acc,c)) >= 3 {"Yes"} else {"No"});
}

#[doc = " aaabbccccaa = (3,a),(2,b),(4,c),(2,a)"]
#[allow(dead_code)]
fn compress<T: Clone + PartialEq>(slice: &[T]) -> Vec<(u64, T)> {
    if slice.len() == 0 {
        return vec![];
    }
    let mut acc = vec![];
    let mut current = slice[0].clone();
    let mut cnt = 1u64;
    for i in 1..slice.len() {
        if current != slice[i] {
            acc.push((cnt, current));
            cnt = 0;
        }
        current = slice[i].clone();
        cnt += 1;
    }
    acc.push((cnt, current));
    acc
}

Measured memory_bytes: 4352
#undef NDEBUG
#include <bits/stdc++.h>

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;
using ld = long double;

void solve(bool);

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cout << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}


const int maxn = (int)4e5 + 55;

int n, m, sz;
int sx, sy;
string s, t, st;
int u[maxn], d[maxn], l[maxn], r[maxn];

void solve(bool __attribute__((unused)) read) {
    cin >> n >> m >> sz;
    cin >> sx >> sy;
    --sx; --sy;
    cin >> s >> t;
    st = "";
    for (int i = sz - 1; i >= 0; --i) {
        st += t[i];
        st += s[i];
    }
    u[0] = 0;
    d[0] = n - 1;
    l[0] = 0;
    r[0] = m - 1;
    for (int i = 0; i < (int)st.size(); ++i) {
        u[i + 1] = u[i];
        d[i + 1] = d[i];
        l[i + 1] = l[i];
        r[i + 1] = r[i];

        int u1, d1, l1, r1;

        u1 = u[i] + (st[i] == 'U') - (st[i] == 'D');
        d1 = d[i] + (st[i] == 'U') - (st[i] == 'D');
        l1 = l[i] + (st[i] == 'L') - (st[i] == 'R');
        r1 = r[i] + (st[i] == 'L') - (st[i] == 'R');

        if (i % 2 == 0) {
            u[i + 1] = min(u1, u[i + 1]);
            d[i + 1] = max(d1, d[i + 1]);
            l[i + 1] = min(l1, l[i + 1]);
            r[i + 1] = max(r1, r[i + 1]);
        } else {
            u[i + 1] = max(u1, u[i + 1]);
            d[i + 1] = min(d1, d[i + 1]);
            l[i + 1] = max(l1, l[i + 1]);
            r[i + 1] = min(r1, r[i + 1]);
        }

        u[i + 1] = max(u[i + 1], 0);
        l[i + 1] = max(l[i + 1], 0);

        d[i + 1] = min(d[i + 1], n - 1);
        r[i + 1] = min(r[i + 1], m - 1);

        if (u[i + 1] > d[i + 1] || l[i + 1] > r[i + 1]) {
            cout << "NO\n";
            return;
        }
    }

    if (u[st.size()] <= sx && sx <= d[st.size()] && l[st.size()] <= sy && sy <= r[st.size()])
        cout << "YES\n";
    else
        cout << "NO\n";
}

Measured memory_bytes: 7576
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem A

if __name__ == '__main__':
    card_orders = [number for number in range(2, 13 + 1)] + [1]
    a, b = list(map(int, input().split()))

    if card_orders.index(a) > card_orders.index(b):
        print('Alice')
    elif card_orders.index(a) < card_orders.index(b):
        print('Bob')
    else:
        print('Draw')


Measured memory_bytes: 3060
#include <stdio.h>
int main ()
{
	long int zday, qday, qmoney, hmoney;
	scanf("%ld%ld%ld%ld", &zday, &qday, &qmoney, &hmoney);
	if (zday>=qday)
		printf("%ld", qday*qmoney+(zday-qday)*hmoney); 
	else
		printf("%ld", zday*qmoney);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int a,sum[2]={0};
	for(int i=0;i<4;i++){
		cin>>a;
		sum[0]+=a;
	}
	for(int i=0;i<4;i++){
		cin>>a;
		sum[1]+=a;
	}
	cout<<(sum[0]<sum[1]?sum[1]:sum[0])<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    string s,t;cin>>s>>t;
    cout<<t<<s;
    return 0;  
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
 
int main() {
 string s,t;
  cin>>s>>t;
  int count=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      count++;
    }
  }
  cout<<count<<endl;
}
    

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  long double A,B;
  cin >> A >> B;
  HpOut((A*B));
}

Measured memory_bytes: 3848
#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>

#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



#include <array>
#include <iterator>



using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl;
typedef pair < int, int> P;


int N;
int main() {
	cin >> N;
	ll ans = 0;
	rep (i, N) {
		ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
using namespace std;
struct point{
  double x,y;
    };
int main(){
  point p[4];
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> p[0].x >> p[0].y>>p[1].x>>p[1].y>>p[2].x>>p[2].y>>p[3].x>>p[3].y;
    if(fabs((p[1].y -p[0].y)*(p[3].x -p[2].x)- (p[3].y-p[2].y)*(p[1].x-p[0].x)) <1.0e-15){
	cout << "YES" << endl;
      } else {cout << "NO" << endl;}
      
  }
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

    static int N;
    static int K;

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

        N = scanner.nextInt();
        K = scanner.nextInt();

        double acc = 0;

        double baseProb = (double) 1 / N;

        for(int i=1; i<=N; i++){
            if(i >= K){
                acc += baseProb;
            }else{
                acc += baseProb * powerProb(i);
            }
        }

        System.out.println(acc);
    }

    private static double powerProb(int target) {
        double ret = 1;

        while(target <= K-1){
            target *= 2;
            ret *= 0.5;
        }

        return ret;
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;

long long N, X[1009], Y[1009], H[1009]; 
vector<tuple<long long, long long, long long>>vec;

int main() {
	cin >> N; 
	tuple<long long, long long, long long>G = make_tuple(-1, -1, -1);
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i] >> H[i];
		if (H[i] >= 1) G = make_tuple(X[i], Y[i], H[i]);
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			long long V = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j); 
			V = max(V, 0LL); 
			bool flag = true;
			for (int k = 1; k <= N; k++) {
				long long VV = V - abs(X[k] - i) - abs(Y[k] - j); 
				VV = max(VV, 0LL);
				if (H[k] != VV) flag = false;
			}
			if (flag == true) vec.push_back(make_tuple(i, j, V));
		}
	}
	if (vec.size() == 1) {
		cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl;
	}
	return 0;
}

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

int main() {
	long long int n,k,t,ans;
	cin >> n >> k;
    ans = n % k;
    t = max(ans,k) - min(ans,k);
  while(t < ans){
    ans = t;
    t = max(ans,k) - min(ans,k);
  }  
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    int n, m; cin >> n >> m;
    vector<vector<int>> G(n);
    rep(i, m){
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    //bfs
    queue<int> que; que.push(0);
    vector<int> sirube(n, -1);//-1:未訪問
    sirube[0] = 0;
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(int e: G[v]){
            if(sirube[e] != -1) continue;
            sirube[e] = v;
            que.push(e);
        }
    }
    cout << "Yes" << ln;
    rept(i, 1, n) cout << sirube[i] + 1 << ln;
}

Measured memory_bytes: 10088
#include <stdio.h>

int min(int a,int b){
	if(a<b){return a;}
	else{return b;}
}

int max(int a,int b){
	if(a>b){return a;}
	else{return b;}
}

int main(){

	int A1,A2,A3;

	scanf("%d %d %d",&A1,&A2,&A3);

	int sum[6];

	sum[0]=max(A2-A1,A1-A2)+max(A3-A2,A2-A3);
	sum[1]=max(A3-A1,A1-A3)+max(A3-A2,A2-A3);
	sum[2]=max(A2-A3,A3-A2)+max(A3-A1,A1-A3);
	sum[3]=max(A2-A1,A1-A2)+max(A3-A1,A1-A3);
	sum[4]=max(A3-A1,A1-A3)+max(A1-A2,A2-A1);
	sum[5]=max(A3-A2,A2-A3)+max(A1-A2,A2-A1);

	int i;

	int ans=114514;

	for(i=0;i<6;i++){
	ans=min(ans,sum[i]);
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int R,B,G,N;
int cnt;
int main(){
    cin>>R>>B>>G>>N;
    for(int i=0;i<=N/R;i++)
        for(int j=0;j<=N/B;j++){
            if(N-i*R-j*B>=0 && (N-i*R-j*B)%G==0)
                cnt++;
        }
    cout<<cnt<<endl;
    return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rs64() {
	int64_t n;
	scanf("%" SCNd64, &n);
	return n;
}


int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri() - 1;
	std::set<int> left;
	for (int i = 0; i < n; i++) left.insert(i);
	
	std::map<int, int> taboo;
	for (int i = 0; i < n; i++) taboo[a[i]]++;
	
	auto zen = [&] (int no) {
		std::vector<int> res(left.begin(), left.end());
		int n = left.size();
		bool ok = false;
		do {
			if (res[0] == no) continue;
			bool cont = true;
			for (int i = 0; i + 1 < n; i++) if (res[i + 1] == a[res[i]]) {
				cont = false;
			}
			if (!cont) continue;
			ok = true;
			break;
		} while (std::next_permutation(res.begin(), res.end()));
		if (!ok) system("sleep 0.3"), assert(n != 6);
		if (!ok) return std::vector<int>();
		return res;
	};
	
	std::vector<int> res;
	int last_taboo = -1;
	bool ok = true;
	int i = 0;
	for (; i < n - 4; i++) {
		auto next = left.begin();
		std::set<int> no{last_taboo};
		if (taboo.size() == 3) {
			std::vector<std::pair<int, int> > all;
			for (auto j : taboo) all.push_back({j.second, j.first});
			std::sort(all.begin(), all.end());
			if (all[0].first == 1 && all[1].first == 1 && all[2].first == (int) left.size() - 2) {
				if (a[all[0].second] == all[2].second && a[all[2].second] == all[0].second) no.insert(all[0].second);
				if (a[all[1].second] == all[2].second && a[all[2].second] == all[1].second) no.insert(all[1].second);
			}
		}
		while (no.count(*next)) next++;
		if (taboo.size() == 2) {
			std::vector<std::pair<int, int> > all;
			for (auto j : taboo) all.push_back({j.second, j.first});
			std::sort(all.begin(), all.end());
			if (all[0].first == 1 && all[1].first == (int) left.size() - 1) {
				next = left.find(all[1].second);
				assert(*next != last_taboo);
			}
		} else if (taboo.size() == 1 && taboo.begin()->second == (int) left.size() - 1) {
			next = left.find(taboo.begin()->first);
		}
		res.push_back(*next);
		/*
		std::cerr << *next << " " << taboo.size() << std::endl;
		std::cerr << "no:";
		for (auto j : no) std::cerr << j << " ";
		std::cerr << std::endl;*/
		
		if (taboo.count(a[*next]) && !--taboo[a[*next]]) taboo.erase(a[*next]);
		taboo.erase(*next);
		
		last_taboo = a[*next];
		left.erase(*next);
	}
	auto tmp = zen(last_taboo);
	res.insert(res.end(), tmp.begin(), tmp.end());
	if (!ok || !tmp.size()) {
		std::cout << -1 << std::endl;
	} else {
		for (auto i : res) std::cout << i + 1 << " ";
		std::cout << std::endl;
	}
	
	return 0;
}


Measured memory_bytes: 10624
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {

	string s, ts = "CODEFESTIVAL2016";
	cin >> s;

	int cnt = 0;
	for (int i = 0; i < ts.size(); i++) {
		if (s[i] != ts[i]) cnt++;
	}

	cout << cnt << endl;

	return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    lint r, g, b, n;
    cin >> r >> g >> b >> n;

    lint ans = 0;
    rep(i, n + 1){
        rep(j, n + 1){
            lint ball = r * i + j * g;
            if(n >= ball && (n - ball) % b == 0LL){
                ++ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

long long gcd(long long a, long long b) {
    return b ? gcd(b, a%b) : a;
}

template <typename T>
vector<pair<T, int>> factorize(T n) {
    vector<pair<T, int>> res;
    for (T i = 2; i * i <= n; ++i) {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

int main(){
    long long A, B;
    cin >> A >> B;
    long long g = gcd(A, B);
    auto f = factorize<long long>(g);
    cout << f.size() + 1 << endl;
}


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

int main()
{
	int n,m,p;
	int x[100];
	double sum,pool;
	int win;
	
	while(1){
		cin >> n >> m >> p;
		if(n==0 && m==0 && p==0)break;
		
		sum = 0;
		for(int i=0;i<n;i++){
			cin >> x[i];
			sum += x[i] * 100;
		}
		
		if(x[m-1]==0){
			cout << 0 << endl;
		}else{
			pool = sum - sum * p/100;
			win = pool / x[m-1];
			cout << win << endl;
		}
		
	}
	
	return 0;
}
		
		

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;
void solve(){
    int a,b; cin>>a>>b;
    if((a+b)%2==0) cout<<(a+b)/2;
    else cout<<"IMPOSSIBLE";
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

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

int main(){
	string number;
	int sum;
	
	while(1){
		cin >> number;
		
		if(number == "0"){
			break;
		}
		sum = 0;
		for(int i = 0; i < number.size(); i++){
			sum += number[i] - '0';
		}
		
		cout << sum << endl;
	}
		
 	return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)

typedef long long ll;
typedef unsigned int uint;

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

    int ret = 0;
    int count = 0;
    rep(i,S.length()){
        string cs = "0";
        if (i%2 == 0) cs = "1";
        if (S.substr(i,1) != cs ) {
            count ++;
        }
    }
    ret = min(count, int(S.length()-count));

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
         
        int n = stdIn.nextInt();
        int m = stdIn.nextInt();
        int l = stdIn.nextInt();
         
        long[][] A = new long[n][m];
        long[][] B = new long[m][l];
        long[][] C = new long[n][l];
         
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                A[i][j] = stdIn.nextInt();
            }
        }
         
        for(int i = 0; i < m; i++) {
            for(int j = 0; j < l; j++) {
                B[i][j] = stdIn.nextInt();
            }
        }
         
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < l; j++) {
                for(int k = 0; k < m; k++) {
                    C[i][j] += A[i][k] * B[k][j];
                }
            }
        }
         
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < l-1; j++) {
                System.out.print(C[i][j] + " ");
            }
            System.out.println(C[i][l-1]);
        }
    }
}


Measured memory_bytes: 54296
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int[] b = Arrays.copyOf(a, n);
		Arrays.sort(b);
		int max1 = b[n - 1];
		int max2 = b[n - 2];
		for (int i = 0; i < n; i++) {
			if (a[i] == max1) {
				System.out.println(max2);
			} else {
				System.out.println(max1);
			}
		}
	}
}


Measured memory_bytes: 116720
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>

class DSU {
	std::vector<int> dat;

public:
	DSU(int n) : dat(n, -1) {}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x != y) {
			if (dat[x] > dat[y]) {
				std::swap(x, y);
			}
			dat[x] += dat[y];
			dat[y] = x;
		}
	}

	int find(int x) {
		if (dat[x] < 0) {
			return x;
		}
		return dat[x] = find(dat[x]);
	}

	int get_size(int x) {
		return -dat[find(x)];
	}
};

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

	std::vector<int> a(n + 1), b(n + 1);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		a.back() ^= a[i];
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
		b.back() ^= b[i];
	}

	std::map<int, int> ma;
	std::map<int, int> mb;
	for (int i = 0; i <= n; i++) {
		ma[a[i]]++;
		mb[b[i]]++;
	}
	if (ma != mb) {
		puts("-1");
		return 0;
	}

	std::vector<int> dict(a.begin(), a.end());
	std::sort(dict.begin(), dict.end());
	dict.erase(std::unique(dict.begin(), dict.end()), dict.end());
	DSU dsu(dict.size());
	for (int i = 0; i <= n; i++) {
		a[i] = std::lower_bound(dict.begin(), dict.end(), a[i]) - dict.begin();
		b[i] = std::lower_bound(dict.begin(), dict.end(), b[i]) - dict.begin();
		dsu.unite(a[i], b[i]);
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += a[i] != b[i];
	}
	for (int i = 0; i < dict.size(); i++) {
		if (dsu.find(i) == i) {
			if (dsu.get_size(i) >= 2 && (dsu.find(i) != dsu.find(a.back()))) {
				ans++;
			}
		}
	}
	std::cout << ans << std::endl;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 1000000007ll;

// struct ---------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
    

    return 0;
}


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

using namespace std;

int main(void) {
     int n;
     cin >> n;
     long long  ans = 0;
     for (int i = n;;) {
          if (i / 500) {
               ans += 1000;
               i -= 500;
          }
          else if (i / 5) {
               i -= 5;
               ans += 5;
          }
          else {
               break;
          }
     }
     cout << ans << endl;
     
     return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dp[1111][1111];
char mp[1111][1111];

void modadd(ll &a, ll b){
	a += b;
	a %= MOD;
}

int main(){
	
	int h,w;cin >> h >> w;
	REP(i,h){
		REP(j,w)cin >> mp[i][j];
	}
	
	dp[0][0] = 1;
	REP(i,h){
		REP(j,w)if(mp[i][j] == '.'){
			if(i + 1 < h && mp[i+1][j] == '.')modadd(dp[i+1][j],dp[i][j]);
			if(j + 1 < w && mp[i][j+1] == '.')modadd(dp[i][j+1],dp[i][j]);
		}
	}
	
	cout << dp[h-1][w-1] << endl;
	
	return 0;
}


Measured memory_bytes: 10368
import java.io.*;
import java.math.*;
import java.util.*;

class Main {
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.nextLine());
        if (n == 1) {
            System.out.println("Hello World");
        }
        else {
            int a = Integer.parseInt(sc.nextLine());
            int b = Integer.parseInt(sc.nextLine());
            System.out.println(a+b);
        }
        sc.close();
    }
}

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

	typedef long long ll;
	using namespace std;

	int main(){
		string s;
		int m = 0;
		cin >> s;
		int lm = 0;
		for(int i=0; i<s.size();i++){
			char c = s[i];
			if( c == 'A' || c == 'C' || c == 'G' || c == 'T'){
				lm++;
			}else{
				m = max(m, lm);
				lm = 0;
			}
		}
		cout << max(m,lm);
		return 0;
	}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[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 $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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

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

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

    ($next:expr, 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")
    };
}

fn solve() {
    input!(
        a: i32,
        b: i32,
    );

    let mut ans;

    if a < 10 && b < 10 {
        ans = a * b;
    }
    else {
        ans = -1;
    }
    println!("{}", ans);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int keta(int x) {
  int ans = 0;
  while (x > 0) {
    ans += x%10;
    x /= 10;
  }

  return ans;
}

int main() {
  int n,a,b; cin >> n >> a >> b;
  int cnt = 0;
  rep(i,n+1) {
    if (keta(i)>=a && keta(i)<=b) cnt+=i;
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  vector<int> a(N), b(N), c(N);
  int sum_a = 0, sum_b = 0;
  rep(i,N) {
    cin >> a[i] >> b[i] >> c[i];
    sum_a += a[i];
    sum_b += b[i];
  }
  int dp[N][sum_a + 1][sum_b + 1];
  rep(k,N) rep(i,sum_a+1) rep(j,sum_b+1) dp[k][i][j] = INF;
  dp[0][0][0] = 0;
  dp[0][a[0]][b[0]] = c[0];
  for (int k = 1; k < N; k++) rep(i,sum_a+1) rep(j,sum_b+1) {
    dp[k][i][j] = dp[k - 1][i][j];
    if (i - a[k] >= 0 && j - b[k] >= 0) {
      dp[k][i][j] = min(dp[k][i][j], dp[k - 1][i - a[k]][j - b[k]] + c[k]);
    }
  }
  
  int ans = INF;
  for (int k = 1; Ma * k <= sum_a && Mb * k <= sum_b; k++) {
    ans = min(ans, dp[N - 1][Ma * k][Mb * k]);
  }

  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 12404
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
    public static void Main()
    {
        int a = GetInt();
        int b = GetInt();
        int c = GetInt();
        int d = GetInt();
        int x = a * b;
        int y = c * d;
        if (x != y)
        {
            Console.WriteLine(Math.Max(x, y));
        }
        else
        {
            Console.WriteLine(x);
        }
        
    }
}

public static class MyIO
{
    private static string[] args = null;
    private static int num = -1;
    private static int used = -1;

    private static string getArg()
    {
        if (used == num)
        {
            args = Console.ReadLine().Split(' ');
            num = args.Length;
            used = 0;
        }
        return args[used++];
    }

    public static int GetInt() { return int.Parse(getArg()); }
    public static long GetLong() { return long.Parse(getArg()); }
    public static double GetDouble() { return double.Parse(getArg()); }
    public static string GetString() { return getArg(); }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        int x = Integer.parseInt(sc.next());
        
        int ans = 1;
        int a = x;
        while(a != 0){
            a += x;
            a %= 360;
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35668
#include<iostream>
using namespace std;
typedef long long int ll;
int main(){
  ll A, V;
  cin >> A >> V;
  ll B,W;
  cin >> B >> W;
  ll T;
  cin >> T;
  ll D=abs(A-B);
  ll D2=(V-W)*T;
  puts(D<=D2?"YES":"NO");
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,k;
  int score=0;
  cin >> a >> b >> c >> k ;
  if(a >= k) score = k;
  else {
    score = a ;
    k -= a ;
    if(b >= k) score = score;
    else{
      score = score;
      k -= b ;
      if(c >= k) score -= k ;
    }
  }
  
  cout << score ;
}


Measured memory_bytes: 3636
#include<iostream>

int main(){

    size_t a, b, k;
    std::cin >> a >> b >> k;
    
    if(k > a){
        if(b < (k - a)){
            std::cout << 0 << ' ' << 0 << std::endl;
        }else{
            std::cout << 0 << ' ' << b - (k - a) << std::endl;
        }
    }else{
        std::cout << a - k << ' ' << b << std::endl;
    }

    return 0;
}


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

int main(){
    int n;
    cin>>n;
    int last = n % 10;
    if(last == 3){
        cout<<"bon"<<"\n";
    }
    else if( (last == 0) ||(last == 1) ||(last == 6) ||(last == 8)){
        cout<<"pon"<<"\n";
    }
    else{
        cout<<"hon"<<"\n";
    }
}

Measured memory_bytes: 3636
n=int(input())
i=0
L=[]
 
 
while i<n:
    card=input().split( )
    suit=card[0]
    number=int(card[1])
 
    if suit == "H":
        number = number +13
    elif suit == "C":
        number = number +26
    elif suit == "D":
        number = number +39
    L.append(number)
    i+=1
 
for j in range(52):
    k=j+1
    if not k in L:
        if int(j/13)==0:
            print(f"S {(j%13)+1}")
        elif int(j/13)==1:
            print(f"H {(j%13)+1}")
        elif int(j/13)==2:
            print(f"C {(j%13)+1}")
        elif int(j/13)==3:
            print(f"D {(j%13)+1}")


Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

struct Button {
    int x1, y1, x2, y2;
    string to;
};

struct Page {
    vector<Button> bs;
};

int main() {
    int n;
    while (cin >> n, n) {
        int w, h;
        cin >> w >> h;
        map<string, Page> ps;
        vector<string> buf;
        for (int i = 0; i < n; i++) {
            string name;
            int b;
            cin >> name >> b;
            Page p;
            for (int j = 0; j < b; j++) {
                Button l;
                cin >> l.x1 >> l.y1 >> l.x2 >> l.y2 >> l.to;
                p.bs.push_back(l);
            }
            ps[name] = p;
            if (i == 0) {
                buf.push_back(name);
            }
        }
        int m;
        cin >> m;
        int idx = 0;
        for (int i = 0; i < m; i++) {
            string cmd;
            cin >> cmd;
            if (cmd == "click") {
                int x, y;
                cin >> x >> y;
                Page p = ps[buf[idx]];
                for (vector<Button>::iterator it = p.bs.begin(); it != p.bs.end(); it++) {
                    if (it->x1 <= x && x <= it->x2 && it->y1 <= y && y <= it->y2) {
                        buf.erase(buf.begin() + idx + 1, buf.end());
                        buf.push_back(it->to);
                        idx++;
                        break;
                    }
                }
            } else if (cmd == "back") {
                if (idx > 0) {
                    idx--;
                }
            } else if (cmd == "forward") {
                if (idx < (int) buf.size() - 1) {
                    idx++;
                }
            } else if (cmd == "show") {
                cout << buf[idx] << endl;
            }
        }
    }
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int m,d,i,cou,zyu,iti;
  cou=0;
  cin>>m>>d;
  for(i=22; i<d+1; i++){
    zyu=i/10;
    iti=i%10;
    if(zyu*iti<m+1&&zyu>1&&iti>1){
      cou=cou+1;
    }
  }
  cout<<cou;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int64_t INF=100000000000000;
int N;
int64_t dp[305][305];
int main(){
  cin>>N;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      cin>>dp[i][j];
  bool x=true;int64_t ans=0;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++){
     int64_t d=INF;
    for(int k=0;k<N;k++){
     if(k!=i && k!=j){
    if(dp[i][k]+dp[k][j]<d)
      d=dp[i][k]+dp[k][j];
    }
    }if(d<dp[i][j]){
      x=false;break;
                   }else if(dp[i][j]<d)
      ans+=dp[i][j];
      else{
      }
      
    }if(!x)
      cout<<-1<<endl;
  else
    cout<<ans/2<<endl;
  return 0;
}

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

typedef struct node {
  vector<int> befs;
  int tail;
} node;

int ans;

int checktail(node *a[],int i){
  int ma = 0;
  vector<int>::iterator it;
  for(it = a[i]->befs.begin(); it != a[i]->befs.end(); ++it){
    a[*it]->tail = checktail(a, *it);
    ma = max(ma,a[*it]->tail);
  }
  return ma + 1;
}

int cuttail(node *a[],int i,int K){
  int t = -1;
  int ma = 0;
  vector<int>::iterator it;
  for(it = a[i]->befs.begin(); it != a[i]->befs.end(); ++it){
    if(a[*it]->tail > K){
      a[*it]->tail = cuttail(a, *it, K);
    }
    if(i != 0 && a[*it]->tail == K){
      ++ans;
      a[*it]->tail = 0;
    }
    ma = max(ma,a[*it]->tail);
  }
  return ma + 1;
}

int main(int argc, char* argv[]){
  ans = 0;
  int N, K;
  cin >> N >> K;
  node *a[N];
  int i;
  int l;
  for(i=0; i<N; ++i){
    a[i] = new node();
  }
  for(i=0; i<N; ++i){
    cin >> l;
    if(i==0){
      if(l!=1){
        l = 1;
        ++ans;
      }
    }else{
      a[l-1]->befs.push_back(i);
    }
  }
  a[0]->tail = checktail(a,0);
  a[0]->tail = cuttail(a,0,K);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#define _USE_MATH_DEFINES
#define LL long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
using namespace std;

int main() {
	int h, w, ans, base, ansh, answ;
	for (;;) {
		cin >> h >> w;
		ansh = answ = 0;
		if (h == 0 && w == 0) break;
		base = h*h + w*w;
		ans = 100000000;
		for (int i = 1; i < 151; i++) {
			for (int j = 1; j < 151; j++) {
				if ((base < i*i + j*j||(base==i*i+j*j&&h<i))&&(i*i + j*j < ans)&&i < j) {
					ans = i*i + j*j;
					ansh = i;
					answ = j;
				}
			}
		}
		printf("%d %d\n", ansh, answ);
	}
	return 0;
}

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

typedef long long ll;

const
 ll INF=(ll)1e18;

ll DP[3010][3010][2];
ll tab[3010];

ll rec(ll l,ll r,ll kode)
{
	if (l>r) return 0;
	if (DP[l][r][kode]!=-INF)
	{
		return DP[l][r][kode];
	}
	if (l==r)
	{
		if (kode==1)
			DP[l][r][kode]=-tab[l];
		else
			DP[l][r][kode]=tab[l];
		return DP[l][r][kode];
	}
	if (kode==0)
	{
		ll ret=-INF;
		ll tot=0ll;
		for (int i=l;i<=l;i++)
		{
			tot+=tab[i];
			ret=max(ret,tot+rec(i+1,r,kode^1));
		}
		tot=0ll;
		for (int i=r;i>=r;i--)
		{
			tot+=tab[i];
			ret=max(ret,tot+rec(l,i-1,kode^1));
		}
		if (ret==-INF)
			ret=0ll;
		// cout<<l<<" "<<r<<" "<<kode<<" "<<ret<<" lr kode dp\n";
		return DP[l][r][kode]=ret;
	}
	else
	{
		ll ret=INF;
		ll tot=0ll;
		for (int i=l;i<=l;i++)
		{
			tot+=tab[i];
			ret=min(ret,rec(i+1,r,kode^1)-tot);
		}
		tot=0ll;
		for (int i=r;i>=r;i--)
		{
			tot+=tab[i];
			ret=min(ret,rec(l,i-1,kode^1)-tot);
		}
		if (ret==INF)
			ret=0ll;
		// cout<<l<<" "<<r<<" "<<kode<<" "<<ret<<" lr kode dp\n";
		return DP[l][r][kode]=ret;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	for (ll i=1;i<=n;i++)
		for (ll j=1;j<=n;j++)
			DP[i][j][0]=DP[i][j][1]=-INF;
	for (ll i=1;i<=n;i++)
		cin>>tab[i];
	rec(1,n,0);
	cout<<DP[1][n][0]<<"\n";
}

Measured memory_bytes: 141696
import bisect

X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    p = sorted(list(map(int, input().split())))

    idx = bisect.bisect_left(p, X)
    
    if p[idx] != X:
        print(X)
    else:
        pre = idx - 1
        nxt = idx + 1
        pre_num = X - 1
        for i in range(pre, -1, -1):
            if p[i] != pre_num:
                break
            else:
                pre_num -= 1
        nxt_num = X + 1
        for i in range(nxt, N):
            if p[i] != nxt_num:
                break
            else:
                nxt_num += 1
        if abs(X - pre_num) <= abs(X - nxt_num):
            print(pre_num)
        else:
            print(nxt_num)
    

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);   
    string s;
    cin >> s;
    Int n = (Int)s.size();
    Int a[3] = {};
    for (Int i = 0; i < n; i++) a[s[i] - 'a']++;
    sort(a, a + 3);
    if ((a[0] == a[1] && a[1] == a[2]) ||
        (a[0] + 1 == a[2] && a[1] == a[2]) ||
        (a[0] + 1 == a[2] && a[0] == a[1])) {
            dump("YES");
    }
    else {
        dump("NO");
    }
    return 0;
}

Measured memory_bytes: 512
/*
  AtCoder Beginner Contest 101
  D - Sunuke Numbers
*/

#include<iostream>
using namespace std;

unsigned long long K;

unsigned long long calcSunuke(unsigned long long n) {
  unsigned long long sunuke = 0;
  while (n != 0) {
    sunuke += n % 10;
    n /= 10;
  }
  return sunuke;
}

bool check(unsigned long long n, unsigned long long base) {
  return n * calcSunuke(n + base) <= calcSunuke(n) * (n + base);
}

int main() {
  scanf("%llu", &K);

  unsigned long long c = 0;
  unsigned long long n = 0;
  unsigned long long base = 1;

  while (1) {
    if (K <= c) break;
    
    if (!check(n + base, base)) base *= 10;

    n += base;
    printf("%llu\n", n);
    ++c;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
 
int main(){
  int a, b;
  cin >> a >> b;
  cout << max({a+b,a-b,a*b}) << endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
ll dp[100110];


void solve(long long N, long long K, std::vector<long long> h){
    rep(i, N) {
        dp[i] = mod * 10;
    }
    dp[0] = 0;

    rep(i, N) {
        REP(j, 1, K+1) {
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        } 
        // cout << i << " " << dp[i] << endl;
    }

    cout << dp[N-1] << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, K, std::move(h));
    // return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    double a, b, x; cin >> a >> b >> x;

    double s = x / a;
    double rad;
    if(s >= a * b / 2){
        double h = (a * b - s) * 2 / a;
        rad = atan2(h, a);
    }else{
        double w = s * 2 / b;
        rad = atan2(b, w);
    }
    double PI = acos(-1);
    double deg = rad / (2 * PI) * 360;
    printf("%.10f", deg);

    return 0;
}


Measured memory_bytes: 4044
import java.util.Scanner

import scala.io.StdIn._
object Main extends App {

  val k = scala.io.StdIn.readInt()
  val s = scala.io.StdIn.readLine()

  def solve() = {
    if(s.length <= k) s else s.take(k) + "..."
  }

  println(solve())

}



Measured memory_bytes: 54608
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
#define debug(x) (cout << "#x = " << (x) << endl)
#define lowbit(x) (x & -x)
#define Set(x, i) memset(x, i, sizeof x)
#define R register
#define For( i, j, k ) for(R int i = (j); i <= (k); ++i)
#define Rep( i, j, k ) for(R int i = (j); i >= (k); --i)
#define Cross( i, j, k ) for(R int i = (j); i; i = (k))
typedef long long ll;
using namespace std;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; bool f = 0; char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar (x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x); putchar (' '); }

	inline void wln ( ll x ) { write(x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x); wln (y); }

}

using namespace IO;

namespace Cesare {
	
	char s[N];
	ll n, Ans;
	
	int main() {
		n = read();
		cin >> s + 1;
		for (int i = 1, j = 1; i <= n; i = j + 1) {
			j = i;
			while (j <= n && s[i] == s[j]) ++j; 
			++Ans, --j;
		}
		return wln(Ans), 0;
	}
	
}

int main()
{
	return Cesare :: main();
}

/*

*/



Measured memory_bytes: 384
a = int(input())
b, c = map(int, input().split())
d = list(map(int, input().split()))
e = []
for i in range(a):
    f = b - d[i] * 0.006
    e.append([i+1, abs(f-c)])
e = sorted(e, key=lambda x: x[1])
print(e[0][0])


Measured memory_bytes: 3188
while 1:
    n, q = map(int, raw_input().split())
    if n==0:
        break
    d = [0]*101
    for i in xrange(n):
        D = map(int, raw_input().split())
        for j in xrange(D[0]):
            d[D[j+1]] += 1

    v = max(d)
    if v < q:
        print 0
    else:
        print d.index(v)

Measured memory_bytes: 6352
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
n,p=map(int,input().split())
a=list(map(int,input().split()))
cnt=0
odd=0
even=0
ans=0
for i in range(n):
    if a[i]%2==0:
        even+=1
    else:
        odd+=1
if p==0:
    cnt=odd
    if cnt%2!=0:
        cnt-=1
    while cnt>=0:
        ans+=combinations_count(odd, cnt)
        cnt-=2
    ans*=2**even
else:
    cnt=odd
    if cnt%2==0:
        cnt-=1
    while cnt>=0:
        ans+=combinations_count(odd, cnt)
        cnt-=2
    ans*=2**even
print(ans)
    


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> human(N);
  int K;
  cin>>K;
  int count =0;
  
  for(int i=0;i<N;i++){
    
    cin>>human.at(i);
    if(human.at(i)>=K){
      count++;
    }
    
  }
  
  cout<<count<<endl;
  
  return 0;
  
}

Measured memory_bytes: 640