akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{

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

	void run() {
		
		Scanner sc=new Scanner(System.in);
		
		String str=sc.next();
		
		int gyoukan=str.length()-1;
		
		
		long ans=0;
		
		for(int bit=0;bit<(1<<gyoukan);bit++) {
			
			long sum=0;
			long a=str.charAt(0)-'0';
			
			
			for(int pointer=0;pointer<gyoukan;pointer++) {
				
				//○桁目にビットが立ってるかどうか。
				if((bit>>pointer)%2==1) {
					
					sum+=a;
					a=0;
					
				}
				
				a=a*10+(str.charAt(pointer+1)-'0');
				
			}
			
			sum+=a;
			
			ans+=sum;
			
		}

		System.out.println(ans);
		

	}




}





Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
#define REP2(i, m, n) for (ll(i) = (ll)(n)-1; i >= (ll)(m); --i)
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<ll, ll> pll;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
const int MOD = 1000000007;
// constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> inline void print(T x) { cout << x << '\n'; }
template <class T> bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)
// vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(w + 1, vector<int>(k+1, 0)));


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
	cin >> n;
	vector<ll> l(n);
	rep(i,n) {
        cin >> l[i];
    } 
	sort(all(l));
	ll res = 0;
	rep(i,n-2){
		for(ll j = i+1; j < n-1; ++j){
			ll idx = lower_bound(l.begin(), l.end(), l[i]+l[j]) - l.begin();
			res += (ll)(idx - j - 1);
		}
	}
    print(res);

    return 0;
}


Measured memory_bytes: 3680
function Main(input){
	var xs = input.trim().split(' ');
    if(xs[0]==xs[1]){
    console.log("=");
    }else if(xs[0]<xs[1]){
    console.log("<");
    }else if(xs[0]>xs[1]){
    console.log(">");
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

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

using namespace std;

int main()
{
  vector<pair<int,int>> price;

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

    price.push_back(make_pair(a,b));
  }  

  int sabc;
  for(pair<int,int> e : price){
    if(e.first == 1){
      sabc = 6000 * e.second;
    }
    else if(e.first == 2){
      sabc = 4000 * e.second;
    }
    else if(e.first == 3){
      sabc = 3000 * e.second;
    }
    else if(e.first == 4){
      sabc = 2000 * e.second;
    }
    cout<<sabc<<endl;
  }

  return 0;
}


Measured memory_bytes: 3076
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n, l, r;
  vector<int> vecL, vecR;
  
  scanf("%d", &n);

  for(int i=0;i<n;i++){
    scanf("%d%d", &l, &r);
    vecL.push_back(l);
    vecR.push_back(r);
  }

  sort(vecL.begin(), vecL.end(), greater<int>());
  sort(vecR.begin(), vecR.end());

  ll ans1 = 0, ans2 = 0;
  ll pos1 = 0, pos2 = 0;
  
  for(int i=0;i<n;i++){
    if(pos1 >= vecL[i]) break;
    ans1 += vecL[i] - pos1;
    pos1 = vecL[i];

    if(vecR[i] >= pos1) break;
    ans1 += pos1 - vecR[i];
    pos1 = vecR[i];
  }

  for(int i=0;i<n;i++){
    if(vecR[i] >= pos2) break;
    ans2 += pos2 - vecR[i];
    pos2 = vecR[i];
    
    if(pos2 >= vecL[i]) break;
    ans2 += vecL[i] - pos2;
    pos2 = vecL[i];
  }

  cout << max(ans1 + abs(pos1), ans2 + abs(pos2)) << endl;
  
  
  return 0;
}


Measured memory_bytes: 1276
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    a,b,c = inputMap()
    
    tmp = []
    tmp.append(a)
    tmp.append(b)
    tmp.append(c)
    tmp.sort()
    
    print(tmp[0] + tmp[1])
        
if __name__ == "__main__":
	main()


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

