akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
	long long n,a,b,r;
	scanf("%lld%lld%lld",&n,&a,&b);
	r=n%(a+b)<a?n%(a+b):a;
	n/=(a+b);
	printf("%lld",n*a+r);
	return 0;
}

Measured memory_bytes: 1724
n = int(input())
a = list(map(int, input().split()))

def lcm(x_, y_):
    x, y = max(x_, y_), min(x_, y_)
    while x%y > 0:
        x, y = y, x%y
    gcd = y
    return x_*y_//gcd

a_lcm = a[0]
for i in range(1, n):
    a_lcm = lcm(a_lcm, a[i])
ans = 0
for i in range(n):
    ans += (a_lcm-1)%a[i]
print(ans)


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int cnt = 0;
		for(int i = 0 ; i <= K ; i++) {
			for(int j = 0 ; j <= K ; j++) {
				if(S - i - j >= 0 && S - i - j <= K) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

vector <string> rotate90 (vector <string> src )
{
	int size = src.size();
	vector <string> res (8, string(8, ' ' ) );

	int i,j;
	
	for (i = 0; i < size; ++i){
		for (j = 0; j < size; ++j){
			res[j][size - 1 - i] = src[i][j];
 		} // end for
	} // end for

	return res;
}

void disp_pattern (vector <string> p )
{
	int size = p.size();
	int i,j;

	for (i = 0; i < size; ++i){
		for (j = 0; j < size; ++j){
			cout << p[i][j];
		} // end for
		cout << endl;
	} // end for
}

int main()
{
	const string ang[] = { "90", "180", "270" };

//	cut here before submit 
//	freopen ("testcase.pattern", "r", stdin );
	string str = "";
	vector <string> pattern (8);
	int i;
	
	for (i = 0; i < 8; ++i){
		getline (cin, str );
		pattern[i] = str;
	} // end for

	vector <string> res;

	// for debug
//	disp_pattern (pattern );

	for (i = 0; i < 3; ++i){
		res = rotate90 (pattern );
		cout << ang[i] << endl;
		disp_pattern (res );
		pattern = res;
	} // end for

	return 0;
}

Measured memory_bytes: 0
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int64_t N, K;
  cin >> N >> K;
  cout << min(N, (N / K + (N % K ? 1 : 0)) * K - N) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;
using P = pair<int, int>;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main(void) {

    ios::sync_with_stdio(false); cin.tie(0);

    ll n, a, b;
    cin >> n >> a >> b;

    if (!a && !b) {
        cout << 0 << endl;
        return 0;
    }
    if (a + b >= n) {
        cout << min(n, a);
    }
    else {
        ll ans = n / (a + b) * a;
        ans += min(a, n % (a+b));
        cout << ans;
    }
    
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)

ll a[3];

int main() {
    rep(i,3) cin >> a[i];
    sort(a,a+3);
    if (a[0] == a[1] && a[1] == a[2]){
        cout << "Yes" <<endl;
    }
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 200005
#define pb push_back
#define vit vector<int>::iterator

int A[MAX],n,k;
int possible(int mid){
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=(A[i]-1)/mid;
    }
    if(sum<=k)
        return 1;
    return 0;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int mx=0,hi,lo,mid;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>A[i];
        mx=max(mx,A[i]);
    }
    lo=1;
    hi=mx;
    while(hi>lo){
        mid=(hi+lo)/2;
        if(possible(mid)) hi=mid;
        else lo=mid+1;
    }
    cout<<lo;
    return 0;
}


Measured memory_bytes: 4424
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int*,int);
void inputVector(vector<int>*,int);
template <typename T>
void output(T,int);

int main(){
	//source
	string s;
	ll k;
	cin >> s;
	cin >> k;

	char first='1';
	int first_index=0;
	rep(i,s.size()){
		if(s[i]!='1'){
			first=s[i];
			first_index=i+1;
			break;
		}
	}

	char ans='0';

	if(k<first_index){
		ans='1';
	}else{
		ans=first;
	}

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

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template<typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}


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

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

        int psg = (int)inpt[0];

        long tein = inpt[1];

        long weightMax = inpt[2];

        long[] list = new long[psg];
        for (int i = 0; i < psg; i++)
        {
            list[i] = long.Parse(Reader.ReadLine());
        }
        inpt = list.OrderBy(a => a).ToArray();


        int fromIdx = 0;
        long ans = 0;
        while (fromIdx < psg)
        {
            long count = 0;
            for (int i = fromIdx; i < inpt.Length; i++)
            {
                if (inpt[fromIdx] + weightMax < inpt[i])
                {
                    ans++;
                    fromIdx = i;
                    break;
                }
                count++;
                if (count >= tein || i == psg-1)
                {
                    ans++;
                    fromIdx = i + 1;
                    break;
                }
            }
        }
        Console.WriteLine(ans);
    }


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


