akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s;
	std::cin >> s;
	int diff = 0;
	rep(i,s.size()/2) {
		if(s[i]!=s[s.size()-i-1]) diff++;
	}
	print(diff);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

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

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

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

template<typename T>
struct Max_Flow{
    struct edge{
        int to; T cap; int rev;
        edge(int to, T cap, int rev) : to(to), cap(cap), rev(rev) {}
    };

    vector<vector<edge>> es;
    vector<bool> used;
    const T INF_T;

    Max_Flow(int n) : INF_T(numeric_limits<T>::max()){
        es.resize(n), used.resize(n);
    }

    void add_edge(int from, int to, T cap, bool directed = true){
        es[from].eb(to, cap, sz(es[to]));
        es[to].eb(from, directed? 0 : cap, sz(es[from])-1);
    }

    T dfs(int now, int t, T flow){
        if(now == t) return flow;
        used[now] = true;
        for(auto &e: es[now]){
            if(!used[e.to] && e.cap > 0){
                T f = dfs(e.to, t, min(flow, e.cap));
                if(f > 0){
                    e.cap -= f;
                    es[e.to][e.rev].cap += f;
                    return f;
                }
            }
        }
        return 0;
    }

    T max_flow(int s, int t){
        T flow = 0;
        for(;;){
            fill(all(used), false);
            T f = dfs(s, t, INF_T);
            if(f == 0) return flow;
            flow += f;
        }
    }
};

int main(){
    while(true){
        int N, M;
        cin >> N >> M;
        if(N == 0) break;
        int b[N], r[M];
        rep(i, N) cin >> b[i];
        rep(i, M) cin >> r[i];
        Max_Flow<int> G(N+M+2);
        int s = N+M, t = N+M+1;
        rep(i, N) G.add_edge(s, i, 1);
        rep(i, M) G.add_edge(N+i, t, 1);
        rep(i, N){
            rep(j, M){
                if(gcd(b[i], r[j]) > 1) G.add_edge(i, N+j, 1);
            }
        }
        cout << G.max_flow(s, t) << endl;
    }
}


Measured memory_bytes: 7400
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
typedef long long int ll;
const double pi = 3.14159265358979323846;

int main() {
    fast
    //test
    {
        int a,b,c;
        cin >> a>>b>>c;
		int c5=0,c7=0;
      	if(a==5)c5++;
      	if(a==7)c7++;
      	if(b==5)c5++;
      	if(b==7)c7++;
      	if(c==5)c5++;
      	if(c==7)c7++;
      if(c5==2&&c7==1)cout<<"YES";
      else cout<<"NO";
    }
	return 0;
}


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

int main() {
  long long n, th = 1;
  int keta = 0;
  string ans;
  cin >> n;
  for (int j = 0; j < 11; j++) {
    n -= th;
    th *= 26;
    keta++;
    if (n < th) {
      for (int i = 0; i < keta; i++) {
        ans = (char)('a' + n % 26) + ans;
        n /= 26;
      }
      cout << ans << endl;
      return 0;
    }
  }
}

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

int H,W;
int C[26] = {0};
char c;

bool evens(){
	for(int i=0;i<=25;i++){
		if(C[i]%2!=0) return false;
	}
	return true;
}

bool evens_odd(){
	int count = 0;
	//cout << count << endl;
	for(int i=0;i<=25;i++){
		if(C[i]%2!=0) count++;
	}
	if(count==1) return true;
	else return false;
}

bool fours(){
	for(int i=0;i<=25;i++){
		if(C[i]%4!=0) return false;
	}
	return true;
}

bool odd_odd1(){
	int count = 0;
	for(int i=0;i<=25;i++){
		while(C[i]>=4){
			if(count==(H/2)*(W/2)) break;
			count++;
			C[i] -= 4;
		}
		if(count==(H/2)*(W/2)) break;
	}
	if(count <(H/2)*(W/2)) return false;
	else return evens_odd();
}


bool even_odd(){
	int count = 0;
	for(int i=0;i<=25;i++){
		while(C[i]>=4){
			if(count==(H/2)*(W/2)) break;
			count++;
			C[i] -= 4;
		}
		if(count==(H/2)*(W/2)) break;
	}
	if(count < (H/2)*(W/2)) return false;
	else return evens();
}

