akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int N, M;
    string s, t;
    map<string, int> mp;
    cin >> N;
    rep(i, N) {
        cin >> s;
        mp[s]++;
    }
    cin >> M;
    rep(i, M) {
        cin >> t;
        mp[t]--;
    }
    int ans = 0;
    for (auto i : mp) {
        ans = max(ans, i.second);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=2e5+5,M=5e6+5;
int en=1,h[N],n,a[N],b[N],id1[N],id2[N],cnt,cnt1,cnt2,d[N],cur[N];

struct edge{
	int n,v,w;
}e[M<<1];

void add(int x,int y,int z){
	e[++en]={h[x],y,z};
	h[x]=en;
}

void exadd(int x,int y,int f){
	add(x,y,f);
	add(y,x,0);
}

bool bfs(int s,int aim){
	for(int i=0;i<=cnt1+cnt2+1;i++) d[i]=0,cur[i]=h[i];
//	memset(d,0,sizeof d);
//	memcpy(cur,h,sizeof cur);
	queue<int> q;
	q.push(s);
	d[s]=1;
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(int i=h[x];i;i=e[i].n){
			int y=e[i].v;
			if(!d[y]&&e[i].w){
				d[y]=d[x]+1;
				if(y==aim) return 1;
				q.push(y);
			}
		}
	} 
	return 0;
}

int dfs(int x,int flow,int aim){
	if(x==aim) return flow;
	int rest=flow;
	for(int &i=cur[x];i&&rest;i=e[i].n){
		int y=e[i].v;
		if(d[y]==d[x]+1&&e[i].w){
			int tp=dfs(y,min(rest,e[i].w),aim);
			if(!tp) d[y]=0;
			rest-=tp;
			e[i].w-=tp;
			e[i^1].w+=tp;
		}
	}
	return flow-rest;
}

int dinic(int s,int t){
	int res=0;
	while(bfs(s,t)) res+=dfs(s,INT_MAX,t);
	return res;
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]),a[i]++;
	for(int i=1;i<=n;i++) read(b[i]),b[i]++;
	for(int i=1;i<=n;i++) if(!id1[i]){
		cnt1++;
		int x=i;
		do{
			id1[x]=cnt1;
			x=a[x];
		}while(x!=i);
	}
	for(int i=1;i<=n;i++) if(!id2[i]){
		cnt2++;
		int x=i;
		do{
			id2[x]=cnt2;
			x=b[x];
		}while(x!=i);
	}
  	for(int i=1;i<=n;i++){
  		int x=id1[i],y=id2[i];
  		if(a[i]!=i&&b[i]!=i){
  			exadd(x,cnt1+y,1);
  			if(a[i]==b[i]) exadd(cnt1+y,x,1);
		}
		else if(a[i]!=i) exadd(x,cnt1+cnt2+1,1);
		else if(b[i]!=i) exadd(0,cnt1+y,1);
		else cnt++;
	}
  	write(n-cnt-dinic(0,cnt1+cnt2+1));
}


Measured memory_bytes: 14276
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 *
	 */
	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int dir[][] = new int[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(dir[i], -1);
		}

		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			dir[a][b] = c;
		}
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (dir[i][k] < 0 || dir[k][j] < 0)
						continue;
					dir[i][j] = Math.max(dir[i][j], dir[i][k] + dir[k][j]);
				}
			}
		}
		System.out.println(dir[0][n-1]);
	}

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().run();

	}
}

Measured memory_bytes: 25068
#include<iostream>
#include<string>

using namespace std;

int chmin(int a, int b){return (a < b)? a: b;}

int main(){
  string s;

  cin >> s;

  int cnt_0 = 0;
  int cnt_1 = 0;
  size_t size = s.length();
  for(int i =0; i < size; ++i){
    if(s[i] == '0')++cnt_0;
    if(s[i] == '1')++cnt_1;
  }
  cout << chmin(cnt_0,cnt_1) * 2 << endl;
}





Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;
const int N=1e5+5;
using namespace std;
ll l[N],r[N];
ll a[N];
int main()
{
    int n;cin>>n;
    for(int i=0;i<=n;i++) cin>>a[i];
    if(n==0)
    {
        if(a[0]==1) cout<<1<<endl;
        else cout<<-1<<endl;
        return 0;
    }
    //l[0]=1,r[0]=1;
    for(int i=n;i>=0;i--)
    {
        l[i]=(l[i+1]+1)/2+a[i];
        r[i]=r[i+1]+a[i];
    }
    if(l[0]!=1)
    {
        cout<<-1<<endl;
        return 0;
    }
    ll ans=1,t=1;
    for(int i=1;i<=n;i++)
    {
        t-=a[i-1];
        t=min(r[i],t*2);
        ans+=t;
    }
    cout<<ans<<endl;
    return 0;
}


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

ll MOD = ll(1000000000+7);

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

