akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll par[1000000];
ll Rank[1000000];
ll num[1000000];

void init(ll n){
    rep(i,1,n){
        par[i]=i;
        Rank[i]=0;
        num[i]=1;
    }
}

ll find(ll x){
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
}

void unite(ll x,ll y){
    x=find(x);
    y=find(y);
    if(x==y){
        return ;
    }
    if(Rank[x]<Rank[y]){
        par[x]=y;
        num[y]=num[x]+num[y];
    }else{
        par[y]=x;
        num[x]=num[x]+num[y];
        if(Rank[x]==Rank[y]){
            Rank[x]++;
        }
    }
    
}

bool same(ll x,ll y){
    return find(x)==find(y);
}

int main(){
    ll n,m,k;cin>>n>>m>>k;
    ll a[m],b[m];rep(i,0,m-1)cin>>a[i]>>b[i];
    ll c[k],d[k];rep(i,0,k-1)cin>>c[i]>>d[i];
    init(n);
    rep(i,0,m-1){
        unite(a[i],b[i]);
    }
    ll iran[n+1];memset(iran,0,sizeof(iran));
    rep(i,0,m-1){
        iran[a[i]]++;
        iran[b[i]]++;
    }
    rep(i,0,k-1){
        if(same(c[i],d[i])){
            iran[c[i]]++;
            iran[d[i]]++;
        }
    }
    rep(i,1,n){
        cout<<num[find(i)]-1-iran[i];
        if(i<n){
            cout<<' ';
        }else{
            cout<<endl;
        }
    }
    
    return 0;
}




Measured memory_bytes: 13696
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

#define loop(i,first,end) for(int i=(first);i<(end);i++)
#define uint unsigned int
#define ull unsigned long long
#define ll long long
#define vint vector<int>
#define vuint vector<unsigned int>
#define vull vector<ULL>
#define vll vector<LL>
#define mod 1000000007

int main(void){
	int n;
	cin >> n;
	vint a(n);
	int amax = 0, asecond = 0;
	loop(i, 0, n){
		cin >> a[i];
		if (a[i] >= amax){
			asecond = amax;
			amax = a[i];
		}
		else if (a[i] > asecond)asecond = a[i];
	}

	loop(i, 0, n)cout << (a[i] == amax ? asecond : amax) << endl;

	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> vec(N);
  int count=0;
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
    count+=vec.at(i);
  }
  int ave=count/N;
  int S1,S2;
  S1=S2=0;
  for(int i=0;i<N;i++){
  	S1+=pow(vec.at(i)-ave,2);
    S2+=pow(vec.at(i)-ave-1,2);
  }
  cout<<min(S1,S2)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

typedef int64_t ll;

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

#define SPRE(x) setprecision(x) // 精度を指定

signed main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	ll h,w;
	cin >> h >> w;
	ll A,B,C;
	ll diff = 1e+15;

	for(int i = 1; i < h; i++) {
		A = i * w;
		ll b = w/2;
		B = (h-i) * b;
		C = (h-i) * (w-b);
		ll ma = max(max(A,B),C);
		ll mi = min(min(A,B),C);
		diff = min(diff, ma-mi);

		b = (h-i)/2;
		B = b * w;
		C = (h - i - b ) * w;
		ma = max(max(A,B),C);
		mi = min(min(A,B),C);
		diff = min(diff, ma-mi);
	}

	swap(h,w);

	for (int i = 1; i < h; i++) {
		A = i * w;
		ll b = w/2;
		B = (h-i) * b;
		C = (h-i) * (w-b);
		ll ma = max(max(A,B),C);
		ll mi = min(min(A,B),C);
		diff = min(diff, ma-mi);

		b = (h-i)/2;
		B = b * w;
		C = (h - i - b ) * w;
		ma = max(max(A,B),C);
		mi = min(min(A,B),C);
		diff = min(diff, ma-mi);
	}

	cout << diff << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <set>
#include <climits>
#include <sstream>
#include <bitset>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926535;

class UnionFind {
	std::vector<int> p;

public:
	UnionFind(int n) : p(n, -1) {}

	int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

	bool same(int x, int y) { return root(x) == root(y); }

	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (p[y] < p[x]) std::swap(x, y);
		if (p[x] == p[y]) --p[x];
		p[y] = x;
		return true;
	}
};

ll fast(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	if (k == 1) {
		return n;
	}
	if (k % 2 == 0) {
		ll tmp = fast(n, k / 2);
		return tmp * tmp % MOD;
	}
	else {
		ll tmp = fast(n, k / 2);
		tmp = tmp * tmp % MOD;
		return n * tmp % MOD;
	}
}

