akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define var(n) int n; scn(n)
#define F first
#define S second 
#define pb(n) push_back(n)
const int N=2e5+5;
const ll M=1e9+7;
const ll inf=1e18;

ll tree[4*N];

ll query(int node,int st,int ed,int l, int r)
{
	if(l<=st and ed<=r)
	{
		return tree[node];
	}
	if(r<st || ed<l)
		return 0;
	int mid = (st+ed)/2;
	ll ans1 = query(2*node,st,mid,l,r);
	ll ans2 = query(2*node+1,mid+1,ed,l,r);

	return max(ans1,ans2);
}
void update(int node,int st,int ed,int pos,ll val)
{
	if(st==ed)
	{
		tree[node] = max(tree[node],val);

		return ;
	}
	int mid = (st+ed)/2;
	if(pos<=mid)
	{
		update(2*node,st,mid,pos,val);
	}
	else update(2*node+1,mid+1,ed,pos,val);

	tree[node] = max(tree[2*node],tree[2*node+1]);
}

int main()
{
	var(n);
	ll h[n],b[n];
	rep(i,0,n)
		lscn(h[i]);

	rep(i,0,n)
		lscn(b[i]);

	ll store[n+1]={0};

	for(int i=0;i<n;i++)
	{
		ll res = query(1,1,n,1,h[i]-1);
		// printf("querying %lld and got %lld\n",h[i]-1,res);
		store[h[i]] = max(store[h[i]],res+b[i]);

		update(1,1,n,h[i],store[h[i]]);
		// printf("updating %lld %lld\n",h[i],store[h[i]]);
	}
	ll ans = 0;
	for(int i=0;i<=n;i++)
	{
		ans = max(ans,store[i]);
		// lpri(store[i]);
	}

	lpri(ans);

}

Measured memory_bytes: 11008
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
}


Measured memory_bytes: 3080
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}
ll dx[2]={1,0};
ll dy[2]={0,1};

