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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	ll n;
	 cin>>n;
	 vector<ll>vect(n);
	 ll xor_all=0;
	 f(i,0,n)
	 {
	 	cin>>vect[i];
	 	xor_all^=vect[i];
	 }
	 for(int i=0;i<n;i++)
	 {
	 	cout<<(vect[i]^xor_all)<<" ";

	 }
	 cout<<"\n";
	 	



	
	return 0;
}

Measured memory_bytes: 4748
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>

typedef long long ll;

const ll INF=1E9+10;
const ll MAXN=1e5+10;
using namespace std;

ll par[2*MAXN]; 

struct NODE{
	ll len,a,b;
}node[2*MAXN];

struct NO{
	ll sit,order;
}x[MAXN],y[MAXN];

ll rk[MAXN];

bool cmp1(NO i,NO j){
	return i.sit<j.sit;
}
bool cmp2(NODE h,NODE k){
	return h.len<k.len;
}


ll find(ll a){//寻找根节点 
	if(rk[a]==a)	return a;
	else {
		rk[a]=find(rk[a]);
		return rk[a];
	} 
} 

ll Kruskal(ll ver,ll edge){//顶点数量、边数 
	ll tot=0,e=0;//目前的权值和已加入的边数
	
	//初始化前驱 
	for(ll i=1;i<=ver;i++){
		rk[i]=i;//最开始第i个顶点的集合是他自己 
	}
	
	for(ll i=1;i<=edge&&e<ver-1;i++){
		ll h=find(node[i].a);//a点根节点 
		ll k=find(node[i].b);//b点根节点 
		if(h!=k){//如果这两个点不在同一个集合中，说明可以加入这条边 
			tot+=node[i].len;//增加权值 
			e++;//增加边数 
			rk[h]=k; //合并这两个点到同一个集合 
		}
	}
	 
	return tot; 
}

 int main() {
 	ll n;
 	scanf("%lld",&n);
 	for(ll i=1;i<=n;i++){
 		scanf("%lld %lld",&x[i].sit,&y[i].sit);
 		x[i].order=i;
 		y[i].order=i;
	}
	sort(x+1,x+n+1,cmp1);
	sort(y+1,y+n+1,cmp1);
	 
	//一共有2*n-2条边从 1到2*n-2 
	for(ll i=1;i<n;i++){
		node[i].len=x[i+1].sit-x[i].sit;
		node[i].a=x[i+1].order;node[i].b=x[i].order;
		
		node[i+n-1].len=y[i+1].sit-y[i].sit;
		node[i+n-1].a=y[i+1].order;node[i+n-1].b=y[i].order;
	}
	
	sort(node+1,node+2*n-1,cmp2);
	
	//克鲁斯卡尔算法 
	ll ans=Kruskal(n,2*n-2);//顶点数量、边数 
	printf("%lld\n",ans);
	
 	return 0;
 }

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define M 100002
using namespace std;
vector<int> v[M];
int degree[M];
int costarray[M];

int fun2(int n){
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<v[i].size();j++){
			degree[v[i][j]]++;	
		}
	}
	queue<int> q;
	for(int i=1;i<=n;i++){
		if(degree[i]==0)q.push(i);
	}
	int m=0;
	while(!q.empty()){
		int t = q.front();q.pop();
		for(int i=0;i<v[t].size();i++){
			degree[v[t][i]]--;
			costarray[v[t][i]]=	max(costarray[v[t][i]],costarray[t]+1);
			m=max(m,costarray[v[t][i]]);
			if(degree[v[t][i]]==0)q.push(v[t][i]);			
		}
	}
  	for(int i=1;i<=n;i++){
      v[i].clear();
      degree[i]=costarray[i]=0;
    }
	return m;
}

void addedge(int i,int j){
	v[i].push_back(j);	
}


int main(){
	int n,m,x,y;
  	cin>>n>>m;
  	for(int i=0;i<m;i++){
      cin>>x>>y;
      addedge(x,y);
    }
	cout << fun2(n) <<endl;
	return 0;	

}

Measured memory_bytes: 9756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