6 3 3
7
6
2
8
10
6


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 20700
use std::cmp::{max, min};
use std::collections::BTreeMap;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, lr: [(usize, usize); n]);
    let mut lr: Vec<(usize, usize)> = lr.iter().map(|&(l, r)| (l, r + 1)).collect();
    let (rmin, _, rmini) = lr
        .iter()
        .enumerate()
        .map(|(i, &(l, r))| (r, r - l, i))
        .min()
        .unwrap();
    let (lmax, _, lmaxi) = lr
        .iter()
        .enumerate()
        .map(|(i, &(l, r))| (l, r - l, i))
        .max()
        .unwrap();
    let mut ret = 0;
    for &(l, r) in lr.iter() {
        ret = max(ret, r.saturating_sub(l) + rmin.saturating_sub(lmax));
    }

    lr.sort_by_key(|&(l, r)| (r, l));
    let mut ls = !0;
    let mut rs = rmin.saturating_sub(lmax);
    for &(l, r) in lr.iter() {
        rs = r.saturating_sub(lmax);
        if ls != !0 {
            ret = max(ret, ls + rs);
        }
        ls = min(ls, rmin.saturating_sub(l));
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 10620
#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>;

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> d(n);
  rep(i,n) {
    cin >> d[i];
  }
  int cnt = 0;
  rep(i,n) {
    if (d[i] >= k) cnt++;
  }
  
  cout << cnt <<  endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define gcd(m,n)        __gcd(m,n)
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz               size()
#define inc(i,x,y)      for(int i=x;i<=y;i++)
#define dec(i,x,y)      for(int i=x;i>=y;i--)



#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif

void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}

//////////////////////////////code//////////////////////////////

int32_t main()
{
  fast();

  int n,k;
  cin>>n>>k;
  mii m;

  inc(i,0,k-1)
  {
      int d;
      cin>>d;
     inc(j,0,d-1)
     {
         int r;
         cin>>r;
         m[r]++;
     }
  }

  cout<<n-m.sz;








}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 998244353;
const int MAX_NM = 200005;
ll fac[MAX_NM], finv[MAX_NM], inv[MAX_NM];

ll pow(ll n, ll x)
{
	if (x == 0) return ll(1);
	if (x == 1) return n % MOD;
	if (x % 2 == 0)
	{
		ll p = pow(n,x/2);
		return p * p % MOD;
	}
	else
	{
		return n * pow(n,x-1) % MOD;
	}
}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_NM; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	COMinit();
	ll N,M,K;
	cin >> N >> M >> K;
	ll ans = 0;
	rep(i,K+1)
	{
		ans = (ans + COM(N-1,i) * pow(M-1,N-ll(i)-1) % MOD) % MOD;
	}
	ans = ans * M % MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8328
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
char b;
signed main(){
    cin>>b;
    if(b=='A')cout<<"T"<<endl;
    else if(b=='T')cout<<"A"<<endl;
    else if(b=='C')cout<<"G"<<endl;
    else cout<<"C"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
	char suit;
	int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
	int i, j, k;
	int n1 = mid -left;
	int n2 = right - mid;
	for(i=0; i<n1; i++) L[i] = A[left + i];
	for(i=0; i<n2; i++) R[i] = A[mid + i];
	L[n1].value = R[n2].value = SENTINEL;
	i = j = 0;
	for(k=left; k<right; k++){
		if(L[i].value <= R[j].value)
		{
			A[k] = L[i++];
		}
		else
		{
			A[k] = R[j++];
		}
	}
}

