akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;



int main() {
  int64_t N;
  cin>>N;
  map<int64_t,int64_t> ann;
  for(int i=0;i<N;i++){
    int64_t D;
    cin>>D;
    ann[D]++;
  }
  int64_t M;
  cin>>M;
  map<int64_t,int64_t> mon;
  vector<int64_t> vec(M);
  for(int i=0;i<M;i++){
    cin>>vec.at(i);
  }
  for(int i=0;i<M;i++){
    mon[vec.at(i)]++;
  }
  for(int i=0;i<M;i++){
    int64_t x=vec.at(i);
    if(mon[x]>ann[x]){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 29816
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
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;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

    
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  string s;
  cin >> s;
  ll n=s.size();
  ll r=0;
  ll cnt=0;
  map<ll,ll>mp;
  mp[0]++;
  ll tenfactor=1;
  rep(i,n){
    r=(r+(s[n-1-i]-'0')*tenfactor)%2019;
    tenfactor=(tenfactor*10)%2019;
    mp[r]++;      
  }
  
  for(auto p:mp){
    int num=p.second;
    cnt+=num*(num-1)/2;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 15652
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i, n) for (int i = 0; i < (n); i ++)
using namespace std;

int main()
{
  int n;
  cin >> n;
  
  vector<int> a(n), b(n);
  rep(i, n) cin >> a.at(i);
  rep(i, n) cin >> b.at(i);
  
  vector<int> v(n);
  rep(i, n) v.at(i) = i + 1;
  
  int count = 0, a_i = -1, b_i = -1;  
  do
  {
    if (v == a) a_i = count;
    if (v == b) b_i = count;
    if (a_i != -1 && b_i != -1) break;
    count ++;
  } while(next_permutation(v.begin(), v.end()));
  
  int ans = a_i - b_i;
  if (ans < 0) ans *= -1;
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = -1;
    rep(i, 0, 1000000){
        if(a % 2 || b % 2 || c % 2){
            ans = i;
            break;
        }
        int na = b / 2 + c / 2;
        int nb = a / 2 + c / 2;
        int nc = a / 2 + b / 2;
        a = na; b = nb; c = nc;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
arr = list(map(int, input().split()))

supervisor = {}

for i in arr:
    if i in supervisor:
        supervisor[i] = supervisor[i] + 1
    else:
        supervisor.update({i:1})

for i in range(1,n+1):
    if i in supervisor:
        print(supervisor[i])
    else:
        print(0)

Measured memory_bytes: 33528
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>

#define MAX 1000000

using namespace std;

int n,k;
int rankk[MAX+1];
int tmp[MAX+1];
int sa[MAX+1];

bool compare_sa(int i,int j){
	if(rankk[i]!=rankk[j]) return rankk[i]<rankk[j];
	else{
		int ri=(i+k<=n ? rankk[i+k]:-1);
		int rj=(j+k<=n ? rankk[j+k]:-1);
		return ri<rj;
	}
}

void construct_sa(string S){
	n = S.length();
	//???????¨???????, 1????????§, rank????????????????????§??????.
	for(int i=0;i<=n;i++){
		sa[i]=i;
		rankk[i]=(i<n ? S[i]:-1);
	}
	
	//k??????????????????sort?????????????????¨?????????, 2k????????§sort
	for(k=1;k<=n;k*=2){
		sort(sa,sa+n+1,compare_sa);
		//tmp????¬????rank????¨????, rank????§?????????????.
		tmp[sa[0]]=0;
		for(int i=1;i<=n;i++){
			tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i]) ? 1:0);
		}
		for(int i=0;i<=n;i++){
			rankk[i]=tmp[i];
		}
	}
}

bool contains(string S, string P){
	int a=0;
	int b=S.length();
	while(b-a>1){
		int c=(a+b)/2;
		//S???sa[C]???????????????|T|????????¨T?????????
		if(S.compare(sa[c],P.length(),P)<0) a=c;
		else b=c;
	}
	return S.compare(sa[b],P.length(),P)==0;
}

int main(){
	int q;
	bool ans;
	string T,P;
	cin >> T;
	construct_sa(T);//Construct Suffix Array
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		cin.ignore();
		cin >> P;
		ans = contains(T,P);
		if(ans==true)
		printf("1\n");
		else
		printf("0\n");
	}
}

Measured memory_bytes: 16668
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

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

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    int k;
    cin>>k;
    int answer=1;
    int now=7;
    set<int> s;
    while(now!=0){
        while(now<k){
            now*=10;
            now+=7;
            answer+=1;
        }
        now%=k;
        auto ret=s.insert(now);
        if(!ret.second){
            cout<<-1;
            return 0;
        }
    }
    cout<<answer;

    return 0;
}


