akhauriyash/Code-Regression huggingface dataset:
//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using ll = long long;
#define all(v) ((v).begin()),((v).end())
#define allr(v)	     ((v).rbegin()), ((v).rend())
#define sz(v) ((int)(v).size())
#define clr(v, d)        memset(v, d, sizeof(v))
const double PI = acos(-1.0);
template<class Int> Int __gcd(Int a, Int b) { return (b == 0 ? abs(a) : __gcd(b, a % b)); }
int dx[] = { 0,0,-1,1 };
int dy[] = { -1,1,0,0 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
}
const int N = 300 + 10;
vector<int>v;
map<pair<int, ll>, bool>mp;
bool solve(int idx, ll m) {
	if (idx == sz(v))
		return m == 0;
	//cout << idx << endl;
	if (mp.count({ idx,m }))
		return mp[{idx, m}];
	int ret = solve(idx + 1, m);
	ret |= solve(idx + 1, m + v[idx]);
	ret |= solve(idx + 1, m -= v[idx]);
	return mp[{idx, m}] = ret;
}
char arr[N][N];
int ans[N][N];
int n, m, k;
bool valid(int x, int y) {
	return x >= 0 && y >= 0 && x < n && y < m;
}
int main() {
	//cout << setprecision(4) << fixed;
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//file();
	//freopen("pocnitoare.in", "r", stdin);
	//freopen("pocnitoare.out", "w", stdout);
	//

	cin >> n >> m >> k;
	vector<pair<int, int>>v;
	for(int i=0;i<n;i++)
		for (int j = 0; j < m; j++)
		{
			cin >> arr[i][j];
			if (arr[i][j] == '#')
				v.push_back({ i,j });
		}
	int idx = 1;
	sort(all(v));
	for (int i = 0; i < k; i++) {
		int x = v[i].first, y = v[i].second;
		arr[x][y] = '.';
		ans[x][y] = idx;
		x++;
		while (valid(x, y) && !ans[x][y] && arr[x][y] != '#')
			ans[x][y] = idx, x++;
		x = v[i].first - 1, y = v[i].second;
		while (valid(x, y) && !ans[x][y]&&arr[x][y]!='#')
			ans[x][y] = idx, x--;
		
		idx++;
	}
	for(int i=0;i<n;i++)
		for (int j = 1; j < m; j++) {
			if (!ans[i][j])
				ans[i][j] = ans[i][j - 1];
		}
	for (int i = 0; i < n; i++) {
		for (int j = m - 2; j >= 0; j--)
			if (!ans[i][j])
				ans[i][j] = ans[i][j + 1];
	}

	for (int i = 1; i < n; i++)
		for (int j = 0; j < m; j++) {
			if (!ans[i][j])
				ans[i][j] = ans[i-1][j];
		}
	for (int i = 0; i < m; i++) {
		for (int j = n - 2; j >= 0; j--)
			if (!ans[j][i])
				ans[j][i] = ans[j+1][i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)
			cout << ans[i][j]<<' ';
		cout << endl;
	}
}

Measured memory_bytes: 2036
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int a,b,c, k;
    cin >> a >> b >> c >> k;

    while(k>0 && a >= b) k--,b*=2;
    while(k>0 && b >= c) k--,c*=2;

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

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

int main()
{
  string ss, t;
  cin >> ss >> t;
  int i, j;
  bool flag = true;
  int locate = -1;
  for(i = ss.length() - t.length(); i >= 0; i--)
  {
    for(j = 0; j < t.length(); j++)
    {
      if(ss.at(i+j) != '?' && ss.at(i+j) != t.at(j))
      {
        flag = false;
        break;
      }
    }
    if(flag == true)
    {
      locate = i;
      break;
    }
    flag = true;
  }
  if(locate < 0)
  {
    cout << "UNRESTORABLE" << endl;
  }
  else
  {
    for(i = 0; i < ss.length(); i++)
    {
      if(ss.at(i) == '?')
      {
        if(i >= locate && i < locate + t.length())
        {
          cout << t.at(i-locate);
        }
        else
        {
          cout << 'a';
        }
      }
      else
      {
        cout << ss.at(i);
      }
    }
    cout << endl;
  }
} 

Measured memory_bytes: 256
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

count = 0

for i in range(N):
	tmp = 0
	for j in range(M):
		tmp += A[i][j] * B[j]
		
	if tmp + C > 0:
		count += 1

print(count)

Measured memory_bytes: 38256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#define ld long double
using namespace std;

int n;
ld x[1005], y[1005], X, Y, d, e, P = 0.1;

