akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define pb push_back
bool u[105][105];
double bad[105];
int n;
struct uf{
	int par[105],ran[105];
	void init(){ for(int i=0;i<105;i++) par[i] = i, ran[i] = 0; }
	int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
	void unite(int x,int y){
		x = find(x); y = find(y); if(x==y) return;
		if(ran[x] < ran[y]) par[x] = y;
		else{
			par[y] = x;
			if(ran[x] == ran[y]) ran[x]++;
		}
	}
	bool same(int x,int y){ return find(x)==find(y); }
}kaede;
int main(){
	while(1){
		cin>>n;
		if(n == 0) return 0;
		memset(u,0,sizeof(u));
		memset(bad,0,sizeof(bad));
		for(int i=1;i<=n;i++){
			scanf("%lf",&bad[i]);
			int cnt; scanf("%d",&cnt);
			rep(j,cnt){
				int a; cin>>a; u[i][a] = 1;
			}
		}
		repn(k,n) repn(i,n) repn(j,n){
			u[i][j] |= (u[i][k] & u[k][j]);
		}
		kaede.init();
		repn(i,n) repn(j,n){
			if(u[i][j] && u[j][i]){
				kaede.unite(i,j);
			}
		}
		int in[105]={};
		repn(i,n) repn(j,n){
			if(u[i][j] && kaede.same(i,j) == false){
				in[kaede.find(j)]++;
			}
		}
		vector<int>lst[105];
		repn(i,n){
			lst[kaede.find(i)].pb(i);
		}
		double ans = 1.0;
		repn(i,n){
			if(i != kaede.find(i)) continue;
			if(in[i]) continue;
			double prob = 1.0;
			rep(j,lst[i].size()){
				int x = lst[i][j];
				prob *= bad[x];
			}
			ans *= (1.0-prob);
		}
		printf("%.12f\n",ans);
	}
}


Measured memory_bytes: 3284
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

vector< bool > prime_table(int n) {
    vector< bool > prime(n + 1, true);
    if(n >= 0) prime[0] = false;
    if(n >= 1) prime[1] = false;
    for(int i = 2; i * i <= n; i++) {
        if(!prime[i]) continue;
        for(int j = i + i; j <= n; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}
int main() {
    auto t = prime_table(100000000);
    SS(ll,n)
    ll ret=0;
    rep(i,n){
        SS(ll,x);
        ret += t[x];
    }
    cout << ret << endl;
}


Measured memory_bytes: 14860
#include<stdio.h>
#define N 100001

int depth(int);
int height(int);
int sibling(int);

int dep;

struct Node{
  int p;
  int l;
  int r;
};
struct Node Tree[N];

 
int main()
{
 
  int i,n,par,left,right,sib,deg=0;
 
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    Tree[i].p = -1;
    Tree[i].l = -1;
    Tree[i].r = -1;
  }
 
  for(i = 0; i < n; i++){
    scanf("%d %d %d",&par,&left,&right);
    Tree[left].p=par;
    Tree[right].p=par;
    Tree[par].l=left;
    Tree[par].r=right;
  }
 
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, ",i , Tree[i].p);
    
  
    printf("sibling = %d, ",sibling(i));

    if(Tree[i].r != -1)deg++;
    if(Tree[i].l != -1) deg++;
    printf("degree = %d, ",deg);
    deg=0;
    
    printf("depth = %d, ",depth(i));

   printf("height = %d, ",height(i));

   if(Tree[i].p == -1)printf("root");
   else  if(Tree[i].l  == -1 && Tree[i].r == -1)printf("leaf");
   else printf("internal node");
   printf("\n");
  }
  return 0;
}
 
int depth(int k){
  int dep_dep =0;
  for(dep_dep = 0; Tree[k].p != -1; dep_dep++){
    k = Tree[k].p;
  }
  return dep_dep;
}


int height(int u){
  int h1=0,h2=0;
  if(Tree[u].l!=-1){
    h1 = height(Tree[u].l)+1;
  }
  if(Tree[u].r!=-1){
    h2 = height(Tree[u].r)+1;
  }
  if(h1 > h2) return h1;
  else return h2;
}