Measured memory_bytes: 45736
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 405;
const int mod = 1e9 + 7;

int n, m, a[MAXN], b[MAXN], c[MAXN], d[MAXN], e[MAXN][MAXN], f[MAXN][MAXN], g[MAXN][MAXN][MAXN];

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = n / 3;
	for (int i = 1; i <= n; i ++)
		a[i] = Read();
	for (int i = 1; i <= n; i ++)
		b[i] = Read();
	f[0][0] = g[0][0][0] = 1;
	for (int i = 0; i <= m; i ++)
		for (int j = 0; j <= m << 1; j ++)
		{
			f[i + 1][j] = (f[i + 1][j] + f[i][j]) % mod;
			if (j < i << 1)
				f[i][j + 1] = (f[i][j + 1] + 1LL * ((i << 1) - j) * f[i][j]) % mod;
		}
	for (int i = 1; i <= n; i ++)
	{
		c[a[i]] = 1, mcpy(d, c);
		int cur = i;
		for (int j = 1; j <= n; j ++)
		{
			if (!d[b[j]])
				cur ++;
			d[b[j]] ++;
			if (d[a[i]] == 1 && d[b[j]] == 1)
				e[i][j] = cur;
		}
	}
	for (int i = 0; i <= n; i ++)
		for (int j = 0; j <= n; j ++)
			if (i || j)
				for (int k = 0; k <= m; k ++)
				{
					if (i && j)
						g[i][j][k] = ((g[i - 1][j][k] + g[i][j - 1][k] - g[i - 1][j - 1][k]) % mod + mod) % mod;
					else if (i)
						g[i][j][k] = g[i - 1][j][k];
					else
						g[i][j][k] = g[i][j - 1][k];
					if (i && j && k && e[i][j])
						g[i][j][k] = (1LL * g[i - 1][j - 1][k - 1] * (n - 3 * (m - k) - e[i][j]) + g[i][j][k]) % mod;
				}
	return printf("%d\n", 1LL * g[n][n][m] * f[m][m << 1] % mod), 0;
}


Measured memory_bytes: 260992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0004
{
    class Program
    {
        static void Main(string[] args)
        {
            // 連立方程式 ax + by = c,dx + ey = f の解、x,yを出力するプログラム
            // 1行ごとにa,b,c,d,e,fがスペース区切りで与えられる

            string str;

            while ((str = Console.ReadLine()) != null)
            {
                double[] num = str.Split(' ').Select(double.Parse).ToArray();
                double a = num[0]; double b = num[1]; double c = num[2];
                double d = num[3]; double e = num[4]; double f = num[5];

                double x = (b * f - c * e) / (b * d - a * e);
                double y = (c - a * x) / b;

                Console.WriteLine(x.ToString("F3") + " " + y.ToString("F3"));
            }
        }
    }
}



Measured memory_bytes: 18448
#include "bits/stdc++.h"

using namespace std;
using uint = unsigned int;
using int64 = long long;
using i64 = int64;
using uint64 = unsigned long long;
using vint = vector<int>;
using vint64 = vector<int64>;
template<typename T>
using p_que = priority_queue<T>;
#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rep1(i,N) for(int i=1;i<=(int)(N);++i)
#define fs first
#define sc second
#define eb emplace_back
#define all(x) x.begin(),x.end()

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

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

template<class T, class U> ostream& operator<<(ostream& os, const map<T, U>& mp) {
	os << "{";
	for (auto& e : mp) os << e << " ";
	return os << "}";
}

void Main();
signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
}

/* Cut from here! */

#define int long long

void Main() {
	int a, b; cin >> a >> b;
	cout << (a + b) / 2 << endl;
}


Measured memory_bytes: 3164
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(K,N+1):
  if i > K:
    tmp1 = A[i-K-1]
    tmp2 = A[i-1]
    if tmp1 < tmp2:
      print('Yes')
    else:
      print('No')




