akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

typedef unsigned long long ull;

#define QMAX 100000
typedef struct { ull s; char x, v; char t; } QUE;  // t:ステップ数
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r;
	int min;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		QUE t = que[i]; que[i] = que[min]; que[min] = t;
		min_heapify(min);
	}
}

void enq(ull s, int x, int v, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].x = x, que[i].v = v, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		i = min;
	}
}


#define HASHSIZ 200003
typedef struct { ull s; char v; } HASH;
HASH hash [HASHSIZ+3], *hashend  = hash +HASHSIZ;

int lookup(ull s)
{
	HASH *hp = hash + (int)(s % HASHSIZ);
	while (hp->s) {
		if (hp->s == s) return hp->v;
		if (++hp == hashend) hp = hash;
	}
	return -1;
}


void insert(ull s, char v)
{
	HASH *hp = hash + (int)(s % HASHSIZ);
	while (hp->s) {
		if (hp->s == s) { hp->v = v; break; }
		if (++hp == hashend) hp = hash;
	}
	hp->s = s, hp->v = v;
}

#define GOAL 0x123456789ABCDEF0LL
#define ABS(a) ((a)>=0?(a):-(a))

int hi[16] = {2,3,3,2,3,4,4,3,3,4,4,3,2,3,3,2};
int to[16][4] = {
{1,4},{0,2,5},{1,3,6},{2,7},
{0,5,8},{1,4,6,9},{2,5,7,10},{3,6,11},
{4,9,12},{5,8,10,13},{6,9,11,14},{7,10,15},
{8,13},{9,12,14},{10,13,15},{11,14}};
double magic = 1;

void toArray(char *p16, ull s)
{
	int i;

	for (i = 15; i >= 0; i--) {
		p16[i] = s & 0xf, s >>= 4;
	}
}

ull swap(char *p16, int zero, int nx)
{
	int i;
	ull res;

	res = 0;
	for (i = 0; i < 16; i++) {
		res <<= 4;
		if      (i == zero) res |= p16[nx];
		else if (i == nx)   res |= p16[zero];
		else                res |= p16[i];
	}
	return res;
}

int eval(ull s)
{
	int i, r1, c1, r2, c2;
	int e, t;

	e = 0;
	for (i = 15; i >= 0; i--) {
		t = s & 0xf, s >>= 4;
		if (t) {
			t--;
			r1 = i >> 2, c1 = i & 3;
			r2 = t >> 2, c2 = t & 3;
			e += ABS(r1-r2) + ABS(c1-c2);
		}
	}
	return (int)(e*magic);

}

int main()
{
	int i, x, nx, v, nv, t;
	ull s, ns;
	char p16[16];

	s = 0; for (i = 0; i < 16; i++) {
		scanf("%d", &t);
		p16[i] = t, s <<= 4, s |= t;
		if (t == 0) x = i;
	}
	qsize = 0;
	t = eval(s);
	if      (t <= 22) magic = 1.12;
	else if (t <= 25) magic = 1.14;
	else              magic = 1.28;

	enq(s, x, 0, (int)(t*magic));

	insert(s, 0);
	while (qsize) {
		s = que[0].s, x = que[0].x, v = que[0].v;

    que[0] = que[--qsize];
    min_heapify(0);

		if (s == GOAL) break;
		if (lookup(s) < v) continue;

		toArray(p16, s);
		for (i = 0; i < hi[x]; i++) {
			nx = to[x][i];
			ns = swap(p16, x, nx), nv = v+1;
			t = lookup(ns);
			if (t < 1 || nv < t) {
				enq(ns, nx, nv, eval(ns)+v);
				insert(ns,  nv);
			}
		}
	}
	printf("%d\n", v);
	return 0;
}



Measured memory_bytes: 6100
#include <iostream>
#include <queue>
#include <cmath>
#define LL long long
#define INF 100000000000000000

using namespace std;