int sibling(int u){
  int NIL=-1;
  if(Tree[u].p == NIL) return NIL;
  else if(Tree[Tree[u].p].l!=u && Tree[Tree[u].p].l!=NIL){
    return Tree[Tree[u].p].l;
  }
  else if(Tree[Tree[u].p].r!=u && Tree[Tree[u].p].r!=NIL) {
    return Tree[Tree[u].p].r;
  }
  return NIL;
}

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

def abc(x,y,z): #x,y:高さまたは幅、z:ｙの幅をもつピースの高さ
    a = z * y
    if (x-z)&1 and y&1:
        b = max(x-z, y)//2 * min(x-z,y)
        c = x*y - a - b
    else:
        b = c = (x-z)*y//2
    return a, b, c

def diffS(a,b,c): #a,b,c:abc()の戻り値
    return max(a, b, c) - min(a, b, c)

def solve(x, y): #x,y:高さまたは幅
    z = x // 3
    return min(diffS(*abc(x,y,z)), diffS(*abc(x,y,z+1)))


if H % 3 == 0 or W % 3 == 0:
    ans = 0
else:
    ans = min(solve(H,W), solve(W,H))
print(ans)

Measured memory_bytes: 9160
package main

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

var (
	BufferSize = 10*10*10*10*10 + 10
)

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func getRev(before byte) byte {
	if before == '0' {
		return '1'
	}
	return '0'
}

func check() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	s := scanStr(sc)

	zeroFirstCount := 0
	oneFirstCount := 0
	for i := 0; i < len(s); i++ {
		surplus := i % 2
		if surplus == 0 {
			// 0, 2, 4,...
			if s[i] == '0' {
				oneFirstCount++
			} else {
				zeroFirstCount++
			}
		} else {
			// 1, 3, 5, ...
			if s[i] == '0' {
				zeroFirstCount++
			} else {
				oneFirstCount++
			}
		}
	}

	ret := 0
	if zeroFirstCount < oneFirstCount {
		ret = zeroFirstCount
	} else {
		ret = oneFirstCount
	}

	fmt.Printf("%d\n", ret)
}

func main() {
	check()
}


Measured memory_bytes: 768
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < n; i++) w[i] = scanner.nextInt();

        long left = 0;
        long right = IntStream.of(w).sum() + 1;
        long result = -1;
        while (left < right) {
            long mid = (left + right) / 2;
            if (check(w,  k,  mid)) {
                result = mid;
                right = mid;
            } else {
                left = mid + 1;
            }
        }

        System.out.println(result);
    }

    private static boolean check(int[] w, int k, long p) {
        int i = 0;
        for (int j = 0; j < k; j++) {
            int k_w = 0;
            while (k_w + w[i] <= p) {
                k_w += w[i];
                i++;
                if (i == w.length) return true;
            }
        }
        return false;
    }

}



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

// global variables
#define debug(x) cout << #x << ": " << x << endl
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

// typedef
typedef pair<int, int> P;
// sort by P.first (asd)
bool comPair(const P &firstElof, const P &secondElof) {
    return firstElof.first < secondElof.first;
}

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

#define MAX_N 100000 //10^5

