akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long           ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                1010
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
    /*#ifndef ONLINE_JUDGE
        double start = clock(); READ(); WRITE();
    #endif*/
        int n, m, sum = 0; sii(n, m);
        vi v(n);

        FOR(i, 0, n){
        	si(v[i]);
        	sum += v[i];
        }
        double avg = (1.0 / (4.0 * m)) * sum * 1.0;
        int ans = 0;
        FOR(i, 0, n){
        	if((double)v[i] >= avg) ++ans;
        }
        puts(ans >= m ? "Yes" : "No");

    /*#ifndef ONLINE_JUDGE
        printf("\n>>Runtime: %.10fs\n", (double)(clock() - start) / CLOCKS_PER_SEC);
    #endif*/

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 4444,mo=1e9+7;
ll n,m,f[N],x,mst,tot,cnt1,cnt2,res,mi[N],head[N],to[N],nxt[N],edgenum;
int val[2002][2002];Vi dot[N];
void add(int u, int v){
	to[++edgenum]=v;nxt[edgenum]=head[u];head[u]=edgenum;
}
int query(int u, int v){
	return max(val[u][v],val[v][u]);
}
int mrk[N];
struct edge{
	ll u,v,w;
}e[N];bool cmp(edge a, edge b){return a.w<b.w;}
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
int main() {
	read(n);read(m);read(x);
	mi[0]=1;rep(i,1,m)mi[i]=2LL*mi[i-1]%mo;
	rep(i,1,m){read(e[i].u);read(e[i].v);read(e[i].w);}sort(e+1,e+m+1,cmp);
	if(n==1){puts("0");return 0;}
	rep(i,1,n)f[i]=i,dot[i].pb(i);
	rep(i,1,m){
		int j;for(j=i;j<=m;j++)if(e[j].w!=e[i].w)break;
		rep(k,i,j-1){
			int x=find(e[k].u),y=find(e[k].v);tot+=x!=y;
		}
		rep(k,i,j-1){
			int x=find(e[k].u),y=find(e[k].v);
			if(x!=y){
				mrk[i]=1,f[x]=y,mst+=e[k].w,add(e[k].u,e[k].v);
				rep(a,0,SZ(dot[x])-1)rep(b,0,SZ(dot[y])-1)val[dot[x][a]][dot[y][b]]=e[k].w;
				rep(a,0,SZ(dot[x])-1)dot[y].pb(dot[x][a]);dot[x].clear();
			}
		}
		
		i=j-1;//[i,j-1]
	}
	if(x<mst){puts("0");return 0;}
	if(x==mst){res=mi[m]-2LL*mi[m-tot];printf("%lld\n",(res%mo+mo)%mo);return 0;}
	rep(i,1,m)if(!mrk[i]){
		ll t=e[i].w-query(e[i].u,e[i].v);//max
		if(t==x-mst)cnt1++;if(t>x-mst)cnt2++;
	}
	res=2LL*(mi[cnt1]-1)%mo*mi[cnt2]%mo;res=(res%mo+mo)%mo;
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 9856
#include<iostream>
#include<stdio.h>
#include<cstdlib>
using namespace std;

//ノードを表す構造体を定義する
struct Node {
	int key;
	Node* left, * right, * parent; //左の子、右の子、親を指すポインタ
};

typedef struct Node* node;

node root, NIL;
//preorder tree walk
void preorder(node u) {
	if (u == NIL) {
		return;
	}
	cout <<" "<< u->key;
	preorder(u->left);
	preorder(u->right);

}

//inorder walk
void inorder(node u) {
	if (u == NIL) {
		return;
	}
	inorder(u->left);
	cout << " " << u->key;
	inorder(u->right);
}

void insert(int k) {
	node y = NIL;		//xの親
	node x = root;
	node z = NIL;

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

	while (x != NIL) {
		y = x;		//親を設定
		if (z->key < x->key) {
			x = x->left;		//左の子へ移動
		}
		else {
			x = x->right;		//右の子へ移動

		}
	}
	z->parent = y;
	if (y == NIL) {	//Tが空の場合
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;		//zをyの左の子にする
		}
		else {
			y->right = z;		//zをyの右の子にする
		}
	}
	
}