int main(void){
  LL N;
  cin >> N;

  //N = p*qとなるp, qのうち，p+qが最小になるようなものを求めればよい
  LL min = INF;
  LL p, q;
  for(LL i=1; i<=sqrt(N); i++){
    if(N%i == 0){
      //p*q = Nとなるp, qの定義
      p = i;
      q = N/i;
      //p+qの最小値を更新していく
      if( p + q < min)
	min = p + q;
    }
  }

  //(1, 1)が初期値なので2を引いて出力
  cout << min - 2 << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(int argc, char *argv[]){
  int a,b;
  scanf("%d %d", &a, &b);
  switch( (a<b) + 2*(a>b) ){
  case 0 : printf("a == b\n"); break;
  case 1 : printf("a < b\n"); break;
  case 2 : printf("a > b\n"); break;
  default : printf("Error\n"); break;
  }
  return(0);
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define N 51
#define INF 1e9
using namespace std;
typedef long long ll;
int n,num[3];
ll rG[N];

ll mem[N][110],used[N][110];
ll dfs(int pos,int dep){
  if(dep==0) return (1LL<<pos);
  if(used[pos][dep]++) return mem[pos][dep];

  ll res=0;
  for(int i=0;i<n;i++)
    if(rG[pos]&(1LL<<i))res|=dfs(i,dep-1);
  return mem[pos][dep]=res;
}

  
int bfs(){
  vector<int> D(N,INF);
  int cnt[3][N]={};
  queue<int> Q;
  Q.push(n-1);
  D[n-1] = 0;
  
  while(!Q.empty()){
    int pos = Q.front();Q.pop();
    int cost = D[pos];
    if(pos==0) return cost;
    
    for(int k=0;k<3;k++){
      ll g = dfs(pos,num[k]);
      for(int i=0;i<n;i++) if((g>>i)&1) cnt[k][i] = 1;
    }

    for(int i=0;i<n;i++){
      if(!cnt[0][i]||!cnt[1][i]||!cnt[2][i]||D[i]<=cost+1)continue;
      Q.push(i);
      D[i] = cost+1;
    }
  }
  return 0;  
}

int main(){
  int m;
  cin>>n>>m;
  for(int i=0;i<3;i++)cin>>num[i];
  for(int i=0,a,b;i<m;i++)cin>>a>>b,rG[b-1]|=1LL<<(a-1);

  int ans = bfs();
  if(ans)cout<<ans<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  
  return 0;
}

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

#define _CRT_SECURE_NO_DEPRECATE 
#define endl "\n"
#define IOS ios::sync_with_stdio(false); cin.tie(nullptr);
#define sz(x) ((int)x.size())

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

#define REP(i, a, b) for(int i = a; i < b; i++)
#define IT(it, x) for(auto it : x)

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
 
int main()
{
   int n;
   string a, b;
   cin >> n >> a >> b;
   for(int i = 0; i < n; i++)
      cout << a[i] <<b[i];     
   return 0;
}

Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

ll ans;
map<pair<string,string>,int>m;
int a,b;
int n;

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n;
	string s;
	cin >> s;
	for(int i = 0;i < (1 << n);i++)
	{
		string a = "";
		string b = "";
		for(int j = 0;j < n;j++)
		{
			if(i & (1 << j)) a += s[j];
			else b += s[j];
		}
		m[mp(a,b)]++;
	}
	reverse(s.begin(),s.end());
	for(int i = 0;i < (1 << n);i++)
	{
		string a = "";
		string b = "";
		for(int j = 0;j < n;j++)
		{
			if(i & (1 << j)) a += s[j];
			else b += s[j];
		}
		ans += m[mp(b,a)];
	}
	rc(ans);
}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second

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

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	int k, x; cin >> k >> x;
	int kk = k;

	vector<int> ans;
	for (int i = x; k && i <= 1000000; i++, k--)
		ans.pb(i);

	k = kk-1;
	for (int i = x-1; k && i >= -1000000; i--, k--)
		ans.pb(i);

	sort(ans.begin(), ans.end());
	for (int i : ans) cout << i << ' ';
	cout << '\n';
	

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <functional>

using namespace std;

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

typedef vector<int> vi;

int main()
{
	int a[5];
	while(1){
		rep(i, 5){
			if(scanf("%d", &a[i]) == EOF)
				return 0;
		}
		sort(a, a+5, greater<int>());
		rep(i, 5){
			printf("%d", a[i]);
			if(i<4) printf(" ");
		}

		puts("");
	}
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

using Graph = vector<vector<int>>;

void dfs(int v, const Graph &G, vector<int> &res, vector<int> &used)
{
    used[v] = 1;
    for (auto to : G[v])
        if (used[to] == 0)
        {
            dfs(to, G, res, used);
        }
    res.push_back(v);
}

vector<int> topo_sort(const Graph &G)
{
    int V = G.size();
    vector<int> ide(V);
    for (int i = 0; i < V; i++)
    {
        for (auto to : G[i])
        {
            ide[to]++;
        }
    }
    vector<int> res;
    vector<int> used(V);
    for (int i = V - 1; i >= 0; i--)
    {
        if (ide[i] == 0)
        {
            dfs(i, G, res, used);
        }
    }
    if (res.size() == 0)
        res = {-1};
    reverse(res.begin(), res.end());
    return res;
}

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

    int n, m;
    cin >> n >> m;
    Graph g(n), rev(n);
    for (int i = 0; i < n - 1 + m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        rev[b].push_back(a);
    }
    vector<int> ts = topo_sort(g);
    vector<int> res(n, -1), pri(n);
    for (int i = 0; i < n; i++)
        pri[ts[i]] = i;
    res[ts[0]] = 0;
    for (int i = n - 1; i > 0; i--)
    {
        int v = ts[i];
        int ma = -1, idx = -1;
        for (auto u : rev[v])
        {
            if (pri[u] > ma)
            {
                ma = pri[u];
                idx = u;
            }
        }
        res[v] = idx + 1;
    }
    for (int i = 0; i < n; i++)
    {
        cout << res[i] << endl;
    }
}


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

bool is_prime(int &num)
{
    for (int i = 2; i < num; i++)
    {
        if (num % i == 0)
            return false;
    }
    return true;
}

void find_next_prime(int &x)
{
    bool found = false;

    for (;; x++)
    {
        if (is_prime(x) == true)
        {
            found = true;
        }
        if (found == true)
            break;
    }
    // return x;
}

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

    // int ans = find_next_prime(x);
    find_next_prime(x);
    cout << x << endl;
}

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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int n;
    cin>>n;
    int a[n+4];
    int xr=0;
    f(i,1,n)
    {
        cin>>a[i];
        xr=xr^a[i];
    }
    if(xr==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;

}





































Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 200000;