int main(){
	cin >> H >> W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> c;
			C[c-'a']++;
		}
	}
	if(H==1 && W==1) cout << "Yes" << endl;
	else if((H==1 && W%2==0) || (W==1 && H%2==0)){
		if(evens()) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else if((H==1 && W%2==1) || (W==1 && H%2==1)){
		if(evens_odd()) cout << "Yes" << endl;
		else cout << "No" << endl;
	}else if(H%2==0 && W%2==0){
		if(fours()) cout << "Yes" << endl;
		else cout << "No" << endl;		
	}else if(H%2==1 && W%2==1){
		if(odd_odd1()) cout << "Yes" << endl;
		else cout << "No" << endl;				
	}else{
		if(even_odd()) 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;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

const int MAX = 1000000;
long long fac[MAX], finv[MAX], inv[MAX];

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

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

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);

    REP(i, N){
        cin >> A[i];
    }

    // 前処理
    COMinit();

    sort(A.begin(), A.end());

    ll minus = 0;
    for(ll i=0; i<N; i++){
        if(N-1-i < K-1) break;
        minus += (A[i] * (COM(N-1-i, K-1) % MOD)) % MOD;
        minus = minus % MOD;
    }

    sort(A.rbegin(), A.rend());

    ll plus = 0;
    for(ll i=0; i<N; i++){
        if(N-1-i < K-1) break;
        plus += (A[i] * (COM(N-1-i, K-1) % MOD)) % MOD;
        plus = plus % MOD;
    }

    plus = (plus+MOD) % MOD;
    minus = (minus+MOD) % MOD;
    // cout << plus << endl;
    // cout << minus << endl;
    // cout << (plus - minus) << endl;
    // cout << (plus - minus) + MOD << endl;
    cout << (plus + MOD - minus) % MOD << endl;

    return 0;
}

Measured memory_bytes: 27552
import sys

stdin = sys.stdin.readline
na = lambda: map(int, stdin().split())
ns = lambda: stdin().rstrip()
ni = lambda: int(ns())
def main():
  n = ni()
  a = list(na())
  b = list(na())
  c = list(na())

  ans = 0
  pre = 0
  for i, aa in enumerate(a):
    aa -= 1
    if i >= 1 and i <= n-1 and pre+1 == aa:
      ans += c[aa-1]
    ans += b[aa]
    pre = aa
  print(ans)
main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
using namespace std;

const int N = 1e9 + 1, mod = 1e9 + 7;
const int inf = 1e9;

bool P(const int &a, const int &b){
    return a > b;
}

ll power(ll x, ll p){
    ll r = 1ll;
    x = x % mod;
    while(p > 0){
        if(p & 1) r = (r * x) % mod;
        p = p >> 1;
        x = (x * x) % mod;
    }
    return r;
}
int n;
ll fun(vector<int> v[]){
    ll ans = 0;
    priority_queue<int, vi, greater<int>> p;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < (int)v[i].size(); j++){
            p.push(v[i][j]);
        }
        while(p.size() > i){
            p.pop();
        }
    }
    while(!p.empty()){
        ans += p.top();
        p.pop();
    }
    return ans;
}

void solve(){
    cin >> n;
    ll ans = 0;
    vi v1[n + 1], v2[n + 1];
    for(int i = 0; i < n; i++){
        int k, l, r;
        cin >> k >> l >> r;
        ans += min(l, r);
        if(l > r){
            v1[k].pb(l - r);
        }
        else if(r > l && n != k){
            v2[n - k].pb(r - l);
        }
    }
    ans += fun(v1);
    ans += fun(v2);
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);//cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    //t=1;
    cin>>t;
    for(p=1;p<=t;p++){
        //cout << power(2, 5);
        solve();
    }
    return 0;
}


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

int k;