int main(){
    IOS;
    make(ll,n);
    vector <ll> a(n+1);
    fr(i,n) cin>>a[i+1];
    ll i=1;
    vector <ll> vis(n+1);
     bool flag=1; ll ans=0;
    while(true){
        if(i==2) break;
        if(vis[i]==1) {flag=0; break;}
        vis[i]=1; i=a[i]; ans++;
    }
    if(!flag) cout<<"-1 \n";
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4704
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000
using namespace std;



int main(){
	int n;
	cin >> n;
	int a[2][n];
	int i,j;
	rep(i,2){
	   rep(j,n){
		   cin >> a[i][j];
	   }
	}

	int first[n];
	rep(i,n){
		first[i] = 0;
		RREP(j,i,0)
			first[i] += a[0][j];
	}

	int second[n];
	rep(i,n){
		second[i] = 0;
		REP(j,i,n)
			second[i] += a[1][j];
	}

	int ans = 0;
	int temp = 0;
	rep(i,n){
		temp = first[i] + second[i];
		ans = max(ans, temp);
	}

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



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll ans = 0;
    int sqrt_n = sqrt(n);
    for(int i = 1; i <= sqrt_n; i++) {
        ll m = n / i;
        ans += m * (m + 1) * i / 2;
    }
    for(int m = n / sqrt_n - 1; m > 0; m--) {
        int l = n / (m + 1);
        int r = n / m;
        ans +=
            (ll)m * (m + 1) * ((ll)r * (r + 1) / 2 - (ll)l * (l + 1) / 2) / 2;
    }
    cout << ans << "\n";
}

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

int main(){
    int g[]={1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y; cin>>x>>y;
    if(g[x-1]==g[y-1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define ROF(i,a,b) for(int i=int(b);i>=int(a);i--)
#define pb push_back
#define pq priority_queue
#define ps push
#define x first
#define y second
using namespace std;
string s,t;
long long anw,pre;
bool chk=1;
vector<long long> idx[27];
int main(){
    cin>>s>>t;
    FOR(i,0,s.size()-1) idx[s[i]-'a'].pb(i+1);
    FOR(i,0,s.size()-1) idx[s[i]-'a'].pb(s.size()+i+1);
    FOR(i,0,t.size()-1) if(idx[t[i]-'a'].size()==0) chk=0;
    if(!chk) cout<<"-1";
    else{
        FOR(i,0,t.size()-1){
            int lb=0,ub=idx[t[i]-'a'].size()-1;
            while(ub-lb>1){
                int mid=(lb+ub)/2;
                if(pre<idx[t[i]-'a'][mid]) ub=mid;
                else lb=mid;
            }
            long long pos=0;
            if(pre<idx[t[i]-'a'][lb]) pos=idx[t[i]-'a'][lb];
            else pos=idx[t[i]-'a'][ub];
            if(pos>s.size()){
                anw+=(s.size()-pre);
                pos-=s.size();
                pre=0;
            }
            anw+=(pos-pre);
            pre=pos;
        }
        cout<<anw;
    }
}


Measured memory_bytes: 2800
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n, x = map(int, input().split())
if x==1 or x==2*n-1:
    print("No")
else:
    if n==2:
        ans = [1,2,3]
    else:
        s = set(range(1,2*n))
        ans = [None]*(2*n-1)
        if x>2:
            ans[n-2] = x-1
            ans[n-1] = x
            ans[n] = x+1
            ans[n+1] = x-2
        else:
            ans[n-2] = x+1
            ans[n-1] = x
            ans[n] = x-1
            ans[n+1] = x+2
        for i in range(n-2, n+2):
            s.remove(ans[i])
        for i in range(2*n-1):
            if ans[i] is None:
                ans[i] = s.pop()
    print("Yes")
    print("\n".join(map(str, ans)))

Measured memory_bytes: 112228
use proconio::input;

const LIM:i32=1000_010;

fn main(){
    input!{
        k:i32
    }

    let mut m=0;
    for i in 1..LIM{
        m=(m*10+7)%k;
        if m==0{
            println!("{}",i);
            return;
        }
    }
    println!("-1");
}

Measured memory_bytes: 2136
A = input()
a = [str(c) for c in A]
ans = 0
c = 0
for i in a:
	if i == "A" or i =="C" or i == "G" or i =="T":
		c = c + 1
	else:
		if c > ans:
			ans = c
		c = 0
if c > ans:
	ans = c
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//#pragma GCC optimize "trapv"
int main()
{
	// ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<3;i++)
		if(s[i]=='R')
			ans++;

	if(ans==2 && s[1]!='R')
		ans--;
	cout<<ans<<"\n";

}

Measured memory_bytes: 3584
#include<stdio.h>

int main(){
  int i,j;
  int n,q;
  int left,right;
  int count=0;
  int mid;

  scanf("%d",&n);
  int S[n];
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int T[q];
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  
  for(i=0;i<q;i++){
    left=0;
    right=n;
    while(left < right){
      mid = (left + right)/2;
      if(S[mid] == T[i]){
	count++;
	break;
      }
      else if(T[i]<S[mid]) right = mid;
      else left = mid + 1;
    }
  }
  printf("%d\n",count);
  return 0;
}




Measured memory_bytes: 2324
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
c.sort()
sum=0
for i in range(n):
    ans_a=bisect.bisect_left(a,b[i])
    ans_c=n-bisect.bisect_left(c,b[i]+1)
    sum+=ans_a*ans_c
print(sum)

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n;cin>>n;
  int v[n+10];
  rep(i,0,n)cin>>v[i];

  sort(v,v+n);
  double ans=v[0];
  rep(i,0,n-1){
    ans=(ans+v[i+1])/2.0;
  }
  out(ans);


  return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

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

sum = 0
prev = -3
0.upto(n - 1) do |i|
  j = a[i] - 1
  sum += b[j]
  sum += c[j - 1] if prev == j - 1
  prev = j
end
puts sum


Measured memory_bytes: 1788
/*author : Yashvardhan
Friday, May 31, 2019
6:53 PM
*/

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

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n,k;
	cin>>n>>k;
	vi arr(n);

	for(int i = 0; i < n ; i++){
		cin>>arr[i];
	}

	sort(arr.begin(),arr.end());
	int ans = inf;
	for(int i = 0; i < n ; i++){
		int li = i + k - 1;
		if(li >= n) break;
		ans = min(ans,arr[li]-arr[i]);
	}
	cout<<ans<<endl;
	

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 1024
def is_operator(operator)
  return ['+', '-', '*'].include?(operator)
end

def calc(operator, o1, o2)
  n1, n2 = o1.to_i, o2.to_i
  if (operator == '+') then
    return n1 + n2
  elsif (operator == '-') then
    return n1 - n2
  elsif (operator == '*') then
    return n1 * n2
  else
    raise "unknown operator: #{operator}"
  end
end


array = gets.split(' ')

while (array.size > 1) do
  index = 0
  while (index < array.size) do
    if (is_operator(array[index])) then
        calculated = calc(array[index], array[index-2], array[index-1])
        array[index-2, 3] = calculated
        break
    end
    index += 1
  end
end

puts array

Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
int32_t main()
{
	IOS;
	int t=1;
	// cin>>t;
	while(t--)
	{
		string a,b;
		cin>>a>>b;

		int m=b.length()-1;

		char app=b[m];

		a+=app;

		if(a==b)
		{
			cout<<"Yes";
		}
		else
		{
			cout<<"No";
		}
	}
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void)
{
	int i = 0;
	int time = 1;
	while (time!=10001) {
		scanf("%d", &i);

		if (i == 0) {
			break;
		}

		printf("Case %d: %d\n", time, i);
		time++;
	}
    return 0;
}


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

void insertionSort(int *A, int n, int g);
void shellSort(int *A, int n);

static int count;

int main(void){
  int i, n, *a;

  scanf("%d", &n);
  a = (int *)malloc(sizeof(int) * n);
  if(a == NULL){
    printf("?????¢????¢??????¨??????\n");
    return -1;
  }
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  shellSort(a, n);
  for(i = 0; i < n; i++){
    printf("%d\n", a[i]);
  }
  free(a);
  return 0;
}


void insertionSort(int *A, int n, int g){
  int i, j, v;

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


void shellSort(int *A, int n){
  int m = 1, h = 1;

  while(3*h+1 < n){
    h = 3 * h + 1;
    m++;
  }
  printf("%d\n", m);
  count = 0;
  for( ; h >= 1; h /= 3){
    insertionSort(A, n, h);
    printf("%d", h);
    if(h != 1){
      printf(" ");
    }
  }
  printf("\n%d\n", count);
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> wa(n);
  vector<bool> ac(n);
  int ans_ac = 0, ans_wa = 0;
  for (int i = 0; i < m; i++) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (s == "AC") {
      if (!ac.at(p)) {
        ac.at(p) = true;
        ans_ac++;
        ans_wa += wa.at(p);
      }
    } else {
      wa.at(p)++;
    }
  }
  cout << ans_ac << " " << ans_wa << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int data[100];
  int dp[2][100] = {{0}};
  int *prev = dp[0], *next = dp[1];
  int idx = 0;
  int pdx = 0;
  while(true){
    int tmp;
    char c;
    if(scanf("%d",&tmp) == -1) break;
    data[idx++] = tmp;
    if(scanf("%c",&c) == -1) break;
    if(c != ','){
      if(pdx < idx){
	REP(i,idx){
	  next[i] = prev[i] + data[i];
	  if(i != 0) next[i] = max(next[i], prev[i-1] + data[i]);
	}
      }else{
	REP(i,idx){
	  next[i] = prev[i] + data[i];
	  next[i] = max(next[i], prev[i+1] + data[i]);
	}
      }

      //REP(i,idx) printf("%d ",next[i]); puts("");
      pdx = idx;
      idx = 0;
      swap(prev, next);
    }
  }

  printf("%d\n",prev[0]);
  return 0;
}

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

#define int long long
signed main(){
	int x;
	cin >> x;
	int i = 0,v = 100;
	double val = 100.00;
	while(v < x){
		val = ((double)v)*1.01;
		v =  (int)floor(val);
		i++;
	}
	cout << i;
	
	return 0;
}


Measured memory_bytes: 3744
#include<stdio.h>
#define R 512

int h(int *x,int a,int n){
	if(a>=n){
		*x-=n;
		return 1;
	}
	else return 0;
}

int p(int x){
	int a=1,i;
	for(i=0;i<x;i++)a*=2;

	return a;
}

int main(){
	int x,c[10],i,a,o;
	while(scanf("%d",&x)!=EOF){
		a=R;
		for(i=9;i>=0;i--){
			c[i]=h(&x,x,a);
			a/=2;
		}
		o=1;
		for(i=0;i<10;i++){
			if(c[i]&&o){
				printf("%d",p(i));
				o=0;
			}
			else if(c[i])printf(" %d",p(i));
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 600
class Tree:
    def __init__(self):
        self.id = 0
        self.p = -1
        self.depth = -1
        self.type = "leaf"
        self.len_c = 0
        self.c = []
    def __str__(self):
        return f"node {self.id}: parent = {self.p}, depth = {self.depth}, {self.type}, {self.c}"
n = int(input())
li = [Tree() for _ in range(n)]
for _ in range(n):
    id, k, *c = map(int, input().split())
    if k == 0:
        c = []
    else:
        li[id].type = "internal node"
    li[id].id = id
    li[id].c = c
    for j in c:
        li[j].p = id
root = 0
while True:
    a = li[root].p
    if a == -1:
        li[root].type = "root"
        li[root].depth = 0
        break
    root = a
dp = [(root, 0)]
while dp:
    id, d = dp.pop()
    for i in li[id].c:
        li[i].depth = d + 1
        dp.append((i, d + 1))
for i in range(n):
    print(li[i])



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> time2(51,1);
vector<ll> time10(19,1);

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){//yがいくつ集まったらx以上になるか
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	ll W,a,b; cin>>W>>a>>b;
	if(a==b){
		cout<<0;
		return 0;
	}
	if(a>b) swap(a,b);
	//a<b
	if(a+W<b) cout<<b-a-W;
	else cout<<0;
		
}

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

int a, b, ans;
int main () {
	cin >> a >> b;
	
	if (a==b)
		cout << a;
		
	else if (a>b)
		cout << a-1;
	
	else if (b>a)
		cout << a;
		
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int a = 0, b = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (i % 2)
		{
			if (s[i] == '1')
				b++;
			else a++;
		}
		else
		{
			if (s[i] == '1')
				a++;
			else b++;
		}
	}
	cout << min(a, b);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
int main() {
	int MO, OTOMO, KIN;
	std::cin >> MO >> OTOMO >> KIN;
	if (MO >= KIN) {
		std::cout << 0 << std::endl;
	}
	if (MO < KIN) {
		if (MO + OTOMO >= KIN) {
			std::cout << KIN - MO << std::endl;
		}
	}
	if (MO + OTOMO < KIN) {
		std::cout << "NA" << std::endl;
	}
}


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


#define N 1000

/*int lcs(char* X,char* Y){
  int i,j;
  
  int c[N+1][N+1];
  int m=strlen(X);
  int n=strlen(Y);
  int maxl = 0;
  X=' '+X;
  Y=' '+Y;
  for(i=1;i<=m;i++) c[i][0]=0;
  for(j=0;j<=n;j++) c[0][j]=0;

  for(i=1;i<=m;i++){
    for(j=0;j<=n;j++){
      if(X[i]==Y[j]){
	c[i][j]=c[i-1][j-1]+1;
      }else{
	if(c[i-1][j]<=c[i][j-1]){
	  c[i][j]=c[i][j-1];
	}else{
	  c[i][j]=c[i-1][j-1];
	}
      }
      if(maxl<c[i][j]) maxl=c[i][j];

    }
  }

  return maxl;
}
*/
int lcs(char *S1,char *S2){
  int c[N+1][N+1],i,j,x,y;
  x=strlen(S1)+1;
  y=strlen(S2)+1;
  for(i=1;i<x;i++)c[0][i]=0;
  for(i=0;i<y;i++)c[i][0]=0;

  for(i=1;i<x;i++){
    for(j=1;j<y;j++){
      if(S1[i-1]==S2[j-1])c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1])c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
  return c[x-1][y-1];
}
 
int main(){
  char s1[N+1],s2[N+1];
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s1);
    scanf("%s",s2);
    printf("%d\n",lcs(s1,s2));
  }

  return 0;
}



Measured memory_bytes: 5612
import sys
from collections import deque, defaultdict
def input(): return sys.stdin.readline().strip()

def main():
    N, u, v = map(int, input().split())
    u -= 1
    v -= 1
    
    edges = [map(int, input().split()) for _ in range(N-1)]

    to = [[] for _ in range(N)]
    for a, b in edges:
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)
    
    dist  = {key:defaultdict(int) for key in [u, v]}

    def bfs(key):
        q = deque()
        q.append(key)
        while(len(q)):
            now = q.popleft()
            for nv in to[now]:
                if nv == key or dist[key][nv]:
                    continue
                else:
                    dist[key][nv] = dist[key][now] + 1
                    q.append(nv)
    
    for key in [u, v]:
        bfs(key)
    
    ans = 0
    for i in range(N):
        diff = dist[v][i] - dist[u][i]
        if diff > 0:
            ans = max(ans, dist[v][i]-1)

    print(ans)    

if __name__ == "__main__":
    main()

Measured memory_bytes: 80668
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  string ch[10];
  ch[1] = ".,!? ";
  ch[2] = "abc";
  ch[3] = "def";
  ch[4] = "ghi";
  ch[5] = "jkl";
  ch[6] = "mno";
  ch[7] = "pqrs";
  ch[8] = "tuv";
  ch[9] = "wxyz";
  int n;
  cin>>n;
  string inp;
  while(n--){
    cin>>inp;
    REP(i,inp.size()){
      if(inp[i]=='0') continue;
      int count = inp.find("0",i) - i-1;
      int num = inp[i] - '0';
      putchar( ch[num][count%ch[num].size()] );
      i += count + 1;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0206();
	}
	
	class AOJ0206{
		public AOJ0206() {
			while(true){
				int l = in.nextInt();
				if(l==0)break;
				int kin = 0;
				boolean sw = true;
				int result = -1;
				for(int i=0;i<12;i++){
					int m = in.nextInt();
					int n = in.nextInt();
					kin += m-n;
					if(kin>=l&&sw){
						sw=false;
						result=i+1;
					}
				}
				System.out.println(sw? "NA":result);
			}
		}
	}
	
}

Measured memory_bytes: 34576
using System;
using System.Linq;
using System.Collections.Generic;

public class Hello{
    public static void Main(){
        string InputNum;
        int Num;
        List<int> Primes = new List<int>();
        bool[] PrimeCheck = Enumerable.Repeat<bool>(true, Consts.MAXNUM).ToArray();
        
        while((InputNum = Console.ReadLine()) != null){
            Num = int.Parse(InputNum);

            if(Primes.Count == 0){
                for(int i = 0; i < Consts.MAXNUM; i++){
                    if(i == 0 || i == 1){
                        PrimeCheck[i] = false;
                        continue;
                    }
                    else if(PrimeCheck[i] == false){
                        continue;
                    }
                    else{
                        Primes.Add(i);
                        for(int n = i * 2; n < Consts.MAXNUM; n += i){
                            PrimeCheck[n] = false;
                        }
                    }
                }
            }
            
            for(int i = 0; i < Primes.Count; i++){
                if(Num < Primes[i]){
                    System.Console.WriteLine(i);
                    break;
                }
                if(i == Primes.Count -1){
                    System.Console.WriteLine(Primes.Count);
                }
            }
        }
    }
}

public static class Consts{
    public static int MAXNUM = 999999;
}

Measured memory_bytes: 12668
import numpy as np
from numba import jit


@jit("i8[:](i8, i8, i8[:])", nopython=True)
def myfunc(n, k, A):
    for _ in range(k):
        l = np.zeros((n + 1,), dtype=np.int64)
        for i, a in enumerate(A[:-1]):
            l[max(0, i - a)] += 1
            l[min(n, i + a + 1)] -= 1
        A = np.cumsum(l)
        if np.all(A[:-1] == n):
            break
    return A


def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    A = np.append(A, 0)
    print(*myfunc(n, k, A)[:-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 137684
H, W = map(int, input().split())
N = int(input())
c = [[0]*W for _ in range(H)]
a = list(map(int, input().split()))
colors = []
for i in range(N-1, -1, -1):
    colors += [i+1]*a[i]

route = []
for h in range(H):
    tmp = []
    for w in range(W):
        tmp.append((h, w))
    if h % 2 == 0:
        route += tmp
    else:
        route += tmp[::-1]

for i in range(H*W):
    x, y = route[i]
    c[x][y] = colors.pop()

for row in c:
    print(*row)

Measured memory_bytes: 74928
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string a, b;
    cin >> a >> b;
    string str = a + b;
    
    int s = std::stoi(str); 

    // cout << s <<endl;

    for (int i = 0; i < 1000; i++)
    {
        // cout<< i*i<<endl;
        if (i*i==s){
            cout << "Yes" <<endl;
            return 0;
        }


    }
    cout << "No"<<endl;
    return 0;

}
 

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int a, b;
    int c;
    scanf("%d %d", &a, &b);
    c = a*b;
    if (c%2==0){
        printf("%s", "Even");
    }
    else{
        printf("%s", "Odd");

    }
    return 0;


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	ll res = INF;
	REP(i, x+1) res = min(res, a*i + (x-i)*c*2 + max((ll)0, y-(x-i))*min(b, c*2));
	cout << res << endl;
	return 0;
}
 

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

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

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong x, a;
	cin >> x >> a;

	cout << (x<a ? 0 : 10) << endl;

	return 0;
}

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int k, n;
    cin>>k>>n;
    vi a(n);
    int mx =0;
    for(int i=0; i<n; i++) {
        cin>>a[i];
    }
    for(int i=1; i<n; i++) {
        mx = max(mx, a[i]-a[i-1]);
    }
    mx = max(mx, k-a[n-1] + a[0]);
    cout << k-mx << "\n";
    return 0;
}



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

using namespace std;
typedef uint uint32_t;

int main() {
    uint a,b,c,d;
    cin >> a >> b >> c >> d;
    // cout << x * x * x << endl;
    // scanf("%u %u", &x, &y);
    cout << min(a, b) + min(c, d) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N,D;
    cin >> N >> D;
    cout << dup(N,2*D+1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int h,m,s;
    
    while(scanf("%d%d%d",&h ,&m ,&s)!=EOF){
        if(h==-1&&m==-1&&s==-1) break;
        int tl = (3600*2)-(3600*h+60*m+s) ,three = tl*3;
        printf("%02d:%02d:%02d\n" ,tl/60/60 ,tl/60%60 ,tl%60);
        printf("%02d:%02d:%02d\n" ,three/60/60 ,three/60%60 ,three%60);
    }
    return 0;
}

Measured memory_bytes: 612
# K : 湖の円周 n : 家の軒数　
k, n = map(int, input().split())
# 家の位置をリストで取得
house_point = list(map(int,input().split()))

# それぞれの家の位置を差分を取得
house_point_diff = [house_point[i+1] - house_point[i] for i in range(n-1)]
# 最初の家と最後の家に位置の差分を、Kを考慮し取得
house_point_diff.append(k + house_point[0] +  - house_point[n-1])

# 最も離れた家の間を通らないようにすれば最短距離を得られる。
# そのため、湖の円周(K)から、最も離れた家の間の距離(max(house_point_diff))を引く
print(k-max(house_point_diff))


Measured memory_bytes: 26436
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;


int main()
{
    int n, m;
    cin >> n >> m;
    int resL = 0;
    int resR = n + 1;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        resL = max(l, resL);
        resR = min(r, resR);
        if (resL > resR) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << resR - resL + 1 << 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 MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;

typedef unsigned long long ll;

const long long MOD = 1000000000 + 7;

//For DP
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//Union-Find tree
struct UnionFind{
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N;  i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る : root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y) { //xとyの木を併合
        int rx = root(x); //xの木の根をrx
        int ry = root(y); //yの木の根をyx
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)ときはそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時 : xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};



int main(){
    string s,t;
    cin >> s;
    cin >> t;
    rep(i,s.size()){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  string s;cin>>s;
  deque<char>d;

  rep(i,0,s.size()){
    if(s[i]=='0')d.push_back('0');
    else if(s[i]=='1')d.push_back('1');
    else {
      if(d.size()!=0)d.pop_back();
    }
  }
  rep(i,0,d.size()){
    cout<<d[i];
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

int main(void){
    int a, b, c, x; //500, 100, 50, total
    cin >> a >> b >> c >> x;
    
    int ans = 0;
    
    for(int ai=0; ai<=a; ai++){
        for(int bi=0; bi<=b; bi++){
            for(int ci=0; ci<=c; ci++){
                if(x == ai * 500 + bi * 100 + ci * 50) ++ans;
            }
        }
    }
    
    printf("%d", ans);
    return 0;
}


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

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int m, n1, n2;
    while(cin >> m >> n1 >> n2 && m != 0) {
    vector<int> P(m);
    REP(i, m) cin >> P[i];
    int max_diff = -1;
    int ans = -1;
    for(int i = n1; i <= n2; i++) {
        int diff = P[i-1] - P[i];
        if(diff >= max_diff) {
            max_diff = diff;
            ans = i;
        }
    }
    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	int n,q;
	int s,t,x;
	int d;
	cin>>n>>q;
	vector<pair<int,int>> begin,end; //first:影響時間 second:終端地点
	vector<int> D;

	rep(i,n){
		cin>>s>>t>>x;
		begin.push_back(pair<int,int>{max(0,s-x),x});
		end.push_back(pair<int,int>{max(0,t-x),x});
	}
	sort(all(begin));
	sort(all(end));
	rep(i,q){
		cin>>d;
		D.push_back(d);
	}
	vector<int> ans;
	int bi=0,ei=0;
	priority_queue<int, vector<int>, greater<int>> qb,qe;
	rep(di,q){
		while(bi < begin.size()){
			if(begin[bi].first > D[di]) break;
			qb.push(begin[bi].second);
			bi++;
		}
		while(ei < end.size()){
			if(end[ei].first > D[di]) break;
			qe.push(end[ei].second);
			ei++;
		}
		while(qe.size() > 0){
			if(qb.top() == qe.top()){
				qb.pop();qe.pop();
			}else{
				break;
			}
		}
		if(qb.size()==0){
			cout<<-1<<endl;
		}else{
			cout<<qb.top()<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 7780
#include <bits/stdc++.h>
using namespace std;
  
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
  
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  
typedef long long int ll;
  
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =5*100001;
ll power(ll x, ll n) {
  ll res = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
  }
  return res;
}

int32_t main()
{
    

  
    IOS
	ll h,w,n;
	cin>>h>>w>>n;
	map<pll,ll> m;
	for(ll ii=0;ii<n;ii++)
	{
		ll a,b;
		cin>>a>>b;
		for(ll i=-2;i<=0;i++)
		{
			for(ll j=-2;j<=0;j++)
			{	
				if(a+i>=1&&b+j>=1&&a+i<=h-2&&b+j<=w-2)
					m[mp(a+i,b+j)]++;
			}
		}
	}
	ll ans[10]={0};
	for(auto x:m)
	{	
		//trace(x.ff.ff,x.ff.ss,x.ss);
		ans[x.ss]++;
	}
	ll sum=0;
	for(ll i=1;i<=9;i++)
		sum+=ans[i];
	cout<<(h-2)*(w-2)-sum<<endl;
	for(ll i=1;i<=9;i++)
	{
		cout<<ans[i]<<endl;
	}

	
	
}
  
           
         
       


Measured memory_bytes: 56576
#include <iostream>

using namespace std;

int table[501][501];

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

  int N, M, Q;
  cin >> N >> M >> Q;

  int l, r;
  for (int i = 0; i < M; i++) {
    cin >> l >> r;
    table[l][r]++;
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      table[i][j] += table[i - 1][j] + table[i][j - 1] - table[i - 1][j - 1];
    }
  }
  int p, q;
  for (int i = 0; i < Q; i++) {
    cin >> p >> q;

    const int ans =
        table[q][q] - table[p - 1][q] - table[q][p - 1] + table[p - 1][p - 1];
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 4520
import java.util.Scanner;

public class Main {
    static final int INF = 2000000000;

    static int ans;

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

        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        ans = 0;
        mergeSort(a, 0, n);

        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++) {
            if(i != 0) sb.append(" ");
            sb.append(a[i]);
        }
        System.out.println(sb);
        System.out.println(ans);

        sc.close();
    }

    private static void mergeSort(int[] a, int left, int right) {
        if(left + 1 < right) {
            int mid = (left + right) / 2;
            mergeSort(a, left, mid);
            mergeSort(a, mid, right);
            merge(a, left, mid, right);
        }
    }

    private static void merge(int[] a, int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;

        int[] l = new int[n1 + 1];
        int[] r = new int[n2 + 1];
        for(int i = 0; i < n1; i++) {
            l[i] = a[left + i];
        }
        for(int i = 0; i < n2; i++) {
            r[i] = a[mid + i];
        }
        l[n1] = INF;
        r[n2] = INF;

        int i = 0;
        int j = 0;
        for(int k = left; k < right; k++) {
            ans++;
            if(l[i] <= r[j]) {
                a[k] = l[i];
                i++;
            }else {
                a[k] = r[j];
                j++;
            }
        }
    }
}


Measured memory_bytes: 179888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  int k,x;cin>>k>>x;
  if(500*k>=x)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
    return 0;
}

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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	int w, a, b;
	cin >> w >> a >> b;

	if (a + w < b) {
		cout << b - (a + w) << endl;
	} else if (b + w < a) {
		cout << a - (b + w) << endl;
	} else {
		cout << 0 << endl;
	}
	return 0;
}

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

int main() {
    long long N,K;
    cin >> N >> K;
    vector<pair<long long, int>> A(N);
    for(int i=0; i<N; ++i) {
        int t;
        long long d;
        cin >> t >> d;
        A[i] = {d,t};
    }

    sort(A.begin(), A.end());
    map<int, int> s;
    long long ans = 0, sum = 0;
    int r = 0;
    for(int i=N-1; i>=0; --i) {
        if(i >= N-K) {
            s[A[i].second] += 1;
            sum += A[i].first;
            if(i == N-K) {
                long long tmp = s.size();
                ans = sum + tmp * tmp;
                r = N - K;
            }
        } else {
            if(!s.count(A[i].second)) {
                while(r<N && s[A[r].second]==1) ++r;
                if(r == N) break;
                ++s[A[i].second];
                --s[A[r].second];
                sum += A[i].first - A[r].first;
                ++r;
                long long tmp = s.size();
                ans = max(ans, sum + tmp*tmp);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, h int
	fmt.Scan(&n, &h)

	var a, b int
	op := make(map[int]bool)
	bs := make(map[int]int)
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		if !op[a] {
			op[a] = true
		}
		if !op[b] {
			op[b] = false
		}
		bs[b]++
	}
	d := make([]int, 0)
	for k := range op {
		d = append(d, k)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(d)))

	ans := 0
	for i := 0; i < len(d); i++ {
		x := d[i]
		if op[x] {
			ans += (h + x - 1) / x
			break
		}

		y := min((h+x-1)/x, bs[x])
		h -= x * y
		ans += y
		if h <= 0 {
			break
		}
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 5504
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
using namespace std;


int main(){
	long long n,m,l;
	cin>>n>>m>>l;
	long long A[n][m] ={{0}};
	long long B[m][l] ={{0}};
	long long C[n][l] ={};
	for(int a=0;a<n;a++){
		for(int b=0;b<m;b++){
			cin >>A[a][b];
		}
	}
	for(int i=0;i<m;i++){
		for(int j =0;j<l;j++){
			cin >>B[i][j];
		}
	}
	
	for(int a=0;a<n;a++){
		for(int b=0;b<l;b++){
			for(int c=0;c<m;c++){
				C[a][b] += A[a][c] * B[c][b];
			}
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
			if(j==0){
				cout<<C[i][j];
			}
			else{
				cout<<" "<<C[i][j];
			}

			
		}
		cout<<"\n";
	}
	return 0;
}



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

const int MAX = 510000;
const ll mod = 1e9+7;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i-1] * (ll)i % mod;
    inv[i] = mod - inv[mod%i] * (mod/(ll)i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

ll 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(){
  ll n, k;
  cin >> n >> k;
  COMinit();
  cout << COM(n+k-1,n) << endl;
  return 0;
}



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

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

    if(abs(b-a) > w) cout << abs(b-a) - w << endl;
  	else cout << 0 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec.at(i);
		vec.at(i)--;
	}
	vector<set<int>> wait(n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (wait.at(i).count(vec.at(i))) {
			ans++;
		}
		else {
			wait.at(vec.at(i)).insert(i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 9984