int n;
char c[N];
int r = 0;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n;
    
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        if (c[i] == 'R')
            r++;
    }
    
    int ans = 0;
    for (int i = 0; i < r; i++)
        ans += c[i] == 'W';
    
    cout << ans;
    
    return 0;
}


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

int main(){
    long int N,A,B;
    cin >> N >> A >> B;

    long int count,reg;
    count = N/(A+B);
    reg = N%(A+B);

    if(A == 0)
    {
        count = 0;
    }
    else if(reg<=A)
    {
        count = count*A + reg;
    }
    else
    {
        count = count*A + A;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=1;i<=n;i++)
#define endl   "\n"







int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double a,b;
    cin>>a>>b;




        cout<<ceil((b-1)/(a-1));







}

Measured memory_bytes: 3792
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
#define ll long long
const int maxn=2e5+5;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll ans[maxn];
vector<pair<int,ll> > head[maxn],tail[maxn];
struct node
{
    int l,r;
    ll maxx,lz;
}tree[4*maxn];
void push_up(int cur)
{
    tree[cur].maxx=max(tree[cur<<1].maxx,tree[cur<<1|1].maxx);
    return;
}
void build(int l,int r,int cur)
{
    tree[cur].l=l;
    tree[cur].r=r;
    if(l==r) return;
    int mid=(l+r)>>1;
    build(l,mid,cur<<1);
    build(mid+1,r,cur<<1|1);
    return;
}
void push_down(int cur)
{
    if(tree[cur].lz)
    {
        tree[cur<<1].maxx+=tree[cur].lz;
        tree[cur<<1].lz+=tree[cur].lz;
        tree[cur<<1|1].maxx+=tree[cur].lz;
        tree[cur<<1|1].lz+=tree[cur].lz;
        tree[cur].lz=0;
    }
    return;
}
void add(int l,int r,ll val,int cur)
{
    if(tree[cur].l>=l&&tree[cur].r<=r)
    {
        tree[cur].maxx+=val;
        tree[cur].lz+=val;
        return;
    }
    if(tree[cur].l>r||tree[cur].r<l)
        return;
    push_down(cur);
    add(l,r,val,cur<<1);
    add(l,r,val,cur<<1|1);
    push_up(cur);
    return;
}
ll query(int l,int r,int cur)
{
    if(tree[cur].l>=l&&tree[cur].r<=r)
        return tree[cur].maxx;
    if(tree[cur].l>r||tree[cur].r<l)
        return -INF;
    push_down(cur);
    ll res=max(query(l,r,cur<<1),query(l,r,cur<<1|1));
    push_up(cur);
    return res;
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int l,r;
        ll val;
        scanf("%d%d%lld",&l,&r,&val);
        head[l].push_back(make_pair(r,val));
        tail[r].push_back(make_pair(l,val));
    }
    ll ret=0;
    build(0,n,1);
    for(int i=1;i<=n;i++)
    {
        ll sum=0;
        for(int j=0;j<(int)head[i].size();j++)
            sum+=head[i][j].second;
        add(0,i-1,sum,1);
        for(int j=0;j<(int)tail[i-1].size();j++)
            add(0,tail[i-1][j].first-1,-tail[i-1][j].second,1);
        ans[i]=query(0,i-1,1);
        ret=max(ret,ans[i]);
        add(i,i,ans[i],1);
    }
    printf("%lld\n",ret);
    return 0;
}
/*
5 3
1 3 10
2 4 -10
3 5 10
 
3 4
1 3 100
1 1 -10
2 2 -20
3 3 -30
 
1 1
1 1 -10
 
1 5
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
 
6 8
5 5 3
1 1 10
1 6 -8
3 6 5
3 4 9
5 5 -2
1 3 -6
4 6 -7
 */


