akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> S(1UL << N);
    copy_n(istream_iterator<unsigned long>(cin), 1UL << N, S.begin());
    sort(S.rbegin(), S.rend());
    vector<unsigned long> T{S[0]};
    list<unsigned long> l(S.begin() + 1, S.end());
    for(unsigned long i = 0, cnt; i < N; ++i){
        cnt = 0;
        auto it = l.begin();
        while(it != l.end() && (cnt < 1UL << i)){
            auto t = *it;
            if(T[cnt] > t){
                T.push_back(t);
                it = l.erase(it);
                ++cnt;
            }else++it;
        }
        if(cnt < 1UL << i)return 0 & puts("No");
        sort(T.rbegin(), T.rend());
    }
    puts("Yes");
    return 0;
}

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

#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const long long int infLL = 9000000000000000000;

#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937

const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;

#define MOD 1000000007

typedef long long ll;
const int mx=2e5+125;

ll pr[mx],ar[mx],br[mx];

#define PB push_back
#define endl '\n'
#define S second
#define F first

int main()
{
    ll a,b,k;
    cin>>a>>b>>k;
    ll sum=a+b;
    ll ans,ans1;
    if(sum<=k)
        ans=0,ans1=0;
    else
    {
        if(k>=a)
            ans=0;
        else
            ans=a-k;
        k-=a;
        if(k>0)
            ans1=abs(b-k);
        else
            ans1=b;
    }
    cout<<ans<<" "<<ans1<<endl;


    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  
  set<int> S;
  for (int i = 0; i < N; ++i) S.insert(A[i]);
  if (S.size() % 2 == 1) cout << S.size() << endl;
  if (S.size() % 2 == 0) cout << S.size() - 1 << endl;
  return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  int odd = 1;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i]%2 == 0) odd *= 2;
  }
  long long ans = pow(3, n) - odd;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0339?year=2016

#include <bits/stdc++.h>

using namespace std;

set<vector<int>> st;

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

    vector<int> vt(3);
    for (int i = 0; i < n; ++i) {
        cin >> vt[0] >> vt[1] >> vt[2];
        sort(vt.begin(), vt.end());
        st.insert(vt);
    }

    cout << n - st.size() << endl;
    return 0;
}

/*
 * 3点の組を構造体で処理しようかと思ったが，
 * ベクタで十分だった。
 * 
 */



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;

int dp[105][105];

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    rep(i, h) rep(j, w) dp[i][j] = INF;
    if (s[0][0]=='#') dp[0][0] = 1;
    else dp[0][0] = 0;
    rep(i, h) rep(j, w) {
        if (i==0 && j==0) continue;
        if (j>0) {
            int now = dp[i][j-1];
            if (s[i][j-1]=='.' && s[i][j]=='#') now += 1;
            chmin(dp[i][j], now);
        }
        if (i>0) {
            int now = dp[i-1][j];
            if (s[i-1][j]=='.' && s[i][j]=='#') now += 1;
            chmin(dp[i][j], now);
        }
    }
    int ans = dp[h-1][w-1];
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, M) = read!(usize, usize);
    let mut T = read![usize, i64; N];

    let mut Q = BinaryHeap::new();
    let mut total = 0;
    T.sort();
    T.reverse();
    debug!(T);

    let mut t = M + 1;
    while t >= 1 {
        t -= 1;

        while let Some(&(a, b)) = T.last() {
            if t + a > M {
                break;
            }
            Q.push(b);
            T.pop();
        }

        debug!((t, &Q));
        if let Some(b) = Q.pop() {
            total += b;
        }
    }

    println!("{}", total)
}


Measured memory_bytes: 8444
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
sys.setrecursionlimit(10**7)

