akhauriyash/Code-Regression huggingface dataset:
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

void dfs(Graph &G, int num, vector<int> &mole, int i) {
    mole[i] = num;
    for(auto v : G[i]) {
        if(mole[v] == 0) {
            dfs(G, num, mole, v);
        }
    }
}

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<P> p;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        p.push_back(P(a,b));
    }
    int ans = 0;
    rep(i, m) {
        Graph G(n);
        rep(j,m) {
            if(i == j) continue;
            G[p[j].first].push_back(p[j].second);
            G[p[j].second].push_back(p[j].first);
        }
        int num = 0;
        vector<int> mole(n,0);
        rep(i, n) {
            if(mole[i] == 0) {
                num++;
                dfs(G, num, mole, i);
            }
        }
        if(num!= 1) ans++;
    }
    cout << ans << endl;;
    return 0;
}


Measured memory_bytes: 256
n = int(input())                                                                                                                                                             
p = list(map(int, input().split()))
count = 0 

for i in range(n-2):
    list = [p[i],p[i+1],p[i+2]]
    if min(list) != p[i+1] and max(list) != p[i+1]:
        count += 1

print(count)

Measured memory_bytes: 3060
n=int(input())
l=list(map(int,input().split()))
l.sort()
# print(l)
ans=0
a=len(l)
for i in range(a):
    for j in range(i,a):
        if l[i] == l[j]:
            continue
        for k in range(j,a):
            if l[j]==l[k]:
                continue
            elif l[k]>=l[i]+l[j]:
                continue
            # print(l[i],l[j],l[k])
            ans+=1
        
print(ans)


Measured memory_bytes: 9188
n = int(input())
a = list(range(n))
for i in range(n):
    a[i] = list(map(int, input().split()))
dx = 0
dy = 0
c = 0
k = 0
for s in range(n):
    dx = a[s][1] - dx
    dy = a[s][2] - dy
    if((dx+dy)>a[s][0]):
        print("No")
        break
    if(((abs(dx)+abs(dy))%2) == ((a[s][0]-k)%2)):
        c += 1
        k += a[s][0]
    else:
        print("No")
        break
if(c == n):
    print("Yes")

Measured memory_bytes: 27388
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

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

#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b[li],a[1005][1005],k,flag,t,cevap;
lo cev;
string s;
vector<lo> v;

int main(void){
	scanf("%lld %lld",&n,&m);
	for(lo i=1;i<=n;i++){
		for(lo j=1;j<=m;j++){
			scanf("%lld",&a[i][j]);
		}
	}
	for(lo i=1;i<=n;i++){
		for(lo j=i+1;j<=n;j++){
			cev=0;
			for(lo k=1;k<=m;k++){
				cev+=abs(a[i][k]-a[j][k])*abs(a[i][k]-a[j][k]);
			}
			lo at=sqrt(cev);
			if(cev==at*at)cevap++;
		}
	}
	printf("%lld\n",cevap);
	return 0;
}


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

int main(){
  int N;
  string s;
  cin >> N;
  bool flag = false;
  for(int i=0;i<N;i++){
    cin >> s;
    if(s=="Y"){
      flag = true;
      break;
    }
  }
  if(flag){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,c,d,n;
	int i=0;
	while(scanf("%d",&n)!=EOF){
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(a+b+c+d==n)
					    	i++;
					}
				}
			}
		}
	    printf("%d\n",i);
	    i=0;
	}
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
using namespace std;
int N=0;
int K=0;
int ans =0;
int cnt=0;
int cntPlus=0;
int cntMinus=0;
bool isReplaced=false;
int main(){
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    if(A.at(i) == 1){
      cnt=i;
    }
  }
  cntPlus=cnt;
  cntMinus=cnt;
  while(A.at(N-1)!=A.at(cnt) || A.at(0)!=A.at(cnt)){
    isReplaced=false;
    for(int i=0;i<K-1;i++){
      if(cntPlus==N-1){
        if(cntMinus==0){
          break;
        } else{
          A.at(cntMinus-1) = A.at(cntMinus);
          cntMinus--;
          isReplaced=true;
        }
      } else{
        A.at(cntPlus+1) = A.at(cntPlus);
        cntPlus++;
        isReplaced=true;
      }
    }
    if(isReplaced){
      ans++;
    }
  }

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



