akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

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

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

  int ans = A[0];
  for(int i=0; i<N; i++) {
    ans = gcd<int>(ans, A[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int h, w;
	int i, j;
	
	while (scanf("%d %d", &h, &w), h || w) {

		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if ((i + j) % 2 == 0) putchar('#');
				else putchar('.');
			}
			puts("");
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 588
s = list(input())

for i in range(int(input())):
    cmd,a,b, *c = input().split()
    a = int(a); b = int(b)
    if cmd == "print":
        print(*s[a:b+1],sep="")

    elif cmd =="reverse":
        s[a:b+1] = reversed(s[a:b+1])
    else:
        s[a:b+1] = c[0]


Measured memory_bytes: 5736
// C - Tax Increase
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int A,B;

int solve(){
	rp(i,1,1250+1) if(int(i*0.08)==A && int(i*0.10)==B) return i;
	return -1;
}

int main(){
	cin>>A>>B;
	cout<< solve() <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MN 1000000
#define mod 1000000007
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,K,p[MN+5],inv[MN+5],pw[MN+5],ans;
inline int C(int n,int m){return m<0||m>n?0:1LL*p[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
    n=read();m=read();K=read();p[0]=inv[0]=p[1]=inv[1]=pw[0]=1;pw[1]=3;
    for(int i=2;i<=MN;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod,pw[i]=3LL*pw[i-1]%mod;
    for(int i=2;i<=MN;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod;
    for(int i=0,res=1;i<=m+K;++i)
    {
        if(i)
        {
            int l=max(0,i-K),r=min(m,i);
            int L=max(0,i-1-K),R=min(m,i-1);
            res=(2LL*res+mod-C(i-1,R)+C(i-1,L-1))%mod;
            if(l>L) res=(res+mod-C(i,L))%mod;
            if(r>R) res=(res+C(i,r))%mod;
        }
        ans=(ans+1LL*res*C(i+n-1,n-1)%mod*pw[m+K-i])%mod;
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 11904
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>

using namespace std;
#define cerr cerr << "[DBG] "
#define DBG(x) cerr << #x << ": " << x << endl
// http://genkisugimoto.com/jp/blog/procon/2015/04/15/print-debug-technique-in-cpp.html
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { s << v[i]; if (i < v.size() - 1) s << "\t"; } return s; }

typedef long long ll;
const int MOD = 1000000007;

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

	int n;
	cin >> n;
	vector<int> t(n);
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> t[i];
	}
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	vector<int> kakutei(n, -1);
	vector<int> multiple(n, -1);
	ll result = 1;
	
	for(int i=0; i<n; i++){
		if(i==0 || t[i-1] < t[i]){
			kakutei[i] = t[i];
			if(t[i] > a[i]) goto FAILED; // 矛盾
		}
	}

	for(int i=n-1; i>=0; i--){
		if(i==n-1 || a[i] > a[i+1]){
			if(kakutei[i] == -1) kakutei[i] = a[i];
			else if(a[i] != kakutei[i]) goto FAILED;
			if(t[i] < a[i]) goto FAILED;
		}
	}

	for(int i=0; i<n; i++){
		if(kakutei[i] == -1){
			multiple[i] = min(a[i], t[i]);
		}
	}

	for(int i=0; i<n; i++){
		if(multiple[i] != -1){
			result = ((ll)(result * (ll)multiple[i])) % MOD;
		}
	}

	cout << result << endl;
	return 0;
FAILED:
	cout << 0 << endl;
	return 0;
}


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



int main(void)
{
    long long h,w,n;
    cin >> h >> w >> n;
    map<pair<int,int>,int> nine; 
    
    for (int i = 0;i < n; i++){
        //cerr << "n=" << i << endl;
        int x,y;
        cin >> y >> x;
        x--;
        y--;
        for(int i = y-2; i <= y;i++){
            if ((i < 0) || (h-3 < i)) continue;
            for (int j = x-2; j <= x;j++) {
                if ((j < 0) || (w-3 < j)) continue;
                //cerr << j << ":" << i << endl;
                auto p = make_pair(j,i);
                auto c = nine.count(p);
                if (c != 0) {
                    nine[p]++;
                } else {
                    nine[p] = 1;
                }
            }
        }
    }
    vector<long long> sum = {0,0,0,0,0,0,0,0,0,0};
    for(auto iter = nine.begin(); iter != nine.end(); ++iter) {
        sum[iter->second]++;
    }
    sum[0] = (h - 2) * (w - 2) - accumulate(sum.begin()+1, sum.end(), 0LL);
    for(int i = 0,e = sum.size();i < e;i++) cout << sum[i] << endl;
            
    return 0;
}


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

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

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

fn main() {
    input! {
        k: u32,
        x: u32
    }
    println!("{}", if x <= 500 * k {"Yes"} else {"No"});
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

vector<bool> sieve_of_eratosthenes(int n) {
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= n; ++i)
            if (is_prime[i])
                    for (int k = 2 * i; k <= n; k += i)
                            is_prime[k] = false;
    return is_prime;
}
  
int main() {
  int N;
  cin >> N;
  v(bool) p = sieve_of_eratosthenes(55555);
  vi candidate;
  for(int i = 6; i < 55556;i += 5) {
    if(p[i]) candidate.push_back(i);
  }
  rep(i,N) {
    cout << candidate[i] << " ";
  }
  cout << endl;
  return 0;
}

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

int main(){
	string S,T; cin>>S>>T;
	int Ns = S.size(), Nt = T.size();

	vector<vector<int>> dp(Nt+1, vector<int>(Ns+1));
	for(int t=1; t<=Nt; t++)
		for(int s=1; s<=Ns; s++)
			if(T[t-1]==S[s-1]) dp[t][s] = dp[t-1][s-1] + 1;
			else dp[t][s] = max(dp[t][s-1], dp[t-1][s]);

	string ans;
	int t = Nt, s = Ns;
	while(t>=1 && s>=1){
		if(dp[t][s]==dp[t][s-1]) s--;
		else if(dp[t][s]==dp[t-1][s]) t--;
		else{
			t--; s--;
			ans = S[s] + ans;
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int ret = 0;
  rep(i,N){
    int j = i;
    while(j<N && S[i] == S[j]) j++;
    i = j-1;
    ret++;
  }

  cout << ret << endl;
  
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)

const ll N = 123456;
const ll mod = 998244353;
const ld eps = 1e-5;

int dp[3333][3333];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cout << fixed;


    string s , t;

    cin >> s >> t;

    int n = s.length();

    int m = t.length();

    // rep(i , 0 , n - 1) {
    //     if(s[i] == t[0])
    //         dp[i][0] = 1;
    // }

    // rep(i , 0 , m - 1) {
    //     if(t[i] == s[0])
    //         dp[0][i] = 1;
    // }

    rep(i , 1 , n) {
        rep(j , 1 , m){

            if(s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else {
                dp[i][j] = max(dp[i - 1][j] , dp[i][j - 1]);
            }
        }
    }
    
    int i = n;
    int j = m;

    string ans = "";

    // rep(i , 1 , n) {
    //     rep(j , 1 , m) {
    //         cout << dp[i][j] << " ";
    //     }

    //     cout << endl;
    // }

    while(1) {
        if(i == 0 || j == 0) break;

//cout << i << " " << j << endl;
        if(dp[i][j] > dp[i - 1][j - 1] && dp[i][j] > dp[i - 1][j] && dp[i][j] > dp[i][j - 1]) {

            ans += s[i - 1];
            i--;
            j--;
        }
        else {
            if(dp[i - 1][j] > dp[i][j - 1]) {
                if(i > 0) i--;
                else j--;
            }
            else {
                j--;
            }
        }
    }

// cout << ans << endl;
    reverse(ans.begin() , ans.end());

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


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

int main() {
  int n;
  cin >> n;
  cout << "ABC" << n << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            TreeSet<Integer> tree = new TreeSet<>();
            int[] count2 = new int[123];
            int N = in.nextInt();
            for (int i = 0; i < N; i++) {
                int x = in.nextInt();
                int twos = 0;
                while ((x & 1) == 0) {
                    twos++;
                    x >>= 1;
                }
                count2[twos]++;
                tree.add(twos);
            }
            int last = tree.first();
            count2[last]--;
            if (count2[last] == 0) tree.remove(last);
            for (int i = 1; i < N; i++) {
                int required = 2 - last;
                Integer next = tree.ceiling(required);
                if (next == null) {
                    out.print("No");
                    return;
                }
                count2[next]--;
                if (count2[next] == 0) tree.remove(next);
                last = next;
            }
            out.print("Yes");
        }

    }

    static class InputReader {
        private int lenbuf = 0;
        private int ptrbuf = 0;
        private InputStream in;
        private byte[] inbuf = new byte[1024];

        public InputReader(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = in.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }
}



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

int main(){
  int W,H,x,y,ans2;
  cin >> W >> H >> x >> y;
  double dw,dh;
  dw = W;
  dh = H;
  double ans1 = dw*dh/2.000000;
  if(W%2==1||H%2==1){
    ans2 = 0;
  }else if(W/2==x&&H/2==y){
    ans2 = 1;
  }else{
    ans2 = 0;
  }
  cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2,3)
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define re register
#define int long long
using namespace std;
int n,m,k,a[200002],b[200002],cnt,cnt1,c[200002],cnt2;
inline int read(){
	re int t=0,f=0;
	re char v=getchar();
	while(v<'0')f|=(v=='-'),v=getchar();
	while(v>='0'){
	t=(t<<3)+(t<<1)+v-48;
	v=getchar();}
	return f?-t:t;
}
inline int check(re int x){
	int ans=0;
	if(x>0){
		ans+=cnt*cnt1+cnt*cnt2+cnt1*cnt2+cnt2*(cnt2-1)/2;
		int t=cnt;
		for(re int i=1;i<=cnt;++i){
			while(a[i]*a[t]>x&&t>=i)--t;
			if(t<=i)break;
			ans+=(t-i);
		}//cout<<ans<<endl;
		t=cnt1;
		for(re int i=1;i<=cnt1;++i){
			while(b[i]*b[t]>x&&t>=i)--t;
			if(t<=i)break;
			ans+=(t-i);
		}
		return ans;
	}
	else if(x==0){
		ans+=cnt*cnt1+cnt*cnt2+cnt1*cnt2+cnt2*(cnt2-1)/2;
		return ans;
	}
	else{
		x=-x;
		int t=1;
		for(re int i=cnt;i>=1;--i){
			while(a[i]*b[t]<x&&t<=cnt1)++t;
			ans+=cnt1-t+1;
		}
		t=1;
		for(re int i=cnt1;i>=1;--i){
			while(b[i]*a[t]<x&&t<=cnt)++t;
			ans+=cnt-t+1;
		}
		return ans/2;
	}
}
int x;
signed main(){
n=read();k=read();
for(re int i=1;i<=n;++i){
x=read();if(x>0)a[++cnt]=x;else if(x<0)b[++cnt1]=-x;else c[++cnt2]=x;
}
sort(a+1,a+cnt+1);
sort(b+1,b+cnt1+1);
int l=-1e18,r=1e18;
while(l<r){
	int mid=(l+r)/2;
	if(mid==r)--mid;
	if(check(mid)>=k)r=mid;
	else l=mid+1;
}
printf("%lld",l);
}


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

const int INF = 1e9;

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

	int n;
	cin >> n;
	bool ans = true;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0))
			ans = false;
	}
	if (ans)
		cout << "APPROVED" << endl;
	else
		cout << "DENIED" << endl;

	return 0;
}

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

using namespace std;

typedef int Weight;
const Weight INF = 1e9;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

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

// T: 頂点部分集合．同じものが複数入っていても大丈夫
// g: 隣接行列．無向性（対称性）を仮定する．つながっていない場合はINF
// 戻り値：シュタイナー木の重み．ただし，>= INFのときは存在しない（連結でない）
Weight MinimumSteinerTree(const vector<int> &T, const Matrix &g) {
    const int n = g.size();
    const int numT = T.size();
    if (numT <= 1)
        return 0;

    Matrix d(g);  // all-pair shortest
    for (int k = 0; k < n; ++k)
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    Weight OPT[(1 << numT)][n];
    for (int S = 0; S < (1 << numT); ++S)
        for (int x = 0; x < n; ++x)
            OPT[S][x] = INF;

    for (int p = 0; p < numT; ++p) // trivial case
        for (int q = 0; q < n; ++q)
            OPT[1 << p][q] = d[T[p]][q];

    for (int S = 1; S < (1 << numT); ++S) { // DP step
        if (!(S & (S - 1)))
            continue;
        for (int p = 0; p < n; ++p)
            for (int E = 0; E < S; ++E)
                if ((E | S) == S)
                    OPT[S][p] = min(OPT[S][p], OPT[E][p] + OPT[S - E][p]);
        for (int p = 0; p < n; ++p)
            for (int q = 0; q < n; ++q)
                OPT[S][p] = min(OPT[S][p], OPT[S][q] + d[p][q]);
    }
    Weight ans = INF;
    for (int S = 0; S < (1 << numT); ++S)
        for (int q = 0; q < n; ++q)
            ans = min(ans, OPT[S][q] + OPT[((1 << numT) - 1) - S][q]);

    return ans;
}


int main()
{
    int H, W;

    while (cin >> H >> W, H || W) {
        const int N = H * W;
        vector<int> T;
        int c;

        for (int i = 0; i < H; ++i)
            for (int j = 0; j < W; ++j) {
                cin >> c;
                if (c == 1)
                    T.push_back(W * i + j);
            }


        Matrix g(N, vector<Weight>(N, INF));

        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                int v = j + i * W;

                g[v][v] = 0;

                for (int d = 0; d < 4; ++d) {
                    int nx = j + dx[d];
                    int ny = i + dy[d];
                    if (nx < 0 || ny < 0 || nx >= W || ny >= H)
                        continue;
                    int u = nx + ny * W;
                    g[v][u] = g[u][v] = 1;
                }
            }
        }

        cout << N - MinimumSteinerTree(T, g) - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1416
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TemplateAlgorithm
{
    class Program
    {
        public const long Inf = (long)1e18;
        public const double eps = 1e-6;
        public const string alfa = "abcdefghijklmnopqrstuvwxyz";
        public const string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const int MOD = 1000000007;
        
        // c ot i
        static int ToInt(char c) => c - '0';

        static void Main(string[] args)
        {
            int A = IO.ReadInt();

            int L = A / 100;
            int R = A % 100;

            if (InRange(1,12,L))
            {
                if (InRange(1, 12, R))
                {
                    WriteLine("AMBIGUOUS");
                }
                else WriteLine("MMYY");
            }
            else
            {
                if (InRange(1, 12, R)) WriteLine("YYMM");
                else WriteLine("NA");
            }
        }

        #region  範囲

        public static bool InRange<T>(T begin, T end, T value) where T : IComparable<T> 
            => value.CompareTo(begin) >= 0 && value.CompareTo(end) <= 0;

        #endregion

        #region MIN,MAX

        /// <summary>
        /// 最大値を返す
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vals"></param>
        /// <returns></returns>
        public static T MaxValue<T>(params T[] vals) => vals.Max();

        /// <summary>
        /// 最小値を返す
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="vals"></param>
        /// <returns></returns>
        public static T MinValue<T>(params T[] vals) => vals.Min();
        #endregion
    }

    #region IO

    /// <summary>
    /// IO
    /// </summary>
    public class IO
    {
        public static string ReadStr(bool isTrim = false) => (isTrim) ? ReadLine().Trim() : ReadLine();
        public static int ReadInt() => int.Parse(ReadStr());

        public static long ReadLong() => long.Parse(ReadStr());

        public static decimal ReadDecimal() => decimal.Parse(ReadStr());
        public static double ReadDouble() => double.Parse(ReadStr());
        public static string[] ReadStrArr(char separator = ' ') => ReadLine().Split(separator);
        public static int[] ReadIntArr() => Array.ConvertAll(ReadStrArr(), int.Parse);
        public static long[] ReadLongArr() => Array.ConvertAll(ReadStrArr(), long.Parse);

        public static decimal[] ReadDecimalArr() => Array.ConvertAll(ReadStrArr(), decimal.Parse);
        public static double[] ReadDoubleArr() => Array.ConvertAll(ReadStrArr(), double.Parse);        
    }

    #endregion    
}


Measured memory_bytes: 11092
/*
 * FileName:     include
 * CreatedDate:  2020-06-10 20:31:51 +0900
 * LastModified: 2020-06-10 20:45:20 +0900
 */

#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n;scanf("%d",&n);
    int *a = malloc(n*sizeof(int));
    for(int i=0;i<n;i++)scanf("%d",a+i);
    int m;scanf("%d",&m);
    int *b = malloc(n*sizeof(int));
    for(int i=0;i<m;i++)scanf("%d",b+i);
    if(m>n){
        printf("0\n");
        free(a);
        free(b);
        return 0;
    }
    int index_a=0,index_b=0;
    while(index_a<n&&index_b<m){
//        printf("index_a,b:%d,%d\n",index_a,index_b);
//        printf("a[%d],b[%d]:%d,%d\n",index_a,index_b,a[index_a],b[index_b]);
        if(a[index_a]<b[index_b]){
            index_a++;
        }
        else if(a[index_a]==b[index_b]){
            index_b++;
        }
        else{
            printf("0\n");
            free(a);
            free(b);
            return 0;
        }
    }
    if(index_a==n&&index_b<m){
        printf("0\n");
        free(a);
        free(b);
        return 0;
    }
    printf("1\n");
    free(a);
    free(b);
    return 0;
}



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
string A, B, C;

signed main() {
    cin >> N;
    cin >> A >> B >> C;
    int ans = 0;
    rep(i, N) {
        ans += 2;
        if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i])ans--;
        if (A[i] == B[i] && B[i] == C[i])ans--;
    }
    cout << ans << endl;
    return 0;
}


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

llong n, r, t;
llong pos[105];
llong pase[105];
llong c[1005];
llong cnt[1005];
llong ans;

int main() {
	cin >> n >> r >> t;
	for (llong i = 0; i < n; i++) cin >> pase[i];
	
	for (llong i = 0; i < t; i++) {
		for (llong j = 0; j < r; j++) cnt[j] = 0;
		
		for (llong j = 0; j < n; j++) {
			if (i > 0) c[pos[j]]--;
			
			pos[j] += pase[j];
			pos[j] %= r;
			
			cnt[pos[j]]++;
		}
		
		for (llong j = 0; j < r; j++) {
			ans += max(0ll, cnt[j] - c[j]);
			c[j] = max(c[j], cnt[j]);
		}
		
		if (i > 0) {
			for (llong j = 0; j < n; j++) {
				c[pos[j]]++;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
#include <queue>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull n;
  cin >> n;

  vector<pair<ull, ull>> a;
  each(i, n) {
    ull tmp;
    cin >> tmp;
    a.push(make_pair(tmp, i+1));
  }

  sort(a.begin(), a.end(), [](const auto& r, const auto& l) {
                             return r.first < l.first;
                           });

  each(i, n) {
    cout << a[i].second << " ";
    //cout << "attendNO: " << a[i].first << " at:" << a[i].second << endl;
  }
  //dump(a);
  cout << endl;

  return 0;
}


Measured memory_bytes: 2544
#include <bits/stdc++.h>   
using namespace std;
#define N 1000000
#define REP(i, n) for(int i=0; i<n; i++)
int n;
string s;
int e[N];//西向いている人の累積和
int ans;
int main(void){
    cin>>n;
    cin>>s;
    if(s[0]=='E')e[0]=1;
    for(int i=1;i<n;i++){
        if(s[i]=='E'){
            e[i]=e[i-1]+1;    
        }else{
            e[i]=e[i-1];    
        }
    }
    ans=(e[n-1]-e[0]);
    for(int i=1;i<=n-1;i++){
       ans=min(ans,i-e[i-1]+(e[n-1]-e[i]));
    }
    cout<< ans <<endl;
}


Measured memory_bytes: 1796
N,M,X = map(int,input().split())
CA = [list(map(int,input().split())) for _ in range(N)]
def judge(books):
    study = [0]*M
    money = 0
    for i in range(N):
        if(books[i] == "1"):
            for j in range(M):
                study[j] += CA[i][j+1]
            money += CA[i][0]
    #print(study)
    for i in range(M):
        if(study[i] < X):
            return -1
    return money
ans = 10**10
for i in range(0,2**N):
    books =  str('{:0100b}'.format(i))[100-N:]
    #print(books)
    tmp = judge(books)
    if(tmp == -1):
        continue
    ans = min(tmp,ans)
if(ans == 10**10):
    print("-1")
else:
    print(ans)

Measured memory_bytes: 8972
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>

typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()ss		
#define debug system("pause")				//デバッグ用

int saiki(string, int, int);

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

	string s;
    cin>>s;
    int val=700;
    
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='o')
            val+=100;
        else
            continue;
    }
    cout<<val<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll A, B;

ll X[MAX_N];

void solve() {
	cin >> N >> A >> B;
	ll p = 0;
	ll ans = 0;
	rep(i, 0, N) {
		ll x; cin >> x;
		if(i != 0) {
			ans += min(A * (x - p), B);
		}
		p = x;
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector<int64_t> X(N);
  for(int i=0;i<N;i++){
    cin >> X.at(i);
  }
  sort(X.begin(),X.end());
  priority_queue<int64_t,vector<int64_t>,greater<int64_t> > pq;
  for(int64_t i=X.at(0);i<=X.at(N-1);i++){
    int64_t ans=0;
    for(int j=0;j<N;j++){
      ans+=(int)pow(X.at(j)-i,2);
    }
    pq.push(ans);
  }
  cout << pq.top() << endl;
  return 0;
}


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

int main(){
    int t;  cin >> t;
    while(t-- > 0){
        vector<int> a(9), b(9);
        for(int i = 0; i < 9; i++)  cin >> a[i];
        for(int i = 0; i < 9; i++)  cin >> b[i];
        sort(b.begin(), b.end());
        int g = 0;
        do{
            int tmpg = 0;
            for(int i = 0; i < 9; i++)  if(a[i] > b[i]) tmpg += a[i]+b[i];
            if(tmpg > 85)   g++;
        }while(next_permutation(b.begin(), b.end()));
        double s = (double)g /1/2/3/4/5/6/7/8/9;
        cout << fixed << setprecision(5) << s << " " << 1-s << endl;
    }
    return 0;
}


Measured memory_bytes: 3288
#include <stdio.h>
#include <math.h>


main()
{
int h,w;
while(1){
	scanf("%d %d",&h,&w);
	if((h|w)==0)break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%c",(j+i)%2?'.':'#');
		}
		printf("\n");
	}
	printf("\n");
}
}


Measured memory_bytes: 2612
#include <iostream>

using namespace std;

const int MOD = 1000000007;

int main(){
	
	int n;
	string en;
	cin>>n>>en;
	long long res = 1;
	long long op = 0;
	for(int i=0;i<2*n;i++){
		if(en[i]=='B'){
			if(op%2){
				res = (res*op)%MOD;
				op--;
			}
			else{
				op++;
			}
		}
		else{
			if(op%2){
				op++;
			}
			else{
				if(op==0){
					cout<<0<<endl;
					return 0;
				}
				res = (res*op)%MOD;
				op--;
			}
		}
	}
	if(op){
		cout<<0<<endl;
		return 0;
	}
	while(n){
		res = (res * n)%MOD;
		n--;
	}
	cout<<res<<endl;
		
	return 0;
}

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

int gcd(int x, int y){
  int a = max(x,y);
  int b = min(x,y);
  if(a%b == 0){
    return b;
  }else{
    return gcd(a%b,b);
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int ans = gcd(A.at(0),A.at(1));
  for(int i=1;i<N;i++){
    ans = gcd(ans,A.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>

using namespace std;

int main() {
    int n, d;
    cin >> n >> d;
    double a[n][d];
    int ans = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> a[i][j];
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            double dist = 0;
            for (int k = 0; k < d; k++) {
                dist += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
            }
            if (floor(sqrt(dist)) == ceil(sqrt(dist))) {
                ans++;
            }
        }
    }

    cout << ans << "\n";
}

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

using namespace std;
constexpr int NMAX = 200010;

char numx[NMAX];

int fSmall(int x) {
	if (x == 0) return 0;
	else return fSmall(x % __builtin_popcount(x)) + 1;
}

int main() {
	int n;
	scanf("%d", &n);
	scanf("%s", numx);
	vector<int> valAfterOne(n);
	vector<int> ones, zeroes;
	for (int i = 0; i < n; ++i) {
		if (numx[i] == '0') zeroes.push_back(n - 1 - i);
		else ones.push_back(n - 1 - i);
	}
	// get the powers of 2 modulo curPop - 1 and curPop + 1
	// and compute the number modulo curPop - 1 and curPop + 1
	vector<int> ans(n, -1);
	// compute answer for all zeroes
	vector<int> pow2ModP1(n);
	pow2ModP1[0] = 1 % (ones.size() + 1);
	for (int i = 1; i < n; ++i) pow2ModP1[i] = (pow2ModP1[i-1] * 2) % (ones.size() + 1);
	int totalModP1 = 0;
	for (int v : ones) totalModP1 = (totalModP1 + pow2ModP1[v]) % (ones.size() + 1);
	for (int v : zeroes) ans[n-1-v] = fSmall((totalModP1 + pow2ModP1[v]) % (ones.size() + 1)) + 1;
	// compute answer for all ones
	if (ones.size() == 1) {
		// the answer will be 0
		ans[n-1-ones[0]] = 0;
	} else if (ones.size() > 1) {
		vector<int> pow2ModM1(n);
		pow2ModM1[0] = 1;
		for (int i = 1; i < n; ++i) pow2ModM1[i] = (pow2ModM1[i-1] * 2) % (ones.size() - 1);
		int totalModM1 = 0;
		for (int v : ones) totalModM1 = (totalModM1 + pow2ModM1[v]) % (ones.size() - 1);
		for (int v : ones) ans[n-1-v] = fSmall((totalModM1 - pow2ModM1[v] + ones.size() - 1) % (ones.size() - 1)) + 1;
	}
	for (int x : ans) printf("%d\n", x);
	return 0;
}


Measured memory_bytes: 7564
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          Out(solve(Input.ScanStr(),Input.ScanStr()));
        }
      static public string solve(string a, string b){
        if(a==b) return "EQUAL";
        if(a.Length > b.Length) return "GREATER";
        if(a.Length < b.Length) return "LESS";
        int i = 0;
        while(true){
          int s = int.Parse(a[i].ToString());
          int t = int.Parse(b[i].ToString());
          if(s > t) return "GREATER";
          if(s < t) return "LESS";
          i++;
        }
      }
      
        static public void Out(object s) { Console.WriteLine(s); }
    }
    
    static class Input {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(); }
    }

    static class MyMath {
        public static int DistanceL1(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = Math.Abs(a[i]-b[i]);
            return c.Sum();
        }

        public static double DistanceL2(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = (a[i]-b[i])*(a[i]-b[i]);
            return Math.Sqrt(c.Sum());
        }
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int wa(int n){
  return n/10000 + n%10000/1000 + n%1000/100 + n%100/10 + n%10;
}

int main() {
  int N,ans = 10000;
  cin >> N;
  for(int A = 1;A < N;A++)ans = min(ans,wa(A)+wa(N - A));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;    
const int N = 1e5+6, M = 1e5+5, OO = 0x3f3f3f3f;

int main()
{
    int x;
    scanf("%d",&x);
    printf("%d\n",x*x);
    return 0;
}

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

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

    int n,m;
    cin >> n >> m;

    long long int mod = 1000000007;

    char arr[n][m];

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

    int dp[n][m];

    dp[0][0] = 1;

    for(int j = 1; j<m; j++){
        
        if(arr[0][j] == '#'){
            dp[0][j] = 0;
        }

        else if(arr[0][j] == '.'){
            dp[0][j] = dp[0][j-1];
        }

    }

    cout << endl;

    for(int i = 1; i<n; i++){
        for(int j = 0; j<m; j++){

            if(arr[i][j] == '#'){
                dp[i][j] = 0;
            }

            else if( j == 0){
                dp[i][j] = dp[i-1][j]%mod;
            }

            else{
                dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
            }

        }


    }

    cout << dp[n-1][m-1] <<endl;
    
    return 0;
}

Measured memory_bytes: 8448
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int A = in.nextInt();
		int B = in.nextInt();
		if(A==B) System.out.println("Draw");
		else if(A==1) System.out.println("Alice");
		else if(B==1) System.out.println("Bob");
		else if(A<B) System.out.println("Bob");
		else if(A>B) System.out.println("Alice");
	}
}