Measured memory_bytes: 39496
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int l;
    cin >> l;
    int cnt = 0;
    while(pow(2, cnt) <= l) cnt++;
    vector<vector<int>> ans;
    for(int i = 1; i < cnt; i++){
        ans.push_back({i, i + 1, 0});
        ans.push_back({i, i + 1, (int)pow(2, i - 1)});
    }
    int now = pow(2, cnt - 1) - 1;
    for(int i = cnt - 1; i > 0; i--){
        if(l - now > pow(2, i - 1)){
            ans.push_back({i, cnt, now + 1});
            now += pow(2, i - 1);
        }
    }
    cout << cnt << " " << ans.size() << endl;
    REP(i,ans.size()){
        cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << endl;
    } 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ALL(a) (a.begin(), a.end())
using ll = long long;
template<typename T> void Out(T x) { cout << x << endl; }
const int maxn = 2e5;
int dp[10][10];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    int l = i % 10;
    int h = i;
    int hh = i/ 10;
    while (hh) { h /= 10; hh /= 10; }
    dp[l][h]++;
  }
  ll res = 0;
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      res += dp[i][j] * dp[j][i];
  Out(res);
}


Measured memory_bytes: 256
import numpy as np
N, K, Q = map(int, input().split())
a = np.zeros(N)
for i in range(Q):
    A = int(input())
    a[A-1] += 1
for i in range(N):
    if a[i] > Q-K:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 21904
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000
/*
2019. 5.13
7.4 Counting Sort
*/

int main(){
    unsigned short *A, *B;

    int C[VMAX+1];
    int n, i, j;
    scanf("%d", &n);

    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);

    for(i = 0; i <= VMAX; i++) C[i] = 0;

    for(i = 0; i < n; i++){
        scanf("%hu", &A[i + 1]);  //  %hu for unsigned short
        C[A[i + 1]]++;
    }
    for(i = 1; i <= VMAX; i++) C[i] = C[i] + C[i - 1];

    for(j = 1; j <= n; j++){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }

    for(i = 1; i <= n; i++){
        if (i > 1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 9564
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int n,m;
    cin >> n >> m;
    map<int,int> sum;
    rep(i,0,n){
	int k;
	cin >> k;
	rep(j,0,k){
	    int a;
	    cin >> a;
	    sum[a]++;
	}
    }
    int ans = 0;
    rep(i,1,m+1){
	if(sum[i] == n)ans++;
    }
    P(ans);
    return  0;
}


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

string ans;
int func(ll a){
	
	if(a <= 0) return 0;
	a--;
	ans += 'a'+ a%26;
	a /= 26;
	return func(a);

}

 
int main(){
	ll N;
	cin >> N;
	func(N);
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll MOD = 1e9+7;
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        res %= MOD;
        a = a * a;
        a %= MOD;
        b >>= 1;
    }
    return res;
}
ll inverse(ll a) {
	return binpow(a, MOD - 2);
}

ll dp [5005][5005];

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	string S; cin >> S; int M = S.size();

	// dp[i][j] = pos i, rem j
	dp[0][N] = 1;

	R0F(j, N) {
		F0R(i, 5005) {
			// insert
			if (i > 0) 
				dp[i][j] += 2 * dp[i-1][j+1];
			// erase
			if (i + 1 < 5005)
				dp[i][j] += dp[i+1][j+1];
			// non functional erase
			if (i == 0) {
				dp[i][j] += dp[i][j+1];
			}
			dp[i][j] %= MOD;
		}
	}
	print(dp[M][0] * inverse(binpow(2, M)) % MOD);
}

