akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

vector<int> Zalgo(string s) {
	vector<int> v(1,s.size());
	for(int i=1,l=-1,r=-1;i<s.size();i++) {
		if(i<=r && v[i-l]<r-i+1) v.push_back(v[i-l]);
		else {
			l=i; r=(i>r)?i:(r+1);
			while(r<s.size() && s[r-i]==s[r]) r++;
			v.push_back((r--)-l);
		}
	}
	v.push_back(0);
	return v;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;

    int ans = 0;
    for(int i=0;i<N;++i){
        string T = S.substr(i);
        auto lcp = Zalgo(T);

        for(int j=0;j<T.size();++j){
            int l = min(lcp[j],j);
            chmax(ans, l);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

int N, ans = 0;
int A[200000];
bool B[200000] = {false};

int main() {
    scanf("%d", &N);
    REP(i, N) scanf("%d", A+i);
    sort(A, A+N);
    for(int i=N-1; i>=0; i--) {
        int p = 0;
        while(A[i] >= 1<<p) p++; 
        int x = (1<<p) - A[i];
        int j = lower_bound(A, A+N, x) - A;
        if(B[i]) continue;
        if(j < i && A[j] == x && !B[j]) {
            B[j] = true;
            A[j]--;
            ans++;
        }
    }
    printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N, X;
  cin >> N >> X;
  ll sum = 0;
  ll mini = INF;
  rep(i, N) {
    ll a;
    cin >> a;
    sum += a;
    if (a < mini) {
      mini = a;
    }
  }

  ll nokori = X - sum;
  ll n = nokori / mini;
  COUT(n + N);

  return 0;
}

Measured memory_bytes: 3648
//Chandigarh University
//author: shivamkr21 (pseduo coders)
#include<bits/stdc++.h>
//#include "boost/multiprecision/cpp_int.hpp"
//#define eint int1024_t
#define lli long long int
#define endl "\n"
#define vint vector<int>
#define vvint vector< vector<int> >
#define pub push_back 
#define mod 1000000007
//using namespace boost::multiprecision;
using namespace std;
int main()
{
	string s,s1,res="Yes";
    cin>>s>>s1;
    for(int i=0;i<s.length();i++)
    {
    	if(s[i]!=s1[i])
        {
        	res="No";
            break;
        }
    }
    cout<<res;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(i);
// sort(arr, arr+n, greater<int>());
// const long double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int n;
	cin>>n;
	set<string> s1;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		s1.insert(s);
	}
	cout<<s1.size<<endl;
}

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

signed main()
{
    int a,b; cin>>a>>b;
    if((a+b)%2==0){
      cout<<(a+b)/2<<endl;
    }else{
      cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100

main()
{
  int i, j, N, A[MAX], irekae, flag=1, count=0;

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

  while(flag)
    {
      flag = 0;
      for(j=N-1; j>0; j--)
	{
	  if(A[j] < A[j-1])
	    {
	      irekae = A[j];
	      A[j] = A[j-1];
	      A[j-1] = irekae;
	      count++;
	      flag = 1;
	    }
	}
    }

  for(i=0; i<N; i++)
    {
      printf("%d", A[i]);
      if(i<N-1)
	{
	  printf(" ");
	}
    }
  printf("\n");
  printf("%d\n", count);

  return 0;  
}

Measured memory_bytes: 604
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int64) (int, int64) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	x := nextInt()
	y := nextInt()
	a := nextInt()
	b := nextInt()
	c := nextInt()
	p := nextInts(a)
	q := nextInts(b)
	r := nextInts(c)
	sort.Ints(p)
	sort.Ints(q)
	sort.Ints(r)
	p = p[len(p)-x : len(p)]
	q = q[len(q)-y : len(q)]
	var sump int64
	for _, pi := range p {
		sump += int64(pi)
	}
	var sumq int64
	for _, qi := range q {
		sumq += int64(qi)
	}
	dp := make([][]int64, c)
	for i := 0; i < c; i++ {
		dp[i] = make([]int64, 3)
	}
	ans := sump + sumq
	for i := c - 1; i >= 0; i-- {
		var minp int
		var minq int
		if len(p) == 0 {
			minp = 1001001001
		} else {
			minp = p[0]
		}
		if len(q) == 0 {
			minq = 1001001001
		} else {
			minq = q[0]
		}
		if r[i] < minp && r[i] < minq {
			break
		}
		if minp <= minq {
			ans = ans + int64(r[i]-minp)
			p = p[1:]
		} else {
			ans = ans + int64(r[i]-minq)
			q = q[1:]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <fstream>
#include <cmath>
#include <limits>
#include <chrono>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
#include <cassert>
#include <atcoder/all>
using namespace atcoder;
#pragma warning (disable: 4996)
using namespace std;

using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

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

struct UnionFind {
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

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

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

long long modpow(long long a, long long n, long long mod) {
    if (n < 0)return 0;
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

ll merge_cnt(vector<ll>& a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<ll> b(a.begin(), a.begin() + n / 2);
    vector<ll> c(a.begin() + n / 2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    while (ai < n) {
        if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
            a[ai++] = b[bi++];
        }
        else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

int main() {
    ll n, q;
    cin >> n >> q;
    fenwick_tree<ll> z(n);
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        z.add(i, a);
    }
    for (int i = 0; i < q; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        if (a == 0) {
            z.add(b, c);
        }
        else {
            cout << z.sum(b, c) << endl;
        }
    }
}

Measured memory_bytes: 8220
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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 long COM(int n, int 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(){
  int n,k; cin >> n >> k;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  ll minus = 0, plus = 0;
  COMinit();

  rep(i,n) {
    minus += (COM(n-1-i, k-1) * a[i])%MOD;
    minus %= MOD;
  }

  reverse(all(a));
  rep(i,n) {
    plus += (COM(n-1-i, k-1) * a[i])%MOD;
    plus %= MOD;
  }

  ll ans = (plus - minus)%MOD;
  if(ans < 0) ans += MOD;

  cout << ans << endl;
}

Measured memory_bytes: 12928
S=input()
S=S[::-1]
N=len(S)

index=0
words=["dream","dreamer","erase","eraser"]
for i in range(4):
    words[i]=words[i][::-1]

while index<N:
    word1=S[index:index+5]
    word2=S[index:index+6]
    word3=S[index:index+7]
    if word1 in words:
        index+=5
    elif word2 in words:
        index+=6
    elif word3 in words:
        index+=7
    else:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 9292
def main():
    h,w = map(int,input().split())
    n=int(input())
    a = list(map(int,input().split()))
    ans=[[0 for _ in range(w)] for _ in range(h)]
    x=y=key=0
    for i in range(n):
        for _ in range(a[i]):
            ans[x][y]=str(i+1)
            if key==0:
                y+=1
            else:
                y-=1
            if key==0 and y==w:
                x+=1
                y-=1
                key=1
            elif key==1 and y==-1:
                x+=1
                y+=1
                key=0
    for i in range(h):
        print(" ".join(ans[i]))
if __name__ == "__main__":
    main()

Measured memory_bytes: 40560
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>

using namespace std;

typedef long long int lld;
typedef pair<lld,lld> P;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXE = 500000;
const lld MAXV = 100000;

struct edge
{
	lld to,cost;
};

int main()
{
	lld V,E,r;
	vector<edge> e[MAXV];

	cin >> V >> E >> r;
	for(int i = 0; i < E; i++)
	{
		lld s,t,d;
		cin >> s >> t >> d;
		
		edge ee;
		ee.to = t, ee.cost = d;
		e[s].push_back(ee);
	}

	lld dist[MAXV];
	fill(dist,dist+V,INF);
	dist[r] = 0;

	priority_queue< P, vector<P>, greater<P> > Q;

	Q.push(P(0,r));

	while(!Q.empty())
	{
		//printf("okok\n");
		P p = Q.top();
		Q.pop();

		lld v = p.second;
		if (dist[v] < p.first)
		{
			continue;
		}

		for(int i = 0; i < e[v].size(); i++)
		{
			//printf("bbbb\n");
			edge ee = e[v][i];
			//printf("ee.cost = %lld\n",ee.cost);
			//printf("dist[ee.to] = %lld\n", dist[ee.to]);
			if (dist[ee.to] > dist[v] + ee.cost)
			{
				dist[ee.to] = dist[v] + ee.cost;

				//printf("dist[%lld] = %lld\n", ee.to,dist[ee.to]);

				Q.push(P(dist[ee.to],ee.to));
			}
		}
	}

	for(int i = 0; i < V; i++)
	{
		if (dist[i] == INF)
		{
			cout << "INF" << endl;
		}else
		{
			cout << dist[i] << endl;
		}
	}

	return 0;
}
	

Measured memory_bytes: 19576
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';

const ll MOD = 1e9 + 7;

ll i, j, le;

int sv(int x)
{
    int n = 200000;
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= n; p++)
    {

        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    if (prime[x])
        return 1;
    else
        return 0;
}

int main()
{
    IOS;
    int t;
   // cin >> t;
    t=1;
    while (t--)
    { ll f=0, ans= INT_MAX;
     string s,t;
     cin>>s>>t;
     
     for(i=0;i+t.size()<=s.size();i++)
     {
        string st= s.substr(i,t.size());
        if(st==t){
            f=1;
            break;
        }
        else{
            ll cnt=0;
            flu(j,0,t.size())
            {
                if(st[j]!=t[j])cnt++;
            }
            ans= min(ans,cnt);
        }
     }
     if(f==1)cout<<0<<e;
     else
     cout<<ans<<e;
    }
    return 0;
}

Measured memory_bytes: 3656
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
      
    def group_count(self):
        return len(self.roots())

n, m = map(int, input().split())
un = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    un.union(a, b)
print(un.group_count() - 1)


Measured memory_bytes: 12944
N, M = map(int, input().split()) 
H = list(map(int, input().split())) 

G = [[] for j in range(N)]
for i in range(M):
    a, b = map(int, input().split()) 
    G[a - 1].append(H[b - 1])
    G[b - 1].append(H[a - 1])

ans = 0
for i, g in enumerate(G):
    if not g:
        ans += 1
        continue
    if H[i] > max(g):
        ans += 1

print(ans)

Measured memory_bytes: 23040
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    main.solve();
    main.show();
  }

  String s;
  int n;
  int ans;
  
  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      s = sc.next();
      n = s.length();
    } finally {
      sc.close();
    }
  }
  
  void solve() {
    for (int i = 0; i < n; i++) {
      for (int j = i; j <= n; j++) {
        if (checkString(i, j)) {
          int k = j - i;
          if (ans < k) ans = k;
        } 
      }
    }
  }
  
  boolean checkString(int lo, int hi) {
    for (int i = lo; i < hi; i++) if (!checkChar(i)) return false;
    return true;
  }
  
  boolean checkChar(int i) {
    char[] cs = new char[] { 'A', 'C', 'G', 'T' };
    for (char c: cs) if (s.charAt(i) == c) return true;
    return false;
  }

  void show() {
    System.out.println(ans);
  }
}


Measured memory_bytes: 35608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int *h=new int[n+1];
    int *notgood=new int[n+1];
    memset(notgood, 0, sizeof(int)*(n+1));
    for(int i=1; i<=n; ++i)
    {
        cin>>h[i];
    }
    vector< pair<int,int> > vis;
    for(int i=0; i<m; ++i)
    {
        int a,b;
        cin>>a>>b;
        vis.push_back(make_pair(a,b));
        vis.push_back(make_pair(b,a));
    }
    for(int i=0; i<vis.size(); ++i)
    {
        if(h[vis[i].first]<=h[vis[i].second])
        {
            ++notgood[vis[i].first];
        }
    }
    int icount=0;
    for(int i=1; i<=n; ++i)
    {
        if(notgood[i]==0)
            ++icount;
    }
    cout<<icount<<endl;
    return 0;
}


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

#define int long long

const int inf = 1e18;

signed main(){

  int ans = inf;
  int H, W, K;
  vector<string> A;
  vector<vector<int>> dis;
  queue<pair<int,pair<int,int>>> Q;

  cin>>H>>W>>K;

  A.resize(H);
  dis.resize(H, vector<int>(W, inf));

  for(int i = 0; i < H; i++){
    cin>>A[i];
    for(int j = 0; j < W; j++){
      if(A[i][j] == 'S') {
        dis[i][j] = 0;
        Q.push({0, {i,j}});
      }
    }
  }

  while(!Q.empty()){
    pair<int,pair<int,int>> P = Q.front(); Q.pop();
    int d = P.first;
    int y = P.second.first, x = P.second.second;

    if(dis[y][x] < d) continue;
    if(dis[y][x] == K) continue;

    for(int i = 0; i < 4; i++){
      int ny = y + (2-i)%2, nx = x + (i-1)%2;

      if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;

      if(A[ny][nx] == '#') continue;

      if(dis[ny][nx] > d + 1) {
        dis[ny][nx] = d + 1;
        Q.push({d+1, {ny, nx}});
      }
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int x = min(min(i, H - i - 1), min(j, W - j - 1));

      if(dis[i][j] == inf) continue;

      ans = min(ans, (x + K - 1) / K + 1);
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define INF 0x7fffffff
using namespace std;

struct Edge{int to,capa,flow,next;} e[10500];
int h[210],sum=-1,s,t;
bool vis[210];
int d[210],cur[210];

void AddEdge(int u,int v,int w)
{
	e[++sum].to=v;
	e[sum].flow=0;
	e[sum].capa=w;
	e[sum].next=h[u];
	h[u]=sum;
}

void add_edge(int u,int v,int w)
{
	AddEdge(u,v,w);
	AddEdge(v,u,0);
}

bool BFS()
{
	memset(vis,0,sizeof(vis));
	queue<int> q;
	q.push(s);
	d[s]=0;vis[s]=1;
	while(!q.empty())
	{
		int u=q.front();
		for(int tmp=h[u];~tmp;tmp=e[tmp].next)
			if(e[tmp].capa>e[tmp].flow&&!vis[e[tmp].to])
			{
				vis[e[tmp].to]=1;
				d[e[tmp].to]=d[u]+1;
				q.push(e[tmp].to);
			}
		q.pop();
	}
	return vis[t];
}

int DFS(int u,int a)
{
	if(u==t||a==0) return a;
	int f,flow=0;
	for(int& tmp=cur[u];~tmp;tmp=e[tmp].next)
		if(d[e[tmp].to]==d[u]+1)
		{
			f=DFS(e[tmp].to,min(a,e[tmp].capa-e[tmp].flow));
			if(f>0)
			{
				flow+=f;a-=f;
				e[tmp].flow+=f;
				e[tmp^1].flow-=f;
				if(a==0) break;
			}
		}
	return flow;
}

int Maxflow()
{
	int flow=0;
	while(BFS())
	{
		for(int i=s;i<=t;i++) cur[i]=h[i];
		flow+=DFS(s,INF);
	}
	return flow;
}

const int N=10000000;
bool mark[N+10],up[N+10];
int prime[N/10],num=0;
int lft[110],rht[110];

void Init()
{
	mark[1]=1;
	for(int i=2;i<=N;i++)
	{
		if(!mark[i]) prime[++num]=i;
		for(int j=1;j<=num&&i*prime[j]<=N;j++)
		{
			mark[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}
	mark[2]=1;
}

int main()
{
	int n,x;Init();
	scanf("%d",&n);
	memset(h,-1,sizeof(h));
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		up[x]=1;
	}
	int l=0,r=0;
	for(int i=1;i<=N+1;i++)
		if(up[i]!=up[i-1])
		{
			if(i&1) lft[++l]=i;
			else rht[++r]=i;
		}
	s=0;t=l+r+1;
	for(int i=1;i<=l;i++) add_edge(s,i,1);
	for(int i=1;i<=r;i++) add_edge(l+i,t,1);
	for(int i=1;i<=l;i++)
		for(int j=1;j<=r;j++)
			if(!mark[abs(lft[i]-rht[j])])
				add_edge(i,j+l,1);
	int falun=Maxflow(),dafa=falun;
	if(l>falun) dafa+=(l-falun)/2*2;
	if(r>falun) dafa+=(r-falun)/2*2;
	if((l-falun)&1) dafa+=3;
	printf("%d\n",dafa);
	return 0;
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define int long long
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std; 

const int N = 1e6 + 7;
 
vector <int> v[N];
int par[N];
int n , m;
bool seen[N]; 
int32_t main(){
    L_T_S_K;
    cin >> n >> m;

    for(int i = 0 ; i < m ; i++){
        int x , y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    set <int> s;

    queue <int> Q;
    Q.push(1);
    par[1] = 1;
    seen[1] = 1;
    while(Q.size() > 0){
        auto it = Q.front();
        Q.pop();
        s.insert(it);
        for(auto x : v[it]){
            if(seen[x] == 0){
                Q.push(x);
                seen[x] = 1;
                par[x] = it;
            }
        }
    }

    if(s.size() != n) {cout << "No\n" ; return 0;}
    cout << "Yes\n";
    for(int i = 2 ; i <= n ; i++){
        cout << par[i] << "\n";
    }

    return 0;
}


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

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(vs) (ll)(vs.size())
#define rep(i,a,b) for (ll i=a;i<b;++i)
#define rep_(i,a,b) for (ll i=a;i>b;--i)
#define iter(i,c) for (auto i:c)
#define endl '\n'
const ll mod = 1e9 + 7;

const ll maxn = 1e5;

ll n, m;
ll a[maxn];
vi g[maxn];
string s;
char c;

void solve() {
	cin>>n;
	
	if (n<600) {cout<<8;return;}
	if (n<800) {cout<<7;return;}
	if (n<1000) {cout<<6;return;}
	if (n<1200) {cout<<5;return;}
	if (n<1400) {cout<<4;return;}
	if (n<1600) {cout<<3;return;}
	if (n<1800) {cout<<2;return;}
	if (n<2000) {cout<<1;return;}
}

void aux() {
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout<<fixed<<setprecision(10);
	aux();
	ll _ = 1;
	// cin>>_;
	while(_--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 5992
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ll a, b, k;
	cin >> a >> b >> k;
	if (a < k) {
		cout << 0 << " " << max(0ll, b - k + a) << endl;
	}
	else {
		cout << (a - k) << " " << b << endl;
	}
}


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

static const int MAX = 200000;
static const int INF = 1e9;

// 隣接リストを用いた幅優先探索 O(|V|+|E|)
int n;
vector<int> G[MAX], d(MAX, INF); // 始点sから頂点iまでの最短距離をd[i]に記録
// main関数からこれらを削除すること
 
void bfs(int s) {
  queue<int> q;
  q.push(s);
  d[s] = 0;
  while(!q.empty()){
    int u = q.front();
    q.pop();
    for(int v = 0; v < G[u].size(); v++){
    if(d[G[u][v]] == INF){
        d[G[u][v]] = d[u] + 1;
        q.push(G[u][v]);
      }
    }
  }
}

int main() {
// 無向(有向)グラフの隣接リスト
  int m, u, v;
  cin >> n >> m;
  
  for(int i = 0; i < m; i++){
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u); // 有向グラフではこの行をコメントアウト
  }
  
  bfs(0);
  
  if(d[n - 1] == 2) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 13168
#include<stdio.h>
#include<string.h>
int main(){
	char c[101]={0},s[101]={0},t[101]={0},p[101]={0};
	int a;
	scanf("%s",s);
	a=strlen(s);
	scanf("%s",p);
	strcpy(t,s);
	strncat(s,t,a-1);
	if(strstr(s,p)!=NULL)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s;
  cin >> s;

  int K;
  cin >> K;

  int N = s.size();

  int dp[N+1][K+2][2];
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;

  REP(i, N) REP(j, K+1){
    int d = s[i]-'0';

    dp[i+1][j][1] += dp[i][j][1];
    dp[i+1][j+1][1] += dp[i][j][1]*9;

    if(d != 0){
      dp[i+1][j][1]   += dp[i][j][0];
      dp[i+1][j+1][1] += dp[i][j][0]*(d-1);
      dp[i+1][j+1][0] += dp[i][j][0];
    }else{
      dp[i+1][j][0] += dp[i][j][0];
    }
  }

  cout << dp[N][K][0]+dp[N][K][1] << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000],arr1[1000000];
int main()
{
	long long n,m,i,j,x,gc,lc;
	gc=0;
	cin>>n>>m;
	for (i=0;i<n;i++)
	{
		cin>>arr[i];
	}	
	sort(arr,arr+n);
	arr1[0]=arr[0];
	x=1;
	for (i=1;i<n;i++)
	{
		if(arr[i]!=arr[i-1])
		{
			arr1[x]=arr[i];
			x++;
		}
	}
	for (i=0;i<x;i++)
	{
		arr1[i]=arr1[i]/2;
		gc=__gcd(arr1[i],gc);
	}
	lc=arr1[0]/gc;
	for (i=1;i<x;i++)
	{
		lc=lc*arr1[i];
	}
	lc=arr1[0];
	for (i=1;i<x;i++)
	{
		lc=(lc*arr1[i])/(__gcd(arr1[i],lc));
	}

	for (i=0;i<x;i++)
	{
		if ((lc/arr1[i])%2==0)
		{
			cout<<0<<endl;
			return 0;
		}
	}
	cout<<((m/lc)+1)/2<<endl;
}

Measured memory_bytes: 5120
// C - Exam and Wizard
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int in(){int x;scanf("%d",&x);return x;}

int main(){
	int ans = 0, N = in(), C[N];
	long long minus = 0, impossible = 0;// <0: impossible

	rp(i, 0, N) impossible += C[i] = in();

	rp(i, 0, N){
		int b = in();
		impossible -= b;
		if(impossible < 0){ puts("-1"); return 0; }
		C[i] -= b;
		if(C[i] < 0){
			ans++;//変更が必要
			minus += C[i];
		}
	}

	sort(C, C+N);
	reverse(C, C+N);

	for(int c:C){
		if(minus >= 0) break;
		if(c <= 0) break;
		ans++;//変更が必要
		minus += c;
	}

	printf("%d\n",ans);
}

Measured memory_bytes: 640
/**
*    created: 27.06.2020 18:25:44
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;
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;}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    if (1 <= n &&  n <= 999) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    return 0;
}

Measured memory_bytes: 3608
using System;

class Task3
{

    public static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int len = N.ToString().Length;
        int ans = 0;

        for (int i = 0; i < len; i++)
        {
            if ((i + 1) % 2 != 0)
            {
                ans += 9 * (Convert.ToInt32(Math.Pow(10, i)));
            }
            else
            {
                ans += 0;
            }
        }
        if (len % 2 != 0)
        {
            ans += (N + 1) - (Convert.ToInt32(Math.Pow(10, len)));
        }
        Console.WriteLine(ans);
        
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cerr << x << endl
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

int main()
{
    int x;
    cin >> x;
    cout << 1 - x << endl;
}


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

using namespace std;

int main() {
   long long int n,d,x, y;
    cin>>n>>d;
    long long int a,b,c,e;
    a=d*d;
    // cout<<a<<endl;
    int count=0;
    for (long long int i=0; i<n; i++){
        cin>>x>>y;
        b=x*x;
        c=y*y;
        e=b+c;
        //cout<<b<<" "<<c<<" "<<e<<endl;
        if (e<=a){
            count++;
            //cout<<i<<endl;
        }
    }
    cout<<count;
    return 0;
};

Measured memory_bytes: 3632
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x,'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x,'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x,'x') # rev => int(res, 16)
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(n=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## const ##
MOD=10**9+7
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    n, m = MII()
    ab = [MIIZ() for _ in range(m)]
    g = [[] for _ in range(n)]
    for a,b in ab:
        g[a].append(b)
        g[b].append(a)
    dist = [-1]*n
    dq = deque()
    dist[0] = 0
    dq.append(0)
    res = [0]*n
    while dq:
        v = dq.popleft()
        for nv in g[v]:
            if dist[nv] != -1: continue
            res[nv] = v
            dist[nv] = dist[v] + 1
            dq.append(nv)
    res = [i+1 for i in res[1:]]
    print('Yes')
    print(*res,sep='\n')


if __name__ == '__main__':
    main()

Measured memory_bytes: 63320
s = input().rstrip()
front = int(s[:2])
back = int(s[2:])

if (front >= 1 and front <= 12) and (back >= 1 and back <= 12):
    print("AMBIGUOUS")
elif (front >= 1 and front <= 12):
    print("MMYY")
elif (back >= 1 and back <= 12):
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	ll x; scanf("%lld", &x);
	ll y = 1'000'000'000LL;
	ll a = (x+y-1)/y, b = y*a -x;
	printf("0 0 %lld %lld %lld %lld\n", a, b, 1LL, y);
	DEBUG("%lld=%lld\n", x, a*y-1*b);
}


Measured memory_bytes: 764
n = gets.to_i
a = gets.split.map(&:to_i)

count = 0
flag = false
n.times do |nn|
    if flag
        flag = false
        next
    elsif a[nn] == nn + 1 && a[nn + 1] == nn + 2
        flag = true
        count += 1
    elsif a[nn] == nn + 1
        count += 1
    end
end

p count

Measured memory_bytes: 8068
<?php
  fscanf(STDIN,"%d %d",$a,$b);
  $h = [];
  for($i=1; $i<=1000; $i++){
    $h[] = $i*$i;
  }
  if(in_array($a.$b,$h)){
    echo "Yes\n";
  }else{
    echo "No\n";
  }

Measured memory_bytes: 4604
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a,b;
  ci(a>>b);
  For(i,1,b+1){
    a*=2;
    if(a>b){
      co(i);
      break;
    }
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder.Problems
{
    public class ProblemC
    {
        public static void Main(string[] args)
        {
            var s = new SolveC();
            s.Solve();
        }

        public class Scanner
        {
            private string[] _s;
            private int _i;
            private readonly char[] _separators = new char[] { ' ' };

            public Scanner()
            {
                _s = new string[0];
                _i = 0;
            }

            public string Next()
            {
                if (_i < _s.Length) return _s[_i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                _s = st.Split(_separators, StringSplitOptions.RemoveEmptyEntries);
                if (_s.Length == 0) return Next();
                _i = 0;
                return _s[_i++];
            }

            public int NextInt() => int.Parse(Next());
            public long NextLong() => long.Parse(Next());
            public ulong NextULong() => ulong.Parse(Next());
            public double NextDouble() => double.Parse(Next());

            public int[] GetIntArray(int n, int add = 0)
            {
                int[] array = new int[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextInt() + add;
                }
                return array;
            }

            public long[] GetLongArray(int n, long add = 0)
            {
                long[] array = new long[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextLong() + add;
                }
                return array;
            }

            public double[] GetDoubleArray(int n, double add = 0)
            {
                double[] array = new double[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextDouble() + add;
                }
                return array;
            }
        }
    }

    public class SolveC
    {
        public void Solve()
        {
            var cin = new ProblemC.Scanner();
            var n = cin.NextInt();
            var s = new string[n];
            for (int i = 0; i < n; i++)
            {
                s[i] = cin.Next();
            }

            var result = GetAnswer(n, s);
            Console.WriteLine(result);
        }

        public int GetAnswer(int n, string[] s)
        {
            return s.Distinct().Count();
        }
    }
}


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

int main() {
    int N, a, b = 1001, c = -1;
    cin >> N;
    rep(i, N) {
        cin >> a;
        b = min(b, a);
        c = max(c, a);
    }
    cout << c - b << endl;
}

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,k;cin>>n>>k;
    vector<int> num(n);
    rep(i,n) num.at(i)=0;
    vector<int> a(n);
    rep(i,n) cin>>a.at(i);
    rep(i,n) num[a[i]-1]++;
    sort(num.begin(),num.end());
    reverse(num.begin(),num.end());
    int sum=0;
    for(int i=k;i<n;i++) sum+=num[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 1792
'use strict'

/////////////////////////////////////
//コピペスペース//////////////////////

//定数
const INF  =  900719925474099 // Math.floor(Number.MAX_SAFE_INTEGER / 10);

//スペース区切りの数字列を数字の配列にして返す
function mapint(line){return line.split(' ').map((v)=>parseInt(v));}

function lower_bound(d,a,b,e){
    for(var c;1<b-a;)
        d[c=0|(a+b)/2]<e ? a=c : b=c;
    return d[a]<e?b:a
};

const N109 = 1000000000;
const MOD = N109+7;

//コピペスペース//////////////////////
/////////////////////////////////////

function Main(input){
	let temp = input.trim().split('\n');
	let n = parseInt(temp[0]);
	let h = mapint(temp[1]);

	let f = true;
	for(let i=n-1;i>=1;i--){
		if(h[i-1]-h[i]>=2){
			f=false;
			break;
		}else if(h[i-1]-h[i]>=1){
			h[i-1]--;
		}
	}
	if(f){
		console.log('Yes');
	}else{
		console.log('No');
	}
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int a, b, p, q, s, t, cnt;

int main()
{
    int i;

    cin >> a >> b;

    for(i=a; i<=b; i++){
        p=i/10000, q=(i-(p*10000))/1000, s=(i%100-i%10)/10, t=i%10;
        if(p==t && q==s) cnt++;
    }

    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;


signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);
  int a[5];
  int ans;
  for (int i = 0; i < 5; i++){
    cin >> a[i];
    if (a[i] == 0)
      ans = i + 1;
  }
  cout << ans << endl;
  

}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int A, B;
    cin >> A >> B;
    int C, D;
    cin >> C >> D;

    C -= B;
    while(C > 0 && A > 0) {
        A -= D;
        C -= B;
    }
    
    ATYN(A > 0)


    return 0;
}

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

int main(){
  int N;
  long long count=0;
  string S;
  cin >> N >> S;
  long long R=0,G=0,B=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R'){
      R++;
    }
    else if(S.at(i)=='G'){
      G++;
    }
    else{
      B++;
    }
  }
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      int k=2*j-i;
      if(k<=j || N-1<k){
        continue;
      }
      if(S.at(i)==S.at(j) || S.at(j)==S.at(k) || S.at(k)==S.at(i)){
        continue;
      }
      count++;
    }
  }
  cout << R*G*B-count << endl;
}

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

using namespace std;

int main(void){
    int ans = 0;
    char l = '\0';
    int N;
    cin >> N;
    string S;
    cin >> S;
    for(int i = 0; i < S.length(); i++){
        if(l != S[i]){
            l = S[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
K = int(input())

cycle = set()
if K % 2 == 0:
    print(-1)
else:
    n = 7
    i = 1
    while 1:
        if n in cycle:
            i = -1
            break
        if n % K == 0:
            break
        cycle.add(n)
        n = (n * 10 + 7) % K
        i += 1
       
    print(i)

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

int main(int argc, char *argv[]) {
        int D;
        cin >> D;
        switch (D) {
        case 25:
                cout << "Christmas" << endl;
                break;
        case 24:
                cout << "Christmas Eve" << endl;
                break;
        case 23:
                cout << "Christmas Eve Eve" << endl;
                break;
        case 22:
                cout << "Christmas Eve Eve Eve" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a=="SUN")
	cout<<7<<endl; 
	if(a=="MON")
	cout<<6<<endl;
	if(a=="TUE")
	cout<<5<<endl;
	if(a=="WED")
	cout<<4<<endl; 
	if(a=="THU")
	cout<<3<<endl; 
	if(a=="FRI")
	cout<<2<<endl;
	if(a=="SAT")
	cout<<1<<endl;  
}

Measured memory_bytes: 256