int main(void){
  // Here your code !
  scanf("%d", &k);
  if (k % 2 == 0) {
    printf("%d\n", (k / 2) * (k / 2));
  }
  else printf("%d\n", (k / 2) * (1 + k / 2));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=1e5+5;

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


int main(){
	int N;
  	cin>>N;
	int a[MAX];
	rep1(i,N)cin>>a[i];
	
	int l[MAX];
	int r[MAX];
	
	l[0]=0;
	rep1(i,N)l[i]=gcd(l[i-1],a[i]);
	r[N+1]=0;
	for(int i=N;i>=1;i--)r[i]=gcd(r[i+1],a[i]);
	
	int ans=0;
	rep1(i,N){
		int pa=gcd(l[i-1],r[i+1]);
		ans=max(ans,pa);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>

using namespace std;
#define int long long
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> all;
	int mini = 99999999999999999LL;
	for (int i = 0; i < 5; i++)
	{
		int x;
		cin >> x;

		mini = min(mini, x);
		all.push_back(x);
	}
	cout << 5 + ((n-1)/mini) << "\n";
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  const int N = 200005;


int n;
vector<vector<int>> adj;
vector<int> a;
vector<int> ans;
multiset<int> ss;
void dfs(int s,int ps)
{

    auto it = ss.lower_bound(a[s]);
    int y = -1 ;
    ss.insert(a[s]);
    if(it != ss.end())
      {
        y = *it;
        ss.erase(it);
      }


    ans[s] = ss.size();
    for(auto &i : adj[s])
    {
      if(i == ps)continue;

      dfs(i,s);
    }


    auto it1 = ss.find(a[s]);
    if(it1 != ss.end())ss.erase(it1); // to delete vertices not in current path


    if(y != -1)ss.insert(y); // to restore LIS 


}


int32_t main()
{



    IOS


    cin >> n;
    adj.resize(n+1);
    a.resize(n+1);
    ans.resize(n+1);

    for(int i = 1; i <=n; i++)cin >> a[i];


    for(int i = 1; i <= n-1; i++)
    {
      int x, y;
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }

    dfs(1,0);


    for(int i = 1; i <= n; i++)cout << ans[i] << endl;


    

    return 0;
}



Measured memory_bytes: 29256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 mod = 1e9 + 7;
i64 n, k, cnt_all[2001], cnt[2001];
vector<i64> a;
int main() {
  cin >> n >> k;
  read_n(a, n);

  for (i64 x : a) cnt_all[x]++;
  i64 ans = 0;
  for (i64 i = 0; i < n; ++i) {
    i64 c = 0, d = 0;
    for (i64 x = a[i] + 1; x <= 2000; ++x) {
      c += cnt_all[x];
      d += cnt[x];
    }
    ans += k * (k - 1) / 2 % mod * c % mod;
    ans += k * d;
    cnt[a[i]]++;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}



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

typedef long long ll;

ll N,L,T;
vector<ll> ans;
ll mem = 0;

int main()
{
    scanf("%d%d%d",&N,&L,&T);
    for(int i = 0; i < N; i++)
    {
        ll X,W;
        scanf("%lld%lld",&X,&W);
        if(W - 1)
        {
            ans.push_back((X + (T % L) * -1 + L) % L);
        }
        else
        {
            ans.push_back((X + T % L) % L);
        }
        ll p = X + T * ((W == 2) * -1 + (W == 1) * 1);
        if(p > 0)mem += p / L;
        else mem += (p - L + 1) / L;
    }
    sort(ans.begin(),ans.end());
    mem = ((mem % N) + N) % N;
    for(int i = 0; i < N; i++)printf("%lld\n",ans[(i + mem) % N]);
    return 0;

}


Measured memory_bytes: 2164
#include <iostream>
#include <algorithm>
#include <string>
#include <memory>
#include <cmath>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <array>




struct Point {
	int x, y;
	std::vector<Point> neighbors() const {
		return { Point{x + 1, y}, Point{x - 1, y}, Point{x, y + 1}, Point{x, y - 1} };
	}
};
int main() {
	int h, w; std::cin >> h >> w;
	std::vector<std::string> state(h);
	for (auto& line : state) std::cin >> line;
	std::vector<std::vector<int>> memo(h, std::vector<int>(w, -1));
	std::queue<Point> queue;
	int count = 0;
	for (auto y = 0; y < h; ++y) for (auto x = 0; x < w; ++x) {
		if (state[y][x] == '#') {
			memo[y][x] = 0;
			queue.push(Point{ x, y});
			++count;
		}
	}
	while (count < h * w) {
		auto current = queue.front();
		queue.pop();
		for (const auto next : current.neighbors()) {
			if (0 <= next.y && next.y < h && 0 <= next.x && next.x < w && state[next.y][next.x] == '.') {
				memo[next.y][next.x] = memo[current.y][current.x] + 1;
				state[next.y][next.x] = '#';
				queue.push(next);
				++count;
			}
		}
	}
	auto max = 0;
	for (auto y = 0; y < h; ++y) for (auto x = 0; x < w; ++x) {
		if (max < memo[y][x]) max = memo[y][x];
	}
	std::cout << max << std::endl;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 200010
const int MOD = 1000000007;

struct pot {
    int s, t, c;
};
int ans[maxn], range[maxn];

void solve() {
    int n, c;
    cin >> n >> c;

    vector<pot> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].s >> v[i].t >> v[i].c;

    for (int i = 1; i <= 30; i++) {
        memset(range, 0, sizeof range);
        for (auto x: v)
            if (x.c == i) {
                range[2 * x.s - 1] += 1;
                range[2 * x.t] -= 1;
            }
        partial_sum(range, range + maxn, range);
        for (int i = 0; i < maxn; i++)
            if (range[i])ans[i]++;
    }
    cout << *max_element(ans, ans + maxn) << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

#define F(i,a,b) for(int i=(a);i<=(b);++i)

const int mod = 1e9 + 7;

const int maxn = 45;
const int maxm = (1<<17) + 10;

int d[maxn][maxm];
int n,x,y,z;

int main()
{
	//freopen("test.txt","r",stdin);
	cin >> n >> x >> y >> z;
	int m = x+y+z;
	d[0][0] = 1;
	F(i,0,n-1)
	{
		F(s,0,1<<m)
		{
			if(!d[i][s]) continue;
			F(p,1,10)
			{
				if(s == 1<<m)
				{
					d[i+1][s] = (d[i+1][s] + d[i][s]) %mod;
					continue;
				}
				int msk = ((s << p) | (1 << (p-1))) & ((1<<m)-1);
			//	printf("%d\n",msk);
				if((msk & 1<<(x-1)) && (msk & 1<<(x+y-1)) && (msk & (1<<(x+y+z-1)))) msk = 1<<m;
				d[i+1][msk] = (d[i+1][msk] + d[i][s]) %mod;
			}
		}
	}
	printf("%d\n",d[n][1<<m]);
	return 0;
}


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

int main () {
  int N, M;
  cin >> N >> M;
  dsu city(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    city.merge(a - 1, b - 1);
  }
  
  vector<vector<int>> group = city.groups();
  cout << (group.size() - 1) << endl;
}

Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
string s[]={ "","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts" };
main(){
  int n,m;
  while(cin>>m>>n,m){
    int a[18]={};
    a[0]=1;
    for(int i=0;i<n;i++)
      for(int j=17;j>=0;j--){
        a[j]*=m;
        a[j+1]+=a[j]/10000;
        a[j]=a[j]%10000;
      }
    for(int i=17;i>=0;i--)if(a[i])cout<<a[i]<<s[i];
    cout<<endl;
  }
}

Measured memory_bytes: 3224
N, M = map(int, input().split())

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
            x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

uf = UnionFind(N)

for _ in range(M):
  x,y,z = map(int, input().split())
  uf.union(x-1,y-1)
  
ans = len(uf.roots())
  
print(ans)


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

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

int find_lower(int *a, int n, int v){
    int l = -1, r = n;

    while (r-l > 1){
        int m = (l+r)/2;
        if (a[m] <= v) l = m;
        else r = m;
    }
    return l;
}

int bin(int *p, int n, int x){
    int l = 0, r = n-1;
    while (r >= l){
        int m = (l+r)/2;
        if (p[m] == x) return m;
        if (p[m] > x) r = m-1;
        else l = m+1;
    }
    return -1;
}



void solve(){
    ll n;
    cin >> n;
    cout << n*n*n << '\n';
}

int main(){
    //init();

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

    //ll t; cin >> t; while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;
public class Main{
    public static void main(String[]args){

        Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	if(a >= 0 && a < 86400){
	    int h = a / 3600;
	    int m = a % 3600 / 60;
	    int s = a % 60;
		System.out.println(h+":"+m+":"+s);
	}
    }
}

Measured memory_bytes: 17308
#include <bits/stdc++.h>
#define fi first
#define se second
#define int long long
using namespace std;
const int N = 2e5 + 1;
const int inf = 1e9;
bool f[N];
void solve() {
    int i, j, k, n;
    string s;
    cin >> s >> k;
    int ansfirst = 0;
    for (i = 1; i < s.size(); ++i)
    if (s[i] == s[i - 1] && (i == 1 || !f[i - 1]))
        ++ansfirst, f[i] = 1;
    int ans = k * ansfirst;
    if (s[0] == s[s.size() - 1] && !f[s.size() - 1]) {
        for (i = 1; i < s.size(); ++i)
        if (s[i] == s[i - 1] && (i == 1 || !f[i - 1]))
            f[i] = 0;
        f[0] = 1;
        int anssecond = 1;
        for (i = 1; i < s.size(); ++i)
        if (s[i] == s[i - 1] && (!f[i - 1]))
            ++anssecond, f[i] = 1;
        if (f[s.size() - 1])
            ans += (k / 2) *(anssecond - ansfirst);
        else
            ans += (k - 1) * (anssecond - ansfirst);
    }
    cout << ans;
}

signed main() {
    #ifdef local
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
}


Measured memory_bytes: 256
n = input()
hs = list(map(int,input().split(" ")))

step = 0
while(True):
  
  if(sum(hs) == 0):
    break
  
  start = None
  stop = None
  
  for i,h in enumerate(hs):

    if(h>0 and start is None):
      start = i
    if(h==0 and start is not None and stop is None):
      stop = i
     	
  if(start is not None and stop is None):
    stop = len(hs)
    
  for i in range(start, stop):
    hs[i] -= 1
    
  step += 1
  
print(step)

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

ll MOD = 1000000007;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n,-1) { }

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

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

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x) {
        return -par[root(x)];
    }
};
int main() {
    vector<pair<int,int>>Q;
    SS(int,n,m)
    UnionFind uf(n);
    rep(i,m){
        SS(int,a,b);
        a--;b--;
        uf.unite(a,b);
    }
    int now=0;
    rep(i,n)Q.push_back(make_pair(uf.root(i),uf.size(i)));
    sort(rbegin(Q),rend(Q));
    for (auto V : Q) {
    if(now!=V.first)n-=V.second-1;
    now=V.first;
    }
    p(n-1);
  
    }

Measured memory_bytes: 4652
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>
 
using namespace std;
typedef long long int ll;
 
#define C cout<<
#define E <<endl
#define CE cout<<endl
 
ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010];
bool r,ra,rb,rc[200010];
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc,vd,ve,vaa,vbb;
set<int> st;
 


template<typename MAIN> ostream & operator<<(ostream & osys,const vector<MAIN> target){ for(MAIN it:target)osys<<it<<" "; return osys; }

ll digit(ll target,short dec=10){
        ll cri=dec;
        ll res=0;
        while(target){
                target/=cri;
                res++;
        }
        return res;
}

int main(){
    cin>>n;
    a=0;
    for(int i=1;i<=n;i++){
            if(digit(i)%2==1)a++;
    }
    C a E;
    
}

//g++ atcoder.cpp ; ./a.exe


Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int n;
vector<int> a;

long long cost(int i, int j) { return abs(a[i] - a[j]); }

int main() {
  cin >> n;
  a.resize(n + 2);
  a[0] = a[n + 1] = 0;
  for (int i = 0; i < n; i++)
    cin >> a[i + 1];
  long long sum = 0;
  for (int i = 0; i < n + 1; i++)
    sum += cost(i, i + 1);
  for (int i = 0; i < n; i++) {
    cout << sum - cost(i, i + 1) - cost(i + 1, i + 2) + cost(i, i + 2) << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
a, b, k = map(int, input().split())
for i in range(100):
    if i >= k:
        break

    if not(i%2):
        if a%2:
            a -= 1
        a /= 2
        b += a
    else:
        if b%2:
            b -= 1
        b /= 2
        a += b


print(int(a), int(b))


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
const int M = 1000000007;
long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

long long L, R;

long long calc(long long lx, long long ly, int i, int j) {
    long long rx = lx + (1LL<<i), ry = ly + (1LL<<j);
    if (ry <= lx || rx <= L || ry <= L || R <= lx || R <= ly) return 0;
    if (L <= lx && rx <= R)
        if (L <= ly && ry <= R) {
            if (i >= j) {
                if (((lx >> i) & (ly >> i)) == (lx >> i)) {
                    int p = __builtin_popcountll((ly>>j)&((1LL<<(i-j))-1));
                    return modexp(3, j, M) * modexp(2, p, M) % M;
                } else
                    return 0;
            } else {
                if (((lx >> j) & (ly >> j)) == (lx >> j)) {
                    int p = __builtin_popcountll((lx>>i)&((1LL<<(j-i))-1));
                    return modexp(3, i, M) * modexp(2, j-i-p, M) % M;
                } else
                    return 0;
            }
        } else {
            long long my = ly + (1LL<<(j-1));
            return (calc(lx, ly, i, j-1) + calc(lx, my, i, j-1)) % M;
        }
    else {
        long long mx = lx + (1LL<<(i-1));
        return (calc(lx, ly, i-1, j) + calc(mx, ly, i-1, j)) % M;
    }
}

int main() {
    cin >> L >> R;
    R++;
    long long ans = 0;
    for (int k = 0; k < 60; k++)
        ans += calc(1LL<<k, 1LL<<k, k, k);
    cout << ans % M << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string A;
	cin >> A;
	int ans=1000;
	for (int i = 0; i < A.size() - 2; i++) {
		int n;
		int d;
		n = (A[i]-'0') * 100 + (A[i + 1]-'0') * 10 + A[i + 2]-'0';
		d = abs(n - 753);
		ans = min(ans, d);
	}
	cout << ans << endl;
}

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

typedef struct Node{
  int value;
  Node *parent, *left, *right;
} Node;

Node *NIL, *root;

void insert(int k){
  Node *y = NIL, *x = root, *z;

  z = (Node *)malloc(sizeof(Node));
  z->value = k;
  z->left = z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->value < x->value) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->value < y->value) y->left = z;
  else y->right = z;
}

void preParse(Node *node){
  if(node == NIL) return ;

  cout << " " << node->value;
  if(node->left != NIL) preParse(node->left);
  if(node->right != NIL) preParse(node->right);
}

void inParse(Node *node){
  if(node == NIL) return ;

  if(node->left != NIL) inParse(node->left);
  cout << " " << node->value;
  if(node->right != NIL) inParse(node->right);
}

int main(){

  int n, key;
  string command;

  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> command;
    if(command == "insert"){
      cin >> key;
      insert(key);
    }else if(command == "print"){
      inParse(root);
      cout << endl;
      preParse(root);
      cout << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 26484
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<=c&&c<=b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

  



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

int n, s, t, ans;
int inf = 1000000000;
std::vector<int> vec;
int main() {
    std::cin >> n >> s;
    for (int i = 0; i < n; i++) {
        std::cin >> t;
        vec.push_back(t);
    }
    for (int i = 0; (i+s-1) < n; i++) {
        if (vec[i] < 0 && vec[i+s-1] <= 0) {
            ans = std::abs(vec[i]);
        }
        else if (vec[i] >= 0 && vec[i+s-1] >= 0) {
            ans = vec[i+s-1];
        }
        else if (vec[i] < 0 && vec[i+s-1] > 0) {
            int x = std::abs(vec[i]);
            int y = std::abs(vec[i+s-1]);
            ans = x + y + std::min(x, y);
        }
        if (ans < inf) {
            inf = ans;
        }
    }
    std::cout << inf << std::endl;
}


Measured memory_bytes: 892
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, t;
	cin >> n >> m >> t;
	vi v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));
	v.push_back(t + m);
	int ans = 0;
	ans += max(0, v[0] - m);
	FOR(i, 1, n+1) {
		if (v[i - 1] + 2 * m <= v[i])ans += max(0, v[i]-v[i-1]-2*m);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3220
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#define rep(i,n) for(i = 0; i < n; i++)
using namespace std;
//無様なコード　2番めに多いものを探す方法はもっといいものが有るはず
int main2(), main();
const int arrlen = 100001;


int main(){
    string s;
    
    cin>>s;
    string ans;
    if(s == "Sunny") ans = "Cloudy";
    if(s == "Cloudy") ans = "Rainy";
    if(s == "Rainy") ans = "Sunny";
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int a, b, c ,k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    ans += min(a, k);
    k -= a;
    if(k > 0){
        k -= b;
        if(k > 0){
            ans -= min(c, k);
        }
    }
    cout << ans;
}

Measured memory_bytes: 3632
#include <cstdio>

using namespace std;

int pic[128][128];
int edge[64][64];

int ax, ay;

void rotate(int m)
{
	int temp[64][64];
	
	for (int i = 0; i < m; i++){
		for (int j = 0; j < m; j++){
			temp[i][j] = edge[m - j - 1][i];
		}
	}
	
	for (int i = 0; i < m; i++){
		for (int j = 0; j < m; j++){
			edge[i][j] = temp[i][j];
		}
	}
}

void search(int n, int m)
{
	for (int i = 0; i <= n - m; i++){
		for (int j = 0; j <= n - m; j++){
			bool flag = true;
			int px, py;
			px = py = 128;
			for (int dy = 0; dy < m; dy++){
				for (int dx = 0; dx < m; dx++){
					if (~edge[dy][dx] && (pic[i + dy][j + dx] != edge[dy][dx])){
						flag = false;
					}
					if (px == 128 && pic[i + dy][j + dx] == edge[dy][dx]){
						px = j + dx;
						py = i + dy;
					}
				}
			}
			if (flag == true && (ax == -1 || ay > py || (ay == py && ax > px))){
				ax = px;
				ay = py;
			}
		}
	}
	
}

int main()
{
	int n, m;
	
	while (scanf("%d %d", &n, &m), n){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				scanf("%d", &pic[i][j]);
			}
		}
		
		for (int i = 0; i < m; i++){
			for (int j = 0; j < m; j++){
				scanf("%d", &edge[i][j]);
			}
		}
		
		ax = ay = -1;
		
		for (int i = 0; i < 4; i++){
			rotate(m);
			search(n, m);
		}
		
		if (~ax){
			printf("%d %d\n", ax + 1, ay + 1);
		}
		else {
			printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
vector<int> W(100001);

int main()
{
  int64_t N, a, neg = 0, res = 0;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    if (a < 0)
      neg++;
    A.at(i) = abs(a);
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++)
  {
    res += A.at(i);
  }
  if (neg % 2)
    res -= 2 * (A.at(0));
  cout << res << endl;
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int N; cin >> N;
	vector <int> a(N);
	for (auto &i : a) cin >> i;
	bool allpos = false;
	int small = *min_element(a.begin(),a.end()), big = *max_element(a.begin(),a.end());
	int smallid = min_element(a.begin(),a.end()) - a.begin();
	int bigid = max_element(a.begin(),a.end()) - a.begin();
//	cout << small << " " << smallid << "\n";
//	cout << big << " " << bigid << "\n";
	queue <pair<int,int>> moves;
	if (!(big < 0 || small >= 0)){
		if (abs(big) >= abs(small)){
			for (int i = 0; i < N; ++i){
				if (a[i] < 0){
					moves.push(make_pair(bigid, i));
					a[i] += big;
				}
			}
			allpos = true;
		}else{
			for (int i = 0; i < N; ++i){
				if (a[i] > 0){
					moves.push(make_pair(smallid, i));
					a[i] += small;
				}
			}
			allpos = false;
		}
	}else if(small >= 0){
		allpos = true;
	}
	if (allpos){
		for (int i = 1; i < N; ++i){
			if (a[i-1] > a[i]){
				moves.push(make_pair(i-1, i));
				a[i] += a[i-1];
			}
		}
	}else{
		for (int i = N-2; i >= 0; --i){
			if (a[i+1] < a[i]){
				moves.push(make_pair(i+1, i));
				a[i] += a[i+1];		
			}
		}
	}
	int m = moves.size();
	cout << m << "\n";
	for (int i = 0; i < m; ++i){
		cout << moves.front().first+1 << " " << moves.front().second +1 << "\n";
		moves.pop();
	}	
	return 0;
}


Measured memory_bytes: 3596
// https://atcoder.jp/contests/abc172/tasks/abc172_a
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;
#define lli long long int
#define numberofdigits(x) floor(log10(x)) + 1

int main()
{
    lli a;
    cin>>a;
    cout<<a+a*a+a*a*a<<"\n";
    return 0;
}

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

#define debug(x) cout << #x" = " << x;

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

int D;
int a[20];
int b[20];

int main(){
	scanf("%d", &D);
	for (int t = D, i = 0; i < 20; ++i)
		a[i] = t % 10, t /= 10;
	ll ans = 0;
	for (int i = 2; i <= 18; ++i){
		int m = i >> 1;
		for (int j = (1 << m) - 1; j >= 0; --j){
			ll tot = i & 1 ? 10 : 1;

			bool flag = true;
			for (int k = 0; k < m; ++k){
				b[k] = a[k] - 10 * (j >> k & 1) + (k ? j >> k - 1 & 1 : 0);
				b[i - k - 1] = -b[k];
				flag &= -9 <= b[k] && b[k] <= 9;
			}
			flag &= 0 <= b[i - 1] && b[i - 1] <= 8;
			if (!flag)
				continue;
			if (i & 1)
				b[m] = 0;

			ll val = 0;
			for (int k = i - 1; k >= 0; --k)
				val = val * 10 + b[k];
			if (val != D)
				continue;

			tot *= 9 - abs(b[0]);
			for (int k = 1; k < m; ++k)
				tot *= 10 - abs(b[k]);

			ans += tot;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if(a == b) {
    printf("a == b\n");
  } else if(a < b) {
    printf("a < b\n");
  } else {
    printf("a > b\n");
  }
  return 0;
}

Measured memory_bytes: 2584
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int minc = INF;
    for( int i = 0; i < n; ++i ) {
        int a;
        cin >> a;
        int cnt = 0;
        while( !(a % 2) ) {
            a /= 2;
            ++cnt;
        }
        minc = min( cnt, minc );
    }

    cout << minc << endl;
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a,b,k = map(int,input().split())

"""
for i in range(a, b + 1):
    if a + k - 1 >= i or b - k + 1 <= i:
        print(i)
"""
tmp = []
for i in range(k):
    if a + i <= b:
        print(a + i)
        tmp.append(a + i)
for i in range(k):
    i = k - i - 1
    if (b - i >= a) and (not((b - i) in tmp)):
        print(b - i)


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;
 
typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)
 
int main(void){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  cout << s << endl;
}

Measured memory_bytes: 1172
#include "bits/stdc++.h" 
using namespace std; 
#define ll unsigned long long 
#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++)
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) 
    {  
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i)
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
ll calculate(ll x)
{ 
   ll prev=spf[x];
   ll cnt=0;
   ll ans=1;
   while(x!=1)
   {
     if(spf[x]==prev)
     {
       cnt++;
     }
     else
     {
       prev=spf[x];
       ans*=(cnt+1);
       cnt=1;
    }
    x/=spf[x];
   }
   ans*=(cnt+1);
   return ans;
} 
int main()
{  
    sieve(); 
    ll x;
    cin>>x;
    ll sum=0;
    for(ll i=1;i<=x;i++)
    {
      sum+=(i*calculate(i));
    }
    cout<<sum<<endl;
} 

Measured memory_bytes: 81784
#[allow(unused_macros)]
macro_rules! getl {
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let s = s.trim_right();
            let mut ws = s.split_whitespace();
            ($(ws.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! getl_vec {
    ( $t:ty ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let s = s.trim_right();
            s.split_whitespace().map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    };
}


fn main() {
    let n = getl!(usize);

    dfs("", b'a' - 1, n);
}

fn dfs(s: &str, max_char: u8, n: usize) {
    if s.len() == n {
        println!("{}", s);
        return
    }

    for c in b'a'..(max_char + 2) {
        let mut s = s.to_string();
        s.push(c as char);
        let next_mc = std::cmp::max(max_char, c);
        dfs(&s, next_mc, n);
    }
}


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

int main()
{
	int n,c=0;
	cin>>n;
	string s,s2,s3;
	cin>>s;
	if(n%2!=0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        s2=s.substr(0,n/2);
        s3=s2+s2;
        //cout<<s3<<endl;

	    if(s3==s)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }




	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define mp make_pair
vector<pair<ll,ll>> num;

void prime(ll n)
{
    ll fac=2;
    int cnt=0;
    if (n%fac==0)
    {
        while (n%fac==0)
        {
            n/=fac;
            cnt++;
        }
        num.push_back(mp(fac,cnt));
    }
    fac++;
    while (fac*fac<=n)
    {
        if (n%fac==0)
        {
            cnt=0;
            while (n%fac==0)
            {
                n/=fac;
                cnt++;
            }
            num.push_back(mp(fac,cnt));
        }
        fac+=2;
    }
    if (n!=1) num.push_back(mp(n,1));
}

int main()
{
    ll n;cin >> n;
    prime(n);
    int ans=0;
    for (int i=0;i<num.size();i++)
    {
        int cnt=num[i].second;
        int loop=1;
        while (cnt>loop*(loop+1)/2) loop++;
        if (cnt!=loop*(loop+1)/2) loop--;
        ans+=loop;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
char s[105];
int main()
{
	int k,l,i;
	cin>>k;
	cin>>s;
	l=strlen(s);
	if(k>=l)
	{
		for(i=0;i<l;i++)
		cout<<s[i];
	}
	else
	{
		for(i=0;i<k;i++)
		cout<<s[i];
		cout<<"...";
	}
	return 0;
}

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

typedef ostringstream OSS;
typedef istringstream ISS;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int n;
VI xs, ys, rs, cs;
//VI memo;
map<int, int> memo;
VI memo2;
VVI grp;

VVB nears;

bool is_top(int i, int used) {
	for (int j = i - 1; j >= 0; j--) {
		if (1 << j & used) continue;

		if (nears[i][j]) {
			return false;
		}
	}

	return true;
}

int dfs(int used) {
	int sum = 0;

	int flg = (n > 2 && (used < (1 << (n - 2)))) ? 1 : 0;

	if (flg  && memo2[used] != -1) return memo2[used];
	if (!flg && memo.count(used)) return memo[used];

	for(int i = 0;i < n;i++) {
		for (auto j : grp[cs[i]]) {
			if(i == j || (1 << i & used) || (1 << j & used)) continue;
			if(cs[i] != cs[j]) continue;
			if(!is_top(i, used) || !is_top(j, used)) continue;

			int used_tmp = used;
			used_tmp |= 1 << i;
			used_tmp |= 1 << j;

			sum = max(sum, dfs(used_tmp) + 2);
		}
	}

	return (flg ? memo2[used] : memo[used]) = sum;
//	return sum;
}

int main(void) {
	while(cin >> n, n){
		xs = VI(n);
		ys = VI(n);
		rs = VI(n);
		cs = VI(n);

		grp = VVI(4);
		memo.clear();

		if (n > 2) {
			memo2 = VI(1 << (n - 2), -1);
		}

		for(int i = 0;i < n;i++){
			cin >> xs[i] >> ys[i] >> rs[i] >> cs[i];
			cs[i]--;
			grp[cs[i]].push_back(i);
		}

		nears = VVB(n, VB(n));

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				int x = (xs[i] - xs[j]) * (xs[i] - xs[j]);
				int y = (ys[i] - ys[j]) * (ys[i] - ys[j]);
				int dis = x + y;
				int dis2 = (rs[i] + rs[j]) * (rs[i] + rs[j]);

				nears[i][j] = dis < dis2;
			}
		}

		int used = 0;
		cout << dfs(used) << endl;
	}
	return 0;
}

Measured memory_bytes: 54456