const int MAX = 1e6 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> a(n);
	vector <int> vis(MAX, -1);
	vector <int> cnt(MAX);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		++cnt[a[i]];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		if (vis[a[i]] == -1) {
			for (int j = 2 * a[i]; j < MAX; j += a[i]) {
				vis[j] = 2;
			}
			vis[a[i]] = 1;
		}
	}
	int ans  = 0;
	for (int i = 0; i < MAX; i++) {
		if (vis[i] == 1) {
			ans += cnt[i] == 1;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 11892
#include<stdio.h>
int main()
{
	int N,K,a,sum;
	scanf("%d %d",&N,&K);
	sum=K;
	for(a=2;a<=N;a++)
	{
		sum=sum*(K-1);
	}
	printf("%d\n",sum);
	return 0;
 } 

Measured memory_bytes: 128
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def get_pattern1(H, W):
    if W%3 == 0:
        return 0
    else:
        return (H * (W/3 + 1) - H * (W/3))

def get_pattern2(H, W):
    min_S = sys.maxint
    for x in range(1, W):
        a = H * x
        b = (W - x) * (H/2)
        c = (W - x) * ((H/2) + (H %2))
        S = max(a,b,c) - min(a,b,c)
        if S < min_S:
            min_S = S
    return min_S



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W] =  [long(input_raw[0]), long(input_raw[1])]
    s1 = get_pattern1(H, W)
    s2 = get_pattern2(H, W)
    s3 = get_pattern1(W, H)
    s4 = get_pattern2(W, H)
    print min(s1,s2,s3,s4)

if __name__ == '__main__':
    main()

Measured memory_bytes: 6112
#include<stdio.h>
//#include<math.h>
int main ()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if((a+b)%2==0)
    {
        printf("%d\n",(a+b)/2);
    }
    else printf("IMPOSSIBLE\n");

    return 0;
}


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = 1;
    fact[1] = 1;
    for(int i=2; i<=num; i++){
        fact[i] = fact[i-1] * i % MOD;
    }
}

void create_seq_inv_mod(int num){
    seq_inv[0] = 1;
    seq_inv[1] = 1;
    for(int i=2; i<=num; i++){
        seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
    }
}

void create_fact_inv_mod(int num){
    fact_inv[0] = 1;
    fact_inv[1] = 1;
    for(int i=2; i<=num; i++){
        fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
    }
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int N, K;
vector<int> edges[100000];

int64_t dp[100000];

int64_t ans;
void dfs(int i, int p){
    int ng = 1 + (i!=0);
    int child = edges[i].size() - (i!=0);
    mul(ans, perm_mod(K-ng, child));
    for(int j : edges[i]) if(j != p) dfs(j, i);
}

int main(){
    cin >> N >> K;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }
    for(int i=0; i<N; i++) if(edges[i].size()+1 > K){
        cout << 0 << endl;
        return 0;
    }

    create_mod_tables(100000);
    ans = K;
    dfs(0, -1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11648
#include <stdio.h>
#define N 100
#define INFTY 1990000000
#define min(a, b) ((a) < (b) ? (a) : (b))

int main(){
  int n, P[N + 1], m[N + 1][N + 1], l, i, j, k;
  
  scanf("%d", &n);
  for(i = 1; i <= n; i++) scanf("%d %d", &P[i - 1], &P[i]);

  for(i = 1; i <= n; i++) m[i][i] = 0;
  
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l -1;
      m[i][j] = INFTY;
      for(k = i; k <= j - 1; k++){
	m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + P[i - 1] * P[k] * P[j]);
	//if(m[i][j] < m[i][k] + m[k + 1][j] + P[i - 1] * P[k] * P[j]) m[i][j] = m[i][j];
	//else m[i][j] = m[i][k] + m[k + 1][j] + P[i - 1] * P[k] * P[j];
      }
    }
  }
  printf("%d\n", m[1][n]);
  
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  string S; cin >>S;
  string check[4]={"dream","dreamer","erase","eraser"};
  reverse(S.begin(),S.end());
  rep(i,0,4) {
    reverse(check[i].begin(),check[i].end());
  }
  int cur=0;
  while (cur<(int)S.size()) {
    bool flag=false;
    rep(i,0,4) {
      int find_pos=S.find(check[i],cur);
      if (cur==find_pos) {
        flag=true;
        cur=find_pos+check[i].size();
        break;
      }
    }
    if (!flag) {cout <<"NO" <<endl; return 0;}
  }
  cout <<"YES" <<endl;
  return 0;
}


Measured memory_bytes: 512
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
  
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll n, ans = 0;
    cin >> n;
    ll res[n+1] = {0};
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= n; j++)
        {
            if(i*i + j*j + 1 + i*j + j + i > n)
                break;
            for(ll k = 1; k <= n; k++)
            {
                ll curr = i*i + j*j + k*k + i*j + j*k + k*i;
                if(curr > n)
                    break;
                else 
                    res[curr]++;
            }
        }
    }
    for(ll i = 1; i <= n; i++)
        cout << res[i] << '\n';

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3640
n = int(input())
t,a = map(int,input().split())
lih = list(map(int,input().split()))

