akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

const ll MAX_N=202020;
ll now_id;
ll s[MAX_N];//色cを根とする部分木のサイズ
ll c[MAX_N];
ll dp[MAX_N];//色cの補集合
ll id;//頂点id

void dfs(Graph& g, int v, int p){
    id++;
    for(auto e:g[v]){
        if(e.to==p) continue;

        ll pre=id - s[c[v]];
        dfs(g,e.to,v);
        ll nxt=id - s[c[v]];
        ll d=nxt-pre;//差分＝部分木における色cまでの頂点の総数
        dp[c[v]]+=d*(d+1)/2;
        s[c[v]]+=d;
    }
    s[c[v]]++;
}

void solve(){
    ll n;
    cin>>n;
    REP(i,n) cin>>c[i];
    Graph g(n);
    REP(i,n-1){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        add_edge(g,a,b,1,true,1);
    }

    dfs(g,0,-1);
    rep(i,1,n+1) {
        ll ans = n*(n+1)/2;
        //根からの分を引く
        ll con = n - s[i];
        dp[i] += con*(con+1)/2;
        ans-=dp[i];
        
        cout<<ans<<en;
    }

}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 43788
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

ll absll(ll a) {
   if (a < 0) return -a;
   else return a;
}

int main() {
   int N;
   cin >> N;
   ll A[N];
   int minus = 0;
   for (int i = 0; i < N; i++) {
      cin >> A[i];
      if (A[i] < 0) minus++;
   }
   sort(A, A + N);
   ll ans = 0;
   if (minus % 2 == 0) {      
      for (int i = 0; i < N; i++) {
         ans += absll(A[i]);
      }
   } else {
      for (int i = 0; i < N; i++) {
         if (i != minus && i != minus - 1) {
            ans += absll(A[i]);
         }
      }
      if (minus != N) ans += absll(A[minus] + A[minus - 1]);
      else ans += A[minus - 1];
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;

int a, b, x1, y1, x2, y2, x3, y3, x4, y4;

int main() {
	cin >> x1 >> y1 >> x2 >> y2;
	if(x2 >= x1 && y1 >= y2) {
		a = x2-x1, b = y1-y2;
		cout << x2+b << " " << y2+a << " " << x1+b << " " << y1+a;
	}
	else if(x2 >= x1 && y1 <= y2) {
		a = x2-x1, b = y2-y1;
		cout << x2-b << " " << y2+a << " " << x1-b << " " << y1+a;
	}
	else if(x2 <= x1 && y1 >= y2) {
		a = x1-x2, b = y1-y2;
		cout << x2+b << " " << y2-a << " " << x1+b << " " << y1-a;
	}
	else if(x2 <= x1 && y1 <= y2) {
		a = x1-x2, b = y2-y1;
		cout << x2-b << " " << y2-a << " " << x1-b << " " << y1-a;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 2000

int a[N], n, sum, q, m, i;

int divide(int i,int m){
  if(sum < m)return 0;
  if(m == 0)return 1;
  if(i >= n)return 0;
  return divide(i+1,m) || divide(i+1,m-a[i]);
}

int main(){

  sum = 0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&m);
    if (divide(0,m)){
      printf("yes\n");
    }else{
      printf("no\n");
    }

  }
  return 0;
}

Measured memory_bytes: 2612
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
	string S;
	cin >> S;
	int cnt = 0;
	rep(i, S.size()-1)
	{
		if (S[i] == S[i + 1])
		{
			S[i + 1] = S[i] == '0' ? '1' : '0';
			cnt++;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   bool pos = 1;
   rep(n)
   {
       ll temp;
       cin>>temp;
       if(temp%2 == 0)
       {
           if(temp%5 == 0 || temp%3 == 0)
                continue;
           pos = 0;        
       }
   }
   
   if(pos)
        cout<<"APPROVED";
   else cout<<"DENIED";        
   return 0;        
}  
   

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
ll nlcm(vector<ll> numbers){
    ll res;
    res=numbers[0];
    for (ll i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
     return res;
}
int main(){
    ll n;cin>>n;
    vector<ll> t(n);
    rep(i,n){
     cin>>t[i];
    }
    ll ans=0;
    ans=nlcm(t);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int p(int A,int B){
  if(!B)return 1;
  if(B&1)return p(A,B-1)*A%mod;
  int C=p(A,B/2);
  return C*C%mod;
}
signed main(){
  int N;
  cin>>N;
  cout<<((p(10,N)-p(9,N)*2%mod+mod)%mod+p(8,N))%mod<<endl;
}


Measured memory_bytes: 3572
#https://atcoder.jp/contests/abc126
# -*- coding: utf-8 -*-
 
s = input()
MMYY = 0
YYMM = 0
s1 = int(s[0:2])
s2 = int(s[2:4])

if 1 <= s1 <= 12:
        MMYY = 1

if 1 <= s2 <= 12:
        YYMM = 1

if MMYY and YYMM:
        print("AMBIGUOUS")

if MMYY and not YYMM:
        print("MMYY")

if YYMM and not MMYY:
        print("YYMM")

if not YYMM and not MMYY:
        print("NA")

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

using namespace std;

using ll = long long;

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

    int w, h, n;
    cin >> w >> h >> n;

    pair<int, int> x(0, w), y(0, h);
    for (int i = 0; i < n; ++i) {
        int xx, yy, a;
        cin >> xx >> yy >> a;
        if (a == 1) x.first = max(x.first, xx);
        else if (a == 2) x.second = min(x.second, xx);
        else if (a == 3) y.first = max(y.first, yy);
        else y.second = min(y.second, yy);
    }

    if (x.second <= x.first || y.second <= y.first) cout << "0\n";
    else cout << (x.second - x.first) * (y.second - y.first) << endl;

    return 0;
}


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

int main()
{
  long long A;
  string B;
  cin >> A >> B;
  long long dig1, dig2, dig3;
  dig1 = B[0] - '0';
  dig2 = B[2] - '0';
  dig3 = B[3] - '0';
  long long ans = 0;
  dig1 *= A;
  dig2 *= A;
  dig3 *= A;
  int dig2mod = dig2%10;
  int dig3mod = dig3%100;
  dig2 /= 10;
  dig3 /= 100;
  ans += dig1+dig2+dig3;
  if (dig2mod*10+dig3mod >= 100) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 3612
"use strict";

const input = require("fs").readFileSync("/dev/stdin", "utf8");
const X = Number(input.trim());

const memo = {};
const pow5 = (n) => {
  if (!memo[n]) {
    memo[n] = Math.pow(n, 5);
  }
  return memo[n];
};

const MAX = 120;
const resultList = [];
for (let a = -MAX; a <= MAX; a++) {
  for (let b = -MAX; b < MAX; b++) {
    if (pow5(a) - pow5(b) === X) {
      resultList.push(a, b);
      break;
    }
  }
  if (resultList.length) {
    break;
  }
}

console.log(resultList.join(" "));


Measured memory_bytes: 33704
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
} edge;
int main( void ){
	int A, B, C; cin >> A>>B>>C;
	rep(i,1,B+1){
		if (A*i%B == C){
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  string s;
  cin >> s;
  cout << s.substr(0, 4) << " " << s.substr(4) << endl;
  return 0;
}

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

struct card{
	char suit;
	int num;
	int jun;
};

int out_card(vector<card> &A,int n){
	int i;
	for (i=0;i<=n-1;i++){
		cout << A[i].suit << " "<< A[i].num <<endl;
	}
}

int judgeStability(vector<card> &A,int n){
	int i;
	int flag=0;
	for(i=1;i<n;i++){
		if((A[i].num==A[i-1].num)&&(A[i].jun<A[i-1].jun)){
			flag=1;
		}
	}
	return flag;
}

int partition(vector<card> &A, int p, int r){
	int x=A[r].num;
	int i=p-1;
	int j;
	for (j=p;j<r;j++){
		if (A[j].num<=x){
			i++;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i+1;
}

void QuickSort(vector<card> &A, int p, int r){
	if (p<r){
		int q=partition(A,p,r);
		QuickSort(A,p,q-1);
		QuickSort(A,q+1,r);
	}
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,i;
	cin >> n;
	
	vector<card> C(n);
	for (i=0;i<n;i++){
		cin >> C[i].suit >> C[i].num;
		C[i].jun=i;
	}	
	
	QuickSort(C,0,n-1);
	
	int flag=judgeStability(C,n);
	if (!flag){
		cout <<"Stable" <<endl;
	}else{
		cout <<"Not stable" <<endl;
	}
	out_card(C,n);
	
	return 0;
}

Measured memory_bytes: 2324
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INT_INF 1000000000
#define DOUBLE_INF 1e18
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_N 101

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main()
{
  int N, a[MAX_N];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  int ans = 0;
  int tmp = 1;
  for (int i = 1; i < N; i++) {
    if (a[i] == a[i-1]) {
      tmp++;
    } else {
      ans += tmp / 2;
      tmp = 1;
    }
  }
  ans += tmp / 2;

  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define M 1000000007ULL

unsigned long long dp[201][10];
unsigned long long fibt[10];

int main()
{

    fibt[1] = 1;
    fibt[2] = 1;
    for (int i = 3; i < 10; i++)
    {
        fibt[i] = fibt[i - 1] + fibt[i - 2];
    }

    int H, W, K;

    cin >> H >> W >> K;

    if(W == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    dp[0][0] = 1ULL;
    for (int h = 1; h <= H; h++)
    {
        for (int x = 0; x < W;x++)
        {
            unsigned long long X, Y, Z;
            X = Y = Z = 0ULL;

            if (x > 0)
            {
                if(x == 1 || x == W - 1)
                {
                    X = fibt[W - 1];
                }
                else
                {
                    X = fibt[x] * fibt[W - x];
                }
                dp[h][x - 1] += dp[h - 1][x] * X;
                dp[h][x - 1] %= M;
            }

            if (x == 0 || x == W - 1)
            {
                Y = fibt[W];
            }
            else
            {
                Y = fibt[x + 1] * fibt[W - x];
            }
            dp[h][x] += dp[h - 1][x] * Y;
            dp[h][x] %= M;

            if(x < W - 1)
            {
                if (x == W - 2 || x == 0)
                {
                    Z = fibt[W - 1];
                }
                else
                {
                    Z = fibt[x + 1] * fibt[W - x - 1];
                }
                dp[h][x + 1] += dp[h - 1][x] * Z;
                dp[h][x + 1] %= M;
            }
        }
    }

    cout << dp[H][K - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a,n;;
vector<int>v;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if((i+n+1)%2)v.push_back(a);
		else v.insert(v.begin(),a);
	}
	for(int i=0;i<n;i++)cout<<v[i]<<" ";
}

Measured memory_bytes: 3060
/// input macro
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
///
/// # Example
///
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[macro_export]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
        s: i32,
    }

    let s = s.to_string().chars().collect::<Vec<char>>();

//    let ans = s.iter().fold(0, |acc, x| if *x == '1' { acc + 1 } else { acc });
//    let ans = s.iter().fold(0, |acc, &x| if x == '1' { acc + 1 } else { acc });
    let ans = s.iter().filter(|&x| *x == '1').count();

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



Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) {
		cout << b + c << endl;
	}
	else {
		c = a + b + 1;
		cout << b + c << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#alds13c
from collections import deque

d_stack=deque()
res_stack=deque()
s = input()

for i in range(len(s)):
    #print(d_stack,res_stack)
    if s[i]=="\\":
        d_stack.append(i)
    elif s[i]=="/":
        if len(d_stack)==0:
            continue
        left = d_stack.pop()
        area = i-left
        #res_stack.append((left,area))
        if len(res_stack)>0:
            flag=True
            #merge_candidate = []
            mergeareasum=0
            while flag:
                if len(res_stack)>0 and left<res_stack[-1][0]:
                    mc = res_stack.pop()
                    mergeareasum += mc[1]
                    #res_stack.append((left,under[1]+area))
                else:
                    flag = False
                    res_stack.append((left,area+mergeareasum))
        else:
                res_stack.append((left,area))

ans=0
v_devided=[]
for pair in res_stack:
    ans += pair[1]
    v_devided.append(str(pair[1]))
print(ans)
if len(v_devided)>0:
    print(len(v_devided)," ".join(v_devided))
else:
    print(0)


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

int main(){
	int n;
	while(cin>>n , n){
		vector<int> a(n);
		int cnt=0;
		for(int i=0;i<n;++i){
			cin >> a[i];
		}
		while(1){
			vector<int> b(n,0);
			for(int i=0;i<n;++i){
				for(int j=0;j<n;++j){
					if(a[i]==a[j]) b[i]++;
				}
			}
			if (a==b) break;
			for(int i=0;i<n;++i){
				a[i]=b[i];
			}
			++cnt;
		}
		cout << cnt << endl;
		for(int i=0;i<n-1;++i){
			cout << a[i] << " ";
		}
		cout << a[n-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#define ll long long
#define pb push_back
#define rep(i,n) for (int i=0;i<n;i++)
#define INF 1e9+7
#define vec vector<int>

using namespace std;




int main() {
    int n; cin >>n;
    vector<pair<ll,ll>> x(n);
    rep(i,n) cin >>x[i].first>>x[i].second;
    sort(x.begin(),x.end());
    rep(i,n) cout<<x[i].first<<" "<<x[i].second<<endl;


}


Measured memory_bytes: 4352
N,K,L = map(int,input().split())
PQ = [tuple(map(int,input().split())) for i in range(K)]
RS = [tuple(map(int,input().split())) for i in range(L)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

roads = UnionFind(N)
rails = UnionFind(N)
for p,q in PQ:
    p,q = p-1,q-1
    roads.unite(p,q)
for r,s in RS:
    r,s = r-1,s-1
    rails.unite(r,s)
for i in range(N):
    roads.root(i)
    rails.root(i)

from collections import Counter
ctr = Counter()
for i in range(N):
    ctr[(roads.parent[i], rails.parent[i])] += 1
ans = []
for i in range(N):
    ans.append(ctr[(roads.parent[i], rails.parent[i])])
print(*ans)

Measured memory_bytes: 74908
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
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)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;



int n, k, cnt = 1, ans;

int main() {

	cin >> n >> k;

	while (cnt <= n) {
		cnt *= k;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int[] v=new int[3];
v[0]=Integer.parseInt(sc.next());
v[1]=Integer.parseInt(sc.next());
v[2]=Integer.parseInt(sc.next());
int K=Integer.parseInt(sc.next());
Arrays.sort(v);
for(int i=0;i<K;i++){
v[2]*=2;
}
System.out.println(v[0]+v[1]+v[2]);
}}

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

using namespace std;

/* spaghetti source */
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight) :
            src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
           e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

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

bool visit(const Graph &g, int v, vector<int> &order, vector<int> &color) {
    color[v] = 1;
    FOR(e, g[v]) {
        if (color[e->dst] == 2) continue;
        if (color[e->dst] == 1) return false;
        if (!visit(g, e->dst, order, color)) return false;
    }
    order.push_back(v); color[v] = 2;
    return true;
}
bool topologicalSort(const Graph &g, vector<int> &order) {
    int n = g.size();
    vector<int> color(n);
    REP(u, n) if (!color[u] && !visit(g, u, order, color))
        return false;
    reverse(ALL(order));
    return true;
}
/* ^^^spaghetti source^^^ */

int main() {
    int n, m;
    cin >> n >> m;
    vector<Edges> g(n);
    for (int i = 0; i < (n + m - 1); ++i) {
        int a, b;
        cin >> a >> b;
        g[a-1].push_back(Edge{a-1, b-1, 0});
    }

    vector<int> ord;
    topologicalSort(g, ord);
    
    const int INF = 1e9;
    vector<int> par(n, INF);
    for (int i = 0; i < n; ++i) {
        auto edges = g[ord[i]];
        for (auto &e : edges) {
            par[e.dst] = e.src;
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << (par[i] == INF ? -1 : par[i]) + 1 << endl;
    }

}

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

void shift(vector<char> &box, int set[4]){
	for(int i = 0;i < 3;i++){
		swap(box[set[i]], box[set[i + 1]]);
	}
}

int main(){
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		vector<char> box[30];
		for(int i = 0;i < n;i++){
			box[i].resize(6);
			for(int j = 0;j < 6;j++){
				string in;
				cin >> in;
				box[i][j] = in[0];
			}
		}
		int shiftSet[3][4] = {
			{1, 2, 4, 3},
			{0, 2, 5, 3},
			{0, 1 ,5, 4}
		};
		int ans = 0;
		for(int i = 0;i < n;i++){
			for(int j = i + 1;j < n;j++){
				vector<char> buf = box[j];
				//相手
				for(int x = 0;x < 4;x++){
					for(int y = 0;y < 4;y++){
						for(int z = 0;z < 4;z++){
							if(box[i] == buf){
								ans++;
								goto END;
							}
							shift(buf, shiftSet[0]);
						}
						shift(buf, shiftSet[1]);
					}
					shift(buf, shiftSet[2]);
				}
			}
END:;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);
        int INF = Integer.MAX_VALUE/2;

        int n = sc.nextInt();
        int[] time = new int[n-1];
        for(int i=0; i<n-1; i++) time[i] = sc.nextInt();

        int[][][] dp = new int[2][n/2+1][2];
        for(int i=0; i<2; i++)
            for(int j=0; j<=n/2; j++) Arrays.fill(dp[i][j], INF);
        dp[0][0][1] = 0; dp[0][1][0] = 0;

        int idx = 1;
        for(int i=1; i<n; i++){
            for(int j=0; j<=n/2; j++){
                int n1 = INF, n2 = INF;
                if(j!=0){
                    n1 = Math.min(dp[1-idx][j-1][0], dp[1-idx][j-1][1] + time[i-1]);
                }
                n2 = Math.min(dp[1-idx][j][0] + time[i-1], dp[1-idx][j][1]);
                if(j!=0) dp[idx][j][0] = Math.min(dp[idx][j][0], n1);
                dp[idx][j][1] = Math.min(dp[idx][j][1], n2);
            }
            idx = 1-idx;
            for(int j=0; j<=n/2; j++) Arrays.fill(dp[idx][j], INF);
        }

        System.out.println(Math.min(dp[1-idx][n/2][0], dp[1-idx][n/2][1]));
    }

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

Measured memory_bytes: 37592
n = int(raw_input())
intervals = [[u-l,u+l] for u,l in [map(int, raw_input().split()) for _ in range(n)] ]
intervals.sort(key = lambda x:x[1])

count = 1
i = 1
cur= intervals[0]
while(i < len(intervals)):
	while(i < len(intervals) and cur[1] > intervals[i][0]): i += 1
	if i < len(intervals):
		cur = intervals[i]
		count +=1


print count

Measured memory_bytes: 102788
///apigs property
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
#define sz(s) s.size()
#define md (s + e) / 2
#define mid (l + r) / 2
#define msdp(dp) memset(dp , -1 , sizeof dp)
#define mscl(dp) memset(dp , 0 , sizeof dp)
using namespace std;
typedef long long ll;
ll q, a[555555] , b[555555], k, l, m, n, o, p;
ll dp[100005][5];
vll adj[555555];
const ll mod = 1e9+7;
ll mem(ll i , ll oo, bool pp){
	ll &r = dp[i][pp];
	if(r != -1)return r;
	ll o1 = 1 , o2 = 1;
	if(!pp){
		for(auto u : adj[i]){
			if(u != oo){
				o1 = (o1 * mem(u , i , 0)) % mod;
				o2 = (o2 * mem(u , i , 1)) % mod;
			}
		}
		r = (o1 + o2) % mod;
	}
	else{
		for(auto u : adj[i]){
			if(u != oo){
				o1 = (o1 * mem(u , i , 0)) % mod;
			}
		}
		r = o1;
	}
	return r;
}
void solve(){
	msdp(dp);
	cin >> n;
	for(ll i = 0 ; i < n - 1 ; i++){
		cin >> o >> p;
		adj[o].pb(p);
		adj[p].pb(o);
	}
	cout << mem(1 , -1 , 0);
}
int main() {
    fast ;
	// cin >> q;
    q = 1;
    while(q--){
    	solve();
	}
}



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


int table[10][5];

int H,W;
int destroy(){
	int done[10][5]={};
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j+2 < W ; j++){
			if( table[i][j] == table[i][j+1] && table[i][j+2] == table[i][j] )
				done[i][j] = done[i][j+1] = done[i][j+2] = 1;
		}
	}

	int ans = 0;
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){
			if( done[i][j] ){
				ans += table[i][j];
				table[i][j] = 0;
			}
		}
	}
	for(int k = 0 ; k < H ; k++)
	for(int i = 0; i+1 < H ; i++){
		for(int j = 0 ; j < W ; j++){
			if( table[i+1][j] == 0 ){
				table[i+1][j] = table[i][j];
				table[i][j] = 0;
			}
		}
	}
	return ans;
}
int main(){
	while( cin >> H && H ){	
		W = 5;
		for(int i = 0 ; i < H ; i++)
			for(int j = 0 ; j < W ; j++)
				cin >> table[i][j];
		int r;
		int ans = 0;
		while( r=destroy() ){
			ans += r;
			
		}
		cout << ans << endl;
	}
}

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

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

  int sum = 0;
  int num = N;

  while(num > 0){
    sum += num % 10;
    num /= 10; 
  }

  if(N % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int main(){
    int N,A;
    cin >> N >> A;
    if(N-(N/500)*500<=A) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
local A, B = io.read("l", "l")
if #A ~= #B then
  print(#A>#B and "GREATER" or "LESS")
else
  for i=1,#A do
    local a,b = A:sub(i,i), B:sub(i,i)
    if a~=b then
      print(a>b and "GREATER" or "LESS")
      return
    end
  end
  print("EQUAL")
end

Measured memory_bytes: 508
n=int(input())
a=list(map(int,input().split()))
list=[]
count=0
ans=1
a.sort(reverse=True)
for i in range(1,len(a)):
	if a[i]==a[i-1]:
		ans*=a[i]
		a[i]=0
		count+=1
	if count==2:
		break
else:
	ans=0
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<ll>v(n);
    bool test=false;
    for(int i=0;i<n;i++){
        cin>>v[i];
        if(v[i]==1)test=true;
    }
    if(test==false){
        cout<<-1<<endl;
        return 0;
    }
    int cnt=0;
    ll el=1;
    for(int i=0;i<n;i++){
        if(el==v[i]){
            cnt++;
            el++;
        }
    }
    cout<<n-cnt<<endl;
    return 0;

}


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

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

int main(){
    int H,W; cin >> H >> W;
    char s[55][55];
    int t[55][55];
    int cnt=0;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin >> s[j][i];
            if(s[j][i]=='#') cnt++;
        }
    }
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cerr << s[j][i] << "\t";
        }
        cerr << "\n";
    }
    for(int i=0;i<55;i++){
        for(int j=0;j<55;j++){
            t[i][j]=-1;
        }
    }
    queue<pair<int,int> > q;
    q.push(make_pair(1,1));
    t[1][1]=0;
    while(!q.empty()){
        pair<int,int> pp = q.front(); q.pop();
        int tx=pp.first;
        int ty=pp.second;
        for(int i=0;i<4;i++){
            int nx=tx+dx[i];
            int ny=ty+dy[i];
            if(nx<=0 || nx>W || ny<=0 || ny>H) continue;
            if(s[nx][ny]=='.' && t[nx][ny]==-1){
                cerr << nx << " " << ny << endl;
                t[nx][ny] = t[tx][ty]+1;
                q.push(make_pair(nx,ny));
            }
        }
    }
    cerr << t[W][H] << endl;
    if(t[W][H]==-1){
        cout << -1 << endl;
    }else{
        cout << H*W-cnt-t[W][H]-1 << endl;
    }
    return 0;
}


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

int main(int argc, const char * argv[]) {
    int a1=0,a2=0,a3=0,a4=0,dice[7],i=0,x=0,y=0,a=0,z=0;
    
    for(i = 1;i <= 6;i++){
        scanf("%d",&dice[i]);
    }
    
    scanf("%d",&a);
    for(i=0;i<a;i++){
        scanf("%d %d",&x,&y);
        while(1){
            z = rand()%4;
            if(z==0){
                a1=dice[1];
                a2=dice[3];
                a3=dice[4];
                a4=dice[6];
                dice[1]=a3;
                dice[3]=a1;
                dice[4]=a4;
                dice[6]=a2;
            }else if(z==1){
                a1=dice[1];
                a2=dice[2];
                a3=dice[5];
                a4=dice[6];
                dice[1]=a2;
                dice[2]=a4;
                dice[5]=a1;
                dice[6]=a3;
            }else if(z==2){
                a1=dice[1];
                a2=dice[2];
                a3=dice[5];
                a4=dice[6];
                dice[1]=a3;
                dice[2]=a1;
                dice[5]=a4;
                dice[6]=a2;
            }else if(z==3){
                a1=dice[1];
                a2=dice[3];
                a3=dice[4];
                a4=dice[6];
                dice[1]=a2;
                dice[3]=a4;
                dice[4]=a1;
                dice[6]=a3;
            }
            if(dice[1]==x && dice[2]==y){
                break;
            }
    }
    printf("%d\n",dice[3]);
    }
    return 0;
}

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

int main() {
	int dish;
	int diff = 0;
	int sum = 0;
	for (int i = 0; i < 5; i++) {
		cin >> dish;

		if (dish % 10 != 0) {
			sum = sum + (dish / 10 + 1) * 10;
		} else {
			sum = sum + dish;
		}
		if ((10 - dish % 10) > diff && dish % 10 != 0)
			diff = (10 - dish % 10);
	}

	cout << sum - diff << endl;

	return 0;
}

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

int main(){

        int N;
        int i,j;

        cin >> N;

        vector<string> a(N);

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

        for(i=0;i<N;i++){
                for(j=0;j<N;j++){
                        if(i!=j && a[i]==a[j]){
                        cout << "No" << endl;
                        return 0;
                        }
                }
        }

        for(i=1;i<N;i++){
                if(a[i-1].back()!=a[i].front()){
                cout << "No" << endl;
                return 0;
                }
        }

        cout << "Yes" << endl;

        return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner (System.in);
        int tem = 0;
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        
        for(int i=0;i<=a;i++){
            for(int j=0;j<=b;j++){
                for(int k=0;k<=c;k++){
                    if (500*i+100*j+50*k == x){
                        tem += 1;
                    }
                }
            }
        }
        
        System.out.printf("%d\n",tem);
        tem=0;
    }
}


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

using namespace std;

bool check(int number, vector<int> &v){
    while(number != 0){
        int digit = number % 10;
        if(v[digit] == 1) return false;
        number = number/10;
    }
    return true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int amount, k, answer;
    cin >> amount >> k;
    
    vector<int> v(9, 0);
    for(int i = 0; i < k; i++){
        int number;
        cin >> number;
        v[number] = 1;
    }
    for(int a = amount; ; a++){
        if(check(a, v) == true){
            answer = a;
            break;
        }
    }
    cout << answer << "\n";
    
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n;
	cin>>n;
	if(n<105)cout<<0<<endl;
	else if(n<135)cout<<1<<endl;
	else if(n<165)cout<<2<<endl;
	else if(n<189)cout<<3<<endl;
	else if(n<195)cout<<4<<endl;
	else cout<<5<<endl;
	
	return 0;
}

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

data = [ int(input()) for i in range(int(input())) ]

un = [num for num in data if num % 10 == 0]
data = [num for num in data if num % 10 != 0]

if len(data) == 0:
    print(0)
else:
    if sum(un+data) % 10 != 0:
        print(sum(un+data))
    else:
        print(sum(un+data)-min(data))


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		2505

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

ll DP[52][52][MAX];
//
int main(){
	int N,A;cin>>N>>A;
	V x(N);
	REP(i,N)cin>>x[i];

	DP[0][0][0] = 1;
	REPS(j,1,N+1){
		REP(k,N+1){
			for(int s=0;s<=2500;++s){
				if(s < x[j-1]) DP[j][k][s] = DP[j-1][k][s];
				else if(k>=1){
					DP[j][k][s] = DP[j-1][k][s] + DP[j-1][k-1][s-x[j-1]];
				}
			}
		}
	}


	ll ans = 0;
	REPS(i,1,N+1){
	//	cout << DP[N][i][A*i] << endl; 
		ans += DP[N][i][A*i];
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 51072
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class CVacantSeat {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;

	    string res;
	    out << 0 << endl << flush;
	    in >> res;

	    if(res == "Vacant") return;

	    int left = 0, right = n;
	    string zero = res;
	    while(left + 1 < right){
            int mid = left + (right - left)/2;
            out << mid << endl << flush;
            in >> res;
            if(res == "Vacant") return;
            if(mid % 2 == 0){
                if(res == zero) left = mid;
                else right = mid;
            }else{
                if(res == zero) right = mid;
                else left = mid;
            }
	    }

	    return;
	}
};


int main() {
	CVacantSeat solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s.at(i);
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());
    cout << s.size() << endl;
}

Measured memory_bytes: 9536
#include<bits/stdc++.h>
using namespace std;
int n,a[110];
double s=0.0;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),s+=1.0/(double)(a[i]);
	printf("%lf",1.0/s);
	return 0;
}

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

int main(){
    int a, b;
    string op = "+";
    while (op!="?"){
        cin >> a >> op >> b;
        if (op=="+") cout << a+b << endl;
        else if (op=="-") cout << a-b << endl;
        else if (op=="*") cout << a*b << endl;
        else if (op=="/") cout << a/b << endl;
    }
    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define N 20
using namespace std;
int n;
int a[N],b[N];
int dp[1<<19][51];
int Abs(int a){
	return a > 0 ? a : -a;
}
int dfs(int hav, int ma,int cnt)
{
	if(cnt == n) return 0;
	if(dp[hav][ma] != -1) return dp[hav][ma];
	dp[hav][ma] = 10086;
	int dx,ans,tot = 0;
	for(int i = 0; i < n;i ++){
		if(hav & (1 << i)){
			tot ++;
			continue;
		}
		if(Abs(i - cnt) & 1) dx = b[i];
		else dx = a[i];
		if(dx < ma) continue;
		ans = dfs(hav | (1 << i), dx, cnt + 1);
		if(ans > 1000) continue;
		dp[hav][ma] = min(ans + cnt - tot, dp[hav][ma]);
	}
	return dp[hav][ma];
}
int main(){
	memset(dp, -1, sizeof(dp));
	scanf("%d",&n);
	for(int i = 0; i < n; i ++){
		scanf("%d", &a[i]);
	}
	for(int i = 0; i < n; i ++){
		scanf("%d", &b[i]);
	}
	int ans = dfs(0,0,0);
	if(ans > 1000) puts("-1");
	else printf("%d\n", ans);
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int t, x, y;
        cin >> t >> x >> y;

        int d = abs(x) + abs(y);
        if (d > t) {
            cout << "No" << endl;
            return 0;
        } 
        if ((t - d) % 2 > 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int p,q;
	
	while(cin >> p >> q){
		string str = "";
		vector<int> his;
		his.push_back(p%q);
		
		for(int i=0;i<100;i++){
			p *= 10;
			str += '0' + p / q;
			p %= q;

			if(p == 0){cout << str << endl;break;}

			if( find(his.begin(),his.end(),p) != his.end() ){
				int pos = find(his.begin(),his.end(),p)-his.begin();
				cout << str << endl;
				rep(i,pos)cout << " ";
				rep(i,his.size()-pos)cout << "^";
				cout << endl;
				break;
			}
			his.push_back(p);
		}
	}
}

Measured memory_bytes: 0
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
lim = N+10  # 必要そうな階乗の限界を入れる
fact = [1] * (lim+1)
fact_inv = [1] * (lim+1)
for n in range(1, lim+1):
    fact[n] = (fact[n-1] * n) % mod
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
    fact_inv[n-1] = (n * fact_inv[n]) % mod

tree = [[] for _ in range(N+1)]  # 1-indexed
for _ in range(N-1):
	a, b = MAP()
	tree[a].append(b)
	tree[b].append(a)

root = 1
parent = [0]*(N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in tree[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

size_d = [0]*(N+1)
dp_d = [1]*(N+1)

for v in order[::-1]:  # 根に遠いほうから(down方向のボトムアップ)
    dp_d[v] *= fact[size_d[v]]
    dp_d[v] %= mod
    p = parent[v]
    s = size_d[v] + 1
    size_d[p] += s
    dp_d[p] *= fact_inv[s] * dp_d[v]
    dp_d[p] %= mod

size_u = [N-1-x for x in size_d]
dp_u = [1]*(N+1)

def merge(p1, p2):
    den_inv1, v1 = p1
    den_inv2, v2 = p2
    return den_inv1*den_inv2%mod, v1*v2%mod

for v in order:
    p = parent[v]
    arr = [(fact_inv[size_d[node]+1], dp_d[node]) if node != p else (fact_inv[size_u[v]], dp_u[v]) for node in tree[v]]
    left = [(1, 1)] + list(accumulate(arr, merge))[:-1]
    right = list(accumulate(arr[::-1], merge))[-2::-1] + [(1, 1)]
    contrib = [merge(x, y) for x, y in zip(left, right)]
    for node, c in zip(tree[v], contrib):
        if node != p:
            dp_u[node] = (((c[0]*c[1])%mod)*fact[size_u[node]-1])%mod
# print(dp_u)
for xd, xu, sd, su in zip(dp_d[1:], dp_u[1:], size_d[1:], size_u[1:]):
    x = xd * xu * fact[sd + su] * fact_inv[sd] * fact_inv[su] % mod
    print(x)


Measured memory_bytes: 140228
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i=1; i<=n; i++) {
        double d = 1.08 * i;
        if (n == (int)d) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << ":(" << '\n';
    return 0;
}

Measured memory_bytes: 256