int main(void)
{
    ll N, K;
    cin >> N >> K;
    vector<ll> ans(K+1, 0ll);
    for(int k=K;k>=1;k--){
        ll d = K / k;
        ll a = mpow(d, N);
        for(int m=2;m<=d;m++){
            a += MOD - ans[m*k]; a %= MOD;
        }
        ans[k] = a;
    }
    ll answer = 0ll;
    for(int k=1;k<=K;k++){
        answer += ans[k] * k; answer %= MOD;
    }
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 4020
#include <iostream>
using namespace std;
using ll = long long;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  ll max,min,tmp,tmp1,tmp2;
  cin>>tmp1>>tmp2;
  (tmp1>=tmp2)?(max=tmp1,min=tmp2):(max=tmp2,min=tmp1);
  for(int i=0;i<n-2;i++){
    cin>>tmp;
    if(tmp>max) max=tmp;
    if(tmp<min) min=tmp;
  }
  cout<<max-min<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void)
{
  double r,menseki,enshuu;
  scanf("%lf",&r);
  menseki=r*r*M_PI;
  enshuu=2*r*M_PI;
  printf("%f %f\n",menseki,enshuu);
  return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#define ll long long
#define vel vector<int>
#define vvel vector<vel>
#define veb vector<bool>
#define pin pair<int,int>
#define mp make_pair 
#define int long long
using namespace std;
void mmin(int &a, int b) { a = min(a, b); }
int low(vel &s,int x){return s[upper_bound(s.begin(), s.end(), x) - s.begin()-1];}
int upp(vel &s,int x){return s[lower_bound(s.begin(), s.end(), x) - s.begin()];}
void cal(vel &s, vel &t, int &ans, int x) {
	int si = low(s, x); int co0 = x - si;
	int sisi = low(t, si); int co1 = si - sisi;
	int siue = upp(t, si); int co2 = siue - si;
	mmin(ans, co0 + min(co1, co2));
	int ue = upp(s, x); int co3 = ue - x;
	int ueue = upp(t, ue); int co4 = ueue - ue;
	int uesi = low(t, ue); int co5 = ue - uesi;
	mmin(ans, co3 + min(co4, co5));
}
signed main() {
	ll a, b;
	cin >> a >> b;
	vel s(a + 2);
	s[0] = -100000000000;
	s[a + 1] = 200000000000;
	vel t(b + 2);
	t[0] = s[0];
	t[b + 1] = s[a + 1];
	int q; cin >> q;
	for (int i = 1; i <= a; i++) { cin >> s[i]; }
	for (int i = 1; i <= b; i++) { cin >> t[i]; }
	for (int i = 0; i < q; i++) {
		int x; cin >> x;
		int ans = s[a + 1];
		cal(s, t, ans, x);
		cal(t, s, ans, x);
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int N,M,C;
    int ans = 0;
    cin >> N >> M >> C;
    vector <int> B(M);
    vector < vector <int> > A(N,vector<int>(M));
    for (int i = 0; i < M; i++) cin >> B.at(i);
    for (int i = 0; i < N; i++){
        for (int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < N; i++){
        int num = 0;
        for (int j = 0; j < M; j++){
            num += A[i][j]*B[j];
        }
        num += C;
        if (num > 0) ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cassert>

using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    vector<pair<int, int> > A, B;
    for(int n=0; n<N; ++n) {
        int a;
        scanf("%d", &a);
        A.emplace_back(a, n);
    }
    for(int n=0; n<N; ++n) {
        int b;
        scanf("%d", &b);
        B.emplace_back(b, n);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    for(int n=0; n<N; ++n) {
        if(B[n].first<A[n].first) {
            printf("No\n");
            return 0;
        }
    }
    for(int n=1; n<N; ++n) {
        if(A[n].first<=B[n-1].first) {
            printf("Yes\n");
            return 0;
        }
    }
    vector<int> Ans(N), Now(N), Pos(N);
    for(int n=0; n<N; ++n) {
        Now[n] = n;
        Pos[n] = n;
        Ans[B[n].second] = A[n].second;
    }
    for(int n=0; n<N-1; ++n) {
        if(Now[n]==Ans[n]) {
            printf("Yes\n");
            return 0;
        }
        int i = Pos[Ans[n]];
        Now[i] = Now[n];
        Pos[Now[i]] = i;
    }
    printf("No\n");
    return 0;
}


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

int main() {
	string w; cin >> w;
	for (char&c : w)c = tolower(c);
	string s;
	int cnt = 0;
	while (cin >> s, s != "END_OF_TEXT") {
		for (char&c : s)c = tolower(c);
		if (s == w)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3152
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <ctime>
#include <bitset>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};
ll gcd(ll a, ll b) {if (b==0) return a; else return gcd(b, a%b);}

int main() {
  int n; cin>>n;
  ll x[n],y[n];
  for(int i=0;i<n;i++) cin>>x[i]>>y[i];

  ll an = 0, mn = 3e9;

  for(int i=0;i<n;i++) {
    ll nw = x[i]+y[i]-1;
    chmax(an, nw-mn);
    chmin(mn, nw);
  }

  mn = 3e9;

  for(int i=0;i<n;i++) {
    x[i] = 1e9 - x[i];
  }

  mn = 3e9;
  for(int i=0;i<n;i++) {
    ll nw = x[i]+y[i]-1;
    chmax(an, nw-mn);
    chmin(mn, nw);
  }

  for(int i=0;i<n;i++) {
    y[i] = 1e9 - y[i];
  }

  mn = 3e9;
  for(int i=0;i<n;i++) {
    ll nw = x[i]+y[i]-1;
    chmax(an, nw-mn);
    chmin(mn, nw);
  }

  for(int i=0;i<n;i++) {
    x[i] = 1e9 - x[i];
  }

  mn = 3e9;
  for(int i=0;i<n;i++) {
    ll nw = x[i]+y[i]-1;
    chmax(an, nw-mn);
    chmin(mn, nw);
  }

  cout<<an<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


Measured memory_bytes: 6756
#include<iostream>
using namespace std;
int main(){

  int N,K,itmp;
  double dtmp;
  cin>>N>>K;
  int x;
  for(int i=0;i<N;i++) cin>>x;
  
  dtmp=(double)(N-K)/(double)(K-1);
  itmp=dtmp;
  if(dtmp-(double)itmp!=0.0) itmp+=1;

  cout<<(itmp+1)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

template <class T, class F>
vector<T> cumulative_sum(size_t n, F f) {
    vector<T> acc(n+1);
    repeat (i,n) {
        acc[i+1] = acc[i] + f(i);
    }
    return acc;
}
template <class T, class F>
vector<vector<T> > cumulative_sum(size_t h, size_t w, F f) {
    vector<vector<T> > acc(h+1, vector<T>(w+1));
    repeat (y,h) {
        repeat (x,w) {
            acc[y+1][x+1] = acc[y+1][x] + f(y, x);
            acc[y+1][x] += acc[y][x];
        }
        acc[y+1][w] += acc[y][w];
    }
    return acc;
}

int main() {
    int h, w, query; scanf("%d%d%d", &h, &w, &query);
    vector<vector<bool> > f = vectors(h, w, bool());
    repeat (y,h) {
        repeat (x,w) {
            char c; scanf(" %c", &c);
            f[y][x] = c != '0';
        }
    }
    auto g_hr = [&](int y, int x) { return x >= 1 and f[y][x-1] and f[y][x]; };
    auto g_vr = [&](int y, int x) { return y >= 1 and f[y-1][x] and f[y][x]; };
    auto g = [&](int y, int x) { return g_hr(y, x) + g_vr(y, x); };
    vector<vector<int> > acc = cumulative_sum<int>(h, w, [&](int y, int x) { return f[y][x] - g(y, x); });
    vector<vector<int> > hr(h); repeat (y,h) hr[y] = cumulative_sum<int>(w, [&](int x) { return g_vr(y, x); });
    vector<vector<int> > vr(w); repeat (x,w) vr[x] = cumulative_sum<int>(h, [&](int y) { return g_hr(y, x); });
    while (query --) {
        int ly, lx, ry, rx; scanf("%d%d%d%d", &ly, &lx, &ry, &rx); -- ly; -- lx; // [ly, ry) * [lx, rx)
        int result = 0;
        result += acc[ry][rx] - acc[ry][lx] - acc[ly][rx] + acc[ly][lx];
        result += hr[ly][rx] - hr[ly][lx];
        result += vr[lx][ry] - vr[lx][ly];
        printf("%d\n", result);
    }
    return 0;
}


Measured memory_bytes: 49536
#include <iostream>
#include <vector>
using namespace std;
typedef unsigned long long UL;
UL GetGB(UL a,UL b){
	UL r, x, tmp;
	UL A=a;
	UL B=b;
	//自然数 a > b を確認・入替 
	if(a<b){ 
		tmp = a; 
		a = b; 
		b = tmp; 
	} 
	//ユークリッドの互除法 
	r = a % b; 
	while(r!=0){ 
		a = b; 
		b = r; 
		r = a % b; 
	} 
	if (A%b==0){
		return (A/b)*B;
	}
	if (B%b==0){
		return (B/b)*A;
	}
	int n=0;
	while (b%2==0){
		n++;
		b/=2;
	}
	while (A%2==0){
		if (n>0){
			A/=2;
			n--;
		}
	}
	while (B%2==0){
		if (n>0){
			B/=2;
			n--;
		}
	}
	if (A%b==0){
		A/=b;
		b=1;
	}
	if (B%b==0){
		B/=b;
		b=1;
	}
	//最小公倍数を出力
	return (A*B)/b;
}
int main(int argc, char* argv[])
{
	int N;
	int i,j;
	cin>>N;
	vector<UL> T(N);
	for (i=0;i<N;i++){
		cin>>T[i];
	}
	UL maxGB=T[0];
	for (i=0;i<N-1;i++){
		for (j=i+1;j<N;j++){
			UL gb=GetGB(maxGB,T[j]);
			if (maxGB<gb){
				maxGB=gb;
			}
		}
	}
	cout<<maxGB<<endl;
	return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
#初期値
x = X ; y = Y
mn = 1e10
if 2*C-(A+B) >= 0 :
    ans = A * x + B * y
    print(ans)
else :
    for z in range(0,max(X,Y)*2+1,2) :
        if x > 0 and y > 0 :
            ans = A*x + B*y + C*z
            mn = min(mn,ans)
            x -= 1 ; y -= 1
        elif x > 0 and y == 0 :
            ans = A*x + C*z
            mn = min(mn, ans)
            x -= 1
        elif x == 0 and y > 0 :
            ans = B*y + C*z
            mn = min(mn, ans)
            y -= 1
        else :
            ans = C*z
            mn = min(mn, ans)
    print(mn)


Measured memory_bytes: 9096
n = int(input())
ss = []
for _ in range(n):
    ss.append(sorted(input().strip()))
ss.sort()
now = ss[0]
ans = 0
cnt = 1
for i in range(1, n):
    if ss[i] == now:
        cnt += 1
    else:
        if cnt != 1:
            ans += cnt * (cnt - 1) // 2
        now = ss[i]
        cnt = 1
if cnt != 1:
    ans += cnt * (cnt - 1) // 2
print(ans)


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

const int MAX_V = 10000;

int V, E;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];

void add_edge(int from, int to) {
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v) {
  used[v] = true;
  for(int i=0; i<G[v].size(); i++) {
    if(!used[G[v][i]]) dfs(G[v][i]);
  }
  vs.push_back(v);
}

void rdfs(int v, int k) {
  used[v] = true;
  cmp[v] = k;
  for(int i=0; i<rG[v].size(); i++) {
    if(!used[rG[v][i]]) rdfs(rG[v][i], k);
  }
}

int scc() {
  memset(used, 0, sizeof(used));
  vs.clear();
  for(int v=0; v<V; v++) {
    if(!used[v]) dfs(v);
  }
  memset(used, 0, sizeof(used));
  int k=0;
  for(int i=vs.size() - 1; i>=0; i--) {
    if(!used[vs[i]]) rdfs(vs[i], k++);
  }
  return k;
}

int main() {
  
  cin >> V >> E;
  int s, t;
  
  for(int i=0; i<E; i++) {
    cin >> s >> t;
    add_edge(s, t);
  }

  scc();

  int q;
  cin >> q;
  
  for(int i=0; i<q; i++) {
    cin >> s >> t;
    cout << ( cmp[s] == cmp[t] ) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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


/* ACL */

//using namespace atcoder;



int main(){
    string S;
    cin >> S;
    if(S.at(S.size()-1)=='s'){
        cout << S +"es" << endl;
    }else{
        cout << S+"s" << endl;
    }
    return 0;
}

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



a, b, c = gets.split.map(&:to_i).sort

ans = 0

ans += (c - b) / 2
if (c - b).even?
  b = c
else
  ans += 1
  b = c
  a += 1
end

ans += (c - a) / 2
if (c - a).odd?
  ans += 2
end

puts ans


Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<complex>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=1000005;
int n,father[N],m,dist[N];
inline int getfather(int x){
	if(father[x]==x)return x;
	int t=getfather(father[x]);
	dist[x]+=dist[father[x]];
	return father[x]=t;
}
int main(){
	n=read(); m=read();
	for(int i=1;i<=n;i++)father[i]=i;
	for(int i=1;i<=m;i++){
		int l=read(),r=read(),d=read();
		int t1=getfather(l),t2=getfather(r);
		if(t1!=t2){
			dist[t2]=d-dist[r]+dist[l];
			father[t2]=t1;
		}else{
			if(dist[r]-dist[l]!=d){
				puts("No"); return 0;
			}
		}
	}
	puts("Yes");
}

Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
using namespace std;int main(){long long x;cin>>x;for(int i=0;i<=1000;i++){for(int j=-1000;j<=i;j++){if((long long)i*i*i*i*i-(long long)j*j*j*j*j==x){cout<<i<<" "<<j<<endl;return 0;}}}}

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

int main(){
    int a,b;
    cin>>a>>b;
    for(int x=0;x<b+2;x++){
    	cout<<"#";
	}cout<<endl;
	for(int x=0;x<a;x++){
		string z;
		cin>>z;
		cout<<"#"<<z<<"#"<<endl;
	}
	for(int x=0;x<b+2;x++){
    	cout<<"#";
	}
}

Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 10**9+7
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    a = A[i]
    s1 = 0
    s2 = 0
    for j in range(N):
        if a > A[j]:
            s2 += 1
    for j in range(i, N):
        if a > A[j]:
            s1 += 1
    ans = (ans + K*s1 + (K-1)*K//2*s2)%mod

print(ans)

Measured memory_bytes: 42476
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

int t = 0;

void selectionSort(vector<int> &a, int n) {
  int minj;
  rep(i, n) {
    minj = i;
    FOR(j, i, n) {
      if (a[j] < a[minj]) {
        minj = j;
      }
    }
    if (minj != i) {
      swap(a[i], a[minj]);
      t++;
    }
  }

  rep(i, n) {
    if (i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  cout << t << endl;
}

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

  selectionSort(a, n);

  
  return 0;
}


Measured memory_bytes: 3092
import Foundation

let  menber = (Int(readLine()!) ?? 0 ) 
var	 boss_num = Array(repeating: 0, count: menber-1)
boss_num = (readLine()!).components(separatedBy: " ").map{Int($0) ?? 0 }

var	 subordinate = Array(repeating: 0, count: menber)
boss_num.forEach{
   subordinate[$0-1] += 1
}

subordinate.forEach{
   print($0)
}

Measured memory_bytes: 22480
{-# OPTIONS_GHC -O #-}
import Data.List
import Data.Array.Unboxed

mp = 1000000007

powmod = pd' 1 where
    pd' x _ 0 = x
    pd' x a b
        | odd b = pd' (mod (x*a) mp) a (b-1)
        | otherwise = pd' x (mod (a*a) mp) (div b 2)

facts n = listArray (0,n) $ scanl' (\f n->(mod (f*n) mp)) 1 [1..]
ifacts fs = array (0,n) $ take (n+1) $ iterate psi (n,im) where
    n = snd $ bounds fs
    im = powmod (fs ! n) (mp-2)
    psi (n,m) = (n-1, mod (m*n) mp)

cmbmod fs ifs n k = (`mod` mp) $ (* t3) $ (`mod` mp) $ t1*t2 where
    t1 = fs ! n
    t2 = ifs ! k
    t3 = ifs ! (n-k)

main = do
    (h:w:a:b:_)<-map read.words<$>getLine::IO[Int]
    let fs = facts (h+w-2) :: UArray Int Int
    let ifs = ifacts fs :: UArray Int Int
    print $ foldl' (\a x->mod (a+x) mp) 0 $ unfoldr (way fs ifs) (b + (h-a-1), b, a-1 + (w-b-1), w-b-1)
way _ _ (_,_,_,-1) = Nothing
way fs ifs (n1,k1,n2,k2) = Just (mod (w1*w2) mp, (n1+1, k1+1, n2-1, k2-1)) where
    w1 = cmbmod fs ifs n1 k1
    w2 = cmbmod fs ifs n2 k2


Measured memory_bytes: 5372
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <math.h>
#include <stdio.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
P x[210000];
double pi = 3.1415926535897932384626433832;
int dp[210000];

int main(){
  ll x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cin >> N;
  int in = 0;
  for(int i = 0; i < N; i++){
    ll a, b;
    cin >> a >> b;
    if((x1-a)*(x2-a) <= 0 && (y1-b)*(y2-b) <= 0){
      x[in].first = a;
      x[in].second = b;
      in++;
    }
  }

  N = in;
  sort(x, x + N);


  double z = 100.0;
  double tu = 5.0 * pi - 20.0;
  double st = 10.0 * pi - 20.0;

  fill(dp, dp+N, 100000001);
  if((x2 - x1) * (y2 - y1) >= 0){
    for(int i = 0; i < N; i++){
      *lower_bound(dp, dp+N, x[i].second) = x[i].second;
    }
  }
  else{
    for(int i = 0; i < N; i++){
      *lower_bound(dp, dp+N, -x[i].second) = -x[i].second;
    }
  }
  ll n = lower_bound(dp, dp+N, 100000001) - dp;

  /*for(int i = 0; i < N; i++){
    cout << x[i].first << " " << x[i].second << endl;
  }*/

  if(n == min(abs(x1 - x2), abs(y1 - y2)) + 1){
    printf("%.20lf\n", tu * (n-1) + st + (abs(x1 - x2) + abs(y1 - y2)) * z);
  }
  else
    printf("%.20lf\n",  tu * n + (abs(x1 - x2) + abs(y1 - y2)) * z);



  return 0;
}


Measured memory_bytes: 2560
// AOJ 1182 Railway Connection
// 2018.2.22 bal4u
 
#include <stdio.h>
#include <string.h>

#define QMAX 10000
typedef struct { int t; int s; } QUE;
QUE que[QMAX]; int qsize;

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

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

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

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

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

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

#define INF 0x10101010
#define MAX 20001

int d[22][102][102];
int p[22], q[22][52], r[22][52];
int hi[102], to[102][204], w[102][204];
int dist[102], fare[22][20010];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	while (c <= ' ') c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int s, int g)
{
	int i, e, d;

	memset(dist, INF, sizeof(dist));
	qsize = 0;
	enq(s, 0), dist[s] = 0;
	while (qsize) {
		s = que[0].s, deq();
		if (s == g) return dist[g];
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i], d = dist[s] + w[s][i];
			if (d < dist[e]) dist[e] = d, enq(e, d);
		}
	}
	return -1;
}

#if 0
int fare(int c, int dist)
{
	int i, pre, ans;

	ans = 0, pre = 0;
	for(i = 0; q[c][i] <= dist; i++) {
		ans += r[c][i] * (q[c][i] - pre);
		pre = q[c][i];
	}
	return ans + r[c][i] * (dist - pre);
}
#endif

int main()
{
	int N, M, C, S, G, i, j, k;
	int x, y, c, t;

	while (N = in()) {
		M = in(), C = in(), S = in()-1, G = in()-1;

		memset(d, INF, sizeof(d));
		for (c = 0; c < C; c++) for (i = 0; i < N; i++) d[c][i][i] = 0;

		for (i = 0; i < M; i++) {
			x = in()-1, y = in()-1, t = in(), c = in()-1;
			if (t < d[c][x][y]) d[c][x][y] = d[c][y][x] = t;
		}

		for (c = 0; c < C; c++) {
			for (k = 0; k < N; k++) for (i = 0; i < N; i++) for (j = 0; j < N; j++) {
				t = d[c][i][k] + d[c][k][j];
				if (t < d[c][i][j]) d[c][i][j] = t;
			}
		}

		for (c = 0; c < C; c++) p[c] = in();
		for (c = 0; c < C; c++) {
			for (i = 1; i < p[c]; i++) q[c][i] = in();
			q[c][p[c]] = MAX-1;
			for (i = 1; i <= p[c]; i++) r[c][i] = in();
		}

		if (!M) { puts(S == G? "0": "-1"); continue; }

		for (c = 0; c < C; c++) {
			for (i = 1; i <= p[c]; i++) for (j = q[c][i-1]+1; j <= q[c][i]; j++)
				fare[c][j] = fare[c][j-1] + r[c][i];
		}

		memset(hi, 0, sizeof(hi));
		for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
			t = INF;
			for (c = 0; c < C; c++) if (d[c][i][j] < MAX) {
				if (t > (k=fare[c][d[c][i][j]])) t = k;
			}

			if (t < INF) {
				k = hi[i]++, to[i][k] = j, w[i][k] = t;
				k = hi[j]++, to[j][k] = i, w[j][k] = t;
			}
		}
		printf("%d\n", dijkstra(S, G));
	}
	return 0;
}



Measured memory_bytes: 4448
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define N 1000000
int main() {
	int i, j, cnt = 0, *p ,n,a,d;
	p = (int*)calloc(N + 1, sizeof(int));
	for (i = 2; i <= (int)sqrt(N); ++i) if (!*(p+i)) for (j = 2; j*i < N; j++) *(p+i*j) = 1;
	p[0] = p[1] = 1;
	while (~fscanf(stdin, "%d%d%d", &a, &d, &n), (a || d || n)) {
		for (i = a; n>0; i+=d) if (!*(p + i)) n--;
		P(d, i-d);
	}
	return 0;
}

Measured memory_bytes: 4524
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
#define biggest(A,B) A=max(A,B)
#define smallest(A,B) A=min(A,B)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	int a,b,c;
	cin>>a>>b>>c;
	int kk=0;
	while(b<=a){
		b*=2;
		kk++;
	}
	while(c<=b){
		c*=2;
		kk++;
	}
	int k;
	cin>>k;
	cout<<(kk<=k? "Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
 
int main(){
	int n;
  	cin >> n;
  	map<string, int> cnt;
  	rep(i, n){
  		string s;
      	cin >> s;
      	cnt[s]++;
    }
  	
	for(string s: {"AC", "WA", "TLE", "RE"}){
    	cout << s << " x " << cnt[s] << endl;
    }
}

Measured memory_bytes: 3612
#include<iostream>

using namespace std;

int main(){
  string C1, C2;
  cin >> C1 >> C2;
  
  int check = 0;
  for(int i;i < 3;i++){
    if(C1[i] != C2[2-i])
      check = 1;
  }
  if(check == 1)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

long power(long a, long b) {
    return b ? power(a*a%MOD, b/2) * (b%2?a:1)%MOD:1;
}

long perm(int N, int K) {
    long x = 1;
    for(int i = 1; i <= K; i++) x = x * (N-i+1) % MOD;
    return x % MOD;
}

long comb(int N,int K) {
    long x = 1, y = 1;
    for(int i = 1; i <= K; i++) {
        x = x * (N-i+1) % MOD;
        y = y * i % MOD;
    }
    return x * power(y, MOD-2) % MOD;
}

bool isprime(int n) {
    if(n < 2) return false;
    for(int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}

void dfs(const vector<vector<int> > &G, int v, vector<int> &seen) {
    seen[v] = true;

    for(int next_v : G[v]) {
        if(seen[next_v]) continue;
        dfs(G, next_v, seen);
    }
}

void yes() { cout << "Yes" << endl;}
void no() { cout << "No" << endl;}

int main() {
  int n, tmp, count = 1;
  cin >> n;
  vector<int> button(n);
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    button[i] = tmp;
  }
  int i = 0;
  while (button[i] != 2) {
    if (count > 1000000) {
      count = -1;
      break;
    }
    i = button[i] - 1;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3736
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int N,tmp,ans=0;;
	vector<int> L;
	int i;

	cin>>N;
	for(i=0;i<2*N;i++){
		cin>>tmp;
		L.push_back(tmp);
	}
	sort(L.begin(),L.end());


		for(i=0;i<2*N;i=i+2){
		ans=ans+L[i];
	}

	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 256
from collections import Counter

def main():
    h, w = map(int, input().split())
    c = [[int(i) for i in input().split()] for _ in range(10)]
    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j] = min(c[i][j], c[i][k] + c[k][j])
    print(sum(c[k][1] * v for k, v in Counter(sum([[int(i) for i in input().split() if i != "-1"] for _ in range(h)], [])).items()))

if __name__ == '__main__':
    main()

Measured memory_bytes: 4560
use std::io;
use std::cmp;
use std::collections::HashMap;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let n: i32 = b - a + 1;

    if (a<=0 && b>=0) || a==0 || b==0 {
        println!("{}", "Zero" );
    } else {
        if a>0 || n%2==0 {
            println!("{}", "Positive" );
        } else {
            println!("{}", "Negative" );
        }
    }
}


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

int main(void){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0;i < n;i++)cin >> a[i];
    bool check = true;
    for(int i = 0;i < n;i++){
        if(a[i] % 2 == 1)continue;
        if(a[i] % 3 != 0 && a[i] % 5 != 0)check = false;
    }
    if(check == true)cout << "APPROVED";
    else cout << "DENIED";
}

Measured memory_bytes: 256
import java.io.*;

/**
 * Created by Ayushi on 04/08/2019.
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = r.readLine().split(" ");
        int n = Integer.parseInt(temp[0]);
        temp = r.readLine().split(" ");
        r.close();
        boolean ans = true;
        int[] s = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = Integer.parseInt(temp[i]);
        }
        s[0]--;
        for (int k = 1; k < n; k++) {
            if (s[k] > s[k-1]) s[k]--;
            if (s[k-1] > s[k]) {
                ans = false;
                break;
            }
        }
        System.out.println(ans ? "Yes":"No");
    }
}


Measured memory_bytes: 43856
# input() = input()
lines = '''\
5 3
8
1
7
3
9'''.split('\n')

# 方針　最大重量をPとしてPの場合に何個の荷物が全部で乗るか計算

def count(p,n,tracks,data):
  w = 0
  cnt = 0
  idx = 0
  while tracks > 0:
    if idx == n:
      break
    elif p >= data[idx] + w:
      w += data[idx]
      cnt += 1
      idx += 1
    else:
      tracks -= 1
      w = 0
  return cnt

n,tracks = [int(l) for l in input().split(' ')]
data = [int(input()) for i in range(n)]

# P の探索
wsum = 0
for dt in data:
  wsum += dt
wsum *= 2

def search(wsum,n,tracks,data):
  result = 0
  left = 0
  right = wsum
  while right - left > 1:
    mid = (left + right)//2
    v = count(mid,n,tracks,data)
    if v >= n:
      right = mid
    else:
      left = mid
  return right

r = search(wsum,n,tracks,data)
print(r)



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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  cout << (x-a)%b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  const int d[8][8]={
    {0,0,  0,  0,  0,  0,   0,  0},
    {0,0,300,500,600,700,1350,1650},
    {0,0,  0,350,450,600,1150,1500},
    {0,0,  0,  0,250,400,1000,1350},
    {0,0,  0,  0,  0,250, 850,1300},
    {0,0,  0,  0,  0,  0, 600,1150},
    {0,1,  0,  0,  0,  0,   0, 500},
    {0,1,  1,  1,  0,  0,   0,   0}
  };
  int n,m,ih,it,oh,ot;
  int p=0;
  while(1){
    scanf("%d",&n);
    if(!n)break;
    scanf("%d %d %d %d %d",&ih,&it,&m,&oh,&ot);
    if(n>m){
      p=n;
      n=m;
      m=p;
    }
    p=d[n][m];
    it+=60*ih;
    ot+=60*oh;
    if(d[m][n]==0&&
       ((17*60+30<=it&&it<=19*60+30)||
	17*60+30<=ot&&ot<=19*60+30))p/=2;
    if(p%50)p+=25;
    printf("%d\n",p);
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,a,b,c,d,x;
    cin>>n>>a>>b;
    c=a+b;
    d=n%c;
    x=n/c;
    if(d<=a)
        cout<<x*a+d;
    else
        cout<<x*a+a;
}


Measured memory_bytes: 256
N,X = map(int,input().split())
a,p = [1],[1]

for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(N,X):
    if N == 0:
        return 0 if X<=0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1]+1+f(N-1,X-2-a[N-1])

print(f(N,X))


Measured memory_bytes: 3064
use proconio::{input, marker::Usize1};

fn main() {
    input!(n: usize, q: usize, c: [Usize1; n], lr: [(Usize1, usize); q]);
    let mut queries: Vec<_> = lr
        .into_iter()
        .enumerate()
        .map(|(i, (l, r))| (l, r, i))
        .collect();
    let k = 1000;
    queries.sort_by_key(|&(l, r, _)| (l / k, if l / k % 2 == 0 { r } else { n - r }));
    let mut mul = vec![0; n];
    let mut kind = 0;
    #[inline]
    fn add(i: usize, c: &[usize], kind: &mut usize, mul: &mut [usize]) {
        if mul[c[i]] == 0 {
            *kind += 1;
        }
        mul[c[i]] += 1;
    }
    #[inline]
    fn sub(i: usize, c: &[usize], kind: &mut usize, mul: &mut [usize]) {
        mul[c[i]] -= 1;
        if mul[c[i]] == 0 {
            *kind -= 1;
        }
    }
    let mut i = 0;
    let mut j = 0;
    let mut ans = vec![None; q];
    for (l, r, query_id) in queries {
        while j < r {
            add(j, &c, &mut kind, &mut mul);
            j += 1;
        }
        while l < i {
            i -= 1;
            add(i, &c, &mut kind, &mut mul);
        }
        while r < j {
            j -= 1;
            sub(j, &c, &mut kind, &mut mul);
        }
        while i < l {
            sub(i, &c, &mut kind, &mut mul);
            i += 1;
        }
        ans[query_id] = Some(kind);
    }
    for x in ans.iter().copied().map(Option::unwrap) {
        println!("{}", x);
    }
}


Measured memory_bytes: 39200
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

int h,w,n;
ll ans[maxn];
map< pair<int,int>, ll >num;

void solve()
{
	scanf("%d%d%d",&h,&w,&n);

	for(int i=0;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		for(int le=0;le<=2;le++)
		{
			for(int ri=0;ri<=2;ri++)
			{
				int x=a-le;
				int y=b-ri;
				if(x>=1&&x<=h-2&&y>=1&&y<=w-2)
				{
					num[make_pair(x,y)]++;
				}
			}
		}
	}
	ll all = 1LL*(h-2)*(w-2);
	ans[0]=all-num.size();

	map< pair<int,int>, ll > ::iterator it;
	for(it = num.begin();it!=num.end();it++)
	{
		ans[it->second]++;
		//cout<<it->first.first<<" "<<it->first.second<<" "<<it->second<<endl;
	}
	for(int i=0;i<=9;i++)
	{
		printf("%lld\n",ans[i]);
	}
}

int main()
{
    solve();
	return 0;
}

Measured memory_bytes: 56448
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
 
using namespace std;
 
typedef long long LL;
 
const int inf = 1 << 30;
 
int n;
LL a[505][505];
 
LL gcd(LL a,LL b){
	return !b?a:gcd(b,a%b);
}
LL lcm(LL a,LL b){
	if(a==0)return b;
	if(b==0)return a;
	return a/gcd(a,b)*b;
}
 
int notpm[100005],pm[100005],pcnt=0;
void xxs(){
	notpm[1]=1;
	for(int i=2;i<=100000;i++){
		if(!notpm[i]){
			pm[++pcnt]=i;
		}
		for(int j=1;pm[j]*i<=100000&&j<=pcnt;j++){
			notpm[i*pm[j]]=1;
			if(i%pm[j]==0)break;
		}
	}
}
 
int main(){
	LL cnt=0;
	scanf("%d",&n);
	if(n==2){
		puts("4 7\n23 10");
		return 0;
	}
	xxs();
	
	for(int i=1;i<=n;i++){
		for(int j=(i%2==0)+1;j<=n;j+=2){
			a[i][j]=pm[(i+j)/2];
		}
	}
	
	for(int i=1;i<=n;i++){
		for(int j=(i%2==0)+1;j<=n;j+=2){
//			printf("%d %d %d\n",i,j,n+(j-i+1)/2+2);
			a[i][j]*=pm[n+(j-i+((j-i)%2==0?0:1))/2+2];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(!a[i][j]){
				a[i][j]=lcm(lcm(lcm(a[i-1][j],a[i][j-1]),a[i][j+1]),a[i+1][j])+1;
			}
		}
	}
	LL mx=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
//			if(a[i][j]==9223216780099161841){
//				printf("%d %d %lld %lld %lld %lld\n",i,j,a[i-1][j],a[i+1][j],a[i][j-1],a[i][j+1]);
//			}
//			mx=max(mx,a[i][j]);
			printf("%lld ",a[i][j]);
		}
		puts("");
	}
//	printf("%lld\n",mx);
 
	return 0;
}

Measured memory_bytes: 5504
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

n,x,t = gets.split.map(&:to_i)

i = 1
time = t
taco = 0
while true
  taco += x
  break if taco >= n 
  i += 1
  time += t
end

puts time

Measured memory_bytes: 14196
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    vector<int> q = p;
    sort(q.begin(), q.end());

    int cnt = 0;
    rep(i, n){
        if(p[i] != q[i]){
            cnt++;
        }
    }

    cout << (cnt == 2 || cnt == 0 ? "YES" : "NO") << endl;

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    string s;
    int t;
    int all = 0;
    for (int i = 0; i < n; i++){
        cin >> s >> t;
        all += t;
        mp[s] = all;
    }
    string x;
    cin >> x;
    cout << all - mp[x] << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
	string a,b,c;
	char tmp='a';
	int ia=0,ib=0,ic=0;
	cin>>a>>b>>c;
	while(1){
		//cout<<"\n"<<tmp<<"\n";
		//cout<<a[ia]<<b[ib]<<c[ic]<<"\n";

		//cout<<tmp<<"\n";
		if(tmp=='a'){
			tmp=a[ia];
			ia++;
		}else if(tmp=='b'){
			tmp=b[ib];
			ib++;
		}else if(tmp=='c'){
			tmp=c[ic];
			ic++;
		}

		if(ia==a.size()+1){
			tmp='a';
			break;
		}
		if(ib==b.size()+1){
			tmp='b';
			break;
		}
		if(ic==c.size()+1){
			tmp='c';
			break;
		}



	}
	tmp=tmp-32;

	cout<<tmp<<"\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

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();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	for(double v; cin >> v;) {
		double y = 4.9 / (9.8 * 9.8) * v * v;
		cout << (ceil)(y / 5) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr)
int main()
{
        fast;
        int n;
        cin>>n;
        ll max=1e18,a[n],flag=1,ans=1;
        for(int i=0;i<n;i++)
        {
                cin>>a[i];
                if(a[i]==0)
                        flag=0;
        }
        if(flag==0)
                ans=0;
        else
        {
                sort(a,a+n);
                ans=a[0];
                for(int i=1;i<n;i++)
                {
                        if(a[i]<=(max/ans))
                                ans*=a[i];
                        else
                        {
                                ans=-1;
                                break;
                        }
                }
        }
        cout<<ans<<endl;

}


Measured memory_bytes: 4420
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int a[3],ans;
int main(){
cin >> a[0] >> a[1] >> a[2];
while(a[0]!=a[1] or a[1]!=a[2] or a[0]!=a[2]){
sort(a,a+3);
if(a[2]!=a[1]){
a[0]++;
a[1]++;
}
else
a[0]+=2;
ans++;
}
cout << ans;
return 0;
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 089
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<ll> cnt(5,0);
    REP(i,n){
        string s;
        cin >> s;
        switch(s[0]){
            case 'M':cnt[0]++; break;
            case 'A':cnt[1]++; break;
            case 'R':cnt[2]++; break;
            case 'C':cnt[3]++; break;
            case 'H':cnt[4]++; break;
        }
    }

    ll ans=0;
    FOR(i, 0, 2){
        FOR(j, i+1, 3){
            FOR(k, j+1, 4){
                ans += (cnt[i]*cnt[j]*cnt[k]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.IO;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int H = int.Parse(Console.ReadLine());
        int W = int.Parse(Console.ReadLine());

        Console.WriteLine((N - (H - 1)) * (N - (W - 1)));
    }

    static long max(long a, long b)
    {
        return a > b ? a : b;
    }

}

Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main()
{
	int a , b , c , d ,counter=0;
	cin>>a>>b>>c>>d;
	for(int i=0;i<=100;i++)
	{
		if( a<i && b>=i && c<i && d>=i)
		{
			counter++;
		}
	}
	cout<<counter;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int a,b,n=0;
	cin>>a>>b;
	for(int i=1;i<=1000;i++)
	{
		if(i*8/100 == a&&i*10/100 == b)
		{
			n = i;
			break;
		}
	 } 
	 if(n)
	cout<<n<<endl;
	else 
	cout<<-1<<endl;
	return 0;
} 

Measured memory_bytes: 256