ld dist(ld a, ld b) {
	return a*a + b*b;
}
int main() {
	cin>>n;
	for (int i = 0; i < n; i++){
		cin>>x[i]>>y[i];
		X += x[i]; Y += y[i];
	}
	X /= n; 
	Y /= n;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
	cout<<setprecision(10)<<fixed<<sqrt(d)<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n; string s;
int main() {
  cin>>n>>s;
  int num=0, spree=0; char cur='@';
  for (int i=0; i<n; ++i) {
    if (s[i]!=cur) {
      if (spree>0) num++;
      cur=s[i]; spree=1;
    }
    else {spree++;}
  }
  if (spree>0) num++;
  cout<<num;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

const int CENTER = 165 * 80;
bool reach[81][81][2 * CENTER + 1];

int key(int diff) {
    return CENTER + diff;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int H, W;
    cin >> H >> W;
    VEC(VEC(int)) A(H, VEC(int)(W));
    VEC(VEC(int)) B(H, VEC(int)(W));
    for(VEC(int)& row : A)
        READVEC(row);
    for(VEC(int)& row : B)
        READVEC(row);

    memset(reach, false, sizeof reach);
    reach[0][0][key(A[0][0] - B[0][0])] = reach[0][0][key(B[0][0] - A[0][0])] = true;
    FOR(i, 0, H)
        FOR(j, 0, W) {
            FOR(diff, -CENTER, CENTER + 1)
                if (reach[i][j][key(diff)]) {
                    if (i + 1 < H) {
                        int celldiff = A[i + 1][j] - B[i + 1][j];
                        reach[i + 1][j][key(diff + celldiff)] = true;
                        reach[i + 1][j][key(diff - celldiff)] = true;
                    }
                    if (j + 1 < W) {
                        int celldiff = A[i][j + 1] - B[i][j + 1];
                        reach[i][j + 1][key(diff + celldiff)] = true;
                        reach[i][j + 1][key(diff - celldiff)] = true;
                    }
                }
        }

    int ret = 1231232;
    FOR(diff, -CENTER, CENTER + 1)
        if (reach[H - 1][W - 1][key(diff)])
            ret = min(ret, abs(diff));
    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 169472
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let (h, w): (usize, usize) = read();
    let n: usize = read();
    let a: Vec<usize> = readnc();

    let mut positions: Vec<(usize, usize)> = vec![];
    for i in 0..h {
        if i % 2 == 0 {
            for j in 0..w {
                positions.push((i, j));
            }
        } else {
            for j in (0..w).rev() {
                positions.push((i, j));
            }
        }
    }

    let mut ans: Vec<Vec<usize>> = vec![vec![0; w]; h];
    let mut idx = 0;
    for i in 0..n {
        for j in 0..a[i] {
            let (y, x) = positions[idx];
            ans[y][x] = i+1;
            idx += 1
        }
    }

    for i in 0..h {
        for j in 0..w {
            if j >= 1 {
                print!(" ");
            }
            print!("{}", ans[i][j]);
        }
        println!();
    }
}

Measured memory_bytes: 4352
S = list(map(int, input()))

def reverse(i):
    return (i+1)%2

ans1 = 0
expect = S[0]
for s in S:
    if s != expect:
        ans1 += 1
    expect = reverse(expect)

ans2 = 0
expect = reverse(S[0])
for s in S:
    if s != expect:
        ans2 += 1
    expect = reverse(expect)


print(min(ans1, ans2))


Measured memory_bytes: 3956
# b.py
n,d = map(int,input().split())
lis = [list(map(int,input().split())) for x in range(n)]
ans = 0
for xli in range(n-1):
    for yli in range(xli,n):
        le = 0
        for x,y in zip(lis[xli],lis[yli]):
            le += (y-x) **2
        #print(xli,yli,'xli','yli')
        #print((le**0.5)//1,le**0.5,le**0.5==(le**0.5)//1 and xli != yli,'root')
        if le**0.5 == (le**0.5)//1 and xli != yli:
             ans += 1
print(ans)


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


int main()
{
	int k,x;
	cin>>k>>x;
	for(int i=-k+1;i<k;i++)
	{
		if(x+i>=-1000000 && x+i<=1000000)
			cout<<x+i<<' ';
	}
}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll h,w,d; cin >> h >> w >> d;
    vector<Pll> pos(h * w);
    rep(i,0,h)rep(j,0,w){
        ll a; cin >> a;
        a--;
        pos[a] = {i, j};
    }
    vector<ll> dp(h * w);
    rep(i,0,h*w){
        if(i - d < 0)continue;
        dp[i] = dp[i - d] + abs(pos[i].first - pos[i-d].first) + abs(pos[i].second - pos[i-d].second);
    }

    ll q; cin >> q;
    rep(i,0,q){
        ll l,r; cin >> l >> r;
        l--;r--;
        cout << dp[r] - dp[l] << "\n";
    }
}

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

int main(){
long long H,W,h,w;
cin>>H>>W>>h>>w;
long long matr[H][W];
long long num=(H/h)*(W/w)+1;
for(int i=0;i<H;i++){
	for(int j=0;j<W;j++)
	matr[i][j]=num;
}
if(H%h==0&&W%w==0)
cout<<"No"<<endl;
else{
	cout<<"Yes"<<endl;
	for(int i=h-1;i<H;i+=h){
		for(int j=w-1;j<W;j+=w){
			matr[i][j]=(-1)*(num*h*w-num)-1;
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++)
		cout<<matr[i][j]<<" ";
		cout<<endl;
	}
}
return 0;
}


Measured memory_bytes: 3968
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  ll h1,h2,m1,m2;

  cin >> h1>>m1>>h2>>m2>>k;
  
  ll tmp=h2*60+m2-(h1*60+m1);
  if (tmp<0)tmp+=24*60;
  ans=tmp-k;

  cout<<ans<<endl;
  return 0;
}
//23 0 2 0 120