class Program
{
    static int[] x;
    static long?[,,] memo;
    static long Solve(int i, int n, int sum)
    {
        if (sum == 0) { return (n == 0) ? 1 : 0; }
        if (i >= x.Length || n == 0) { return 0; }
        if (!memo[i, n, sum].HasValue)
        {
            long count = 0;
            if (sum >= x[i])
            {
                count += Solve(i + 1, n - 1, sum - x[i]);
            }
            count += Solve(i + 1, n, sum);
            memo[i, n, sum] = count;
        }
        return memo[i, n, sum].Value;
    }
    static void Main(string[] args)
    {
        var values = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = values[0];
        int A = values[1];
        x = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        memo = new long?[N, N + 1, A * N + 1];
        long count = 0;
        for (int i = 1; i <= N; ++i)
        {
            count += Solve(0, i, A * i);
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 43736
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int r, g, b;
  cin>>r>>g>>b;
  int a = 100*r+10*g+b;
  if(a%4==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



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

int main()
{
	long long N,M;
	cin >> N >> M;
	long long height[N];
	long long i;
	for(i = 0;i < N;i++)
	{
		cin >> height[i];
	}
	bool exist[N];
	for(i = 0;i < N;i++)
	{
		exist[i] = true;
	}
	for(i = 0;i < M;i++)
	{
		int tmpa,tmpb;
		cin >> tmpa >> tmpb;
		if(height[tmpa-1] > height[tmpb-1]) 
		{exist[tmpb-1] = false;}
		else if (height[tmpa-1] < height[tmpb-1]) 
		{exist[tmpa-1] = false;}
		else
		{
			exist[tmpa-1] = false;
			exist[tmpb-1] = false;
		}
	}
	long long ans = 0;
	for(i = 0;i < N;i++)
	{
		if(exist[i] == true) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 4504
#include <iostream>
#include<algorithm>
#include<vector>
#include<map>

#define pb push_back
#define mp make_pair

using namespace std;


long long a[200010];
   long long b[200010];


int main()
{
   int n;

   cin>>n;
   for( int i = 0;i<n;i++ ){
    cin>>a[i];
    b[i]=a[i]-i;
   }
   sort( b,b+n );
  // for(int i =0;i<n;i++)
  //  cout<<b[i] << " ";
//   cout<<endl;
   // za 5 : 3
   long long sum=0,ans;
   if( n%2==1 ) ans=b[ (n-1)/2 ];
   else ans=( b[ (n-1)/2]+b[(n-1)/2 + 1] )/2;

   for(int i=0;i<n;i++){
    sum+= abs(b[i]-ans );
   }
    cout<<sum<<endl;

   return 0;
}



















Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
const int N=(1<<19)+5;
int lim=1,M=924844033,a[N],r[N],fac[N],inv[N],b[N],tot,h[N],sz[N],g=5,gi=554906420,n,i,x,y,l;
struct node{
	int to,ne;
}e[N];
inline int mul(int x,int y){return 1ll*x*y%M;}
inline int inc(int x,int y){x+=y;if(x>=M)x-=M;return x;}
inline int dec(int x,int y){x-=y;if(x<0)x+=M;return x;}
void add(int x,int y){e[++tot]={y,h[x]},h[x]=tot;}
int pw(int x,int y){
	int z=1;
	for (;y;y>>=1,x=1ll*x*x%M)
		if (y&1) z=1ll*z*x%M;
	return z;
}
int Inv(int x){return pw(x,M-2);}
void dfs(int u,int fa){
	sz[u]=1;
	for (int i=h[u],v;i;i=e[i].ne)
		if ((v=e[i].to)!=fa) dfs(v,u),sz[u]+=sz[v],a[sz[v]]++;
	a[n-sz[u]]++;
}
void ntt(int *a,int op){
	for (int i=0;i<lim;i++)
		if (i<r[i]) swap(a[i],a[r[i]]);
	for (int mid=1,pp=M-1>>1;mid<lim;mid<<=1,pp>>=1)
		for (int R=mid<<1,j=0,wn=pw(op==1?g:gi,pp);j<lim;j+=R)
			for (int k=0,w=1;k<mid;k++,w=mul(w,wn)){
				int x=a[j|k],y=mul(w,a[j|k|mid]);
				a[j|k]=inc(x,y);
				a[j|k|mid]=dec(x,y);
			}
	if (op==-1){
		int inv=Inv(lim);
		for (int i=0;i<lim;i++) a[i]=mul(a[i],inv);
	}
}
int main(){
	scanf("%d",&n);
	for (i=1;i<n;i++) scanf("%d%d",&x,&y),add(x,y),add(y,x);
	dfs(1,0);
	fac[0]=1,a[0]=0;
	for (i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%M,a[i]=1ll*a[i]*fac[i]%M;
	b[0]=inv[n]=Inv(fac[n]);
	for (i=n-1;~i;i--) inv[i]=1ll*inv[i+1]*(i+1)%M,b[n-i]=inv[i];
	for (;lim<=n+n;lim<<=1,l++);
	for (i=0;i<lim;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
	ntt(a,1),ntt(b,1);
	for (i=0;i<lim;i++) a[i]=1ll*a[i]*b[i]%M;
	ntt(a,-1);
	for (i=1;i<=n;i++) printf("%lld\n",(1ll*fac[n]*inv[i]%M*inv[n-i]%M*n%M-1ll*inv[i]*a[n+i]%M+M)%M);
}

Measured memory_bytes: 28544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
struct UnionFind
{
    vector<int> par, sz;
    UnionFind(int n) : par(n), sz(n, 1) {
        for (int i = 0; i < n; ++i) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sz[x] < sz[y]) swap(x, y);
        par[y] = x;
        sz[x] += sz[y];
        sz[y] = 0;
    }
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return sz[root(x)];
    }
};
template<typename T>
struct edge {
    int src, to;
    T cost;
};
template<typename T>
using Graph = vector<vector<edge<T>>>;
template<typename T>
T kruskal(vector<edge<T>> &es, int V) {
    UnionFind uf(V);
    T ret = 0;
    sort(es.begin(), es.end(), [](edge<T> &a,edge<T> &b){
            return a.cost < b.cost;
            });
    for (auto &e : es) {
        if (!uf.issame(e.src, e.to)) {
            ret += e.cost;
            uf.merge(e.src, e.to);
        }
    }
    return ret;
}
struct Cell {
  double x, y, z, r;
};
double dist(Cell c1, Cell c2) {
  return sqrt((c1.x - c2.x) * (c1.x - c2.x) + (c1.y - c2.y) * (c1.y - c2.y) + (c1.z - c2.z) * (c1.z - c2.z));
}
bool colide(Cell c1, Cell c2) {
  return c1.r + c2.r + eps > dist(c1, c2);
}
void solve(int n) {
  vector<Cell> v(n);
  for(int i=0;i<n;++i) {
    cin >> v[i].x >> v[i].y >> v[i].z >> v[i].r;
  }
  vector<edge<double>> edges;
  for(int i=0;i<n;++i) {
    for(int j=i+1;j<n;++j) {
      if(colide(v[i], v[j])) {
        edges.push_back({i, j, 0});
        edges.push_back({j, i, 0});
      } else {
        edges.push_back({i, j, dist(v[i], v[j]) - v[i].r - v[j].r});
        edges.push_back({j, i, dist(v[i], v[j]) - v[i].r - v[j].r});
      }
    }
  }
  printf("%.3f\n", round(kruskal(edges, n) * 1000) / 1000.0);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    solve(n);
  }
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int n, m, l, f[2020][2020], p = 1000000007, z;
int main() {
	scanf("%d%d%d", &n, &m, &l);
	for (int i = 1; i < l; i++) {
		f[i][l - i] = 1;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (f[i][j]) {
				for (int k = 0; k < l; k++) {
					if (i + k <= n && j + l - 1 - k <= m) {
						f[i + k][j + l - 1 - k] += f[i][j];
						f[i + k][j + l - 1 - k] %= p;
					}
				}
			}
			if (i % (l - 1) == n % (l - 1) && j % (l - 1) == m % (l - 1)) {
				z += f[i][j];
				z %= p;
			}
		}
	}
	printf("%d\n", z);
	return 0;
}

Measured memory_bytes: 16000
#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)
#define MOD 1000000007

int x,a;


int main(){
  int ans=0;
  cin >> x >> a;
  if (x<a){
    cout<<0<<endl;
    return 0;
  }else{
    cout<<10<<endl;
    return 0;
  }


  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<string>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

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

typedef long long ll;

void solve(){
}

int main(){
  int n,p;

  while(cin>>n>>p,n||p){
    int rem[n+2];
    memset(rem,0,sizeof(rem));
    int stone = p;
    int now = 0;
    int winner = -1;

    while(1){
      if(stone >= 1){
        rem[now]++;
        stone--;
        if(stone == 0 && rem[now] == p){
          winner = now;
          break;
        }
      }
      else{
        stone += rem[now];
        rem[now] = 0;
      }

      now = (now + 1) % n;
    }

    cout<<winner<<endl;
  }
}

Measured memory_bytes: 864
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

struct Segment_Tree
{
	int maxn[1200050];
	int lazy[1200050];
	void init()
	{
		memset(maxn,0,sizeof(maxn));
		memset(lazy,0,sizeof(lazy));
	}
	void Update(int rt,int l,int r,int ll,int rr,int val)
	{
		if(ll <= l && r <= rr)
		{
			maxn[rt] -= val;
			lazy[rt] -= val;
			return ;
		}
		int mid = (l + r) >> 1;
		if(mid >= ll) Update(rt << 1,l,mid,ll,rr,val);
		if(mid < rr) Update(rt << 1 | 1,mid + 1,r,ll,rr,val);
		maxn[rt] = max(maxn[rt << 1],maxn[rt << 1 | 1]) + lazy[rt];
	}
}Seg;

struct Node
{
	int x,y;
	bool operator < (const Node &a) const
	{
		return x == a.x ? y < a.y : x < a.x;
	}
}node[300050];

Node lower[300050],upper[300050];
int w,h,n,ans;

void solv()
{
	sort(node + 1,node + 1 + n);
	Seg.init();
	int top1 = 0,top2 = 0;
	for(int i = 1;i < n; ++ i)
	{
		int nxt = i - 1;
		if(node[i].y <= h / 2)
		{
			while(top1 && node[i].y > lower[top1].y) Seg.Update(1,1,n,lower[top1].x,nxt,node[i].y - lower[top1].y),nxt = lower[top1 --].x - 1;
			if(nxt != i - 1) lower[++ top1] = (Node){nxt + 1,node[i].y};
		}
		else
		{
			while(top2 && node[i].y < upper[top2].y) Seg.Update(1,1,n,upper[top2].x,nxt,upper[top2].y - node[i].y),nxt = upper[top2 --].x - 1;
			if(nxt != i - 1) upper[++ top2] = (Node){nxt + 1,node[i].y};
		}
		lower[++ top1] = (Node){i,0};
		upper[++ top2] = (Node){i,h};
		Seg.Update(1,1,n,i,i,node[i].x - h);
		ans = max(ans,Seg.maxn[1] + node[i + 1].x);
	}
}

int main()
{
	scanf("%d%d%d",&w,&h,&n);
	ans = max(w,h) + 1;
	for(int i = 1;i <= n; ++ i) scanf("%d%d",&node[i].x,&node[i].y);
	node[++ n] = (Node){0,0};
	node[++ n] = (Node){w,h};
	solv();
	swap(w,h);
	for(int i = 1;i <= n; ++ i) swap(node[i].x,node[i].y);
	solv();
	printf("%d\n",ans * 2);
	
}

Measured memory_bytes: 15616
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

ans = -1

n = readInt()
s = input()

for i in range(1,n):
  a = set(s[:i])
  b = set(s[i:])
  ans = max(ans,len(a&b))

print(ans)

Measured memory_bytes: 9404
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}
#define chk_max(x,y) (x<y?(x=y,1):0)
#define chk_min(x,y) (y<x?(x=y,1):0)

enum{N=100023};

struct Edge{ int nxt,to,len; } bow[N*2];
int head[N],tot_e;
il void add(int x,int y,int z){
	tot_e++;
	bow[tot_e<<1]=(Edge){head[x],y,z};
	bow[tot_e<<1|1]=(Edge){head[y],x,z};
	head[y]=(head[x]=tot_e<<1)|1;
}

int n;
ll ans;
int size[N],mxc[N];
void dfs(int u,int fa){
	size[u] = 1;
	each(i,u){
		int v = bow[i].to;
		if( v==fa ) continue;
		dfs(v,u);
		size[u] += size[v];
		chk_max(mxc[u],size[v]);
		ans += 2ll*bow[i].len*min(size[v],n-size[v]);
	}
	chk_max(mxc[u],n-size[u]);
}

int main(){
	n = ci();
	rep(i,1,n-1){
		int x=ci(), y=ci(), z=ci();
		add(x,y,z);
	}
	dfs(1,0);
	int seq[5],tot=0;
	rep(i,1,n) if( mxc[i]<=n/2 ) seq[++tot] = i;
	if( tot==1 ){
		int u = seq[1];
		ll mn = 1e9;
		each(i,u) chk_min(mn,bow[i].len);
		ans -= mn;
	}else if( tot==2 ){
		int u = seq[1], v = seq[2];
		each(i,u) if( bow[i].to==v ) ans -= bow[i].len;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 7680
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}
long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H;
long long int ans;

int da[200000];

int root(int x) {
	return da[x] < 0 ? x : da[x] = root(da[x]);
}
bool unionSet(int x, int y) {
	x = root(x); y = root(y);
	if (x != y) {
		if (da[y] < da[x]) swap(x, y);
		da[x] += da[y]; da[y] = x;
	}
	return  x != y;
}
bool findSet(int x, int y) {
	return root(x) == root(y);
}

int size(int x) {
	return -da[root(x)];
}

int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	long long int x[100000];
	long long int y[100000];
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		x[i] = x[i] * MOD + i;
		y[i] = y[i] * MOD + i;
	}
	for (int i = 1; i <= N; i++)da[i] = -1;
	sort(x, x + N);
	sort(y, y + N);
	list<long long int>edge[100001];
	for (int i = 0; i < N - 1; i++) {
		int a = x[i] % MOD;
		int b = x[i + 1] % MOD;
		edge[a].push_back((x[i + 1] / MOD - x[i] / MOD)*MOD + b);
		edge[b].push_back((x[i + 1] / MOD - x[i] / MOD)*MOD + a);
		 a = y[i] % MOD;
		 b = y[i + 1] % MOD;
		edge[a].push_back((y[i + 1] / MOD - y[i] / MOD)*MOD + b);
		edge[b].push_back((y[i + 1] / MOD - y[i] / MOD)*MOD + a);
	}
	bool flag[100001] = {};
	flag[0] = true;
	int used = 1;
	priority_queue<long long int, vector<long long int>, greater<long long int>>Q;
	for (auto i : edge[0])Q.push(i);
	while (used<N) {
		long long int a = Q.top();
		Q.pop();
		if (flag[a%MOD])continue;
		used++;
		flag[a%MOD] = true;
		ans += a / MOD;
		for (auto i : edge[a%MOD])Q.push(i);
	}
	cout << ans << endl;
	return 0;
}

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

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

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n, m;
	cin >> n >> m;
	Vec<int> cnt(n);
	while (m--) {
		int a, b;
		cin >> a >> b;
		cnt[--a]++;
		cnt[--b]++;
	}
	for (auto&& i : cnt) {
		cout << i << "\n";
	}
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <climits>

using namespace std;
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define sz(v) (int)v.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vi;
//const int mod=1e9+7;
//const int N=1e5+7;

int main(){
    fast;
    int t=1;
    //cin>>t;
    while(t--){
        string s;
        int ans=0;
        cin>>s;
        forn(i,sz(s)-1){
            if(s[i]!=s[i+1]) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)

int sd[114514];
int td[114514];

signed main() {
  string s, t;
  cin >> s >> t;
  int now = 0;
  rep(i, s.size()) {
    sd[i] = now;
    if(s[i] == 'A') {
      now++;
    }
    else {
      now--;
    }
  }
  sd[s.size()] = now;
  now = 0;
  rep(i, t.size()) {
    td[i] = now;
    if(t[i] == 'A') {
      now++;
    }
    else {
      now--;
    }
  }
  td[t.size()] = now;
  int q;
  cin >> q;
  rep(i, q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(((sd[b] - sd[a - 1]) - (td[d] - td[c - 1])) % 3 == 0) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int N;
vector<string> W;
set<string> Ws;
int main()
{
    cin >> N;
    W.resize(N);
    REP(i, N)
    {
        cin >> W[i];
        Ws.insert(W[i]);
    }
    if (Ws.size() < N)
    {
        cout << "No" << endl;
        return 0;
    }
    REP(i, N - 1) if (W[i].back() != W[i + 1].front())
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

int N,M,R,Q;
int A[10000][1005]; //生徒番号,時間

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

    while(cin>>N>>M,N){
        memset(A,0,sizeof(A));
        cin>>R;
        REP(i,R){
            int t,n,m,s;
            cin>>t>>n>>m>>s;
            t-=540; n--; m--;
            if(s) A[m][t]++;
            else A[m][t]--;
        }
        REP(i,M){
            REP(j,1000){
                A[i][j+1]+=A[i][j];
            }
        }
        cin>>Q;
        REP(i,Q){
            int s,e,m;
            cin>>s>>e>>m;
            s-=540; e-=540; m--;
            int res=0;
            for(int i=s;i<e;i++){
                res+=(A[m][i]>=1);
            }
            cout<<res<<endl;
        }
    }
} 


Measured memory_bytes: 81536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
  long int N, p[4], m=0, i, sum=0, ans, f[4]={0,0,0,0};
  double left;
  scanf("%ld %ld %ld %ld",&p[0],&p[1],&p[2],&p[3]);
  scanf("%ld",&N);
  for(i=0;i<3;i++){
    if(p[m]*pow(2,i-m+1)<p[1+i])  f[i+1]=1; 
    else m=i+1;
  }
  left=(double)N;
  for(i=3;i>=0;i--){
    if(f[i]==0){
      ans=(long int)left/pow(2,i-2);  left-=ans*pow(2,i-2);
      //printf("%d: %d %.2f\n",i,ans,left);
      sum+=p[i]*ans;
    }
  }
  printf("%ld\n",sum);
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> V(N), C(N);
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += max(0, V[i] - C[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc093/tasks/arc094_a

#include <iostream>
using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;

    int ret = 0;
    auto mi = min(min(a,b),c);
    auto mx = max(max(a,b),c);
    auto middle = a + b + c - mi - mx;

    ret += (middle - mi) / 2;
    ret += ((middle - mi) % 2)*2;
    ret += mx - middle;

    cout << ret << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

int main(void) {
	long long n, i, j, kete, a, b, ma = 0, aa, bb, n2;
	cin >> n;
	n2 = sqrt(n);
	for (i = n2; i>=1; i--) {
		a = i;
		if (n%a == 0) {
			b = n / a;
			aa = log10(a) + 1; bb = log10(b) + 1;
			ma = max(aa, bb);
			break;
		}
	}
	
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

struct table
{
    int c, s, f;
};
double dp[100010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cout << fixed << setprecision(15);

    int N;
    cin >> N;
    vector<table> v;
    REP(i, N - 1)
    {
        table T;
        cin >> T.c >> T.s >> T.f;
        v.push_back(T);
    }
    vector<int> ans;
    for (int i = 0; i < N - 1; ++i)
    {
        int s = v[i].s + v[i].c;

        for (int j = i + 1; j < N - 1; ++j)
        {
            if (s < v[j].s)
            {
                s = v[j].s;
                s += v[j].c;
            }
            else
            {
                if (s % v[j].f == 0)
                {
                    s += v[j].c;
                }
                else
                {
                    s = s + v[j].f - s % v[j].f;
                    s += v[j].c;
                }
            }
        }
        ans.push_back(s);
    }
    ans.push_back(0);
    for (auto e : ans)
        cout << e << endl;
    return 0;
}


Measured memory_bytes: 256
// A - キャンディーとN人の子供イージー / Children and Candies (ABC Edit)

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

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

    int ans = 0;

    for (int i=1; i<=N; i++) {
        ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	ll ans = 0;
	//1<<x-1でxbitの探索が可能
	//cout << (1 << (s.size() - 1)) << endl;
	rep(i, 1 << (s.size()-1)) {
		//cout << i << endl;
		ll sum = 0, cur = 0;
		rep(j, s.size()) {
			if (j > 0 && (i & (1 << (j - 1)))) {
				sum += cur;
				cur = 0;
				//ok1
			}
			cur = cur * 10 + (s[j] - '0');
		}
		sum += cur;
		//cout << sum << endl;
		ans += sum;
		
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
    int n,t;
    scanf("%d%d",&n,&t);
    int i;
    int x[n];
    int time = 0;
    for (i=0; i<n; i++) {
        scanf("%d",&x[i]);
    }
    for (i=0; i<n-1; i++) {
        if (x[i+1] - x[i] < t) {
            time += x[i+1] - x[i];
        } else {
            time += t;
        }
    }
    time += t;
    printf("%d\n", time);
    return 0;
}


Measured memory_bytes: 896
n, m = map(int, input().split())
b = [None] * m
for i in range(m):
    _, *b[i] = map(lambda x: int(x)-1, input().split())
p = list(map(int, input().split()))
ans = 0
for x in range(2**n):
    light = 0
    for i, j in enumerate(b):
        switch = 0
        for k in j:
            switch += x >> k & 1
        if switch % 2 == p[i]:
            light += 1
    if light == m:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std; 
int n,m;
int a[100010];
int res;
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) cin >>a[i];
	res=(n-1)/(m-1);
	if ((n-1)%(m-1)) res++;
	cout <<res;
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(int, N);
    vector<int> a(N + 1);
    for (int i = 1; i <= N; ++i) read(a[i]);

    vector<int> box(N + 1);
    for (int i = N; i >= 1; --i) {
        int cnt = 0;
        for (int k = i; k <= N; k += i) cnt += box[k];
        if ((cnt & 1) != a[i]) box[i] = 1;
    }

    vector<int> ans;
    for (int i = 1; i <= N; ++i) if (box[i]) ans.push_back(i);
    print(ans.size());
    print(ans);

    return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
const int N = 3030;
#define ll long long
ll dp[N][N];
ll a[N];
int n;
int main(){
  cin>>n;
  ll sum = 0;
  for(int i=0;i<n;++i){
    cin>>a[i];
    sum += a[i];
  }
  for(int gap = 0;gap<n;++gap){
    for(int i=0,j=gap;j<n;++i,++j){
      ll x = ((i+2<=j)?dp[i+2][j]:0);
      ll y = ((j-2>=i)?dp[i][j-2]:0);
      ll z = ((i+1<=j-1)?dp[i+1][j-1]:0);
      dp[i][j] = max(a[i]+min(x,z),a[j]+min(y,z));
    }
  }
  ll ans = dp[0][n-1];
  ll fans = 2*ans - sum;
  cout<<fans<<endl;
  return 0;
}

Measured memory_bytes: 71936
#include<iostream>
#include<vector>
using namespace std;
const int INF=1e6;

int main(){
    int N;
    cin >> N;
    int dp[N+5];
    for(int i=0;i<=N;i++){
        dp[i]=INF;
    }
    dp[0]=0;
    for(int i=0;i<=N;i++){
        for(int j=1;j<=i;j*=6){
            dp[i]=min(dp[i-j]+1,dp[i]);
        }
        for(int j=1;j<=i;j*=9){
            dp[i]=min(dp[i-j]+1,dp[i]);
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static long x = sc.nextLong();
    public static void main(String[] args) {
        int year = 0;
        long money = 100;
        while (money < x){
            money = money + (money / 100);
            year++;
        }
        System.out.println(year);
    }
}


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

int N, X;
int A[110];

int main () {
  std::ios::sync_with_stdio (0);
  std::cin >> N >> X;
  for (int i = 0; i < N; ++i) std::cin >> A[i];
  std::sort (A, A + N);
  int ans = 0;
  for (int i = 0; i < N - 1; ++i)
    if (A[i] <= X) X -= A[i], ++ans;
  if (X == A[N - 1]) ++ans;
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
s = input()

x = int(s[0:2])
y = int(s[2:])

if x > 12:
    if y > 12:
        print("NA")
    elif y >= 1:
        print("YYMM")
    else:
        print("NA")
elif x >= 1:
    if y > 12:
        print("MMYY")
    elif y >= 1:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if y > 12:
        print("NA")
    if y >= 1:
        print("YYMM")
    else:
        print("NA")
        

Measured memory_bytes: 3060
#include <stdio.h>
#define N 100

int main(void){

  int i,j,n,key,k;
  int A[N];

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

  for(i=1;i<=n;i++){
    key = A[i];
    j = i - 1;
    while(j>0 && A[j] >key){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;

    for(k=1;k<=n;k++){
      if(k == n){
	printf("%d\n",A[k]);
      }else{
	printf("%d ",A[k]);
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2124
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		UL K; cin >> K;
		if (N < K) K = N;
		vector<UL> H(N); rep(i, N) cin >> H[i];
		sort(H.begin(), H.end());
		H.resize(N - K);
		ULL ans = 0;
		for (UL h : H) ans += h;
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

int main() {
  // ここにプログラムを追記
  double a, b, x;
  int inx, x10;
  cin >> a >> b;
  x = (a + b) / 2;
  x10 = x * 10;
  if(x10 % 10 != 0){
    inx = x + 1;
  }else{
    inx = x;
  }
  
  cout << inx << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 

int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    cout<<max(min(B,D)-max(A,C),0)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
bool F(int t,int e,int x)
{
	for(int a=0; a<=t+e; a+=x)
	{
		if(abs(a-t)<=e)
			return true;
	}
	return false;
}
int main()
{
	int n,t,e,x;
	scanf("%d%d%d",&n,&t,&e);
	for(int i=1;i<=n; ++i)
	{
		scanf("%d",&x);
		if(F(t,e,x))
		{
			printf("%d\n",i);
			return 0;
		}
	}
	puts("-1");
	return 0;
}

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

int main() {
  string s; cin >> s;
  vector<string> week = vector<string>{"SUN","MON","TUE","WED","THU","FRI","SAT"};
  int index = 0;
  for(int i=0; i<week.size(); i++){
    if(s == week[i]){
      index = i;
      break;
    }
  }
  cout << 7-index << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    string s; cin>>s;
    int n=s.size();
    int k; cin>>k;
    set<string> st;
    for(int i=0; i<n; i++){
        string t=s.substr(i, 1);
        st.insert(t);
    }
    for(int i=0; i<n-1; i++){
        string t=s.substr(i, 2);
        st.insert(t);
    }
    for(int i=0; i<n-2; i++){
        string t=s.substr(i, 3);
        st.insert(t);
    }
    for(int i=0; i<n-3; i++){
        string t=s.substr(i, 4);
        st.insert(t);
    }
    for(int i=0; i<n-4; i++){
        string t=s.substr(i, 5);
        st.insert(t);
    }

    int cnt=0;
    for(auto x : st){
        cnt++;
        if(cnt==k){
            cout << x << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll status[5000005];
void siv(){
    ll N=1000000;
    for(ll i=2;i*i<=N;i++){
        if(status[i]==0){
            for(ll j=i*i;j<=N;j+=i)
                status[j]=1;
        }
    }
    status[1]=1;
}
int main(){
    fastread;
    ll n,i,j,k,l;
    ll m;
    cin>>n;
    vector<ll>v1,v2;
    for(i=2;i*i<=n;i++){
        if(n%i==0) {
            v1.pb(i);
            if (i != n / i)
                v1.pb(n / i);
        }
    }
    v1.pb(n);
    for(i=2;i*i<=(n-1);i++) {
        if ((n - 1) % i == 0) {
            v2.pb(i);
            if (i != (n - 1) / i)
                v2.pb((n - 1) / i);
        }
    }
    if(n-1!=1)
    v2.pb(n-1);
    ll cnt=0;
    for(i=0;i<v1.size();i++){
        ll kola=n;
        while(kola%v1[i]==0)
            kola/=v1[i];
        if(kola%v1[i]==1)
            cnt++;
    }
    cout<<cnt+v2.size();
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <queue>
const int N=2e5+5;
int n,lg2[N],val[N],npos0[17][N>>1],npos1[17][N>>1];
struct data{
	int l,r,x,y;
	friend bool operator < (const data &a,const data &b){
		return a.x==b.x?val[a.y]>val[b.y]:val[a.x]>val[b.x];
	}
};

namespace utils{
	template <class T> inline void apx(T &x,const T y){
		x<y?x=y:0;
	}
	template <class T> inline void apn(T &x,const T y){
		x>y?x=y:0;
	}
	inline int nxi(FILE *fd=stdin){
		int x=0;
		char c;
		while(((c=fgetc(fd))>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=fgetc(fd));
		while(x=x*10-48+c,(c=fgetc(fd))>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

void init(){
	for(int i=2; i<=n; ++i){
		lg2[i]=lg2[i>>1]+1;
	}
}

void build_rmq(int pos[17][N>>1]){
	for(int i=1; i<=lg2[n>>1]; ++i){
		for(int j=1<<i; j<=n>>1; ++j){
			int p1=pos[i-1][j],p2=pos[i-1][j-(1<<(i-1))];
			pos[i][j]=val[p1]<val[p2]?p1:p2;
		}
	}
}

int rmq(int pos[17][N>>1],const int x,const int y){
	if(x==y) return pos[0][y];
	int len=y-x+1,lg=lg2[len];
	int p1=pos[lg][y],p2=pos[lg][x+(1<<lg)-1];
	return val[p1]<val[p2]?p1:p2;
}

int get0(const int l,const int r){
	if(l==r){
		assert((l&1)==0);
		return l;
	}
	int x=l>>1,y=r>>1;
	return rmq(npos0,x,y);
}

int get1(const int l,const int r){
	if(l==r){
		assert((l&1)==1);
		return l;
	}
	int x=(l+1)>>1,y=(r+1)>>1;
	return rmq(npos1,x,y);
}

data getdata(const int l,const int r){
	data x=(data){l,r,0,0};
	if(x.l&1){
		x.x=get1(l,r);
		x.y=get0(x.x+1,r);
	}
	else{
		x.x=get0(l,r);
		x.y=get1(x.x+1,r);
	}
	return x;
}

int main(){
	std::priority_queue <data> pq;
	n=nxi();
	init();
	for(int i=1; i<=n; ++i){
		val[i]=nxi();
	}
	for(int i=1; i<=n>>1; ++i){
		npos1[0][i]=(i<<1)-1;
		npos0[0][i]=i<<1;
	}
	build_rmq(npos0);
	build_rmq(npos1);
	pq.push(getdata(1,n));
	while(!pq.empty()){
		data x=pq.top();
		pq.pop();
		printf("%d %d ",val[x.x],val[x.y]);
		if(x.x>x.l){
			pq.push(getdata(x.l,x.x-1));
		}
		if(x.y>x.x+1){
			pq.push(getdata(x.x+1,x.y-1));
		}
		if(x.r>x.y){
			pq.push(getdata(x.y+1,x.r));
		}
	}
	puts("");
	return 0;
}


Measured memory_bytes: 17140
#include <iostream>

using namespace std;

int main()
{
    int i, h, m, s;
    cin >> i;
    h = i / 3600;
    m = i / 60 - h * 60 ;
    s = i % 60;
    cout << h << ":" << m << ":" << s << endl;

    return 0;
}



Measured memory_bytes: 3088
#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<set>
#include<stack>
#include<cstring>
#include<map>
#include<vector>
#define ll long long int
using namespace std;
map<ll,ll> dp;
const ll mod=1000000007;
ll yj(ll x)
{
    if(dp[x]) return dp[x] ;
    else
       {
           dp[x]=(yj(x/2)+yj((x-1)/2)+yj((x-2)/2))%mod;
           return dp[x];
       }
}
int main()
{
    ll n;
    cin>>n;
    dp[0]=1;
    dp[1]=2;
    yj(n);
    cout<<dp[n];

}


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

#define MAX 100

int data[MAX+1][MAX+1] = {{}};

void show(int r, int c)
{
    int i, j;

    for(i=0;i<r;i++) {
        for(j=0;j<c;j++) {
            if(j!=0) putchar(' ');
            printf("%d", data[i][j]);
        }
        putchar('\n');
    }

    return;
}

int main(void)
{
    int i, j;
    int r, c;
    char str[4*MAX+1], *tok;
    char temp[] = " \n";

    scanf("%d %d", &r, &c);

    scanf("%*c");
    for(i=0;i<r;i++) {
        fgets(str, 4*MAX+1, stdin);
        tok = strtok(str, temp);
        data[i][0] = atoi(tok);
        for(j=1;j<c;j++) {
            tok = strtok(NULL, temp);
            data[i][j] = atoi(tok);
        }
    }

    for(i=0;i<r;i++) {
        for(j=0;j<c;j++) {
            data[i][c] += data[i][j];
        }
    }

    for(i=0;i<=c;i++) {
        for(j=0;j<r;j++) {
            data[r][i] += data[j][i];
        }
    }

    show(r+1,c+1);

    return 0;
}

Measured memory_bytes: 648
import sys
sys.setrecursionlimit(10000000)


def main():
    N = int(input())
    A = [int(c) for c in input().split()]
    num_lists = [0] * (N + 1)
    for a in A:
        num_lists[a] += 1
    A_C = [int(c * (c - 1) / 2) for c in num_lists]
    sum_ = sum(A_C)

    for a in A:
        temp_sum = sum_ - A_C[a]
        temp_sum += (num_lists[a] - 1) * (num_lists[a] - 2) / 2
        print(int(temp_sum))


if __name__ == '__main__':
    main()


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

int main(){
    int D, N;
    cin >> D >> N;

    int sums = 1;

    for (int i = 0; i < D; i++)
    {
        sums *= 100;
    }

    if(D==0) sums = 1;

    if(N == 100) N = 101;

    cout << sums * N << endl;
    
}

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

int main(){
    string marble;
    cin >> marble;
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(marble[i] - '0'){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;


int main() {
    int n, k, r, s, p;
    string t;
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;
    
    ll score = 0;

    rep(i, n){
        if ('r' == t[i]) score += p;
        else if ('s' == t[i]) score += r;
        else score += s;
    }
    
    rep(ki, k){
        int cnt = 1;
        int i;
        for (i=ki+k;i<n;i+=k){
            if (t[i - k] ==t[i]) cnt++;
            else {
                if (cnt > 1){
                    int v;
                    if ('r' == t[i - k]) v = p;
                    else if ('s' == t[i - k]) v = r;
                    else v = s;
                    score -= cnt / 2 * v;
                }
                cnt = 1;
            }
        }
        if (cnt > 1){
            int v;
            if ('r' == t[i - k]) v = p;
            else if ('s' == t[i - k]) v = r;
            else v = s;
            score -= floor(cnt / 2.0) * v;
            cnt = 1;
        }
    }
    cout << score << endl;
    
}


Measured memory_bytes: 512