ll count(ll n, ll k) {
	ll cnt = 0;
	while (true)
	{
		if (n >= k) {
			break;
		}
		cnt++;
		n *= 2;
	}
	return cnt;
}

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

	// 0..5 AM
	// 5..10 PM
	vector<vector<ll>> SHOP(10);

	for (ll i = 0; i < N; i++)
	{
		for (ll j = 0; j < 5; j++)
		{
			ll am, pm;
			cin >> am >> pm;
			if (am) {
				SHOP[j].push_back(i);
			}
			if (pm) {
				SHOP[j + 5].push_back(i);
			}
		}
	}

	vector<vector<ll>> p(N, vector<ll>(11, 0));
	for (ll i = 0; i < N; i++)
	{
		for (ll j = 0; j <= 10; j++)
		{
			cin >> p[i][j];
		}
	}


	ll ans = INT_MIN;
	for (ll i = 1; i < (1 << 10); i++)
	{
		vector<ll> kasanari(N, 0);


		for (ll j = 0; j < 10; j++)
		{
			for (auto&& d : SHOP[j])
			{
				if (bitset<10>(i)[j]) {
					kasanari[d] += 1;
				}
			}
		}

		ll cur = 0;
		for (ll j = 0; j < N; j++)
		{
			cur += p[j][kasanari[j]];
		}
		ans = max(ans, cur);
	}
	cout << ans << endl;
}

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

int main() {
	int N,K,a[5000],cnt=0,sum=0,head=0,last=INT_MAX;
	cin>>N>>K;
	rep(i,N)cin>>a[i];
	sort(a,a+N,greater<int>());
	rep(i,N){
		sum += a[i];
		if(sum>=K) {
			last = min(last,min(a[i],K-(sum-a[i])));
			sum -= a[head];
			head++;
		}
	}
	rep(i,N)if(a[i]<last)cnt++;
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]

use procon::*;
use std::cmp::{max, min};
use std::collections::*;
use std::ops::*;
use std::*;

pub fn main() {
    let N = read_line().parse::<usize>().unwrap();
    let A = (0..N)
        .map(|_| read_line().parse::<i64>().unwrap())
        .collect::<Vec<_>>();

    {
        let mut m = 0_i64;
        for i in 0..N {
            if A[i] > m || (i > 0 && A[i] - A[i - 1] > 1) {
                println!("-1");
                return;
            }

            if A[i] == 0 {
                m = 1;
            } else {
                m += 1;
            }
        }
    }

    // seqs[zi] = n: 位置ziのゼロから長さnの列を伸ばしている
    // zi は降順
    let mut seqs = vec![0; N];

    for i in 1..N {
        // assert 0 <= A[i] <= i
        let zi = i - (A[i] as usize);
        seqs[zi] = max(seqs[zi], A[i]);
    }

    let count: i64 = seqs.into_iter().sum();

    println!("{}", count);
    return;
}

pub mod procon {
    use std;
    use std::collections::*;
    use std::io;
    use std::mem;
    use std::str::FromStr;

    pub fn read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim_right().to_owned()
    }

    pub fn read_words<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace()
            .map(|word| T::from_str(word).unwrap())
            .collect()
    }

    pub fn read_vec(len: usize) -> Vec<String> {
        let mut vec = Vec::new();
        while vec.len() < len {
            let line = read_line();
            for word in line.split_whitespace() {
                vec.push(word.to_owned());
            }
        }
        assert!(vec.len() == len);
        vec
    }
}


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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0, ans = 0;
    for(int i = 0; s[i]; i++)
    {
        if(s[i] == 'I') x++;
        if(s[i] == 'D') x--;
        ans = max(ans, x);
    }
    cout << ans << endl;
}


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

#define foreach(i,v) for(auto&& i: v)
#define all(x) (x).begin(), (x).end()

typedef std::vector< std::string > VS;
typedef std::vector<int> VI;
typedef long long ll;

template <class C> C& mini(C& a, C b) { if (b < a) a = b; return a; }
template <class C> C& maxi(C& a, C b) { if (a < b) a = b; return a; }

using namespace std;

