akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n;
        cin>>n;
        vl vec(n);
        rep(i, n)   cin>>vec[i];
        sort(all(vec));reverse(all(vec));
        ll ans = 0;
        if(n == 1)  {cout<<0; return 0;}
        ans += vec[0];
        ll chs = n-2;
        ll i = 1;
        while(chs > 0){
            ans += vec[i];
            chs--;
            if(chs == 0)    break;
            ans += vec[i]; chs--; i++;
        }
        cout<<ans;
    }
}

Measured memory_bytes: 4780
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;

    vector<int> d;
    int tmp;
    for (int i = 0; i < n; i++) {
      cin >> tmp;
      d.push_back(tmp);
    }
    sort(d.begin(), d.end());
    cout << d[n/2] - d[n/2-1] << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      break;
    }
    else {
      if (i == N-1) {
      cout << "Three" << endl;  
      }
      continue;
    }
  }
}


Measured memory_bytes: 256
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Feb 24 18:11:43 2018
//
package main

import (
	"fmt"
)

func main() {
	var N, A int
	fmt.Scan(&N, &A)

	cards := make([]int, N+1)
	for i := 1; i <= N; i++ {
		fmt.Scan(&cards[i])
	}

	dp := make([][][]int64, N+1)
	for i := range dp {
		dp[i] = make([][]int64, N+1)
		for j := range dp[i] {
			dp[i][j] = make([]int64, 2501)
		}
	}

	dp[0][0][0] = 1
	for i := 1; i <= N; i++ {
		for j := 0; j <= N; j++ {
			for k := 0; k <= 2500; k++ {
				if 0 <= j-1 && 0 <= k-cards[i] {
					dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-cards[i]]
				} else {
					dp[i][j][k] = dp[i-1][j][k]
				}
			}
		}
	}

	var count int64 = 0
	for i := 1; i <= N; i++ {
		count += dp[N][i][A*i]
	}

	fmt.Println(count)
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int n; cin >> n;
    cout << n*2*pi << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7920
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;

int main()
{
	int n,k;cin>>n>>k;
	string s;cin>>s;
	
	int ans=0;
	for(int i=1; i<s.size(); i++)
		if(s[i]==s[i-1])
			ans++;
	ans=min(2*k+ans,n-1);
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
)

var N, M, ans int

func main() {
	fmt.Scan(&N, &M)
	cost := [51][51]int{}
	dp := [51][51]int{}

	for i := 0; i < 51; i++ {
		for j := 0; j < 51; j++ {
			cost[i][j] = 99999999
			dp[i][j] = 99999999
		}
	}
	var a = make([]int, M)
	var b = make([]int, M)
	for i := 0; i < M; i++ {

		fmt.Scan(&a[i])
		fmt.Scan(&b[i])

		cost[a[i]][b[i]] = 1
		cost[b[i]][a[i]] = 1
	}

	// 取り除く対象の辺は50本以下なので，ワーシャルフロイドで全探索しても
	// たかだか O(50*50*50*50)
	// もっと良いアルゴリズムあると思うけど，思いつかなかった...orz
	for index := 0; index < M; index++ {

		dp = cost

		// 橋を切る
		dp[a[index]][b[index]] = 99999999
		dp[b[index]][a[index]] = 99999999

		// ワーシャルフロイドで全探索
		for k := 1; k <= N; k++ {
			for i := 1; i <= N; i++ {
				for j := 1; j <= N; j++ {
					dp[i][j] = min(dp[i][k]+dp[k][j], dp[i][j])
				}
			}
		}

		var flag bool
		for i := 1; i <= N; i++ {
			for j := i + 1; j <= N; j++ {
				// 任意のノードiから任意のノードjへの移動コストが99999999だったら(非連結なら)
				if dp[i][j] == 99999999 {
					flag = true
					break
				}
			}
		}
		if flag == false {
			ans++
		}
	}
	fmt.Println(M - ans)
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}
type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define int long long
#define INF 0x3f3f3f3f3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,m,qq;
int a[3010][3010];
int dp[3010][3010][4];//dp到了i行j列，本行已经取了k个数 值为score
void chmax(int&a,int b){a=max(a,b);}
signed main(){
//	memset(dp,0,sizeof dp);
	cin>>n>>m>>qq;
	for(int i=1;i<=qq;i++){
		int x,y,z;
		cin>>x>>y>>z;
		a[x][y]=z;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			dp[i][j][0]=max(dp[i-1][j][0],dp[i][j-1][0]);
			chmax(dp[i][j][0],dp[i-1][j][1]);
			chmax(dp[i][j][0],dp[i-1][j][2]);
			chmax(dp[i][j][0],dp[i-1][j][3]);
			for(int k=1;k<=3;k++){
				//cur:dp[i][j][k]
				dp[i][j][k]=dp[i][j-1][k];
				if(a[i][j]!=0){
					chmax(dp[i][j][k],dp[i][j-1][k-1]+a[i][j]);
					if(k==1){
						chmax(dp[i][j][1],dp[i-1][j][0]+a[i][j]);
						chmax(dp[i][j][1],dp[i-1][j][1]+a[i][j]);
						chmax(dp[i][j][1],dp[i-1][j][2]+a[i][j]);
						chmax(dp[i][j][1],dp[i-1][j][3]+a[i][j]);
					}
				}
			}
		}
	}
	int ans=0;