lians = [0]*n
for i in range(n):
  lians[i] = [abs(t - 0.006*lih[i] - a),i+1]
lians = sorted(lians)
print(lians[0][1])

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int cnt[100005];
int main(){
	int a,n;
	cin>>n;
	int i;
	int unq = 0;
	for(i=1;i<=n;i++){
		cin>>a;
		if(cnt[a]==0)
		  {
		  	 unq++;
		  	 cnt[a]=1;
		  }
	}
	if((n-unq)%2==0)
	  cout<<unq;
	else
	  cout<<unq-1;
	return 0;
}

Measured memory_bytes: 640
long long n[100][21];a[100],i,j;main(N){
for(scanf("%d",&N);i<N;i++)scanf("%d",a+i);
for(n[0][a[0]]=i=1;i<N-1;i++)for(j=0;j<=20;j++){0<=j-a[i]&&(n[i][j-a[i]]+=n[i-1][j]);j+a[i]<=20&&(n[i][j+a[i]]+=n[i-1][j]);}
printf("%lld\n",n[N-2][a[N-1]]);exit(0);}

Measured memory_bytes: 616
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int main() {
	int n; std::cin >> n;
	std::vector<int> from_numbers(n), to_numbers(n); for (auto& a : from_numbers) std::cin >> a; for (auto& b : to_numbers) std::cin >> b;
	auto comparator = [](const std::pair<int, int>& a, const std::pair<int, int>& b) {return a.first < b.first; };
	std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, decltype(comparator)> queue(comparator);
	for (auto i = 0; i < n; ++i) {
		if (to_numbers[i] != from_numbers[i]) queue.emplace(to_numbers[i], i);
	}
	long long int count = 0LL;
	while (!queue.empty()) {
		auto front = queue.top();
		if (to_numbers[front.second] > std::max({ to_numbers[(front.second + 1) % n] + to_numbers[(front.second + n - 1) % n], from_numbers[front.second] })) {
			if (to_numbers[(front.second + 1) % n] + to_numbers[(front.second + n - 1) % n] > from_numbers[front.second]) {
				queue.pop();
				count += to_numbers[front.second] / (to_numbers[(front.second + 1) % n] + to_numbers[(front.second + n - 1) % n]);
				to_numbers[front.second] %= to_numbers[(front.second + 1) % n] + to_numbers[(front.second + n - 1) % n];
				if (to_numbers[front.second] != from_numbers[front.second]) queue.emplace(to_numbers[front.second], front.second);
			}
			else if ((to_numbers[front.second] - from_numbers[front.second]) % (to_numbers[(front.second + 1) % n] + to_numbers[(front.second + n - 1) % n]) == 0) {
				queue.pop();
				count += (to_numbers[front.second] - from_numbers[front.second]) / (to_numbers[(front.second + 1) % n] + to_numbers[(front.second + n - 1) % n]);
				to_numbers[front.second] = from_numbers[front.second];
			}
			else {
				break;
			}
		}
		else {
			break;
		}
	}
	if (queue.empty()) std::cout << count << std::endl;
	else std::cout << -1 << std::endl;
}


Measured memory_bytes: 3956
from functools import reduce

# 入力
L = input()

MOD = 10**9 + 7