Measured memory_bytes: 3592
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


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

	vector<vector<int>> ss(m);
	rep(i, m)
	{	
		int k;
		cin >> k;
		ss[i] = vector<int>(k);
		rep(j, k)
		{
			cin >> ss[i][j];
		}
	}

	vector<int> ps(m);
	rep(i, m)
	{
		cin >> ps[i];
	}

	int answer = 0;
	int c = pow(2, n);
	rep(i, c)
	{	//iの各ビットがスイッチのon/offに対応
		//各電球の条件をチェック
		bool flg = true;
		rep(j, m)
		{
			int count = 0;
			for (int s : ss[j])
			{
				//スイッチは1始まりなので0始まりに変換
				s--;
				//スイッチのon/offをチェック
				int bit = 1 << s;
				if ((i & bit) == bit) count++;
			}

			if (count % 2 != ps[j])
			{
				flg = false;
				break;
			}
		}

		//全部の電球が条件を満たしている場合にカウントアップ
		if (flg) answer++;
	}

	cout << answer << endl;

	return 0;
}

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

int num[101][101];

int main()
{
    int r, c;
    int rSum = 0;
    int cSum = 0;
    int totalSum = 0;
    
    cin >> r >> c;
    
    for (int i = 0; i < r; i++)
    {
        rSum = 0;
        for (int j = 0; j < c; j++)
        {
            cin >> num[i][j];
            rSum += num[i][j];
        }
        
        totalSum += rSum;
        num[i][c] = rSum;
    }
    
    for (int i = 0; i < c; i++)
    {
        cSum = 0;
        for (int j = 0; j < r; j++)
        {
            cSum += num[j][i];
        }
        
        num[r][i] = cSum;
    }
    
    num[r][c] = totalSum;
    
    for (int i = 0; i <= r; i++)
    {
        for (int j = 0; j <= c; j++)
        {
            if (j > 0)
            {
                cout << " ";
            }
            
            cout << num[i][j];
        }
        
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

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

  struct Item {
    int weight;
    int64_t value;
  };
  vector<Item> items(n, {0, 0});

  for (int i = 0; i < n; i++) {
    cin >> items[i].weight;
    cin >> items[i].value;
  }

  vector<Item > result;
  for (Item item: items) {
    const int limit = result.size();
    result.push_back(item);
    for (int i = 0; i < limit; i++) {
      int w = result[i].weight + item.weight;
      int64_t v = result[i].value + item.value;
      if (w > W) {
        break;
      }
      result.push_back({w, v});
    }

    // Sort the result:
    sort(result.begin(), result.end(), [](const Item& v1, const Item& v2) {return v1.weight < v2.weight;} );
    // Filter-out the sub-optimal results.
    int out = 1;
    for (int in = 1; in < result.size(); in++) {
      int prevIdx = out - 1;
      if (result[prevIdx].weight == result[in].weight) {
        result[prevIdx].value = max(result[prevIdx].value, result[in].value);
      } else if (result[prevIdx].value < result[in].value) {
        result[out++] = result[in];
      }
    }
    result.resize(out);
  }

  cout << result.back().value << endl;

  return 0;
}


Measured memory_bytes: 512
#At coder 2020/3/9 A
#import math
#import time
S=input()
#Q=int(input())

ans='No'
if len(S)%2==0:
    #print(len(S)/2)
    for ii in range(int(len(S)/2)):
        if S[2*ii]=='h' and S[2*ii+1]=='i':
            ans='Yes'
        else:
            ans='No'
            break

    
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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 snuke srand((unsigned)clock()+(unsigned)time(NULL));
#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 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;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

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

    int a=0;
    int b=0;
    rep(i,s.size()){
        int x = 0;
        if(s[i]=='1')x=1;
      if(i%2==x){
          a++;
      }else{
          b++;
      }  
    }
    cout << min(a,b) << endl;
    return 0;
}
 
 


Measured memory_bytes: 512
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int a=nextInt();
		int b=nextInt();
		for(int i=(int)(Math.ceil(25*a/2.0));2*i/25==a;i++)
		{
			if(i/10==b)
			{
				out.println(i);
				return;
			}
		}
		out.println(-1);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

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

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            //  var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            // int a = ab[0];
            //  int b = ab[1];
            //  Console.WriteLine("{0} {1}", a * b, a*2+b*2);
            int a = int.Parse(Console.ReadLine());
            int b = a / 3600;
            int c = a % 3600;
            Console.WriteLine("{0}:{1}:{2}",b,c/60,c%60);


        }
    }
}

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    rep(i,N){cin>>A.at(i);A.at(i)--;}
    vector<vector<int>> to(60,vector<int>(N));
    rep(i,N){to.at(0).at(i)=A.at(i);}
    rep(i,59){
        rep(j,N){
            to.at(i+1).at(j)=to.at(i).at(to.at(i).at(j));
        }
    }
    int v=0;
    rep(i,60){
        if(K>>i & 1){v=to.at(i).at(v);}
    }
    cout<<v+1<<endl;
}