int main(int argc, const char* argv[]) {
	int N;
	scanf("%d", &N);
	VI A(N);
	foreach (a, A)
		scanf("%d", &a);
	VI D(N+1);
	int r = 0;
	foreach (a, A) {
		maxi(r, D[a] = D[a-1] + 1);
	}

	printf("%d\n", N - r);
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int A[10][10], C[10][10];

int main(void){
    int i, j, H, W, h, w;
    char c;
    
    scanf("%d %d", &H, &W);
    
    for(i = 0; i <= H + 1; i++){
        A[i][0] = A[i][W + 1] = 0;
    }
    for(i = 0; i <= W + 1; i++){
        A[0][i] = A[H + 1][i] = 0;
    }
    
    for(i = 1; i <= H; i++){
        for(j = 1; j <= W; j++){
            scanf("%c", &c);
            switch(c){
                case '.' :  A[i][j] = 0;
                break;
                case '#' :  A[i][j] = 1;
                break;
                default  :  j--;
            }
        }
    }
    
    h = w = 1;
    while(h != H || w != W){
        C[h][w] = 1;
        if(A[h + 1][w] && A[h][w + 1]){
            printf("Impossible\n");
            return 0;
        }
        if(A[h + 1][w]) h++;
        else if(A[h][w + 1]) w++;
        else{
            printf("Impossible\n");
            return 0;
        }
    }
    
    C[H][W] = 1;
    
    for(i = 1; i <= H; i++){
        for(j = 1; j <= W; j++){
            if(A[i][j] && !C[i][j]){
                printf("Impossible\n");
                return 0;
            }
        }
    }
    
    printf("Possible\n");
    
    return 0;
}

Measured memory_bytes: 128
n=gets.to_i
ab=(0...n).map{gets.split.map{|s| s.to_i }}
M=1000000007
tmp={}
zero=0
ab.each{|a,b|
    if [a,b] == [0,0]
        zero+=1
    elsif a==0 || b == 0
        r = [0,1]
        tmp[r]||=[0,0]
        tmp[r][(a==0)?0:1]+=1
    else
        r = a.abs == b.abs ? Rational(a.abs,b.abs) : a.abs < b.abs ?  Rational(a,b) : -Rational(b,a)
        tmp[r]||=[0,0]
        tmp[r][((a<0) == (b<0) ? 0:1)]+=1
    end
}

v = 1
tmp.each{|k,(a,b)|
    v *= (2**a + 2**b - 1)
    v %= M
}

p (v-1 + zero ) % M


Measured memory_bytes: 51912
#include<iostream>
using namespace std;
int main(){
  long long N;
  int M;
  cin >> N >> M;
  int A[M];
  for(int i=0;i<M;i++) cin >> A[i];
  long long count=0;
  for(int j=0;j<M;j++) count+=A[j];
  if(N<count)cout << -1 << endl;
  else cout << N-count << endl;
}

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

int main() {
  double a, b, h, m, theta, phi, xi, x;
  double pi = M_PI;
  cin >> a >> b >> h >> m;

  phi = (m / 60);
  xi = ((((h * 60) + m) / 720));
  theta = ((11 * m) - (60 * h)) * pi / 360;
  x = sqrt((a * a) + (b * b) - (2 * b * cos(((11 * m) - (60 * h)) * pi / 360)));
  cout << fixed << setprecision(20)
       << sqrt((a * a) + (b * b) -
               (2 * a * b * cos(((11 * m) - (60 * h)) * pi / 360)))
       << endl;
}

Measured memory_bytes: 4260
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <fstream>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll factorial(ll n) {//階乗
	ll ret = 1;
	rep(i, 1, n + 1)
		ret = (ret *i) % MODU;

	return ret;
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b, ll m) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}
ll ncr(ll n, ll r) {
	return divmod(factorial(n), (factorial(r) * (factorial(n - r))) % MODU, MODU);
}

int n;
string base;
bool quest(int from) { //True:base
	printf("?");
	REP(i, n) {
		printf(" %d", (from+ i) % (2*n) + 1);
	}
	cout << endl;
	string str;
	cin >> str;
	return str == base;
}

bool quest(int from, int ad) { //True:base
	printf("?");
	REP(i, n - 1) {
		printf(" %d", (from + i) % (2 * n) + 1);
	}
	printf(" %d", ad + 1);
	
	cout << endl;
	string str;
	cin >> str;
	return str == base;
}

signed main() {
	int n;
	string str;
	cin >> n >> str;

	REP(i,str.length()) {
		printf("%c",(str[i] - 'A' + n) % 26 + 'A');
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			double v = sc.nextDouble();
			double t = v / 9.8;
			int y = (int)(4.9 * t * t);
			y /= 5;
			System.out.println(y+2);
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include<stdio.h>

int main()
{
	int x ,y ,z ,i;
	scanf("%d %d %d" ,&x ,&y ,&z);
	i = 0;
	
	for (x = x ;x <= y; x++){
		if((z%x) == 0 ) i++;
	}
	
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>

using namespace std;
//author_name:
//date://
//title:
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define eb emplace_back
#define mp make_pair
//tsurune
typedef pair<int,int> pii;
typedef unsigned int uint;

int a[100100],b[100100],n; 
long long ans=0;

int main(){
	cin>>n;
	
	for(int i=0;i<=n;i++)	cin>>a[i];
	for(int i=0;i<n;i++)	cin>>b[i];
	
	for(int i=0;i<n;i++){
		if(b[i]>=a[i]){
			ans+=a[i];
			b[i]-=a[i];
			if(a[i+1]>=b[i]){
				ans+=b[i];
				a[i+1]-=b[i];
			}
			else{
				ans+=a[i+1];
				a[i+1]=0;	
			}
		}
		else ans+=b[i];
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	string st;
	int flag=0;
	cin >> st;
	for(int i=0;i<st.size();i++){
		if(i%2){
			if(st[i]=='R'){
				flag=1;
				break;
			}
		}
		else{
			if(st[i]=='L'){
				flag=1;
				break;
			}
		}
	}
	if(flag)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}

Measured memory_bytes: 256
use num::integer;
use proconio::input;

fn main() {
    input! {
        k: usize,
    };
    let mut result = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                result += integer::gcd(integer::gcd(a, b), c);
            }
        }
    }

    println!("{}", result);
}


Measured memory_bytes: 2148
#!/usr/bin/env python3

from collections import defaultdict
from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x)