n = int(input())
G = [[] for i in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1; b-=1
  G[a].append(b)
  G[b].append(a)
ans = [0] * n
color = [[],[]]
def coloring(node,pre,oddeven):
  color[oddeven%2].append(node)
  for vi in G[node]:
    if vi != pre:
      coloring(vi,node,oddeven+1)
  return

coloring(0,-1,0)
A = n//3 + int(bool(n%3))
B = n//3 + int(n%3 == 2)
C = n//3
# A>=Bである
a=b=0; c=1
if len(color[0]) >= A and len(color[1]) >= B:
  for i,ci in enumerate(color[0]):
    if i < A:
      ans[ci] = 3 * i + 1
    else:
      ans[ci] = 3 * c
      c += 1

  for i,ci in enumerate(color[1]):
    if i < B:
      ans[ci] = 3 * i + 2
    else:
      ans[ci] = 3 * c
      c += 1

elif len(color[0]) < A:
  # elseが読まれるとき必ずlen(color[0]) < A
  # Bは条件を満たすはず
  for i ,ci in enumerate(color[0]):
    ans[ci] = 3 * c
    c += 1
  for i ,ci in enumerate(color[1]):
    if a < A:
      ans[ci] = 3 * a + 1
      a += 1
    elif b < B:
      ans[ci] = 3 * b + 2
      b += 1
    else:
      ans[ci] = 3 * c
      c += 1

else:
  # elseが読まれるとき必ずlen(color[0]) < A
  # そんなことなかったwwww
  for i ,ci in enumerate(color[1]):
    ans[ci] = 3 * c
    c += 1
  for i ,ci in enumerate(color[0]):
    if a < A:
      ans[ci] = 3 * a + 1
      a += 1
    elif b < B:
      ans[ci] = 3 * b + 2
      b += 1
    else:
      ans[ci] = 3 * c
      c += 1

print(*ans)

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

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007
#define tp tuple<ll,ll,ll>

int main() {
	ll A, B, K;
	cin >> A >> B >> K;
	if (A > K) {
		cout << A - K << " " << B << endl;
	}
	else if (A + B > K) {
		cout << "0 " << A + B - K << endl;
	}
	else {
		cout << "0 0" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
const int N=27e4,M=4099;
int n,V[N],W[N],Q,x,y,i,j,k;
P val[M][M],a[M],b[M];
int le[M],xb,vv[29],ww[29],xb2;
inline void calc(){
	xb=0;
	for(j=0;j<1<<xb2;++j){
		int x=0,y=0;
		for(k=0;k<xb2;++k)if(j>>k&1)x+=vv[k],y+=ww[k];
		if(x<=100000)a[xb++]={x,y};
	}
	sort(a,a+xb);
	int xbb=0;
	for(j=0;j<xb;++j)if(!xbb || b[xbb-1].second<a[j].second)b[xbb++]=a[j];
	xb=xbb;memcpy(a,b,xb<<3);
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d%d",W+i,V+i);
	for(i=1;i<=n && i<4096;++i){
//		xb2=0;for(j=i;j;j=j+1>>1){vv[xb2]=V[j],ww[xb2++]=W[j];if(j==1)break;}
		xb2=0;for(j=i;j;j=j>>1){vv[xb2]=V[j],ww[xb2++]=W[j];if(j==1)break;}
		calc();le[i]=xb;memcpy(val[i],a,xb<<3);
	}
	for(scanf("%d",&Q);Q--;){
		scanf("%d%d",&x,&y);
		if(x<4096){
			printf("%d\n",upper_bound(val[x],val[x]+le[x],P{y+1,-1})[-1].second);
			continue;
		}
		xb2=0;for(j=x;j>=4096;j=j>>1)vv[xb2]=V[j],ww[xb2++]=W[j];
		int zz=j;
		calc();
		int ans=0;
		for(j=0;j<xb && a[j].first<=y;++j)
			ans=max(ans,upper_bound(val[zz],val[zz]+le[zz],P{y-a[j].first+1,-1})[-1].second+a[j].second);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 94596
R, G, B ,N = map(int, input().split())

if R==1 and G==1 and B==1:
  print(int((N+2)*(N+1)*(1/2)))
else:
  RGB = [R, G, B]
  RGB.sort(reverse=True)

  R = RGB[0]
  G = RGB[1]
  B = RGB[2]

  cnt = 0
  NR = N//R
  NG = N//G
  for r in range(NR + 1):
    for g in range(NG + 1):
      NrRgG = N - (r*R + g*G)
      if NrRgG < 0:
        break
      elif NrRgG >= 0:
        if NrRgG % B == 0:
          cnt += 1
  print(cnt)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
long long int gcd(long long int i,long long int j)
{
	long long int c,temp;
	long long int tempi=i,tempj=j;
	if(j>i)
	{
		temp=j;
		j=i;
		i=temp;
	}
	while(j)
	{
		c=i%j;
		i=j;
		j=c;
	}
	return tempi/i*tempj;
}
int main()
{
	/*int t;
	cin>>t;
	double x1,y1,x2,y2,x3,y3;
	double a,k;
	while(t--)
	{
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		a=(y2-y1)/((x2-x1)*(x2-x1));
		k=(y3-y2)/(x3-x2);

	}*/
	int n;
	long long int t;
	while(cin>>n)
	{
		long long int k=1;
		while(n--)
		{
			cin>>t;
			k=gcd(k,t);
		}
		cout<<k<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// 端点を間違えないように気をつけること!
#define FOR(i, m, n) for (ll i = (ll)(m); i <= (ll)(n); i++)
#define RFOR(i, m, n) for (ll i = (ll)(m); i >= (ll)(n); i--)
// 割り算をするときは自作関数syou,amariを使うこと!

struct pair3
{
    ll a;
    ll b;
    ll c;
    bool operator<(const pair3 &another) const
    {
        if (a != another.a)
            return a < another.a;
        if (b != another.b)
            return b < another.b;
        return c < another.c;
    }
};
vector<pair3> chosen;
vector<ll> a;

// index が条件を満たすかどうか
bool isOK(ll index, pair3 key)
{
    if (chosen[index] < key)
        return false;
    else
        return true;
}

// 汎用的な二分探索のテンプレ
pair3 binary_search(pair3 key)
{
    ll left = -1;                 //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll right = (ll)chosen.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        ll mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    if (right == chosen.size())
    {
        return {-1, -1, -1};
    }
    return chosen[right];
}

bool choosed(pair3 key)
{
    pair3 bin = binary_search(key);
    if (bin.a == -1)
    {
        return false;
    }
    if (bin.a == key.a && bin.b == key.b && bin.c == key.c)
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A, B, C;
    ll tmp;
    FOR(i, 1, X)
    {
        cin >> tmp;
        A.push_back(tmp);
    }
    FOR(i, 1, Y)
    {
        cin >> tmp;
        B.push_back(tmp);
    }
    FOR(i, 1, Z)
    {
        cin >> tmp;
        C.push_back(tmp);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    FOR(i, 1, K)
    {
        vector<pair3> choose;
        choose.push_back({X - 1, Y - 1, Z - 1});
        FOR(j, 0, chosen.size() - 1)
        {
            choose.push_back({chosen[j].a - 1, chosen[j].b, chosen[j].c});
            choose.push_back({chosen[j].a, chosen[j].b - 1, chosen[j].c});
            choose.push_back({chosen[j].a, chosen[j].b, chosen[j].c - 1});
        }
        ll sum_max = 0;
        sort(chosen.begin(), chosen.end());
        pair3 p;
        FOR(j, 0, choose.size() - 1)
        {
            ll a = choose[j].a;
            ll b = choose[j].b;
            ll c = choose[j].c;
            if (a >= 0 && b >= 0 && c >= 0)
            {
                if (!(choosed(choose[j])))
                {
                    if (sum_max < A[a] + B[b] + C[c])
                    {
                        sum_max = A[a] + B[b] + C[c];
                        p = choose[j];
                    }
                }
            }
        }
        cout << sum_max << endl;
        chosen.push_back(p);
    }
}

Measured memory_bytes: 1184
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	long long a,b,c;cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0)cout<<"0"<<endl;
	else{
		cout<<min(a*b,min(a*c,b*c))<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
seq = [x for x in input().split(' ')]

b = []

if n % 2 == 0:
    for j in range(n-1, -1, -2):
        b.append(seq[j])
    for i in range(0, n, 2):
        b.append(seq[i])

else:
    for j in range(n-1, -1, -2):
        b.append(seq[j])
    
    for i in range(1, n, 2):
        b.append(seq[i])

print(' '.join(b))

Measured memory_bytes: 25668
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		
		// 計算
		int result = 1;
		int rest = x%100;
		int s = (x-rest)/100;
		//System.out.println(rest);
		//System.out.println(s);
		if((rest + 4)/5 > s) result = 0;
		
		// 出力
		System.out.println(result);
	}
}


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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ansbef = 0;
  int ansaft = 0;
  int ans = 0;
  
  for(int i=0; i<N; i++){
    if(S.at(i) == 'I'){
      ansaft = ansbef + 1;
    }
    else if(S.at(i) == 'D'){
      ansaft = ansbef - 1;
    }
    ansbef = ansaft;
    ans = max(ans,ansaft);
  }
  
  cout << ans << endl;
  
}
  

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll a[3];
    for(ll i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a,a+3);
    cout<<a[0]+a[1]+10*a[2]<<endl;
 
}
// Driver Function
int main()
{
    ll compte = 1;
   // test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>

int main(){
	int num[101][101]={0};
	int r,c;   //r:???,c:???
	int i,j;
	
	scanf("%d %d",&r,&c);
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&num[i][j]);
			num[i][c]+=num[i][j];
			num[r][j]+=num[i][j];
		}
		num[r][c]+=num[i][c];
	}
	
	for(i=0;i<r+1;i++){
		for(j=0;j<c+1;j++){
			printf("%d",num[i][j]);
			if(j!=c) printf(" ");
		}
		printf("\n");
	}
	
	return 0;
}

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

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	int al = a.length();
	int bl = b.length();
	if (a[al - 1] == b[0] && b[bl - 1] == c[0]) printf("YES");
	else printf("NO");
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = 1000000000;

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
llint C(llint n, llint r, llint m) {
	llint ans = 1;
	for (llint i = 0; i < r; i++) {
		ans *= n - i;
		ans %= m;
	}
	for (llint i = 1; i <= r; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}


int main() {
	int s;
	cin >> s;
	ll ans = 0;
	int ma = s / 3;
	for (int i = 1; i <= ma;i++) {
		int sum = s-(3 * i);
		int z = sum + i - 1;
		int y = i - 1;
		ll usi=C(z,y, mod);
		usi %= mod;
		ans += usi;
		ans %= mod;
	}
	while (ans < 0)ans += mod;
	cout << ans << endl;
    return 0;
}

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


#define  all(x)          (x).begin(), (x).end()
#define  sz(v)           ((int)((v).size())
#define  debug(x)        cout << '>' << #x << ':' << x << endl;
#define  clr(v, d)       memset(v, d, sizeof(v));
#define  rep(i,a,b)      for(ll i=a; i<=b;i++)
#define  fo(i,n)         for(ll i=0;i<n;i++)
#define  unq(vec)        sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin());
#define  pb              push_back
#define  mp              make_pair
#define  endl            '\n'
#define  F               first
#define  S               second

using namespace std;
typedef long long         ll;
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<long long> vll;
typedef vector<double>    vd;
typedef vector<vi >       vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;
typedef pair<ll, ll>      pii;
typedef vector<pii>       vii;
typedef map<ll,ll>        mii;

const ll MOD = 1e9 + 7;
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }



int main()
{

    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;


}




Measured memory_bytes: 3652
import math
ND = list(map(int, input().split()))

def distance(x, y):
    return math.sqrt(x*x + y*y)

sum = 0
for i in range(ND[0]):
    X = list(map(int, input().split()))
    dis = distance(X[0], X[1])
    if (ND[1] >= math.ceil(dis)):
        sum += 1

print(sum)

Measured memory_bytes: 9200
#include <stdio.h>
#include <string.h>
int main(){

int a[26] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int b[26] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
char s[101];
char t[101];
scanf("%s%s",s,t);
int i = 0;
while(s[i] != '\0'){
	a[s[i] - 'a']++;
	i++;
}
i = 0;
while(t[i] != '\0'){
	b[t[i] - 'a']++;
	i++;
}
int si = 0;
int ti = strlen(t) - 1;
for(i = 0; i < 26; i++){
	while(a[i] != 0){
		s[si] = 97 + i;
		si++;
		a[i]--; 
	}
	while(b[i] != 0){
		t[ti] = 97 + i;
		ti--;
		b[i]--;
	}
}

if(strcmp(s,t) < 0){
	printf("Yes\n");
}else{
	printf("No\n");
}

return 0;
}


Measured memory_bytes: 128
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  vector<int> a(n);
  int ans = 0;
  for (auto &i : a) {
    cin >> i;
    ans += i;
  }
  sort(all(a));
  ans -= a[n - 1] / 2;
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

using namespace std;
typedef long long int l;
#define mod 1000000007
#define t1 l t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define vl vector<l>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

int main() {
fast;
l x,k,d;
cin>>x>>k>>d;
if(x==d)
{
    if(k%2==0)
    cout<<x;
    else
    cout<<0;
}else{if(x<0){
    l p=abs(x/d);
    if(p>=k)
    cout<<abs(x+(k*d));
    else{
        l q=x+p*d;
        l t=q+d;
        if(k%2==0)
            {
                if(p%2==0)
                cout<<abs(q);
                else
                cout<<abs(t);
            }else{
                if(p%2==0)
                cout<<abs(t);
                else
                cout<<abs(q);
            }
    }
}
else{
    l a=x/d;
    if(a>=k)
    cout<<x-(k*d);
    else{
        l b=x-a*d;
        l c=b-d;
       /* if(k-a==1)
        cout<<abs(c);*/

            if(k%2==0)
            {
                if(a%2==0)
                cout<<abs(b);
                else
                cout<<abs(c);
            }else{
                if(a%2==0)
                cout<<abs(c);
                else
                cout<<abs(b);
            }
        }
    }
}


	return 0;
}


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

using namespace std;

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

  int data[6] ={0};

  for(int i = 0;i < n;++i){
    double height;
    cin>>height;

    if(height < 165.0){
      ++data[0];
    }
    else if(165.0 <= height && height < 170.0){
      ++data[1];
    }
    else if(170.0 <= height && height < 175.0){
      ++data[2];
    }
    else if(175.0 <= height && height < 180.0){
      ++data[3];
    }
    else if(180.0 <= height && height < 185.0){
      ++data[4];
    }
    else{
      ++data[5];
    }
  }
  
  int N = 6;
  for(int i = 0;i < N;++i){
    cout<<i+1<<":";

    for(int j = 0;j < data[i];++j){
      cout<<"*";
    }

    cout<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3184
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    cin>>n;
    string A[36]={},B[36]={},C[36]={};
    
    for(int i=0;i<n;i++){
        cin>>A[i];
        B[i]=A[i];
        C[i]=A[i];
    }
    
    string x;
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            string s=A[j],t=A[j-1];
            if(s[1]<t[1]){
                x=A[j-1];
                A[j-1]=A[j];
                A[j]=x;
            }
        }
    }
    
    for(int i=0;i<n-1;i++){
        cout<<A[i]<<" ";
    }
    cout<<A[n-1]<<endl;
    cout<<"Stable"<<endl;
    
    for(int i=0;i<n;i++){
        int min=i;
        for(int j=i;j<n;j++){
            string s=B[j],t=B[min];
            if(s[1]<t[1]){
                min=j;
            }
        }   
        string y;
        y=B[i];
        B[i]=B[min];
        B[min]=y;
    }
    for(int i=0;i<n-1;i++){
        cout<<B[i]<<" ";
    }
    cout<<B[n-1]<<endl;
    
    int count=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int v=0;v<n;v++){
                for(int w=v+1;w<n;w++){
                    string z=B[v],Z=B[w];
                    if(z[1]==Z[1]&&C[i]==Z&&C[j]==z){
                        count+=1;
                    }
                }
            }
        }
    }
    if(count!=0){
        cout<<"Not stable"<<endl;
    }
    else{
        cout<<"Stable"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>  
#include <cstdlib>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int ans = C-(A-B);
    if (ans<0) ans =0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(lambda x: int(x) - 1, input().split()))