//	cout<<dp[1][4][3]<<' '<<dp[2][4][1]<<endl;
	for(int k=0;k<=3;k++)chmax(ans,dp[n][m][k]);
//	cout<<dp[2][5][2]<<endl;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 356104
n,m = gets.split.map(&:to_i)

lmax = 0
rmin = n

m.times do |i|
  l,r = gets.split.map(&:to_i)
  lmax = l if lmax < l
  rmin = r if rmin > r
end
ans = rmin - lmax + 1
puts ans > 0 ? ans : 0

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
long long n,k,ans,a[110];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]<=k/2) ans+=a[i]*2;
		  else ans+=(k-a[i])*2;
	}
	cout<<ans<<"\n";
	return 0;
 } 

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

int main(){
    int n;
    cin >> n;
    long long x[n],y[n];
    long long h[n];
    int si;
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]>0) si=i;
    }
    long long H;
    long long ans;
    int cnt=0;
    long long ansx,ansy,ansh;
    for(long long i=0;i<=100;i++){
        for(long long j=0;j<=100;j++){
            ans=h[si]+abs(x[si]-i)+abs(y[si]-j);
            bool res=true;
            for(int k=0;k<n;k++){
                H=h[k]+abs(x[k]-i)+abs(y[k]-j);
                if(h[k]>0&&ans!=H) res=false;
                if(h[k]==0&&ans>abs(x[k]-i)+abs(y[k]-j)) res=false;
            }
            if(res){
                ansx=i;
                ansy=j;
                ansh=ans;
            }
        }
    }
    cout  << ansx << " " << ansy << " " << ansh << endl;
}