Measured memory_bytes: 640
/* Selection Sort */
#include<stdio.h>
main(){
  int A[101];
  int i,j,n,temp,mini,times=0;

  scanf("%d",&n); /* This n is length of array.*/
  if(n<1||n>100)return 0; /* Constraints: 1<= n <=100 */

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }

  /* Selection Sort */
  for(i=1;i<=n;i++){
    mini=i;
    for(j=i;j<=n;j++){
      if(A[j]<A[mini])mini=j;
    }
    temp=A[i];
    A[i]=A[mini];
    A[mini]=temp;
    if(mini!=i)times++; /* This times is number of swap operations. */
  }
  for(i=1;i<n;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",times);
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#define MAX_L 10001
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,ans=0,tmp,ri,le;
  cin >> n;
  ll l[n];
  ll lsum[MAX_L];
  fill(lsum,lsum+MAX_L,0);
  vector<ll> val;
  for(int i=0;i<n;i++){
    cin >> l[i];
    lsum[l[i]]++;
  }
  for(int i=1;i<MAX_L;i++){
    lsum[i]+=lsum[i-1];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      tmp=0;
      le = abs(l[i]-l[j]);
      ri = l[i]+l[j];
      if(le>=ri){
        continue;
      }
      if(ri>0){
        tmp += lsum[ri-1];
      }
      tmp -= lsum[le];
      if(le<l[i]&&l[i]<ri){
        tmp--;
      }
      if(le<l[j]&&l[j]<ri){
        tmp--;
      }
      ans += max((ll)0,tmp);
    }
  }
  cout << ans/3 << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main (){
	char a[20],b[20],c[20];
scanf("%s %s %s",&a,&b,&c);
	int lenX=strlen(a);
	int lenY=strlen(b);
	
	if (a[lenX-1]== b[0]&&b[lenY-1]==c[0]){
		puts("YES");
	}else {
		puts("NO");
	}

return 0;

}

Measured memory_bytes: 1656
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int s = sc.nextInt();
    int now = s;
    List<Integer> li = new ArrayList<Integer>();
    li.add(s);
    while(!(li.contains(fan(now)))){
      li.add(fan(now));
      now = fan(now);
    }
    int size = li.size();
    System.out.println(size+1);

  }
  public static int fan(int a){
    if(a % 2 == 0){
      return a/2;
    }else{
      return 3*a+1;
    }
  }
}


Measured memory_bytes: 35784
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll h,w;
  cin >> h >> w;
  vvl a(h,vl(w));
  ll cnt=0;
  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
      if(a[i][j]%2==1){
        cnt++;
      }
    }
  }
  if(cnt%2!=0){
    cnt--;
  }
  ll i=0,j=0;
  ll X=0;
  ll A=0;
    while(i<h){
    ll BX=i,BY=j;
    if(a[BX][BY]%2!=0){
      X++;
    }
    if(i%2==0){
      j++;
      if(j==w){
        i++;
        j=w-1;
      }
    }
    else if(i%2==1){
      j--;
      if(j==-1){
        i++;
        j=0;
      }
    }
    if(i==h){
      break;
    }
    if(X%2==1&&X<=cnt){
      A++;
    }
  }
  cout << A << endl;
  i=0,j=0,X=0;
  while(i<h){
    ll BX=i,BY=j;
    if(a[BX][BY]%2!=0){
      X++;
    }
    if(i%2==0){
      j++;
      if(j==w){
        i++;
        j=w-1;
      }
    }
    else if(i%2==1){
      j--;
      if(j==-1){
        i++;
        j=0;
      }
    }
    if(i==h){
      break;
    }
    if(X%2==1&&X<=cnt){
      cout << BX+1 << " " << BY+1 << " " << i+1 << " " << j+1 << endl;
    }
  }
}

Measured memory_bytes: 4096
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
int main()
{
    // freopen("A.01.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char c;
    scanf("%c", &c);
    for (short i = 65; i <= 90; i++)
    {
        if (c == i)
        {
            printf("%c", 'A');
            return 0;
        }
    }
    printf("%c", 'a');
    return 0;
}

Measured memory_bytes: 3712
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d)
        cout << "Left" << endl;
    else if (a + b == c + d)
        cout << "Balanced" << endl;
    else
        cout << "Right" << endl;
    return 0;
}

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
s = LI()
t = LI()
dp  = [[0]*(m+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(n+1):
    dp[i][0] = 1
for j in range(m+1):
    dp[0][j] = 1
for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % mod
        else:
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j]) % mod
print(dp[n][m])

Measured memory_bytes: 72540
#include<iostream>
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;

  int a, b;
  cin >> a >> b;

  string u;
  cin >> u;

  if(u.compare(s) == 0){
    a-- ;
  } else {
    b--;
  }
  
  cout << a << " " << b << endl;
    
  return 0;
}

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

struct Card{
    char suit;
    char value;
};

void swap(Card& c1,Card& c2){
    Card t=c1;
    c1=c2;
    c2=t;
}

void bubble(Card c[],int n){
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(c[j-1].value>c[j].value) swap(c[j-1],c[j]);
        }
    }
}