checked = [False] * N
ans = 0

for i in range(N):
    if not checked[i] and A[A[i]] == i:
        ans += 1
        checked[i] = True
        checked[A[i]] = True

print(ans)


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<ll > ruiseki;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;
ll N, M;

ll check(ll num){
    //握手したとき（2つの数を決め打ちした時），ある数mid以下の数はいくつあるか
    //億マス計算をイメージ N*Nのマスがあって行と列で足し算して超えるか超えないか判断する
    ll sum = 0;
    //二分探査
    //cout << num << endl;
    for(ll i = 0; i < N; i++){
        ll left = 0; ll right = N;
        //そもそも二分探査が成立しない時
        //leftですでにmidの値より下回っている
        if(vec[i] + vec[0] < num) continue;
        while(left + 1 < right){
            ll mid = (left + right) / 2;
            if(vec[i] + vec[mid] >= num){
                //vecは降順に並んでいることを忘れないで当てはまる境界値を左へ寄せていく
                left = mid;
            }else{
                right = mid;
            }            
        }
        //leftが配列上で当てはまる境界のindexなのでleft+1が当てはまっている個数ですわよ
        sum += left + 1;
    }

    /*
    if(sum <= M){
        return true;
    }else{
        return false;
    }
    */

   return sum;

}

ll calculator(ll num){
    //二分探査で割り出したM個ぴったり選ぶことのできる数Kを使って総和を計算
    //行のある数 * 列上でどこまであてはまるかの数 + 累積和 = 総和
    ll sum = 0;

    for(ll i = 0; i < N; i++){
        //M以下に当てはまる最大の値
        ll left = 0; ll right = N;
        if(vec[i] + vec[0] < num) continue;

        while(left + 1 < right){
            ll mid = (left + right) / 2;
            if(vec[i] + vec[mid] >= num){
                left = mid;
            }else{
                right = mid;
            }            
        }
        sum += vec[i] * (left + 1) + ruiseki[left];
    }

    return sum;

}