Measured memory_bytes: 52628
/***
 *      __  __            _    _       _
 *     |  \/  |          | |  | |     | |
 *     | \  / |_ __      | |  | |_ __ | | ___ __   _____      ___ __
 *     | |\/| | '__|     | |  | | '_ \| |/ / '_ \ / _ \ \ /\ / / '_ \
 *     | |  | | |     _  | |__| | | | |   <| | | | (_) \ V  V /| | | |
 *     |_|  |_|_|    (_)  \____/|_| |_|_|\_\_| |_|\___/ \_/\_/ |_| |_|
 *
 *
***/
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
/*---------------for_stuff-------------------*/
#define f(i,a,b) for (int i=a;i<=b;i++)
#define f_(i,a,b) for (int i=a;i>=b;i--)
/*---------------pair_stuff------------------*/
#define MP make_pair
#define ii pair<int,int>
#define Iii pair<int,ii>
#define ill pair<int,ll>
#define lli pair<ll,int>
#define iiI pair<ii,int>
#define llll pair<ll,ll>
#define fi first
#define se second
/*--------------vector_stuff-----------------*/
#define pb push_back
#define ppb pop_back
/*--------------const_stuff-----------------*/
const ll mod=1000000007;
/*--------------map_stuff--------------------*/
// why do you think I should write something in this part? :v

int n,a[5][105],b[5][105],ans=INT_MIN;
int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	scanf("%d", &n);
	f(i,1,2) {
		f(j,1,n) {
			scanf("%d", &a[i][j]);
			b[i][j]=b[i][j-1]+a[i][j];
		}
	}
	f(i,1,n) 
		ans=max(ans,b[1][i]+b[2][n]-b[2][i-1]);
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif
string S;
int N;
ll ans;

void calc(vi& use) {
    stack<ll> st;
    string t = {S[0]};
    REP(i,N-1) {
        if (use[i]==1){
            //t += "+";
            st.push(stoll(t));
            t = S[i + 1];
        } else {
            t += S[i + 1];
        }
    }
    if (t != "") st.push(stoll(t));

    while(!st.empty()) {
        ans += st.top(); st.pop();
    }
}

void dfs(int n, vi& use) {
    if (n >= N - 1) {
        calc(use);
        return;
    }

    REP(i,2) { // 1:+, 0:nop
        use[n] = i;
        dfs(n + 1, use);
    }
}

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

    cin >> S;
    N = S.size();

    ans = 0;
    vi use(N - 1, 0);
    dfs(0, use);

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		vector<int> gs(n),ss(n);
		for(int i=0;i<n;i++){
			int m; cin>>m>>ss[i];
			for(int j=0;j<m;j++){
				int s,e; cin>>s>>e;
				gs[i]|=((1<<e)-(1<<s))>>6;
			}
		}
		vector<long long> dp(1<<16);
		for(int i=0;i<(1<<16);i++)
			for(int j=0;j<n;j++)
				if(!(i&gs[j]))
					dp[i|gs[j]]=max(dp[i|gs[j]],dp[i]+ss[j]);
		cout<<*max_element(begin(dp),end(dp))<<endl;
	}
}

Measured memory_bytes: 1704
// Isaunoya
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define rep(i , j , n) for(register int i = j ; i <= n ; i ++)
#define Rep(i , j , n) for(register int i = j ; i >= n ; i --)
#define to(u) for(register int i = head[u] ; i ; i = edge[i].nxt)

inline int read() { register int x = 0 , f = 1 ; register char c ;
#define gc c = getchar()
	while(isspace(gc)) ; c == '-' ? f = -1 , gc : 0 ;
	while(x = (x << 1) + (x << 3) + (c & 15) , isdigit(gc)) ;
	return x * f ;
}