int main() {
	int n, i, x;
	string com;
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 26564
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define M 1000000007
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define what_is(x)  cout << #x << " is " << x << endl;
#define U 1000000007
#define N 100005
using namespace std;
signed main()
{
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  int dp[n];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  rep(i,2,n) dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
  //rep(i,0,n) cout<<dp[i]<<" ";
  cout<<dp[n-1];



}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N,M,C;
    string S;
    cin >> N >> M >> C;
    vector<ll> B(M);
    REP(i, M){
        cin >> B.at(i);
    }
        vector<vector<ll>>  A(N, vector<ll>(M));
    REP(i,N){
        REP(j,M){
            cin >> A.at(i).at(j);
        }
    }

    vector<ll> ans(N);
    REP(i,N){
        ans.at(i) = 0;
    }
    ll count = 0;

    REP(i, N)
    {
        REP(j, M)
        {
            ans.at(i)+=A.at(i).at(j)*B.at(j);
        }
        ans.at(i) += C;
        if(ans.at(i)>0){
            count++;
        }

    }
    cout << count << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll a(n),b(n),c(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n) cin>>c[i];
    sort(rall(a));
    sort(all(c));
    // Left
    vll dpL(n+1);
    priority_queue<ll,vll,greater<ll> > queL;
    rep(i,n){
        dpL[0]+=a[i];
        queL.push(a[i]);
    }
    rep(i,n){
        dpL[i+1] += dpL[i];
        dpL[i+1] += b[i];
        queL.push(b[i]);
        dpL[i+1] -= queL.top();
        queL.pop();
    }
    // Right
    vll dpR(n+1);
    priority_queue<ll> queR;
    rep(i,n){
        dpR[0]+=c[i];
        queR.push(c[i]);
    }
    rep(i,n){
        dpR[i+1] += dpR[i];
        dpR[i+1] += b[n-i-1];
        queR.push(b[n-i-1]);
        dpR[i+1] -= queR.top();
        queR.pop();
    }
    ll ans=-1e18;
    FOR(i,0,n){
        ll L = dpL[i];
        ll R = dpR[n-i];
        chmax(ans,L-R);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 6516
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
    os<<'[';
    rep(i,a.size()) os<<(i?" ":"")<<a[i];
    return os<<']';
}

char color(char a, char b) {
    if (a > b) swap(a, b);
    if (a == 'b') {
        if (b == 'g') return 'r';
        if (b == 'r') return 'g';
    }
    return 'b';
}

int main() {
    for(string worm; cin >> worm, worm != "0"; ) {
        int len = worm.size();
        queue<string> que;
        set<string> dist;
        que.push(worm);
        for(int time = 0; ; time++) {
            queue<string> que2;
            while(!que.empty()) {
                string w = que.front();
                que.pop();
                if (dist.count(w) == 1) continue;
                dist.insert(w);
                int cnt = 0;
                rep(i, len - 1) {
                    if (w[i] == w[i + 1]) {
                        cnt++;
                        continue;
                    }
                    char c = color(w[i], w[i + 1]);
                    string t = w;
                    t[i] = t[i + 1] = c;
                    que2.push(t);
                }
                if (cnt == len - 1) {
                    cout << time << endl;
                    goto end;
                }
            }
            if (que2.empty()) {
                cout << "NA" << endl;
                goto end;
            }
            que = que2;
        }
end:;
    }
    
    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll mod=(1e9)+7;
const int maxn=(1e5)+10;
int n,x[maxn];
ll s1[maxn],s2[maxn],iv[maxn],jc[maxn],ivjc[maxn],tmp,ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(x[i]);
	for (int i=1;i<=n;i++) s1[i]=s1[i-1]+x[i];
	for (int i=n;i>=1;i--) s2[i]=s2[i+1]+x[i];
	iv[0]=jc[0]=iv[1]=jc[1]=1;
	ivjc[0]=ivjc[1]=1;
	for (int i=2;i<=n;i++) {
		jc[i]=jc[i-1]*i%mod;
		iv[i]=(mod-mod/i)*iv[mod%i]%mod;
		ivjc[i]=ivjc[i-1]*iv[i]%mod;
	}
	for (int i=1;i<=n-1;i++) {
		tmp=s1[n]-s1[i]-s1[n-i];
		tmp-=x[n]-x[n-i];
	//	printf("%d %lld\n",i,tmp);
		tmp%=mod;
		tmp=tmp*jc[i-1]%mod*ivjc[i+1]%mod;
		ans=(ans+tmp)%mod;
		tmp=x[n]-x[n-i];
		tmp=tmp*iv[i]%mod;
		ans=(ans+tmp)%mod;
	}
	printf("%lld\n",ans*jc[n-1]%mod);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

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

#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back

/** Dateloper */


using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<ll>v;
    while(n--){
        ll tmp;
        cin>>tmp;
        v.pb(tmp);
    }
    int ans=0;
    int tmp=0;
    for(int i=1;i<v.size();i++)
    {
        if(v[i]<=v[i-1])
            {tmp++;
            ans=max(ans,tmp);}
            else tmp=0;
    }
    cout<<ans;
    return 0;
}


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

int main() {
	// your code goes here
	int N;
	cin>>N;
	vector<long long int> v(N);
	for(int c=0;c<N;c++) {
		cin>>v[c];
	}
	long long res = 0;
	long long int maxi = 0;
	for(int c=0;c<N;c++) {
		res += max(0LL,maxi-v[c]);
		maxi = max(maxi,v[c]);
	}
	cout<<res;
	
}

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

int n;
bitset<10010> b;

int main() {
    scanf("%d", &n), b.set(0);
    for (int i = 1, x; i <= n; i++) {
        scanf("%d", &x), b |= (b << x);
    }
    for (int i = 10000; i; i--) {
        if (b.test(i) && i % 10) printf("%d\n", i), exit(0);
    }
    printf("0\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
   int n;
   cin >> n;
   ll ans = 0;
   for(int i = 1;i < n;i++){
      ans += i;
   }
   cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,k;
  cin >> n >> k;
  vector<LL> a(n);
  for(LL &x:a) cin >> x;
  vector<LL> first(212345,-1);
  vector<LL> last(212345,-1);
  vector<LL> succ(n,-1);
  REP(i,n) {
    if(first[a[i]] == -1) first[a[i]] = i;
    if(last[a[i]] != -1) succ[last[a[i]]] = i;
    last[a[i]]=i;
  }

  vector<LL> answers;
  LL tmpans = n;
  do {
    answers.push_back(tmpans);
    LL pos = (tmpans == n) ? 0 : first[a[tmpans]]+1;
    while(true) {
      if(pos==n) break;
      if(succ[pos]==-1) break;
      else pos = succ[pos]+1;
    }
    tmpans = pos;
  } while(tmpans != n);
  LL from = answers[k%answers.size()];
  vector<LL> res;
  set<LL> nums;
  FOR(i,from,n) {
    if(nums.count(a[i])) {
      while(res.back() != a[i]) {
        nums.erase(res.back());
        res.pop_back();
      }
      nums.erase(res.back());
      res.pop_back();
    } else {
      res.push_back(a[i]);
      nums.insert(a[i]);
    }
  }
  REP(i, res.size()) {
    if(i) cout << " ";
    cout << res[i];
  }
  cout << endl;
}


Measured memory_bytes: 20464
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    ll ans = 0;
    reps(i,n){
        if(i % 3 != 0 && i % 5 != 0)ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(A: int, B: int, C: int, X: int, Y: int):
    mn = 1e9
    for i in range(0, 2*(max(X, Y)+1), 2):
        mn = min(mn, C*i+A*max(X-i//2, 0)+B*max(Y-i//2, 0))
    print(int(mn))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5304
import itertools
import math

n = int(input())

li = []
for i in range(n):
    a = list(map(int, input().split()))
    li.append(a)

p_list = list(itertools.permutations(li, n))

def cal_distance(lis):
    dis = 0
    for i in range(n-1):
        dis += math.sqrt((lis[i+1][0]-lis[i][0])**2 + (lis[i+1][1] - lis[i][1])**2)
    return dis

total_distance = 0
for i in range(len(p_list)):
    total_distance += cal_distance(p_list[i])

print(total_distance/len(p_list))

Measured memory_bytes: 7972
A =[]
while True:
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        break
    else:
        a = 0
        for i in range(1,n+1):
            if (i * 3 + 2)  > x:
                A.append(a)
                break
            else:
                for j in range(i+1,((x-i)//2) + 1):
                    c = x - (i + j)
                    if j < c <= n:
                        a += 1
                        
for i in A:
    print(i)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,q,a,b,c;

struct UnionFind{
	vector<int> data;
	
	UnionFind(int sz){
		data.assign(sz, -1);
	}
	
	bool unite(int x,int y){
		x = find(x); y = find(y);
		if(x == y) return false;
		if(data[x] > data[y]) swap(x,y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
	
	int find(int k){
		if(data[k] < 0) return k;
		return data[k] = find(data[k]);
	}
	
	int size(int k){
		return -data[find(k)];
	}
	
	bool same(int x,int y){
		if(find(x) == find(y)) return true;
		else return false;
	}
};

int main(){
	cin >> n >> q;
	UnionFind data(n);
	REP(i,0,q){
		cin >> a >> b >> c;
		if(a==0) data.unite(b,c);
		else cout << data.same(b,c) << endl;
	}
	return 0;
}



Measured memory_bytes: 3148
#include <iostream>
using namespace std;
int n;
long long k,A[100000],ans,x;
int cnt[2][45];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>A[i];
        for(int j=0;j<45;j++)cnt[(A[i]>>j)%2][j]++;
    }
    for(int i=44;i>=0;i--){
        long long y=1LL<<i;
        if(cnt[0][i]>cnt[1][i]&&y<=k){
            k-=y;
            x+=y;
            ans+=cnt[0][i]*y;
        }else ans+=cnt[1][i]*y;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	dp := make([][]int, len(s)+1)
	dp[len(s)] = make([]int, 26)
	for i := 0; i < 26; i++ {
		dp[len(s)][i] = -1
	}
	for i := len(s) - 1; i >= 0; i-- {
		dp[i] = make([]int, 26)
		for j := 0; j < 26; j++ {
			if s[i]-'a' == byte(j) {
				dp[i][j] = i
			} else {
				dp[i][j] = dp[i+1][j]
			}
		}
	}
	sum := 0
	now := -1
	for _, v := range t {
		if now = dp[now+1][v-'a']; now == -1 {
			sum++
			if now = dp[0][v-'a']; now == -1 {
				fmt.Println(-1)
				return
			}
		}
	}
	fmt.Println(sum*len(s) + now + 1)
}


Measured memory_bytes: 24704
#include<bits/stdc++.h>
using namespace std;
const int N=303;
int n,f[N][N][N],p,ans;char s[N];
int main(){
    scanf("%s%d",s+1,&p);n=strlen(s+1);
    for(int i=n;i;i--)
        for(int j=i;j<=n;j++)
            for(int k=0;k<=(j-i)/2+1;k++)
                f[i][j][k]=max(k||s[i]==s[j]?f[i+1][j-1][k-!!(s[i]^s[j])]+1+!!(i^j):0,max(f[i][j-1][k],f[i+1][j][k]));
    for(int i=0;i<=p;i++)ans=max(ans,f[1][n][i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 108544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()


int main() {
    ll N;
    string S;
    cin>>N>>S;
    ll ans=1;
    rep(i,0,S.size()-1){
        if(S[i]==S[i+1]){}
        else if(S[i]!=S[i+1]){ans++;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<string>
using namespace std;
typedef pair< int , int > Pi;
#define INF (1 << 25)
#define fr first
#define sc second
int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};
int main(){
  int n,m,x,y,MUKI;
  while(cin >> n >> m && n){
    x = 1 , y = 1 , MUKI = 0;
    while(true){
      if( x > m ) x = m;
      if( x < 1 ) x = 1;
      if( y > n ) y = n;
      if( y < 1 ) y = 1;
      string str;
      int n;
      cin >> str;
      if(str == "FORWARD"){
        cin >> n;
        x += dx[MUKI] * n , y += dy[MUKI] * n;
      }else if(str == "BACKWARD"){
        cin >> n;
        x -= dx[MUKI] * n , y -= dy[MUKI] * n;
      }else if(str == "RIGHT") MUKI = ( MUKI + 1 ) % 4;
      else if(str == "LEFT") MUKI = ( MUKI - 1 + 4 ) % 4;
      else break;
      //  cout << y << x;
    }
    cout << y << " " << x << endl;
  }
}

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

int main(){
    int n,m;
    cin >> n >> m;

    vector<int> food(m+1);
    for ( int i = 0 ; i < n ; i++ ){
        int k;
        cin >> k;
        for ( int j = 0 ; j < k ; j++ ){
            int l;
            cin >> l;
            food.at(l)++;
        }
    }
    int cnt = 0;
    for ( int i = 1 ; i <= m ; i++ ){
        if (food.at(i) == n ) cnt++;
    }
    cout << cnt << endl;
}

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

typedef pair<int, int> pii;
typedef pair<short, short> pss;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MX = 200010;

const int SZ = 1 << 18;

struct segtree {
	vector<int> dat;

	void init() {
		dat.resize(SZ * 2);
		rep(i, SZ * 2) dat[i] = INT_MIN;
	}

	void update(int pos, int x) {
		pos += SZ - 1;
		dat[pos] = x;

		while (pos > 0) {
			pos = (pos - 1) / 2;
			dat[pos] = max(dat[pos * 2 + 1], dat[pos * 2 + 2]);
		}
	}

	int get(int a, int b, int k = 0, int l = 0, int r = SZ) {
		if (b <= l || r <= a) return INT_MIN;
		if (a <= l && r <= b) return dat[k];
		return max(get(a, b, k * 2 + 1, l, (l + r) / 2), get(a, b, k * 2 + 2, (l + r) / 2, r));
	}
} seg, seg2;

int N, Q;
int b[MX];
int num[MX];
int ans;

int main() {
	seg.init();
	seg2.init();
	scanf("%d", &N);

	rep(i, N) {
		scanf("%d", &b[i]);
		num[i+1] = num[i] + !b[i];
	}

	scanf("%d", &Q);
	vector<pii> qr(Q);

	rep(i, Q) {
		int l, r;
		scanf("%d%d", &l, &r);
		qr[i] = mp(l, r);
	}

	sort(ALL(qr));

	for (auto p : qr) {
		int l = p.fi, r = p.se;
		int c = r - l + 1 - 2 * (num[r] - num[l-1]);

		int t = max(0, seg.get(0, l));
		t += c;

		int t2 = seg2.get(l, r+1);

		if (t2 != INT_MIN) {
			t2 += r - 2 * num[r];
		}

		int val = max(t, t2);

		ans = max(ans, val);

		seg.update(r, val);
		seg2.update(r, val - r + 2 * num[r]);
	}

	cout << N - num[N] - ans << endl;
	
	return 0;
}

Measured memory_bytes: 7552
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int a, b, c; std::cin >> a >> b >> c;
  std::set<int> s; s.insert(a); s.insert(b); s.insert(c);
  std::cout << sz(s) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#define lli long long int 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

int main() 
{
    fio;
    lli n;
    cin>>n;
    lli arr[n],dp[n];
    dp[0]=0;
    for (int i=0;i<n;i++)
    cin>>arr[i];
    dp[1]=abs(arr[1]-arr[0]);
    for (int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1];
	return 0;
}

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

// 再帰関数を見抜く
// 足し算や掛け算は計算途中でもあまりとってよい

int pcnt(int x) { return __builtin_popcount(x); }
int f(int x) {
  if (x == 0) return 0;
  return f(x % pcnt(x)) + 1;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> x(n);
  rep(i, n) x[i] = s[i] - '0';
  int pc = 0;
  rep(i, n) pc += x[i];
  vector<int> ans(n);
  rep(b, 2) {
    int npc = pc;
    if (b == 0)
      npc++;
    else
      npc--;
    if (npc <= 0) continue;
    int r0 = 0;
    // ２進数を10進数
    rep(i, n) {
      r0 = (r0 * 2) % npc;
      r0 += x[i];
    }
    int k = 1;

    // f(xn)~f(x1)を求める
    for (int i = n - 1; i >= 0; --i) {
      if (x[i] == b) {
        int r = r0;
        if (b == 0)
          r = (r + k) % npc;
        else
          r = (r - k + npc) % npc;
        ans[i] = f(r) + 1;
      }
      k = (k * 2) % npc;
    }
  }

  rep(i, n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 5164
#include <iostream>
    #include <string>
   using namespace std;
     
    int main()
 {
 	int a,b;
 	cin>>a>>b;
 	if(a<=9 && b<=9)
 	{
 		cout<<a*b;
	 }
	 else
	 {
	 	cout<<-1;
	 }
      return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define in(e,l) (std::find(l.begin(), l.end(), e) != l.end())
#define asort(l) (std::sort(l.begin(), l.end()))
#define dsort(l) (std::sort(l.rbegin(), l.rend()))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;

int main() {
  int K, A , B;
  cin >> K >> A >> B;
  int c = B / K;
  if (K * c >= A) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}



Measured memory_bytes: 3632
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
	
		Scanner scanner = new Scanner(System.in);
		long n = scanner.nextLong();
		long m = scanner.nextLong();
		long s = 0;
if(m - n*2 >= 0){
s += n;
m -= n*2;
s += m/4;
}else{
s = m/2;
}
		System.out.println(s);
	}
 
}

Measured memory_bytes: 21588
// unihernandez22
// https://atcoder.jp/contests/abc076/tasks/abc076_b
// implementation

import std.stdio;
void main() {
	int n, k;
	"%s\n%s\n".readf(&n, &k);
	int x = 1;
	foreach(_; 0..n) {
		if (x < k)
			x += x;
		else
			x += k;
	}
	x.writeln;
}


Measured memory_bytes: 3112
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1000000007;
const LL LINF = 1LL * INF * INF;
const int MAXN = 507;
const LD EPS = 1e-7;

const int MAGIC = 1000;

int A[MAXN][MAXN];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, m, h, w;
	cin >> n >> m >> h >> w;
	if (n % h == 0 && m % w == 0)
	{
		cout << "No";
		return 0;
	}
	int n1 = n / h * h, m1 = m / w * w, cnt = 0;
	LL s = 0;
	FOR(i, 1, n + 1)
		FOR(j, 1, m + 1)
	{
		if (i > n1 || j > m1)
		{
			++cnt;
			continue;
		}
		if (i % h == 0 && j % w == 0)
			A[i][j] = - (h * w - 1) * MAGIC - 1;
		else
			A[i][j] = MAGIC;
		s -= A[i][j];
	}
	++s;
	FOR(i, 1, n + 1)
		FOR(j, 1, m + 1)
	{
		if (i > n1 || j > m1)
		{
			A[i][j] = s / cnt;
			s -= A[i][j];
			--cnt;
		}
	}
	cout << "Yes\n";
	FOR(i, 1, n + 1)
	{
		FOR(j, 1, m + 1)
			cout << A[i][j] << ' ';
		cout << '\n';
	}
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int ll
typedef long long ll;
typedef pair<int,ll> pi;

const int MAXN = 5e5+5;
string s;
int a[MAXN];

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	int n = s.size()+1;
	for (int i = 0; i < n-1; ++i) {
		if (s[i]=='<') a[i+1] = max(a[i+1],a[i]+1);
		//else a[i] = 0;
	}
	for (int i = n-2; i >= 0; --i) {
		if (s[i]=='>') a[i] = max(a[i+1]+1,a[i]);
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) ans += a[i];
	cout << ans;;;;;;;;;;;;;;;;;;;;;
	////~ for (int i = 0; i < n; ++i) cout << a[i] << ' ';
	//return 0;
}



Measured memory_bytes: 4764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e5 + 9, OO = (int) 2e9 + 1;
const long long MOD = 1e9 + 7, INF = 1e18 + 9;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(0);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void INPUT() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}

int n, arr[N];

int main() {
//	INPUT();
	OUTPUT();
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}
	if (n < 3) {
		cout << 1;
		return 0;

	}

	ll ans = 1, incc = 0, decc = 0;
	for (int i = 0; i < n - 1; i++) {
		if (arr[i] > arr[i + 1]) {
			if (decc) {
				decc = 0;
				ans++;
			} else {
				incc++;
			}
		} else if (arr[i] < arr[i + 1]) {
			if (incc) {
				incc = 0;
				ans++;
			} else {
				decc++;
			}
		}
	}
	cout << ans;
	return 0;

}


Measured memory_bytes: 640
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner e = new Scanner(System.in);
		
		int a = e.nextInt();
		int b = e.nextInt();
		
		if(a <= 5)
		{
			System.out.println("0");
		}
		else if(a >= 13)
		{
			System.out.println(b);
		}
		else if(a >= 6 || a <= 12)
		{
			System.out.println(b / 2);
		}
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    int a,b;

    cin >> a >> b;

    if(a + b < 10){
        cout << a + b << endl;
    }
    else{
        cout << "error" << endl;
    }
    
    return 0;
}

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

struct UnionFind{
private:
  vector<int> data;
public:
  int N;
  UnionFind(int n) : data(n, -1), N(n){}
  bool unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return false;
    --N;
    if(data[y] < data[x]) swap(x,y);
    data[x] += data[y];
    data[y] = x;
    return x != y;
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int find(int x){
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }
  int size(int x){ return -data[find(x)]; }
};

int main(){
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind uf(N);
  vector<int> D(N);
  for(int i = 0; i < M; ++i){
    int a, b;
    cin >> a >> b;
    --a,--b;
    uf.unite(a,b);
    ++D[a], ++D[b];
  }
  vector<int> ans(N);
  for(int i = 0; i < N; ++i)
    ans[i] = uf.size(i)-D[i]-1;

  for(int i = 0; i < K; ++i){
    int c, d;
    cin >> c >> d;
    --c,--d;
    if(uf.same(c,d)){
      --ans[c];
      --ans[d];
    }
  }
  for(int i = 0; i < N; ++i){
    cout << ans[i] << (i+1 < N ? " " : "\n");
  }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll a, b, v, w, t;
    cin>>a>>v>>b>>w>>t;
    if(v<=w) {cout<<"NO"<<endl; return 0;}
    double velocity = v-w;
    double distance = abs(a-b);
    double time = distance/velocity;
    if(time<=t) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
 
int main()
{
 
    int64_t k,a,b;
    cin>>k>>a>>b;


    bool flg=false;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            flg=true;
            break;
            }
    }

    if(flg)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;

    return 0;
}   

Measured memory_bytes: 3636
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

ll pow(ll n, ll a) {
    ll ans = 1;
    REP(i,n) ans *= a;
    return ans;
}

int main() {
    ll N; cin >> N;
    if(N%2 != 0) cout << 0 << endl;
    else {
        N /= 2;
        ll ans = 0;
        ll n = (ll)(log(N)/log(5));
        for(ll i = 1; i <= n; i++) {
            //cout << pow(i,5LL) << endl;
            ans += N/pow(i,5LL);
        } 
        cout << ans << endl;
    }
}


Measured memory_bytes: 384
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;  
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()
          
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;

const ll   N     =  5e5+8;
const ll   mod   =  998244353;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n, a[N], k;

void solve(){
	cin>>n>>k;
	for(int i = 1; i <= n; i++) cin>>a[i];
	for(int i = 1, j = k+1; j <= n; j++, i++){
		if(a[j] > a[i]) deb1("Yes")
		else deb1("No")
	}
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

Measured memory_bytes: 5224
#include <stdio.h>
#include <math.h>
#define N 500

int parent(int );
int left(int );
int right(int );

main(){
  int n,i,*k[N],x,p,l,r;

  scanf("%d",&n);

  for(i=1; i<=n; i++)
    scanf("%d",(k+i));

  
  for(i=1; i<=n; i++){
    
    printf("node %d: ",i);
    printf("key = %d, ",*(k+i));
    
    if(i==1){
      l=left(i);
      r=right(i);
      printf("left key = %d, ",*(k+l));
      printf("right key = %d, \n",*(k+r));
    }
    
    
    else if(i!=1 && 2*i+1<=n){
      p=parent(i);
      l=left(i);
      r=right(i);
      printf("parent key = %d, ",*(k+p));
      printf("left key = %d, ",*(k+l));
      printf("right key = %d, \n",*(k+r));
    }
    
    else if(i!=1 && 2*i<=n){
      p=parent(i);
      l=left(i);
      printf("parent key = %d, ",*(k+p));
      printf("left key = %d, \n",*(k+l));
    }
    
    else{
      p=parent(i);
      printf("parent key = %d, \n",*(k+p));
    }
  }
  return 0;
}



int parent(int i){
  return floor(i/2);
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


int main (int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, d;
  cin >> n >> d;
  vector<vector<int> > D(n);
  rep(i, n) {
    rep(j, d) {
      int x;
      cin >> x;
      D[i].push_back(x);
    }
  }

  vector<int> check;
  rep(i, 200) {
    check.push_back(i * i);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i ){
    for (int j = i + 1; j < n; ++j) {
      int dist = 0;
      rep(k, d) {
        dist += (D[i][k] - D[j][k]) * (D[i][k] - D[j][k]);
      }
      // cout << dist << endl;
      if (upper_bound(all(check), dist) - lower_bound(all(check), dist)) ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define REP(i,x,y) for(ll i = x;i <= y;++i)
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z))
        ;
    return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
void localTest() {
    #ifndef ONLINE_JUDGE
        freopen("inp", "r", stdin);
        freopen("out", "w", stdout);
    #endif      
}
const ll N = 1e5 + 5;
ll A[N];
int main() {

    localTest();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n, sum = 0;
 	cin >> n;
 	map<ll, ll> has;
 	for(ll i = 1;i <= n;++i) cin >> A[i], sum += A[i], has[A[i]]++;
 	ll q;
 	cin >> q;
 	while(q--) {
 		ll x, y;
 		cin >> x >> y;
 		sum -= has[x] * x;
 		sum += has[x] * y;
 		has[y] += has[x];
 		has[x] = 0;
 		cout << sum << "\n";
 	}

    
    return 0;
}

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

using namespace std;
int main(){
    long long N;
    vector<long long> v(5);
    long long ans=5;


    cin>>N;
    for(auto &x:v){
        cin>>x;
    }

    auto minn=min_element(v.begin(),v.end());

    ans+=N/ *minn;

if(N/ *minn>0&&N% *minn==0)ans--;

    cout<<ans<<endl;
}

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

int main() {
	string N;
	cin >> N;
	
	int dp[11][8]; // 第x桁目に部分集合y(y:{3,5,7})ができている組み合わせ
	memset(dp, 0, sizeof(dp)); // 全ての初期値は0よね
	
	for (int i = 0, tmp = N[0] & 15, j, k, cover = 0, isCover = 1;i < N.size();++ i, cover |= 1 << (tmp - 3 >> 1), isCover &= (tmp & 1) * (tmp & 6) ? 1 : 0, tmp = N[i] & 15) {
		dp[i][0] = 1; // 第x桁目が空集合……すなわち今まで0だった、これが最初の桁の組み合わせは当然だが1通り
		for (j = 1;j < 8;j <<= 1) {
			for (k = 0;k < 8;++ k) dp[i + 1][j | k] += dp[i][k];
			if (isCover && (j & 6) + 3 > tmp) -- dp[i + 1][j | cover]; // Nを超える場合をちょっと引き算
		}
	}
	
	cout << dp[N.size()][7]; // {3,5,7}全てを含む場合のみが答えなので
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

桁dpすると解ける
*/

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl
#define printV(v) for(int zxc=0;zxc<v.size()-1;zxc++){cout << v[zxc] << " ";} cout << v.back() << endl;

typedef pair<int, int> t;

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    long ans = k;
    for (int i = 1; i < n; i++) {
        ans *= (k - 1);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin>>s;
  vector<uint64_t> a(s+1,0);
  if(s==0){
    cout<<1<<endl;
  }else if(s<3){
    cout<<0<<endl;
  }else{
    a.at(0)=1;
    uint64_t sum;
    for(int i=1;i<s+1;i++){
      sum=0;
      if(i>=3){
        for(int j=0;j<=i-3;j++){
          sum+=a.at(j);
          sum%=1000000007;
        }
        a.at(i)=sum;
      }
    }
    cout<<a.at(s)<<endl;
  }
}
      

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="Sunny")
	{
		printf("Cloudy\n");
	}
	else if(s=="Cloudy")
	{
		printf("Rainy\n");
	}
	else
	{
		printf("Sunny\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,n;
	scanf("%d %d",&a,&b);
	n=a+b;
//	printf("%d\n",n);
	if(n>=24) {
		n=n-24;
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 128
def pour_counter(height):
	if not height:
		return 0
	elif 0 in height:
		index = height.index(0)
		# print(height[:index])
		# print(height[index:])
		return pour_counter(height[:index]) + pour_counter(height[index+1:])
	else:
		min_height = min(height)
		for i, element in enumerate(height):
			height[i] = element - min_height
		return pour_counter(height) + min_height

n = int(input())
height =  list(map(int, input().split())) 

count = pour_counter(height)
print(count)



Measured memory_bytes: 3060
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
int INF = 1 << 25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


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

  int N;
  cin >> N;
  VI a(N);
  REP(i, N) {
    cin >> a[i];
  }

  int ans = INF;

  FOR(ave, -100, 101) {
    int cost = 0;
    REP(i, N) {
      cost += (a[i] - ave) * (a[i] - ave);
    }
    ans = min(ans, cost);
  }

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

Measured memory_bytes: 256