int main() {

    cin >> N >> M;
    //配列で言うP-1までは採用対象
    vec.assign(N, 0);
    ruiseki.assign(N, 0);

    for(ll i = 0; i < N; i++){
        cin >> vec[i];
    }
    sort(vec.rbegin(), vec.rend());

    //累積和準備
    for(ll i = 0; i < N; i++){
        if(i == 0){
            ruiseki[0] = vec[0];
        }else{
            ruiseki[i] = ruiseki[i-1] + vec[i];
        }
        //cout << ruiseki[i] << endl;
    }

    //ある数midを与えた時それを満たすような握手のペアがいくつあるか？
    //今回は握手する回数がMで固定なのでM以下であるような境界を見つける
    //Mになるようなmidはたくさんあります.あくまでもM個になる最大値Kが見つかるだけ
    //M以下になるような条件を満たすような数で最大
    //どの数までならM以下になるか，どの数で初めてM個を超えるかしかわからない
    //ので誤差が小さくなる方向で生じる時がある.
    ll left = 0; ll right = INF;
    while(left + 1 < right){
        ll mid = (left + right) / 2;
        if(check(mid) <= M){
            right = mid;
        }else{
            left = mid;
        }
        //cout << check(mid) << endl;
        //cout << left << " " << right << endl;
    }

    ll ans = 0;

    //cout << left << " " << right << " " << calculator(right) << endl;
    //cout << check(right) << endl;
    cout << calculator(right) + (M - check(right)) * (right - 1)<< endl;
    //ではどのようなmidを実際にM個選んだ時の最大値を知ることができるか
    //cout << calculator(right) << endl;

}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)