using namespace std ;
int n , m , q ;
const int N = 2000 + 5 ;
const int M = 2000 + 5 ;
int a[N][M] ;
int sum[N][M] ;
int up[N][M] ;
int lft[N][M] ;
inline int getdigit() {
	register char c = getchar() ;
	while(! isdigit(c)) c = getchar() ;
	return (int)(c & 15) ;
}
inline int get1(int a , int b , int c , int d) {
	return sum[c][d] + sum[a - 1][b - 1] - sum[a - 1][d] - sum[c][b - 1] ;
}
inline int get2(int a , int b , int c , int d) {
	return up[c][d] + up[a - 1][b - 1] - up[a - 1][d] - up[c][b - 1] ;
}
inline int get3(int a , int b , int c , int d) {
	return lft[c][d] + lft[a - 1][b - 1] - lft[a - 1][d] - lft[c][b - 1] ;
}
signed main() {
	// freopen("wang.in" , "r" , stdin) ; freopen("wang.out" , "w" , stdout) ;
	n = read() ; m = read() ; q = read() ;
	for(register int i = 1 ; i <= n ; i ++)
		for(register int j = 1 ; j <= m ; j ++) a[i][j] = getdigit() ;
	for(register int i = 1 ; i <= n ; i ++)
		for(register int j = 1 ; j <= m ; j ++) {
			up[i][j] = up[i - 1][j] + up[i][j - 1] - up[i - 1][j - 1] + (a[i][j] & a[i - 1][j]) ;
			lft[i][j] = lft[i - 1][j] + lft[i][j - 1] - lft[i - 1][j - 1] + (a[i][j] & a[i][j - 1]) ;
		}
	for(register int i = 1 ; i <= n ; i ++)
		for(register int j = 1 ; j <= m ; j ++) sum[i][j] = a[i][j] + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] ;
	for( ; q -- ; ) {
		register int x1 = read() , y1 = read() ;
		register int x2 = read() , y2 = read() ;
		printf("%d\n" , get1(x1 , y1 , x2 , y2) - get2(x1 + 1, y1 , x2 , y2) - get3(x1 , y1 + 1 , x2 , y2)) ;
	}
	return 0 ;
}


Measured memory_bytes: 64640
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <stack>
typedef long long int llint;

