akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N; cin >> N;
	ll A[100010];
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A, A + N, greater<ll>());
	int ans = 0, num = mod;
	for (int i = 1; i < N; i++) {
		if (abs(A[0] / 2 - A[i]) < num) {
			ans = A[i];
			num = abs(A[0] / 2 - A[i]);
		}
	}
	cout << A[0] << " " << ans << endl;
}


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

int main() {
	ll a,b,c,d,i=0;
	cin>>a>>b>>c>>d;
	while(a>0 && c>0)
	{
		if(i%2==0)
		{
			c=c-b;
			i=i+1;
			continue;
		}
		else
		{
			a=a-d;
			i=i+1;
		}
	}
	if(i%2==1)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3636
<?php
  // 逆からみて単調非増加
  
  $n = intVal(trim(fgets(STDIN)));
  $arr = array_map("intVal", explode(" ", trim(fgets(STDIN))));
  for($i=$n-2; $i>=0; $i--){
    if($arr[$i]-$arr[$i+1] > 1){
      echo "No" . PHP_EOL;
      exit();
    }elseif($arr[$i] - $arr[$i+1] == 1){
      $arr[$i] -= 1;
    }
  }
  echo "Yes" . PHP_EOL;
?>

Measured memory_bytes: 16884
#include <iostream>
#define MOD 1000000007
#define INV 500000004
using namespace std;
long long f[3005][3005],g[3005],h[3005];
int a[3005];
int main()
{
 int n,q;
 cin>>n>>q;
 for(int i=1;i<=n;i++)
  cin>>a[i];
 for(int i=1;i<=n;i++)
  for(int j=1;j<=n;j++)
   if(a[i]>a[j])f[i][j]=1;
 long long ans=0,tmp=1;
 while(q--)
 {
  int x,y;
  cin>>x>>y;
  for(int i=1;i<=n;i++)
  {
   g[i]=(f[x][i]+f[y][i])*INV%MOD;
   h[i]=(f[i][x]+f[i][y])*INV%MOD;
  }
  for(int i=1;i<=n;i++)
  {
   f[x][i]=f[y][i]=g[i];
   f[i][x]=f[i][y]=h[i];
  }
  tmp=tmp*2%MOD;
  f[x][x]=f[y][y]=0;
  f[x][y]=f[y][x]=(f[x][y]+f[y][x])%MOD;
 }
 for(int i=1;i<=n;i++)
  for(int j=i+1;j<=n;j++)
   ans=(ans+f[i][j])%MOD;
 cout<<ans*tmp%MOD<<endl;
 return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

const LLI mod = 1e9+7;

LLI power(LLI n, LLI p, LLI m){
  LLI ret = 1;
  while(p>0){
    if(p&1) (ret *= n) %= m;
    (n *= n) %= m;
    p /= 2;
  }
  return ret;
}

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

  int N;
  while(cin >> N){
    vector<int> A(N); cin >> A;

    vector<int> s(N+1);
    REP(i,N) s[i+1] = s[i] ^ A[i];

    vector<int> zero(N+2);
    REPE(i,N) zero[i+1] = zero[i] + (s[i] == 0 ? 1 : 0);

    map<int, vector<int>> ps;
    REPE(i,N){
      if(s[i] != 0) ps[s[i]].push_back(i);
    }

    LLI ans = 0;

    if(s.back() == 0){
      {
	int c0 = count(ALL(s), 0);
	(ans += power(2,c0-2,mod)) %= mod;
      }
      
      for(auto &kv : ps){
	auto &v = kv.snd;

        LLI c0 = 1, cx = 1;

	FOR(i,1,(int)v.size()){
	  (c0 += (zero[v[i]+1]-zero[v[i-1]])*cx%mod) %= mod;
	  (cx += c0) %= mod;
	}
	(ans += cx) %= mod;
      }
      
    }else{
      int x = s.back();

      LLI c0 = 1, cx = 0;

      FOR(i,1,N){
	if(s[i] == 0){
	  (c0 += cx) %= mod;
	}else if(s[i] == x){
	  (cx += c0) %= mod;
	}
      }
      
      ans = c0;
    }

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


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

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 2e5 + 10, Mod = 924844033;
int siz[N], n;
struct node { int to, nxt; } g[N << 1];
int lst[N], gl, cnt[N];
void add(int x, int y) {
	g[++gl] = (node) {y, lst[x]}; lst[x] = gl;
	g[++gl] = (node) {x, lst[y]}; lst[y] = gl;
}
void dfs(int u, int ff) {
	siz[u] = 1;
	for (int i = lst[u]; i; i = g[i].nxt) {
		int v = g[i].to; if (v == ff) continue;
		dfs(v, u); siz[u] += siz[v]; cnt[siz[v]]++;
	}
	cnt[n - siz[u]]++;
}
int fac[N], ifac[N];
int fpow(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1ll * a * a % Mod)
		if (b & 1) res = 1ll * res * a % Mod;
	return res;
}
int A[N << 2], B[N << 2], lim, rev[N << 2];
void NTT(int *a, int op) {
	for (int i = 0; i < lim; i++)
		if (i < rev[i]) swap(a[i], a[rev[i]]);
	for (int i = 1; i < lim; i <<= 1)
		for (int j = 0, w = fpow(5, (Mod - 1) / (i << 1)); j < lim; j += i << 1)
			for (int k = j, s = 1; k < i + j; k++, s = 1ll * s * w % Mod) {
				int t = 1ll * a[i + k] * s % Mod;
				a[i + k] = (a[k] - t + Mod) % Mod;
				a[k] = (a[k] + t) % Mod;
			}
	if (op == -1) {
		reverse(a + 1, a + lim);
		for (int i = 0, inv = fpow(lim, Mod - 2); i < lim; i++)
			a[i] = 1ll * a[i] * inv % Mod;
	}
	return ;
}
int C(int n, int m) {
	if (n < m) return 0;
	return 1ll * fac[n] * ifac[m] % Mod * ifac[n - m] % Mod;
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi<int>();
	for (int i = 1; i < n; i++) add(gi<int>(), gi<int>());
	fac[0] = 1;
	for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % Mod;
	ifac[n] = fpow(fac[n], Mod - 2);
	for (int i = n; i >= 1; i--) ifac[i - 1] = 1ll * ifac[i] * i % Mod;
	dfs(1, 0);
	for (int i = 1; i <= n; i++) A[i] = 1ll * cnt[i] * fac[i] % Mod;
	for (int i = 0; i <= n; i++) B[n - i] = ifac[i];
	int l = -1; lim = 1;
	while (lim <= 2 * n) lim <<= 1, l++;
	for (int i = 0; i < lim; i++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << l);
	NTT(A, 1), NTT(B, 1);
	for (int i = 0; i < lim; i++) A[i] = 1ll * A[i] * B[i] % Mod;
	NTT(A, -1);
	for (int i = 1; i <= n; i++)
		printf("%d\n", (1ll * n * C(n, i) % Mod - 1ll * A[n + i] * ifac[i] % Mod + Mod) % Mod);
	return 0;
}


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

int main() {
  string t;
  cin >> t;
  for (ll i = 0; i < t.size(); i++) {
    if (t[i] == '?') t[i] = 'D';
  }
  cout << t << endl;
}


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

int runner(int n, vector<int> numbs, map<int, int> used, int numb, int number, int counter, 
    map<int, int> &ans) {
    used[numb] = 0;
    number*=10;
    number+=numb;
    counter++;
    int count;
    if(counter == n) {
        int a = 0;
        count = number;
    }
    else {
        for(int i = 0; i < n; i++) {
            if(used.find(numbs[i]) == used.end()) {
                count = runner(n, numbs, used, numbs[i], number, counter, ans);
            }
        }
    }
    // cout << count << endl;
    ans[count] = 1;
    
    return count;
}

int main() {
    int n;
    cin >> n;
    vector<int> p, q, numbs;
    map<int, int> ans;
    int numb;
    int numb1 = 0;
    int numb2 = 0;
    int factorial = 1;
    map<int, int> used;
    for(int i = 0; i < n; i++) {
        cin >> numb;
        p.push_back(numb);
        numb1*=10;
        numb1+=numb;
    }
    for(int i = 0; i < n; i++) {
        cin >> numb;
        q.push_back(numb);
        numb2*=10;
        numb2+=numb;
    }
    for(int i = 0; i < n; i++) {
        numbs.push_back(i+1);
    }

    // for(int )
    for(int i = 0; i < n; i++) {
        runner(n, numbs, used, numbs[i], 0, 0, ans);
    }
    int numb1_idx, numb2_idx;
    map<int, int>::iterator it;
    int i = 0;
    for (it = ans.begin(); it != ans.end(); it++ ) {
        // cout << it->first << endl;
        if(it->first == numb1) {
            numb1_idx = i+1;
        }
        if(it->first == numb2) {
            numb2_idx = i+1;
        }

        i++;
    }
    cout << abs(numb1_idx-numb2_idx) << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define LL               long long
#define PB               push_back
using namespace std;


int main(){
    
        int n,x,t;cin>>n>>x>>t;
        if (n%x){
        cout<<((n/x)+1)*t;
        }
    else cout<<((n/x))*t;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 0;
        for(int i = 1, l = s.length(); i < l; ++i) {
            if(s.charAt(i - 1) != s.charAt(i)) ++ans;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    string bh;
    string hb;
    for (int i = 0; i < S.size(); i++)
    {
        if (i % 2 == 0)
        {
            bh += '0';
            hb += '1';
        }
        else
        {
            bh += '1';
            hb += '0';
        }
    }
    int cnt1 = 0;
    int cnt2 = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == bh[i])
        {
            ++cnt1;
        }
        if (S[i] == hb[i])
        {
            ++cnt2;
        }
    }
    cout << min(cnt1, cnt2) << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<utility>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
using namespace std;

const double eps = 1e-8;
const double INF = 1e12;

typedef pair<long,long> P;
typedef double Real;
typedef complex<Real> Point;
typedef vector<Point> G;

double cross(const Point& a,const Point& b){//calculate ad-bc(vector product)
	return imag(conj(a)*b);
}

struct L:public vector<Point>{//line data
	L(const Point &a,const Point &b){
		push_back(a);
		push_back(b);
	}
};

int n;
int dp[31];

long long func(int i){//i??????????§???????n??????????????????????????°???????????¢??°
	long long res;
	if(dp[i]!=-1)return dp[i];
	if(i==n)return 1;
	else if(i==n-1)res=func(i+1);
	else if(i==n-2)res=func(i+1)+func(i+2);
	else res=func(i+1)+func(i+2)+func(i+3);
	return dp[i]=res;
}

int main(){
	while(cin>>n){
		if(!n)break;
		memset(dp,-1,sizeof(dp));
		unsigned long long sum=func(0);
		bool check=false;
		if(sum%10)check=true;
		sum/=10;
		if(check)sum++;
		long long ans=sum/365;
		if(sum%365)ans++;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
// atc.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <string>
#include    <algorithm>
using namespace std;

int main()
{
    string s, o;
    int n, m;
    int f;
    int count = 0;

    cin >> n>>m;

    vector<int> K(n);
    vector<int> A(m,0);
    for (int i = 0; i < n; i++) {
        cin >> K[i];
        for (int j = 0; j < K[i]; j++) {
            cin >> f;
            A[f - 1]++;
        }
    }

    for (int i = 0; i < m; i++) {
        if (A[i] == n) {
            count++;
        }
    }

    cout << count;


    return 0;
}




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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for(int i = 0; i < N; i++) cin >> x[i];

  int ans = 0;
  for(int i = 0; i < N; i++) {
    ans += 2 * min(x[i], K - x[i]);
  }

  cout << ans;
  


  return 0;
}

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

typedef long long ll;
const ll MOD = (ll)1e+9 + 7;
const int MAX_N = 100000;

int main() {
	int N, M;
	std::cin >> N >> M;
	if(N < M) std::swap(N, M);

	if(N - M > 1) {
		std::cout << 0 << std::endl;
		return 0;
	}

	ll fact[MAX_N + 1];
	fact[0] = 1;
	for(int i = 1; i <= N; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	ll ans = fact[N] * fact[M] % MOD;
	if(N == M) {
		ans *= 2;
		ans %= MOD;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <random>
#include <complex>
#include <random>
 
using namespace std;

#define int long long

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

    int n;
    cin >> n;
    map<int, int> cnt;
    vector<int> a(n);
    for (auto &t : a) {
        cin >> t;
        cnt[t]++;
    }  
    int ans = 0;
    for (int i = 30; i > 0; i--) {
        for (auto f : a) {
            int pr = (1 << i) - f;
            if (pr > 0 && pr < (1 << i)) {
                if (f == pr) {
                    if (cnt[f] > 1) {
                        cnt[f] -= 2;
                        ans++;
                    }
                } else {
                    if (cnt[f] > 0 && cnt[pr] > 0) {
                        cnt[f]--;
                        cnt[pr]--;
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 40192
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=4e4+5,maxm=4e4+5;
const ll inf=1e18;
inline int fa(int u){ return u/2; }
inline int ls(int u){ return u*2; }
inline int rs(int u){ return u*2+1; }
struct heap{
	int hea[maxn],pos[maxn],siz;
	ll *dis;
	heap(ll a[],int n){
		dis=a; siz=n;
		int i;
		for (i=1;i<=n;i++){
			dis[i]=inf; hea[i]=i; pos[i]=i;
		}
	}
	void hswap(int u,int v){
		swap(hea[u],hea[v]);
		pos[hea[u]]=u; pos[hea[v]]=v;
	}
	void update(int u){
		if (u==1) return;
		if (dis[hea[fa(u)]]<=dis[hea[u]]) return;
		hswap(u,fa(u));
		update(fa(u));
	}
	void pushdown(int u){
		int v=u;
		if (ls(u)<=siz&&dis[hea[ls(u)]]<dis[hea[v]]) v=ls(u);
		if (rs(u)<=siz&&dis[hea[rs(u)]]<dis[hea[v]]) v=rs(u);
		if (u==v) return;
		hswap(u,v);
		pushdown(v);
	}
	void change(int u,ll val){
		dis[u]=val;
		update(pos[u]);
		pushdown(pos[u]);
	}
	int pop(){
		hswap(1,siz);
		siz--;
		pushdown(1);
		return hea[siz+1];
	}
};
struct gragh{
	int head[maxn],next[maxm],to[maxm],tot;
	ll wei[maxm],cost[maxn];
	gragh(){
		memset(head,-1,sizeof(head));
		tot=0;
	}
	void clear(){
		memset(head,-1,sizeof(head));
		tot=0;
	}
	void add(int u,int v,ll w,ll c){
		next[tot]=head[u];
		head[u]=tot;
		to[tot]=v;
		wei[tot]=w;
		cost[tot]=c;
		tot++;
	}
	void dijkstra(ll dis[],ll val[],int st,int n){
		heap hp(dis,n);
		hp.change(st,0);
		int i,u,v,ed;
		for (i=1;i<=n;i++) val[i]=inf;
		val[st]=0;
		while (hp.siz){
			u=hp.pop();
			for (ed=head[u];ed!=-1;ed=next[ed])
				if (dis[v=to[ed]]>dis[u]+wei[ed])
					hp.change(v,dis[u]+wei[ed]);
		}
		for (u=1;u<=n;u++) for (ed=head[u];ed!=-1;ed=next[ed])
			if (dis[v=to[ed]]==dis[u]+wei[ed])
			val[v]=min(val[v],cost[ed]);
	}
};
gragh g;
ll dis[maxn],val[maxn];
int main(){
	int n,m,i,u,v;
	ll w,c,ans;
	while (scanf("%d%d",&n,&m)&&(n||m)){
		g.clear();
		for (i=0;i<m;i++){
			scanf("%d%d%lld%lld",&u,&v,&w,&c);
			g.add(u,v,w,c);
			g.add(v,u,w,c);
		}
		g.dijkstra(dis,val,1,n);
		ans=0;
		for (i=1;i<=n;i++) ans+=val[i];
		printf("%lld\n",ans);
	}
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    int a[105];
    int sum = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum += a[i];
    }
    int ans = 101;
    int now = 999999;
    for(int i = n; i >= 1; i--){
        int New = abs(sum - a[i] * n);
        if(New <= now){
            now = New;
            ans = i;
        }
    }
    cout << ans - 1 << endl;
    return 0;
}


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

#define ll long long

using namespace std;

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

    ll a,b,x,y;
    a = b = 0;

    while(n--)
    {
        cin >> x >> y;

        ll l = 1;
        ll h = (ll)10e17/max(x,y);

        //cout << l << " " << h << endl;

        while(l<h)
        {
            ll mid = (l+h)/2;

            ll temp1 = mid*x;
            ll temp2 = mid*y;

            if(temp1 >= a && temp2 >= b)
                h = mid;
            else
                l = mid+1;
        }

        a = x*l;
        b = y*l;

        //cout << a << b << endl;
    }

    cout << a+b << endl;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	cout << accumulate(a.begin(), a.end(), 0) - N << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
using namespace std;
const int MAXN=100005;

int N;
int rt1,rt2;
vector<int> adj1[MAXN],adj2[MAXN],adj[MAXN];
int stk[MAXN],tp;
bool vis[MAXN];
int ans[MAXN];

void dfs(int u,const vector<int> G[])
{
	for(auto v:G[u])
		dfs(v,G);
	if((G[u].size()&1)==0)
		stk[++tp]=u;
	while(tp>=2)
	{
		adj[stk[tp]].push_back(stk[tp-1]);
		adj[stk[tp-1]].push_back(stk[tp]);
		tp-=2;
	}
}
void Mark(int u,int val=1)
{
	vis[u]=true;
	ans[u]=val;
	for(auto v:adj[u])
	{
		if(vis[v])
			continue;
		Mark(v,-val);
	}
}

int main()
{
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		int f;
		scanf("%d",&f);
		if(f==-1)
			rt1=i;
		else
			adj1[f].push_back(i);
	}
	for(int i=1;i<=N;i++)
	{
		int f;
		scanf("%d",&f);
		if(f==-1)
			rt2=i;
		else
			adj2[f].push_back(i);
	}
	for(int i=1;i<=N;i++)
		if((adj1[i].size()&1)!=(adj2[i].size()&1))
		{
			puts("IMPOSSIBLE");
			return 0;
		}
	puts("POSSIBLE");
	tp=0;
	dfs(rt1,adj1);
	tp=0;
	dfs(rt2,adj2);
	for(int i=1;i<=N;i++)
		if(!vis[i])
			Mark(i);
	for(int i=1;i<=N;i++)
	{
		if(adj1[i].size()&1)
			printf("0 ");
		else
			printf("%d ",ans[i]);
	}
	puts("");
	
	return 0;
}


Measured memory_bytes: 15488
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

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 = 1; i <= n; i++){
		scanf("%d", &A[i]);
		C[A[i]]++;
	}
	
	for(i = 1; i <= VMAX; i++)C[i] = C[i] + C[i-1];
	
	for(j = n; j > 0; j--){
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}
	
	for(i = 1; i <= n; i++){
		if(i != n) printf("%d ", B[i]);
		else printf("%d\n", B[i]);
	}
	return 0;
}


Measured memory_bytes: 9600
# input
listA = []
while True:
    try:
        listA.append(int(raw_input()))
    except:
        break;

a = listA[0]
b = listA[1]
c = listA[2]
d = listA[3]
e = listA[4]
k = listA[5]

if (b-a <= k) and (c-a <= k) and (d-a <= k) and (e-a <= k) \
   and (c-b <= k) and (d-b <= k) and (e-b <= k) \
   and (e-c <= k) and (d-c <= k) \
   and (e-d <= k):
    print 'Yay!'
else:
    print ':('


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

int distance2(int a, int b){
  int c=0;
  if(a-b>=0){
    c = a-b;
  }else{
    c = b-a;
  }
  return c;
}

int main(void){
  int N;
  int *A;
  int i;
  long all_money=0;
  int money;
  int money2;
  int cost;
  
  
  scanf("%d", &N);
  A = malloc((N+1)*(sizeof(int)));
  A[0] = 0;
  for(i=1;i<=N;i++){
    scanf("%d", &A[i]);
  }

  
  for(i=0;i<=N;i++){
    all_money += distance2(A[i%(N+1)], A[(i+1)%(N+1)] );
  }

  for(i=1;i<=N;i++){
    money = distance2(A[(i-1)%(N+1)], A[i%(N+1)]) + distance2(A[i%(N+1)], A[(i+1)%(N+1)]);
    money2 = distance2(A[(i-1)%(N+1)], A[(i+1)%(N+1)]);
    cost = all_money - money + money2;
    printf("%d\n", cost);
  }
  return 0;

}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int N;
#define MAXN 2000
int main(){
    cin >> N;
    vector<int> L(N);
    rep(i,N)cin >> L[i];
    sort(L.begin(),L.end());
    ll ans = 0;
    for(int i=1;i<N;i++){
        int a = L[i];
        for(int j=0;j<i;j++){
            vector<int> V(i-j-1);
            for(int k=j+1;k<i;k++){
                V[k-j-1] = L[k];
            }
            int b = L[j];
            int tmp = lower_bound(V.begin(),V.end(),a+b)-upper_bound(V.begin(),V.end(),a-b);
            ans += tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
n,k = map(int,input().split())
P = list(map(lambda x:int(x) + 1 , input().split()))
s = [0] * (n+1)
for i in range(n):
    s[i+1] = s[i] + P[i]
res = 0
for i in range(n-k+1):
    res = max(res, s[i+k] - s[i])
print(res/2)


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

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;


int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    ll v[n];
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    ll dis[n-1];
    for(int i = 0; i < n-1; i++){
        dis[i] = v[i+1] - v[i];
    }
    ll ans = 0;
    for(int i = 0; i < n-1; i++){
        if(dis[i] * a >= b){
            ans += b;
        }else{
            ans += dis[i] * a;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int N, a[100005], sol, fcv[100005];
vector < int > pos;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
        
        if (a[i] == i) {
            pos.push_back(i);
        }
    }
    
    for (int i = pos.size() - 1; i >= 0; --i) {
        if (i > 0 && pos[i] - 1 == pos[i - 1]) {
            ++sol;
            --i;
        } else {
            ++sol;
        }
    }
    
    cout << sol << '\n';
    return 0;
}

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

typedef long long ll;

#define F first 
#define S second 
#define PB push_back
#define MP make_pair 
#define rep(i,a,b) for (ll i=a;i<=b;i++)

typedef vector<int> vi;
typedef pair<int,int> pi;

int main()
{
    string s;
    ll k,a = 1,ans = 0;
    vector<ll> cnt;
    cin >> s >> k;
    s += 'A';
    rep(i,0 ,s.size() - 2){
        if (s[i] == s[i + 1]) {
            ++a;
        }else{
            cnt.push_back(a);
            ans += a / 2;
            a = 1;
        }
    }
    ans *= k;
    if (cnt.size() == 1) {
        if (cnt[0] % 2 == 1) {
            ans += k / 2;
        }
        cout << ans << endl;
        return 0;
    }
    if (s[0] == s[s.size() - 2]) {
        if (cnt[0] % 2 == 1 && cnt[cnt.size() - 1] % 2 == 1) {
            ans += k - 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
	int N;
	cin >> N;//N = 1 kara 200
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i == 105 || i == 135 || i == 165 || i == 189 || i == 195) ans++;
		else continue;
	}
	cout << ans << endl;
	
}

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


int main(){
    int K;
     cin >> K;
     vector<ll> a;
     for(int i = 1; i < 10; i++) a.push_back(i);
     while(1){
         if(K <= a.size()){
             cout << a[K - 1] << endl;
             return 0;
         }
         K -= a.size();
         vector<ll> old;
         swap(old, a);
         for(ll x : old){
             for(int i = -1; i <= 1; i++){
                 int d = x % 10 + i;
                 if(d < 0 || d > 9) continue;
                 ll nx = x * 10 + d;
                 a.push_back(nx);
             }
         }
     }

}


Measured memory_bytes: 1712
n = int(input())
h = list(map(int,input().split()))
cost = [0 for _ in range(n)]
for i in range(1,n):
    if(i == 1):
        cost[i] = cost[i-1] + abs(h[i] -h[i-1])
    else:
        cost[i] = min(cost[i-1] + abs(h[i]-h[i-1]),cost[i-2] + abs(h[i]-h[i-2]))

print(cost[n-1])

Measured memory_bytes: 13928
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
int n;cin>>n;
int p[n];
rep(i,n)cin>>p[i];
int pre=200005;
int count=0;
rep(i,n){
    if(pre>=p[i]){
        count++;
        pre=p[i];
    }
}
cout<<count<<endl;
}

Measured memory_bytes: 1152
n,x = map(int,input().split())
p = [1]
q = [1]
for i in range(n):
    p.append(p[i]*2+1)
    q.append(q[i]*2+3)


def f(fn,fx):
    if fn == 0 and fx == 1:
        return 1
    elif fx == 1:
        return 0
    elif fx == q[fn]:
        return p[fn]
    elif fx == q[fn]//2+1:
        return 1+p[fn-1]
    elif 1 < fx < q[fn]//2+1:
        return f(fn-1, fx-1)
    else:
        return p[fn-1] + 1 + f(fn-1, fx-(q[fn-1]+2))


print(f(n,x))


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

int n,cnt;
vector<int> q[205];
int col[205];
int idx[205];
bool dfs(int x)
{
    bool ok=0;
    idx[x]=cnt;
    for(int i=0;i<q[x].size();i++)
    {
        int nx=q[x][i];
        if(col[nx]==0){
            col[nx]=3-col[x];
            ok|=dfs(nx);
        }
        else if(col[nx]!=(3-col[x]))ok=1;
    }
    return ok;
}

queue<int> que;
int dis[205];

int bfs(int st)
{
    int an=0;
    que.push(st);
    memset(dis,0,sizeof(dis));
    dis[st]=1;
    while(!que.empty())
    {
        int x=que.front();
        que.pop();
        an=max(an,dis[x]);
        for(int i=0;i<q[x].size();i++)
        {
            int nx=q[x][i];
            if(dis[nx]==0){
                dis[nx]=dis[x]+1;
                que.push(nx);
            }
        }
    }
    return an;
}

int maxn[205];

char in[205];

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",in+1);
        for(int j=1;j<=n;j++)
        {
            if(in[j]=='1')
                q[i].push_back(j);
        }
    }

    bool ok=0;
    for(int i=1;i<=n;i++)
    {
        if(!col[i]){
            cnt++;
            col[i]=1;
            ok|=dfs(i);
        }
    }

    if(ok){
        printf("-1\n");
        return 0;
    }

    for(int i=1;i<=n;i++)
        maxn[idx[i]]=max(maxn[idx[i]],bfs(i));
    int ans=0;
    for(int i=1;i<=cnt;i++)
        ans+=maxn[i];

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

    return 0;
}


Measured memory_bytes: 512
N,K = map( int ,input().split())
R,S,P = map( int ,input().split())
T = input()
A = list()
point = 0
for i in range(len(T)):
    if T[i] == 'r' :
        A.append('p')
    elif T[i] == 's':
        A.append('r')
    else:
        A.append('s')
#print(A)
point = A.count('p')*P + A.count('r')*R + A.count('s')*S
#print(point)
for j in range(len(A)-K):
    if A[j] == A[j+K]:
        if A[j] == 'r':
            A[j+K] = 'N'
            point -= R
        elif A[j] == 's':
            A[j+K] = 'N'
            point -= S
        else:
            A[j+K] = 'N'
            point -= P
#print(A)
print(point)

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

int main() {
  string S; cin >> S;
  long len = S.length();

  long total{};
  for (int i{}; i < (1 << len - 1); ++i) {
    long num = S[0] & 0xF;
    for (int j{}; j < len - 1; ++j) {
      if (i & (1 << j)) {
        total += num;
        num = 0;
      } else {
        // no op
      }
      num *= 10;
      num += S[j + 1] & 0xF;
    }
    total += num;
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
int main(){
    ll n,k,ans=0;cin>>n>>k;
    vector<ll> a(n);
    For(i,n){
        cin>>a.at(i);
    }
    For(i,n){
        for(ll j=i+1;j<n;j++){
            if(a.at(i)<a.at(j)){
                ans+=((k-1)*k)/2;
            }
            else if(a.at(i)>a.at(j)){
                ans+=((k+1)*k)/2;
            }
            ans=ans%MOD;
        }
    }
    cout<<ans%MOD<<endl;
}


Measured memory_bytes: 256
import numpy as np
d = int(input())
ci = list(map(int, input().split()))
sdi_list = []
for i in range(d):
    sdi = list(map(int, input().split()))
    sdi_list.append(sdi)

lastdi = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
manzoku = 0
for i in range(d):
    td = np.argmax(sdi_list[i]) + 1
    manzokuteika = 0
    lastdi[td-1] = i + 1
    for j in range(26):
        manzokuteika = manzokuteika + ci[j] * (i + 1 - lastdi[j])
    manzoku = manzoku + sdi_list[i][td-1] - manzokuteika
    print(td)


Measured memory_bytes: 27652
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[200][200];
int dam[26];
char in[2];
int row[1100];
int col[1100];
int q[14];
int dp[1100][1<<12];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		int n,m;scanf("%d%d",&n,&m);
		for(int i=0;i<n;i++)scanf("%s",str[i]);
		int t;scanf("%d",&t);
		for(int i=0;i<t;i++){
			int tmp;
			scanf("%s%d",in,&tmp);
			dam[in[0]-'A']=tmp;
		}
		int s;scanf("%d",&s);
		int sz=0;
		row[0]=col[0]=0;
		sz++;
		for(int i=0;i<s;i++){
			int tmp;
			scanf("%s%d",in,&tmp);
			for(int j=0;j<tmp;j++){
				row[sz]=row[sz-1];col[sz]=col[sz-1];
				if(in[0]=='U')row[sz]--;
				if(in[0]=='D')row[sz]++;
				if(in[0]=='L')col[sz]--;
				if(in[0]=='R')col[sz]++;
				sz++;
			}
		}
		int p;scanf("%d",&p);
		for(int i=0;i<p;i++)scanf("%d",q+i);
		for(int i=0;i<=sz;i++)for(int j=0;j<(1<<p);j++)dp[i][j]=0;
		dp[1][0]=a;
		for(int i=1;i<sz;i++){
			for(int j=0;j<(1<<p);j++){
				if(dp[i][j]<=0)continue;
				int nc=dam[str[row[i]][col[i]]-'A'];
				if(dp[i][j]-nc>0)dp[i+1][j]=max(dp[i+1][j],dp[i][j]-nc);
				for(int k=0;k<p;k++){
					if(j&(1<<k))continue;
					if(min(dp[i][j]+q[k],b)-nc>0)dp[i+1][j+(1<<k)]=max(dp[i+1][j+(1<<k)],min(dp[i][j]+q[k],b)-nc);
				}
			}
		}
		bool ok=false;
		for(int i=0;i<(1<<p);i++)if(dp[sz][i]>0)ok=true;
		if(ok)printf("YES\n");
		else printf("NO\n");
	}
}

Measured memory_bytes: 17428
#include <iostream>

using namespace std;

int main(){
  int a[6]={500,100,50,10,5,1},input,count,i;
  while(1){
    cin>>input;
    if(input==0){
      break;
    }
    input=1000-input;
    for(i=0,count=0;i<6;i++){
      if(input/a[i]>0){
        count+=input/a[i];
      }
      input=input-(input/a[i])*a[i];
    }
    cout<<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>

using namespace std;
char a[20];

int main()
{
	int A,B;
	scanf("%d%d",&A,&B);
	if(A == B)
	printf("Draw\n");
	else if(A == 1)
	printf("Alice\n");
	else if(B == 1)
	printf("Bob\n");
	else if(A > B)
	printf("Alice\n");
	else
	printf("Bob\n");
	return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> v(N), cost(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		if (i) {
			cost[i] = 1e9;
		}
	}
	for (int i = 0; i < N; i++) {
		if (i+1 < N)
			cost[i+1] = min(cost[i]+abs(v[i]-v[i+1]), cost[i+1]);
		if (i+2 < N)
			cost[i+2] = min(cost[i]+abs(v[i]-v[i+2]), cost[i+2]);
	}
	cout << cost[N-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  while(A!=B){
    if(A>B) A=A-B;
    else if(A<B) B=B-A;
    else break;
  }
  if(C%A==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> p(M);
    vector<string> S(M);
    vector<int> number(100005);
    vector<int> penal(100005);
    rep(i,M){
        cin >> p[i];
        cin >> S[i];
    }
    rep(i,100005){
        number[i] = 0;
    }
    int ans = 0;
    int penalty = 0;
    rep(i,M){
        if (S[i] == "WA"){
            if (number[p[i]] == 0){
                penal[p[i]]++;
            }
            else{
                continue;
            }
        }
        else if (S[i] == "AC"){
            if (number[p[i]] == 0){
                ans++;
                number[p[i]]++;
                penalty += penal[p[i]];
            }
            else{
                continue;
            }
        }
    }
    cout << ans <<" " << penalty << endl;
}


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

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> vec(n);
    rep(i,n) cin >> vec.at(i);
    int a = 0;
    rep(i,n-1) {
        a = max(a, vec.at(i+1) - vec.at(i));
    }
    int b = k - vec.at(n-1) + vec.at(0);
    if(a > b) {
        cout << k - a << endl;
    } else cout << k - b << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long ll;

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




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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
using ll=long long;

ll calc(const vector<vector<ll>>& querys, ll num){
  for(const auto& query: querys){
    ll q=query[0], x=query[1], s=query[2], t=query[3];
    if(q==1){
      if(x<=num)num=(num+s)*t;
    }else{
      if(num<=x)num=(num-s)/t;// marumekomi?
    }
  }
  return num;
}

int main(){
  ll N,Q,L,R;
  cin>>N>>Q>>L>>R;
  vector<ll> A(N);
  vector<vector<ll>> querys(Q,vector<ll>(4));

  rep(i,N)cin>>A[i];
  sort(A.begin(),A.end());
  rep(i,Q)rep(j,4)cin>>querys[i][j];

  ll res1,res2;
  ll l=-1,r=N-1;
  while(r-l>1){
    ll mid=(l+r)/2;
    (L<=calc(querys, A[mid]) ? r:l)=mid;
  }
  res1=r;

  l=0,r=N;
  while(r-l>1){
    ll mid=(l+r)/2;
    (calc(querys, A[mid])<=R ? l:r)=mid;
  }
  res2=l;
  //cerr<<res1<<"--"<<res2<<endl;
  cout<<res2-res1+1<<endl;
  return 0;
}



Measured memory_bytes: 18012
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<cmath>
using namespace std;

int main(void)
{
	string a, b;
	cin >> a >> b;

	int n = stoi(a+b);
	int rn = sqrt(n);

	string ret;
	if(rn*rn == n)
		ret = "Yes";
	else
		ret = "No";

	cout << ret << endl;

	return 0;
}


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

int main(){
	int i,h[10];
	for(i=0;i<10;i++){
		cin>>h[i];
	}
	sort(h,h+10);
	for(i=0;i<3;i++){
		cout<<h[9-i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    long long N, M; cin >> N >> M;
    long long res;
    if (N == 1 && M == 1) res = 1;
    else if (N == 1 || M == 1) res = N * M - 2;
    else res = N * M - 2 * N - 2 *  M + 4;;
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define int long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1e15
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pb push_back

using namespace std;


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




int32_t main()
{
	std::ios::sync_with_stdio(false);

#ifndef ONLINE_JUDGE
	freopen("inputf.txt", "r", stdin);
	freopen("outputf.txt", "w", stdout);
#endif
	int cnt = 0;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		double x, y;
		cin >> x >> y;

		double ab = sqrt((x * x) + (y * y));
		//cout << ab << endl;
		if (ab <= m)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

void solve(int N, int M, vi& P, vi& Y) {
    vi ans(M, -1);
    vector<vector<ii>> w(N + 1);
    rep(i, M) {
        w[P[i]].pb(ii(Y[i], i));
    }
    rep1(pref, N) {
        sort(ALL(w[pref]));
        for (int j = 0, c = w[pref].size(); j < c; ++j) {
            int city = w[pref][j].second;
            ans[city] = 1+j;
        }
    }
    rep(i, M) {
        printf("%06d%06d\n", P[i], ans[i]);
    }
}

int main() {
    int N, M; scanf("%d %d", &N, &M);
    vi P(M), Y(M);
    rep(i,M) scanf("%d %d", &P[i], &Y[i]);
    solve(N,M,P,Y);
    return 0;
}


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

int main(){
  int a[5] = {};
  for (int i = 0;i < 5;i++)
    cin >> a[i];
  
  int min = 100;
  int index = 0;
  for(int i = 0;i < 5;i++) {
    if(a[i]%10 != 0 && a[i]%10 < min) {
      min = a[i]%10,index = i;
    }
  }
  int ans = 0;
  for(int i = 0;i < 5;i++) {
    if(i != index)
      ans += (a[i] + ((a[i]%10 == 0) ? 0 : 10 - a[i]%10));
  }
  ans += a[index];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a = 0,b = 0,ab = 0,o = 0;
    int gakureki;
    char blood[3];
    while(scanf("%d,%s",&gakureki,blood)==2){
        if(blood[0] == 'A'){
            if(blood[1]=='B'){
                ab++;
            }
            else if(blood[1]=='\0'){
                a++;
            }
        }
        if(blood[0]=='B'&&blood[1]=='\0'){
            b++;
        }
        if(blood[0]=='O'&&blood[1]=='\0'){
            o++;
        }
    }
    printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

vector<pair<long long, long long>> prime_factorize(long long n) {
    vector<pair<long long, long long>> res;
    for(long long p = 2; p * p <= n; ++p) {
        if(n % p != 0)
            continue;
        int num = 0;
        while(n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if(n != 1)
        res.push_back(make_pair(n, 1));
    return res;
}

const int COMMAX = 1000000;
long long fac[COMMAX], finv[COMMAX], inv[COMMAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1]            = 1;
    for(int i = 2; i < COMMAX; i++) {
        fac[i]  = fac[i - 1] * i % MOD;
        inv[i]  = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    cout << fixed << setprecision(10);
    COMinit();
    LLI X, Y;
    cin >> X >> Y;

    if((2 * Y - X) % 3 != 0) {
        cout << 0;
        return 0;
    }
    LLI a = (2 * Y - X) / 3;

    LLI d = COM((X - a) / 2 + a, a);

    if(d == 0) {
        LLI a2 = (2 * X - Y) / 3;

        LLI d2 = COM((Y - a2) / 2 + a2, a2);
        cout << d2 % MOD;
    } else {
        cout << d % MOD;
    }

    return 0;
}

Measured memory_bytes: 23808
N, M = tuple(map(int, input().split()))
A, B = [], []
for _ in range(M):
    a, b = tuple(map(int, input().split()))
    A.append(a)
    B.append(b)
roads = {i: 0 for i in range(1, N+1)}
for a, b in zip(A, B):
    roads[a] += 1
    roads[b] += 1
for key, val in sorted(roads.items()):
    print(val)

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

int main() {
	int N;
	cin >> N;
	int ans = 0, before=0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a == before) {
			ans++;
			before = 0;
		}
		else before = a;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

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

  			int n,m;
  			double sum =0;
  			cin >> n >> m;
  			int a[n];
  			for(int i =0;i<n;i++){
  				cin >> a[i];
  				sum = sum + a[i];
  			}
  		

  			sort(a,a+n);
  			if(a[n-m] >= sum/(4*m))
  				cout << "Yes";
  			else cout << "No";
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll N;
	cin >> N;

	vector<ll> As(N);
	vector<ll> Bs(N);
	for (ll i = 0; i < N; ++i) {
		cin >> As[i];
	}
	for (ll i = 0; i < N; ++i) {
		cin >> Bs[i];
	}

	queue<ll> to_operate;
	ll a_plus_c;
	for (ll i = 0; i < N; ++i) {
		a_plus_c = Bs[(i - 1 + N) % N] + Bs[(i + 1 + N) % N];
		if (Bs[i] > a_plus_c && Bs[i] > As[i]) {
			to_operate.push(i);
		}
	}

	ll res = 0;
	while (!to_operate.empty()) {
		auto idx = to_operate.front();
		to_operate.pop();

		a_plus_c = Bs[(idx - 1 + N) % N] + Bs[(idx + 1 + N) % N];
		if (Bs[idx] - a_plus_c < As[idx]) {
			continue;
		}

		res += Bs[idx] / a_plus_c;
		Bs[idx] %= a_plus_c;
		if (Bs[idx] < As[idx]) {
			ll incr = (As[idx] - Bs[idx] + a_plus_c - 1) / a_plus_c;
			res -= incr;
			Bs[idx] += a_plus_c * incr;
		}

		ll i = (idx - 1 + N) % N;
		a_plus_c = Bs[(i - 1 + N) % N] + Bs[(i + 1 + N) % N];
		if (Bs[i] > a_plus_c && Bs[i] > As[i]) {
			to_operate.push(i);
		}

		i = (idx + 1 + N) % N;
		a_plus_c = Bs[(i - 1 + N) % N] + Bs[(i + 1 + N) % N];
		if (Bs[i] > a_plus_c && Bs[i] > As[i]) {
			to_operate.push(i);
		}
	}

	for (ll i = 0; i < N; ++i) {
		if (As[i] != Bs[i]) {
			res = -1;
			break;
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for(int i=0; i<N; i++) std::cin >> A[i];

    double sum = 0;
    for(int i=0; i<N; i++) sum += (1.0 / A[i]);
    std::cout << 1.0 / sum << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define asort(x) sort(x.begin(),x.end())
 
int main() {
    int k;
    string s;
    cin>>k>>s;
    if(s.size() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0,k) + "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628