Measured memory_bytes: 195968
fn main() {
    let x: i64 = read();
    println!("{:?}", x / 500 * 1000 + x % 500 / 5 * 5);
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
M=8**7
m=M*476+1
f=[1]*M
g=[1]*M
h=[1]*M
i=2
while i<M:f[i],h[i]=f[i-1]*i%m,-h[m%i]*(m//i)%m;g[i]=g[i-1]*h[i]%m;i+=1
a=0
b=j=1
A,B=map(int,input().split())
if A<B:A,B=B,A
while j<=B:a+=b*f[A+B-j]*g[B-j];b=b*2%m;j+=1
print((a*f[B]*g[A+B]+A)%m)

Measured memory_bytes: 122632
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N,X,Y;
    cin >> N >> X >> Y;
    int i,j;
    int ans[N];
    for(j=1;j<N;j++)ans[j]=0;
    for(i=1;i<N;i++){
        for(j=i+1;j<N+1;j++){
            if(max(i-X,X-i)+1+max(j-Y,Y-j)<j-i)ans[max(i-X,X-i)+1+max(j-Y,Y-j)]++;
            else{ans[j-i]++;}
        }
    }
    for(j=1;j<N;j++)cout << ans[j] << endl;
    }

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int main(){
	long long int n,k;
	long long int ans=0;
	scanf("%lld%lld",&n,&k);
	ans+=(n/k)*(n/k)*(n/k);
	if(k%2==0){
		long long int x=n/(k/2);
		ans+=((x+1)/2)*((x+1)/2)*((x+1)/2);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
int dep[100010];
int par[100010][19];
vector<int> g[100010];
void dfs(int v,int u,int d){
  dep[v]=d;
  for(int i=0; i<g[v].size(); i++){
    int w=g[v][i];if(w==u) continue;
    par[w][0]=v;dfs(w,v,d+1);
  }
}
int lcp(int a,int b){
  if(dep[a]<dep[b]) swap(a,b);
  for(int i=0; i<19; i++){
    if(((dep[a]-dep[b])&(1<<i))) a=par[a][i];
  }
  if(a==b) return a;
  for(int i=18;i>=0;i--){
    if(par[a][i]!=par[b][i]) a=par[a][i],b=par[b][i];
  }
  return par[a][0];
}
void Main() {
  int n;
  while(R n && n) {
    rep(i,n) g[i].clear();
    int aa[n],bb[n],sum=0;
    rep(i,n-1) R aa[i];
    rep(i,n-1) {
      R bb[i];
      sum+=bb[i];
    }
    vector<P> v[n];
    rep(i,n-1) {
      v[i+1].pb(P(aa[i]-1,bb[i]));
      v[aa[i]-1].pb(P(i+1,bb[i]));
      g[i+1].pb(aa[i]-1);
      g[aa[i]-1].pb(i+1);
    }
    memset(par,0,sizeof(par));
    dfs(0,-1,0);
    for(int i=0; i<18; i++) for(int j=0; j<n; j++) par[j][i+1]=par[par[j][i]][i];
    int d[n][n];
    rep(i,n)rep(j,n)d[i][j]=MAX;
    rep(j,n) {
      d[j][j]=0;
      queue<int> que;
      que.push(j);
      while(!que.empty()) {
        int x=que.front();que.pop();
        rep(i,v[x].size()) {
          int y=v[x][i].F;
          if(d[j][y]>d[j][x]+v[x][i].S) {
            d[j][y]=d[j][x]+v[x][i].S;
            que.push(y);
          }
        }
      }
    }
    int ans=MAX,all=sum;
    rep(i,n) if(v[i].size()==1) sum-=v[i][0].S;
    rep(i,n) {
      if(v[i].size()==1) continue;
      REP(j,i,n) {
        if(v[j].size()==1) continue;
        int k=lcp(i,j);
        ans=min(ans,all+sum*2-d[i][k]-d[k][j]);
      }
    }
    pr(ans); 
  }
}

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


Measured memory_bytes: 13620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

char toLowerCase(char c){
  if(isLowerCase(c)){
    return c;
  }else{
    return c+'a'-'A';
  }
}
char toUpperCase(char c){
  if(isLowerCase(c)){
    return c-('a'-'A');
  }else{
    return c;
  }
}
ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
void func(vector<int>& l, int depth, int idx){
  ;
}
int main() {
  int n;
  string s;
  int k;
  cin>>n>>s>>k;
  char c=s[k-1];
  for(int i=0;i<s.size();i++){
    if(s[i]!=c){
      s[i]='*';
    }
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
ll i,j,k,l,ii,jj;
ll n,m;
ll a,b;
ll x[100005];
ll ans=0;
ll v=-1,w;
 
int main(){
    cin>>n>>m;

	for(i=0;i<m;i++){
		cin>>a>>b;
		x[a]++;
		x[b]++;
	}
	bool flag=false;
	for(i=1;i<=n;i++){
		if(x[i]%2==1)flag=true;
	}
	if(flag)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;


	return 0;
}

Measured memory_bytes: 5760
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let vec: Vec<i8> = line.split_whitespace().map(|s| s.parse::<i8>().unwrap()).collect();
    let (a, b, c) = (vec[0], vec[1], vec[2]);
    println!("{}", if a < b && b < c {"Yes"} else {"No"});
}


Measured memory_bytes: 5028
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int t = 0, y = 0, x = 0;
    rep (i, n) {
        int tt, yy, xx; cin >> tt >> yy >> xx;
        if (abs(y - yy) + abs(x - xx) > tt - t || (abs(y - yy) + abs(x - xx)) % 2 != (tt - t) % 2) {
            cout << "No\n";
            return 0;
        }
        t = tt; y = yy; x = xx;
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

 int n,q;
 cin>>n>>q;
 queue<int>v[n];
 while(q--){
  long int x;
  int a,t;
  cin>>a>>t;
  if(a==0){
    cin>>x;
    v[t].push(x);
  }
  else if(a==1){
          if(!v[t].empty())
    cout<<v[t].front()<<endl;
  }
  else{
    if(!v[t].empty())
        v[t].pop();
  }

 }
    }



Measured memory_bytes: 4216
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

#define ALL(V) (V).begin(),(V).end()

using namespace std;

typedef pair<int,int> ii_t;

#define MAX 100010
#define RMAX 1000
char is_prime[MAX];
#define PMAX 100000
int prime[PMAX];

bool check(int j,int m, vector<int> &s, vector<int> &c){
    ostringstream oss;
    oss << j;
    string buf = string(oss.str());
    for (int i=0;i<m;i++) {
        if (buf[s[i]-1] != '0' + c[i])
            return false;
    }
    return true;
}
int main() {

  int n,m;
  char isUpdate[3] = {0};

  cin >> n >> m;
  vector<int> s(m),c(m);
  int answer = -1;
  for (int i=0;i<m;i++) {
      cin >> s[i] >> c[i];
  }

  int start= (n==1?0:(n==2?10:100));
  int end= (n==1?9:(n==2?99:999));
  for (int j=start;j<=end;j++) {
      if (check(j, m, s, c)){
          answer = j;
          break;
      }
  }

    cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fint register int
#define h 5001
#define p 3457893
#define int long long
using namespace std;
inline int dis(int x,int y,int d);
signed main()
{
	int n,d;
	cin>>n>>d;
	int ans=0,x,y;
	for(fint i=1;i<=n;i++)
	cin>>x>>y,ans+=dis(x,y,d);
	cout<<ans;
	return 0;
} 

inline int dis(int x,int y,int d)
{
	if((double)sqrt(x*x+y*y)<=d)
	return 1;
	return 0;
}

Measured memory_bytes: 3640
//B - Exponential
#include<bits/stdc++.h>
using namespace std;
int main(){
	int jj(int b,int p);
	int x,maxv=0;
	cin>>x;
	if(x==1){
		cout<<1;
		return 0;
	}
	for(int i=2;i<=int (sqrt(x));++i){
		for(int j=2;j<=10;++j){
			if(jj(i,j)<=x&&jj(i,j)>maxv)
				maxv=jj(i,j);
		}
	}	
	cout<<maxv;
	return 0;
}
int jj(int i,int j){
	int ans=1;
	for(int k=1;k<=j;k++){
		ans*=i; 
	}
	return ans;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  char a,b,c;
  cin >> a >> b >> c;
  int cnt=0;
  if(a=='o') cnt++;
  if(b=='o') cnt++;
  if(c=='o') cnt++;
  cout << 700+cnt*100 << "\n";
  
  return 0;
}


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

struct matrix {int r, c;};
typedef matrix M;
#define v vector
typedef v<int> vi;
typedef v<vi> vvi;
typedef v<M> vm;

vm m;
vvi t;

int McM(int b, int e) {
	int r = t[b][e];
	if (r != INT_MAX)
		return r;
	if (b == e)
		r = 0;
	else
		for (int i = b; i < e; i++)
			r = min(r, McM(b, i) + McM(i + 1, e) + m[b].r * m[i].c * m[e].c);
	t[b][e] = r;
	return r;
}

int main() {
	int n;
	cin >> n;
	m = vm(n);
	t = vvi(n, vi(n, INT_MAX));
	for (M &x: m)
		cin >> x.r >> x.c;
	cout << McM(0, n - 1) << endl;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

const int N = 1e5+23;
const int mod = 1e9+7;

long long fact[N];
int f[N];

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	fact[0] = 1;
	f[0] = -1;
	for (int i = 1; i < N; ++i) {
		fact[i] = fact[i-1]*i%mod;
		f[i] = -1;
	}
}

int a[N];

long long binpow(long long b, long long e) {
	if (!e) return 1;
	if (e%2) return b*binpow(b, e-1)%mod;
	return binpow(b*b%mod, e/2);
}

long long C(int n, int k) {
	if (k > n) return 0;
	return fact[n]*binpow(fact[k], mod-2)%mod*binpow(fact[n-k], mod-2)%mod;
}

void solve() {
	int n; scanf("%d", &n);
	int d = -1;
	for (int i = 0; i <= n; ++i) {
		scanf("%d", a+i);
		if (f[a[i]] == -1) {
			f[a[i]] = i;
		} else {
			d = i-f[a[i]];
		}
	}
	debug(d);
	for (int k = 1; k <= n+1; ++k) {
		printf("%lld\n", (C(n+1, k)-C(n-d, k-1)+mod)%mod);
	}
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 2816
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::string s0;
    std::cin >> s0;
    std::vector<int64_t> m0(26);
    for (size_t i = 0; i < s0.size(); ++i) {
        m0[s0[i]-'a']++;
    }

    for (decltype(N) j = 0; j < N-1; ++j) {
        std::string s;
        std::cin >> s;
        std::vector<int64_t> m(26);

        for (size_t i = 0; i < s.size(); ++i) {
            m[s[i]-'a']++;
        }
        for (size_t i = 0; i < 26; ++i) {
            m0[i] = std::min(m0[i], m[i]);
        }
    }

    for (size_t i = 0; i < 26; ++i) {
        for (size_t c = 0; c < m0[i]; ++c) {
            char cc = i+'a';
            std::cout << cc;
        }
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
int GCD(int a, int b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
 
    int main(){
      char c;
      cin >> c;
      if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o')cout << "vowel" << endl;
      else cout << "consonant" << endl;
      return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin>>n>>m;
  vector<int>num(2*m);
  vector<int>count(n);
  for(int i=0;i<2*m;i++)
    cin >> num.at(i);
  for(int i1=0;i1<2*m;i1++){
      count.at(num.at(i1)-1)++;
  }
      
  for(int i=0;i<n;i++)
    cout << count.at(i) <<endl;
}

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


#define MOD 1000000007
#define debug(x) cout<<"x :"<<x<<endl;
//#define case(t,ans) cout<<"Case #"<<t<<": "<<ans<<endl;
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define for_it(it,s) for (auto it = s.begin(); it != s.end(); it++)
#define for_each(r,s) for(auto r:s)

#define all(s) s.begin(),s.end()
#define rall(s) s.end(),s.begin()
#define F first
#define S second
#define PB push_back
#define pb pop_back
#define EB emplace_back
#define pf push_front

#define fill0(arr) memset(arr,0,sizeof(arr))
#define filln(arr) memset(arr,-1,sizeof(arr))
#define MP make_pair
#define vi vector<int>
#define vll vector<ll>
#define vf vector<float>
#define vd vector<ld>
#define precision(x) cout<<fixed<<setprecision((x));
 


#define pi pair<int,int> 
#define ll long long 
#define ld long double
#define endl "\n"
//typedef long long ll;
//typedef vector<int> vi;
//typedef pair<int,int> pi;
//sort(a, a+n);
//reverse(a, a+n);
//random_shuffle(a, a+n);

const ll mod=1e9 + 7;




# define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define trace1(x)                cerr << #x << ": " << x << "\n";
# define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
# define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
# define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";


#define case(i) cout<<"Case "<<i<<": ";
using namespace std;


template<typename T>
T gcd(T u, T v)
{
    return u%v==0?v:gcd(v,u%v);
}




void solve();
int main(){
  //  #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
   // freopen("error.txt", "w", stderr);
   // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    clock_t launch=clock();
    for(ll i=1;i<=t;i++)
    {
       // case(i);
        solve();
    }
  
  
     clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
    // cerr<<"error is good"<<endl;
    return 0;
}

void solve()
{
   //code
    int n;
    cin>>n;
    
    int arr[n];
    unordered_set<int> s;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        s.insert(arr[i]);
    }
    if(s.size()==n)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    
	
    
}




Measured memory_bytes: 9288
// https://atcoder.jp/contests/code-festival-2017-qualc/tasks/code_festival_2017_qualc_c
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut counts = vec![0; 3];
    for &ch in s.iter() {
        counts[ch.to_digit(36).unwrap() as usize - 10] += 1;
    }
    if counts.iter().max().unwrap() - counts.iter().min().unwrap() >= 2 {
        println!("NO");
        return;
    } else {
        println!("YES");
        return;
    }
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

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

    vector<long long> a(n);
    for(long long i = 0; i < n; i++){
        cin >> a[i];
    }

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

    for(long long i = 0; i < n-1; i++){
        if(a[i] + a[i+1] < 0){
            a[i] = -1*a[i];
            a[i+1] = -1*a[i+1];
        }
    }

    long long sum = 0;
    for(long long i = 0; i < n; i++){
        sum += a[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
      for(int i = 1; i <= 10; i++){
        if((n - 1000 * i) <= 0){
          System.out.println((n - 1000 * i) * -1);
          break;
        }
      }
    }

}

Measured memory_bytes: 35632
import Control.Monad
import Data.Array
import Data.Bool

main = sol <$> get <*> get >>= print

get = fmap read . words <$> getLine

sol :: [Integer] -> [Integer] -> Integer
sol [n,a] as = dp!(n,0)-1
  where
  bs = (subtract a) <$> as
  ar = listArray (1,n) bs
  mx = n*max (maximum bs) (-minimum bs)
  bnds = ((0,-mx),(n,mx))
  dp = array bnds $ (,) <*> f <$> range bnds
    where
    f (0,0) = 1
    f (0,_) = 0
    f (i,j) = dp!(i-1,j) + bool 0 (dp!(i-1,j-ar!i)) (inRange bnds (i-1,j-ar!i))

Measured memory_bytes: 48380
#include<stdio.h>


int main (void){
	int a = 0;
	int b = 0;

	scanf("%d",&a);
	scanf("%d",&b);
	
	if(b % a == 0){
		printf("%d\n",a + b);
	}
	else{
		printf("%d\n",b - a);
	}
}

Measured memory_bytes: 128
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9+7;

int gcd(int a, int b) {
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	
	ll g = gcd(c, d);
	ll ad = (a - 1) / c + (a - 1) / d - (a - 1) / (c*d / g);
	ll bd = b / c + b / d - b / (c*d / g);

	cout << (b - a + 1) - (bd - ad) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	cin>>n>>x;
	int i,a[n],b=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0;i<n;i++)
	{
		x=x-a[i];
		if(x>=0)
		{	
			b++;
		}
		if(x<=0)
		{
			break;
		}
	}
	
		for(i=n-1;i>=0;i--)
		{
			if(x>0)
			{
			    x=x-a[i];
			    b--;
		    }
			if(x<=0)
			{
				break;
			}
					
		}	

	cout<<b<<endl;	
}

Measured memory_bytes: 3576
#include<stdio.h>

int main(void){
  int a[6];
  int i, j;

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

for(i=0; i<5; i++){
  for(j=0; j<5; j++){
    if((a[i]-a[j])>a[5]){
        printf(":(\n");
        return 0;
    }
  }
}

printf("Yay!\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int ll
int n;
multiset <int> s;
vector <int> v;

void print_set()
{
	printf("Current in set\n");
	for (auto it:s)
	{
		printf("%lld ",it);
	}
	printf("\n");

	printf("Current in vector\n");
	for (auto it:v)
	{
		printf("%lld ",it);
	}
	printf("\n");
}
int32_t main()
{
	usecppio
	cin >> n;
	int maxel = 0;
	int val = (1LL<<n);
	for (int i = 0; i<val; i++)
	{
		int c;
		cin >> c;
		s.insert(c);
		maxel = max(maxel, c);
	}
	s.insert(0);
	v.push_back(maxel);
	s.erase(s.lower_bound(maxel));
	bool flag = true;
	for (int i = 0; i<n; i++)
	{
		for (int j = 0; j<(1LL<<i); j++)
		{
			auto u = s.lower_bound(v[j]);
			u--;
			//printf("Erase %lld by %lld\n",*u,v[j]);
			if (*u == 0)
			{
				flag = false;
				break;
			}
			v.push_back(*u);
			s.erase(u);
		}
		sort(all(v));
		//print_set();
	}
	flag &= (s.size()==1);
	cout << (flag?"Yes":"No") << '\n';

}



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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 main():
    N = I()
    A = LI()
    ans = 0
    for a in A:
        ans += (a-1)
    print(ans)

main()



Measured memory_bytes: 6320