akhauriyash/Code-Regression huggingface dataset:
// AOJ 	0605: Modern Mansion
// 2018.1.10 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define QMAX 80000
typedef struct { int s; long long t; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, long long t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define ABS(a)  ((a)>=0?(a):-(a))
#define INF 0x7ffffff
typedef struct { int x, y, id; } T;
T sw[200005];
int sz;
int to[400005][5], dt[400005][5], hi[400005];
char used[400005];

int xcmp(T *a, T *b) { if (a->x - b->x) return a->x - b->x; return a->y - b->y; }
int ycmp(T *a, T *b) { if (a->y - b->y) return a->y - b->y; return a->x - b->x; }

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

long long dijkstra(int start, int flag, int goal)
{
	int i, s, e;
	long long d;

	qsize = 0;
	enq(start, 0);
	if (flag < 0) {
		for (i = 0; i < hi[start]; i++) if (to[start][i] == start+1) {
			dt[start][i] = INF, hi[start+1] = 0;
		}
	}

	while (qsize) {
		s = que[0].s, d = que[0].t, deq();
		if (s == goal || s == goal+1) return d;
		if (used[s]) continue;
		used[s] = 1;
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i];
			if (used[e]) continue;
			enq(e, d+dt[s][i]);
		}
	}
	return -1;
}