Measured memory_bytes: 21844
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(s: chars);
    let mut mi = 1 << 20;
    for i in 0..2 {
        let mut cnt = 0;
        for j in 0..s.len() {
            if s[j] as u8 != b'0' + ((i + j) % 2) as u8 {
                cnt += 1;
            }
        }
        mi = min(mi, cnt);
    }
    puts!("{}\n", mi);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    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;
int main(){
string s="";
  for(int i=0;i<3;i++){
  string x;
    cin>>x;
    char X=x.at(0);
    char y=char(X-32);
    s+=y;
  
  }cout<<s<<endl;
  
  
   return 0;
}

Measured memory_bytes: 256
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N = int(input())
A = [0] + list(map(int, input().split()))

dp = makelist(N+1, 2)
dp[1][0] = A[1]
dp[1][1] = -int(1e9)
for i in range(2, N+1):
    dp[i][0] = A[i] + max(dp[i-1][0], dp[i-1][1])
    dp[i][1] = -A[i] + max(dp[i-1][0] + (-A[i-1])*2, dp[i-1][1] + A[i-1]*2)

ans = max(dp[N][0], dp[N][1])
print(ans)


Measured memory_bytes: 73888
#include<iostream>
using namespace std;
const int N=2002,mod=1e9+7;
int n,k,c[N][N];
int main() {
	scanf("%d%d",&n,&k);
	for (int i=0; i<=n+1; i++) {
		c[i][0] = 1;
		for (int j=1; j<=i; j++)
            c[i][j] = (c[i-1][j] + c[i-1][j-1]) % mod;
	}
	for (int i=1; i<=k; i++) {
		int ans = 1ll * c[k-1][i-1] * c[n-k+1][i] % mod;
		printf("%d\n", ans);
	}
}


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