Measured memory_bytes: 256
function Main(input){
  var inp = input.split(' ');
  var a = inp[0];
  var b = inp[1];
  var n = parseInt(a + b);
  var flsqn = Math.floor(Math.sqrt(n));
  flsqn * flsqn === n ? console.log('Yes') : console.log('No');
//  (Math.floor(Math.sqrt(n))) ** 2 ? console.log('Yes') : console.log('No');
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(void) {
    char c;
    int cnt[26];
    for (int i = 0; i < 26; i++) cnt[i] = 0;
    while (cin >> c) {
        if (isalpha(c)) {
            c = tolower(c);
            cnt[c - 'a']++;
        }
    }
    for (int i = 0; i < 26; i++) {
        cout << char('a' + i) << " : " << cnt[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1140
#include<cstdio>
#include<cstring>

char s[101];
int main()
{
	int i,j,c,t,ans=100;
	scanf("%s",s);
	int n=strlen(s);
	for(c='a';c<='z';c++)
	{
		for(i=0;i<n;i++)if(s[i]==c)break;
		if(i==n)continue;
		for(i=t=0;i<n;i++)
		{
			for(j=0;j<n-i;j++)
				if(s[i+j]==c)
					break;
			if(j>t)t=j;
		}
		if(t<ans)ans=t;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
n = int(input())
u = [float('inf')] * 26
for _ in range(n):
  s = input()
  t = [0] * 26
  for i in range(len(s)):
    t[ord(s[i]) - ord('a')] += 1
  for i in range(26):
    u[i] = min(u[i], t[i])
print(''.join(chr(i + ord('a')) * u[i] for i in range(26)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;



int h, w, need_black;

bool check(vector<string> &grid) {
    int cnt=0;
    for(int i=0; i<h; i++) {
       for(int j=0; j<w; j++) {
           if(grid[i][j]=='#') {
               cnt++;
           }
       }
    }
    return cnt==need_black;
}


void solve() {
    ll res=0;
    cin >> h >> w >> need_black;
    vector<string> grid(h);
    for (int i=0; i<h; i++) {
        cin >> grid[i];
    }

    for (int i=0; i<(1<<h); i++) {
        for (int j=0; j<(1<<w); j++) {
            vector<string> new_grid=grid;
            for (int k=0; k<h; k++) {
                if (i&(1<<k)) {
                    for (int jj=0; jj<w; jj++) {
                        new_grid[k][jj]='!';
                    }
                }
            }
            for (int k=0; k<w; k++) {
                if (j&(1<<k)) {
                    for (int ii=0; ii<h; ii++) {
                        new_grid[ii][k]='!';
                    }
                }
            }
            if (check(new_grid)) {
                res++;
            }
        }
    }

    
    cout << res << endl;
}

int main() {
    FAST_INPUT;

    solve();
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<bitset>
using namespace std;
int main(){
	char N ;
	cin >> N ;	
	bitset<8> chane;
	chane = bitset<8>(N);
	if(chane[5]==0){
		cout << "A" ;
	}
	else{
		cout << "a" ;
	}
	return 0;
}

Measured memory_bytes: 3040
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var T = sc.nextInt();
        var A = sc.nextInt();
        var H = sc.ArrayInt(N);
        var min = double.MaxValue;
        var ans = 0;
        for (int i = 0; i < N; i++) {
            if (min > Abs(A - (T - H[i] * 0.006))) {
                min = Abs(A - (T - H[i] * 0.006));
                ans = i + 1;
            }
        }
        WriteLine(ans);
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 11156
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;



int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << " " << max(0,min(a,b)-(n-max(a,b))) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, a[200010], s, count, mae, frag;
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    s = 1;
    count = 0;
    frag = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == s)
        {
            mae = i + 1;
            if (s == 1)
            {
                frag = 1;
            }
            /* if (s == 1)
            {
                count += i;
                mae = i + 1;
            }
            else
            {
                count += i - mae;
                mae = i + 1;
            }
            */
            s += 1;
        }
        else
        {
            count += 1;
        }
        if (i == n - 1)
        {
            if (frag == 0)
            {
                count = -1;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
S=input()
[fN,fS,fE,fW]=[False]*4
for c in S:
    if fN and fS and fE and fW:
        break
    if c=='N':
        fN=True
    if c=='S':
        fS=True
    if c=='E':
        fE=True
    if c=='W':
        fW=True

if (fN and not fS) or (not fN and fS) or (fE and not fW) or (not fE and fW):
    print('No')
else:
    print('Yes')

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

char s[50][51] = { 0 };

int main(void) {
	int H, W;

	scanf("%d %d", &H, &W);
	for (int i = 0; i < H; i++) scanf("%s", &s[i]);

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int cnt = 0;
			for (int k = i - 1; k <= i + 1; k++) {
				for (int l = j - 1; l <= j + 1; l++) {
					if (s[k][l] == '#') cnt++;
				}
			}
			if (s[i][j] == '.') printf("%d", cnt);
			else printf("%c", s[i][j]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const int BITSIZE = 100010;

struct Less{
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first < y.first;
    }
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};

vector<pair<double, double> > ans;
int n; 
static const double pi = 3.141592653589793;
void dfs(pair<double, double> p1, pair<double, double> p2, int cnt){
    if(n==cnt) return ;
    
    pair<double, double> s, t, u;
    s=make_pair(p1.first+(p2.first-p1.first)/3, p1.second+(p2.second-p1.second)/3);  
    t=make_pair(p1.first+2*(p2.first-p1.first)/3, p1.second+2*(p2.second-p1.second)/3);
    u=make_pair(s.first+(t.first-s.first)*cos(pi/3) - (t.second-s.second)*sin(pi/3), s.second+(t.first-s.first)*sin(pi/3)+(t.second-s.second)*cos(pi/3));
    
    
    ans.push_back(s);
    ans.push_back(t);
    ans.push_back(u);
    
    dfs(p1, s, cnt+1);
    cout << s.first << " " << s.second << endl;
    dfs(s, u, cnt+1);
    cout << u.first << " " << u.second << endl;
    dfs(u, t, cnt+1);
    cout << t.first << " " << t.second << endl;
    dfs(t, p2, cnt+1);
    return ;
}
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    cin >> n;
    pair<double, double>p1(0, 0);
    pair<double, double>p2(100, 0);
    cout << fixed << setprecision(10);
    cout << 0.0 << " " << 0.0 << endl;
    dfs(p1, p2, 0);
    cout << 100.0 << " " << 0.0 << endl;

	return 0;
}


Measured memory_bytes: 3360
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int n,l,r;
ll ans=1e16;
ll a[200010],pre[200010];
ll aa,ab,ac,ad;
int main(){
	scanf("%d",&n);
	int i,j;
	pre[0]=0;
	for(i=1;i<=n;++i){scanf("%lld",&a[i]);pre[i]=pre[i-1]+a[i];}
	l=1;r=3;
	for(i=2;i<n-1;++i){
		while(l<i&&abs(pre[l]-(pre[i]-pre[l]))>=abs(pre[l+1]-(pre[i]-pre[l+1])))l++;
		while(r<n&&abs(pre[r]-pre[i]-(pre[n]-pre[r]))>=abs(pre[r+1]-pre[i]-(pre[n]-pre[r+1])))r++;
		aa=pre[l];ab=pre[i]-pre[l];ac=pre[r]-pre[i];ad=pre[n]-pre[r];
		ans=min(ans,max(max(aa,ab),max(ac,ad))-min(min(aa,ab),min(ac,ad)));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
#define ll long long
using namespace std;

ll h[100010];

bool check(ll N,ll T,ll A,ll B){
  ll ans = 0,zero = 0;
  FOR(i,0,N){
    if(A*T < h[i])return 0;
    ans += max(zero,(h[i]-B*T+A-B-1)/(A-B));
  }
  return ans <= T;
}

int main(){
  ll N,A,B;
  cin >> N >> A >> B;
  FOR(i,0,N)cin >> h[i];
  ll imin=0,imax=INF;
  while(imax - imin > 1){
    ll imid=(imin+imax)/2;
    if(check(N,imid,A,B))imax = imid;
    else imin = imid;
  }
  cout << imax << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
inline ll read() {
	ll kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
inline void write(ll xx){
	if(xx < 0){putchar('-');xx=-xx;}
	if(xx > 9)write(xx/10);
	putchar(xx%10+'0');
	return;
}
int parent[200005];
int vis[200005];
vector<ll> rest_v;
vector<ll> T_v;
ll T,rest,res;
int n;
ll k;
void find(int x){
	if(vis[x] == 2)
		return;
	if(vis[x] == 0){
		rest++;
		rest_v.push_back(x);
	}
	else if(vis[x] == 1){
		T++;
		T_v.push_back(x);
	}
	vis[x]++;
	find(parent[x]);
}
int main(){
	n = read();
	k = read();
	for(int i = 1;i <= n;i++){
		cin >> parent[i];
	}
	find(1);
	rest -= T;
	if(k <= rest){
		write(rest_v[k]);
	}else{
		res = (k - rest + 1) % T;
		if(res == 0){
			res = T;
		}
		write(T_v[res - 1]);
	}
	return 0;
}

Measured memory_bytes: 8692
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    bool flag = true;
    for(int i = n-1; i>=1; i--){
        if(v[i]<v[i-1]){
            if(v[i]==v[i-1]-1){
                v[i-1] -= 1;
            }else{
                flag = false;
            }
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


int main() {
int K, N, M;
cin >> K >> N >> M;
bool ans = 0;
for(int i = N; i <= M; i++){
    if(i % K == 0) ans = 1;
}



if(ans == 1) cout << "OK" << endl;
else cout << "NG" << endl;

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X), B(Y), C(Z);
  REP(i, X)
  cin >> A[i];
  REP(i, Y)
  cin >> B[i];
  REP(i, Z)
  cin >> C[i];
  vector<ll> vc1;
  REP(i, X)
  REP(j, Y)
  vc1.push_back(A[i] + B[j]);
  sort(ALL(vc1));
  reverse(ALL(vc1));
  vector<ll> vc2;
  REP(i, min(K, X * Y))
  REP(j, Z)
  vc2.push_back(vc1[i] + C[j]);
  sort(ALL(vc2));
  reverse(ALL(vc2));
  REP(i, K)
  cout << vc2[i] << endl;
  return 0;
}

Measured memory_bytes: 43240
#include<algorithm>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;
int n , x;
int a[1010];
int main(){
	cin >> n >> x;
	for(int i = 1 ; i <= n ; ++ i){
		cin >> a[i];
		x -= a[i];
	}
	int ans = n;
	sort(a + 1 , a + n + 1);
	ans += x / a[1];
	cout << ans << endl;
	system("pause");
	return 0;
}

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;
int a[2000000];
int b[2000000];
int c[2000001];

int main() {
    int n;
    int maxim = 0;
    cin >> n;
    REP(i, n) {cin >> a[i]; maxim = max(maxim, a[i]); }
    REP(i, maxim+1) c[i] = 0;
    REP(i, n) c[a[i]]++;
    REP(i, maxim) c[i+1] += c[i];
    for(int i=n-1; i>-1; i--){
        b[c[a[i]] - 1] = a[i];
        c[a[i]]--;
    }

    REP(i, n-1) cout << b[i] << " ";
    cout << b[n-1] << endl;


    return 0;
}

Measured memory_bytes: 18500
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author DifferentHeaven
 */

#include <bits/stdc++.h>

#include <bits/stdc++.h>
#define finc(i, a, b) for (int i = a, _b = (b); i <= _b; i++)
#define fdec(i, a, b) for (int i = a, _b = (b); i >= _b; i--)
#define ii pair <int, int>
#define x first
#define y second
#define db(x) cerr << #x << " = " << (x) << endl
#define _ << " _ " <<
using namespace std;

class AFrog1 {
    const int oo = 1e9 + 7;
    static const int N = 1e5 + 7;
    int a[N], f[N];
    int n;

public:
	void solve(std::istream& cin, std::ostream& cout) {
		cin >> n;
		finc(i, 1, n)
		    cin >> a[i];
		fill(f + 1, f + n + 1, oo);
		f[1] = 0;
		f[2] = abs(a[2] - a[1]);
		finc(i, 3, n)
		    f[i] = min(f[i - 1] + abs(a[i] - a[i - 1]), f[i - 2] + abs(a[i] - a[i - 2]));
		cout << f[n];
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	AFrog1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
/*    BAJUKA     */
#include<bits/stdc++.h>
#define lld long long int
#define ve vector
#define rep(i,a,b) for(i=a;i<b;i++) 
#define per(i,a,b) for(i=b;i>=a;i--)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define Max 1000000000000000
#define md 1000000007

using namespace std;








int main()
{
	
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lld n,k;
    cin>>n>>k;
    lld r=n%500;
    if(k-r>=0)
    	cout<<"Yes";
    else cout<<"No";
    
    
    

    
   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const long long MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す//計算量は0(log(max(a,b))
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す//計算量は0(log(max(a,b))
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す//計算量は0(log(y))
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す//計算量は0(sqrt(a))
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll L,R,X;
  cin>>L>>R>>X;
  ll ans=0;
  for(int i=L;i<=R;i++){
    if(i%X==0){ans++;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int x, a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10) << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int h, w, i, j;
  while(1) {
    scanf("%d %d", &h, &w);
    if ((h == 0) && (w == 0))
      break;
    for ( i = 0; i < h; i++ ) {
      for ( j = 0; j < w; j++ ) {
	if ((i == 0) || (i == h -1))
	  printf("#");
	else if ((j == 0) || (j == w - 1))
	  printf("#");
	else
	  printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;

}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int n;
    ll d;
    cin >> n >> d;
    d *= d;

    int ans(0);
    rep(i,n){
        ll x,y;
        cin >> x >> y;

        if((x*x+y*y)<=d)   ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int n,m,c,b[25],a,tmp,ans;

int main(){
	scanf("%d%d%d",&n,&m,&c);
	for(int i =0;i<m;i++){
		scanf("%d",&b[i]);
	}
	while(n--){
		tmp =c;
		for(int i =0;i<m;i++){
			scanf("%d",&a);
			tmp += a*b[i];
		}
		if(tmp>0)ans++;
	}
	printf("%d\n",ans);
	return 0;
}		

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	string S;
	cin>>S;
	if(S=="MON"){
		cout<<6;
	}else if(S=="TUE"){
		cout<<5;
	}else if(S=="WED"){
		cout<<4;
	}else if(S=="THU"){
		cout<<3;
	}else if(S=="FRI"){
		cout<<2;
	}else if(S=="SAT"){
		cout<<1;
	}else{
		cout<<7;
	}
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end() 
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define forn(i, n) for(int i=0;i<(n);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

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

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

int main() {
	int n, p; string s;
	cin >> n >> p >> s;
	reverse(all(s));
	unordered_map<int,int> um;
	int now = 0;
	ll ans = 0;
	ll base = 1;
	if(p == 2 || p == 5) {
		forn(i, n) {
			now = s[i]-'0'; now %= p;
			um[now]++;
			ans += um[0];
		}
	} else {
		um[0]++;
		forn(i, n) {
			now = now+(s[i]-'0')*base; now %= p;
			base = base*10%p;
			ans += um[now];
			um[now]++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 900
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	n := sc.ScanInt()
	s := sc.ScanStrs(n)

	m := sc.ScanInt()
	t := sc.ScanStrs(m)

	r := make(map[string]int)

	for _, v := range s {
		r[v]++
	}
	for _, v := range t {
		r[v]--
	}

	max := 0
	for _, v := range r {
		if v > max {
			max = v
		}
	}

	fmt.Println(max)
}

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner(r io.Reader) *Scanner {
	s := &Scanner{bufio.NewScanner(r)}
	s.sc.Split(bufio.ScanWords)
	return s
}

func (s *Scanner) ScanInt() int {
	s.sc.Scan()
	i, e := strconv.Atoi(s.sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) ScanStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) ScanStrs(len int) []string {
	a := make([]string, len)
	for i := 0; i < len; i++ {
		a[i] = s.ScanStr()
	}
	return a
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int sum = 0;
		int ans = 0;
		for(int i = 1;i <= n;i++) {
			int tmp = i;
			sum = 0;
			while(tmp >= 1) {
				sum += tmp % 10;
				tmp = tmp / 10;
			}
			if(sum >= a && sum <= b) {
				ans += i;
			}
		}
		System.out.println(ans);
        sc.close();
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); i++){
    s[i] += N;
    if(s[i] > 'Z'){
      s[i] -= 'Z' - 'A' + 1;
    }
  }
  cout << s << endl;
  
  return 0;
}

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

using namespace std;

int H, W;
vector<string> field;

bool isInside(int ch, int cw) {
    return ch >= 0 && ch < H && cw >= 0 && cw < W;
}

void dfs(int ch, int cw) {
    field[ch][cw] = '.';
    if (ch == H - 1 && cw == W - 1) return;
    if (isInside(ch, cw + 1) && field[ch][cw + 1] == '#') dfs(ch, cw + 1);
    else if (isInside(ch + 1, cw) && field[ch + 1][cw] == '#') dfs(ch + 1, cw);
}

bool solve() {
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (field[i][j] == '#') return false;
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    field = vector<string>(H);
    for (int i = 0; i < H; i++) {
        cin >> field[i];
    }
    dfs(0, 0);
    if (solve()) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

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

using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> s(n);
    int ans = 0;
    for(int i = 0; i < n; i++) cin >> s[i], ans += s[i];
    sort(s.begin(), s.end());
    if(ans % 10 == 0){
        for(int i = 0; i < n; i++){
            if((ans - s[i]) % 10 != 0){
                cout << ans - s[i] << endl;
                return 0;
            }
        }
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N,Y = map(int, input().split())

bo = False
for i in range(N+1):
  for j in range(N-i+1):
    if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
      print(str(i) + ' ' + str(j) + ' ' + str(N - i - j))
      bo = True
      exit()

if bo == False: 
  print('-1 -1 -1')
      

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

int main(){
    map<char, int> mp;
    mp['m'] = 1000;
    mp['c'] = 100;
    mp['x'] = 10;
    mp['i'] = 1;
    string str = "mcxi";
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        string s[2];
        cin >> s[0] >> s[1];
        int a[2]={0};
        for(int j=0;j<2;++j){
            for(int k=0;k<s[j].size();++k){
                int m = 1, l = 0;
                if(s[j][k] > '1' && s[j][k] <= '9'){
                    m = s[j][k] - '0';
                    l = 1;
                }
                int d = mp[s[j][k+l]];
                a[j] += m * d;
                k += l;
            }
        }
        string t = to_string(a[0]+a[1]), ans = "";
        for(int j=0;j<t.size();++j){
            if(t[j] > '1' && t[j] <= '9')ans.push_back(t[j]);
            if(t[j] != '0')ans.push_back(str[4-t.size()+j]);
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int k, x; cin >> k >> x;
	if (500 * k >= x) puts("Yes");
	else puts("No");
	return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int64_t> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  // sort(H.begin(),H.end());
  // reverse(H.begin(),H.end());
  // sort(H.begin(),H.end(),greater<int64_t>());
  sort(H.begin(),H.end(),[](int64_t a,int64_t b){return a>b;});
  int64_t ans=0;
  for(int i=K;i<N;i++){
    ans+=H.at(i);
  }
  cout << ans << endl;
}


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

#define ALL(obj) (obj).begin(), (obj).end()
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,b) for(int i=a; i<=b; i++)
using ll = long long;
#define pb push_back
#define INF 100100100
//const int INF = 100100100;
const int MOD = (int) 1e9 + 7;
const double EPS = 1e-9;


int main()
{
  string S;
  cin >> S;

string divide[4] = {
  "dream",
  "dreamer",
  "erase",
  "eraser"};
  reverse(ALL(S));

  rep(i,4) {
    reverse(divide[i].begin(), divide[i].end());
  }

  bool can = true;
  rep(i, S.size()) {

    bool can2 = false; // divided with 4?

    rep(j,4) {
      string d = divide[j];
      if (S.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size()-1;
        break;
      }
    }

    if (!can2) {
      can = false;
      break;
    }

  }
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
  


}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll h,w,n;
  cin >> h >> w >> n;
  vector<int> a(n),b(n);
  map<pair<int,int>,int> mp;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(a[i]+j>=2&&a[i]+j<=h-1&&b[i]+k>=2&&b[i]+k<=w-1){
          mp[make_pair(a[i]+j,b[i]+k)]++;
        }
      }
    }
  }
  vector<ll> c(10);
  c[0]=(h-2)*(w-2);
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(mp[make_pair(a[i]+j,b[i]+k)]!=0){
          c[mp[make_pair(a[i]+j,b[i]+k)]]++;
          c[0]--;
          mp[make_pair(a[i]+j,b[i]+k)]=0;
        }
      }
    }
  }
  for(int i=0;i<10;i++){
    cout << c[i] << endl;
  }
}

Measured memory_bytes: 57344
import java.io.*;
import java.util.*;
import java.math.*;

class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;

    public static void main(String[] args) throws Exception{
        String s = br.readLine();
        boolean f = false;
        for(int i = 0; i < s.length()-1; i++){
            if(s.substring(i, i+2).equals("AC")){
                f = true;
                break;
            }
        }
        pw.print(f ? "Yes\n" : "No\n");

        pw.close(); 
        br.close();
    }
}

class Pair{
    public long x, y;

    Pair(long _x, long _y){
        x = _x;
        y = _y;
    }
}
class Point implements Comparable<Point>{
    public double x, y;

    Point(double x, double y){
        this.x = x;
        this.y = y;
    }

    public int compareTo(Point p){
        if(x != p.x) return x < p.x ? -1 : 1;
        else if(y != p.y) return y < p.y ? -1 : 1;
        return 0;
    }
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;

struct dsu0 {
    vector<int> par, siz;
    int n;
    int cc;
    int largest;
    void init(int n) {
	assert(n>0);
	this->n=n;
	cc=n;
	par.resize(n+10);siz.resize(n+10);
	for (int i=0; i<n; i++) par[i]=i,siz[i]=1;
	largest=1;
    }
    int parent(int x) {
	assert(x>=0 && x<n);
	return par[x]==x?x:par[x]=parent(par[x]);
    }
    bool join(int x, int y) {
	x=parent(x);y=parent(y);
	if (x==y) return false;
	cc--;
	if (siz[x]<siz[y]) swap(x,y);
	siz[x]+=siz[y];par[y]=x;
	largest=max(largest,siz[x]);
	return true;
    }
};


ll n, d;
ll a[maxn];

vector<array<ll,3>> edges;


void solve(int l, int r) {
    if (l==r) return;
    if (l+1==r) {
	edges.push_back({d + a[l] + a[r], l, r});
	return;
    }
    int mid=(l+r)/2;
    int l0=l,r0=r;
    auto f = [&](ll i) {
	return a[i]-d*i;
    };
    auto g = [&](ll i) {
	return a[i]+d*i;
    };

    for (int i=l; i<=mid; i++) {
	if (f(i) < f(l0)) {
	    l0=i;
	}
    }
    for (int i=mid+1; i<=r; i++) {
	if (g(i) < g(r0)) {
	    r0 = i;
	}
    }

    //cout<<l<<" "<<r<<": "<<l0<<" "<<r0<<endl;

    for (int j=mid+1; j<=r; j++) {
	edges.push_back({f(l0)+g(j),l0,j});
    }
    for (int i=l; i<=mid; i++) {
	edges.push_back({f(i)+g(r0),i,r0});
    }

    solve(l,mid);
    solve(mid+1,r);
}

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

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


    solve(0,n-1);


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

    dsu0 dsu;
    dsu.init(n);

    ll res = 0;
    for (auto ed: edges) {
	ll wei = ed[0];
	int u = ed[1];
	int v = ed[2];
	//cout<<wei<<": "<<u<<","<<v<<endl;
	if (dsu.join(u,v)) {
	    res += wei;
	}
    }
    assert(dsu.cc==1);
    cout<<res<<endl;    
    return 0;
}


Measured memory_bytes: 103296
use proconio::input;
use std::cmp::{min, max};

fn main() {
    input! {
        n : usize,
        k : usize,
        a : [i64; n]
    };
    let mut end = k;
    let mut res = vec![vec![0; n]; 2];
    let mut add : Vec<i64> = vec![0; n+1];
    for i in 0..n { res[0][i] = a[i]; }
    for i in 0..k {
        for j in 0..=n { add[j] = 0 }
        for j in 0..n {
            add[max(0, j as i64 - res[i%2][j]) as usize] += 1;
            add[min(n as i64, j as i64 + 1 + res[i%2][j]) as usize] -= 1;
        }
        res[1-i%2][0] = add[0];
        for j in 1..n {
            res[1-i%2][j] = res[1-i%2][j-1] + add[j];
        }
        let mut ok = true;
        for j in 0..n {
            if res[1-i%2][j] != n as i64 { ok = false; }
        }
        if ok {
            end = i+1;
            break;
        }
    }
    for i in 0..n { print!("{} ", res[end%2][i]) }
    println!("");
}


Measured memory_bytes: 9636
#include <iostream>
#include <cmath>

#define INF 1000001

int main(void){
  int a,b,c;
  std::cin >> a >> b >> c;
  if(a+b+c>=22){
    std::cout << "bust" << std::endl;
  } else if(a+b+c<=21){
    std::cout << "win" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll a,b,c,k,sum=0;
	cin >> a >> b >> c >> k;
	if(k<=a)
		sum=k;
	else if(a<k && k<=(a+b))
		sum=a;
	else
		sum=2*a+b-k;
	cout << sum << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 505;
const int INF = 2e9;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, m, d[MAXN][MAXN], c[MAXN][MAXN];
int cost[3][MAXN];
int main() {
	read(n), read(m);
	for (int i = 1; i <= m; i++)
	for (int j = 1; j <= m; j++)
		read(d[i][j]);
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= n; j++)
		read(c[i][j]);
	for (int s = 0; s <= 2; s++)
	for (int col = 1; col <= m; col++) {
		for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if ((i + j) % 3 == s) cost[s][col] += d[c[i][j]][col];
	}
	int ans = INF;
	for (int i = 1; i <= m; i++)
	for (int j = 1; j <= m; j++)
	for (int k = 1; k <= m; k++)
		if (i != j && j != k && i != k) chkmin(ans, cost[0][i] + cost[1][j] + cost[2][k]);
	writeln(ans);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;
int card[100010];
int usa_row[510], usa_col[510], usa_d, usa_u, usa_line;
int neko_row[510], neko_col[510], neko_d, neko_u, neko_line;
int main() {
	int n, u, v, m;
	//int usagi[510][510], neko[510][510];

	map<int, pair<int, int>> usa_map, neko_map;
	set<int> usa_s, neko_s;

	cin>>n>>u>>v>>m;
	if(n==1){
		int usa,neko;
		cin>>usa>>neko;
		REP(i,0,m){
			int num;
			cin>>num;
			if(usa==num) usa_line++;
			if(neko==num) neko_line++;
			if(usa_line>=u && neko_line>=v){
				cout<<"DRAW"<<endl;
				return 0;
			}
			else if(usa_line>=u){
				cout<<"USAGI"<<endl;
				return 0;
			}
			else if(neko_line>=v){
				cout<<"NEKO"<<endl;
				return 0;
			}
		}
		p("DRAW");
		return 0;
	}
	REP(i, 0, n){
		REP(j, 0, n){
			int usa;
			cin>>usa;
			usa_s.insert(usa);
			usa_map[usa]=(make_pair(i, j));
		}
	}
	REP(i, 0, n){
		REP(j, 0, n){
			int neko;
			cin>>neko;
			neko_s.insert(neko);
			neko_map[neko]=(make_pair(i, j));
		}
	}
	REP(i, 0, m){
		cin>>card[i];
	}

	REP(k, 0, m){
		int num=card[k];

		// usa
		if(usa_s.find(num)!=usa_s.end()) {
			int i=usa_map[num].first;
			int j=usa_map[num].second;

			usa_row[i]++;
			usa_col[j]++;
			if(i==j) usa_d++;
			if(i+j==n-1) usa_u++;

			if(usa_row[i]==n) usa_line++;
			if(usa_col[j]==n) usa_line++;
			if(usa_d==n) {
				usa_line++;
				usa_d=0;
			}
			if(usa_u==n) {
				usa_line++;
				usa_u=0;
			}
		}
		//neko

		if(neko_s.find(num)!=neko_s.end()){
			int i=neko_map[num].first;
			int j=neko_map[num].second;
			neko_row[i]++;
			neko_col[j]++;
			if(i==j) neko_d++;
			if(i+j==n-1) neko_u++;

			if(neko_row[i]==n) neko_line++;
			if(neko_col[j]==n) neko_line++;
			if(neko_d==n) {
				neko_line++;
				neko_d=0;
			}
			if(neko_u==n){
				neko_line++;
				neko_u=0;
			}
		}
		if(usa_line>=u && neko_line>=v){

			cout<<"DRAW"<<endl;
			return 0;
		}
		else if(usa_line>=u){
			cout<<"USAGI"<<endl;
			return 0;
		}
		else if(neko_line>=v){
			cout<<"NEKO"<<endl;
			return 0;
		}
	}
	cout<<"DRAW"<<endl;


	return 0;
}

Measured memory_bytes: 34652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
void chmax(t &a, u b)
{
    if (a < b)
        a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
    if (b < a)
        a = b;
}

int main()
{
    map<int,int> m;
    int n;
    cin>>n;
    for (size_t i = 0; i < n; i++)
    {
        int a;
        cin>>a;
        m[a-1]++;
        m[a]++;
        m[a+1]++;
    }
    int ans=0;
    for(auto &i:m){
        chmax(ans, i.second);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736