def solve(H, W, data):
    "void()"
    score = [[0] * (W + 1) for i in range(H + 1)]
    score[0][1] = 1
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if data[y - 1][x - 1] == ord("#"):
                score[y][x] = 0
            else:
                score[y][x] = (score[y - 1][x] + score[y][x - 1]) % MOD
    # print(score)
    return score[H][W]


def main():
    H, W = map(int, input().split())
    data = [input() for i in range(H)]
    print(solve(H, W, data))


T1 = """
3 4
...#
.#..
....
"""

T2 = """
5 5
..#..
.....
#...#
.....
..#..
"""

T3 = """
20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
"""

T4 = """
5 2
..
#.
..
.#
..
"""


def test_T4():
    """
    >>> as_input(T4)
    >>> main()
    0
    """


def test_T3():
    """
    >>> as_input(T3)
    >>> main()
    345263555
    """


def test_T2():
    """
    >>> as_input(T2)
    >>> main()
    24
    """


def _test():
    """
    >>> as_input(T1)
    >>> main()
    3
    """
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())

    def input():
        return bytes(f.readline(), "ascii")

    def read():
        return bytes(f.read(), "ascii")


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 50092
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] s1=new char[s.length()];
		for(int i=0; i<s.length(); i++){
			s1[i]=s.charAt(i);
		}
		long ans=0;
		for(int i = 0; i<Math.pow(2,s.length()-1); i++){
			int t=i;
			int count=1;
			String a=String.valueOf(s1[0]);
			while(count<s.length()){
				if((t & 1)==1){
					ans+=Long.parseLong(a);
					a=String.valueOf(s1[count]);
				}else{
					a+=s1[count];
				}
				t>>=1;
				count++;
			}
			ans+=Long.parseLong(a);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include <stdio.h>
int main()
{
    char match_word[20];
    char word[500];
    int match_count;
    match_count = 0;
    scanf(" %s", match_word);
    for (int i = 0; match_word[i] != '\0'; i++){
        if (match_word[i] >= 'A' && match_word[i] <= 'Z'){
            match_word[i] += 'a' - 'A';
        }
    }
    while (1){
        for (int i = 0; i < 500; i++){
            word[i] = '\0';
        }
        scanf(" %s", word);
        if (!strcmp(word, "END_OF_TEXT")){
            break;
        }
        for (int i = 0; word[i] != '\0'; i++){
            if (word[i] >= 'A' && word[i] <= 'Z'){
                word[i] += 'a' - 'A';
            }
        }
        if (!strcmp(word, match_word)){
            match_count++;
        }
    }
    printf("%d\n", match_count);
    return 0;
}


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


void solve(long long a, long long b){
    char c;
    long long times;
    if(a < b){
        c = '0' + a;
        times = b;
    }else{
        c = '0' + b;
        times = a;
    }
    for(int i=0; i < times; i++){
        cout << c;
    }
    cout << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
import qualified Data.Vector.Unboxed.Mutable as V
import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as B
import Debug.Trace



main :: IO ()
main = do
  [a,b] <- map read.words <$> getLine :: IO [Int]
  if a >= 13 then print $ b
    else if 6 <= a && a <= 12 then print $ b `div` 2
      else print 0


Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#define __DEBUG__

using namespace std;

int main(){
    int x[4],y[4];
    cin>>x[0]>>y[0]>>x[1]>>y[1];
    int dx = x[1]-x[0];
    int dy = y[1]-y[0];
    for(int i = 0;i < 2;i++){
        int temp = dx;
        dx = -dy;
        dy = temp;
        x[i+2]=x[i+1]+dx;
        y[i+2]=y[i+1]+dy;
    }
    cout<<x[2]<<" "<<y[2]<<" "<<x[3]<<" "<<y[3]<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

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

int main(){
  int i,j,k;
  int A,B,C;
  int ans=100000;
  
  scanf("%d %d %d",&A,&B,&C);
  ans= min(min(A+B,C+B),A+C);
  printf("%d\n",ans);
  return 0;
}

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

int main()
{
int n,a,b;
cin >> n;
if(n % 2 == 0)cout << (n /2) * (n/2) << endl;
else cout  << ((n/2) +1) * (n /2) << endl;

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>
#include<memory>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


struct Stage {
	Stage(int n_, int m_, int p_, int a_, int b_):
		n(n_),
		m(m_),
		p(p_),
		a(a_),
		b(b_)
	{
		t.resize(n);
		edge.resize(m);

		REP(i, n) {
			int tmp;
			cin >> tmp;
			t[i] = tmp;
		}
		REP(i, p) {
			int x, y, z;
			cin >> x >> y >> z;
			x--; y--;
			edge[x].push_back({ y,z });
			edge[y].push_back({ x,z });
		}
	}

	void action()
	{
		double res = INF;
		sort(t.begin(), t.end());
		do {
			/*
			{
				double tmp = search_route(t);
				if (res > tmp) {
					cerr << "updated:" << endl;
					debug(t);
					cerr << "ans:" << tmp << endl << endl;
				}
			}
			*/
			res = min(res, search_route(t));
		} while (next_permutation(t.begin(), t.end()));
		//cerr << "answer is::::  ";
		cout << (is_reach(res)
			? to_string(res)
			: "Impossible" )
		<< endl;
	}

private:
	const int n, m, p, a, b;
	vector<int> t;
	vector<vector<pair<int, int>>> edge;

	bool is_reach(double res)	{
		return res < INF / 2.;
	}

	double search_route(vector<int> t)
	{
		queue<int> now, will;
		unique_ptr<double[]> time(new double[m]), willTime(new double[m]);
		REP(i, m) {
			time[i] = willTime[i] = INF;
		}
		time[a] = 0;
		willTime[a] = 0;
		now.push(a);
		
		//チケットを順番に使う。
		for (int ticket : t) 
		{
			//消費対象は、辿り着いた土地に対して
			while (!now.empty())
			{
				int here = now.front(); now.pop();
				//消費する
				for (auto route : edge[here])
				{
					int next = route.first;
					int dist = route.second;
					double additional = 1.*dist / ticket;
					if (willTime[next] >= time[here] + additional)
					{
						willTime[next] = time[here] + additional;
						will.push(next);
					}
				}
			}
			now.swap(will);
			REP(i, m) {
				time[i] = willTime[i];
			}
		}

		return time[b];
	}

	void debug(vector<int> v)
	{
		for (auto num : v)cerr << num << " ";
		cerr << endl;
	}
};


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	while (true)
	{
		int n, m, p, a, b;
		cin >> n >> m >> p >> a >> b;
		if (n == 0)break;
		a--; b--;

		Stage stage(n, m, p, a, b);
		stage.action();
	}
	//debug();
	
	return 0;
}



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

#define MOD 1000000007
// #define INF 100000000000

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


#define PI 3.14159265359

int main(int argc, char const *argv[]) {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double theta1 = (H + M / 60.0) / 12.0 * 2 * PI;
    double theta2 = ((H*60 + M) % 60) / 60.0 * 2 * PI;

    printf("%.15f\n", sqrt(pow((double)A, 2) + pow((double)B, 2) - 2.0 * A * B * cos(theta1 - theta2)));

    return 0;
}


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

int getint() {
    char C;
    while (!isdigit(C = getchar()));
    int x = C - '0';
    while (isdigit(C = getchar())) x = x * 10 + C - '0';
    return x;
}

int main() {
  int N; scanf("%d",&N);
  vector<int> vec(3*N, 0);
  for(int i = 0; i < 3*N; i++) vec[i] = getint();
  sort(vec.begin(),vec.end(), greater<int>());
  long long sum = 0;
  for (int i =0; i < N; i++) sum +=vec[2*i + 1];
  printf("%lld\n",sum);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define vi vector<int>
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

const int MOD = 1e9 + 7;
const int INF = 1 << 30;


class UnionFind{
private:
        vector<int> par,rank,sizes;
        int tree;

public:
        explicit UnionFind(const int n) : tree(n){
            par.resize(n+1);
            rank.resize(n+1);
            sizes.resize(n+1);
            rep(i,n){
                par[i] = i;
                sizes[i] = 1;
            }
        }

        ~UnionFind() = default;

        int root(int x){
            if(par[x] == x) return x;
            else return par[x] = root(par[x]);
        }

        int find(int x){ return root(x);}

        void unite(int x, int y) {
            x = root(x);
            y = root(y);
            if (x == y) return;

            if (rank[x] < rank[y]) swap(x, y);
            par[y] = x;
            tree--;
            sizes[x] += sizes[y];
            if (rank[x] == rank[y]) rank[x]++;
        }

        bool same(int x, int y){
            return root(x) == root(y);
        }

        int size(int x){
            return sizes[root(x)];
        }

        int sumTree(){
            return tree;
        }
};

template <typename T>
class segmentTree{
private:
    int n;
    vector<T> arr;
public:

    explicit segmentTree(vector<T> v){
        ll sz = v.size();
        //while()

        arr.resize(2*n - 1);

    }

    T &operator[](int n){ return arr[n];}


};

template <int mod>
class ModInt{
private:
    ll _num;

public:
    ModInt(){_num = 0;}
    explicit ModInt(ll value){_num = value%mod;}

    ModInt operator+(ModInt &x){ return ModInt(_num + x._num);}
    ModInt operator-(ModInt &x){ return ModInt(_num - x._num);}
    ModInt operator*(ModInt &x){ return ModInt(_num * x._num);}
    friend ostream &operator<<(ostream &os, const ModInt &x){os<<x._num; return os;}
    friend istream &operator>>(istream &is, ModInt &x){is>>x._num; return is;}
};
using mint = ModInt<MOD>;


class topos{

};


ll power(ll m, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = ((res%mod) * (m%mod))%mod;
        m = (m * m)%mod;
        n >>= 1;
    }
    return res;
}



int main(){
    int a,b; cin >> a >> b;
    if(a < 10 and b < 10 and a > 0 and b > 0){
        cout << a*b << endl;
    }else{
        cout << -1 << endl;
    }

}

Measured memory_bytes: 256
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int xmax = -1000;
        int ymin = 1000;
        int com;
        
        for(int i = 0; i < N; i++){
            com = sc.nextInt();
            if(xmax < com){
                xmax = com;
            }
        }
        for(int i = 0; i < M; i++){
            com = sc.nextInt();
            if(ymin > com){
                ymin = com;
            }
        }
        
        if(xmax < ymin && X < ymin && xmax < Y){
            System.out.println("No War");
        }else{
            System.out.println("War");
        }
    }
}


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

const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<vector<vector<int>>> f(n, vector<vector<int>>(5, vector<int>(2)));
  rep(i, n) rep(j, 5) rep(k, 2) cin >> f[i][j][k];
  vector<vector<int>> p(n, vector<int>(11));
  rep(i, n) rep(j, 11) cin >> p[i][j];

  int ans = -INF;
  rep(bit, 1<<10) {
    if (bit == 0) continue;
    vector<int> c(n, 0);
    rep(i, n) rep(j, 5) rep(k, 2) {
      if ((bit & 1<<(j+5*k)) && f[i][j][k]) ++c[i]; 
    }
    int now = 0;
    rep(i, n) now += p[i][c[i]];
    ans = max(ans, now);
  }
  cout << ans << endl;
  return 0;
}

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