template <class Abel>
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n);
        rank.resize(n);
        diff_weight.resize(n);
        for (int i = 0; i < n; ++i)
            par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

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

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

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

    bool merge(int x, int y, Abel w) {
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind<int> uf(n);
    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        r--;
        if (uf.issame(l, r)) {
            if (uf.diff(l, r) != d) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            uf.merge(l, r, d);
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

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

ll solve1(vector<pii> LR)
{
    vector<int> L;
    vector<int> R;
    int N = LR.size();
    for (int i = 0; i < N; i++)
    {
        L.push_back(LR[i].first);
        R.push_back(LR[i].second);
    }
    sort(L.rbegin(), L.rend());
    sort(R.begin(), R.end());
    ll res = 0;
    int li, ri;
    li = ri = 0;
    ll pos = 0;
    while (ri < N)
    {
        cerr << L[li] << " " << R[ri] << " " << pos << endl;
        if (li == ri)
        {

            if (L[li] < pos)
            {
                break;
            }
            res += L[li] - pos;
            pos = L[li];
            li++;
        }
        else
        {
            if (R[ri] > pos)
            {
                break;
            }
            res += pos - R[ri];
            pos = R[ri];
            ri++;
        }
    }
    // cerr << li << " " << ri << endl;
    res += abs(pos);
    return res;
}

int main()
{
    int N;
    cin >> N;
    vector<pii> LR;
    LR.resize(N);

    for (int i = 0; i < N; i++)
    {
        cin >> LR[i].first >> LR[i].second;
    }
    ll res1 = 0;
    ll res2 = 0;
    res1 = solve1(LR);

    for (int i = 0; i < N; i++)
    {
        swap(LR[i].first, LR[i].second);
        LR[i].first = -LR[i].first;
        LR[i].second = -LR[i].second;
    }
    res2 = solve1(LR);
    // cout << res1 << " " << res2 << endl;
    cout << max(res1, res2) << endl;

    return 0;
}

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, sum=0;

	cin>>n;

	vi a(n+2, 0), dist(n+1, 0);

	repr(i, 1, n+1) cin>>a[i];

	rep(i, n+1){
		dist[i]=abs(a[i+1]-a[i]);
		sum+=dist[i];
	}

	rep(i, n){
		cout<<sum-dist[i]-dist[i+1]+abs(a[i]-a[i+2])<<endl;
	}

}

Measured memory_bytes: 2048
from math import*
M=10**9+7
n=int(input())
s=input()
if s[0]==s[-1]=='W':
  print(0)
  exit()
l=a=1
r=f=0
for b,c in zip(s,s[1:]):
  if b==c:
    f^=1
  if f:
    a*=l-r
    a%=M
    r+=1
  else:
    l+=1
print(a*factorial(n)%M*(l==r))

Measured memory_bytes: 46684
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 2e6;
const char newl = '\n';

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

vl get_inv(ll p, ll n){
  vl inv(n+1);
  inv[1] = 1;
  for(ll i=2; i<=n; i++) inv[i] = p - inv[p%i] * (p/i) % p;
  return inv;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll k;
  string s;
  cin >> k >> s;
  
  ll S=s.size();
  
  vl inv = get_inv(MOD, MAX);
  
  vl factorial(MAX+1);
  factorial[0]=1;
  rep(i, MAX) factorial[i+1] = (factorial[i]*(i+1))%MOD;
  vl inv_fac(MAX+1);
  inv_fac[0]=1;
  rep(i, MAX) inv_fac[i+1] = (inv_fac[i]*inv[i+1])%MOD;
  
  ll ans=0;
  rep(K, k+1) {
    ll num=modpow(26, k-K);
    (num *= modpow(25, K)) %= MOD;
    (num *= factorial[S+K-1]) %= MOD;
    (num *= inv_fac[S-1]) %= MOD;
    (num *= inv_fac[K]) %= MOD;
    (ans += num) %= MOD;
  }
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 51244
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        a: usize,
        b: String,
    }
    let k = b.len() - b.chars().position(|c| c == '.').unwrap() - 1;
    let b = b
        .chars()
        .filter(|&c| c != '.')
        .collect::<String>()
        .parse::<usize>()
        .unwrap();
    let c = a * b;
    eprintln!("{}", k);
    println!("{}", c / 10usize.pow(k as u32));
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


modint dp[100005][2];

void solve() {
    string s; cin >> s;
    int N = s.size();
    dp[0][0] = 1;
    rep(i, N){
        if(s[i] == '1'){
            dp[i+1][0] += dp[i][0]*modint(2);
            dp[i+1][1] += dp[i][0] + dp[i][1]*modint(3);
        }else{
            dp[i+1][0] += dp[i][0];
            dp[i+1][1] += dp[i][1]*modint(3);
        }
    }
    modint res = dp[N][0] + dp[N][1];
    cout << res.n << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

vector<vector<pll>> adj;
vl col;

void dfs(ll i, ll p) {
	for (auto e: adj[i]) if (e.xx != p) {
		col[e.xx] = (col[i] + e.yy) % 2;
		dfs(e.xx,i);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	adj.resize(n);
	FOR(i,1,n) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		adj[a].eb(b,c);
		adj[b].eb(a,c);
	}
	
	col.resize(n);
	dfs(0,-1);
	
	FOR(i,0,n) cout << col[i] << endl;
}



Measured memory_bytes: 9984
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	t0, x0, y0 := 0, 0, 0
	for i := 0; i < n; i++ {
		var t, x, y int
		fmt.Scan(&t, &x, &y)
		dt := t - t0
		dx := x - x0
		dy := y - y0
		if dt-dx-dy < 0 || (dt-dx-dy)%2 != 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  LL x,y,a,b,c; cin>>x>>y>>a>>b>>c;
  vector <LL> va(a), vb(b), vc(c);
  for(auto &i:va) cin>>i;
  for(auto &i:vb) cin>>i;
  for(auto &i:vc) cin>>i;
  sort(va.begin(),va.end());
  sort(vb.begin(),vb.end());
  sort(vc.begin(),vc.end());
  LL an = 0;
  LL l = a-x, r = b-y, z = c-1;
  for(int i=l;i<a;i++) an+=va[i];
  for(int i=r;i<b;i++) an+=vb[i];
  while(1){
    if(z<0) break;
    if(r >= b && l>= a) break;
    int bo = 1;
    if(r>=b && l<a){
        if(vc[z] > va[l]) {
          an+=vc[z]-va[l];
          z--,l++;
        continue;
        }
        break;
    }  
    if(l>=a && r<b){
        if(vc[z] > vb[r]) {
          an+=vc[z]-vb[r];
          z--,r++;
          continue;
        }
        break;
    }  

    if(va[l] > vb[r]){
        if(vc[z] > vb[r]) {
          an+=vc[z]-vb[r];
          z--,r++;
          continue;
        }
      }
    else{
        if(vc[z] > va[l]) {
          an+=vc[z]-va[l];
          z--,l++;
          continue;
        }
    }
    break;
  }
  cout<<an<<endl;
  return 0;

}



Measured memory_bytes: 2560
void main() {
  problem();
}

void problem() {
  const S = scan;
  auto N = S.length;

  long solve() {
    if (N < 4) return 0;
    
    const P = 2019;
    long ans;

    auto cs = new long[](P);
    cs[0] = 1;

    long x, t = 1;
    foreach_reverse (c; S) {
        x = ((c-'0').to!long * t + x) % P;
        t = (t * 10) % P;
        ans += cs[x];
        ++cs[x];
    }
    return ans;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");
import std.bigint, std.functional;

const MOD = 100_000_000_7;

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


Measured memory_bytes: 3052
#include<bits/stdc++.h>
#define reg register
#define ll long long
#define inf 0x3f3f3f3f
#define iinf 0x3f3f3f3f3f3f3f3fll
using namespace std;
class data
{
	public:
		int x,y;
		inline bool operator<(const data &b)const
		{
			return y<b.y;
		}
}a[1000005];
int n,m,now,ans;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(reg int i=1;i<=m;i++)cin>>a[i].x>>a[i].y;
	sort(a+1,a+m+1);
	for(reg int i=1;i<=m;i++)
	if(now<=a[i].x)
	{
		now=a[i].y;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n,w1,v,i,j,k,w;
  cin>>n>>w;
  vector<pair<ll,ll> >arr;
  ll value[n+1][w+1];
  for(i=0;i<n+1;i++)
  {
    for(j=0;j<w+1;j++)
    {value[i][j]=0;}
  }
  for(i=0;i<n;i++)
  {
    cin>>w1>>v;
    arr.push_back(make_pair(w1,v));
  }
  for(i=1;i<n+1;i++)
  {
    for(j=1;j<w+1;j++) 
    {
      if(arr[i-1].first==j)
      {
        value[i][j]=max(arr[i-1].second,value[i-1][j]);
      }
      else if(arr[i-1].first<j)
      {
        value[i][j]=max(arr[i-1].second+value[i-1][j-arr[i-1].first], value[i-1][j]);
      }
      else
      {
        value[i][j]=value[i-1][j];
      }
      
      
    }
  }
  cout<<value[n][w]<<endl;
}
  

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

int main () {
    int n, k, ans = 0;
    cin >> n >> k;
    int a[n];

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    sort(a,a+n);
    for (int i = 0; i < k; i++) {
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int len = s.length();
    int a[n], b[n];
    a[0] = 0;
    b[n - 1] = 0;
    for (int i = 1; i < len; i++)
    {
        int diff = 0;
        if (s[i - 1] == 'W')
        {
            diff = 1;
        }
        a[i] = a[i - 1] + diff;
    }
    for (int i = len - 2; i >= 0; i--)
    {
        int diff = 0;
        if (s[i + 1] == 'E')
        {
            diff = 1;
        }
        b[i] = b[i + 1] + diff;
    }
    int ans = n + 100;
    REP(i, n)
    {
        ans = min(ans, a[i] + b[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
double M[12][4096],r,t;D[12],n;
double dfs(p,f){if(M[p][f]<0){
int i=0;
for(M[p][f]=0;i<n;i++)if(!(f&1<<i)&&(t=dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]),M[p][f]<t))M[p][f]=t;
}return M[p][f];}
main(l,i,j,d){for(;~scanf("%d",&l);puts(d-r>l?"NA":"OK")){
for(d=n=0;getchar()-10;d+=D[n++]*2)scanf("%d",D+n);
for(i=0;i<n;i++)for(j=0;j<1<<n;j++)M[i][j]=-1;
for(r=i=0;i<n;)t=dfs(i++,1<<i),r=r>t?r:t;
}exit(0);}

Measured memory_bytes: 964
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,pair<int,int>> PII;
int n,m;
char grid1[55][55],grid2[55][55];
int compare(int i,int j){
	int l,k,o=0,p=0;
	for(l=i;l<n&&o<m;l++,o++){
		p=0;
		for(k=j;k<n&&p<m;k++,p++){
			if(grid1[l][k]!=grid2[o][p]){
				return 0;
			}
		}
	}
	if(o<m||p<m){

		return 0;
	}
	return 1;
}
int main() 
{ 
	turbo();
	int i,j;
	cin>>n>>m;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cin>>grid1[i][j];
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<m;j++){
			cin>>grid2[i][j];
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			int ans=compare(i,j);
			if(ans){
				cout<<"Yes\n";
				return 0;
			}
		}
	}
	cout<<"No\n";
    return 0; 
} 

Measured memory_bytes: 256
#N　展望台の数　M　道の数
N,M = map(int, input().split())
#高さ
H =list(map(int,input().split()))

ans=0
di = {}
#道
J=[""]*M
for i in range(M):
  a,b=list(map(int, input().split()))
  di.setdefault(a,[])
  di[a].append(b)
  di.setdefault(b,[])
  di[b].append(a)
  
#  J[i]=(list(map(int, input().split())))

for i in range(1,N+1):
  flg = 0

  if i in di.keys():
#    print(i)
#    print(di[i])
    for k in di[i]:
      if H[k-1] >= H[i-1]:
        flg = 1
    if flg == 0:
      ans+=1

  else:
    ans+=1

    
print(ans)

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;
#define pow10(n) int(1e##n + n)

void solve()
{
    string S;
    cin >> S;

    REP0(i, S.length())
    {
        cout << "x";
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b;cin>>a>>b;
  if(a==1)a=14;
  if(b==1)b=14;
  if(a>b)cout<<"Alice"<<endl;
  else if(a==b){
    cout<<"Draw"<<endl;
  }
  else cout<<"Bob"<<endl;

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#define ll long long
using namespace std;
ll SSS(string str)
{
    int len=str.size();
    ll sum=0;
    for(int i=0;i<len;i++)
    {
        sum=sum*10+(str[i]-'0');
    }
    return sum;
}
ll int search(string s1,ll presum){
	int i;
  	ll k,sum;
  	sum = 0;
  	for (i=1;i<=s1.size();i++){
      	string s2 = s1.substr(0,i);//[0,i)
      	string s3 = s1.substr(i);
      	if (s3==""){
        	s3 = "AC";//---//---//
        }
      	if(i == s1.size()){
        	sum += SSS(s1)+presum;//---
        }else{
            k = SSS(s2);//---
            if (s3=="AC"){
            	sum += k + presum;//--
            }else{
            	sum += search(s3,k + presum);
            }
        }
    }
  	return sum;//
}
int main(){
	ll sum;
  	string s;
  	cin >> s;
  	sum = search(s,0);//dfs
  	cout << sum;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
const ll MOD = 1E9 + 7;
const ll INF = 1 << 29;

int main() {
  ll N;
  cin >> N;
  char S[N];
  ll CountR = 0;
  ll CountG = 0;
  ll CountB = 0;
  rep(i, N) {
    cin >> S[i];
    if (S[i] == 'R') CountR++;
    if (S[i] == 'G') CountG++;
    if (S[i] == 'B') CountB++;
  };
  ll ans = CountR * CountG * CountB;
  for (ll i = 0; i < N - 2; i++) {
    ll d = 1;
    while (i + 2 * d < N) {
      if ((S[i] != S[i + d]) && (S[i + d] != S[i + 2 * d]) &&
          (S[i + 2 * d] != S[i])) {
        ans--;
      }
      d++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

long long gcd(long long a, long long b) {
  if (b == 0) return a;

  return gcd(b, a % b);
}

long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) {
    res[n]++;
  }
  return res;
}

ll N;
ll A[1010101];

int main() {
  //
  cin >> N;
  rep(i, 0, N) { cin >> A[i]; }

  ll gcdd = A[0];
  rep(i, 0, N) { gcdd = gcd(gcdd, A[i]); }
  if (gcdd != 1) {
    cout << "not coprime";
    return 0;
  }

  set<ll> facts;
  rep(i, 0, N) {
    auto res = prime_factor(A[i]);
    for (auto e : res) {
      if (facts.count(e.first) == 1) {
        cout << "setwise coprime";
        return 0;
      }

      facts.insert(e.first);
    }
  }

  cout << "pairwise coprime";
}


Measured memory_bytes: 11444
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		int k = sc.nextInt();

		long lo = b - a + 1;
		if (lo <= k*2) {

			for (long i = a; i <= b; i++) {

				System.out.println(i);
			}
		} else {
			for (long i = a; i <= a + k-1; i++) {
				System.out.println(i);
			}
			for (long i = b - k+1; i <= b; i++) {
				System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

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

void solve()
{
    int n;
    cin>>n;
    vl a(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    ll g=a[0];
    for(int i=1;i<n;i++) {
        g =__gcd(g,a[i]);
    }
    vi sieve(1e6+1,0),prime;
    
    for(int i=2;i*i<=1e6;i++) {
        //if(sieve[i]!=1) prime.pb(i);
        for(int j=i*i;j<=1e6;j+=i) {
            sieve[j]=1;
        }
    }

    for(int i=2;i<=1e6;i++) {
        if(sieve[i]!=1) prime.pb(i);
    }

    set<ll> s;
    //cout<<sz(prime)<<newl;
    for(int i=0;i<n;i++) {
        ll x=a[i];
        for(int p:prime) {
            if(p*p>x) break;
            if(x%p==0) {
                if(s.count(p)) {
                    if(g==1)
                        cout << "setwise coprime";
                    else
                        cout << "not coprime";
                    return;
                }
                else {
                    s.insert(p);
                }
            }
            while(x%p==0) {
                x/=p;
            }
        }
        if(x>1) {
            if (s.count(x))
            {
                if (g == 1)
                    cout << "setwise coprime";
                else
                    cout << "not coprime";
                return;
            }
            else
            {
                s.insert(x);
            }
        }
    }

    cout << "pairwise coprime";
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        //cout << newl;
    }

    return 0;
}

Measured memory_bytes: 15620
# ABC141D - Powerful Discount Tickets
from heapq import heapify, heappop, heappush


def main():
    N, M, *A = map(int, open(0).read().split())
    B = [-i for i in A]
    heapify(B)
    for _ in range(M):
        x = -heappop(B) >> 1
        heappush(B, -x)
    ans = -sum(B)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14180
#import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

N = int(input())
A = list(map(int,input().split())) ## 横一列

A = sorted(A)

for i in range(N-1):
  if A[i] == A[i+1]:
    print('NO')
    exit()
else:
  print('YES')



Measured memory_bytes: 112976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)

int main() {
    string S;
    cin >> S;
    int ans = 0;
    rep(i,S.length()/2){
        if(S[i]==S[S.length()-i-1]){
            continue;
        }else{
            ans ++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    vector<pair<int, int>> xy(n);
    for (int i = 0; i < n; i++)
    {
        int t1, t2, t3;
        cin >> t1 >> t2 >> t3;
        if (t3 > 2)
            xy[i] = make_pair(t2, t3);
        else
            xy[i] = make_pair(t1, t3);
    }
    int lw = 0, uw = w, lh = 0, uh = h;
    for (auto x : xy)
    {
        if (x.second > 2)
        {
            if (x.second % 2 == 1)
                lh = max(x.first, lh);
            else
                uh = min(x.first, uh);
        }
        else if (x.second % 2 == 1)
            lw = max(x.first, lw);
        else
            uw = min(x.first, uw);
    }
    if ((uw - lw) < 0 || (uh - lh) < 0)
        cout << 0 << endl;
    else
        cout << (uw - lw) * (uh - lh) << endl;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N+1);
    REP(i,1,N+1) cin >> A[i];

    vec CO((N+1)/2+1, 0), CE((N-1)/2+1, 0);
    REP(i,1,(N+1)/2+1) CO[i] += CO[i-1] + A[i*2-1] * 2;
    REP(i,1,(N-1)/2+1) CE[i] += CE[i-1] + A[i*2] * 2;

    vec B(N+1);
    ll S = (CO[(N+1)/2] + CE[(N-1)/2]) / 2;
    REP(i,1,(N+1)/2+1) B[i*2-1] = S - (CO[i-1] + CE[(N-1)/2] - CE[i-1]);
    REP(i,1,(N-1)/2+1) B[i*2] = S - (CE[i-1] + CO[(N+1)/2] - CO[i]);
    REP(i,1,N+1) PS(B[i]);
    PR("");

    return 0;
}

/*



*/

Measured memory_bytes: 5636
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(long long N, long long K) {
  ll ans = 0, k = 1;
  while (k <= N) {
    ++ans;
    k *= K;
  }
  ANS(ans);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  solve(N, K);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long long ll;
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; }

const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll gcd( ll x ,ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  vector<ll>a(n);
  ll sum=0,sum_odd=0;
  rep(i,n){
    cin >> a[i];
    sum+=a[i];
    a[i]=2*a[i];
    if(i%2==1)sum_odd+=a[i];
  }
  vector<ll>b(n);
  b[0]=sum-sum_odd;
  rep(i,n-1){
    b[i+1]=a[i]-b[i];
  }
  rep(i,n){
    if(i!=0)cout << " ";
    cout << b[i];
  }    
}


Measured memory_bytes: 2944
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
vvb visited;
int main(void)
{
	int n, x;

	cin>>n>>x;

	vll a(n), sum(n+1, 0);

	rep(i, n) cin>>a[i];

	sort(all(a));

	rep(i, n){
		sum[i+1]=sum[i]+a[i];
	}

	rep(i, n+1){
		if(sum[i]==x){
			cout<<i<<endl;
			return 0;
		}else if(sum[i]>x){
			cout<<i-1<<endl;
			return 0;
		}
	}
	cout<<n-1<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a,b,c,d,i,f;
    while(scanf("%d",&i) != EOF){
        if(i>36){
            f=0;
        }
        else{
        f=0;
        for(a=0;a<=9;a++){
            for(b=0;b<=9;b++){
                for(c=0;c<=9;c++){
                    for(d=0;d<=9;d++){
                        if(a+b+c+d == i){
                            f++;
                        }
                    }
                }
            }
        }
        }
        printf("%d\n",f);
    }
    return (0);
}

Measured memory_bytes: 592
import math
 
n = int(input())
a = [int(i) for i in input().split(" ")]

m = n * (n + 1) // 2
 
class BIT:
    def __init__(self, n):
        self.t = [0] * (n + 1)
    
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.t[i]
            i -= (i & -i)
        return s
    
    def add(self, i, v):
        while i < len(self.t):
            self.t[i] += v
            i += (i & -i)
            
def count(s):
    s_min = min(s)
    b = BIT(max(s) - s_min + 1)
    t = [0] * len(s)
    for j in range(0, len(s)):
        t[j] = b.sum(s[j] - s_min + 1)
        b.add(s[j] - s_min + 1, 1)
    return sum(t)
            
def bs(l, r):
    if l == r:
        return l
    else:
        h = math.ceil((l + r) / 2)
        
        ab = [-1 if a[i] < h else 1 for i in range(0, n)]
        s = [0] * (n + 1)
        
        for i in range(1, n + 1):
            s[i] = s[i - 1] + ab[i - 1]
            
        if count(s) >= math.ceil(m / 2):
            return bs(h, r)
        else:
            return bs(l, h - 1)
        
print(bs(min(a), max(a)))

Measured memory_bytes: 122468
S = list(input())
ans = 0
for bit in range(1 << len(S)-1) :
    BIT = []
    calc = ""
    for k in range(len(S)-1) :
        if bit & (1 << k) :
            BIT.append(1+k)
    for k in range(len(S)) :
        if k in BIT :
            calc += "+"
        calc += S[k]
    ans += eval(calc)
print(ans)


Measured memory_bytes: 3060
//  cd Desktop/Atcoder
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define rep(i,n) for(i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

int compare_smallorder(const void *a, const void *b){return *(int*)a - *(int*)b;}


int main(){
    ull ans=0;
    int j,i,n,q,a[100002]={},b[100002]={},c[100002]={},table[100002]={};
    scanf("%d",&n);
    rep(i,n){
        scanf("%d",&a[i]);
        ans+=a[i];
        table[a[i]]++;
    }
    scanf("%d",&q);
    rep(i,q) scanf("%d%d",&b[i],&c[i]);
    rep(i,q){
        ans+=(c[i]-b[i])*table[b[i]];
        table[c[i]]+=table[b[i]];
        table[b[i]]=0;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3296
#include <iostream>
#include <vector>
#include <numeric>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
int main() {
    int n, k; cin >> n >> k;
    vector<ll> a(n); repeat (i,n) cin >> a[i];
    vector<ll> a_acc { 0 }; whole(partial_sum, a, back_inserter(a_acc));
    vector<ll> b(n); repeat (i,n) b[i] = max<int>(0, a[i]);
    vector<ll> b_acc { 0 }; whole(partial_sum, b, back_inserter(b_acc));
    ll ans = 0;
    repeat (l,n-k+1) {
        int r = l+k;
        setmax(ans, (b_acc[l] - b_acc[0])                         + (b_acc[n] - b_acc[r]));
        setmax(ans, (b_acc[l] - b_acc[0]) + (a_acc[r] - a_acc[l]) + (b_acc[n] - b_acc[r]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4084