int main()
{
  int n,k;
  cin>>n>>k;
  int d[k];
  rep(i,k) cin>>d[i];

  rep(i,9*n+1)
  {
    int num=n+i,ans=num;
    bool flag=true;
    int keta=log10(num)+1;
    rep(j,keta)
    {
      int tmp=num%10;
      rep(l,k)
      {
        if(tmp==d[l])
        {
          flag=false;
          break;
        }
      }

      num/=10;
    }

    if(flag)
    {
      cout<<ans<<endl;
      break;
    }
  }


}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,L,R;
	while(cin>>N>>M) {
		ll l=-1, r=N+1;
		REP(i, M) {
			cin>>L>>R;
			maxUpdate(l, L);
			minUpdate(r, R);
		}
		
		cout<<max(0LL, r-l+1)<<endl;
	}
	
	return 0;
}


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

int main(){
	char s[50];

	scanf("%[^\n]", s);
	int tam = strlen(s);
	printf("%c", toupper(s[0]));
	for (int i = 0;i < tam;i++) {
		if(s[i] == ' '){
			printf("%c", toupper(s[i+1]));
		}
	}
	puts("");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define COUTDOUBLE(v) cout << std::setprecision(10)<<(v)<<endl;
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define f first
#define s second

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int dis(char c){
    int hoge = c-'a';
    return (26-hoge)%26;
}

int main(){
    SCIN(str);
    CIN(K);
    string ans;
    for(char c :str){
        int calc = dis(c);
        if(calc <= K){
            ans.push_back('a');
            K-=calc;
        }else{
            ans.push_back(c);
        }
    }
    int ins = ans.back() - 'a';
    ins += K;
    ins%=26;
    char c = 'a'+ins;
   // COUT(c);
    ans.back() = c;
    COUT(ans);
    return 0;
}


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

const int p = 1000000007;
long long dp[100];

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  int idx;
  if ( s[0] == t[0] ) {
    idx = 0;
    dp[idx++] = 3;
  }
  else {
    idx = 1;
    dp[idx++] = 6;
  }
  while ( idx < n ) {
    if ( s[idx] == t[idx] ) {
      if ( s[idx-1] == t[idx-1] ) dp[idx] = dp[idx-1] * 2 % p;
      else dp[idx] = dp[idx-1];
      idx++;
    }
    else{
      if ( s[idx-1] == t[idx-1] ) dp[idx+1] = dp[idx] = dp[idx-1] * 2 % p;
      else dp[idx+1] = dp[idx] = dp[idx-1] * 3 % p;
      idx += 2;
    }
  }
  cout << dp[n-1] << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , A;
  cin >> N >> A;
  N = N % 500 ;
  
  if (N <= A) { 
   cout << "Yes" << endl; 
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;

int n;
vector<pair<int, int> > location;
double ans;

int main(){

  cin >> n;
  location = vector<pair<int, int> >(n);
  rep(i,n) cin >> location[i].first >> location[i].second;

  sort(location.begin(), location.end());
  double sum = 0;
  double count = 0;
  do{
    rep(i,n-1){
      sum += hypot(location[i+1].first-location[i].first, location[i+1].second-location[i].second);
    }
    count += 1;
  }while(next_permutation(location.begin(), location.end()));

  cout<< setprecision(16) << sum/count << endl;

  return 0;
}


Measured memory_bytes: 256
n = input()
a = map(int, raw_input().strip().split())

p = sorted(a)

if a == p:
    print "YES"
    exit()

flag = 0
for i in xrange(n):
    for j in xrange(i + 1, n):
        a[i], a[j] = a[j], a[i]
        if (a == p):
            flag = 1
            break
        a[i], a[j] = a[j], a[i]

    if flag: break

if flag:
    print "YES"
else:
    print "NO"


Measured memory_bytes: 30060
#include<bits/stdc++.h>
#define LL long long
#define pii pair<LL,LL>
#define fir first
#define sec second
#define mp make_pair
using namespace std;
map<pii,LL> a;
LL X[100010],Y[100010],ans[50];
int main()
{
	LL H,W,N,tot,x,y,i;
	scanf("%lld %lld %lld",&H,&W,&N);
	for(i=1;i<=N;i++)
	{
		scanf("%lld %lld",&X[i],&Y[i]);
		a[mp(X[i],Y[i])]=1LL;
	}
	
	memset(ans,0,sizeof(ans));
	for(i=1;i<=N;i++)
	{
		x=X[i];y=Y[i];
		if(x+2<=H&&y+2<=W)
		{
			tot=a[mp(x,y)]+a[mp(x,y+1)]+a[mp(x,y+2)]+a[mp(x+1,y)]+a[mp(x+1,y+1)]+a[mp(x+1,y+2)]+a[mp(x+2,y)]+a[mp(x+2,y+1)]+a[mp(x+2,y+2)];
			ans[tot]++;
		}
		if(x+2<=H&&1<=y-1&&y+1<=W)
		{
			tot=a[mp(x,y-1)]+a[mp(x,y+1)]+a[mp(x+1,y-1)]+a[mp(x+1,y)]+a[mp(x+1,y+1)]+a[mp(x+2,y-1)]+a[mp(x+2,y)]+a[mp(x+2,y+1)]+a[mp(x,y)];
			ans[tot]++;
		}
		if(x+2<=H&&1<=y-2&&y<=W)
		{
			tot=a[mp(x,y-2)]+a[mp(x,y-1)]+a[mp(x,y)]+a[mp(x+1,y-2)]+a[mp(x+1,y-1)]+a[mp(x+1,y)]+a[mp(x+2,y-2)]+a[mp(x+2,y-1)]+a[mp(x+2,y)];
			ans[tot]++;
		}
		if(1<=x-1&&x+1<=H&&y+2<=W)
		{
			tot=a[mp(x-1,y)]+a[mp(x-1,y+1)]+a[mp(x-1,y+2)]+a[mp(x,y)]+a[mp(x,y+1)]+a[mp(x,y+2)]+a[mp(x+1,y)]+a[mp(x+1,y+1)]+a[mp(x+1,y+2)];
			ans[tot]++;
		}
		if(1<=x-1&&x+1<=H&&1<=y-1&&y+1<=W)
		{
			tot=a[mp(x-1,y-1)]+a[mp(x-1,y)]+a[mp(x-1,y+1)]+a[mp(x,y-1)]+a[mp(x,y)]+a[mp(x,y+1)]+a[mp(x+1,y-1)]+a[mp(x+1,y)]+a[mp(x+1,y+1)];
			ans[tot]++;
		}
		if(1<=x-1&&x+1<=H&&1<=y-2)
		{
			tot=a[mp(x-1,y-2)]+a[mp(x-1,y-1)]+a[mp(x-1,y)]+a[mp(x,y-2)]+a[mp(x,y-1)]+a[mp(x,y)]+a[mp(x+1,y-2)]+a[mp(x+1,y-1)]+a[mp(x+1,y)];
			ans[tot]++;
		}
		if(1<=x-2&&y+2<=W)
		{
			tot=a[mp(x-2,y)]+a[mp(x-2,y+1)]+a[mp(x-2,y+2)]+a[mp(x-1,y)]+a[mp(x-1,y+1)]+a[mp(x-1,y+2)]+a[mp(x,y)]+a[mp(x,y+1)]+a[mp(x,y+2)];
			ans[tot]++;
		}
		if(1<=x-2&&1<=y-1&&y+1<=W)
		{
			tot=a[mp(x-2,y-1)]+a[mp(x-2,y)]+a[mp(x-2,y+1)]+a[mp(x-1,y-1)]+a[mp(x-1,y)]+a[mp(x-1,y+1)]+a[mp(x,y-1)]+a[mp(x,y)]+a[mp(x,y+1)];
			ans[tot]++;
		}
		if(1<=x-2&&1<=y-2)
		{
			tot=a[mp(x-2,y-2)]+a[mp(x-2,y-1)]+a[mp(x-2,y)]+a[mp(x-1,y-2)]+a[mp(x-1,y-1)]+a[mp(x-1,y)]+a[mp(x,y-2)]+a[mp(x,y-1)]+a[mp(x,y)];
			ans[tot]++;
		}
	}
	tot=0ll;for(i=1;i<=9;i++){ans[i]/=i;tot+=ans[i];}
	ans[0]=(H-2LL)*(W-2LL)-tot;
	for(i=0;i<=9;i++)printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 158080
int main() {
  int a, b;
  char op;
  for (;;) {
    scanf("%d %c %d", &a, &op, &b);
    switch(op) {
      case '+':
        printf("%d\n", a + b);
        break;
      case '-':
        printf("%d\n", a - b);
        break;
      case '*':
        printf("%d\n", a * b);
        break;
      case '/':
        printf("%d\n", a / b);
        break;
      default:
        return 0;
    }
  }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<class V, int ME> class BIT {
public:
    V bit[1<<ME];
    V total(int e) {V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
    void update(int e, V val) {e++; while(e<=1<<ME) bit[e-1]+=val,e+=e&-e;}
};
BIT<int, 5> bi;
ll count_inversion(vector<int> &a, int s, int t){
    REP(i, 1<<5) bi.bit[i] = 0;
    ll res = 0;
    for(int i=t;i>s-1;i--){
        res+=bi.total(a[i]);
        bi.update(a[i], 1);
    }
    return res;
}

const ll INF = (1ll<<60);

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

    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];

    vector<int> ura(N);
    vector<ll> C(N, 0), D(N, 0);
    ll res = INF;
    REP(mask, (1ll<<N)){
    	//dump(mask)
    	REP(i, N){
    		ura[i] = (mask>>i & 1);
    	}
    	REP(i, N){
    		if(ura[i]==1){
    			C[i] = B[i];
    		}else{
    			C[i] = A[i];
    		}
    	}
    	//cout << C << endl;
    	REP(i, N) D[i] = C[i];
    	sort(D.begin(), D.end());
    	vector<bool> checked(N, false);
    	vector<int> perm(N, 0);

    	REP(i, N){
    		//dump(i)
    		REP(j, N){
    			//dump(j)
    			//dump(C[j])
    			//dump(D[i])
    			//dump((abs(j-i)+ura[j]))
    			if(!checked[j] &&  C[j] == D[i] && (abs(j-i)+ura[j])%2==0){
    				checked[j] = true;
    				perm[i] = j;
    				break;
    			}
    		}
    	}
    	bool ok = true;
    	REP(i, N) if(!checked[i]) ok = false;

    	//cout << ura << endl;
    	//cout << perm << endl;

    	if(ok){
	    	ll val = count_inversion(perm, 0, N-1);
	    	res = min(val, res);
	    	//cout << val << endl;
	    }
	    //cout << endl;

    }
    cout << (res==INF ? -1 : res) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,double> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

struct point{
	double x,y;
	point operator+(point p){
		return point{x+p.x,y+p.y};
	}
	point operator-(point p){
		return point{x-p.x,y-p.y};
	}
	point operator*(double p){
		return point{x*p,y*p};
	}
	point operator/(double p){
		if(!p) return point{0,0}; 
		return point{x/p,y/p};
	}
	bool operator==(point p){
		return fabs(x-p.x)<eps&&fabs(y-p.y)<eps;
	}
	bool operator<(point p){
		if(fabs(x-p.x)>eps) return x<p.x;
		return y<p.y;
	}
};

class Graph{
	private:
	int V;
	vvp List;
	public:
	Graph(int v){
		V=v;
		List=vvp(v);
	}
	void add_edge(int s,int t,double c){
		List[s].push_back(P(t,c));
		List[t].push_back(P(s,c));
	}
	double DIJ(int s,int t){
/*		for(int i=0;i<V;i++){
			for(int j=0;j<List[i].size();j++){
				cout<<List[i][j].second<<' ';
			}
			cout<<endl;
		}*/
		priority_queue<P> que;
		vd d(V,INF);
		d[s]=0;
		que.push(P(s,0));
		while(!que.empty()){
			pair<ll,ll> p=que.top();
			que.pop();
			int v=p.first;
			if(d[v]<-p.second) continue;
			for(int i=0;i<List[v].size();i++){
				int F=List[v][i].first;
				double S=List[v][i].second;
				if(d[F]>d[v]+S){
					d[F]=d[v]+S;
					que.push(P(F,-d[F]));
				}
			}
		}
		return d[t];
	}
};


typedef pair<point,point> pp;
typedef vector<point> VP;
const point O{0,0};

double Length(point x,point y){
	point z=y-x;
	return sqrt(z.x*z.x+z.y*z.y);
}

void Point_in(point& p){
	cin>>p.x>>p.y;
}

point p,q;
int n;
VP c;
vi r;

int main(){
	cout<<syosu(11);
	Point_in(p);
	Point_in(q);
	cin>>n;
	c=VP(n);
	r=vi(n);
	for(int i=0;i<n;i++){
		Point_in(c[i]);
		cin>>r[i];
	}
	c.push_back(p);
	c.push_back(q);
	r.push_back(0);
	r.push_back(0);
	Graph g(n+2);
	for(int i=0;i<n+2;i++) for(int j=i+1;j<n+2;j++){
		double e=Length(c[i],c[j])-r[i]-r[j];
		if(e<0) e=0;
		g.add_edge(i,j,e);
	}
	cout<<g.DIJ(n,n+1)<<endl;
}

Measured memory_bytes: 20720
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
		int[] x = new int[6];

        for(var i = 0; i < 6; i++)
		{
			x[i] = int.Parse(Console.ReadLine());
		}
		if (x[4] - x[0] > x[5])
		{
			Console.WriteLine(":(");
		}
		else { Console.WriteLine("Yay!"); }
	}
}





Measured memory_bytes: 13140
function spilitInput(input) {
  var splited = [];
  var rows = input.split('\n');
  for (var i = 0; i < rows.length; i += 1) {
    splited.push(rows[i].split(' '));
  }
  return splited;
}
function Main(input) {
  var splited = spilitInput(input);
  var N = splited[0][0];
  var Y = splited[0][1];
  var ax = 10000;
  var ay = 5000;
  var az = 1000;
  var x = -1;
  var y = -1;
  var z = -1;
  var hit = false;
  
  for(var iz = 0; iz <= N && !hit; iz += 1) {
  for(var iy = 0; iz + iy <= N && !hit; iy += 1) {
    var ix = N - iz - iy;
    var total = (ax*ix)+(ay*iy)+(az*iz);
    if (total == Y) {
      x = ix;
      y = iy;
      z = iz;
      hit = true;
    }
  }
  }
  console.log(x+' '+y+' '+z);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32540
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);
const llint mod=1000000007;
int main(void){
	//1,1,1,1.2.3.4
	//1,1,2,1.2.3.4
	//1,1,3,1.2.3.4.
	//1,1,4,1.2.3.4.
	//1,2,1.2.3.4
	//1,3,1.2.3.4
	//1,4,1.2.3.4
	//2,1,1,(1.2.3.4) 1
	//2,2,222
	//2,333
	//2,44

	llint i,n,ans=0,hai=1;
	static llint dp[1000005]={0};
	scanf("%lld",&n);
	for(i=0;i<n;i++){
		hai+=dp[i];
		hai%=mod;
		dp[i]%=mod;
		//今すぐ終わる
		if(i<n-1){ ans+=hai*(((n-1)*(n-1)+min(i+2,n-1))%mod); } else{ans+=n*hai;}
		ans%=mod;
		dp[i+3]+=hai;
		dp[i+1]+=dp[i];

	}
	printf("%lld",ans%mod);
	return 0;
	
}



Measured memory_bytes: 7936