void selection(Card c[],int n){
    for(int i=0;i<n;i++){
        int min=i;
        for(int j=i;j<n;j++){
            if(c[min].value>c[j].value) min=j; 
        }
        swap(c[min],c[i]);
    }
}

void print(Card c[],int n){
    for(int i=0;i<n;i++){
        if(i) cout<<' ';
        cout<<c[i].suit<<c[i].value;
    }
    cout<<endl;
}

bool isStable(Card c1[],Card c2[],int n){
    for(int i=0;i<n;i++){
        if(c1[i].suit!=c2[i].suit) return false;
    }
    return true;
}


int main(){
    int n;cin>>n;
    Card c1[40],c2[40];
    for(int i=0;i<n;i++){
        cin>>c1[i].suit>>c1[i].value;
    }
    for(int i=0;i<n;i++){
        c2[i]=c1[i];
    }
    bubble(c1,n);
    selection(c2,n);

    print(c1,n);
    cout<<"Stable"<<endl;
    print(c2,n);
    if(isStable(c1,c2,n)) {cout<<"Stable"<<endl;}
    else {cout<<"Not stable"<<endl;}
}





Measured memory_bytes: 3092
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 23 14:44:36 2019

@author: Enya
"""

X = input()

A = int(X.split()[0])
B = int(X.split()[1])
C = int(X.split()[2])
D = int(X.split()[3])

from fractions import gcd

E = (C*D)//gcd(C,D)



N_1 = (B // C) 
N_11 = (A-1) // C
N_2 = (B // D)
N_22 =((A-1) // D)
N_3 = (B // E)
N_33 = (A-1) // E

a = B - (N_1 + N_2 - N_3)
b= (A-1) - (N_11 + N_22 - N_33)




print(int(a-b))

Measured memory_bytes: 5076
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

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


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll res[41]={408875452660,1722125036282,3988800240289,7235062807366,11479011688245,16734924755096,23013964372551,30326413365285,38679944926812,48081994935671,58539707599783,70058785460280,82644353395127,96301520878991,111035349416856,126850549017804,143749192448739,161737467121483,180816973674988,200992441246692,222266481117362,244642548171917,268122443879733,292711324081941,318409439232054,345219904513529,373145655996233,402188826344049,432351372593538,463635895079489,496045307801936,529581632274134,564243999095306,600036645526326,636961255455435,675021515919670,714214048734419,754546104527913,796016413077051,838627288460105,838627288460105};

int main(void){
	scanf("%d",&n);
	ll ans=0;
	int k=0;
	int i=0;
	while(i+250000<=n){
		k++;
		i+=250000;
	}
	if(k>0){
		ans+=res[k-1];
	}
	i++;
	for(;i<=n;i++){
		int cnt=0;
		for(int j=1;j*j<=i;j++){
			if(i%j==0){
				cnt++;
				if(j!=i/j){
					cnt++;
				}
			}
		}
		ans+=(ll)cnt*i;
		/*
		if(i%250000==0){
			res[i/250000]=ans;
			printf("%lld,",res[i/250000]);
		}
		*/
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
int h[100010],num[100010],n,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&h[i]);
	for(int i=n-1;i>=1;--i) {
		if(h[i]>=h[i+1]) num[i]=num[i+1]+1;
		else num[i]=0;
	}
	for(int i=1;i<=n;++i) ans=max(ans,num[i]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
import sys

input = sys.stdin.buffer.readline
n, s = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0] * (s + 1) for _ in range(n + 1)]

mod = 998244353
# dp[i][s] A[i]まで見た時、合計sになる数。
# 各々の地点で新しく開始されるものも有るので毎回dp[i][0]は＋1
dp[0][0] = 1
ans = 0
for i in range(n):
    ni = i + 1
    for j in range(s + 1):
        nj = j
        dp[ni][nj] += dp[i][j]
        dp[ni][nj] %= mod
        nj = j + A[i]
        if nj <= s:
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= mod
    dp[ni][0] += 1
    ans += dp[ni][s]
    ans %= mod
print(ans)


Measured memory_bytes: 112988
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
    int x,y,z,k;
    cin>>x>>y>>z>>k;

    int a[x],b[y],c[z];
    for (int i = 0; i < x; ++i) {
        cin>>a[i];
    }

    for (int i = 0; i < y; ++i) {
        cin>>b[i];
    }

    for (int i = 0; i < z; ++i) {
        cin>>c[i];
    }

    sort(a,a+x,greater<>());
    sort(b,b+y,greater<>());
    sort(c,c+z,greater<>());

    vector<int>ans;

    for (int i = 0; i < x; ++i) {
        if(i+1>k)
            break;
        for (int j = 0; j < y; ++j) {
            if((i+1)*(j+1)>k)
                break;
            for (int l = 0; l < z; ++l) {
                if((i+1)*(j+1)*(l+1)>k)
                    break;

                ans.push_back(a[i]+b[j]+c[l]);
            }
        }
    }


    sort(ans.begin(),ans.end(),greater<> ());
    for (int m = 0; m < k; ++m) {
        cout<<ans[m]<<"\n";
    }
}

Measured memory_bytes: 1400
N,K,Q = map(int,input().split())
A = list(map(int,input().split()))
B = sorted(A) # A をソート
L = [[i,B[i+Q-1] - B[i]] for i in range(N-Q+1)] # BからX-Yの最小パターンを出す
sL = sorted(L,key=lambda x:x[1]) # Lをソート

if Q == 1:
    # 一つしか選ばない -> max == min -> 0
    print(0)
    exit()

if Q == N - K + 1:
    # 全部の要素が選ばれる = 必ず最小値が選ばれる
    print(L[0][1])
    exit()

if K == 1:
    # 一つずつ選べる -> 必ず最小のパターンに出来る
    print(sL[0][1])
    exit()

if sL[0][0] == 0:
    # minが最小の時 最小のパターンになる時
    print(sL[0][1])
    exit()

if sL[0][1] == sL[len(sL)-1][1]:
    print(sL[0][1])
    exit()

now_max_value = -1
now_min_value = -1
now_min_XY = int(1e10)

for key,value in sL:
    max_value = B[key + Q - 1]
    min_value = B[key]
    C = [(i if i >= min_value else None) for i in A]
    i = 0
    j = 0
    count = 0
    min_OK = max_OK = False
    while i < N:
        if not C[i]:
            i += 1
            continue
        j = i + 1
        while j < N:
            if not C[j]:
                break
            j += 1
        tmp = (j-i) - K + 1
        if  tmp < 1:
            # 要素を取得できないパターン
            #if min(C[i:j]) < max_value:
            #    count = 0
            #    break
            i = j + 1
            continue
        sC = sorted(C[i:j])
        if not min_OK and (sC[0] == min_value):
            min_OK = True
        if not max_OK and max_value in sC[0:tmp]:
            max_OK = True
        #if sC[tmp] < max_value:
        #    count = 0
        #    break
        count += tmp - len([i for i in sC[:tmp] if i > max_value])
        i = j +1
    if min_OK and max_OK and (count >= Q):
        print(value)
        exit()
    now_min_XY = min(now_min_XY,now_max_value - now_min_value)
    now_max_value = -1
    now_min_value = -1

print(L[0][1])



Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

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
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) {}

    ll root(ll x) {
        if (data[x] < 0)
            return x;
        else
            return data[x] = root(data[x]);
    }

    ll size(ll x) { return -data[root(x)]; }

    bool isConnect(ll x, ll y) { return root(x) == root(y); }

    bool connect(ll x, ll y) {
        x = root(x);
        y = root(y);

        if (x == y)
            return false;

        if (data[x] > data[y]) {
            x ^= y;
            y ^= x;
            x ^= y;
        }

        data[x] = data[x] + data[y]; // membersize++
        data[y] = x;
        return true;
    }
};

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class E1Or2 {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll N, M;
        in >> N >> M;
        ll X[M], Y[M], Z[M];
        UnionFind U(N);
        REP(i, M) {
            in >> X[i] >> Y[i] >> Z[i];
            X[i]--; Y[i]--;
            U.connect(X[i], Y[i]);
        }
        set<ll> ans;
        REP(i, N) {
            ans.insert(U.root(i));
        }
        out << ans.size() << '\n';
	}
};


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


Measured memory_bytes: 8064
import sys
readline = sys.stdin.buffer.readline

H, W, D = map(int, readline().split())
px = [0] * (H*W+1)
py = [0] * (H*W+1)
d = [0] * (H*W+1)

for y in range(H):
    line = list(map(int, readline().split()))
    for x, A in enumerate(line):
        px[A] = x
        py[A] = y

for i in range(D+1, H*W+1):
    d[i] = d[i-D] + abs(px[i]-px[i-D]) + abs(py[i]-py[i-D])

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print(d[R]-d[L])


Measured memory_bytes: 9268
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;
ll x[200010],y[200010],d;

void solve(){
    cin >> n >> d;
    rep(i,n){
        cin >> x[i] >> y[i];
    }
    int ans=0;
    rep(i,n){
        if(x[i]*x[i]+y[i]*y[i]<=d*d) ans+=1;
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

template<typename T>
struct BIT {
    int n;
    vector<T> bit;
    BIT(int _n) : n(_n), bit(_n + 1) { }
    // [0, i], i is 0-indexed.
    T sum(int i) {
        T s = 0;
        for (i++; i > 0; i -= i & -i) s += bit[i];
        return s;
    }
    // [l, r), l and r is 0-indexed.
    T sum(int l, int r) {
        return sum(r - 1) - sum(l - 1);
    }
    void add(int i, T x) {
        for (i++; i <= n; i += i & -i) bit[i] += x;
    }
};

/*
    verified http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp
*/
int main() {
    int n, q; cin >> n >> q;
    BIT<int> bit(n);
    for (int i = 0; i < q; ++i) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) bit.add(--x, y);
        else cout << bit.sum(--x, y) << endl;
    }
}



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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL A, B, M;
  cin >> A >> B >> M;
  vector<LL> As(A);
  vector<LL> Bs(B);

  LL Amin = mod;
  LL Bmin = mod;
  
  REP(i,A){
    cin>> As[i];
    if(Amin>As[i]){
      Amin = As[i];
    }
  }
  REP(i,B){
    cin>> Bs[i];
    if(Bmin>Bs[i]){
      Bmin = Bs[i];
    }
  }

    LL mn = Amin + Bmin;
    
    REP(i,M){
      LL x,y,c;
      cin >> x >> y >> c;
      LL cost = As[x - 1] + Bs[y - 1] - c;
      if(mn>cost){
        mn = cost;
      }
    }
  

  cout << mn << endl;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func StartsWith(s, prefix []rune) bool {
	if len(s) < len(prefix) {
		return false
	}
	for i := range prefix {
		if s[i] != prefix[i] {
			return false
		}
	}
	return true
}

func main() {
	var s string
	fmt.Scanln(&s)
	r := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	words := [][]rune{[]rune("maerd"), []rune("remaerd"), []rune("esare"), []rune("resare")}
	for {
		if len(r) == 0 {
			fmt.Println("YES")
			return
		}
		fail := 0
		for _, w := range words {
			if StartsWith(r, w) {
				r = r[len(w):]
				break
			} else {
				fail++
			}
		}
		if fail == len(words) {
			fmt.Println("NO")
			return
		}
	}
}


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

#define ll long long
const ll mod = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K,ans=0,cnt = 0,p = 0;
	cin >> N >> K;
	vector<int> A(N);
	for(int i=0;i<N;i++)cin >> A[i];
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
		if(A[i]>A[j])cnt++;
	}
	for(int i=0;i<N;i++)for(int j=0;j<N;j++){
		if(i==j)continue;
		if(A[i]<A[j])p++;
	}
	ans += cnt*K % mod;
	ans %= mod;
	ans += (K-1)*K/2 % mod * p %mod;
	ans %= mod;
	cout << ans%mod << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int n = Integer.parseInt(tmpArray[0]);
		int d = Integer.parseInt(tmpArray[1]);
		
		int result = n / (2*d + 1);
		
		if(n % (2*d + 1) != 0){
			result++;
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 22356
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;

int main(void) {
    ll a,b,c,d; cin >> a >> b >> c >> d;
    
    ll one = a * c;
    ll two = a * d;
    ll three = b * c;
    ll four = b * d;
    
    cout << max(four,max(three ,max(one, two))) << endl;
    
    
    
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
   ll x; cin >> x;
   ll n = 100;
   int i = 0;
   while(true){
       n = n * 1.01;
       i++;
       if(n >= x){
           cout << i << endl;
           return 0;
       }
    }
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll kai(vector<ll> A, ll key) {
	ll an = 0;
	rep(i, A.size()) {
		an += (A.at(i) - 1) / key;
	}
	return an;
}
// index が条件を満たすかどうか
bool isOK(int index,vector<ll> A, int K) {
	if (kai(A,index) <= K) return true;
	else return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(ll MA,vector<ll> A,ll K) {
	int left = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = MA; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, A,K)) right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
vector<ll> fact, factinv, inv;
ll mod = 1e9 + 7;
void prenCkModp(ll n) {
	fact.resize(n + 5);
	factinv.resize(n + 5);
	inv.resize(n + 5);
	fact.at(0) = fact.at(1) = 1;
	factinv.at(0) = factinv.at(1) = 1;
	inv.at(1) = 1;
	for (ll i = 2; i < n + 5; i++) {
		fact.at(i) = (fact.at(i - 1) * i) % mod;
		inv.at(i) = mod - (inv.at(mod % i) * (mod / i)) % mod;
		factinv.at(i) = (factinv.at(i - 1) * inv.at(i)) % mod;
	}

}
ll nCk(ll n, ll k) {
	if (n < 0 || k < 0){
		return 1;
	}
	else if (n < k) {
		return 0;
	}
	return fact.at(n) * (factinv.at(k) * factinv.at(n - k) % mod) % mod;
}
ll HP[4];
int main() {
	ll N, an = 1e10;;
	cin >> N;
	vector<ll> a(N);
	rep(i, N) {
		cin >> a.at(i);
	}
	for (ll i = -100; i <= 100; i++) {
		ll d = 0;
		rep(j, N) {
			d += (i - a.at(j)) * (i - a.at(j));
		}
		an = min(an, d);
	}
	cout << an << endl;
 }


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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int max_n = 100011, inf = 1000111222;

int n, a[max_n], b[max_n];
vector<int> v;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	ll sum = 0;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &b[i]);
		a[i] -= b[i];
		if (a[i] < 0) {
		    sum += a[i];
		    ++ans;
		}
		else v.push_back(a[i]);
	}
	sum *= -1;
	sort(v.begin(), v.end());
	if (sum == 0) {
		cout << 0 << endl;
		return 0;
	}
	if (v.empty()) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = v.size() - 1; i >= 0; --i) {
		sum -= v[i];
		++ans;
		if (sum <= 0) {
			cout << ans << endl;
			return 0;
		}
	}
	cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
map<ll,ll>mp;
vector<ll>v;
int main(){
	mp[10ll] = 10ll;
	mp[100ll] = 100ll;
	mp[2000ll] = 1000ll;
	mp[30000ll] = 10000ll;
	mp[400000ll] = 100000ll;
	mp[5000000ll] = 1000000ll;
	mp[60000000ll] = 10000000ll;
	mp[700000000ll] = 100000000ll;
	mp[8000000000ll] = 1000000000ll;
	mp[90000000000ll] = 10000000000ll;
   mp[1000000000000ll] = 100000000000ll;
   mp[10000000000000ll] = 1000000000000ll;
   mp[110000000000000ll] = 10000000000000ll;
 //  mp[1000000000000000ll] = 100000000000000ll;
   ll x = 1;
	ll add = 1;
	while(x<=1e16){
		x+=add;
		v.pb(x-1);
		if(mp.count(x))add = mp[x];
	}
	int k; 
	cin>>k;
	for(int i=0;i<k;i++){
		cout<<v[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll n,s;
inline bool check (ll b)
{
    if (b<2) return false;
    ll sum=0;
    ll m=n;
    while (m>0) {
        sum+=m%b;
        m/=b;
    }
    if (sum==s) return true;
    else return false;
}
int main ()
{
    cin>>n>>s;
    if (n==s) {
        cout<<n+1<<endl;
        return 0;
    }
    ll k=sqrt(n);
    ll ans=n+1;
    for (ll i=1;i<=k;i++) {
        if (check(i)) ans=min(ans,i);
        if ((n-s)%i==0) {
            ll t=(n-s)/i;
            if (check(t+1)) ans=min(ans,t+1);
            if (i==k && check(k+1)) ans=min(ans,k+1);
        }
    }
    if (ans==n+1) cout<<-1<<endl;
    else cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
/*
 
@author
_      _          _                 _      _
\\    // /\    | | \  |     |    /\ \\    //     
 \\  // /__\   | |_/  |_____|   /__\ \\  //
  \\// /    \  | | \  |     |  /    \ \\//
   \/ /      \ | |_/  |     | /      \ \/
@ Indian Institute of Technology Bhilai

With practice comes perfection,
with knowledge comes wisdom.
Incorporate wisdom in you, practice will harvest better results.
Always learn from others, your method is good but someone's even better.
Results take time, run for wisdom, for innovation, for getting better.
Points are mere objects, either you solve first or you solve better.
Seek for betterment, for quality, pace is important but cannot outstand
the quality you persist.
Times are bad just as now but it'll improve, this is my passion and I promise 
I won't let it go. I'll build myself again like a fighter gets back up after 
being thrown to the ground.
I'll learn. I bet that. I promise that.
*/
 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
#define fr(i,start,end, inc) for(ll i=(start); i<(end); i+=inc)
#define rf(i,end,start, inc) for(ll i=(start-1); i>=(end); i-=inc)
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define pl pair<ll, ll>
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define alla(arr,n) arr, arr+n
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define fsync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll maxx =  1e9+7;

bool compare(vector<ll> &a, const vector<ll> &b){
    return a.size()>b.size();
}

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

bool inline isPrime(ll n) { 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
}

template<class T>
void printv(T &v, ll n){
    if(n==-1)
        n = v.size();
    rep(i,n)
        cout << v[i] << " ";
    cout << "\n";
}


void solve(){
    ll n,m;
    double sum=0;
    cin>>n>>m;
    vector<ll>v(n);
    rep(i,n){
        cin>>v[i];
        sum+=v[i];
    }
    sort(all(v),greater<ll>());
    if(v[m-1]>=(sum/(4*m))){
        yes;
    }
    else
        no;
}
void solve2(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout <<c<<" "<<a<<" "<<b<<"\n";
}

int main(){
    fsync
    ll test=1;
    // cin >> test;
    while(test--){
        solve();
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1) a = 14;
	if (b == 1) b = 14;
	if (a > b) dump("Alice") else if (a == b) dump ("Draw") else dump("Bob")
}

Measured memory_bytes: 256
from collections import defaultdict
import heapq
inpl = lambda: list(map(int,input().split()))

X, Y, Z, K = inpl()
A = [ sorted(inpl(), reverse=True) for _ in range(3) ]
N = [X, Y, Z]

mem = defaultdict(int)
score = sum([A[i][0] for i in range(3)])
mem[(0,0,0)] = 1
candidates = []
heapq.heappush(candidates, (-score,(0,0,0)))

for i in range(K):
    c = heapq.heappop(candidates)
    print(-c[0])
    n = list(c[1])
    
    for p in range(3):
        if n[p] < N[p]-1:
            n[p] += 1
            if mem[tuple(n)] == 0:
                mem[tuple(n)] = 1
                score = sum([A[j][n[j]] for j in range(3)])
                heapq.heappush(candidates, (-score,tuple(n)))
            n[p] -= 1

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const vector<int>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int r;
    cin >> r;

    cout << 3*r*r << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(int, n, k);
	vector<int> a(n);
	cin >> a;
	
	inc(i, n) {
		if(i - k < 0) { continue; }
		OUT(a[i - k] < a[i] ? "Yes" : "No");
	}
}


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

int N, M, Q;
vector< int > Vc[ 510 ];

int main() {
    scanf( "%d%d%d", &N, &M, &Q );
    for( int i = 1; i <= M; ++i ) {
        int X, Y;
        scanf( "%d%d", &X, &Y );
        Vc[ X ].push_back( Y );
    }
    for( int i = 1; i <= N; ++i ) sort( Vc[ i ].begin(), Vc[ i ].end() );
    for( int i = 1; i <= Q; ++i ) {
        int X, Y; scanf( "%d%d", &X, &Y );
        int Ans = 0;
        for( int j = X; j <= Y; ++j ) Ans += upper_bound( Vc[ j ].begin(), Vc[ j ].end(), Y ) - lower_bound( Vc[ j ].begin(), Vc[ j ].end(), X );
        printf( "%d\n", Ans );
    }
    return 0;
}

Measured memory_bytes: 2176
N = int(input())
sum_cnt = 0
for n in range(1, N+1):
  cnt = 0
  for i in range(1, n+1):
    if n % i == 0:
      cnt += 1
  if cnt == 8 and n % 2 == 1:
    sum_cnt += 1
print(sum_cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, s, n) for(int i = s; i < n; i++)
#define rrep(i, s, n) for(int i = s; i > (s)-(n); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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

  int a, b;
  cin >> a >> b;

  if ((a*b)%2 == 0) pr("Even");
  else pr("Odd");


  return 0;
}


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

#define MAX 10000

int main() {
        int s_ary[MAX], q_ary[MAX];
        int n, q, cnt = 0, flag = 0;

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

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

        for ( int i = 0 ; i < q ; i++ ) {

                flag = 0;
                for ( int j = 0 ; j < n ; j++ ) {
                        if ( s_ary[j] == q_ary[i] ) {
                                flag = 1;
                        }
                }
                if ( flag ) { cnt++; }
        }
        printf( "%d\n", cnt );
}



Measured memory_bytes: 2096
#include <iostream>
#include <cstdlib>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <math.h>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

ll n, m;


int main () 
{
	string s;

	cin >> n;

	int r = 0, b = 0;

	cin >> s;

	for (auto a : s)
		if (a == 'R') r++;
		else b++;

	if (r > b) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define op_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fo(i,a,b) for(int i=a; i <b; i++)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<int,int> mpii;
typedef map<ll,ll> mpll;
typedef map<int,ll> mpil;
typedef map<ll,int> mpli;

int main(){
  op_io;
  double pi = 4.0*atan(1.0);
  double cdr = pi/180.0;
  int A,B,H,M;
  cin>>A>>B>>H>>M;
  double totalm = 60*H + M;
  //cout<<"totalm = "<<totalm<<endl;
  double h_ang = (360.0/720.0)*totalm;
  double m_ang = (6.0*M);
  //cout<<"h_ang="<<h_ang<<", m_ang = "<<m_ang<<endl;
  double mang = abs(m_ang - h_ang);
  //cout<<"mang = "<<mang<<endl;
  double c2 = A*1.0*A + B*1.0*B - 2.0*A*B*cos(mang*cdr);
  double c = sqrt(c2);
  cout<<setprecision(15);
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 4180
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;
int n;

const int INF = 1 << 29;

int main(void)
{
	string str;
	cin >> str;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		string ring;
		cin >> ring;
		if((ring + ring).find(str) != string::npos) ans++;
	}
	cout << ans << endl;;
	return 0;
}

Measured memory_bytes: 1212
s=list(input())
t=list(input())
num=len(s)-len(t)
ans1=-1
for i in range(num+1):
    num1=0
    num2=num-i
    for j in range(len(t)):
        if s[num2+j]!=t[j] and s[num2+j]!="?":
            num1=1
            break
    if num1==0:
        ans1=num2
        break
if ans1==-1:
    print("UNRESTORABLE")
else:
    ans=""
    for i in range(len(t)):
        s[ans1+i]=t[i]
    for i in range(len(s)):
        if s[i]=="?":
            s[i]="a"
        ans+=s[i]
    print(ans)


Measured memory_bytes: 9008
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

bool isPrime(int x) {
    if(x == 2) {
        return true;
    } else if(x % 2 == 0) {
        return false;
    }

    for(int i = 3; i * i <= x; i += 2) {
        if(x % i == 0) {
            return false;
        }
    }

    return true;
}


int main(void) {
    int n;

    scanf("%d", &n);

    int *array = malloc(n * sizeof(int));
    if(array == NULL) {
        return 1;
    }

    int cnt = 0;
    for(int i = 0; i < n; i++) {
        scanf("%d", &array[i]);
        if(isPrime(array[i])) {
            cnt++;
        }
    }

    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 2112
N = int(input())
A = list(map(int, input().split(' ')))
ans = []
if A.count(A[0]) == len(A):
    print(0)
    exit(0)
for i in range(-100,101):
    cost = 0
    for j in range(N):
        if A[j] == i:
            continue
        else:
            cost += (A[j] - i)**2
    ans.append(cost)
import heapq
heapq.heapify(ans)
print(heapq.heappop(ans))

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strconv"
)

func output(a, b, c, d int, i, j, k int) {
	fmt.Print(a)
	switch {
	case i == 1:
		fmt.Print("+")
	default:
		fmt.Print("-")
	}
	fmt.Print(b)
	switch {
	case j == 1:
		fmt.Print("+")
	default:
		fmt.Print("-")
	}
	fmt.Print(c)
	switch {
	case k == 1:
		fmt.Print("+")
	default:
		fmt.Print("-")
	}
	fmt.Print(d)
	fmt.Println("=7")
}

func main() {
	var n, a, b, c, d int
	var s string
	fmt.Scan(&s)
	n, _ = strconv.Atoi(s)
	a = (n / 1000) % 10
	b = (n / 100) % 10
	c = (n / 10) % 10
	d = (n / 1) % 10

	for i := 1; i >= -1; i -= 2 {
		res1 := a + (b * i)
		for j := 1; j >= -1; j -= 2 {
			res2 := res1 + (c * j)
			for k := 1; k >= -1; k -= 2 {
				res3 := res2 + (d * k)
				if res3 == 7 {
					output(a, b, c, d, i, j, k)
					return
				}
			}
		}
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a;
  for (int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    tmp--;
    a.push_back(tmp);
  }

  int now = 0, cnt = 0;
  for (;;) {
    if (now == 1) {
      printf("%d\n", cnt);
      break;
    }
    if (cnt >= n) {
      printf("-1\n");
      break;
    }
    cnt++;
    now = a[now];
  }

  return 0;
}


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

vector<int>pr;
vector<int>Qpr;
bool isp[11451419];

void eratos(int mx){
	for(int i=0;i<=mx;i++)isp[i]=true;
	
	isp[0]=false;
	isp[1]=false;
	
	for(int i=2;i<=mx;i++){
		if(isp[i]){
			pr.push_back(i);
			for(int j=2*i;j<=mx;j+=i)isp[j]=false;
			}
		}
		return ;
	}

int main(){
	eratos(11451400);
	for(int i=3;i<pr.size();i++){
			int a=pr[i-3];
			int b=pr[i-2];
			int c=pr[i-1];
			int d=pr[i];
			
			if(b-a==2&&c-b==4&&d-c==2)Qpr.push_back(d);
			}
	int n;
	while(cin>>n,n){
		int ans=0;
		
		for(int i=0;i<Qpr.size();i++){
			if(Qpr[i]>n)break;
			ans=Qpr[i];
			}
			cout<<ans<<endl;
		}
		return 0;
	}

Measured memory_bytes: 17864
#include<cstdio>
using namespace std;
typedef long long LL;
LL a,b,c;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	for(int i=1;i<=b;i++)
	{
		if(i*a%b==c)
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 128