int main()
{
	int m, n, k, i, j;
	int s, ss, g, a, b, d;

	m = in(), n = in(), k = in();
	sz = 0, s = g = -1;
	for (i = 0; i < k; i++) {
		int x, y;
		sw[i].x = x = in(), sw[i].y = y = in(), sw[i].id = sz;
		if (x == 1 && y == 1) s = sz;
		else if (x == m && y == n) g = sz;
		sz += 2;
	}
	ss = s;
	if (s < 0) sw[k].x = 1, sw[k].y = 1, sw[k].id = sz, s = sz, k++, sz+=2;
	if (g < 0) sw[k].x = m, sw[k].y = n, sw[k].id = sz, g = sz, k++, sz+=2;

	qsort(sw, k, sizeof(T), xcmp);
	a = sw[0].id, b = a+1;
	to[a][0] = b, dt[a][0] = 1, hi[a] = 1;
	to[b][0] = a, dt[b][0] = 1, hi[b] = 1;

	for (i = 1; i < k; i++) {
		a = sw[i].id, b = a+1;
		j = hi[a]++, to[a][j] = b, dt[a][j] = 1;
		j = hi[b]++, to[b][j] = a, dt[b][j] = 1;
		if (sw[i-1].x == sw[i].x) {
			a = sw[i-1].id, b = sw[i].id, d =  ABS(sw[i-1].y - sw[i].y);
			j = hi[a]++, to[a][j] = b, dt[a][j] = d;
			j = hi[b]++, to[b][j] = a, dt[b][j] = d;
		}
	}

	qsort(sw, k, sizeof(T), ycmp);
	for (i = 1; i < k; i++) {
		if (sw[i-1].y == sw[i].y) {
			a = sw[i-1].id+1, b = sw[i].id+1, d =  ABS(sw[i-1].x - sw[i].x);
			j = hi[a]++, to[a][j] = b, dt[a][j] = d;
			j = hi[b]++, to[b][j] = a, dt[b][j] = d;
		}
	}

	printf("%lld\n", dijkstra(s, ss, g));
	return 0;
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

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

set<int> st;
vector<int> v;

int n,a[400005];

int main()
{
    int n;
    sf(n);
    int z= n%1000;
    if(z>0)z=1000-z;
    pf("%d",z);
}


Measured memory_bytes: 3760
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  a1 PIC 9(08).
       01  a2 PIC 9(08).
       01  r pic S9(08).
       01 disp pic Z(10)9.
       PROCEDURE DIVISION.
        ACCEPT indata.
        
        UNSTRING indata DELIMITED BY SPACE INTO a1.
 
        COMPUTE r = a1 * a1 * a1
 
        MOVE FUNCTION TRIM(r) to disp
        DISPLAY disp
 
 
       STOP RUN.


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    vel P(N);
    rep(i, N) {
        cin >> P[i];
    }
    ll cnt1 = 0, cnt2 = 0, cnt3 = 0;
    rep(i, N) {
        if (P[i] <= A) {
            cnt1++;
        }
        else if (A < P[i] && P[i] <= B) {
            cnt2++;
        }
        else {
            cnt3++;
        }
    }
    ll ans = min(cnt1, min(cnt2, cnt3));
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
def f(P):
 i=0
 for _ in[0]*k:
  s=0
  while s+w[i]<=P:
   s+=w[i];i+=1
   if i==n: return n
 return i
n,k=map(int,input().split())
w=list(map(int,sys.stdin.read().splitlines()))
l=0;r=sum(w)
while r-l>1:
 m=(l+r)//2
 if f(m)>=n:r=m
 else:l=m
print(r)


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

int main() {
 
  int K,N;
  cin>>K>>N;
  vector<int> a(N);
   for(int i=0;i<N;i++){cin>>a.at(i);}
  
  int difmax=0; 
   for(int j=0;j<N-1;j++){
   if((a.at(j+1)-a.at(j))>difmax){difmax=(a.at(j+1)-a.at(j));}}
  
  int difwarp;
  difwarp=a.at(0)+(K-a.at(N-1));
  
  int difm;
  if(difmax>=difwarp){difm=difmax;}
  else{difm=difwarp;}
  
  int ans;
  ans=K-difm;
  
  cout<<ans<<endl;
    
}


Measured memory_bytes: 1024
#include<cstdio>

using namespace std;

int main()
{
	long long a, b;
	int k;
	int i;

	scanf("%lld %lld %d", &a, &b, &k);

	for (i = 0; i < k; i++)
	{
		if (!(i % 2))
		{
			b += a / 2;
			a /= 2;
		}

		else
		{
			a += b / 2;
			b /= 2;
		}
	}

	printf("%lld %lld\n", a, b);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

const int MAX = 100000;

struct Frame{ int H,W; };

void printFrame(struct Frame frame){
  for(int i=0;i<frame.H;i++){
    for(int j=0;j<frame.W;j++){
      if(i!=0 && i!= frame.H-1 && j!=0 && j!=frame.W-1){
        printf(".");
      } else {
        printf("#");
      }
    }
    printf("\n");
  }
}

int main(){
  struct Frame frames[MAX];
  int length = 0;
  for(int i=0;i<MAX;i++){
    scanf("%d",&frames[i].H);
    scanf("%d",&frames[i].W);
    if(frames[i].H == 0 && frames[i].W == 0){
      break;
    } else {
      length++;
    }
  }

  for(int i=0;i<length;i++){
    printFrame(frames[i]);
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2524
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  


const int N = 1e5+5;
vector<pii> g[N+1];

int ans[N+1] ;
void dfs(int u = 1 , int p =-1,int cur =-1){
	int col = 1 ;
	for(auto[i,k]:g[u]){
		if(i==p)continue;
		if(col == cur) col++;
		ans[k] = col;
		dfs(i,u,col);
		col++;
	}
}
void solve(){
	int n; 
	cin >> n ;
	int siz = 0 ; 
	rep(i,1,n){
		int a ,b ; 
		cin >> a >> b; 
		g[a].pb({b,i});
		g[b].pb({a,i});
		siz = max(siz,sz(g[a]));
		siz = max(siz,sz(g[b]));
	}
	dfs();
	cout << siz << endl;
	fr(i,1,n-1){
		cout << ans[i] << endl; 
	};
}


signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int main()
{
    int h, w;
    while (true)
    {
        cin >> h >> w;
        if ((h == 0) && (w == 0))
            break;

        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3096
#include<stdio.h>
	int k[101]={0},d[101]={},f[101]={};
	int v[101][101]={0};
	int cur;
	void dfs(int id){
		if(d[id]!=0){
			return;
			}
			cur++;
			if(d[id]==0){
				d[id]=cur;
			}
			for(int i=0;i<k[id];i++){
				dfs(v[id][i]);
			}
			cur++;
			f[id]=cur;
			return;
		}
		int main(void){
		int n=0,u=0;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%d",&u);
			scanf("%d",&k[u]);
			for(int j=0;j<k[u];j++){
				scanf("%d",&v[u][j]);//uからいけるj個目のノードがv[u][j]
			}
		}
		for(int i=1;i<n;i++){
		if(d[i]==0){
		dfs(i);
		}
		}
		for(int i=1;i<=n;i++){
			printf("%d %d %d\n",i,d[i],f[i]);
		}
	return(0);
}





Measured memory_bytes: 2720
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] INPUT = Console.ReadLine().Split().Select(int.Parse).ToArray();

            List<int> resList = new List<int>();

            for(int i = -100; i <= 100; i++)
            {
                int res = 0;
                foreach(var a in INPUT)
                {
                    if (a == i) continue;
                    res += (int)Math.Pow((a - i), 2);
                }
                resList.Add(res);
            }


            Console.WriteLine(resList.Min());
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   
    cin>>n;
    in(a,n);f=1;
    for(auto c:a)
    {
        if(c%2==0)
        {
            if(c%3==0 || c%5==0)continue;
            else f=0;
        }
    }
    
    
    
    cout<< (f?"APPROVED":"DENIED") <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3656
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define SIZE 200005
#define UF_MAX 100005
using namespace std;
typedef long double ld;
typedef long long int lli;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
lli MOD = 1000000007;
#define UF_MAX 100005
struct UFind {
    int par[UF_MAX];
    int rank[UF_MAX];
    int count[UF_MAX];
    UFind(int n)
    {
        rep(i, n)
        {
            par[i] = i;
            rank[i] = 0;
            count[i] = 1;
        }
    }
    int find(int x)
    {
        if (par[x] == 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 (rank[x] < rank[y]) {
            par[x] = y;
            count[y] += count[x];
        } else {
            par[y] = x;
            count[x] += count[y];
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

using p = pair<lli, pair<lli, lli>>;
int main()
{
    priority_queue<p, vector<p>, greater<p>> q;
    int n;
    lli x, y;
    cin >> n;
    vector<pair<lli, lli>> X, Y;
    rep(i, n)
    {
        cin >> x >> y;
        X.push_back(make_pair(x, i));
        Y.push_back(make_pair(y, i));
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    rep(i, n - 1)
    {
        q.push(make_pair(X[i + 1].first - X[i].first, make_pair(X[i + 1].second, X[i].second)));
        q.push(make_pair(Y[i + 1].first - Y[i].first, make_pair(Y[i + 1].second, Y[i].second)));
    }
    UFind u(n);
    int cnt = 0;
    lli ans = 0;
    while (cnt < n - 1) {
        auto s = q.top();
        q.pop();
        int l = s.second.first;
        int r = s.second.second;

        if (u.same(l, r)) {
            continue;
        }
        u.unite(l, r);
        cnt++;
        ans += s.first;
    }
    cout << ans << endl;
}


Measured memory_bytes: 13024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	string str;
	cin >> str;
	str[k - 1] += 'a'-'A';
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<ctime>
#include<cstdlib>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-10;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;

void solve(){
    int x;scd(x);
    if(x>=30)puts("Yes");
    else puts("No");
}
int main(){
	//freopen("D://data.txt","r",stdin);
	//freopen("D://out.txt","w",stdout);
    solve();
    return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long x, atk=0, mons=1;
    cin>>x;
    while(x!=0) {
        atk+=mons;
        x/=2;
        mons*=2;
    }
    cout<<atk<<endl;
    return 0;
}


Measured memory_bytes: 256
r,p=range,print
n,a,b=map(int,input().split())
if a+b>n+1or a*b<n:exit(p(-1))
l=[[]for i in r(b-1)]+[list(r(1,a+1))]
for i in r(a+1,n+1):l[-2-(i-a-1)%(b-1)]+=[i]
for i in l:p(*i,end=" ")

Measured memory_bytes: 37660
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
        int week;
        int i;
        int debt = 100000;
        int tmp;

        scanf( "%d", &week );
        for ( i = 0 ; i < week ; i++ )
        {
                debt = debt * 1.05;
                if ( debt % 1000 != 0 )
                {
                        debt = ( debt / 1000 + 1 ) * 1000;
                }
        }

        fprintf( stdout, "%d\n", debt );

        return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

#define _ cin.tie(0);ios::sync_with_stdio(false);

ll n;
int  l[]={6,9,36,81,216,729,1296,6561,7776,46656,59049};
ll dp[100010];
int main(){ _;
  cin>>n;
  REP(i,100010)
    dp[i]=i;
  REP(i,11)
    FOR(x,l[i],n+1)
      dp[x]=min(dp[x],dp[x-l[i]]+1);

  cout<<dp[n]<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ok= (s.size()%2?0:1);
	if(ok){
		for(int i=0;i<s.size();i+=2){
			if(s[i]!='h'||s[i+1]!='i'){
				ok=0;
				break;
			}
		}
	}
	if(!ok)cout<<"No\n"<<endl;
	else cout<<"Yes\n"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int N,M;
int X[100010];
int s[100010];
int p[100010];

int main(){
	scanf("%d%d" , &N , &M);
	repp(i,0,N){
		scanf("%d" , X + i);
	}
	sort(X,X+N);
	repp(i,0,N){
		if(X[i] == X[i+1]){
			p[X[i]%M] += 2;
			++s[X[i]%M];
			++i;
		} else {
			++p[X[i]%M];
		}
	}
	int ans = p[0] / 2;
	if(M%2==0) ans += p[M/2] / 2;
	int w = (M+1) / 2;
	repp(i,1,w){
		int z = min(p[i],p[M-i]);
		ans += z;
		p[i] -= z;
		p[M-i] -= z;
		ans += min(s[i] , p[i]/2);
		ans += min(s[M-i] , p[M-i]/2);
	}
	printf("%d\n" , ans);
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
bool bingo[3][3];

int main() {
  string A[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }

  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string b;
    cin >> b;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (b == A[i][j]) bingo[i][j] = true;
      }
    }
  }

  REP(i, 3) {
    if (bingo[i][0] && bingo[i][1] && bingo[i][2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  REP(i, 3) {
    if (bingo[0][i] && bingo[1][i] && bingo[2][i]) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  if (bingo[0][0] && bingo[1][1] && bingo[2][2]) {
    cout << "Yes" << endl;
    return 0;
  }

  if (bingo[2][0] && bingo[1][1] && bingo[0][2]) {
    cout << "Yes" << endl;
    return 0;
  }

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

Measured memory_bytes: 256
import numpy as np
N,K = map(int,input().split())
p = list(map(int,input().split()))

l = []
for i in range(N):
    l.append((1+p[i])/2)

a = [0] * N
a[0] = l[0]
for i in range(1,len(l)):
    a[i] = a[i-1] + l[i]

ans = 0
for i in range(K,len(l)):
    ans = max(ans,a[i]-a[i-K])

if N == 1 or N - K == 0:
    print(max(a))
else:
    print(ans)

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

using namespace std;
typedef long long unsigned int ll;

int main() {
  ll n, x, m;
  cin >> n >> x >> m;
  map<ll, int> indices;
  vector<ll> mods;
  mods.push_back(x);
  int idx = -1;
  while ((ll)mods.size() < n) {
    x = (x * x) % m;
    if (x == mods[0] || indices[x] != 0) {
      idx = indices[x];
      break;
    } else {
      mods.push_back(x);
      indices[x] = mods.size() - 1;
    }
  }

  if (idx == -1) {
    ll ans = 0;
    for (int i = 0; i < mods.size(); ++i) {
      ans += mods[i];
    }
    cout << ans << '\n';
  } else {
    ll ans = 0;
    ll tmp = 0;
    for (int i = 0; i < mods.size(); ++i) {
      ans += mods[i];
      if (i >= idx) tmp += mods[i];
    }

    n -= mods.size();

    int size = mods.size() - idx;
    ll need = n / size;
    ll remain = n % size;
    ans += need * tmp;

    for (int i = idx; i < idx + remain; ++i) {
      ans += mods[i];
    }
    cout << ans << '\n';
  }
  return 0;
}



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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int gcd(ll a, ll b){
    if(a<b){
        int tmp = a;
        a = b;
        b = tmp;
    }

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

    return b;
}

int main(){
    int n, k;
    cin >> n >> k;
    int ans;
    if((n-1) % (k-1) == 0) ans = (n-1) / (k-1);
    else ans = (n-1) / (k-1) + 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys


def get_num():
    return int(input())


def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


def get_numbers():
    return map(int, input().split())

n, m, c = get_numbers()
b = list(get_numbers())

ans = 0
for _ in range(n):
    a = list(get_numbers())
    res = c
    for i, j in zip(a, b):
        res += i * j
    if res > 0:
        ans += 1

print(ans)

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

int main(){
  int N; cin >> N;
  vector<int> L(N); rep(i, N) cin >> L[i];
  long long ans = 0;
  sort(L.begin(), L.end());

  rep(a, N) rep(b, N) {
    if (a >= b) continue;
    int n = (lower_bound(L.begin(), L.end(), L[a] + L[b]) - L.begin()) - b - 1;
    if (n <= 0) continue;
    ans += n;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod = 998244353;
 
int dx[]={-1, 0, 1, 0,1,-1,1,-1};
int dy[]={0, -1, 0, 1,1,-1,-1,1};




int32_t main()
{

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

int n;
cin>>n;
string s;
cin>>s;

vector<int>v[3];

for(int i=0;i<s.size();i++)
{
    if(s[i]=='R')v[0].push_back(i+1);
    else if(s[i]=='B')v[1].push_back(i+1);
    else v[2].push_back(i+1);
}



int ans=0;

for(int i=0;i<v[0].size();i++)
{
    for(int j=0;j<v[1].size();j++)
    {
        int x=v[0][i],y=v[1][j];
        
        int a=max(x,y),b=min(x,y);
        int k1=a+(a-b),k2=b-(a-b);
        int val=v[2].size();
        

        if(binary_search(v[2].begin(),v[2].end(),k1))val--;
        if(binary_search(v[2].begin(),v[2].end(),k2))val--;
        if((a-b)%2==0)
        {
            
            if(binary_search(v[2].begin(),v[2].end(),b+(a-b)/2))val--;
            
        }

       
        ans+=val;

    }
}

cout<<max(0ll,ans)<<"\n";



}


Measured memory_bytes: 3708
n,k = map(int,input().split())
mod = 10**9+7
print(((-(2*(n+1)**3+3*(n+1)**2+n+1)//6)+(n*(n+1)**2+n*(n+1))//2+((n+1)**2+n+1)//2-((k-1)*n+(k-1)**2*n)//2+n+(k+2*(k-1)**3+3*(k-1)**2-1)//6-(k+(k-1)**2-1)//2-k+2) % mod)

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

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

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

int main()
{
	string x;
	cin.tie(0);
	int a[26] = { 0 };
	while (getline(cin, x)) {
		for (int i = 0; i < x.length(); i++) {
			if (x[i] >= 'A' && x[i] <= 'Z') x[i] += 0x20;
			if (x[i] - 'a' >= 0 && x[i] - 'a' <= 25); a[x[i] - 'a']++;
		}
	}

	for (int i = 0; i < 26; i++) {
		cout << (char)('a' + i) << " : " << a[i] << "\n";
	}
}


Measured memory_bytes: 3228
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

vector<ll> noB,noW,sumB,sumW;
//n^k
ll po(ll n, ll k){
	if(k == 1){
		return n;
	}else if(k==0){
		return 1;
	}else if(k%2 == 0){
		ll memo = po(n,k/2)%MOD;
		return memo*memo%MOD;
	}else{
		return n * po(n,k-1)%MOD;
	}
}

int main(void){
	ll b,w;
	cin>>b>>w;
	noB.push_back(0);
	noW.push_back(0);
	sumB.push_back(0);
	sumW.push_back(0);
	reps(i,b+w){
		if(i < b){
			noB.push_back(0);
			sumB.push_back(0);
		}else if(i == b){
			noB.push_back(1);
			sumB.push_back(1);
		}else{
			noB.push_back(noB[i-1] * (i-1)%MOD * po(i-1-b+1,MOD-2)%MOD);
			sumB.push_back((sumB[i-1]*2 + noB[i])%MOD);
		}
		if(i<w){
			noW.push_back(0);
			sumW.push_back(0);
		}else if(i==w){
			noW.push_back(1);
			sumW.push_back(1);
		}else{
			noW.push_back(noW[i-1] * (i-1)%MOD * po(i-1-w+1,MOD-2)%MOD);
			sumW.push_back((sumW[i-1]*2 + noW[i])%MOD);
		}
	}
	vector<ll> ansB;
	ansB.push_back(0);
	reps(i,b+w){
		ansB.push_back((-sumB[i-1]+sumW[i-1]+po(2,i-1)+MOD)%MOD);
		ansB[i] = (ansB[i] * po(po(2,i)%MOD,MOD-2))%MOD;
		cout<<ansB[i]<</*" "<<sumB[i]<<" "<<sumW[i]<<" "<<" "<<" "<<" "<<*/endl;
	}
	return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll s = 0;
  rep(i, n) s ^= a[i];
  rep(i, n) a[i] &= ~s;

  ll ans = s;
  int r = 0;
  vector<int> top(n);
  for (int i = 59; i >= 0; --i) {
    int j = r;
    for (; j < n; ++j) {
      if (a[j] >> i  & 1) {
        swap(a[r], a[j]);
        break;
      }
    }
    if (j == n) continue;
    top[r] = i;
    rep(k, n) {
      if (k == r) continue;
      if (a[k] >> i & 1) a[k] ^= a[r];
    }
    r++;
  }

  ll x = 0;
  for (int i = 59; i >= 0; --i) {
    ll nx = x | (1ll<<i);
    {
      ll b = nx;
      rep(j, r) {
        if (b >> top[j] & 1) b ^= a[j];
      }
      if ((b & nx) == 0) {
        x = nx;
      }
    }
  }
  ans += x * 2;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<long long> red(A), gre(B), whi(C);
  int i,j;
  for(i=0; i<A; i++){
    cin >> red[i];
  }
  for(i=0; i<B; i++){
    cin >> gre[i];
  }
  for(i=0; i<C; i++){
    cin >> whi[i];
  }
  sort(red.begin(), red.end());
  sort(gre.begin(), gre.end());
  vector<long long> sum(X+Y+C);
  for(i=A-X; i<A; i++){
    sum[i-A+X] = red[i];
  }
  for(i=B-Y; i<B; i++){
    sum[X+i-B+Y] = gre[i];
  }
  for(i=0; i<C; i++){
    sum[X+Y+i] = whi[i];
  }
  sort(sum.begin(), sum.end());
  long long ans=0;
  for(i=C; i<X+Y+C; i++){
    ans += sum[i];
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 4736
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
a = readints()
# print(a)
tmp = gcd(0, a[0])
for i in range(1, n):
    tmp = gcd(tmp, a[i])
print(tmp)


Measured memory_bytes: 91060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<int> B(N+1,1000000);
    rep(i,N-1){
        cin>>B.at(i+1);
    }
    vector<int> A(N);
    rep(i,N){
        A.at(i)=min(B.at(i),B.at(i+1));
    }
    ll ans=0;
    rep(i,N){
        ans+=A.at(i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int counter;
  if(s[0] == '1')++counter;
  if(s[1] == '1')++counter;
  if(s[2] == '1')++counter;
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);

int main() {
  cout << fixed << setprecision(20);
  double A,B,H,M;
  cin >> A >> B >> H >> M;
  double RA = ((H * 60 + M) / 2);
  double TA = RA * (PI / 180);
  double AX = A * sin(TA);
  double AY = A * cos(TA);
  double RB = M * 6;
  double TB = RB * (PI / 180); 
  double BX = B * sin(TB);
  double BY = B * cos(TB);
  cout << sqrt((AX-BX) * (AX-BX) + (AY-BY) * (AY-BY)) << endl;
}


Measured memory_bytes: 4152
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
    if (a < b) return gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int N, K, d, A;
    set<int> s;
    cin >> N >> K;
    rep(i, K) {
        cin >> d;
        rep(j, d) {
            cin >> A;
            s.insert(A);
        };
    }
    cout << N - s.size() << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	string s; cin >> s;
	ll left = 0, right = s.size()-1;
	ll ans = 0;
	while(left < right){
		if(s[left] != s[right]){
			if(s[left]=='x'){
				ans++;
				left++;
			}else if(s[right]=='x'){
				ans++;
				right--;
			}else{
				puts("-1");
				return 0;
			}
		}else{
			left++;
			right--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> p;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n,0){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]>rank[ry]) par[ry]=rx;
        else par[rx]=ry;
        if(rank[rx]==rank[ry]) rank[ry]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
    int cnt(int n){
        int res=0;
        for(int i=0;i<n;++i){
            if(root(i)==i) res++;
        }
        return res;
    }
};

int main(){
    int n,m;cin>>n>>m;
    UnionFind uf(n);
    for(int i=0;i<m;++i){
        int x,y,z;cin>>x>>y>>z;
        x--;y--;
        uf.unite(x,y);
    }
    cout<<uf.cnt(n)<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e18;

int main() {
  ll a, b, q, x, ans;
  cin >> a >> b >> q;
  vector<ll> s(a + 2), t(b + 2);
  rep(i, a) cin >> s[i + 1];
  rep(i, b) cin >> t[i + 1];
  s[0] = t[0] = -INF;
  s[a + 1] = t[b + 1] = INF;

  rep(i, q) {
    cin >> x;
    ans = INF;
    ll si = upper_bound(s.begin(), s.end(), x) - s.begin();
    ll ti = upper_bound(t.begin(), t.end(), x) - t.begin();

    for (int i = si - 1; i <= si; ++i) {
      for (int j = ti - 1; j <= ti; ++j) {
        ll mn1 = abs(s[i] - x) + abs(t[j] - s[i]);
        ll mn2 = abs(s[i] - t[j]) + abs(t[j] - x);
        ans = min({ans, mn1, mn2});
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 4736
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        t: i64,
        a: i64,
        h: [i64; n]
    }
    let mut ans = 0;
    let mut d = (t as f64 - 0.006 * h[0] as f64 - a as f64).abs();
    for i in 1..n {
        let d2 = (t as f64 - 0.006 * h[i] as f64 - a as f64).abs();
        if d > d2 {
            ans = i;
            d = d2;
        }
    }
    println!("{}", ans + 1);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>

using namespace std;

int main(){
	string s; cin >> s;
	int l = s.length();
	for(int i = 1; i < l / 2; i++){
		if(s.substr(0, (l - 2 * i) / 2) == s.substr((l - 2 * i) / 2, (l - 2 * i) / 2)){
			cout << l - 2 * i << endl;
			break;
		}
	}
	return 0;
}

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

typedef long long ll;

int n,m,ans=0;
vector<int> g[10];
bool seen[10];


void dfs(int v){
    seen[v] = true;
    bool ok = true;
    for(int i=0;i<n;i++){
        if(!seen[i]){
            ok = false;
            break;
        }
    }
    if(ok) ans++;
    for(auto nv : g[v]){
        if(seen[nv]) continue;
        dfs(nv);
        seen[nv] = false;
    } 
}

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

    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*; 
class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
       
  		int[] a=new int[n];
		for(int c=0;c<n-1;c++){
    		a[sc.nextInt()-1]++;
          }
  
    for(int ans: a){
    System.out.println(ans);
    }
  
    }

}


Measured memory_bytes: 70908
//============================================================================
// Name        : AOJ.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){

	int n;

	cin>>n;

	cout<<n/3<<endl;
	return 0;



}




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

int main() {
  int s;
  cin >> s;
  
  vector<int> a;
  a.push_back(s);	//初項をいれる
  
  int ibuff=s;
  vector<int>::iterator itr;
  for (long i=2; i<1000001L; i++) {
    //関数計算
    if (ibuff%2)	ibuff = 3*ibuff+1;
    else			ibuff /= 2;
    
    //数値があるか
    itr = find(a.begin(), a.end(), ibuff);
    //無いときは数値を追加する。見つかったらそのまま出力
    if (itr == a.end()) {
	    a.push_back(ibuff);
    } else {
      cout << i << endl;
      return 0;
    }
  }
  
  return 0;
}

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

unsigned long cnt;
int l;
int A[10000000];
int n;
vector<int> G;

void insertionSort(int A[],int n,int g){
    for(int i=g;i<n;i++){
        int v=A[i];
        int j=i-g;
        while(j>=0&&A[j]>v){
            A[j+g]=A[j];
            j-=g;
            cnt++;
        }
        A[j+g]=v;
    }
}

void ShellSort(int A[],int n){
    for(int h=1;;){
        if(h>n)break;
        G.push_back(h);
        h=3*h+1;
    }
    
    for(int i=G.size()-1;i>=0;i--){
        insertionSort(A,n,G[i]);
    }
}

int main(void){
    cin>>n;
    for(int i=0;i<n;i++)scanf("%d",&A[i]);
    cnt=0;
    
    ShellSort(A,n);
    
    cout<<G.size()<<endl;
    for(int i=G.size()-1;i>=0;i--){
        printf("%d",G[i]);
        if(i)printf(" ");
    }
    printf("\n");
    printf("%ld\n",cnt);
    for(int i=0;i<n;i++){
        printf("%d\n",A[i]);
    }
    return 0;
}



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

int main() {
long long n;
long long M=1000000007;
cin>>n;
long long a[n];
long long dp[n+1]={0};
for(long long i=0;i<n;i++){
  cin>>a[i];
}
for(long long i=0;i<n;i++){
  dp[i+1]=(dp[i]+a[i])%M;
}
long long ans=0;
for(long long i=0;i<n-1;i++){
  ans+=(a[i]*(dp[n]-dp[i+1]+M))%M;
  ans=ans%M;
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6716
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def reads():
  return [int(x) for x in input().split()]

(N, K) = reads()

L = K

board = [[0] * K for _ in range(K)]

NW = 0
for _ in range(N):
    (x, y, c) = input().split()
    (x, y) = (int(x), int(y))
    c = (x // K + y // K + int(c == "W")) & 1 # W -> 1, B -> 0
    (x, y) = (x % K, y % K)
    NW += c
    board[y][x] += 1 if c == 1 else -1 # W - B
NB = N - NW

psumr = [[0] * (K+1) for _ in range(K)]

for i in range(K):
    for j in range(K):
        psumr[i][j+1] = psumr[i][j] + board[i][j]

psum = [[0] * (K+1) for _ in range(K+1)]

for i in range(K):
    for j in range(K):
        psum[i+1][j+1] = psum[i][j+1] + psumr[i][j+1]

result = 0
for i in range(K+1):
    for j in range(K+1):
        summ = psum[i][K] + psum[K][j] - 2 * psum[i][j]
        result = max(result, NB + summ, NW - summ)
print(result)

Measured memory_bytes: 71640
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<math.h>
#include<queue>
#include<vector>
#include<algorithm>
#define Max (int)1e9
#define MAX2 (int)1e5+5
#define MOD ((int)1e9+7)
using namespace std;



int main(){
	int n,l,i;
	scanf("%d%d",&n,&l);
	int tmp = 0,min=fabs(l),val = l;
	for(i=0;i<n;i++){
		tmp += l+i;
		if(min > fabs(l+i)){
			min = fabs(l+i);
			val = l+i;
		}
	}
	printf("%d\n",tmp-val);
	return 0;
}



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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
#define bitcount    __builtin_popcountll
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mp make_pair
#define F first
#define S second
#define ll long long
#define rep(i,x,y) for(i=x;i<y;i++)
#define pf(x,y) printf("x",y)
#define pb push_back
#define MOD 1000000007
int main()
{
    int n,i,x=0,y;
    sd(n);
    for(i=0;i<n;i++)
    {
        sd(y);
        if(y%2==1)
            x++;
    }
    if(x%2==0)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	int a[110000], b[110000];
	cin >> n;
	int i;
	for (i = 0; i <= n; i++) {
		cin >> a[i];
	}
	for (i = 0; i < n; i++) {
		cin >> b[i];
	}
	long long ans = 0;
	for (i = 0; i < n; i++) {
		if (b[i] - a[i] < 0) {
			ans += b[i];
		}
		else if (b[i] - a[i] - a[i + 1] < 0) {
			ans += b[i];
			a[i + 1] = a[i + 1] - (b[i] - a[i]);
		}
		else {
			ans += a[i] + a[i + 1];
			a[i + 1] = 0;
		}
	}
	cout << ans;
	return(0);
}

Measured memory_bytes: 1024