void mergeSort(struct Card A[], int n, int left, int right)
{
	int mid;
	
	if(left+1 < right){
		mid = (left+right)/2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int partition(struct Card A[], int n, int p, int r){
	int i, j;
	struct Card t, x;
	x = A[r];
	i = p-1;
	for(j=p; j<r; j++){
		if(A[j].value <= x.value)
		{
			i++;
			t = A[i];
			A[i] = A[j];
			A[j] = t;
		}
	}
	t=A[i+1];
	A[i+1] = A[r];
	A[r] = t;
	return i+1;
}


void quickSort(struct Card A[], int n, int p, int r){
	int q;
	if(p < r)
	{
		q = partition(A,n,p,r);
		quickSort(A, n, p, q-1);
		quickSort(A, n, q+1, r);
	}
}


int main()
{
	int n, i, v;
	struct Card A[MAX], B[MAX];
	char S[10];
	int stable = 1;
	
	scanf("%d", &n);
	
	for(i=0; i<n; i++){
		scanf("%s %d",S, &v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}
	
	mergeSort(A, n, 0, n);
	quickSort(B, n, 0, n-1);
	
	for(i=0; i<n; i++){
		if(A[i].suit != B[i].suit) stable = 0;
	}
	
	if(stable == 1) printf("Stable\n");
	else printf("Not stable\n");
	for(i=0; i<n; i++){
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	
	return 0;
}



Measured memory_bytes: 4060
def main():
    SS = 0
    s1 = []
    s2 = []
    l = raw_input()
    for b in range(len(l)):
        c = l[b]
        if c == '\\':
            s1.append(b)
        elif c == "/":
            if not len(s1) == 0:
                a  = s1.pop()
                s  = b-a
                SS += s
                while not len(s2) == 0:
                    sigma,alpha,beta = s2.pop()
                    if alpha>a and beta<b:
                        s = s + sigma
                    else:
                        s2.append([sigma,alpha,beta])
                        break
                s2.append([s,a,b])
        
    print SS
    print len(s2),
    for item in s2[:-1]:
        print item[0],
    if not len(s2) == 0:
        print s2[-1][0]


if __name__ == "__main__":
    main()

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

signed main() {
  int n, a, b;
  cin >> n >> a >> b;

  int cycle = a + b;
  int loop = n / cycle;

  int blue = a * loop;
  int left = n - cycle * loop;

  left = min(left, a);
  blue += left;

  cout << blue << '\n';
}



Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>

int main()
{
	std::string A;

	std::cin >> A;

	int digit = A.size();
	int count = 0;

	std::vector<std::string> numbers = { "3", "5", "7" };
	std::vector<std::string> targetNumbers = numbers;

	auto Add357 = [&targetNumbers](std::vector<std::string>& src) {
		std::vector<std::string> temp;
		const std::string str357 = "357";

		for (auto&& str : src) {
			for (auto&& ch : str357) {
				temp.push_back(str + ch);
			}
		}

		targetNumbers.insert(targetNumbers.end(), temp.begin(), temp.end());

		return temp;
	};

	for (int i = 1; i < digit; i++) {
		numbers = Add357(numbers);
	}

	int maxNumber = std::stoi(A);

	for (auto&& number : targetNumbers) {
		if (maxNumber < std::stoi(number)) {
			continue;
		}

		if (number.find_first_of('7') == std::string::npos) {
			continue;
		}

		if (number.find_first_of('5') == std::string::npos) {
			continue;
		}

		if (number.find_first_of('3') == std::string::npos) {
			continue;
		}

		count++;
	}

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 2428
import copy

N, Ma, Mb = [int(n) for n in input().split()]
pd = {(0,0):0}
for i in range(N):
    a, b, c = [int(n) for n in input().split()]
    pdcopy = copy.deepcopy(pd)
    for k, v in pdcopy.items():
        nk = (k[0]+a, k[1]+b)
        if nk in pd:
            if pd[nk] > v + c :
                pd[nk] = v + c
        else:
            pd[nk] = v + c

mp = 1000000
for i in range(1,401):
    if (Ma*i, Mb*i) in pd:
        mp = min(pd[(Ma*i, Mb*i)], mp)

if mp == 1000000:
    print(-1)
else:
    print(mp)


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

int main()
{
  int n,m;
  cin >> n >> m;
  char a[n][m];
  int minpos_crr=100;
  int minpos_prev=-1;
  int maxpos_crr=-1;
  int cnt=0;
  bool found =false;
 int v=0;
  for(int i=0;i<n;i++)
   {
     cnt=0;
     //cout <<1<<" "<<(++v)<<"\n";
     for(int j=0;j<m;j++)
      {
        //cout <<2<<" "<<(++v)<<"\n";
        cin >> a[i][j];
        if(a[i][j]=='#')
         {
           cnt++;
           maxpos_crr=max(maxpos_crr,j);
           minpos_crr=min(minpos_crr,j);
         }

      }
      if(minpos_crr!=minpos_prev && i>0)
       found=true;
       minpos_prev=maxpos_crr;
       minpos_crr=100;
      if(!cnt)
       found=true;
   }

   if(found)
    cout << "Impossible"<<"\n";
  else
   cout << "Possible"<<"\n";
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <ctype.h>
#include <string.h>

#define lli long long int
int main(void)
{
	lli n;
	scanf("%lld", &n);
	lli *a;
	lli *b;
	a = (lli *)malloc(sizeof(lli)*(n+1));
	b = (lli *)malloc(sizeof(lli)*(n+1));
	lli i = 0;
	while (i < n+1)
	{
		scanf("%lld",&a[i]);
		i++;
	}
	i = 0;
	while (i < n)
	{
		scanf("%lld",&b[i]);
		i++;
	}
	i = 0;
	lli tmp = 0;
	lli sum = 0;
	while (i < n)
	{
		if (a[i] > b[i])
		{
			tmp = b[i];
		}
		else if (a[i] + a[i+1] > b[i])
		{
			tmp = b[i];
			a[i+1] = a[i+1] - (b[i] - a[i]);
		}
		else
		{
			tmp = a[i] + a[i+1];
			a[i+1] = 0;
		}
		sum += tmp;
		i++;
	}
	printf("%lld\n",sum);
	return (0);
}


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

struct Card {char suit, value;};

void bubble(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        for(int j = N - 1; j >= i + 1; j--){
            if(A[j].value < A[j - 1].value){
                Card t = A[j];
                A[j] = A[j - 1];
                A[j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i];
        A[i] = A[minj];
        A[minj] = t;
    }
}

void print(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        if(i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for(int i = 0; i < N; i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    for(int i = 0; i < N; i++) C2[i] = C1[i];

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if(isStable(C1, C2, N)){
        cout << "Stable" << endl;    
    } else{
        cout << "Not stable" << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 10000000000

int main() {
	long long a, bi, ans;
	double b;
	cin >> a >> b;

	bi = round(b * 100);
	ans = a * bi;
	ans /= 100;

	cout << ans;
	return 0;
}

Measured memory_bytes: 3592
H,W=list(map(int,input().split()))
N=int(input())
a=list(map(int,input().split()))

c=[['']*W for _ in range(H)]
visit=[[0]*W for _ in range(H)]

q=[[0,0,1]]

while len(q)>0:
    h,w,clr=q.pop()
    visit[h][w]=1
    c[h][w]=str(clr)
    a[clr-1]-=1
    if a[clr-1]==0:
        clr+=1

    if h+1<H and visit[h+1][w]==0:
        q.append([h+1,w,clr])
    elif 0<h and visit[h-1][w]==0:
        q.append([h-1,w,clr])
    elif w+1<W and visit[h][w+1]==0:
        q.append([h,w+1,clr])
    
for i in range(H):
    print(' '.join(c[i]))

Measured memory_bytes: 41072
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int H, W, D; cin >> H >> W >> D;

  vector < pair<int, int> > location(H * W);

  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      int A; cin >> A; A--;
      location[A] = make_pair(i, j);
    }
  }
  
  vector < vector<int> > point(D);

  for (int i = 0; i < H * W; i++){
    if (i < D){
      point[i].push_back(0);
    }else{
      pair <int, int> now = location[i], past = location[i - D];
      int P = abs(now.first - past.first) + abs(now.second - past.second);
      P += point[i % D][i / D - 1];
      point[i % D].push_back(P);
    }
  }
  

  int Q; cin >> Q;

  for (int i = 0; i < Q; i++){
    int L, R; cin >> L >> R;
    L--; R--;

    int now = R % D;
    cout << point[now][R / D] - point[now][L / D] << endl;

  }
  
  
  return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define int long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

void solve() {

	int n;
	cin >> n;

	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];

	string s;
	cin >> s;

	vector<int> gauss(60, -1);

	for (int i = v.size() - 1; i >= 0; i--) {

		if (s[i] == '0') {
			int cur = v[i];
			for (int j = 59; j >= 0; j--) {
				if (!((1LL<<j)&cur)) continue;
				if (gauss[j] == -1) {
					gauss[j] = cur;
					break;
				}

				cur ^= gauss[j];
			}
		}

		else {
			int cur = v[i];
			for (int j = 59; j >= 0; j--) {
				if (!((1LL<<j)&cur)) continue;
				if (gauss[j] == -1) {
					cout << "1\n";
					return;
				}

				cur ^= gauss[j];
			}
		}
	}

	cout << "0\n";

}

main(){
#ifdef LOCAL
	freopen("G_input.txt", "r", stdin);
	//freopen("G_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int t;
	cin >> t;

	for (int i = 0; i < t; ++i) solve();

}


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

using namespace std;

int main(){
  long long R[400009];
  string s;
  cin >> s;
  long long n = s.length();
  map<char, int> mp;
  for(int i=0;i<n;i++)mp[s[i]]++;
  long long ans=n*(n-1)/2;
  for(auto& p: mp){
    long long value=p.second;
    ans -= value*(value-1)/2;
  }
  cout << ans+1 << endl;
}



Measured memory_bytes: 3736
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    for (int i = 0; i < 3; ++i) {
        int h1, m1, s1, h2, m2, s2;
        cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
        int t = (h2-h1)*3600+(m2-m1)*60+s2-s1;
        printf("%d %d %d\n", t/3600, t/60%60, t%60);
    }
    return 0;
}



Measured memory_bytes: 3156
H,W = map(int,input().split())

MAP=  [[0 for i in range(W)] for i in range(H)]

HLIST=[0 for i in range(H)]
WLIST=[0 for i in range(W)]

for h in range(H):
    L=list(input())
    MAP[h]=L
    for w in range(W):
        if(MAP[h][w]=="#"):
            HLIST[h]+=1
            WLIST[w]+=1
for h in range(H):
    if(HLIST[h]!=0):
        for w in range(W):
            if(WLIST[w]!=0):
                if(MAP[h][w]=="#"):
                    print("#",end="")
                else:
                    print(".",end="")
        print("")



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

int main()
{
    int yyy,mmm,ddd;
    char a,b;
    cin >> yyy >> a >> mmm >> b >> ddd;

    if (mmm <= 4) {
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
def main():
    h,w = map(int, input().split())
    sl = []
    for _ in range(h):
        sl.append(list(input()))

    left_cnts = []
    for hi, row in enumerate(sl):
        curr_left_cnts = []
        curr_cnt = 0
        for i, s in enumerate(row):
            if s == '.':
                curr_left_cnts.append(curr_cnt)
                curr_cnt += 1
            else:
                curr_left_cnts.append(-1)
                curr_cnt = 0
        left_cnts.append(curr_left_cnts)


    right_cnts = []
    for hi, row in enumerate(sl):
        curr_right_cnts = []
        curr_cnt = 0
        for i, s in enumerate(row[::-1]):
            if s == '.':
                curr_right_cnts.append(curr_cnt)
                curr_cnt += 1
            else:
                curr_right_cnts.append(-1)
                curr_cnt = 0
        curr_right_cnts = curr_right_cnts[::-1]
        right_cnts.append(curr_right_cnts)


    sl_t = [list(x) for x in zip(*sl)]
    left_cnts_t = []
    for hi, row in enumerate(sl_t):
        curr_left_cnts = []
        curr_cnt = 0
        for i, s in enumerate(row):
            if s == '.':
                curr_left_cnts.append(curr_cnt)
                curr_cnt += 1
            else:
                curr_left_cnts.append(-1)
                curr_cnt = 0
        left_cnts_t.append(curr_left_cnts)


    right_cnts_t = []
    for hi, row in enumerate(sl_t):
        curr_right_cnts = []
        curr_cnt = 0
        for i, s in enumerate(row[::-1]):
            if s == '.':
                curr_right_cnts.append(curr_cnt)
                curr_cnt += 1
            else:
                curr_right_cnts.append(-1)
                curr_cnt = 0
        curr_right_cnts = curr_right_cnts[::-1]
        right_cnts_t.append(curr_right_cnts)


    ans = 0
    for hi in range(h):
        for wi in range(w):
            if sl[hi][wi] == '#':continue
            cnt = left_cnts[hi][wi] + right_cnts[hi][wi] + left_cnts_t[wi][hi] + right_cnts_t[wi][hi]
            ans = max(ans, cnt)

    print(ans+1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 396868
////////////////////////////////////////////////////////////////////////
//ファイル名：ITP_1_6_C_Official House.c
//内容；4つの建物を管理します。それぞれの建物には3つのフロアがあり、
//      それぞれが10の部屋で構成されています。
//      テナント通知を読み取り、各部屋のテナント数を報告するプログラム
//
//入力：通知の数 n, 建物bのf階の部屋rにv人が入室したことを表す
//      4つの整数b、f、r、およびv
//
//出力：建物ごとに1階、2階、3階の情報を表示する。
//      建物の間に "####################"（20 '＃'）を出力する。
//
//制約：n ≧ 0
////////////////////////////////////////////////////////////////////////

#include <stdio.h>

#define BULDING_NUM_MIN 1
#define BULDING_NUM_MAX 4
#define FLOOR_NUM_MIN 1
#define FLOOR_NUM_MAX 3
#define ROOM_NUM_MIN 1
#define ROOM_NUM_MAX 10
#define PEOPLE_NUM_MIN -9
#define PEOPLE_NUM_MAX 9


int main()
{
    int t[BULDING_NUM_MAX][FLOOR_NUM_MAX][ROOM_NUM_MAX] = {0};  //建物情報用の配列
    int b,f,r,v;            //b:建物 f:階層 r:部屋 v:人数
    int i,j,k;              //for文用
    int n;                  //通知数

    //通知数を入力
    scanf("%d", &n);

    //制約の範囲外ならエラーメッセージを出力
    if(n <= 0 )
    {
        printf("Invalid Input\n");
        return 0;
    }

    //通知情報を入力
    for(i=0; i<n; i++)
    {
        scanf("%d%d%d%d", &b,&f,&r,&v);

        //制約の範囲外ならエラーメッセージを出力
        if( b < BULDING_NUM_MIN || b > BULDING_NUM_MAX ||
            f < FLOOR_NUM_MIN || f > FLOOR_NUM_MAX ||
            r < ROOM_NUM_MIN || r > ROOM_NUM_MAX ||
            v < PEOPLE_NUM_MIN || v > PEOPLE_NUM_MAX)
        {
            printf("Invalid Input\n");
            return 0;
        }

        t[b-1][f-1][r-1] = t[b-1][f-1][r-1] + v;
    }

    //各建物の情報を順に出力
    for(i=0; i<BULDING_NUM_MAX; i++)
    {
        for(j=0; j<FLOOR_NUM_MAX; j++)
        {
            for(k=0; k<ROOM_NUM_MAX; k++)
            {
                printf(" %d", t[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3)
        {
            printf("####################\n");
        }
        
    }

    return 0;
}


Measured memory_bytes: 2096
# coding: utf-8
N = gets.to_i
H = gets.split(" ").map{|e| e.to_i}
ans = 0
cnt = 0
# 全部の要素分ループ
H.each_with_index do |e, i|
  # 移動できるまでカウント
  next if i == 0
  # 移動できなかったら、カウンタを今までのものと比較して
  # 記録更新していたら変数を更新
  if e <= H[i-1]
    cnt += 1
  else
    ans = [ans, cnt].max
    cnt = 0
  end
end
ans = [ans, cnt].max
puts ans


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

int n, ans;
unordered_map<int, int> h;

int main()
{
	int i, x, y;
	cin >> n;
	
	for (i=0; i<n; ++i)
	{
		cin >> x;
		++h[x];
	}
	
	for (auto j=h.begin(); j!=h.end(); ++j)
	{
		x=j->first;
		y=j->second;
		
		if (y<x) ans+=y;
		if (y>x) ans+=y-x;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4260
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi >
#define vvvi vector<vvi >
#define pii pair<int,int>
#define INF 1e9
#define MOD 1e9+7
typedef long long llong;
using namespace std;

int main(){
	int a,p;
	cin>>a>>p;
	
	cout<<(3*a+p)/2<<endl;
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n, p;
  cin >> n >> p;
  vi a(n);
  rep(i, 0, n) {
    cin >> a[i];
    a[i] %= 2;
  }

  i64 ans = 0;
  if(!count(all(a), 1)) {
    if(!p) ans = 1ll << n;
  }
  else ans = 1ll << (n - 1);
  cout << ans << endl;
}


Measured memory_bytes: 256
//ABC163 A

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint n;
lint a[300000];


int main() {
  cin >> n;

/*   rep(i,n){
    scanf("%lld",&a[i]);
  } */

  
  printf("%lf\n",2*n*M_PI);
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


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

int N;
  cin>>N;

  bool OK=false;
  if(N%10==7)OK=true;
   if((N%100-N%10)==70)OK=true;
 if((N-N%100)/100==7)OK=true;
  
  if(OK){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}



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

int main() {
  int N, T; cin >> N >> T;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A.at(i) >> B.at(i);
  // dp1[i][j] := i 番目の料理までで j 分以内に完食できる、満足度の最大値
  vector<vector<int>> dp1(N+1, vector<int>(T, 0));
  // dp2[i][j] := i 番目以降の料理で j 分以内に完食できる、満足度の最大値
  vector<vector<int>> dp2(N+1, vector<int>(T, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < T; j++) {
      dp1.at(i+1).at(j) = max(dp1.at(i+1).at(j), dp1.at(i).at(j));
      if (j - A.at(i) >= 0) {
        dp1.at(i+1).at(j) = max(dp1.at(i+1).at(j), dp1.at(i).at(j - A.at(i)) + B.at(i));
      }
    }
  }
  for (int i = N-1; i >= 0; i--) {
    for (int j = 0; j < T; j++) {
      dp2.at(i).at(j) = max(dp2.at(i).at(j), dp2.at(i+1).at(j));
      if (j - A.at(i) >= 0) {
        dp2.at(i).at(j) = max(dp2.at(i).at(j), dp2.at(i+1).at(j - A.at(i)) + B.at(i));
      }
    }
  }
  int ans = 0;
  // 料理 i を最後に食べるとする
  for (int i = 0; i < N; i++) {
    int sum = 0;
    for (int j = 0; j < T; j++) {
      int tmp = B.at(i);
      tmp += dp1.at(i).at(j);  // i-1 番目までの料理
      tmp += dp2.at(i+1).at(T-j-1);  // i+1 番目以降の料理
      sum = max(sum, tmp);
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 70912
#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int (i)=0;(i)<(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(n);(i)++)
#define MOD 1000000007

typedef long long ll;

const int MAX = 2e6 + 5;

int h,w;
char a[102][102];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>h>>w;
	REP1(i, h){
		REP1(j, w){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<=h+1;i++){
		for(int j=0;j<=w+1;j++){
			if(i == 0 || j == 0 || i == h+1 || j == w+1)
				cout<<'#';
			else
				cout<<a[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import heapq


def link(x, y):
    if rank[x] > rank[y]:
        p[y] = x
    else:
        p[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1


def find_set(x):
    if x != p[x]:
        p[x] = find_set(p[x])
    return p[x]


def unite(x, y):
    link(find_set(x), find_set(y))


def same(x, y):
    x = find_set(x)
    y = find_set(y)
    if x == y:
        return True
    else:
        return False


h = []

line = sys.stdin.readline()
v, e = map(int, line.split())
p = [i for i in range(v)]
rank = [0 for _ in range(v)]

for i in range(e):
    line = sys.stdin.readline()
    s, t, w = map(int, line.split())
    heapq.heappush(h, (w, s, t))

s = 0
for i in range(e):
    elm = heapq.heappop(h)
    if not same(elm[1], elm[2]):
        s = s + elm[0]
        unite(elm[1], elm[2])

print(s)



Measured memory_bytes: 23336
#include <iostream>

using namespace std;

int gcd(int x, int y) {
    int tmp;
    
    while(y != 0) {
        tmp = x % y;
        x = y;
        y = tmp;
    }
    
    return x;
}

int main() {
    int a, b;
    
    cin >> a >> b;
    
    int ans = gcd(a, b);
    
    cout << ans << endl;
    
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  int i;
  for (i=0; i<N; i++) cin >> mochi.at(i);
  sort(mochi.begin(), mochi.end());
  int sum=1;
  for (i=0; i<N; i++){
    if (i!=0){
    if (mochi.at(i)!=mochi.at(i-1)) sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char S[1001000];
int a[100100],n;
int main(){
	scanf("%s",S+1);
	n=strlen(S+1);
	for(int i=1;i<=n;i++)a[i]=S[i]-'0';
	if(a[n]==1||a[1]==0)return puts("-1"),0;
	for(int i=1;i<n;i++)
		if(a[i]!=a[n-i])return puts("-1"),0;
	int root=1;
	for(int i=1;i<n;i++){
		printf("%d %d\n",root,i+1);
		if(a[i]==1) root=i+1;
	}	
}

Measured memory_bytes: 3660
import sys
for i in range(sys.maxsize):
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    else:
        for j in range(h):
            if j == 0 or j == h-1:
                print("#"*w)
            else:
                print("#"+"."*(w-2)+"#")
    print("")


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

const int MAX = 100000;
const int NIL = -1;
vector<int> G[MAX];
int n;
int color[MAX];

void dfs(int r, int c){
    stack<int> S;
    S.push(r);
    color[r] = c;
    while(! S.empty()){
        int u = S.top();
        S.pop();
        for(int i = 0; i <G[u].size(); ++i){
            int v = G[u][i];
            if(color[v] == NIL){
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor(){
    int id = 1;
    for(int i = 0; i < n; ++i) color[i] = NIL;
    for(int u = 0; u < n; ++u){
        if(color[u] == NIL) dfs(u, id++);
    }
}

int main(){
    int s, t, m, q;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assignColor();
    cin >> q;
    for(int i = 0; i < q; ++i){
        cin >> s >> t;
        if(color[s] == color[t]){
            cout << "yes" << endl;
        }
        else{
            cout << "no" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 8940
use std::io::*;
use std::str::FromStr;

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let line = parse_line::<String>();
    let mut iter = line.split_whitespace();
    (
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
    )
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

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

fn main() {
    let (m, d) = parse_pair::<usize, usize>();

    let mut count = 0;

    for cm in 1..m + 1 {
        for cd in 1..d + 1 {
            if cd >= 20 {
                let d_1 = cd % 10;
                if d_1 >= 2 {
                    let d_10 = cd / 10;
                    if d_1 * d_10 == cm {
                        count += 1;
                    }
                }
                
            }
        }
    }

    println(count);
}


Measured memory_bytes: 4352
local List = {}
function List.new ()
    return {first = 0, last = -1}
end

function List.pushleft (list, value)
    local first = list.first - 1
    list.first = first
    list[first] = value
end

function List.pushright (list, value)
    local last = list.last + 1
    list.last = last
    list[last] = value
end

function List.popleft (list)
    local first = list.first
    local value = list[first]
    list[first] = nil
    list.first = first + 1
    return value
end

function List.popright (list)
    local last = list.last
    local value = list[last]
    list[last] = nil
    list.last = last - 1
    return value
end

function List.empty (list)
    return list.first > list.last
end

----------

local n=io.read("n")
local graph={}
for i=1,n do
    graph[i]={}
end
for i=1,n-1 do
    local u,v,w=io.read("n","n","n")
    graph[u][v]=w
    graph[v][u]=w
end

local stack=List.new()
List.pushright(stack,{1,0})
local checked={}
local color={0}

while not List.empty(stack) do
    local pop=List.popright(stack)
    local u=pop[1]
    local w=pop[2]
    checked[u]=true
    for v,_ in pairs(graph[u]) do
        if not checked[v] then
            local nw=w+graph[u][v]
            color[v]=nw%2
            List.pushright(stack,{v,nw})
        end
    end
end

for i=1,n do
    print(color[i])
end

Measured memory_bytes: 32564
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)

int main(){
    int N,K,Q;
   cin>>N>>K>>Q;
   int A[Q],point[N]={0};
   rep(i,Q){
       cin>>A[i];
       point[A[i]-1]++;
   }
   rep(i,N){
       if(K+point[i]-Q>0){
           cout<<"Yes"<<endl;
       }
       else{
           cout<<"No"<<endl;
       }
   }
    return 0; 
}




Measured memory_bytes: 1408
n, k = map(int,input().split())
x = list(map(int,input().split()))

temp = [None for i in range(k)]

m = float("inf")

for i in range(n-k+1):
	m = min(m, abs(x[i]-x[i+k-1])+min(abs(x[i]),abs(x[i+k-1])))

print(m)


Measured memory_bytes: 14224
// Author: Wenxing Mei
//   File: c.cpp
//   Date: 2019-04-05 17:11
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define per(i, b, a) for (int i = (int)b; i >= (int)a; --i)
#define repv(ele, cont) for (auto &ele : cont)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<ll> vll;
// END OF TEMPLATE

int main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vi f(n);
    int cur = 0;
    rep(i, 1, n) {
        if (s[i] == 'C' && s[i - 1] == 'A') ++cur;
        f[i] = cur;
    }
    rep(i, 0, q) {
        int l, r;
        cin >> l >> r;
        cout << f[r - 1] - f[l - 1] << '\n';
    }
    return 0;
}


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

using namespace std;

int main()
{
	long long int a , b , c;
	while(cin >> a >> b >> c , a + 1 || b + 1 || c + 1)
	{
		b += a * 60;
		c += b * 60;
		long long int x1 = c , x2 = c;
		long long int m = 120 * 60;
		long long int y1 = m - x1 , y2 = m - x2;
		y2 *= 3;
		cout.fill('0');
		cout << setw(2) << y1 / ( 60 * 60 ) << ":" << setw(2) << y1 % ( 60 * 60 ) / 60 << ":" << setw(2) << y1 % 60 << endl;
		cout << setw(2) << y2 / ( 60 * 60 ) << ":" << setw(2) << y2 % ( 60 * 60 ) / 60 << ":" << setw(2) << y2 % 60 << endl;
	}
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main(){
  //type
  int a, b;
  cin >> a >> b;

  //solve
  int ab = b;
  while(b > 0) {
    a *= 10;
    b /= 10;
  }
  ab += a;
  
  for(int i = 4; i*i <= ab; i++)
    if(i*i == ab){
      cout << "Yes" << endl;
      return 0;
    }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAX = 1e5 + 100;
int X, Y, A, B, C;
VI p, q, r;

int main() {
  scanf("%d%d%d%d%d", &X, &Y, &A, &B, &C);
  for (int i = 0; i < A; i++) {
    int t;
    scanf("%d", &t);
    p.PB(t);
  }
  for (int i = 0; i < B; i++) {
    int t;
    scanf("%d", &t);
    q.PB(t);
  }
  for (int i = 0; i < C; i++) {
    int t;
    scanf("%d", &t);
    r.PB(t);
  }

  sort(ALL(p)); reverse(ALL(p));
  sort(ALL(q)); reverse(ALL(q));
  sort(ALL(r)); reverse(ALL(r));

  ll ans = 0;
  for (int i = 0; i < X; i++)
    ans += p[i];
  for (int i = 0; i < Y; i++)
    ans += q[i];

  ll cur = ans;
  for (int t = 0; t < C; t++) {
    if (X == 0 && Y == 0)
      break;
    if (X == 0)
      cur -= q[--Y];
    else if (Y == 0)
      cur -= p[--X];
    else if (p[X - 1] < q[Y - 1])
      cur -= p[--X];
    else
      cur -= q[--Y];
    cur += r[t];
    ans = max(ans, cur);
  }

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


Measured memory_bytes: 1784
#include <iostream>
#include <cstdio>
using namespace std;
int a,b;
char c[52][52];
char re[52][52];
int dis[8][2]= {1,0,0,1,-1,0,0,-1,-1,-1,1,-1,-1,1,1,1};
int in(int i,int j,int k)
{
    if(i+dis[k][0]<0||i+dis[k][0]>a||j+dis[k][1]<0||j+dis[k][1]>b)
        return 0;
    return 1;
}
int main()
{
   while(scanf("%d%d",&a,&b)==2)
   {
       for(int i=0;i<a;i++)
           scanf("%s",c[i]);

        for(int i=0;i<a;i++)
        {
            for(int j=0;j<b;j++)
            {
                if(c[i][j]=='#'){
                    re[i][j]='#';
                }
                else
                {
                    int m=0;
                    for(int k=0;k<=7;k++)
                    {
                       if(in(i+1,j+1,k)==1&&c[i+dis[k][0]][j+dis[k][1]]=='#')
                         m++;
                    }
                    re[i][j]=48+m;
                }
            }

        }
      for(int i=0;i<a;i++)
                printf("%s\n",re[i]);
   }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    string str;
    cin >> str;
    cout << str.substr(0,5) << " " << str.substr(6,7) << " " << str.substr(14,5) << endl;

    return 0;
}

Measured memory_bytes: 256