long long memo[81]{ 0 };
long long lucas(long long n) {
	if (n == 0) {
		return 2;
	}
	if (n == 1) {
		return 1;
	}
	else {
		if (memo[n] != 0) {
			return memo[n];
		}
		return memo[n] = lucas(n - 1) + lucas(n - 2);
	}
}

int main()
{
	long long n;
	cin >> n;
	cout << lucas(n) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<a*b/2;
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int a, b, cnt=0;
    cin >> a >> b;

    REP(i, 2){
        cnt += max(a, b);
        if(a >= b) a -= 1;
        else b -= 1;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp ": "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(__typeof(a)i=(a);i<=(b);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define db(something)   cerr<<#something<<" - "<<something<<"\n";         
int main()
{
  
   Ezio
   /*Variables*/
   /*Code*/
   int t=0, n;
   while(cin>>n){
     t++;
     if(n==0){
       cout<<t<<endl ;
       return 0;
       }
   }
   return 0;
}
    

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  
  int A[N];
  for(int i = 0; i < N; i++) scanf("%d", A + i);
  
  long long cnt = 0;
  int now = -1;
  for(int i = 0; i < N; i++){
    if(A[i] == now + 1){
      now++;
    }else if(A[i] <= now){
      cnt += now;
      now = A[i];
    }else{
      cnt = -1;
      break;
    }
  }
  if(A[N - 1] == now) cnt += now;
  
  printf("%lld", cnt);
  
  return 0;
}

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

#define INF             1e9
#define INFL            1e19
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cout << endl;
#define HOISE           cerr << "hoise" << endl
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << endl
#define READ            freopen("alu.txt", "r", stdin)
#define WRITE           freopen("vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)

#define MASK(x)         for(int i = 0; i < 8; i++){ if(x&(1<<i)){ cout << i << " "; } } cout << endl;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX = 3000 + 2;
const int MAXLOG = log2(MAX) + 2;
const int MAXN = 1e6 + 2;
const int MOD = 1000000007;

struct data{
    int a, b;
};
bool operator < (const data &ob1, const data &ob2)
{
    return ob1.a < ob2.a;
}


int n, t;
data arr[MAX];
int dp[MAX][MAX];

int re(int i, int timpassed)
{
    if(i >= n) return 0;
    if((double)timpassed >= (double)t-0.5) return 0;
    int &ret = dp[i][timpassed];
    if(ret != -1) return ret;

    ret = re(i+1, timpassed);
    ret = max(ret, arr[i].b + re(i+1, timpassed+arr[i].a));
    return ret;
}

int main()
{
//    READ;
//    WRITE;
    FASTIO;

    cin >> n >> t;
    for(int i = 0; i < n; i++)
        cin >> arr[i].a >> arr[i].b;

    sort(arr, arr+n);

    memset(dp, -1, sizeof dp);
    cout << re(0, 0);

    return 0;
}


Measured memory_bytes: 35584
s = input()

count = 0
ac = 0
abc = 0
carry = 0
for c in s:
    if c == 'A':
        ac += 1
        abc = 1
    elif c == 'B':
        if abc == 1:
            carry = ac
            abc = 2
        else:
            abc = 0
        ac = 0
    elif c == 'C':
        if abc == 2:
            count += carry
            ac = carry
            abc = 1
        else:
            ac = 0
            abc = 0
print(count)

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;long long x[200000],s[200000][3],n,m,b[200000],sum,i,j;main(){cin>>n>>m;for(i=1;i<=m;i++){cin>>b[i];if(i>=2){for(j=b[i-1];j<b[i];j++){x[j]++;}for(j=b[i];j<b[i-1];j++){x[j]++;}}}for(i=1;i<n;i++){cin>>s[i][0]>>s[i][1]>>s[i][2];}for(i=1;i<n;i++){sum+=min(s[i][0]*x[i],s[i][1]*x[i]+s[i][2]);}cout<<sum<<endl;return 0;}

Measured memory_bytes: 7008
s = input()

ki = s[1::2]
gu = s[::2]


cnt_1 = 0
cnt_2 = 0

#奇数を1，偶数を0に
for i in ki:
    if i == '0':
        i = 1
        cnt_1 += 1
for i in gu:
    if i == '1':
        i = 0
        cnt_1 += 1

#奇数を0，偶数を1に
for i in ki:
    if i == '1':
        i = 0
        cnt_2 += 1
for i in gu:
    if i == '0':
        i = 1
        cnt_2 += 1
ans = [cnt_1,cnt_2]
print(min(ans))

Measured memory_bytes: 3188
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

// 隣り合う頂点同士の距離が奇数だったら絶対に同じ色にならない
//

int main() {
    int N;
    cin >> N;
    auto G = vectors(make_pair(0, 0), N, 0);
    for (int i = 0; i < N - 1; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        --u, --v;
        G[u].emplace_back(v, w);
        G[v].emplace_back(u, w);
    }

    // for (int i = 0; i < N; ++i) {
    //     cout << "i: " << i << endl;
    //     for (auto pa : G[i]) {
    //         cout << pa.first << " " << pa.second << endl;
    //     }
    // }

    vector<int> color(N, -1);
    auto dfs = [&](auto f, int cur, int col, int x) -> void {
        color[cur] = col;
        for (auto &elem : G[cur]) {
            int to = elem.first, dx = elem.second;
            if (color[to] == -1) {
                if ((x + dx) % 2 == 0)
                    f(f, to, 1, x + dx);
                else
                    f(f, to, 0, x + dx);
            }
        }
    };
    dfs(dfs, 0, 1, 0);
    for (int col : color) {
        cout << col << endl;
    }
    return 0;
}

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

int main(){
  long long x, y; cin >> x >> y;
  long long a, b, c, d;
  a=y-x;
  b=y+x+1;
  c=-y-x+1;
  d=-y+x+2;
  if(a<0){
    a=1e10;
  }
  if(b<0){
    b=1e10;
  }
  if(c<0){
    c=1e10;
  }
  if(d<0){
    d=1e10;
  }
  cout << min({a,b,c,d}) << endl;
}
  

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

#define ff(i,a,b) for (int i = a; i < b; i++) 
#define bf(i,a,b) for (int i = a; i >= b; i--) 
#define all(v) v.begin(),v.end() 
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define F first 
#define S second
#define pb push_back
#define mp make_pair
#define lb lower_bound   
#define ub upper_bound
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define one cout<<"-1"<<endl
#define pi 3.141592653589793238
#define mod 1000000007
#define intmx INT_MAX 
#define intmi INT_MIN
int cnt;
bool visited[200001];
map<int,set<int> > m;
void dfs(int node){
    visited[node]=1;
    cnt++;
    for(auto i:m[node]){
        if(!visited[i]){
            dfs(i);
        }
    }
}
void solve(){
    int n,tt;
    cin>>n>>tt;
    memset(visited,0,sizeof(visited));
    while(tt--){
        int a,b;
        cin>>a>>b;
        m[a].insert(b);
        m[b].insert(a);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!visited[i]){
            cnt=0;
            dfs(i);
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
    
}
signed main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}


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

int A[1000000], n;

int binary(int key)
{
    int left=0, mid, right=n;

    while (left < right) {
        mid = (left + right)/2;
        if (A[mid] ==key) return 1;
        else if (key < A[mid]) right = mid;
        else left = mid + 1;
    }
    return 0;
}

int main()
{
    int q, k, sum=0;

    scanf("%d", &n);
    for (int i=0; i<n; ++i) scanf("%d", &A[i]);

    scanf("%d", &q);
    for (int i=0; i<q; ++i) {
        scanf("%d", &k);
        if ( binary(k) ) sum++;
    }
    printf("%d\n", sum);

    return 0;
}



Measured memory_bytes: 3516
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let d: Vec<usize> = (0..n)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();
    if d[0] != 0 {
        return "0".to_string();
    }

    let mut counts: HashMap<usize, usize> = HashMap::new();
    for i in 0..n {
        *counts.entry(d[i]).or_insert(0) += 1;
    }

    if !counts.contains_key(&0) || *counts.get(&0).unwrap() != 1 {
        return "0".to_string();
    }

    let mut ans: usize = 1;
    let d_max: usize = *d.iter().max().unwrap();
    for i in 1..(d_max + 1) {
        if !counts.contains_key(&i) {
            return "0".to_string();
        }
        let a = counts.get(&(i - 1)).unwrap();
        let b = counts.get(&i).unwrap();
        ans = ans * mod_pow(*a, *b) % MOD
    }
    return ans.to_string();
}

const MOD: usize = 998244353;

fn mod_pow(a: usize, b: usize) -> usize {
    let mut result = 1;
    for _ in 0..b {
        result = result * a % MOD;
    }
    return result
}


Measured memory_bytes: 14588
#include <stdio.h>



int main(){
    int n, i,ans=0;
 
    scanf("%d",&n);
    int data[n];
       int top=0,head=n-1;
    
    for (i=0;i<n;i++){
        scanf("%d",&data[i]);
        
    }
    while(top <=head){
        if(ans <0){
            ans+=data[top];
            top+=1;
        }else{
            ans-=data[head];
            head-=1;
            
        }
       
    }  
    if(ans <0){ans*=-1;}
    printf("%d\n",ans);
   
    return 0;
}


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

int main() {
  int N;
  int A[210];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  int res = 0;

  while (true) {
    bool odd = false;
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 != 0) odd = true;
    }
    if (odd) break;
    for (int i = 0; i < N; i++) {
      A[i] /= 2;
    }
    res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
aryArySize = gets.split.map(&:to_i);
aryCalculation1 = Array.new(aryArySize[0]).map{Array.new(aryArySize[1],0)};

for num1 in 0..aryArySize[0]-1 do
	
	aryInputLines = gets.split.map(&:to_i);
	
	for num2 in 0..aryArySize[1]-1 do
	
		aryCalculation1[num1][num2] = aryInputLines[num2];
		
	end
	
end

aryCalculation2 = Array.new(aryArySize[1]);

for num in 0..aryArySize[1]-1 do
	
	aryCalculation2[num] = gets.to_i;
	
end

for num1 in 0..aryArySize[0]-1 do
	
	sum = 0;
	
	for num2 in 0..aryArySize[1]-1 do
	
		sum += aryCalculation1[num1][num2] * aryCalculation2[num2];
		
	end
	
	puts sum.to_s;
	
end

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

int main() {
  int N,j,i;
  cin>>N;
  vector<int> num(N);
  vector<int> ren(N);
  for(i=0;i<N;i++)cin>>num[i];
  for(j=0;j<N;j++){
    for(i=0;i<N;i++){
      if(ren[j]<num[i]){
        ren[j]=num[i];
      }
    }
    for(i=0;i<N;i++){
      if(ren[j]==num[i]){
        num[i]=0;
        break;
      }
    }
  }
  int sum=0;
  for(i=0;i<N;i++){
    if(i%2==0)sum+=ren[i];
    else sum-=ren[i];
  }
  cout<<sum<<endl;
}


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

int main() {
  int k;
  cin >> k;
  int ans = 0;

  for (int i = 0; i < k; i++){
    for (int j = 0; j < k; j++){
      for (int l = 0; l < k; l++){
        ans += __gcd(i + 1, __gcd(j + 1, l + 1));
      }
    }
  }
  cout << ans;

}

Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
	int a,b;
	scanf( "%u", &a );
	scanf( "%u", &b );
	int i = (1<<(a-1)) + (1<<(b-1));
	i ^= 7;
	printf("%d",(i==1) + ((i==2)*2) + ((i==4)*3) );
}


Measured memory_bytes: 128