int main(void){
  int a, b, c;
  std::cin >> a >> b >> c;
  if(a+b+c <=21) std::cout << "win" << std::endl;
  else           std::cout << "bust" << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

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

int main() {
	int n,a; cin >> n >> a;
	cout << n*n-a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int O = 0, I = 0, ans, x = s.size();
	for (int i = 0; i < x; i++) {
		if (s[i] == '0')O++;
		else I++;
	}
	if (O <= I)ans = O;
	else ans = I;
	cout << ans * 2 << endl;
	return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 20:55:33 2020

@author: Kanaru Sato
"""

k = int(input())
a,b = list(map(int,input().split()))
flag = 0

for i in range(a,b+1):
    if i%k == 0:
        print("OK")
        flag = 1
        break

if flag == 0:
    print("NG")

Measured memory_bytes: 9176
n = int(input())
c = [0] * n
s = [0] * n
f = [0] * n
for i in range(n - 1):
    c[i], s[i], f[i] = map(int, input().split())

ans = [0] * n
for i in range(n - 1):
    for j in range(i, n - 1):
        if ans[i] < s[j]:
            ans[i] = s[j]
        elif ans[i] % f[j] > 0:
            ans[i] += f[j] - ans[i] % f[j]
        ans[i] += c[j]

for i in range(n):
    print(ans[i])

Measured memory_bytes: 9036
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}


using namespace std;

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

ll combination(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

int main(int argc, char *argv[]) {
    ll result = 0;
    ll N;
    cin >> N;
    vector<string> s(N);
    rep(i, N){
        cin >> s[i];
    }
    rep(i, N){
        sort(ALL(s[i]));
    }
    sort(ALL(s));
    string search = s[0];
    ll count = 1;
    For(i, 1, N){
        if(search == s[i]){
            count ++;
        }else{
            search = s[i];
            if(count != 1){
                result += combination(count, 2);
                
                count = 1;
            }
        }
    }
    if(count != 1){
        result += combination(count, 2);
    }
    
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define dump(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  float N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) cin >> A[i];

  float tmp = (N - 1) / (K - 1);
  // dump(tmp);
  cout << ceil(tmp) << endl;
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 1e6+9;

void solve() {
    int a, b, n, k;
    string s;
    cin>>k>>s;
    for(int i=0;i<s.size() && i<k;++i) {
        cout<<s[i];
    }
    if(s.size() > k) cout<<"...";
}
int main() {
    ios_base::sync_with_stdio(0);
    int T=1 ,cas=0;
    while(T--) {
        solve();
    }
    return 0;
}

// ll, reset, 1, bottom

Measured memory_bytes: 3592
#include<stdio.h>
int main(){
  int i;
  int x[100000];
  
  for (i = 0;; i++) {
    scanf ("%d", &x[i]);
    if (x[i] == 0) {
      break;
    }
  }

  for (i = 0; x[i] != 0; i++) {
    printf ("Case %d: %d\n", i + 1, x[i]);
  }
  
  return 0;
}


Measured memory_bytes: 1992
#include<iostream>
#include<stdio.h>
#include<vector>
#include<queue>
#define MAX 100000
using namespace std;
int d[MAX];

int n;
vector <int> M[MAX];


int tail;



void BFS(int s,int t) {
	queue <int>Q;
	Q.push(s);
	d[s] = t;
	while (!Q.empty()) {
		s = Q.front();
		Q.pop();
		for (int j = 0; j < M[s].size(); j++) {
				
				if (d[M[s][j]] == -1) {
					d[M[s][j]] = t;
					Q.push(M[s][j]);
				}
		}

	}
}


int main() {
	int  m, s, t, q;
	scanf("%d %d", &n, &m);

	for (int i = 0; i < m; i++) {
		scanf("%d %d", &s, &t);
		M[s].push_back(t);
		M[t].push_back(s);
	}

	for (int i = 0; i < n; i++) {
		d[i] = -1;
	}
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (d[i] == -1) {
			count++;
			BFS(i, count);
		}
	}
	cin >>q;
	for (int i = 0; i < q; i++) {
		int s2, t2;
		scanf("%d %d", &s2, &t2);
		if (d[s2] == d[t2]) {
			printf("yes\n");
		}
		else {
			printf("no\n");
		}
		
		
	}
	
	return 0;
}


Measured memory_bytes: 9024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

class mod {
public:
    mod() {m_n = 0;}
    mod(ll n) {if (n >= 0) m_n = n % MOD; else m_n = n % MOD + MOD;}
    friend bool operator== (const mod& a, const mod& b) {return a.m_n == b.m_n;}
    friend bool operator!= (const mod& a, const mod& b) {return !(a == b);}
    friend mod operator+ (const mod& a, const mod& b) {return (a.m_n + b.m_n) % MOD;}
    friend mod& operator+= (mod& a, const mod& b) {return a = a + b;}
    friend mod operator- (const mod& a) {return -a.m_n;}
    friend mod operator- (const mod& a, const mod& b) {return (a.m_n + (-b.m_n)) % MOD;}
    friend mod& operator-= (mod& a, const mod& b) {return a = a - b;}
    friend mod operator* (const mod& a, const mod& b) {return (a.m_n * b.m_n) % MOD;}
    friend mod& operator*= (mod& a, const mod& b) {return a = a * b;}
    friend mod mod_pow(const mod& n, ll r) {
        if (r == 0) {
            return 1;
        } else if (r < 0) {
            return mod_pow(n, (MOD - 2) * (-r));
        } else if (r % 2 == 0) {
            mod tmp = mod_pow(n, r / 2);
            return tmp * tmp;
        } else {
            return n * mod_pow(n, r - 1);
        }
    }
    friend mod operator/ (const mod& a, const mod& b) {return a * mod_pow(b, -1);}
    friend mod& operator/= (mod& a, const mod& b) {return a = a / b;}
    friend ostream& operator<< (ostream& os, const mod& n) {os << n.m_n; return os;}
    friend istream& operator>> (istream& is, mod& n) {ll tmp; is >> tmp; n = mod(tmp); return is;}
private:
    ll m_n;
};

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> S(N), T(M);
    for (int n = 0; n < N; ++n) cin >> S[n];
    for (int m = 0; m < M; ++m) cin >> T[m];
    vector<vector<mod>> DP(N+1, vector<mod>(M+1));
    
    DP[0] = vector<mod>(M+1, 1);
    for (int n = 0; n < N; ++n) {
        DP[n+1][0] = 1;
        for (int m = 0; m < M; ++m) {
            DP[n+1][m+1] = DP[n][m+1]+DP[n+1][m];
            if (S[n] != T[m]) DP[n+1][m+1] -= DP[n][m];
        }
    }
    cout << DP[N][M] << endl;

    return 0;
}


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

using namespace std;

#define foorp(i , a , n) for (int (i) = (a); (i) < (n); (i)++)
#define foorm(i , a , n) for (int (i) = (a); (i) > (n); (i)--)
#define ll long long int

int ii;
string s;

int main()
{
    cin >> s;
    for (int i = 0; i < (int)s.size() - 1; i++)
    {
        if (s[i] == 'S' && s[i + 1] == 'T')
        {
            s.erase(s.begin() + i);
            s.erase(s.begin() + i);
            i -= 2;
        }
    }
    cout << s.size() << endl;
    return 0;
}



Measured memory_bytes: 640
"bit全探索"

def PadZero(bit, size)
  n = size - bit.size
  n.times do
    bit = '0' + bit
  end
  bit
end

def GetExpr(bit, num)
  num = num.split('')
  str = num[0]
  1.upto(bit.size) do |i|
    if bit[i]=='0'
      str = str + num[i]
    elsif bit[i]=='1'
      str = str + '+' + num[i]
    end
  end
  str
end

S = gets.chomp
ans = 0
bit = nil
tmp = []
(2**(S.size-1)).times do |i|
  bit = PadZero(i.to_s(2), S.size)
  ans = ans + GetExpr(bit, S).split('+').map(&:to_i).inject(:+)
end
puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int x[100000];
int y[100000];
int black[2001][2001];
int white[2001][2001];
char c[100000];

int Square(int x1,int y1,int x2,int y2,bool B)
{
	int ret=0;
	int a,b,c;
	if(B==true)
	{
		if(y1>0)
		{
			a = black[x2][y1-1];
		}else{
			a=0;
		}
		if(x1>0)
		{
			b=black[x1-1][y2];
		}else{
			b=0;
		}
		if(y1>0&&x1>0)
		{
			c=black[x1-1][y1-1];
		}else{
			c=0;
		}
		ret = black[x2][y2]-a-b+c;
	}else{
		if(y1>0)
		{
			a = white[x2][y1-1];
		}else{
			a=0;
		}
		if(x1>0)
		{
			b=white[x1-1][y2];
		}else{
			b=0;
		}
		if(y1>0&&x1>0)
		{
			c=white[x1-1][y1-1];
		}else{
			c=0;
		}
		ret = white[x2][y2]-a-b+c;
	}
	return ret;
}

int main()
{
	int n,k;
	int M=0;
	int cnt=0;
	int xl,xr,yd,yu;
	
	cin>>n>>k;
	for(int i=0;i<2001;i++)
	{
		for(int j=0;j<2001;j++)
		{
			black[i][j]=0;
			white[i][j]=0;
		}
	}
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i]>>c[i];
		x[i]%=(2*k);
		y[i]%=(2*k);
		if(c[i]=='B')
		{
			black[x[i]][y[i]]++;
		}else if(c[i]=='W'){
			white[x[i]][y[i]]++;
		}
	}
	//x方向の累積和
	for(int i=0;i<2*k;i++)
	{
		for(int j=1;j<2*k;j++)
		{
			black[j][i]=black[j][i]+black[j-1][i];
			white[j][i]=white[j][i]+white[j-1][i];
		}
	}
	//y方向の累積和
	for(int j=0;j<2*k;j++)
	{
		for(int i=1;i<2*k;i++)
		{
			black[j][i]=black[j][i]+black[j][i-1];
			white[j][i]=white[j][i]+white[j][i-1];
		}
	}
	//累積和チェック
	/*
	for(int j=0;j<2*k;j++)
	{
		for(int i=0;i<2*k;i++)
		{
			cerr<<black[i][j]<<" ";
		}
		cerr<<endl;
	}*/
	//x
	for(xl=0;xl<k;xl++)
	{
		//y
		for(yd=0;yd<k;yd++)
		{
			cnt=0;
			//初期位置白
			//白の数え上げ
			cnt += Square(xl,yd,xl+k-1,yd+k-1,false)+Square(xl+k,yd+k,2*k-1,2*k-1,false);
			if(xl>0)
			{
				cnt += Square(0,yd+k,xl-1,2*k-1,false);
			}
			if(yd>0)
			{
				cnt += Square(xl+k,0,2*k-1,yd-1,false);
			}
			if(xl>0&&yd>0)
			{
				cnt += Square(0,0,xl-1,yd-1,false);
			}
			//黒の数え上げ
			cnt += Square(xl+k,yd,2*k-1,yd+k-1,true)+Square(xl,yd+k,xl+k-1,2*k-1,true);
			if(xl>0)
			{
				cnt += Square(0,yd,xl-1,yd+k-1,true);
			}
			if(yd>0)
			{
				cnt += Square(xl,0,xl+k-1,yd-1,true);
			}
			//cerr<<"("<<xl<<","<<yd<<") ... "<<cnt<<endl;
			if(M<cnt)
			{
				M=cnt;
			}
			//初期位置黒
			cnt = n-cnt;
			if(M<cnt)
			{
				M=cnt;
			}
		}
	}
	cout<<M<<endl;
	return 0;
}

Measured memory_bytes: 32384
import java.io.*;
public class Main {
		public static void main(String[] arg) throws IOException {
			InputStreamReader is = new InputStreamReader(System.in); 
	        BufferedReader br = new BufferedReader(is);
			String str = br.readLine();
			String[] spl = str.split(" ");
			int first = 0;
			int second = 1;
			int thrid = 2;
			if(Integer.parseInt(spl[0]) < Integer.parseInt(spl[1])){
				if(Integer.parseInt(spl[1]) < Integer.parseInt(spl[2])){
					System.out.println(spl[0]+" "+spl[1]+" "+spl[2]);
				}else if(Integer.parseInt(spl[0]) < Integer.parseInt(spl[2])){
					System.out.println(spl[0]+" "+spl[2]+" "+spl[1]);
				}else{
					System.out.println(spl[2]+" "+spl[0]+" "+spl[1]);
				}
			}else if(Integer.parseInt(spl[0]) < Integer.parseInt(spl[2])){
				System.out.println(spl[1]+" "+spl[0]+" "+spl[2]);
			}else if(Integer.parseInt(spl[1]) < Integer.parseInt(spl[2])){
				System.out.println(spl[1]+" "+spl[2]+" "+spl[0]);
			}else{
				System.out.println(spl[2]+" "+spl[1]+" "+spl[0]);
			}
	}

}

Measured memory_bytes: 24472
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
      
      int x1 = in.nextInt();
      int x2 = in.nextInt();
      int x3 = in.nextInt();
      int x4 = in.nextInt();
      int x5 = in.nextInt();
      
      if(x1==0){
        System.out.println("1");
      }else if(x2==0){
        System.out.println("2");
      }else if(x3==0){
        System.out.println("3");
      }else if(x4==0){
        System.out.println("4");
      }else if(x5==0){
        System.out.println("5");
      }
      
    }
}
      

Measured memory_bytes: 27024
N, M = map(int, input().split())
G = []
for i in range(M):
    G.append(list(map(int, input().split())))
tG = list(zip(*G))
A = max(tG[0])
B = min(tG[1])

ans = B - A + 1
if ans < 0:
    print(0)
else:
    print(ans)


Measured memory_bytes: 36048
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int gcd(int m,int n){if(m%n==0)return n;return gcd(n,m%n);}
int main()
{
	int n,x;cin>>n>>x;
	int a[100010]={0};
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		a[i]-=x;
	}
	int g=a[0];
	for(int i=1;i<n;i++)
	{
		g=gcd(g,a[i]);
	}
	cout<<abs(g)<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int X = scanner.nextInt();
    int Y = scanner.nextInt();
    int Z = scanner.nextInt();
    
    int x = X;
    int y = Y;
    int z = Z;
    
    Y = x;
    Z = y;
    X = z;
    
    System.out.println(X+" "+Y+" "+Z);
  }
}

    

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
#include <numeric>
#include "math.h"
using namespace std;

#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for (long long i=(b)-1;i>=(a);i--)
#define REP(i,n) for (long long i=0;i<(n);i++)
#define RREP(i,n) for (long long i=(n)-1;i>=0;i--)

#define inf long long_MAX/3
#define INF long long_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<long long,long long>
#define pii pair<long long,long long>
#define pcc pair<char,char>
#define pic pair<long long,char>
#define pci pair<char,long long>
#define VS vector<string>
#define VI vector<long long>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out prlong longf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

vector <pair <ll,ll> > a;
int n;
int main(){

	cin >> n;
	a.resize(n);
	REP(i,n){
		cin >>a[i].second;
		cin >>a[i].first;
	}
	sort(a.begin(),a.end());
	ll sum = 0;
	REP(i,n){
		sum += a[i].second;
		if (sum > a[i].first){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


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

int main() {
    int N, Y,as = -1,bs = -1,cs = -1;
    cin >> N >> Y;

    //if (Y%1000 != 0 || Y > 10000*N){
    //    cout << -1 << -1 << -1 << endl;
    //}
    //else
    //{
        for (int a = 0; a <= N; a++){
            for (int b = 0; b <= N - a; b++){
                if (Y - 10000 * a - b * 5000 == 1000*(N-a-b)){
                    as = a;
                    bs = b;
                    cs = N - a - b;
                }
            }
        }
    //}
    cout << as << " " << bs << " " << cs << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N; cin >> N;
	ll a[2][100] = {};
	rep(i, 0, 2)rep(j, 0, N)cin >> a[i][j];

	ll maxsum = 0;
	rep(i, 0, N) {
		ll sum = 0;
		repe(x, 0, i)sum += a[0][x];
		rep(y, i, N)sum += a[1][y];

		if (maxsum < sum) {
			maxsum = sum;
		}
	}
	cout << maxsum << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> takoyaki(N);
    for (int i = 0; i < N; i++) cin >> takoyaki[i];
    int sum;
    for (int i = 0; i < N-1; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            sum += takoyaki[i]*takoyaki[j];
        }
        
    }
    
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
N,*ls=$<.read.split.map(&:to_i)

ls = ls.sort

ret = 0

0.upto(N-3) do |i|
  (i+1).upto(N-2) do |j|
    t =ls[i]+ls[j]
    idx = ls[j+1..-1].bsearch_index{|x| t<=x}
    ret += idx ? idx : N-1-j
    # p [i,j,idx,ls[i]+ls[j],ls[j+1..-1],ret]
  end
end

p ret


Measured memory_bytes: 1912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = ReadIntArray();
            var n = nums[0];
            var k = nums[1];
            var q = nums[2];

            var points = new int[n];
            for (int i = 0; i < n; i++)
            {
                points[i] = k - q;
            }
            for (int i = 0; i < q; i++)
            {
                var num = ReadInt();
                points[num - 1]++;
            }


            for (int i = 0; i < n; i++)
            {
                if (points[i] > 0)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }

        public static string ReadString()
        {
            return Console.ReadLine();
        }

        public static string[] ReadStringArray()
        {
            return ReadString().Split(' ');
        }

        public static int[] ReadIntArray()
        {
            return ReadStringArray().Select(x => int.Parse(x)).ToArray();
            
        }

        public static int ReadInt()
        {
            return int.Parse(ReadString());
        }
    }
}


Measured memory_bytes: 17888
#include<iostream>
using namespace std;
int main()
{
	int ans=1,n,k,i;
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		if(ans>k)
		{
			ans=ans+k;
		}
		if(ans<=k)
		{
			ans=ans+ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))

L = []
R = []
for i in range(M):
    L1,R1=[int(i) for i in input().split()]
    L.append(L1)
    R.append(R1)
lmax = max(L)
rmin = min(R)
if rmin >= lmax:
    print (rmin-lmax+1)
else:
    print(0)

Measured memory_bytes: 11052