Measured memory_bytes: 31676
n = int(input())
a = list(map(int, input().split()))

def bubbleSort():
  cnt = 0
  flag = 1
  while flag:
    flag = 0
    for j in range(n-1, 0, -1):
      if a[j]<a[j-1]:
        a[j], a[j-1] = a[j-1], a[j]
        flag = 1
        cnt += 1
  return cnt

cnt = bubbleSort()
print(" ".join(map(str, a)))
print(cnt)


Measured memory_bytes: 5600
n = int(input())
a = list(map(int, input().split()))
sign = 0
for i in range(n):
    if a[i] < 0:
        sign += 1
        a[i] *= -1
if sign%2 == 0:
    print(sum(a))
else:
    print(sum(a)-2*min(a))


Measured memory_bytes: 64880
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long LongLong;
const int INFTER=0x3f3f3f3f;
const int MAX=1e5+5;
int a[MAX];
int Gold[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int center=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[center]>0) {Gold[i][j]=center;--a[center];}
                   else if(a[center]==0) {++center;Gold[i][j]=center;--a[center];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[center]>0) {Gold[i][j]=center;--a[center];}
                    else if(a[center]==0) {++center;Gold[i][j]=center;--a[center];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",Gold[i][j]);
                else printf("%d\n",Gold[i][j]);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int a,b,c,d,flg = 0,a2,b2,c2,d2;
    cin >> a >> b >> c >> d;
    a2 = a,b2 = b,c2 = c,d2 = d;
    while(1){
        if(flg == 0){
            c -= b2;
            if(c <= 0){
                cout << "Yes" << endl;
                return 0;
            }
            flg = 1;
        }else{
            a -= d2;
            if(a <= 0){
                cout << "No" << endl;
                return 0;
            }
            flg = 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	vector<int> a(n);
	rep(i,n){
		cin >> a[i];
	}

	int cnt;
	for(cnt = 0; true; cnt++){
		bool f = true;
		rep(i,n){
			if(a[i] % 2 || not a[i]) f = false;
			a[i] /= 2;
		}
		if(not f) break;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define my_all(v) v.begin(),v.end()
#define my_un(v) v.erase(unique(ALL(v)),v.end())
#define my_each(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
bool b[805][805],vis[805][805];
int dist[805][805];
char t;
int n,m,k,ans=INT_MAX,sx,sy;
void swap_int(int &a,int &b)
{
	a^=b;
	b^=a;
	a^=b;
}
bool inrange(int x,int y)
{
	return x>0&&x<=n&&y>0&&y<=m;
}
queue<pii> q;
int main(int argv,char *argc[])
{
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			t=getchar();
			while(t!='#'&&t!='S'&&t!='.')
			{
				t=getchar();
			}
			b[i][j]=(t=='#');
			if(t=='S')
			{
				sx=i,sy=j;
			}
		}
	}
	q.push(make_pair(sx,sy));
	vis[sx][sy]=1;
	while(!q.empty())
	{
		pii fr=q.front();
		q.pop();
		int x=fr.first,y=fr.second;
		if(dist[x][y]==k)
		{
			continue;
		}
		for(int dir=0;dir<4;dir++)
		{
			int nx=x+dx[dir],ny=y+dy[dir];
			if(inrange(nx,ny))
			{
				if(!vis[nx][ny]&&!b[nx][ny])
				{
					vis[nx][ny]=1;
					dist[nx][ny]=dist[x][y]+1;
					q.push(make_pair(nx,ny));
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(vis[i][j])
			{
				int dis=min(i-1,min(j-1,min(n-i,m-j)));
				ans=min(ans,(dis%k==0?(dis/k):(dis/k+1)));
			}
		}
	}
	ans++;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4096
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 31-May-2020 18:00:26
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void Int(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void Int(T &x, W &y) {Int(x), Int(y);}
template <TN T, TN W, TN Q> inline void Int(T &x, W &y, Q &z) {Int(x, y), Int(z);}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;


int solve() {
    long long a, b; cin >> a >> b;
    cout << a * b << endl;

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // Int(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, q, node1, node2, v, node3;
vector<ll> adjlist[200005];
ll coun[200005];
bool visited[200005];
void dfs(ll x){
	if (visited[x])return;
	visited[x] = 1;
	for (auto i:adjlist[x]){
		//if (visited[i])return;
		//visited[i] = 1;
		//if (visited[i])return;
		if (visited[i]) continue; //return exits the function and all other children are not visited sian
		coun[i] += coun[x];
		dfs(i);
		}
	}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	cin >> q;
	for (ll i = 0; i < n-1; i++){
		cin >> node1 >> node2;
		adjlist[node1].push_back(node2);
		adjlist[node2].push_back(node1);
		}
		for (ll i = 0; i < q; i++){
			cin >> node3 >> v;
			coun[node3] += v;
			}
			dfs(1);
			for (ll i = 1; i <= n; i++){
				cout << coun[i] << ' ';
				}
}

Measured memory_bytes: 21376
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Node {
		int id, gid, val;
		Set<Integer> conns;

		Node(int id, int val) {
			this.id = id;
			this.val = val;
			this.gid = -1;
			this.conns = new HashSet<>();
		}

	}

	int N, M;
	Node[] p;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	void mark(int current, int gid, int parent) {
		if (p[current].gid >= 0) {
			return;
		}
		p[current].gid = gid;
		for (Integer conn : p[current].conns) {
			if (conn != parent) {
				mark(conn, gid, current);
			}
		}
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		M = Integer.parseInt(tokens[1]);
		p = new Node[N];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			p[i] = new Node(i, Integer.parseInt(tokens[i]) - 1);
		}
		for (int i = 0; i < M; ++i) {
			tokens = in.readLine().split(" ");
			int x = Integer.parseInt(tokens[0]) - 1;
			int y = Integer.parseInt(tokens[1]) - 1;
			p[x].conns.add(y);
			p[y].conns.add(x);
		}
	}

	int count(Set<Node> nodes) {
		Set<Integer> ids = new HashSet<>();
		Set<Integer> vals = new HashSet<>();
		for (Node node : nodes) {
			ids.add(node.id);
			vals.add(node.val);
		}
		ids.retainAll(vals);

		return ids.size();
	}

	void calc() {
		// mark
		int gid = 0;
		for (int i = 0; i < N; ++i) {
			if (p[i].gid < 0) {
				mark(i, gid, -1);
				++gid;
			}
		}
		// gidごとにまとめる
		Map<Integer, Set<Node>> groups = new HashMap<>();
		for (int i = 0; i < N; ++i) {
			if (!groups.containsKey(p[i].gid)) {
				groups.put(p[i].gid, new HashSet<>());
			}
			groups.get(p[i].gid).add(p[i]);
		}

		int count = 0;
		for (Set<Node> group : groups.values()) {
			count += count(group);
		}
		System.out.println(count);

	}

	void showResult() {
	}
}


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

char ans[17]="CODEFESTIVAL2016";

int main(){
  int result  = 0;
  char S[17];

  cin >> S;

  for(int i =0;i<16;i++){
    if(ans[i]!=S[i])result++;
  }
  cout << result<<endl;
 
  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
	bool is(int x){
		for(int i=2;i*i<=x;i++)if(x%i==0)return false;
		return true;
	}
int main(){
	int n,p;

	while(cin>>n>>p,n!=-1||p!=-1){
		int cnt=0;
		n++;
		if(n==1)n++;
		vector<int>primes;
		vector<int>sums;
		while(true){
			if(is(n)){
				cnt++;
				primes.push_back(n);
			}
			if(cnt==22)break;
			n++;
		}
		//for(int i=0;i<primes.size();i++)cout<<primes[i]<<endl;
		for(int i=0;i<primes.size();i++){
			for(int j=0;j<primes.size();j++){
				if(j>primes.size())break;
				if(i<j)break;
				sums.push_back(primes[i]+primes[j]);
			}
		}
		sort(sums.begin(),sums.end());
		cout<<sums[p-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
INF = 1000000

n = int(input())
m = int(input())
cost = [[INF] * (n + 1) for i in range(n + 1)]

for i in range(m):
    ai, bi, ci, di = (int(s) for s in input().split(','))
    cost[ai][bi] = ci
    cost[bi][ai] = di

x1, x2, y1, y2 = (int(s) for s in input().split(','))

for k in range(1, n + 1):
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            if cost[i][j] > cost[i][k] + cost[k][j]:
                cost[i][j] = cost[i][k] + cost[k][j]

print(y1 - y2 - cost[x1][x2] - cost[x2][x1])

Measured memory_bytes: 6740
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    string s;cin>>s;
    int dp[SZ(s)+1][2];
	REP(i,2)dp[0][i]=0;
    REP(i,SZ(s)){
        int d=s[i]-'0';
        dp[i+1][0]=min(dp[i][0]+d,dp[i][1]+d+2);
        dp[i+1][1]=min(dp[i][0]+9-d,dp[i][1]+9-d);
    }
    cout<<min(dp[SZ(s)][0],dp[SZ(s)][1]+2)<<endl;
}

Measured memory_bytes: 17028
#!/usr/bin/env python3

from itertools import product

def main():
    a, b, c, d = map(int, input())
    for x, y, z in product(("+", "-"), repeat=3):
        eq = "a{x}b{y}c{z}d".format(x=x, y=y, z=z)
        val = eval(eq)
        if val == 7:
            print("{a}{x}{b}{y}{c}{z}{d}=7".format(x=x, y=y, z=z, a=a, b=b, c=c, d=d))
            return

main()


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(void) {
	int k, n; cin >> k >> n;
	vector<int> v(n);
	rep(i, n)cin >> v[i];
	sort(ALL(v), greater<>());
	int res = v[0] - 1;
	for (int i = 1; i < n; i++) {
		res -= v[i];
	}
	cout << max(res, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int ans = (int)Math.ceil((double)n/((2 * m)+1));
        System.out.println(ans);

    }
}



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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) {
        int x;
        cin >> x;
        x--;
        a[i] = x;
    }

    int passed[n] = {0};
    int ans = 1, i = 0;

    while (a[i] != 1) {
        passed[i] = 1;
        i = a[i];
        ans++;
        if (passed[i]) {
            ans = -1;
            break;
        }
    }

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


Measured memory_bytes: 4416
#include<bits/stdc++.h>
#define ll long long
#define MN 18
#define MX (1<<18)
#define MM 2000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
bool b[MN+1][MN+1][MX+5];ll f[MN+1][MN+1][MX+5];
int n,A[MN+5],id[MM+5][MM+5],cnt;
ll Solve(int l,int r,int x,int y)
{
    if(l+1==r) return 0;
    if(!id[x][y]) id[x][y]=++cnt;
    int a=id[x][y];ll mn=1LL<<60;
    if(b[l][r][a]) return f[l][r][a];b[l][r][a]=1;
    for(int j=l+1;j<r;++j) mn=min(mn,Solve(l,j,x,x+y)+Solve(j,r,x+y,y)+1LL*(x+y)*A[j]);
    return f[l][r][a]=mn;
}
int main()
{
    n=read();
    for(int i=1;i<=n;++i) A[i]=read();
    printf("%lld\n",Solve(1,n,1,1)+A[1]+A[n]);
    return 0;
}

Measured memory_bytes: 360320
from collections import Counter
def rearange(x):
    counter=Counter(x)
    x_=''
    for i in range(26):
        num=ord('a')+i
        x_+=chr(num)*counter[chr(num)]
    return x_

s=input()
t=input()

s_=rearange(s)
t_=rearange(t)
t_=list(t_)
t_.sort(reverse=True)
t_=''.join(t_)
if s_<t_:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3316
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
P<int,int> p[300005]; 
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x,y,lx,ly,lz;
	cin>>x>>y>>lx>>ly>>lz;
	int t,len=0;
	FOR(i,1,lx){
		cin>>t;
		p[++len]=MP(t,1);
	}
	FOR(i,1,ly){
		cin>>t;
		p[++len]=MP(t,2);
	}
	FOR(i,1,lz){
		cin>>t;
		p[++len]=MP(t,3);
	}
	sort(p+1,p+len+1,greater<P<int,int> >());
	int ans=0;t=0;
	FOR(i,1,len){
		if(p[i].S==1){
			if(!x)continue;
			x--;
		}else if(p[i].S==2){
			if(!y)continue;
			y--;
		}else t++;
		ans+=p[i].F;
		if(t==x+y)break;
	}
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

    ll X;
    cin >> X;
    for(ll ans = 1; ans <= 100000000; ans++) {
        if(ans * (ans + 1) >= 2 * X) {
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}


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

int main() {

  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());

    cout << d.at(N/2)-d.at(N/2-1) << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,t[105],m,p,x,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>t[i];
    }
    cin>>m;
    for(int j=1;j<=m;j++)
    {
        cin>>p>>x;
       long long temp=t[p];
        t[p]=x;
        for(int k=1;k<=n;k++)
        {
            sum+=t[k];
        }
        t[p]=temp;
        printf("%lld\n",sum);
        sum=0;
    }
return 0;
}



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

int main() {
  int N;
  cin >> N;
  int T[N], A[N];
  for (int i=0 ; i<N ; i++) {
    cin >> T[i] >> A[i];
  }
  long long ans1 = 1, ans2 = 1;
  for (int i=0 ; i<N ; i++) {
    long long n1 = (ans1 % T[i] == 0) ? ans1 / T[i] : ans1 / T[i] + 1;
    long long n2 = (ans2 % A[i] == 0) ? ans2 / A[i] : ans2 / A[i] + 1;
    ans1 = T[i] * max(n1, n2);
    ans2 = A[i] * max(n1, n2);
  }
  cout << ans1 + ans2 << endl;
}


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

int main(void)
{
 
  char s[11];
  char t[11];
  char u[11];
  int a;
  int b;
  scanf("%s %s",s,t);
  scanf("%d %d",&a,&b);
  scanf("%s",u);

  if(strcmp(s,u)==0){
    a--;
  }

  if(strcmp(t,u)==0){
    b--;
  }

  printf("%d %d",a,b);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[103],ans;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
	cin>>a[i];
    for(int i=1;i<=n-1;i++)
	for(int j=i+1;j<=n;j++)
	    ans+=a[i]*a[j];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................


   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  //aint n=int_v(read());
	        		  long x=long_v(read());
	        		  Map<Long,Integer> map=new HashMap<>();
	        		  for(int i=-1000;i<=1000;i++){
	        		  	long xx=(long)i*i*i*i*i;
	        		  	map.put(xx,i);
	        		  }
	        		  for(int i=-1000;i<=1000;i++){
	        		  	long xx=(long)i*i*i*i*i+x;
	        		  	if(map.get(xx)!=null){
	        		  		out.write(map.get(xx)+" "+i);
	        		  		out.flush();
	        		  		break;
	        		  	}
	        		  }
	        		  //out.write(res+"");
	        	
	        		// if(n[0]>0){out.write("Yes");}
	        		 //else{out.write("No");}
                      //out.flush();
	        		 
	}
}
	       
	          



	
  





Measured memory_bytes: 37032
n = int(input())

a = list(map(int, input().split()))
hasZero = False
for x in a:
    if x == 0:
        hasZero = True
if hasZero:
    print(0)
    exit(0)
res = 1
limits = 10**18
for x in a:
    res *= x
    if res > limits:
        res = -1
        break
print(res)

Measured memory_bytes: 84564
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

#define N_MAX 200001

using namespace std;

long long int N, K;
int A[N_MAX], F[N_MAX];

bool func(long long int time)
{
	long long int k = 0;
	for (int i = 0; i < N; i++){
		k += max((long long int)0, A[i] - time / F[N - i - 1]);
	}

	return k <= K;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	scanf("%lld%lld", &N, &K);
	int maxA = -1, maxF = -1;
	for (int i = 0; i < N; i++){
		scanf("%d", A + i);
		maxA = max(maxA, A[i]);
	}
	for (int i = 0; i < N; i++){
		scanf("%d", F + i);
		maxF = max(maxF, F[i]);
	}

	sort(A, A + N);
	sort(F, F + N);

	long long int left = 0, right = (long long int)maxA*(long long int)maxF;
	while (right - left>1){
		if (func((left + right) / 2)){
			right = (left + right) / 2;
		}
		else{
			left = (left + right) / 2;
		}
	}

	if (func(left)){
		right = left;
	}
	printf("%lld", right);

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#ifdef Debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#else
#define dump(x)
#endif

int main(){
	string s;
	while(cin>>s){
		string str="";
		rep(i,s.size()){
			if(s[i]=='A'||s[i]=='Z')str+=s[i];
		}
		string ans="";
		rep(i,str.size()-1){
			if(str[i]=='A'&&str[i+1]=='Z'){
				ans+="AZ";
			}
		}
		if(ans.size())
			cout<<ans<<endl;
		else cout<<"-1"<<endl;

	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

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

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

    vector<int> nums(n);
    rep(i, n){
        cin >> nums[i];
        nums[i] -= (i+1);
    }

    sort(nums.begin(), nums.end());

    int b = nums[n/2];

    long long out = 0;
    rep(i, n) out += abs(nums[i] - b);

    cout << out << endl;
}


Measured memory_bytes: 1024
n = int(input())
G = [[] for _ in range(n)]
d = {}
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
    d[(a,b)] = d[(b,a)] = i

k = 0
ans = [None]*(n-1)

stack = [(0,-1)] #node, par

while stack:
    now,pre = stack.pop()
    color = 1
    for nex in G[now]:
        if nex == pre:continue
        stack.append((nex,now))
        if pre != -1:
            if color == ans[d[(now,pre)]]:
                color += 1
        ans[d[(now,nex)]] = color
        k = max(k,color)
        color += 1

print(k)
print(*ans, sep="\n")

Measured memory_bytes: 52760
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

C = sorted(Counter(A).items())
M = len(C)

if C[0][1] > 2:
    print('Impossible')
    exit()

is2src = C[0][1] == 2
src = C[0][0]
depth = src - is2src + 1

if not is2src and C[1][1] < 2:
    print('Impossible')
    exit()

if len(C) != depth:
    print('Impossible')
    exit()

for i, (k, v) in enumerate(C[1:], 1):
    prevk, prevv = C[i-1]
    if k != prevk + 1:
        print('Impossible')
        exit()
    if 2 > v:
        print('Impossible')
        exit()
print('Possible')


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using pii = pair<int, int>;

inline void Main() {
  // code
  const int MAX_N = 2 * 1e5;
  int n;
  pii ba[MAX_N];
  cin >> n;
  rep(i, n) cin >> ba[i].second >> ba[i].first;
  sort(ba, ba+n);

  long long t = 0;
  rep(i, n) {
    t += ba[i].second;
    if(t > ba[i].first) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


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

#define ll long long

const int MaxN(100003);
int a[MaxN], b[MaxN];
ll ans;

int main()
{
	int n, m;
	cin >> n >> m;
	if(n >= m)
		return puts("0"), 0;
	for(int i = 1; i <= m; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + 1 + m);
	for(int i = 2; i <= m; i++)
		ans += (b[i - 1] = a[i] - a[i - 1]);
	sort(b + 1, b + m, greater<int>());
	for(int i = 1; i < n; i++)
		ans -= b[i];
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    r = sum(i for i in range(1, n+1) if i % 3 > 0 and i % 5 > 0)

    return r


print(main())





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

int main() {
  int A,B,C;
  cin >> A >> B >>C;
  if(A==B&&B==C){
  cout << "1" << endl;
  }else if(A==B||B==C||A==C){
  cout << "2" << endl;
  } else {
    cout << "3" << endl;}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n,k=1;
    cin >> n;
    vector<char> s(n);
    cin >> s[0];
    for(int i=1;i<n;i++)
    {
        cin>> s[i];
        if(s[i-1]!=s[i]) {
            k++;
        }
    }
    cout << k;
}

Measured memory_bytes: 384
// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	string s, t; cin >> s >> t;
	int n = s.size();
	int ans = 0;
	for(int i = 0; i < n; i++) {
		ans += (s[i] != t[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3800
#include<stdio.h>
#include<stdlib.h>
#define N 100000
typedef struct {
  int p,k,dep;
  int *c;
} Node;
int main(){
  int i,j,n,id;
  Node T[N],t;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    T[i].p = -1;
    T[i].dep = 0;
  }
  for(i=0; i<n; i++){
    scanf("%d",&id);
    scanf("%d",&T[id].k);
    T[id].c = (int *)malloc(sizeof(int)*T[id].k);
    for(j=0; j<T[id].k; j++){
      scanf("%d",&T[id].c[j]);
      T[T[id].c[j]].p = id;
    }
  }
  for(i=0; i<n; i++){
    t = T[i];
    while(1){
      if(t.p==-1) break;
      T[i].dep++;
      t = T[t.p];
    }
  }
  for(i=0; i<n; i++){
    if(T[i].dep==0){
      printf("node %d: parent = %d, depth = %d, root, [",i,T[i].p,T[i].dep);
      for(j=0; j<T[i].k-1; j++) printf("%d, ",T[i].c[j]);
      if(T[i].k!=0) printf("%d]\n",T[i].c[j]);
      else printf("]\n");
    }
    else if(T[i].k!=0 && T[i].p!=-1){
      printf("node %d: parent = %d, depth = %d, internal node, [", i,T[i].p,T[i].dep);
      for(j=0; j<T[i].k-1; j++) printf("%d, ", T[i].c[j]);
      printf("%d]\n",T[i].c[j]);
    }
    else if(T[i].k==0) printf("node %d: parent = %d, depth = %d, leaf, []\n",i,T[i].p,T[i].dep);
  }
  return 0;
}

Measured memory_bytes: 6460
/**
 *      ABC 73 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-04 22:18:47
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    if (N / 10 == 9 || N % 10 == 9){
        cout << "Yes"; return 0;
    }
    else {
        cout << "No"; return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;

#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 1000000;


template<int mod>
struct ModInt {
    int x;
 
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
 
    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }
 
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
 
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
 
    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }
 
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }
 
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

using modint = ModInt<mod>;
modint f[d5];

void makef() {
    f[0] = 1;
    for (int i = 1; i < d5; i++) f[i] = f[i - 1] * i;
}
 
modint nCr(int n, int r){
    if(n < r) return 0;
    else if(r<0) return 0;
    return f[n] / (f[r] * f[n - r]);
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x,y;
    cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    int a = (2 * x - y) / 3;
    int b = (2 * y - x) / 3;
    makef();
    cout << nCr(a + b, b) << endl;
}


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

int par[100010];
int ra[100010];
void init(int s) {
	for (int i = 0; i < s; i++) {
		par[i] = i;
		ra[i] = 0;
	}
}

int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) {
		return;
	}
	if (ra[x] < ra[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (ra[x] == ra[y]) {
			ra[x]++;
		}
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

int main() {
	int n, m;
	cin >> n >> m;
	int p[n], x[m], y[m];
	for (int j = 0; j < n; j++) cin >> p[j];
	for (int j = 0; j < m; j++) cin >> x[j] >> y[j];
	init(n);
	for (int j = 0; j < m; j++) {
		unite(x[j] - 1, y[j] - 1);
	}
	int ans = 0;
	for (int j = 0; j < n; j++) {
		if (same(j, p[j] - 1)) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2176
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

int N;
int A, B, C;
vi l;
int ans;

void dfs(int n, vi use) {
    if (n >= N) {
        int a = 0, b = 0, c = 0;
        int cat = 0;
        REP(i,N) {
            switch (use[i]) {
            case 1:
                if (a > 0) cat++;
                a += l[i];
                break;
            case 2:
                if (b > 0) cat++;
                b += l[i];
                break;
            case 3:
                if (c > 0) cat++;
                c += l[i];
                break;
            default:
                break;
            }
        }
        if (a > 0 && b > 0 && c > 0) {
            ans = min(ans, cat * 10 + abs(a - A) + abs(b - B) + abs(c - C));
        }
        return;
    }

    REP(i,4) { // 0:Not Used, 1:A, 2:B, 3:C
        use[n] = i;
        dfs(n + 1, use);
    }
}

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

    cin >> N;
    cin >> A >> B >> C;
    l = vi(N); REP(i, N) cin >> l[i];
    
    ans = INF;
    vi use(N, 0);
    dfs(0, use);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
int a,b,answer;
a=1;
b=1;
for (a=1;a<10;a++)
{
b=1;
do
{
answer=a*b;
printf("%dx%d=%d\n",a,b,answer);
b++;
}
while (b<10);
}
return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        long H = sc.nextLong();
        long W = sc.nextLong();
        
        int ans = 0;
        for (int i = 0; i < N; i++) {
        	long h = sc.nextLong();
        	long w = sc.nextLong();
        	if (h >= H && w >= W) {
        		ans++;
        	}
        }
        
        System.out.println(ans);
    }
}	

Measured memory_bytes: 25428
import sys

input = sys.stdin.readline


def main():
    A, B = map(int, input().split())
    S = input().rstrip()

    is_valid = True
    for s in S[:A]:
        if s not in "0123456789":
            is_valid = False
    if S[A] != "-":
        is_valid = False
    for s in S[A + 1:]:
        if s not in "0123456789":
            is_valid = False

    ans = "Yes" if is_valid else "No"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060