# 最上位ビットから順に、0にする場合と1にする場合の個数を求める
# 最上位ビットが0の場合、直ちに解が求められる（3のべき乗になる）ことに注意
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(
                pow(self.x, other.x, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    def __radd__(self, other):
        return ModInt(other + self.x)

    def __rsub__(self, other):
        return ModInt(other - self.x)

    def __rmul__(self, other):
        return ModInt(other * self.x)

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rpow__(self, other):
        return ModInt(pow(other, self.x, MOD))


ans = reduce(
    lambda acc, t:
        ModInt(3)**t[0] + 2 * acc if t[1] == '1' else
        acc,
    enumerate(reversed(L)),
    ModInt(1)
)

# 出力
print(ans)


Measured memory_bytes: 3804
package main

import (
	"fmt"
)

func main() {
	var a,b int
	fmt.Scan(&a,&b)

	count := 0
	for i := 0; i < 2; i++ {
		if a > b {
			count += a
			a--
		} else {
			count += b
			b--
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define dump(x)  cerr << #x << " = " << (x) << endl;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

 

//ここから書き始める
int main(int argc, char const *argv[])
{
	int H,W;
	cin >> H >> W;
	int a[H][W];
	queue<PII> que;
	int count = 0;

	REP(i, H)
	{
		REP(j, W)
		{
			cin >> a[i][j];
		}
	}


	//本処理
	REP(i, W*H)	
	{
		int retu_mae = i % W;
		int gyo_mae = i / W;

		if(gyo_mae % 2 == 1) //奇数行のとき
		{
			retu_mae = W - 1 - retu_mae;
			int retu_ato = (retu_mae == 0? 0 : retu_mae - 1);
			int gyo_ato = (retu_mae == 0? gyo_mae + 1 : gyo_mae);
			//dump(gyo_mae)
			//dump(retu_mae)
			//dump(a[gyo_mae][retu_mae])
			//dump(gyo_ato)
			//dump(retu_ato)

			if(a[gyo_mae][retu_mae] % 2 == 1)
			{
				if(i != H * W - 1)
				{
					count++;
					a[gyo_ato][retu_ato]++;
					//cout << gyo_mae + 1 << " " << retu_mae + 1 << " " << gyo_ato + 1 << " " << retu_ato + 1 << endl;

					PII pos1, pos2;
					pos1.first = gyo_mae + 1;
					pos1.second = retu_mae + 1;
					pos2.first = gyo_ato + 1;
					pos2.second = retu_ato + 1;

					que.push(pos1);
					que.push(pos2);

				}
			}


		}
		else //偶数行のとき
		{
			int retu_ato = (retu_mae == W-1? W-1 : retu_mae + 1);
			int gyo_ato = (retu_mae == W-1? gyo_mae + 1 : gyo_mae);

			//dump(gyo_mae)
			//dump(retu_mae)
			//dump(a[gyo_mae][retu_mae])
			//dump(gyo_ato)
			//dump(retu_ato)

			if(a[gyo_mae][retu_mae] % 2 == 1)
			{
				if(i != H * W - 1)
				{
					count++;
					a[gyo_ato][retu_ato]++;
					//cout << gyo_mae + 1 << " " << retu_mae + 1 << " " << gyo_ato + 1 << " " << retu_ato + 1 << endl;

					PII pos1, pos2;
					pos1.first = gyo_mae + 1;
					pos1.second = retu_mae + 1;
					pos2.first = gyo_ato + 1;
					pos2.second = retu_ato + 1;

					que.push(pos1);
					que.push(pos2);

				}
			}

		}




	}

	cout << count << endl;
	REP(i, count)
	{
		cout << que.front().first << " " << que.front().second << " ";
		que.pop();

		cout << que.front().first << " " << que.front().second << endl;
		que.pop();
	}


}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
main(){
  int n;
  while(cin>>n,n){
    int s=0,t;
    r(i,n*(n-1)/2){
      cin>>t;
      s+=t;
    }
    cout<<s/(n-1)<<endl;
  }
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    if(s[5] == '0'){
        if(s[6] == '4' || s[6] == '3' || s[6] == '2' || s[6] == '1') puts("Heisei");
        else puts("TBD");
    }
    else puts("TBD");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,m,t[128],h[128],ts,hs,i,cn,dif,yn;
	while(scanf("%d%d",&n,&m) , n != 0){
		yn = 0;
		for(i = 0;i <= 127;i++){
			t[i] = 0;h[i] = 0;
		}
		ts=0;hs=0;
		for(i = 1;i <= n;i++){
			scanf("%d",&cn);
			t[cn]++;
			ts+=cn;
		}
		for(i = 1;i <= m;i++){
			scanf("%d",&cn);
			h[cn]++;
			hs+=cn;
		}
		if((ts - hs) % 2 != 0){printf("-1\n");continue;}
		if(ts >= hs){
			dif = (ts - hs) / 2;
			for(i = 0;i + dif <= 100;i++){
				if(t[i+dif] && h[i]){
					printf("%d %d\n",i+dif,i);yn = 1;break;
				}
			}
		}
		if(ts < hs){
			dif = (hs - ts) / 2;
			for(i = 0;i + dif <= 100;i++){
				if(t[i] && h[i+dif]){
					printf("%d %d\n",i,i+dif);yn = 1;break;
				}
			}
		}
		if(yn == 0){printf("-1\n");}
	}
	return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

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

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

pair<ll,ll> cals(ll x,vector<ll> &a,vector<ll> &s){
	ll tot = 0, num = 0;
	rep(i,a.size()){
		int j = lower_bound(all(a),x-a[i]) - a.begin();
		num += a.size() - j;
		tot += s[a.size()] - s[j];
		tot += a[i] * (ll)(a.size() - j);
	}
	return make_pair(tot, num);
}

int main()
{
	long long int n, m;
	cin >> n >> m;
	vector<long long int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	vector<long long int> s(n + 1);
	rep(i,n){
		s[i + 1] = s[i] + a[i];
	}
	int l = 0, r = 200005;
	while(l+1<r){
		int mid = (l + r) / 2;
		if(cals(mid,a,s).second >= m)
			l = mid;
		else
			r = mid;
	}
	auto p = cals(l,a,s);
	ll ans = p.first;
	ans -= (p.second - m) * l;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);
		int d = Integer.parseInt(str[3]);
		int e = Integer.parseInt(str[4]);

		if (a == 0) {
			System.out.println("1");
		} else if (b == 0) {
			System.out.println("2");
		} else if (c == 0) {
			System.out.println("3");
		} else if (d == 0) {
			System.out.println("4");
		} else if (e == 0) {
			System.out.println("5");
		}
	}
}


Measured memory_bytes: 32664
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,h;
  	cin>>a>>b>>h;
  	ll ans=(a+b)*h;
  	cout<<ans/2;
  	return 0;
}







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

#define ll long long
using namespace std;

int main(){
  ll k,n;
  cin>>n>>k;
  vector<ll> der[n];
  for(int i=0;i<n;i++){
    int t,d;
    cin>>t>>d;
    --t;
    der[t].push_back(d);
  }
  for(int i=0;i<n;i++){
    if(der[i].size()){
      sort(der[i].begin(),der[i].end());
      reverse(der[i].begin(),der[i].end());
    }
  }
  vector<ll> umai;
  vector<ll> umakunai;
  for(int i=0;i<n;i++){
    if(der[i].size()) umai.push_back(der[i][0]);
    for(int j=1;j<der[i].size();j++) umakunai.push_back(der[i][j]);
  }
  sort(umai.begin(),umai.end());
  reverse(umai.begin(),umai.end());
  sort(umakunai.begin(),umakunai.end());
  reverse(umakunai.begin(),umakunai.end());
  ll accumd[n+1],accumn[n+1];
  fill(accumd,accumd+n+1,0);
  fill(accumn,accumn+n+1,0);
  for(int i=1;i<=umai.size();i++){
    accumd[i]=accumd[i-1]+umai[i-1];
  }
   for(int i=1;i<=umakunai.size();i++){
    accumn[i]=accumn[i-1]+umakunai[i-1];
  }
  ll ans=0;
  for(ll i=1;i<=k;i++){
    if(i<=umai.size()&&(k-i)<=umakunai.size()){
      ll pos=accumd[i]+accumn[k-i]+i*i;
      ans=max(ans,pos);
    }
  }
  cout<<ans<<endl;
  //for(auto a:umai){ cout<<a<<" ";}
  
  return 0;
}


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

typedef long long lint;
typedef unsigned long long ulint;

int main(){
    string S,A="AKIHABARA";
    cin >> S;
    int i=0;
    for(int j=0;j<A.size();j++){
        if(S[i]==A[j]){
            i++;
        }else if(A[j]=='A'){}
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    if(i==S.size()) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

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

#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug4(a,b,c,d) cout<<a<<" "<< b <<" "<<c<<" "<<d<<"\n";

ll mod = 1000000007;

using namespace std;

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

	 int n,x;
	 cin>>n>>x;
	 int k;
	 cin>>k;
	 int ans = abs(k-x);
	 for (int i = 0; i < n-1; ++i)
	  {
	  		cin>>k;
	  		ans = __gcd(ans,abs(k-x));
	  } 

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

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := getInt()
	syogen := make([][]int, n)
	for i := range syogen {
		syogen[i] = makeIntSlice(n, -1)
		a := getInt()
		for j := 0; j < a; j++ {
			x, y := getInt()-1, getInt()
			syogen[i][x] = y
		}
	}

	ans := 0
	for bit := 0; bit < (1 << uint(n)); bit++ {
		ok := true
		honest := 0
	L:
		for i := 0; i < n; i++ {
			if bit&(1<<uint(i)) == 0 {
				continue
			}

			honest++
			for x, y := range syogen[i] {
				if y == -1 {
					continue
				}

				if bit&(1<<uint(x)) > 0 {
					if y == 0 {
						ok = false
						break L
					}
				} else {
					if y == 1 {
						ok = false
						break L
					}
				}
			}
		}
		if ok {
			ans = max(ans, honest)
		}
	}

	fmt.Fprintln(wr, ans)
}

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

func makeIntSlice(n, init int) []int {
	is := make([]int, n)
	for j := range is {
		is[j] = init
	}
	return is
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

ll n,c,k,t[200000];
int main(){
    cin >> n >> c >> k;
    REP(i,n) {
        cin >> t[i];
    }

    sort(t,t + n);

    ll fast = t[0],wait = 1,ans = 0;

    FOR(i,1,n){
        if(fast + k < t[i] || wait >= c) {
            //cout << fast << " " << wait << endl;
            ans++;
            fast = t[i];
            wait = 0;
        }
        wait++;
    }
    cout << ans + 1 << endl;
    return 0;
}



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

int main() {
	int n, lastt = 0, lastx = 0, lasty = 0;
	bool flag = true;
	cin >> n;
	while (n--) {
		int t, x, y;
		cin >> t >> x >> y;
		if (t - lastt < abs(lastx - x) + abs(lasty - y)) {
			flag = false;
		} else if ((t - lastt) % 2 != (abs(lastx - x) + abs(lasty - y)) % 2) {
			flag = false;
		}
		lastt = t, lastx = x, lasty = y;
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    string S;
    cin>>S;
    vl use(26);
    if(S=="zyxwvutsrqponmlkjihgfedcba"){
        cout<<-1<<endl;
        return 0;
    }
    if(S.size()!=26){
    rep(i,S.size()){
        use[S[i]-'a']++;
    }
    for(char a='a';a<='z';a++){
        if(use[a-'a']==0){
            S=S+a;
            cout<<S<<endl;
            return 0;
        }
    }
    }else{
        string T=S;
        next_permutation(all(S));
        rep(i,26){
            cout<<S[i];
            if(S[i]!=T[i])break;
        }
        cout<<endl;
    }
}


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

int calc(vector<int> &from, vector<int> &to)
{
    if (accumulate(from.begin(), from.end(), 0) != accumulate(to.begin(), to.end(), 0))
        return INT_MAX;

    int res = 0, k = 0;
    for (int i = 0; i < (int)from.size(); ++i)
    {
        if (from[i] == 0)
            continue;
        while (to[k] == 0)
            k++;
        res += abs(i - k);
        k++;
    }

    return res;
}

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

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

    vector<int> p1(N), p2(N);
    int k = 0, p;
    for (int i = 0; i < M; ++i)
    {
        cin >> p;
        while (p--)
        {
            p1[k] = i % 2;
            p2[k] = (i + 1) % 2;
            k++;
        }
    }
    cout << min(calc(b, p1), calc(b, p2)) << endl;

    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>

using namespace std;

int n, m;
set<int> s;
vector< pair<pair<int, int>, int> > vec;

int main(void)
{
	cin >> n >> m;
	int a, b;
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		vec.push_back(make_pair(make_pair(a, 0), i));
		vec.push_back(make_pair(make_pair(b-1, 1), i));
	}
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	
	int ans = 0;
	for(int i = 0; i < vec.size(); i++){
		if(vec[i].first.second == 0){
			s.insert(vec[i].second);
		}
		if(vec[i].first.second == 1){
			if(s.count(vec[i].second)){
				s.clear();
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4852
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[3];
    for(int i = 0; i < 3; i++) cin >> a[i];
    sort(a, a + 3);
    cout << a[0] + a[1] << endl;
    return 0;
}



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

int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  if(c-b-a<=0){
    cout << "No"<<endl;
  }else if(4*a*b < (c-b-a)*(c-b-a)){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }
}
    
    

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;

ll comb(ll n, ll k) {
    if(k==0) return 1;
    if(n==k) return 1;
    else return comb(n-1, k-1)+comb(n-1, k);
}

ll zeroer(ll x) {
    if(x<0) return 0;
    else return x;
}

int main(void) {
    ll N, K;
    cin >> N >> K;
    ll x=N/K, y=2*N/K-N/K;
    ll ans=x*x*x;
    if(K%2==0)
        ans+=y*y*y;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is #" << (x) <<"#" <<endl
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 1e5+5;
const ll inf = 1e18+7;
ll dp[MAX][4];
ll a[MAX],b[MAX],c[MAX];
int main() {
  fastio;
  ll n;
  cin>>n;
  f(i,0,n) cin>>a[i]>>b[i]>>c[i];
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  f(i,1,n){
    dp[i][0] = max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
    dp[i][1] = max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
    dp[i][2] = max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
  }
  ll ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
  cout<<ans<<"\n";
  return 0; 
}

Measured memory_bytes: 9128
n, m = map(int, input().split(' '))
l = {}
ac = 0
er = 0

for _ in range(m):
  num_prob, state = input().split(' ')
  if (num_prob in l) and (l[num_prob] != -1):
    if state == 'WA':
      l[num_prob] += 1
    else:
      er += l[num_prob]
      l[num_prob] = -1
      ac += 1
  elif num_prob not in l:
    l[num_prob] = 0
    if state == 'WA':
      l[num_prob] += 1
    else:
      er += l[num_prob]
      l[num_prob] = -1
      ac += 1
      
print(ac, er)

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0; i<N; ++i) cin >> a[i];

    sort(a.begin(), a.end());
    vector<bool> ok(1e6+1, true);
    int res = 0;
    for (int i=0; i<N; ++i) {
        if (ok[a[i]]) {
            if (i == N-1 || a[i] != a[i+1]) ++res;
            int cur = a[i];
            while (cur <= 1e6) {
                ok[cur] = false;
                cur += a[i];
            }
        }
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int s1=a*b;
  int s2=c*d;
  if(s1>=s2){
    cout<<s1;
  }
  else{cout<<s2;}
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string S;
  cin >> S;
  int c1=1, c2=1;
  char tmp=' ';
  for(int i=1; i<4; i++){
    if(S[i] == S[0]){
      c1++;
    }else if(S[i] == tmp){
      c2++;
    }else{
      tmp = S[i];
    }
  }
  if(c1==2 && c2==2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
const int MOD = 1000000007;
const int INF = 100100100;
const double EPS = 0.000000001;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int odd = 0;
  int even = 0;
  int n = s.size();
  REP(i, n){
    if(((i & 1) && (s[i] == '0')) || ((!(i & 1)) && (s[i] == '1'))) odd++;
  }
  REP(i, n){
    if(((i & 1) && (s[i] == '1')) || ((!(i & 1)) && (s[i] == '0'))) even++;
  }

  int ans = min(odd, even);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9+7;

ll A,B,C;
ll K;
int main(){
    cin>>A>>B>>C;
    cin>>K;
    if(K%2){
        p(B-A);
    } else{
        p(A-B);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double eps=1e-7;
const int N=250005;
int a[N];
int main()
{
     int n,maxn=1000000009,cnt=0;
     cin>>n;
     for(int i=1;i<=n;i++)
     {
        scanf("%d",&a[i]);
        if(a[i]<=maxn) cnt++;
        maxn=min(a[i],maxn);
     }
     cout<<cnt<<endl;
     return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
 public static void main(String[] args){

 Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

if (a<=b && b<=c){
System.out.println(a+" "+b+" "+c);
}else if (a<=c && c<=b){
System.out.println(a+" "+c+" "+b);
}else if (b<=a && a<=c){
System.out.println(b+" "+a+" "+c);
}else if (b<=c && c<=a){
System.out.println(b+" "+c+" "+a);
}else if (c<=a && a<=b){
System.out.println(c+" "+a+" "+b);
}else if (c<=b && b<=a){
System.out.println(c+" "+b+" "+a);
}

}
}



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

class Vec{
public:
	double x, y;
	Vec(const double x, const double y) :x(x), y(y){}
	Vec() :x(0), y(0){}
	double cross(const Vec& tgt){
		return (x*tgt.y) - (y*tgt.x);
	}
};

Vec operator - (const Vec& v2, const Vec& v1){
	Vec v(v2.x - v1.x, v2.y - v1.y);
	return v;
}

istream& operator >> (istream& strm, Vec& v){
	strm >> v.x >> v.y;
	return strm;
}

bool direc_v(const Vec& v1, const Vec& v2, const Vec& vp){
	if ((v2 - v1).cross(vp - v2) >= 0) return true;
	return false;
}

int main(){
	Vec a, b, c, p;
	
	auto direc = bind(direc_v, placeholders::_1, placeholders::_2, ref(p));

	while (cin >> a >> b >> c >> p){
		if (direc(a, b) != direc(b, c)){
			cout << "NO" << endl;
			continue;
		}
		if (direc(a, b) != direc(c, a)){
			cout << "NO" << endl;
			continue;
		}
		cout << "YES" << endl;
	}

	return 0;
}

Measured memory_bytes: 3036
using System;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var hw = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            string[] map = new string[hw[0]];
            for (int i = 0; i < hw[0]; i++)
            {
                map[i] = Console.ReadLine();
            }

            bool ans = true;
            for (int i = 0; i < hw[0]; i++)
            {
                for (int j = 0; j < hw[1]; j++)
                {
                    if (map[i][j] == '#')
                    {
                        if (i - 1 >= 0 && map[i - 1][j] == '#') continue;
                        if (j - 1 >= 0 && map[i][j - 1] == '#') continue;
                        if (i + 1 < hw[0] && map[i + 1][j] == '#') continue;
                        if (j + 1 < hw[1] && map[i][j + 1] == '#') continue;
                        ans = false;
                    }
                }
            }
            Console.WriteLine(ans ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int a,b;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b;
	cout<<(((a%3==0)||(b%3==0)||((a+b)%3==0))?"Possible":"Impossible");
	return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define INF 0x3f3f3f3f
const int N=2e5 + 5;
const ll mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    vector<int> l(k), r(k);
    int i = 0, j = n - 1;
    for(int idx=0;idx<k;idx++) {
        while(s[i] != 'o') i++;
        l[idx] = i;
        i += c + 1;
        while(s[j] != 'o') j--;
        r[k - idx - 1] = j;
        j -= c + 1;
    }
    for(int idx=0;idx<k;idx++) {
        if(l[idx] == r[idx]) cout << l[idx] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3348
#include<bits/stdc++.h>
#define fs first
#define se second
using namespace std;

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

const int maxn=5e5+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

int top = 0;
int head[maxn];

struct Edge{
	int to,w,next;
}edge[maxn*2];

void init(){
	top=0;
	memset(head,-1,sizeof(head));
}

void addedge(int u,int v,int w){
	edge[top].w=w;
	edge[top].to=v;
	edge[top].next=head[u];
	head[u]=top++;
}

struct Node{
	int id,val;
	Node(int id,int val):id(id),val(val){
	}
	bool operator <(const Node &bb) const
	{
		return val > bb.val;
	}
};

int dis[maxn];
int vis[maxn];

void dijk(int st){
	memset(dis,0x3f,sizeof(dis));
	memset(vis,0,sizeof(vis));
	priority_queue<Node> q;
	dis[st]=0;
	q.push(Node(st,0));
	while(!q.empty()){
		int u=q.top().id;
		q.pop();
		if(vis[u]) continue;
		vis[u]=1;
		for (int i = head[u]; i!=-1; i=edge[i].next)
		{
			int to=edge[i].to;int w=edge[i].w;
			if(dis[to]>dis[u]+w&&!vis[to]){
				dis[to]=dis[u]+w;
				q.push(Node(to,dis[to]));
			}
		}
	}
}

int main(){
	init();
	int k;
	scanf("%d",&k);
	for(int i=1;i<=k-1;i++){
		addedge(i,(i+1)%k,1);
		addedge(i,(i*10)%k,0);
	}
	dijk(1);
	printf("%d",dis[0]+1);
	return 0;
}

Measured memory_bytes: 12284
#include <iostream>
using namespace std;
int main()
{
	string a;
	int n,b;
	cin>>n>>b>>a;
	if (a.size()!=n+b+1){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<a.size();i++)
		if ((i==n && a[i]!='-')||(i!=n && (a[i]>'9' || a[i]<'0')))
		{
			cout<<"No"<<endl;
			return 0;
		}
	cout<<"Yes"<<endl;
	return 0;
}


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

struct ab {
  int a, b;
};

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> cnt(100001, 0);
  for (int i = 0; i < N; ++i) {
    ll ai, bi;
    cin >> ai >> bi;
    cnt[ai] += bi;
  }
  for (int i = 1; i <= pow(10, 5); ++i) {
    K -= cnt[i];
    if (K <= 0) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 1152