akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using Lf = long double;
using plong = pair<ll,ll>;
const int MOD = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
const long MAX = 100000;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long COM(long n, long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    for(ll i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    COMinit();
    mint res=0;
    for(ll i=0;i<N;i++){
        res+=(A[i])*(COM(i,K-1)-COM(N-1-i,K-1));
        // cout<<res<<endl;
    }

    cout<<res<<endl;


}

Measured memory_bytes: 3328
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  b++;
  if(b - a > c * 2){
    for(int i = 0;i < c;i++){
      printf("%d\n",a + i);
    }
    for(int i = b - c;i < b;i++){
      printf("%d\n",i);
    }
  }else{
    for(int i = a;i < b;i++){
      printf("%d\n",i);
    }
  }
  return 0;
}

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int flag[1003][1003];
int num[1003][1003];
int dx[8]={-1,0,1,1,1,0,-1,-1};
int w,h;
int dy[8]={1,1,1,0,-1,-1,-1,0};
string c[1003];
bool in(int a,int b){
    if(a>=0&&b>=0&&a<h&&b<w)return true;
    else false;
}
signed main()
{
    cin >> h >> w;
    rep(i,0,h){
        cin >> c[i];
    }
    rep(i,0,1000){
        rep(j,0,1000){
            num[i][j]=0;
            flag[i][j]=0;
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            if(c[i][j]=='.'){
                num[i][j]=0;
                rep(k,0,8){
                    if((i+dy[k])>=0&&(j+dx[k])>=0&&(i+dy[k])<h&&(j+dx[k])<w){flag[i+dy[k]][j+dx[k]]++;}
                }
            }else{
                num[i][j]=(c[i][j]-'0');
            }
        }
    }
    int ans=0;
    queue<pii> que;
    queue<pii> ser;
    rep(i,0,h){
            rep(j,0,w){
                if(num[i][j]==0)continue;
                if(flag[i][j]>=num[i][j]){
                    num[i][j]=0;
                    que.push(mp(i,j));
                }
            }
    }
    while(1){
        if(ans!=0){
            if(ser.empty())break;
            while(!ser.empty()){
                pii p=ser.front();ser.pop();
                int i=p.first;int j=p.second;
                if(num[i][j]==0)continue;
                if(flag[i][j]>=num[i][j]){
                    num[i][j]=0;
                    que.push(mp(i,j));
                    //flag[i][j]++;
                }
            }
        }
        if(que.empty())break;
        ans++;
        while(!que.empty()){
            pii p=que.front();que.pop();
            int y=p.first;
            int x=p.second;
            rep(k,0,8){
                if((y+dy[k])>=0&&(x+dx[k])>=0&&(y+dy[k])<h&&(x+dx[k])<w){
                    if(num[y+dy[k]][x+dx[k]]!=0){
                        //if(flag[y+dy[k]][x+dx[k]]>=num[y+dy[k]][x+dx[k]]){
                            //num[y+dy[k]][x+dx[k]]=0;
                            ser.push(mp(y+dy[k],x+dx[k]));
                            flag[y+dy[k]][x+dx[k]]++;
                        //}
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19724
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int n, m;
    io.read(n, m);
    cout << (n - 1) * (m - 1);
    return 0;
}

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

#define int long long
const long long MOD=1e9+7;
void f(int &a){
  a%=MOD;if(a<0)a+=MOD;
}
void kakeru(int &a,int b){
  f(a);f(b);a*=b;f(a);
}

signed main(){
  int n,k,ans=1;cin>>n>>k;
  vector<int> pl,mi;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    (a>=0?pl:mi).push_back(a);
  }
  sort(pl.begin(),pl.end());
  sort(mi.begin(),mi.end());
  if(n==k){
    for(int p:pl)kakeru(ans,p);
    for(int p:mi)kakeru(ans,p);
    cout<<ans<<endl;return 0;
  }
  if(k&1)
    if(pl.size()){
      kakeru(ans,pl.back());
      pl.erase(pl.end()-1);
    }
    else{
      for(int i=0;i<k;i++)kakeru(ans,mi[n-1-i]);
      cout<<ans<<endl;return 0;
    }
  k>>=1;
  priority_queue<int> pque;
  for(int i=(int)pl.size()-1;i>0;i-=2)pque.push(pl[i]*pl[i-1]);
  for(int i=0;i<(int)mi.size()-1;i+=2)pque.push(mi[i]*mi[i+1]);
  while(k--){
    kakeru(ans,pque.top());pque.pop();
  }
  cout<<ans<<endl;
}


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

int so(int a){
  for(int i=2;i*i<=a;i++){
    if(a%i==0)return 0;
  }
  return 1;
}

int main(){
  int n,a,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    cnt+=so(a);
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3096
def resolve():
    a = [[int(i) for i in input().split()] for _ in range(3)]
    ans = 'No'
    n = int(input())
    for _ in range(n):
        b = int(input())
        for i in range(3):
            for j in range(3):
                if b == a[i][j]:
                    a[i][j] = 0

    for i in range(3):
        if sum(a[i]) == 0 or sum([a[0][i], a[1][i], a[2][i]]) == 0:
            ans = 'Yes'
        elif sum([a[0][0], a[1][1], a[2][2]]) == 0 or sum([a[0][2], a[1][1], a[2][0]]) == 0:
            ans = 'Yes'
    print(ans)

resolve()

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)


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

  ll n;
  cin >> n;
  vvll c(10,vll(10,0));
  
  rep(i,1,n+1){
   string s=to_string(i);
    c[int(s[0]-'0')][int(s[s.length()-1]-'0')]++;
  }
  
  ll res=0;
  rep(i,1,10){
   rep(j,1,10) res+=(c[i][j]*c[j][i])%mod,res%=mod; 
  }
  cout << res << endl;
}


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

signed main(){
  

  P a[100000];
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++)
    cin>>a[i].second>>a[i].first;

  sort(a,a+n);
  reverse(a,a+n);

  priority_queue<P,vector<P>,greater<P> > Q1;
  priority_queue<P> Q2;

  int sm=0,cnt[100001]={},sh=0;
  for(int i=0;i<k;i++){
    sm+=a[i].first;
    if(cnt[a[i].second]==0)sh++;
    cnt[a[i].second]++;
    Q1.push(a[i]);
  }

  
  for(int i=k;i<n;i++){
    Q2.push(a[i]);
  }

  int ans=sm+sh*sh;

  while(!Q1.empty()&&!Q2.empty()){
    while(!Q1.empty()&&cnt[Q1.top().second]<=1)Q1.pop();
    while(!Q2.empty()&&cnt[Q2.top().second])Q2.pop();
    if(Q1.empty()||Q2.empty())break;
    P x=Q1.top(); 
    P y=Q2.top(); 
    Q1.pop();
    Q2.pop();
    sm=sm-x.first+y.first;
    cnt[x.second]--,cnt[y.second]++;
    sh++;
    ans=max(ans,sm+sh*sh);
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 5236
n, k = map(int, input().split())
mod = 10**9+7

def cmb1(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1, k+1):
    ans = cmb1(n-k+1, i, mod)*cmb1(k-1, i-1, mod)
    ans %= mod
    print(ans)


Measured memory_bytes: 58224
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 100002

typedef struct{
    int X;
    int L;
    int end;
} robo;
int compare_int(const void *a,const void *b){
    return ((robo *)a)->end - ((robo *)b)->end;
}
int main(){
    robo robot[MAX];
    int N;
    scanf("%d",&N);
    int X[MAX],L[MAX];
    int end[MAX];
    for(int i=0;i<N;i++){
        scanf("%d %d",&robot[i].X,&robot[i].L);
        robot[i].end = robot[i].X + robot[i].L;
    }
    qsort(robot,N,sizeof(robo),compare_int);
    int ans=1,tmp=robot[0].X + robot[0].L;
    for(int i=0;i<N;i++){
        if(tmp <= robot[i].X - robot[i].L){
            tmp = robot[i].X + robot[i].L;
            ans++;
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 3896
K, N = map(int, input().split())
A = list(map(int, input().split()))
#B = A + A[0]
ans = 10**20
for i in range(N):
    if i == 0:
        ans = min(ans, A[-1]-A[0], K - (A[1] - A[0]))
    elif i == N-1:
        ans = min(ans, K - (A[N-1] - A[N-2]), A[N-1] - A[0])
    else:
        ans = min(ans, K - (A[i] - A[i-1]), K - (A[i+1] - A[i]))
print(ans)


Measured memory_bytes: 77388
#include<stdio.h>
int main(void){
  int N,R,ans;
  scanf("%d %d",&N,&R);
  if(N>=10){
    ans=R;
    printf("%d\n",ans);
  }else if(N<10){
    ans=100*(10-N)+R;
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 128
S = input()
ans = 0

for i in range(2**(len(S)-1)):
    temp = S[0]
    for j in range(len(S)-1):
        #print(i, 1<<j, i&(1<<j))
        if i & (1<<j) != 0:
            temp += "+"
        temp += S[j+1]
    #print(temp)
    ans += eval(temp)
print(ans)

Measured memory_bytes: 3060
import java.util.Map.Entry;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		if(isPrime(m)){
			System.out.println(1);
			return;
		}
		
		for(long i = n; i <= m; i++){
			if(m % i == 0){
				System.out.println(m / i);
				return;
			}
		}
	}
	
	public static boolean isPrime(int m){
		int mm = m;
		for (long i = 2; i * i <= m; i++) {
			if (m % i == 0) {
				while (m % i == 0) {
					m /= i;
				}
			}
		}
		if(m == mm) return true;
		else return false;
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


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



int main(){
	int N;
	scanf("%d", &N);
	int a[N+1];
	for (int i = 0; i < N; ++i)
		scanf("%d", &a[i]);
	sort(a, a+N);
	reverse(a, a+N);
	a[N] = 0;
	int alice = 0, bob = 0;
	for (int i = 0; i <= (N - 1)/ 2; ++i){
		alice += a[i * 2];
		bob += a[i * 2 + 1];
	}
	printf("%d\n", alice - bob);
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<functional>
using namespace std;
int main(){
  int n,x,ans,aa=-1,bb=-1,cc=-1;
  cin>>n>>x;
  for(int i=0;i<=n;i++){
    for(int j=0;i+j<=n;j++){
      ans=i*10000+j*5000+(n-i-j)*1000;
      if(ans==x){
        aa=i;
        bb=j;
        cc=n-i-j;
      }
    }
  }
  cout<<aa<<" "<<bb<<" "<<cc<<endl;
}

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

using namespace std;

int dp[100006];
int arr[106];
int n;
int fun(int k){
    
    if(k==0) return 0;
    
    if(dp[k]!=-1)return dp[k];
    int ans =0;
    
    for(int i=0;i<n;i++){
        if(arr[i]<=k)ans|=(!fun(k-arr[i]));
    }
    // cout<<k<<" "<<ans<<endl;
    return dp[k]=ans;
    
}

int main(){
    
    int k;
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>arr[i];
    
    for(int i =0;i<k;i++)dp[i+1]=-1;
    
    if(fun(k)==0)cout<<"Second"<<endl;
    else cout<<"First"<<endl;
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
bool is_prime(ll n){
    if(n<=1) return false;
    if(n==2) return true;
    if(n%2==0) return false;
    for(ll i=3; i*i<=n; i+=2){
      if(n%i==0) return false;
    }
    return true;
}

int main(){
  ll x;
  cin >> x;
  
  while(is_prime(x)==false){
    x++;
  }
  
  cout << x << endl;  
  return 0;
}


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

int main() {
  int h,n;
  cin >> h >> n;
  int a[n],b[n];
  rep(i,n)cin >> a[i] >> b[i];
  int dp[n+1][11001];
  rep(i,n+1)rep(j,11000)dp[i][j+1]=1000000001;
  rep(i,n+1)dp[i][0]=0;
  rep(i,n){
    rep(j,11000){
      dp[i+1][j+1]=min(dp[i][j+1],dp[i+1][j+1]);
      if(j+1>=a[i])dp[i+1][j+1]=min(dp[i+1][j+1-a[i]]+b[i],dp[i+1][j+1]);
    }
    rep(j,11000)dp[i+1][10999-j]=min(dp[i+1][10999-j],dp[i+1][11000-j]);
  }
  cout << dp[n][h] << endl;
}


Measured memory_bytes: 43264
n = gets.to_i
as = gets.split.map(&:to_i)

max = 10 ** 5
count = Array.new(max + 2, 0)

as.each do |a|
  count[a - 1] += 1
  count[a] += 1
  count[a + 1] += 1
end

puts count.max


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

int h[1501],w[1501];
int n,m,sum,line_length,a;
int ish[1500001],isw[1500001];


int solve(int n, int m){
	for (int i=1; i<=1500000; i++){
		ish[i] = 0;
		isw[i] = 0;
	}
	sum = 0;
	
	for (int i=0; i<=n; i++){
		for (int j=i+1; j<=n; j++){
			ish[h[j]-h[i]]+=1;
		}
	}
	for (int i=0; i<=m; i++){
		for (int j=i+1; j<=m; j++){
			isw[w[j]-w[i]]+=1;
		}
	}
	
	for (int i=1; i<=1500000; i++){
		sum += ish[i] * isw[i];
	}
	
	return sum;
}


int main()  
{    
	h[0] = 0;
	w[0] = 0; 
	while(cin >> n >> m && n>0){
		for (int i=1; i<=n; i++){
			cin >> a;
			h[i] = h[i-1] + a;
		}
		for (int i=1; i<=m; i++){
			cin >> a;
			w[i] = w[i-1] + a;
		}
		cout << solve(n,m) << endl;
	}
	     
	
	return 0;  
}  

Measured memory_bytes: 14692
#include<iostream>

using namespace std;

int main(){

    int q;
    cin>> q;
    long L=0, R=0;
    for(int i=0; i<q; i++){
        int p, n;
        char c;
        cin>> p>> c>> n;

        if(c=='(') L+=n;
        else R+=n;

        if(L==R) cout<< "Yes"<< endl;
        else cout<< "No"<< endl;
    }
    
    return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
const double PI = acos(-1);
typedef long long ll;

int main(void){
    string S;cin>>S;
    V<string> w={"Sunny","Cloudy","Rainy","Sunny","Cloudy","Rainy"};

    REP(i,6){
        if(w[i]==S){
            cout<<w[i+1]<<endl;
            return 0;
        }
    }
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int array[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin >> n;
  cout << array[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
function main(input) {
  input=input.trim();
  const x = parseInt(input.split("\n")[0], 10);
  var arr=[]
  for(var i=0; i<32; i++){
    arr.push((i+1)*(i+1))
  }
  for(var i=0; i<10; i++){
    arr.push((i+1)*(i+1)*(i+1))
  }
  for(var i=0; i<5; i++){
    arr.push((i+1)*(i+1)*(i+1)*(i+1))
  }
  arr.push(32,243,64,729,128,256,512)
  arr.sort(function(a,b){
    if( a < b ) return -1;
    if( a > b ) return 1;
    return 0;
  });
  for(var i=0; i<arr.length; i++){
    if(arr[i]<=x){
      ans=arr[i]
    }else{
      break
    }
  }
  console.log(ans);

}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        long[][] ans = new long[n][8];
        List<Cake> xlist = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            Cake c = new Cake();
            c.x = sc.nextLong();
            c.y = sc.nextLong();
            c.z = sc.nextLong();
            xlist.add(c);
        }
        for (int i = 0; i < n; i++) {
            ans[i][0] = xlist.get(i).x + xlist.get(i).y + xlist.get(i).z;
            ans[i][1] = -xlist.get(i).x + xlist.get(i).y + xlist.get(i).z;
            ans[i][2] = xlist.get(i).x - xlist.get(i).y + xlist.get(i).z;
            ans[i][3] = -xlist.get(i).x - xlist.get(i).y + xlist.get(i).z;
            ans[i][4] = xlist.get(i).x + xlist.get(i).y - xlist.get(i).z;
            ans[i][5] = -xlist.get(i).x + xlist.get(i).y - xlist.get(i).z;
            ans[i][6] = xlist.get(i).x - xlist.get(i).y - xlist.get(i).z;
            ans[i][7] = -xlist.get(i).x - xlist.get(i).y - xlist.get(i).z;
        }
        long[] A = new long[8];
        Arrays.sort(ans, (a, b) -> Long.compare(a[0], b[0]));
        for (int i = 0; i < m; i++) {
            A[0] += ans[n - 1 - i][0];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[1], b[1]));
        for (int i = 0; i < m; i++) {
            A[1] += ans[n - 1 - i][1];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[2], b[2]));
        for (int i = 0; i < m; i++) {
            A[2] += ans[n - 1 - i][2];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[3], b[3]));
        for (int i = 0; i < m; i++) {
            A[3] += ans[n - 1 - i][3];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[4], b[4]));
        for (int i = 0; i < m; i++) {
            A[4] += ans[n - 1 - i][4];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[5], b[5]));
        for (int i = 0; i < m; i++) {
            A[5] += ans[n - 1 - i][5];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[6], b[6]));
        for (int i = 0; i < m; i++) {
            A[6] += ans[n - 1 - i][6];
        }
        Arrays.sort(ans, (a, b) -> Long.compare(a[7], b[7]));
        for (int i = 0; i < m; i++) {
            A[7] += ans[n - 1 - i][7];
        }

        Arrays.sort(A);
        System.out.println(A[7]);
    }

    static class Cake {
        long x;
        long y;
        long z;
    }
}


Measured memory_bytes: 30072
#include<bits/stdc++.h>
using namespace std;
const int m = 2019;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  reverse(s.begin(), s.end());
  vector<int> cnt(m);
  cnt[0] = 1;
  int x = 1; // exp modint
  int a = 0; // sum(10^0-10^i) modint
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    a = (a + (s[i] - '0') * x) % m;
    cnt[a]++;
    x = x * 10 % m;
  }
  for (int i = 0; i < m; i++) {
    ans += cnt[i] * (cnt[i] - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3676
// 0002.c
#include<stdio.h>
int main(void)
{
  int a,b,i,n;
  while(scanf("%d %d",&a,&b)!=EOF){
    a=a+b;
    n=1;
    a=a/10;
    while(a>0){
      n++;
      a=a/10;
    }
   printf("%d\n",n);
  }
  return 0;
}

Measured memory_bytes: 1760
import sys
for x1, y1, x2, y2, x3, y3, x4, y4 in (map(lambda x: int(float(x)*100000), l.split()) for l in sys.stdin.readlines()):
    if (x2-x1)*(x4-x3) + (y4-y3)*(y2-y1) == 0:
        print("YES")
    else:
        print("NO")


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

// 最小の分割数
unordered_map<int,int> dp;
const int INF=INT_MAX/2;

int main(){
  string S; cin>>S;
  int n=S.length();
  int a=0;
  dp[0]=0;
  rep(i,n){
    a^=(1<<(S[i]-'a'));
    if(!dp.count(a)) dp[a]=INF;
    rep(j,26){
      int x=a^(1<<j);
      if(dp.count(x)) dp[a]=min(dp[a],dp[x]+1);
    }
  }
  cout<<max(1,dp[a])<<endl;
  return 0;
}


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

int n,x;
int a[300000];
map<int,bool> mp;

main()
{
	scanf("%d %d",&n,&x);
	if(x==1||x==2*n-1)
	{
		printf("No");
		return 0;
	}
	printf("Yes\n");
	if(n==2)
	{
		printf("1\n2\n3");
		return 0;
	}
	if(2*n-1-1>x)
	{
		a[n]=x;
		mp[x]=1;
		a[n-1]=x+2;
		mp[x+2]=1;
		a[n+1]=x-1;
		mp[x-1]=1;
		a[n+2]=x+1;
		mp[x+1]=1;
		int nw=1;
		for(int i=1;i<=2*n-1;i++)
		{
			if(a[i]==0)
			{
				while(mp[nw]==1)
				{
					nw++;
				}
				printf("%d\n",nw);
				mp[nw]=1;
			}
			else
			{
				printf("%d\n",a[i]);
			}
		}
	}
	else
	{
		a[n]=x;
		mp[x]=1;
		a[n-1]=x-1;
		mp[x-1]=1;
		a[n+1]=x+1;
		mp[x+1]=1;
		a[n+2]=x-2;
		mp[x-2]=1;
		int nw=1;
		for(int i=1;i<=2*n-1;i++)
		{
			if(a[i]==0)
			{
				while(mp[nw]==1)
				{
					nw++;
				}
				printf("%d\n",nw);
				mp[nw]=1;
			}
			else
			{
				printf("%d\n",a[i]);
			}
		}
	}
}


Measured memory_bytes: 10880
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>

#define INF 1000

using namespace std;

int main(){
	
	
	while(1){
		int n, m;
		int chmin = INF;
		int s1min, s2min;
		
		cin >> n >> m;
		if(!n && !m)
			break;
		
		vector<int> s1(n), s2(m);
		int sum1 = 0, sum2 = 0;
		for(int i = 0; i < n; i++){
			cin >> s1[i];
			sum1 += s1[i];
		}
		for(int i = 0; i < m; i++){
			cin >> s2[i];
			sum2 += s2[i];
		}
		
		sort(s1.begin(), s1.end());
		sort(s2.begin(), s2.end());
		
		for(int i = 0; i < n; i++){
			if(i && s1[i] == s1[i - 1])
				continue;
			
			for(int j = 0; j < m; j++){
				if(j && s2[j] == s2[j - 1])
					continue;
				
				int sum1tmp, sum2tmp;
				sum1tmp = sum1 - s1[i] + s2[j];
				sum2tmp = sum2 - s2[j] + s1[i];
				
				if(sum1tmp == sum2tmp){
					if(chmin > s1[i] + s2[j]){
						chmin = s1[i] + s2[j];
						s1min = s1[i];
						s2min = s2[j];
					}
				}
			}
		}
		if(chmin == INF)
			cout << -1 << endl;
		else
			cout << s1min << " " << s2min << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
using System;

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            bool flg = false;
            int cnt = 0;
            for (int i = 0; i < 3; i++)
            {
                if (flg && a.Substring(i, 1) == "S")
                {
                    break;
                }
                if (a.Substring(i, 1) == "R")
                {
                    flg = true;
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    const i64 mod = 1'000'000'007;

    i64 H,W;
    cin >> H >> W;

    vector<string> a(H);
    rep(i,0,H) cin >> a[i];

    vector<vector<i64>> dp(H,vector<i64>(W));
    dp[0][0]=1;
    rep(i,0,H){
        rep(j,0,W){
            if((i==0 and j==0) or a[i][j]=='#') continue;
            if(i-1>=0){
                dp[i][j]+=dp[i-1][j];
                dp[i][j]%=mod;
            }
            if(j-1>=0){
                dp[i][j]+=dp[i][j-1];
                dp[i][j]%=mod;
            }
        }
    }

    cout << dp[H-1][W-1] << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		
		if(A.length() > B.length()) {
			System.out.println("GREATER");
		} else if(A.length() < B.length()) {
			System.out.println("LESS");
		} else {
			for(int i = 0; i < A.length(); i++) {
				if(A.charAt(i) > B.charAt(i)) {
					System.out.println("GREATER");
					return;
				} else if(A.charAt(i) < B.charAt(i)) {
					System.out.println("LESS");
					return;
				} 
			}
			System.out.println("EQUAL");
		}
		
		
	}
}


Measured memory_bytes: 23764
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
 
int main(){
	int a;scanf("%d",&a);
	int L=a/100;
	int R=a%100;
	if(1<=L&&L<=12){
		if(1<=R&&R<=12)printf("AMBIGUOUS\n");
		else printf("MMYY\n");
	}else{
		if(1<=R&&R<=12)printf("YYMM\n");
		else printf("NA\n");
	}
}

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

int main() {
    set<int> A = {1,3,5,7,8,10,12};
    set<int> B = {4,6,9,11};
    set<int> C = {2};

    int x,y; cin >> x >> y;
    if(A.count(x) && A.count(y) || B.count(x) && B.count(y) || C.count(x) && C.count(y)){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
vi to[202020];
// [0]~[99999]:person
// [100000]~[200000]:language
int L=1e5;
int read[202020];


signed main(){
  int n,m;
  cin>>n>>m;
  rep(i,n){
    int k;
    cin>>k;
    rep(j,k){
      int l;
      cin>>l;
      l--;
      to[i].pb(L+l);
      to[L+l].pb(i);
    }
  }
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int p=q.front();
    q.pop();
    read[p]=true;
    for(auto v:to[p]){
      if(!read[v]) q.push(v);
    }
  }
  rep(i,n){
    if(!read[i]){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 12160
#include<stdio.h>

void writeSharp(int n) {
	int i;
	for(i = 0; i < n; i++) {
		printf("#");
	}
	printf("\n");
}

int main () {
	int rooms[4][3][10];
	int b , f , r , v;
	int n , i , s , k;

	for(i = 0; i < 4; i++) {
		for(s = 0; s < 3; s++) {
			for(k = 0; k < 10; k++) {
				rooms[i][s][k] = 0;
			}
		}
	}

	scanf("%d" , &n);
	for(i = 0; i < n; i++) {
		scanf("%d %d %d %d" , &b , &f , &r , &v);
		rooms[b - 1][f - 1][r - 1] += v;
	}

	for(i = 0; i < 4; i++) {
		for(s = 0; s < 3; s++) {
			for(k = 0; k < 10; k++) {
				printf(" %d" , rooms[i][s][k]);
			}
			printf("\n");
		}
		if (i < 3) writeSharp(20);
	}

	return 0;
}

Measured memory_bytes: 600
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#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;}

void solve();

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

void solve(){
    ll N;cin>>N;
    vl a(N);rep(i,N)cin>>a[i];

    ll money=1000;
    ll stock=0;
    for(int i=0;i<N-1;i++){
        if(a[i]<a[i+1]){
            stock+=money/a[i];
            money%=a[i];
        }else{
            money+=stock*a[i];
            stock=0;
        }
    }
    money+=stock*a[N-1];
    cout<<money<<endl;
}


Measured memory_bytes: 3596
// https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d

#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

using ll = long long;

int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<vector<int>> num(10);
  int ans = 0;
  for(int i = 0; i < n; i++){
    num[s[i] - '0'].push_back(i);
  }
  for(int i = 0; i < 10; i++){
    if(!num[i].size()) continue;
    for(int j = 0; j < 10; j++){
      if(!num[j].size()) continue;
      for(int k = 0; k < 10; k++){
        if(!num[k].size()) continue;
        for(int l = 0; l < num[k].size(); l++){
          if((*num[i].begin()) < num[k][l] && num[k][l] < (*num[j].rbegin())){
            ans++;
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>

int main() {
  int num;
  std::cin >> num;

  int max_count = 0;
  int ans = 1;
  for (int i = 1; i <= num; ++i) {
    int count = 0;
    int a = i;
    while (a % 2 == 0 && a != 0) {
      a /= 2;
      ++count;
    }
    if (count > max_count) {
      max_count = count;
      ans = i;
    }
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e6+10, M = 1e6+10;

int main() {
	int d, t, s;
	cin>>d>>t>>s;
	if(t * s >= d) {
		cout<<"Yes\n";
	} else {
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 3584
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};



//!!!問題をちゃんと読む!!!
//!!!問題をちゃんと読め!!!
//!!!問題は読みましたか？!!!

int ans[1000000];
bool visited[1000000];
Graph G(100001);

void dfs(int node, int weight, int color) {
	if (visited[node]) return;
	if (ans[node] != -1) return;

	visited[node] = true;
	if (weight % 2 == 0) {
		ans[node] = 1;
	}
	else {
		ans[node] = 0;
	}

	for (Edge e : G[node]) {
		if (visited[e.dst]) {
			continue;
		}

		dfs(e.dst, weight + e.weight, color);
	}
}

signed main() {
	uf_tree uf(1000000);
	int N, M;
	cin >> N >> M;
	rep(i, M) {
		int x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		uf.unite(x, y);
	}
	map<int, int> ma;
	rep(i, N) {
		ma[uf.find(i)]++;
	}
	cout << ma.size() << "\n";


	return 0;
}

Measured memory_bytes: 16640
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3","unroll-loops")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,m,k,a,b,c,ans,w,h;

multiset<int> f,s,t;

main(){
	cin>>n>>a>>b;
	int p;
	rep(i,n){
		cin>>p;
		if(p<=a)f.ins(p);
		else if(p>b)t.ins(p);
		else s.ins(p);
	}
	dump(min({f.size(),s.size(),t.size()}));
}


Measured memory_bytes: 256
/*
    Those who cannot remember the past are condemned to repeat it.
                                            - Dynamic Programming
    
    I never lose, I either win or I learn.
                - Competitive Programming

*/

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.nio.charset.IllegalCharsetNameException;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);

        st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        char[][] c = new char[n][];
        for(int i=0 ; i<n ; i++) {
            c[i] = br.readLine().toCharArray();
        }

        int[][] dp = new int[n][m];

        for(int i=0 ; i<n ; i++) {
            if(c[i][0] == '#') break;
            dp[i][0] = 1;
        }

        for(int j=0 ; j<m ; j++) {
            if(c[0][j] == '#') break;
            dp[0][j] = 1;
        }

        for(int i=1 ; i<n ; i++) {
            for(int j=1 ; j<m ; j++) {
                if(c[i][j] != '#') {
                    dp[i][j] = dp[i-1][j] + dp[i][j-1];
                    dp[i][j] %= 1000000007;
                }
            }
        }

        pw.println(dp[n-1][m-1]);
        
        
        
        
        
        
        
        pw.flush();
        pw.close();
    }
}


Measured memory_bytes: 32132
using System;
using System.Collections.Generic;

namespace abc165
{
    class Program
    {
        static void Main()
        {
            var nmq = Console.ReadLine().Split(' ');
            var a = long.Parse(nmq[0]);
            var b = long.Parse(nmq[1]);
            var n = long.Parse(nmq[2]);
            if (n >= b)
            {
                Console.WriteLine((a * (b - 1)) / b);
            }
            else
            {
                Console.WriteLine((a * n) / b);
            }
        }
    }
}


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

int main(){
  int n,m;
  cin >>n >>m;
  vector<int> cnt(m,0);
  rep(i,n){
    int k;
    cin >>k;
    rep(j,k){
      int a;
      cin >>a;
      a--;
      cnt[a]++;
    }
  }
  int ans = 0;
  rep(i,m){
    if(cnt[i] == n) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    int Q, T, F;
    string addS;
    string head = "", tail = "";
    cin >> S >> Q;
    int rev = 0;
    for (int i = 0; i < Q; i++) {
        cin >> T;
        if (T == 1) rev = (rev + 1) % 2;
        else {
            cin >> F >> addS;
            F--;
            F = (F + rev) % 2;
            if (F == 0) head += addS;
            else tail += addS;
        }
    }
    reverse(head.begin(), head.end());
    S = head + S + tail;
    if (rev) reverse(S.begin(), S.end());
    cout << S << '\n';
}


Measured memory_bytes: 1348
n = gets.to_i

evidence = Array.new(n) {[]}

n.times do |i|
  a = gets.to_i
  a.times do
    x,y = gets.split.map(&:to_i)
    evidence[i].push [x,y]
  end
end

max = 0

(0..(2**n-1)).each do |i|
  binary = ("%0#{n}b" % i).chars

  ng = false
  binary.each.with_index do |b,i|
    next if b == '0'
    if evidence[i].any? { |x,y|
      binary[x-1] != y.to_s
    }
      ng = true
      break
    end
  end
  next if ng

  count = binary.count{|b| b == '1'}
  max = count if count > max
end

puts max

Measured memory_bytes: 1916
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

int n, t;
int a[MAXN];

int input() {
	if (scanf("%d %d", &n, &t) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%d", &a[i]);
	return 1;
}

void init() {
}

int solve() {
	set<int> s;
	s.insert(a[0]);
	int p=INT_MIN, r=0;
	for (int i=1; i<n; i++) {
		int x = a[i] - *s.begin();
		if (x>p) {
			p = x;
			r = 1;
		}
		else if (x==p) {
			r++;
		}
		s.insert(a[i]);
	}
	return r;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 5376
using System;
using System.Collections.Generic;

class IDONTKNOWCSHARP
{
    public static void Main()
    {
        string[] values = Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

        for (int i = 0; i < 5; i++)
        {
            if (values[i] == "0")
            {
                Console.WriteLine(i + 1);
                return;
            }

        }
    }


}

Measured memory_bytes: 25936
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<int> x(N);
  int res = 0;
  for(int i = 0; i < N; i++){
    cin >> x[i];
    res += x[i];
  }
  int ans = round((double)res/N);
  ll tmp = 0;
  for(int i = 0; i < N; i++){
    tmp += (ans - x[i]) * (ans - x[i]);
  }
  cout << tmp << endl;
    
}


Measured memory_bytes: 256