akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

bool isPrime(ll num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    for (ll i = 3; i*i <= num; i += 2) {
        if (num % i == 0)
          return false;
        }
    return true;
}

int main() {
    ll n;
    cin >> n;
    map<ll, ll> mp;
    ll m = n;
    for (ll i = 2; i*i <= m; i++) {
        while (m % i == 0) {
            mp[i]++;
            m /= i;
        }
    }
    if (isPrime(m))
        mp[m]++;
    
    if (n != 1 && mp.size() == 0) {
        cout << 1 << endl;
        return 0;
    }
    int ans = 0;
    for (auto p : mp) {
        int t = p.second;
        for (int k = 1; t - k >= 0; k++) {
            t -= k;
            ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<ll> vec(n);
    rep(i,n) cin>>vec[i];
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());

    priority_queue<ll> que;
    que.push(vec[0]);
    ll ans =0;
    
    REP(i,n-1){
        ll t = que.top();que.pop();
        ans+=t;
        que.push(vec[i]);
        que.push(vec[i]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6928
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
//    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
//    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

int n, m;
const int MAXN = 1e5 + 1;

vector<int> g[MAXN];
bool used[MAXN];

void dfs(int v) {
    used[v] = 1;
    for (auto u : g[v]) {
        if (!used[u]) {
            dfs(u);
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    cin >> n >> m;
    int u, v;
    for (int i = 0; i < m; i++) {
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
        cin >> v;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            ans++;
            dfs(i);
        }
    }
    cout << ans;
}
/*
3 2
*/


Measured memory_bytes: 8960
/* 
 * Author: pawanmsr
 */

// #include <iostream>
// #include <iomanip>
// #include <string>
// #include <vector>
// #include <algorithm>
// #include <queue>
// #include <deque>
// #include <bitset>
// #include <iterator>
// #include <list>
// #include <stack>
// #include <map>
// #include <set>
// #include <functional>
// #include <numeric>
// #include <utility>
// #include <limits>
// #include <fstream>
// #include <cstring>

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //
const int a[] = {
    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 k;

// Functions //


// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    
    /* code */
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 1e6+3; //AREGLAAAAAAAAR!!!!
vector<int> G[MAXN];

int bfs(int raiz, int n){
    queue<int> cola;
    vector <int> d(n+2,-1);
    cola.push(raiz);
    d[raiz]=0;
    while(!cola.empty()){
        int t=cola.front(); cola.pop();
        for(int i=0; i<G[t].size(); i++){
            if(d[G[t][i]]==-1){
                d[G[t][i]]=d[t]+1;
                cola.push(G[t][i]);
            }
        }

    }
    return(d[n]);
}


int main(){
	int n,m;
	rii(n,m);
	FOR(i,0,m){
		int a,b;
		rii(a,b);
		G[a].pb(b);
		G[b].pb(a);
	}
	int ans=bfs(1,n);
	if(ans==-1 || ans>2) printf("IMPOSSIBLE\n");
	else printf("POSSIBLE\n");
}


Measured memory_bytes: 31856
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct UnionFind{
    vector<int> d;
    UnionFind(int n): d(n, -1) {}
    int find(int x){
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        
        d[x] += d[y];
        d[y] = x;
        return false;
    }
    bool same(int x, int y){
        x = find(x);
        y = find(y);
        
        if (x == y) return true;
        return false;
    }
    int size(int x){
        return -d[find(x)];
    } 
};

int main(void){
    int N, M, cnt;
    cin >> N >> M;
    UnionFind uf(N);
    
    for (int i = 0; i < M; i++){
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        
        if (!uf.same(A, B)){
            uf.unite(A, B);
        }
    }
    
    cnt = 0;
    for (int i = 0; i < N; i++){
        if (uf.find(i) == i) cnt++;
    }
    
    cout << cnt - 1 << endl;
    
    return 0;
}


Measured memory_bytes: 3700
#include <stdio.h>

int main(void)
{
	int s, i, sum;
	
	sum = 0;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &s);
		
		sum += s;
	}
	
	printf("%d\n", sum);
	
	return (0);
}

Measured memory_bytes: 600
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  map<int,int> cnt;
  for(int x:a) ++cnt[x];
  int re=0,two=0;
  for(pii p:cnt){
    if(p.Y%2) ++re;
    else ++two;
  }
  re+=two/2*2;
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl v(n-1);
	rep(i,n-1)cin>>v[i];
	vl ans(n);
	rep(i,n-1){
		ans[v[i]-1]++;
	}
	rep(i,n)puta(ans[i]);
}


Measured memory_bytes: 6364
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,res=0;
    cin>>n;
    ll a[n],i,sum=0,diff;
    for(i=0;i<n;i++)
    {
         cin>>a[i];
         sum+=a[i];
    }
   sum=(round)((double)sum/n);
   for(i=0;i<n;i++)
   {
       diff=labs(a[i]-sum);
       res+=fastpow(diff,2);
   }
   cout<<res;
}



Measured memory_bytes: 3576
s=input()
l=len(s)
a=[]
for i in range(l):
  n=len(a)
  if s[i]=='0':
    a.append(0)
  elif s[i]=='1':
    a.append(1)
  elif s[i]=='B':
    if a!=[]:
      del a[n-1]
    
for i in range(len(a)):
  print(a[i],end="")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define bpc __builtin_popcount
#define MOD (ll)(1e9+7)
#define INF (1e18)
#define EPS (1e-6)
#define NATHANLEE_IS_EVIL_AND_ELECTRIC true
#define int ll
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<"\n";}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(!NATHANLEE_IS_EVIL_AND_ELECTRIC);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

#define LO(x) (x&(-x))
struct BIT{
	int a[200020];
	int n;
	void init(int _n){
		n=_n;
		memset(a,0,sizeof(a));
	}
	void mod(int i,int x){
		while(i<=n){
			a[i]=max(a[i],x);
			i+=LO(i);
		}
	}
	int ask(int i){
		int ans=0;
		while(i>0){
			ans=max(ans,a[i]);
			i-=LO(i);
		}
		return ans;
	}
}bit;

int h[200020];
int b[200020];

int32_t main() {
	INIT();
	//code...
	int n; cin>>n;
	bit.init(n);
	For(i,0,n-1) cin>>h[i];
	For(i,0,n-1) cin>>b[i];
	int ans=0;
	For(i,0,n-1){
		b[i]+=bit.ask(h[i]-1);
		ans=max(ans,b[i]);
		bit.mod(h[i],b[i]);
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 8284
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll grundy(const ll A, const ll K)
{
    const ll n = A / K;
    const ll m = A % K;
    const ll l = (m + n) / (n + 1);
    return A == n * K ? n : grundy(A - l * (n + 1), K);
}
int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll A, K;
        cin >> A >> K;
        ans = ans ^ grundy(A, K);
    }
    cout << (ans == 0 ? "Aoki" : "Takahashi") << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

const long long inf = 1e18;

struct edge {
	int a, b;
	long long cost;
};

signed main() {
	long long n, m, p; cin >> n >> m >> p;

	vector<edge> e(m);
	REP(i, 0, m) {
		long long a, b, c; cin >> a >> b >> c;
		e[i].a = a - 1;
		e[i].b = b - 1;
		e[i].cost = - c + p;
	}

	vector<long long> d(n, inf);
	d[0] = 0;
	bool x = 0;
	for (int i = 0; i < 2 * n; ++i) {
		for (int j = 0; j < m; ++j)
			if (d[e[j].a] < inf)
				if (d[e[j].b] > d[e[j].a] + e[j].cost) {
					d[e[j].b] = d[e[j].a] + e[j].cost;
					if (i >= n && e[j].b == n - 1) x = 1;
				}
	}

	if (x || d[n - 1] == inf) cout <<  -1;
	else cout << max(0LL, -d[n - 1]);
}


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

using namespace std;

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

ll N, M, Q, A, B, C, arr[200005], lgcd[200005], rgcd[200005];
string s, p;

ll gcd(ll x, ll y){
	if (!x || !y) return x+y;
	return gcd(y,x%y);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; ++i){
		cin >> arr[i];
		lgcd[i] = gcd(arr[i],lgcd[i-1]);
	}
	for (int i = N; i >= 1; --i){
		rgcd[i] = gcd(arr[i],rgcd[i+1]);
	}
	for (int i = 1; i <= N; ++i){
		A = max(A,gcd(lgcd[i-1],rgcd[i+1]));
	}
	cout << A << '\n';
}

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

using namespace std;

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

int dp[N][N];
int acc[2][N];
int n;

int a[N];

int main() {
  scanf("%d %d %d", &n, a, a+1);
  for (int i = 0; i < n; i++)
    scanf("%d", a+2+i);
  n += 2;
  for (int i = 0; i <= n; i++)
    acc[0][i] = inf;
  for (int i = 0; i <= n; i++)
    acc[1][i] = 0;
  for (int j = n-1; j >= 0; j--) {
    for (int i = n-2; i > j; i--) {
      // minimize
      dp[i][j] = min(abs(a[i]-a[n-1]), acc[0][i]);
      acc[1][j] = max(dp[i][j], acc[1][j]);
      // maximize
      dp[j][i] = max(abs(a[i]-a[n-1]), acc[1][i]);
      acc[0][j] = min(dp[j][i], acc[0][j]);
    }
  }
  printf("%d\n", dp[0][1]);
  return 0;
}

Measured memory_bytes: 16640
n,a,b,c=map(int,input().split())
l=sorted([int(input()) for i in range(n)])
def kad(w,x,y,z):
    if w==n:
        if min(x,y,z)>0:
            return abs(x-a)+abs(y-b)+abs(z-c)-30
        else:
            return 10e4
        
    c0=kad(w+1,x,y,z)
    c1=kad(w+1,x+l[w],y,z)+10
    c2=kad(w+1,x,y+l[w],z)+10
    c3=kad(w+1,x,y,z+l[w])+10
    return min(c0,c1,c2,c3)

print(kad(0,0,0,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std; 
int main(){
	int N, K; 
	cin >> N >> K; 
	long long int A[1010] = {};
	long long int S[1010] = {}; 
	for(int i = 1; i <= N; i++){
		cin >> A[i]; 
		S[i] = S[i-1] + A[i]; 
	}
	vector<long long int> X; 
	for(int i = 1; i <= N; i++){
		for(int j = i; j <= N; j++){
			X.push_back(S[j] - S[i-1]); 
		}
	}
	int M = X.size(); 
	long long int ans = 0; 
	for(int d = 43; d >= 0; d--){
		int count = 0; 
		for(int i = 0; i < M; i++){
			if((X[i] >> d) & 1) count ++; 
		}
		if(count < K) continue; 
		ans += (long long) 1 << d; 
		for(int i = 0; i < M; i++){
			if(((X[i] >> d) & 1) == 0) X[i] = 0; 
		}
	}
	cout << ans << endl; 
}

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

int main() {
  int K;
  cin>>K;
  vector<int> vec = { 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};
  cout<<vec.at(K-1)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int r;
  cin >> r;
  cout << r*r << endl;
}


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

int main() {
    double n, d;
    scanf("%lf%lf", &n, &d);
    int count = 0;
    rep(i, n) {
        double x, y;
        scanf("%lf%lf", &x, &y);
        double distance = sqrt(x * x + y * y);
        if (distance <= d) count++;
    }
    printf("%d\n", count);
}

Measured memory_bytes: 3868
#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 incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, 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 FI first
#define SE second
#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); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#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)

// ---- ----

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	inc(i, n) { cin >> a[i]; }
	inc(i, n) { cin >> b[i]; }
	
	int INF = 1e9, ans = INF;
	inc(B, 1 << n) {
		vector<pair<int, int>> v, x, y, w;
		inc(i, n) { v.EB((bit(B, i) == 0 ? a[i] : b[i]), i); }
		
		inc(i, n) { (bit(B, i) == i % 2 ? x : y).PB(v[i]); }
		if_not(SI(x) == SI(y) || SI(x) == SI(y) + 1) { continue; }
		
		sort(ALL(x));
		sort(ALL(y));
		inc(i, SI(x)) {
			w.PB(x[i]);
			if(i < SI(y)) { w.PB(y[i]); }
		}
		bool f = true;
		inc(i, n - 1) { f &= (w[i].FI <= w[i + 1].FI); }
		if(! f) { continue; }
		
		int t = 0;
		inc(i, n) {
		inc(j, n) {
			if(i < j && w[i].SE > w[j].SE) { t++; }
		}
		}
		setmin(ans, t);
	}
	
	if(ans == INF) { ans = -1; }
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define ll long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 1000000007
        #define inf 2e18
 
        int main() {

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
            
        ll n,k;
        cin>>n>>k;
        if(n<10)
            cout<<k+100*(10-n)<<"\n";
        else
            cout<<k<<"\n";
 
 
        return 0;
        }

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l[] = new int[n];
		for(int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		int ans = 0;
		
		Arrays.sort(l);
//		for(int i = 0; i < n; i++) {
//			System.out.print(l[i]);
//		}
		for(int i = 0; i < n ; i++) {
			for(int j = i + 1; j < n; j++) {
				for(int k = j + 1; k < n; k++) {
					if(l[i] + l[j] > l[k]) {
						ans++;
					} else break;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 28708
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//
        int X, Y;
        cin >> X >> Y;

        cout << X+Y/2 << endl;

        return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=55,maxm=2500;
struct edge{
	int link,next;
}e[maxm];
int head[maxn],tot,n,m;
inline void insert(int u,int v){
	e[++tot]=(edge){v,head[u]}; head[u]=tot;
}
inline void ins(int u,int v){
	insert(u,v); insert(v,u);
}
inline void init(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		ins(u,v);
	}
}
bool instack[maxn];
int ans,tim,cnt,dfn[maxn],stack[maxn],top,low[maxn];
inline void pop(){
	instack[stack[top--]]=0;
}
void tarjan(int u,int fa){
	dfn[u]=low[u]=++tim; stack[++top]=u; instack[u]=1;
	for (int i=head[u];i;i=e[i].next){
		int v=e[i].link;
		if (v!=fa){
			if (!dfn[v]){
				tarjan(v,u);
				low[u]=min(low[u],low[v]);
			}else{
				if (instack[u]){
					low[u]=min(low[u],dfn[v]);
				}
			}
			if (low[v]>dfn[u]){
				ans++;
				while (stack[top]!=v){
					pop();
				}
				pop();
			}
		}else{
			fa=0;
		}
	}
}
inline void solve(){
	tarjan(1,0);
	printf("%d\n",ans);
}
int main(){
	init();
	solve();
	return 0;
}

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

using namespace std;

typedef long long LL;

int main() {
    int n;
    scanf("%d", &n);

    LL a1 = 1, a2 = 1;

    for (int i = 0; i < n; i++) {
        LL tt, aa;
        scanf("%lld%lld", &tt, &aa);
        LL b1 = 1, b2 = 1;
        if (tt < a1) {
            b1 = (a1+tt-1)/tt;
        }
        if (aa < a2) {
            b2 = (a2+aa-1)/aa;
        }
        a1 = tt * max(b1,b2);
        a2 = aa * max(b1,b2);
    }

    printf("%lld", a1+a2);

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=2000;

int n;
int a[MAXN];
int ret[MAXN];

bool done[MAXN];
bool e[MAXN+1][MAXN+1];

vector<int> merge(const vector<int> &a,const vector<int> &b) {
	vector<int> c(SZ(a)+SZ(b),-1);
	int ai=0,bi=0;
	while(ai<SZ(a)||bi<SZ(b)) {
		if(ai<SZ(a)&&(bi>=SZ(b)||a[ai]>b[bi])) c[ai+bi]=a[ai++]; else c[ai+bi]=b[bi++];
	}
	return c;
}

vector<int> dfs(int at) {
	done[at]=true;
	vector<int> ret;
	REP(to,n) if(!done[to]&&e[at][to]) {
		vector<int> cur=dfs(to); cur.insert(cur.begin(),a[to]);
		ret=merge(ret,cur);
	}
	return ret;
}

void solve() {
	sort(a,a+n);
	REPE(i,n) REPE(j,n) e[i][j]=i!=j&&(i==n||j==n||gcd(a[i],a[j])!=1);
	REP(i,n) done[i]=false;
	// in each connected component, any unmarked node can be chosen iff there is no connected component with a higher lowest unmarked node
	// algorithm: for each connected component, determine the lowest unmarked node. choose the highest of them. mark all nodes in that cc. unmark the adjacent nodes.
	// different connected components can be merged later -> always choose lowest unprocessed adjacent node
	
	vector<int> ret=dfs(n);
	REP(i,n) { if(i!=0) printf(" "); printf("%d",ret[i]); } puts("");
}

void run() {
	scanf("%d",&n);
	REP(i,n) scanf("%d",&a[i]);
	solve();
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 4608
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner stdin = new Scanner(System.in);
	int a = stdin.nextInt();
	int b = stdin.nextInt();
	int d = a/b;
	int r = a%b;
	double f = (double)a/(double)b;
	System.out.print(d+" "+r+" ");
	System.out.printf("%.8f %n", f);
    }
}

Measured memory_bytes: 26432
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 23 09:58:29 2019

@author: Yamazaki Kenichi
"""

N, L = map(int,input().split())

Apple = []
for i in range(N):
    Apple.append(L + i)

eat = 999
for a in Apple:
    if abs(a) < abs(eat):
        eat = a

ans = sum(Apple) - eat
print(ans)

Measured memory_bytes: 3060
// https://atcoder.jp/contests/abc053/tasks/abc053_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  string s;

  cin >> s;

  cout << (s.rfind('Z') - s.find('A') + 1) << '\n';

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    int n,j,k;
    string s,t,a;
    cin>>n;
    cin>>s>>t;
    j=0;
    //cout<<s<<t;
//    for(int i=0;i<n;i++)
//    {
//        a[j]=s[i];
//        j++;
//        a[j]=t[i];
//        j++;
//    }
   for(int i=0;i<n;i++)
   {
       cout<<s[i]<<t[i];
   }
    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    unordered_map<ll, ll> mp;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        ans += mp[i - a];
        mp[i + a]++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 18528
n = gets.chomp!.to_i
v_n = gets.chomp!.split(" ").map!(&:to_i)
c_n = gets.chomp!.split(" ").map!(&:to_i)

cost_n = v_n.zip(c_n).map{|v, c| v - c }

puts cost_n.select{|cost| cost >= 0 }.inject(0) {|sum, x| sum += x }

Measured memory_bytes: 3836
n = int(input())
a = list(map(int, input().split()))
count = 0
num = 1

for i in range(n):
    if a[i] == num:
        num += 1
        count += 1


if num == 1:
    count = -1
else:
    count = len(a) - count

print(count)
    


Measured memory_bytes: 24744
n,k = map(int,input().split())
s = input()
c = []
buf = 1
for i in range(n-1):
    if s[i]==s[i+1]:
        buf += 1
    else:
        c.append(buf)
        buf = 1
c.append(buf)
n = len(c)
l = min(n,2*k+1)
ans = buf = sum(c[:l])
ind = 0
for i in range(n-l):
    buf = buf-c[i]+c[i+l]
    if ans<buf:
        ind = i+1
        ans = buf
ans -= 1
for i in range(n):
    if ind<=i<ind+l:
        continue
    ans += c[i]-1
print(ans)

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

int main(){
  int N;
  cin >> N;
  
  vector <int> A(N);
  vector <int> B(N);
  vector <int> C(N);
  
  int i;
  
  for(i=0;i<N;i++){
    cin >> A[i];
  }
  for(i=0;i<N;i++){
    cin >> B[i];
  }
  for(i=0;i<N-1;i++){
    cin >> C[i];
  }
  
  int sum = 0;
  
  for(i=0;i<N;i++){
    sum += B[i];
  }
  
  for(i=0;i<N-1;i++){
    if(A[i] + 1 == A[i+1]) sum += C[A[i]-1];
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
def main():
    N = int(input())
    ans = 1
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return 0
    for i in range(N):
        ans *= a[i]
        if ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)
    return 0
main()


Measured memory_bytes: 21648
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll N, K;
vector<ll> H;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  H.resize(N);
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    H[i] = tmp;
  }

  sort(H.begin(), H.end(), greater<int>());
  ll ans = 0;
  for (int i = 0; i < H.size(); i++) {
    if (K > 0) {
      K--;
      continue;
    }
    ans += H[i];
  }

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


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

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define test() ll t;cin>>t;for(ll test = 1;test<=t;test++)
#define f first
#define s second
#define pb push_back
#define ins insert
#define nl cout<<"\n"
#define P 1000000007
#define N 100005
#define MOD(x) ((x%P)+P)%P
#define show(x) cout<<x<<" "
#define vec(v) loop(i,0,v.size()) show(v[i]); nl
ll dp[N][105];
int main()
{
	fastio();

	ll n,k;
	cin>>n>>k;

	ll arr[n+1];
	loop(i,0,n)
		cin>>arr[i+1];

	dp[0][0] = 1;


	loop(i,1,n+1)
	{
		ll sum = 1;
		ll mx = arr[i];

		loop(j,0,k+1)
		{
			if(j==0)
			{
				dp[j][i] = 1;
				continue;
			}

			sum += dp[j][i-1];

			if((j-mx-1)>=0)
				sum -= dp[j-mx-1][i-1];

			dp[j][i] = sum;
			dp[j][i] = MOD(dp[j][i]);
		}
	}

	cout<<dp[k][n],nl;

	//cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
	return 0;
}

Measured memory_bytes: 82304
fn solve(n: u8) -> u8 {
    let mut result = 0;
    fn f(n: u8) -> u8 {
        let mut result = 1;
        for x in 1..=(n / 2) {
            if n % x == 0 { result += 1 }
        }

        result
    }
    for x in (1..=n).step_by(2) {
        if f(x) == 8 { result += 1 }
    }
    result
}

fn main() {
    let n = read_1();

    println!("{}", solve(n));
}

fn read_1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 2164
S = input()
sb = S[:(len(S) - 1) // 2]
sc = S[(len(S) + 3) //2 -1:]
a = S == "".join(reversed(S))
b = sb == "".join(reversed(sb))
c = sc == "".join(reversed(sc))
print("Yes" if a and b and c == True else "No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
using namespace std;

int X, Y, Z;
struct Coin {
    long long a, b;
};

int main()
{
    cin.sync_with_stdio(false);
    cin >> X >> Y >> Z;
    int n = X + Y + Z;
    long long temp = 0;
    long long base = 0;
    vector<Coin> coins(n);
    for (auto& c : coins) {
        cin >> c.a >> c.b >> temp;
        c.a -= temp;
        c.b -= temp;
        base += temp;
    }

    sort(coins.begin(), coins.end(), [](const Coin& a, const Coin& b) {
        return (a.a - a.b) < (b.a - b.b);
    });

    // for (auto& c : coins) {
    //     cout << c.a << ", " << c.b << ", " << (c.a - c.b) << endl;
    // }

    priority_queue<int, vector<int>, std::greater<int>> queue;
    vector<long long> sum_silver(Z+1, 0);
    long long sum = 0;
    for (int i = 0; i < Y; ++i) {
        sum += coins[i].b;
        queue.push(coins[i].b);
    }
    sum_silver[0] = sum;
    for (int k = Y; k < Y+Z; ++k) {
        auto& c = coins[k];
        if (c.b > queue.top())
        {
            sum += c.b - queue.top();
            // cout << "bpoppush: " << queue.top() << ", " << c.b << endl;
            queue.pop();
            queue.push(c.b);
        }
        sum_silver[k-Y+1] = sum;
    }

    std::reverse(coins.begin(), coins.end());

    // queue = priority_queue<int>();
    while (!queue.empty())
        queue.pop();
    vector<long long> sum_gold(Z+1, 0);
    sum = 0;
    for (int i = 0; i < X; ++i) {
        sum += coins[i].a;
        queue.push(coins[i].a);
    }
    sum_gold[0] = sum;
    for (int k = X; k < X+Z; ++k) {
        auto& c = coins[k];
        if (c.a > queue.top())
        {
            sum += c.a - queue.top();
            // cout << "apoppush: " << queue.top() << ", " << c.a << endl;
            queue.pop();
            queue.push(c.a);
        }
        sum_gold[k-X+1] = sum;
    }

    long long ans = LLONG_MIN;
    for (int i = 0; i <= Z; ++i) {
        // cout << sum_silver[i] << ", " << sum_gold[Z-i] << endl;
        ans = max(ans, sum_silver[i]+sum_gold[Z-i]);
    }
    ans += base;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3072
import java.util.*;

class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt(), l = scan.nextInt();
    int newOne = scan.nextInt();
    int oldOne = 0;
    int index = -1;
    for(int i = 0; i < n-1; i++) {
      oldOne = newOne;
      newOne = scan.nextInt();
      if(oldOne+newOne>=l) {
        index = i;
        break;
      }
    }
    if(index==-1) {
      System.out.println("Impossible");
      return;
    }
    else System.out.println("Possible");
    StringBuilder sb = new StringBuilder();
    for(int i = 1; i <=index; i++) {
      sb.append(i);
      sb.append("\n");
    }
    for(int i = n-1; i >= index+2 ; i--) {
      sb.append(i);
      sb.append("\n");
    }
    sb.append(index+1);

    System.out.println(sb.toString());
  }
}


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

using ll= long long;
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define _setl(x) __builtin_popcountll(x)
#define PI  3.14159265358979323846264338327950L
#define mod 1000000007LL

void debug(){
	cerr<<"]\n";
}
template<class H,class ... T> void debug(H h,T... t){
	cerr<<h;
	if(sizeof... (t)){
		cerr<<", ";
	}
	debug(t...);
}
#ifdef DEBUG
	#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", debug(__VA_ARGS__)
	#define dpv(...) cerr<< "["#__VA_ARGS__ " : ";for(int i: (__VA_ARGS__)){cerr<<i<<" ";}cerr<<"]\n"
#else
	#define dbg(...) 0
	#define dpv(...) 0
#endif

int n,m;
vector<vector<int>> g;
const int maxN = 2e5+6;
bool vis[maxN];

int dfs(int node){
	vis[node]= true;
	int cnt =1;
	for(auto v: g[node]){
		if(!vis[v]){
			cnt += dfs(v);
		}
	}
	return cnt;
}
void solve(){
	cin>>n>>m;
	memset(vis,0,n);
	g = vector<vector<int>> (n);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans =1;
	for(int i=0;i<n;i++){
		if(!vis[i]){
			ans = max(ans,dfs(i));
		}
	}
	cout<<ans<<"\n";
}


int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	for(int i=1;i<=_;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

/*
   check for overflows int long long
   correct mize of array
*/


Measured memory_bytes: 23768
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
using namespace std;


int main(){
    int n;
    int m = 0;
    cin >> n;
    if(n/100 == 1) m += 900;
    else m += 100;
    if((n-100*(n/100))/10 == 1) m += 90;
    else m += 10;
    if(n%10 == 1) m += 9;
    else m += 1;

    cout << m << endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;



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

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

ll n, m;
vector<ll> a;

int main() {
	cin >> n >> m;
	bool odd = false;
	for (int i = 0; i < n; i++) {
		ll t;
		cin >> t;
		t /= 2;
		if (t & 1) {
			odd = true;
		}
		a.push_back(t);
	}

	ll l = 1;
	for (int i = 0; i < n; i++) {
		l = lcm(a[i], l);
		if (l > m) {
			cout << "0" << endl;
			return 0;
		}
	}
	ll ans = 1 + (m / l - 1) / 2;
/*	if ((n == 1) || (l % 2 == 1)) {
		cout << ans << endl;
	} else {*/
		int two = 1;
		while (!(l & 1)) {
			l >>= 1;
			two <<= 1;
		}
		bool ok = true;
		for (int i = 0; i < n; i++) {
			if (!((a[i] % two) == 0)) {
				ok = false;
			}
		}
		if (ok) {
			cout << ans << endl;
		} else {
			cout << 0 << endl;
		}
//	}

	return 0;
}


Measured memory_bytes: 4292
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array
strToInt s = (read :: String -> Int) s
f (a,_,_) = a
s (_,b,_) = b
t (_,_,c) = c

main = do
   n <- readLn :: IO Int
   an <- map strToInt . words <$> getLine
   let bn = group  $ sort an
   print (solve bn)


solve :: [[Int]] -> Int
solve [] = 0
solve (a:an) = if (length a) - (head a) >= 0
               then (length a) - (head a) + (solve an)
               else (length a) + (solve an)

Measured memory_bytes: 37500
import math

def reconclied(n , m):

    ans = 0
    mod = 10**9 + 7

    if n == m:
        ans = 2 * (math.factorial(n) * math.factorial(m))

    elif abs(n - m) == 1:
        ans = (math.factorial(n) * math.factorial(m))

    return ans % mod

def main():
    n , m = map(int , input().split())
    print(reconclied(n , m))

if __name__ == '__main__':
    main()

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int s, w;
    cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;
 
int main()
{
    int N, M;
    cin>>N>>M;
    vector<int> A(N), B(N);
    for (int i=0; i<N;i++)
        cin>>A[i]>>B[i];
    vector<int> L(M), R(M);
    for (int i=0; i<M; i++)
        cin>>L[i]>>R[i];
 
    vector<pair<int, int>> AB(N);
    for (int i=0; i<N; i++)
        AB[i] = make_pair(A[i], B[i]);
    sort(AB.begin(), AB.end());
    for (int i=0; i<N; i++)
        A[i] = AB[i].first,
        B[i] = AB[i].second;
 
    A.push_back(1000000001);
    B.push_back(0);
    vector<int> C(N+1);
    C[0] = B[0];
    for (int i=1; i<=N; i++)
        C[i] = B[i-1]^B[i];
 
    vector<vector<int>> E(N+1);
    vector<vector<int>> EI(N+1);
    for (int i=0; i<M; i++)
    {
        int x = int(lower_bound(A.begin(), A.end(), L[i])-A.begin());
        int y = int(lower_bound(A.begin(), A.end(), R[i]+1)-A.begin());
        E[x].push_back(y);
        EI[x].push_back(i);
        E[y].push_back(x);
        EI[y].push_back(i);
    }
 
    vector<bool> V(N+1);
    vector<int> ans;
 
    function<int (int)> f = [&](int p)
    {
        if (V[p])
            return 0;
        V[p] = true;
 
        int s = C[p];
        for (int i=0; i<(int)E[p].size(); i++)
            if (f(E[p][i]) != 0)
            {
                ans.push_back(EI[p][i]);
                s ^= 1;
            }
        return s;
    };
 
    for (int r=0; r<=N; r++)
        if (!V[r])
            if (f(r)!=0)
            {
                cout<<-1<<endl;
                return 0;
            }
    
    sort(ans.begin(), ans.end());
    cout<<ans.size()<<endl;
    for (int a: ans)
        cout<<a+1<<endl;
}

Measured memory_bytes: 22256
#include <stdio.h>
#define mn(a,b) a<b ? a:b
#define mx(a,b) a>b ? a:b
#define INF 1000000000

using namespace std;

int chk[10];
int n,k;
int ans = INF;

void play(int state)
{
	int i;
	if(state >= n)
	{
		ans = mn(ans,state);
		return;
	}
	for(i=0;i<=9;i++)
	{
		if(chk[i])
			continue;
		int tmp = state*10 + i;
		if(tmp == state)
			continue;
		play(tmp);
	}
}

int main()
{
	int i,j;
	// freopen("../test.in","r",stdin);
	// freopen("../test.out","w",stdout);
	scanf("%d %d",&n,&k);
	for(i=0;i<k;i++)
	{
		scanf("%d",&j);
		chk[j] = 1;
	}
	play(0);
	printf("%d\n",ans);
	return 0;
}

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

int compare(const void* x, const void* y){
  if(*(int*)x<*(int*)y) return -1;
  else if(*(int*)x>*(int*)y) return 1;
  return 0;
}

int main(){
  int N,K;
  int h[100001];
  int i;
  int dif=1000000000;

  scanf("%d%d",&N,&K);
  for(i=0;i<N;i++) scanf("%d",&h[i]);

  qsort(h,N,sizeof(int),compare);

  for(i=0;i<=N-K;i++){
    if(h[i+K-1]-h[i]<dif) dif=h[i+K-1]-h[i];
  }

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

  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
    int n;
    cin>>n;
    n=n%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9)
        cout<<"hon";
    else if(n==0 || n==1 || n==6 || n==8)
        cout<<"pon";
    else
        cout<<"bon";
}   


Measured memory_bytes: 3620
#include<iostream>
#include<cmath>

int main(){

    size_t n;
    double d;
    std::cin >> n >> d;

    size_t cnt = 0;

    for(size_t i = 0; i < n; i++){
        double x, y;
        std::cin >> x >> y;

        if(std::sqrt(x * x + y * y) <= d) cnt++;
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 3840
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;

const int N = 1e5 + 10;
int n, fa[N], tot;
map <pii, int> mp;
multiset <int> s[N];
queue <pii> q;

pii mk(int x, int y) {
	if (x > y) return pii(x, y);
	return pii(y, x);
}

int gf(int x) {return fa[x] == x ? x : fa[x] = gf(fa[x]);}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) fa[i] = i;
	for (int i = 1; i <= n * 2 - 2; ++ i) {
		int x, y;
		scanf("%d %d", &x, &y);
		s[x].insert(y);
		s[y].insert(x);
		mp[mk(x, y)] ++;
	}
	for (map <pii, int> :: iterator it = mp.begin(); it != mp.end(); ++ it)
		if ((*it).se == 2) q.push((*it).fi);
	while (!q.empty()) {
		pii now = q.front(); q.pop();
		int x = gf(now.fi), y = gf(now.se);
		if (x == y) continue;
		tot ++;
		if (s[x].size() < s[y].size()) swap(x, y);
		fa[y] = x;
		for (set <int> :: iterator it = s[y].begin(); it != s[y].end(); ++ it) {
			int u = gf(*it);
			if (u == x) continue;
			s[x].insert(u), s[u].insert(x);
			mp[mk(y, u)] --;
			mp[mk(x, u)] ++;
			if (mp[mk(x, u)] == 2) q.push(mk(x, u));
		}
		s[y].clear();
	}
	puts(tot == n - 1 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 41984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char str[7];
    cin >> str;

    if (str[2] == str[3] && str[4] == str[5])
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long double lld;
lld dp[3500][3500];
lld p[3500];
int n;
int main()
{
    scanf("%d",&n);
    for(int i = 1; i <= n; i++)scanf("%Lf",&p[i]);
    //start dping
    dp[0][0] = 1;
    for(int i = 1; i <=n; i++)
    {
        for(int j = 0; j <= i; j++)
        {
            dp[i][j] = (1-p[i])*dp[i-1][j]+p[i]*dp[i-1][j-1];
        
        }
    }
    lld ans = 0;
    for(int i = (n+1)/2; i<=n;i++)
    {

        ans += dp[n][i];
    }
    printf("%.9Lf\n",ans);
}


Measured memory_bytes: 164352