ll H, W;
char S[500][500];
bool visited[500][500];
ll dd[5] = { -1, 0, 1, 0, -1 };

void dfs(ll y, ll x, ll &b, ll &w) {
  if (visited[y][x]) return;
  visited[y][x] = true;

  if (S[y][x] == '#') b++;
  else w++;

  REP(i, 0, 4) {
    ll ny = y + dd[i], nx = x + dd[i + 1];
    if (0 <= ny && ny < H && 0 <= nx && nx < W && S[y][x] != S[ny][nx]) {
      dfs(ny, nx, b, w);
    }
  }
}

int main(void) {
  cin >> H >> W;
  REP(i, 0, H) cin >> S[i];

  ll ans = 0;
  REP(i, 0, H) REP(j, 0, W) {
    if (!visited[i][j]) {
      ll b = 0, w = 0;
      dfs(i, j, b, w);
      ans += b * w;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 13184
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

class Edge{
    public:
    int to = -1;
    int edgeNum = 0;
    int color = -1;
    int no;
};

int n;

vector<vector<Edge>> g;

vector<int> edgesnum;
vector<int> lastcolor;
vector<int> visited;

vector<int> ans;


void dfs(int now){

    //cout << now << endl;

    //if(now != 0) edgesnum[now] = g[now].size() + 1;

    int c = 1;

    visited[now] = 1;

    for(int i = 0; i < g[now].size(); i++){

        int next = g[now][i].to;

        if(visited[next] == 1){
            continue;
        }

        //cout << "LC " << now << ":" << lastcolor[now] << endl;

        if(c != lastcolor[now]){
            g[now][i].color = c;
            ans[g[now][i].no] = c;
        } else {
            c++;
            g[now][i].color = c;
            ans[g[now][i].no] = c;
        }

        lastcolor[next] = c;

        dfs(next);

        c++;

    }

}

int main(void){
    cin >> n;

    ans.resize(n - 1);

    g.resize(n);

    edgesnum.resize(n, 0);
    lastcolor.resize(n, -1);
    visited.resize(n, 0);

    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;

        a--;
        b--;

        Edge tmp;
        tmp.to = b;
        tmp.no = i;

        g[a].push_back(tmp);
        
        tmp.to = a;
        tmp.no = i;
        g[b].push_back(tmp);

    }

    //edgesnum[0] = g[0].size();

    for(int i = 0; i < n; i++){
        edgesnum[i] = g[i].size();
    }

    int k = 0;
    int sindex = 0;

    for(int i = 0; i < n; i++){
        if(k < edgesnum[i]){
            k = edgesnum[i];
            sindex = i;
        }
    }

    //edgesnum[sindex]--;

    k = 0;
    for(int i = 0; i < n; i++){
        k = max(k, edgesnum[i]);
    }

    dfs(sindex);

    cout << k << endl;

    for(int i = 0; i < n - 1; i++){
        cout << ans[i] << endl;
    }

    


}

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

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> snuke(n);
	rep(i, k){
		int d;
		cin >> d;
		rep(j, d){
			int b;
			cin >> b;
			snuke.at(b-1)++;
		}
	}

	int ans = 0;
	rep(i, n){
		if(snuke.at(i) == 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624