akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <deque>

std::deque<int> dq;

int main() {
  int n;
  std::cin >> n;
  std::string op;
  int k;
  for (int i = 0; i < n; ++i) {
    std::cin >> op;
    if (op == "deleteFirst") {
      dq.pop_front();
    }
    if (op == "deleteLast") {
      dq.pop_back();
    }
    if (op == "insert") {
      std::cin >> k;
      dq.push_front(k);
    }
    if (op == "delete") {
      std::cin >> k;
      for (auto it = dq.begin(); it != dq.end(); ++it) {
        if (*it == k) {
          dq.erase(it);
          break;
        }
      }
    }
  }
  bool f = false;
  for (auto &k : dq) {
    if (f) std::cout << " ";
    f =  true;
    std::cout << k;
  }
  std::cout << std::endl;
  return 0;
}



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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 5e5;
ll f[N + 1], f_inv[N + 1], b[N + 1];

ll power (ll n, ll k) {
    ll res = 1;
    while (k != 0) {
        if (k & 1)
            res = (res * n) % mod;
        k /= 2;
        n = (n * n) % mod;
    }
    return res;
}

ll C (ll n, ll k) {
    if (n < k) return 0;
    ll x = f[n] * f_inv[k] % mod * f_inv[n - k] % mod;
    return x;
}

ll sq (ll x) {
    return x * x % mod;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif	
    f[0] = f_inv[0] = b[0] = 1;
    for (ll i = 1; i <= N; i++) {
        f[i] = i * f[i - 1] % mod;
        b[i] = b[i - 1] * f[i] % mod;
    }
    ll x = power(b[N], mod - 2);
    for (ll i = N; i > 0; i--) {
        f_inv[i] = x * b[i - 1] % mod;
        x = x * f[i] % mod;
    }
    ll n, m;
    cin >> n >> m;
    ll ans = 0, temp;
    for (ll i = 0; i <= n; i++) {
        temp = C(n, i) * C(m, i) % mod;
        temp *= f[i];
        temp %= mod;
        temp *= sq(C(m - i, n - i));
        temp %= mod;
        temp *= sq(f[n - i]);
        temp %= mod;
        if (i & 1)
            temp *= -1;
        if (temp < 0)
            temp += mod;
        ans += temp;
        ans %= mod;
    }
    cout << ans << "\n";
 	return 0;
}         

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

int main()
{
    // 整数の入力
    int N;
    cin >> N;
    vector<int64_t> L(N + 1);

    if (N == 1)
    {
        L.at(N) = 1;
    }
    else
    {
        L.at(0) = 2;
        L.at(1) = 1;
        for (int i = 2; i <= N; i++)
        {
            L.at(i) = L.at(i - 1) + L.at(i - 2);
        }
    }
    cout << L.at(N) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}




int main(){
  int N;
  cin>>N;
  int t[N+1],x[N+1],y[N+1];
  t[0]=0;
  x[0]=0;
  y[0]=0;
  for(int i=1;i<N+1;i++){
    cin>>t[i]>>x[i]>>y[i];
  }
  int imax=0;
  int imay=0;
  bool ok=true;
  for(int i=1;i<N+1;i++){
    int tmp=abs(imax-x[i])+abs(imay-y[i]);
    if(tmp<=t[i]){
    tmp-=t[i]-t[i-1];
    if(tmp%2==0){
    }else{
      ok=false;
      break;
    }
    imax=x[i];
    imay=y[i];}
    else{
      ok=false;
      break;
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}



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

using namespace std;
typedef long long ll;

struct lst
{
private:
    int n;
    vector<ll> node;
    vector<ll> lazy;
    vector<bool> lflg;

    void lazy2node(int k, int l, int r)
    {
        if(lflg[k])
        {
            node[k]+=(r-l+1)*lazy[k];
            prop(lazy[k], k, l, r);
            lflg[k]=false;
            lazy[k]=0;
        }
    }

    void prop(int v, int k, int l, int r)
    {
        if(r-l>0)
        {
            lazy[2*k+1]+=v;
            lazy[2*k+2]+=v;
            lflg[2*k+1]=lflg[2*k+2]=true;
        }
    }

public:
    lst(int sz)
    {
        n=1; while(n<sz) n*=2;
        node.resize(2*n-1, 0);
        lazy.resize(2*n-1, 0);
        lflg.resize(2*n-1, false);
    }

    void update(int qa, int qb, int v, int k=0, int l=0, int r=-1)
    {
        if(r<0) r=n-1;
        lazy2node(k, l, r);
        if(qb<l || r<qa) return;
        if(qa<=l && r<=qb)
        {
            node[k]+=(r-l+1)*v;
            prop(v, k, l, r);
        }
        else
        {
            int m=(l+r)/2;
            update(qa, qb, v, 2*k+1, l, m);
            update(qa, qb, v, 2*k+2, m+1, r);
            node[k]=node[2*k+1]+node[2*k+2];
        }
    }

    ll get(int qa, int qb, int k=0, int l=0, int r=-1)
    {
        if(r<0) r=n-1;
        lazy2node(k, l, r);
        if(qb<l || r<qa) return 0;
        if(qa<=l && r<=qb) return node[k];
        else
        {
            int m=(l+r)/2;
            ll ls = get(qa, qb, 2*k+1, l, m);
            ll rs = get(qa, qb, 2*k+2, m+1, r);
            return ls+rs;
        }
    }
};

int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    lst tree=lst(n);
    for(int i=0; i<q; i++)
    {
        int c;
        scanf("%d", &c);
        if(c)
        {
            int t;
            scanf("%d", &t);
            int a=tree.get(t-1, t-1);
            printf("%lld\n", tree.get(t-1, t-1));
        }
        else
        {
            int s, t, v;
            scanf("%d %d %d", &s, &t, &v);
            tree.update(s-1, t-1, v);
        }
    }
    return 0;
}


Measured memory_bytes: 7036
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FAST ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define mod 1000000007



int main()
{
	
	FAST;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
    	 int n ; cin>>n;
    	 int h[n+1], dp[n+1];
    	 for(int i=1; i<=n; i++) cin>>h[i];
    	 dp[1] = 0 , dp[2] = abs(h[2]-h[1]);
    	 for(int i=3; i<n+1; i++)
    	 {
    	 	dp[i] = min( dp[i-1]+abs(h[i]-h[i-1]) , dp[i-2]+abs(h[i]-h[i-2]));
		 }
		 cout<<dp[n]<<endl;
	}
		
    return 0;
}

Measured memory_bytes: 4436
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize =  read();
    let p: Vec<u64> = (0..n).map(|_| read()).collect();
    let mut ret = 0;
    let mut m = (n + 1) as u64;

    for i in 0..n {
        if m >= p[i] {
            ret += 1;
            m = p[i];
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 6396
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <random>
#include <map>
#include<iomanip>

//AtCoderC++.cpp

using namespace std;


#define rep(i,from,to) for(int i=from;i<to;i++)
#define ints(name,n) vector<int> name;name.resize(n)

template<typename T> void Show(vector<vector<T>> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(vector<T> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	rep(i, 0, h) {
		rep(j, 0, w) {
			if (!ts[i][j])return false;
		}
	}
	return true;
}


int main() {
	int *times = new int[5];
	for (size_t i = 0; i < 5; i++) {
		cin >> times[i];
	}
	auto max_d = 0;
	for (size_t i = 0; i < 5; i++) {
		if (times[i] % 10 != 0)	max_d = max(max_d, 10 - times[i] % 10);
	}
	int sum = 0;
	for (size_t i = 0; i < 5; i++) {
		sum += times[i];
		if (times[i] % 10 != 0)	sum += (10 - times[i] % 10);
	}
	std::cout << sum - max_d << endl;
}




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

double PI = 3.14159265358979323846;

int main() {
    double a, b, degree;
    cin >> a >> b >> degree;

    double rad = (degree * PI) / 180.0;

    double s = 0.5 * a * b * sin(rad);
    double l = a + b + (sqrt(a*a + b*b - 2*a*b*cos(rad)));
    double h = (2.0 * s) / a;

    printf("%.11f\n", s);
    printf("%.11f\n", l);
    printf("%.11f\n", h);

    return 0;
}


Measured memory_bytes: 3464
import java.util.Scanner;

public class Main{
	static int[][] dfs(int x,int y,int[][] fie,int[][] flag,int w,int h){
		flag[x][y]=1;
		for(int i=-1;i<=1;i++)for(int j=-1;j<=1;j++){
			int nx=x+i,ny=y+j;
			if(nx>=0 && nx<w && ny>=0 && ny<h){
				if(flag[nx][ny]==0 && fie[nx][ny]==1)flag=dfs(nx,ny,fie,flag,w,h);
			}
		}
		return flag;
	}
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int[][] fie,flag;
		int w,h;
		fie=new int[60][60];
		flag=new int[60][60];
		while(1>0){
			for(int i=0;i<60;i++)for(int j=0;j<60;j++)flag[j][i]=0;
			w=sc.nextInt();
			h=sc.nextInt();
			if(w+h==0)break;
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)fie[j][i]=sc.nextInt();
			int cnt=0;
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(fie[j][i]==1 && flag[j][i]==0){
				cnt++;
				flag=dfs(j,i,fie,flag,w,h);
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 48844
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	vector<vector<int>> grid(3, vector<int>(3));
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> grid[i][j];
		}
	}
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				if (grid[i][j] == tmp)
					grid[i][j] = 0;
			}
		}
	}
	if (grid[0][0] + grid[0][1] + grid[0][2] == 0)
	{
		cout << "Yes" << endl;
	}
	else if (grid[1][0] + grid[1][1] + grid[1][2] == 0)
	{
		cout << "Yes" << endl;
	}
	else if (grid[2][0] + grid[2][1] + grid[2][2] == 0)
	{
		cout << "Yes" << endl;
	}
	else if (grid[0][0] + grid[1][0] + grid[2][0] == 0)
	{
		cout << "Yes" << endl;
	}
	else if (grid[0][1] + grid[1][1] + grid[2][1] == 0)
	{
		cout << "Yes" << endl;
	}
	else if (grid[0][2] + grid[1][2] + grid[2][2] == 0)
	{
		cout << "Yes" << endl;
	}
	else if (grid[0][0] + grid[1][1] + grid[2][2] == 0)
	{
		cout << "Yes" << endl;
	}
	else if (grid[0][2] + grid[1][1] + grid[2][0] == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import collections

x, y = map(int, input().split())
d = collections.defaultdict(int)
d[3] = 100000
d[2] = 200000
d[1] = 300000
ans = 0
if x == 1 and y == 1:
    ans += 400000
ans += d[x] + d[y]
print(ans)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 998244353;
const int N = 3005;

int a[N];
int f[N];
int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        f[0]++;
        for (int k = m; k >= a[i]; k--) {
            f[k] += f[k - a[i]];
            f[k] %= mod;
        }
        ans += f[m];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
ll A[1010][1010];
vector<ll> tree[1000010];
int cnt[1000010] = {};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    rep(i,0,N){
        rep(j,0,N-1){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    
    ll M = N * (N-1) / 2;
    ll idx = 0;
    map<lpair,ll> pos;
    rep(i,0,N){
        rep(j,i+1,N){
            pos[make_pair(i,j)] = idx;
            idx++;
        }
    }
    rep(i,0,N){
        rep(j,0,N-2){
            ll p1 = i, p2 = A[i][j];
            if(p1 > p2) swap(p1, p2);
            ll v1 = pos[make_pair(p1, p2)];
            p1 = i; p2 = A[i][j+1];
            if(p1 > p2) swap(p1, p2);
            ll v2 = pos[make_pair(p1, p2)];
            tree[v1].push_back(v2);
            cnt[v2]++;
        }
    }
    stack<ll> st;
    rep(i,0,M){
        if(cnt[i] == 0) st.push(i);
    }
    vector<ll> res;
    ll ans = 0;
    while(not st.empty()){
        ans++;
        ll sz = st.size();
        vector<ll> v;
        rep(i,0,sz){
            ll t = st.top();
            res.push_back(t);
            st.pop();
            v.push_back(t);
        }
        for(auto &e: v){
            for(auto &e2: tree[e]){
                cnt[e2]--;
                if(cnt[e2] == 0) st.push(e2);
            }
        }
    }
    if(res.size() != M){
        print(-1);
    }else{
        print(ans);
    }
}

Measured memory_bytes: 88172
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 200000;

int aa[N], kk[N + 1];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)
		cin >> aa[i];
	for (int i = 0; i < n; i++)
		kk[aa[i]]++;
	long long x = 0;
	for (int a = 1; a <= n; a++)
		x += (long long) kk[a] * (kk[a] - 1) / 2;
	for (int i = 0; i < n; i++)
		cout << x - (kk[aa[i]] - 1) << '\n';
	return 0;
}


Measured memory_bytes: 3712
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int max = 0;
		int start = 0;
		for (int i = 0; i < n; i++) {
			if (i != 0 && arr[i] == arr[i - 1]) {
				continue;
			}
			int count = 0;
			boolean setFlag = false;
			for (int j = start; j < n; j++) {
				if (arr[i] - arr[j] > 1) {
					continue;
				}
				if (arr[j] - arr[i] > 1) {
					break;
				}
				count++;
				if (!setFlag) {
					setFlag = true;
					start = j;
				}
			}
			if (max < count) {
				max = count;
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 51624
K = 0
def recursive(d:int,value:int,lis:list):
    lis.append(value)
    if(d == 10):return
    for j in range(-1,2,1):
        add = value % 10 + j
        if(add >= 0 and add <= 9):
            recursive(d + 1,value * 10 + add,lis)
    

def main():
    global K
    K = int(input())
    lis = []
    for v in range(1,10):
        recursive(1,v,lis)
    lis.sort()
    print(lis[K - 1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 12304
/*
 *  author: chw0501
 *  reference: 
 *  created: 18.04.2020 07:44:17(UTC)
*/
#include <bits/stdc++.h>

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

#define MOD 1000000007

int n;
/*dp[i][j]: i번째 남자를 확인해야하고(1~i-1까지 매칭 완료)
매칭된 여자 집합이 j일때 앞으로 얻을 수있는 최대 가짓수*/
ll dp[22][1<<21];

int com[21][21];

ll solve(int i,int j){
	ll & ret=dp[i][j];
	if(ret!=-1ll) return ret;
	if(i==n && j==((1<<n)-1)) return ret=1;
	else if(i==n) return ret=0;
	ret=0;
	for(int k=0;k<n;k++){
		if(com[i][k]==1 && ( (1<<k)&j )==0){
			ret=(ret+solve(i+1,j|(1<<k)))%MOD;
		}
	}
	return ret;
}

int main(){
	cin>>n;
	memset(dp,-1ll,sizeof(dp));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&com[i][j]);
		}
	}
	cout<<solve(0,0);
	return 0;
}

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

int main(){
    long long A,B,ans=1;
    cin >> A >> B;
    long long g = __gcd(A,B);
    for(long long i=2;i*i<=g;i++){
        if(g%i==0){
            ans++;
            while(g%i==0)g/=i;
        }
    }
    if(g!=1) ++ans;
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    n,k = map(int, input().split())
    ans = 0
    for b in range(k+1, n+1):
        c = 0
        a = k+c*b
        while a <= n:
            if a != 0:
                if a+b-k <= n:
                    ans += b-k
                else:
                    ans += n-a+1
            else:
                if a+b-k <= n:
                    ans += b-k-1
                else:
                    ans += n-a
            c += 1
            a = k+c*b
    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
	long long n, d, x, y, s=0;
	cin >> n >> d;
	
	for(int i=0; i<n; i++){
		cin >> x >> y;
		if (x*x+y*y<=d*d) s++;
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 3584
#include"bits/stdc++.h"
using namespace std;
namespace ORIGIN {
#define LL long long
#define VLL vector<long long>
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define COUT(x) cout<<x<<endl
#define WHOLE(x) x.begin(),x.end()
	double pai = 3.1415926535;
	string atc = "atcoder";
	typedef pair<long long, long long> data_t;
	string strnum = "0123456789";
	string alpS = "abcdefghijklmnopqrstuvwxyz";
	string alpL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int sizealp = (int)(alpS.size());
	int mod = 1e9 + 7;
	bool test = false;
}
using namespace ORIGIN;

void Test(char a) {
	if (test) {
		printf("%c", a);
	}
}
int gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}

int main() {
	int a, b;
	cin >> a >> b;
	b += a * 3;
	COUT(b / 2);
}

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

int numTimes(int m, int d) {
    int n = m;
    int times = 0;
    for (int k = 6; k >= 0; k--) {
        int pow_d_k = (int)pow(d, k);
        if (pow_d_k <= n) {
            times += n / pow_d_k;
            n -= pow_d_k * (n / pow_d_k);
        }
    }
    return times;
}

int main() {
    int n;
    scanf("%d", &n);

    int ans = (1 << 21);

    int n_div_9 = n / 9;
    for (int ni = 0; ni <= n_div_9; ni++) {
        int si = (n - 9 * ni) / 6;
        int sum = 9 * ni + 6 * si;
        ans = min(ans, numTimes(ni, 9) + numTimes(si, 6) + (n - sum));
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main () {
	int A;
	int B;
	scanf("%d\n", &A);
	scanf("%d", &B);
			if(A==1 && B==2){
				printf("3\n");
			}
			else if(A==2 && B==1){
				printf("3\n");
			}
			else if(A==1 && B==3){
				printf("2\n");
			}
			else if(A==3 && B==1){
				printf("2\n");
			}
			else{
				printf("1\n");
			}
			return 0;
		}


Measured memory_bytes: 3168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

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

		int A = sc.nextInt(); // Red
		int B = sc.nextInt(); // Green
		int C = sc.nextInt(); // Blue

		int K = sc.nextInt();

		for (int i=0; i < K; i++) {
			if (A >= B) {
				B = B * 2;
			}
			else if (B >= C) {
				C = C * 2;
			}
		}


		if (check(A, B, C)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

	private static boolean check(int red, int green, int blue) {
		//System.out.println("red="+red+",green="+green+"blue="+blue);

		if (red < green && green < blue) {
			//System.out.println("true");
			return true;
		}
		//System.out.println("false");
		return false;
	}

	private static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


Measured memory_bytes: 32724
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }
int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) { cin >> S[i]; }
    auto f = [&](const string& s1, const string& s2) {
        for (int i = 0; i < H; i++) {
            if (s1[i] != s2[H - 1 - i]) { return false; }
        }
        return true;
    };
    mt19937 mt{random_device{}()};
    for (int t = 0; t < 10; t++) {
        shuffle(S.begin(), S.end(), mt);
        vector<vector<int>> rs;
        auto rec = fix([&](auto&& self, vector<int> r, const int num) -> void {
            if (num == (H + 1) / 2) {
                rs.push_back(r);
            } else {
                int head = 0;
                for (; r[head] != -1; head++) {}
                r[head] = num;
                if (H % 2 == 1 and num == (H - 1) / 2) {
                    self(self, r, num + 1);
                } else {
                    for (int tail = head + 1; tail < H; tail++) {
                        if (r[tail] == -1) {
                            r[tail] = num;
                            self(self, r, num + 1);
                            r[tail] = -1;
                        }
                    }
                }
            }
        });
        rec(vector<int>(H, -1), 0);
        for (const auto& row : rs) {
            vector<int> r(H, -1);
            for (int i = 0; i < H; i++) {
                if (r[row[i]] == -1) {
                    r[row[i]] = i;
                } else {
                    r[H - 1 - row[i]] = i;
                }
            }
            vector<string> cols(W);
            for (int i = 0; i < W; i++) {
                for (int j = 0; j < H; j++) { cols[i].push_back(S[r[j]][i]); }
            }
            vector<bool> unused(W, true);
            for (int i = 0; i < W; i++) {
                if (not unused[i]) { continue; }
                for (int j = i + 1; j < W; j++) {
                    if (unused[j] and f(cols[i], cols[j])) {
                        unused[i] = false, unused[j] = false;
                        break;
                    }
                }
            }
            if (accumulate(unused.begin(), unused.end(), 0LL) <= 1) {
                bool s = true;
                for (int i = 0; i < W; i++) {
                    if (unused[i] and not f(cols[i], cols[i])) { s = false; }
                }
                if (s) {
                    cout << "YES" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 1256
import java.io.PrintWriter
import java.math.BigDecimal
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)


fun main(args: Array<String>) {
    val (a, b) = nextListOfString()
    val A = BigDecimal(a)
    val B = BigDecimal(b)
    val AB = A.multiply(B)
    println("$AB".split(".")[0])

}

fun abc000a() {
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }

Measured memory_bytes: 38076
#include <iostream>

using namespace std;

int main()
{
    int s, a, tmps[1000000] = {0}, ans;

    cin >> s;
    a = s;
    tmps[a]++;
    for (int i = 2; ; i++) {
        if (a % 2 == 0) {
            a = a / 2;
        } else {
            a = 3 * a + 1;
        }
        if (tmps[a] != 0) {
            ans = i;
            break;
        } else {
            tmps[a]++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4096
A, B, Q = gets.split.map(&:to_i)
s_list = A.times.map { gets.to_i }
t_list = B.times.map { gets.to_i }
x_list = Q.times.map { gets.to_i }

MAX = 1 << 60

x_list.each do |x|
  si = s_list.bsearch_index do |s|
    s >= x
  end
  ti = t_list.bsearch_index do |t|
    t >= x
  end
  s_candidates = []
  t_candidates = []
  if si
    s_candidates.push(s_list[si])
    s_candidates.push(s_list[si - 1]) if si > 0
  else
    s_candidates.push(s_list[-1])
  end
  if ti
    t_candidates.push(t_list[ti])
    t_candidates.push(t_list[ti - 1]) if ti > 0
  else
    t_candidates.push(t_list[-1])
  end
  ans = MAX
  s_candidates.each do |s|
    t_candidates.each do |t|
      n = (s - t).abs + [(x - s).abs, (x - t).abs].min
      ans = n if n < ans
    end
  end
  puts ans
end


Measured memory_bytes: 5684
import numpy as np
mod=10**9+7
N=int(input())
A=np.array(list(map(int, input().split())))
ans=0
for i in range(60):
  b=np.count_nonzero(A>>i&1)
  ans+=(2**i)*b*(N-b)
  ans%=mod
  
print(ans)

Measured memory_bytes: 49916
#include <stdio.h>

#include <vector>

using namespace std;

int global_min;
void update_global_min(int v) {
  if (global_min > v)
    global_min = v;
}

int digit_sum(int n) {
  int s = 0;
  while (n > 0) {
    s += n % 10;
    n /= 10;
  }
  return s;
}

int solve_dp(int k, int v, int s, vector<vector<int>>* dp) {
  if (v == 0 || s > 45)
    return s;
  //fprintf(stderr, "%d %d %d %d\n", k ,v, s, global_min);
  if ((*dp)[v][s])
    return (*dp)[v][s];
  (*dp)[v][s] = 999999;

  int score = digit_sum(v) + s;
  //fprintf(stderr, "up score=%d %d %d %d %d\n", score, k ,v, s, global_min);
  update_global_min(score);
  for (int i = 0; i <= 9; i++) {
    int nv = v + k * i;
    int ns = s + nv % 10;
    nv /= 10;
    if ((nv != v || ns != s) && ns < global_min) {
      int sc = solve_dp(k, nv, ns, dp);
      if (score > sc)
        score = sc;
    }
  }

  //fprintf(stderr, "return score=%d\n", score);
  return (*dp)[v][s] = score;
}

int solve(int k) {
  global_min = digit_sum(k);
  vector<vector<int>> dp(k+1);
  for (int i = 0; i <= k; i++) {
    dp[i].resize(50);
  }

  for (int i = 1; i <= 9; i++) {
    int nv = k * i;
    int ns = nv % 10;
    nv /= 10;
    int sc = solve_dp(k, nv, ns, &dp);
    //fprintf(stderr, "sc=%d\n", sc);
    update_global_min(sc);
  }
  return global_min;
}

int main() {
  int k;
  scanf("%d", &k);
  printf("%d\n", solve(k));
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; ++i) cin >> p[i];

    int cnt = 0;
    for(int i = 0; i < n - 2; ++i) {
        if((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i] > p[i + 1] && p[i + 1] > p[i + 2])) {
            cnt++;
        }
    }

    cout << cnt << endl;
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, auto init = 0) {
    return std::accumulate(all(vec), T(init));
}
// -------------------------------------------------------------------

using P = pair<int, int>;

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

    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;

    int cnt = 0;
    rep (i, n) {
        if (a[i] == b[i] and b[i] == c[i]) continue;
        if (a[i] == b[i] or b[i] == c[i] or c[i] == a[i])
            cnt++;
        else
            cnt += 2;
    }
    print(cnt);

    return 0;
}


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

using namespace std;

int a[5];

int main(){
   cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if (a[0] == a[1] && a[1] != a[2]) cout << "Yes";
  else if (a[0] != a[1] && a[1] == a[2]) cout << "Yes";
  else cout << "No";
	return 0; 
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
int64_t i,j,k,l;//preparation for
int main(){
    int x,n,s;
    cin>>x>>n;
    if(n==0){
        s=x;
    }
    {
    int p[n],q[n],r[200];
    fill(r,r+200,0);
    for(i=0;i<n;i++){
        cin>>p[i];
        q[i]=abs(p[i]-x);
        r[q[i]]+=1;
    }
    for(i=0;i<n;i++){
        if(r[i]==0){//p[] dosent have number which satisfys |x-i|
         s=x-i;
         break;
        }
        else if(r[i]==1&&i>0){
            for(j=0;j<n;j++){
                if(abs(p[j]-x)==i){
                    s=2*x-p[j];
                    break;
                }
            }
            break;
        }
    }
    }
    cout<<s;

    return 0;
}

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

const int N = 101010;

int n, a[N], b[N], ans, res, tot, fa[N], vis[N];
vector<int> va, vb, V[N];
set<int> all;
map<int, int> mp;

int Find(int x) {
  return fa[x] == x ? x : fa[x] = Find(fa[x]);
}

void Merge(int x, int y) {
  if(x == y) return;
  ans++;
  x = Find(x);
  y = Find(y);
  if(x != y) {
    vis[x] = 1;
    vis[y] = 1;
    fa[x] = y;
  }
}

int main(void) {
  //freopen("duliu.in", "r", stdin);
  //freopen("duliu.out", "w", stdout);
  scanf("%d", &n);
  for(int i = 1; i <= n; i++)
    scanf("%d", &a[i]), a[n + 1] ^= a[i];
  for(int i = 1; i <= n; i++)
    scanf("%d", &b[i]), b[n + 1] ^= b[i];
  for(int i = 1; i <= n + 1; i++) {
    va.push_back(a[i]);
    vb.push_back(b[i]);
    res += (a[i] != b[i]) && (i <= n);
  }
  sort(va.begin(), va.end());
  sort(vb.begin(), vb.end());
  
  for(int i = 0; i <= n; i++) {
    if(va[i] != vb[i])
      return puts("-1"), 0;
    if(mp.find(va[i]) == mp.end())
      mp[va[i]] = ++tot;
  }

  for(int i = 1; i <= tot; i++)
    fa[i] = i;

  for(int i = 1; i <= n; i++)
    Merge(mp[a[i]], mp[b[i]]);
  
  for(int i = 1; i <= tot; i++)
    if(vis[i] && fa[i] == i)
      ans++;
  if(vis[mp[a[n + 1]]])
    ans--;
  
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

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



int main() {
	
	int k;
	cin >> k;
	ll sum=0;

	for(ll i=1;i<=k;i++) {
		for(ll j=1;j<=k;j++) {
			ll temp = gcd(i,j);
			for(ll s=1;s<=k;s++) {
				sum+=gcd(temp,s);
			}
		}
	}
	cout << sum;

	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VVI A(N,VI(N-1));
  rep(i,N) rep(j,N-1) cin>>A[i][j];
  map<PII,int> M;
  int T=0;
  rep(i,N) rep(j,N) if(i<j) M[mp(i,j)]=T++;
  VVI X(N*(N-1)/2,VI(0));
  VI G(N*(N-1)/2);
  rep(i,N) rep(j,N-2){
    int tmp=i;
    int tmp2=A[i][j]-1;
    if(tmp>tmp2) swap(tmp,tmp2);
    int tmp3=i;
    int tmp4=A[i][j+1]-1;
    if(tmp3>tmp4) swap(tmp3,tmp4);
    X[M[mp(tmp,tmp2)]].pb(M[mp(tmp3,tmp4)]);
    G[M[mp(tmp3,tmp4)]]++;
  }
  int ans=1;
  VI H(N*(N-1)/2);
  rep(i,N*(N-1)/2) H[i]=G[i];
  VI FF(N*(N-1)/2);
  int Z;
  queue<int> Q;
  VI TP(0);
  rep(i,N*(N-1)/2){
    if(H[i] or FF[i]) continue;
    Z=i;
    Q.push(i);
    while(!Q.empty()){
      int now=Q.front();
      Q.pop();
      FF[now]=1;
      TP.pb(now);
      rep(j,X[now].size()){
        int nxt=X[now][j];
        H[nxt]--;
        if(!H[nxt]) Q.push(nxt);
      }
    }
  }
  if(TP.size()!=N*(N-1)/2){
    cout<<-1<<endl;
    return 0;
  }
  VI F(N*(N-1)/2,-1);
  rep(i,N*(N-1)/2){
    if(F[TP[i]]==-1) F[TP[i]]=1;
    rep(j,X[TP[i]].size()) F[X[TP[i]][j]]=max(F[X[TP[i]][j]],F[TP[i]]+1);
  }
  rep(i,N*(N-1)/2) ans=max(ans,F[i]);
  cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    int a,b,mx=INT_MIN;
    cin>>a>>b;
    int s1,s2,s3;
    s1=a+b;
    s2=a-b;
    s3=a*b;
    cout<<max(max(s1,s2),s3);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


// 68 11 55 - rank 3
// 69 12 19 - rank 3
// 70 12 34

int gcd(int a, int b) {
    while (b != 0) {
        auto na = a % b;
        a = b;
        b = na;
    }
    return a;
}


void oneCase() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a,c)) << "\n";
}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
    char a;
    cin>>a;
    if(a=='A')cout<<"T"<<endl;
    else if(a=='T')cout<<"A"<<endl;
    else if(a=='G')cout<<"C"<<endl;
    else if(a=='C')cout<<"G"<<endl;
    return 0;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  cin>>s;
  ll w=0,ans=0;
  rep(i,s.size()) if(s[i]=='W') w++;
  rep(i,s.size()) if(s[i]=='W') ans+=i;
  cout<<ans-w*(w-1)/2<<endl;
  
  
  
  
}

Measured memory_bytes: 720
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int h, w; cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int b;
            cin >> b;
            a[i][j] = abs(a[i][j] - b);
        }
    }
    const int m = 80*80;
    // dp[i][j][k] : iからjまででkになるか
    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(m + 1, false)));
    dp[0][0][a[0][0]] = true;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k <= m; k++) {
                if ((i >= 1 && dp[i - 1][j][k])
                    || (j >= 1 && dp[i][j - 1][k])) {
                    dp[i][j][abs(k - a[i][j])] = true;
                    if (k + a[i][j] <= m) {
                        dp[i][j][k + a[i][j]] = true;
                    }
                }
            }
        }
    }
    for (int i = 0; i <= m; i++) {
        if (dp[h - 1][w - 1][i]) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 5760
use std::io;

fn is_palindrome(s: &str) -> bool {
// sが回文であるかどうかを判定する
	let mut flag = true;
	let v:Vec<char> = s.chars().collect();
	let L = v.len();
	for n in 0..(L/2) {
		if v[n] != v[L - 1 - n] {
			flag = false;
			break;
		};
	}
	flag
}

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim().to_string();
	let mut flag = true;
	if !is_palindrome(&s) {
		flag = false;
	}
	if !is_palindrome(&s[..((s.len()-1)/2)]) {
		flag = false;
	}
	if !is_palindrome(&s[((s.len()+1)/2)..]) {
		flag = false;
	}
	if flag {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	long enc(String s){
		long ret = 0;
		for(int i=0;i<s.Length;i++){
			ret += ((long)(s[i] - 'a' + 1)) * p[i];
		}
		return ret;
	}
	String dec(long v){
		List<char> l = new List<char>();
		for(int i=0;i<11;i++){
			long d = v / p[i] % p[1];;
			if(d == 0) break;
			l.Add((char)(d - 1 + 'a'));
		}
		return new String(l.ToArray());
	}
	long[] p;
	public void Solve(){
		
		p = new long[12];
		p[0] = 1;
		for(int i=1;i<12;i++) p[i] = p[i-1] * 29;
		
		var di = new Dictionary<long, int>();
		foreach(var s in S){
			long hs = enc(s);
			if(!di.ContainsKey(hs)) di.Add(hs, 0);
			di[hs]++;
		}
		
		int ma = 0;
		foreach(var k in di.Keys){
			ma = Math.Max(ma, di[k]);
		}
		
		List<String> L = new List<String>();
		foreach(var k in di.Keys){
			if(di[k] == ma) L.Add(dec(k));
		}
		
		L.Sort(StringComparer.Ordinal);
		Console.WriteLine(String.Join("\n", L));
		
	}
	int N;
	String[] S;
	public Sol(){
		N = ri();
		S = new String[N];
		for(int i=0;i<N;i++) S[i] = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 54380
h,w=map(int,input().split())
L=[list(input()) for i in range(h)]
#L[y][x]
dx=[0,1,1,1,0,-1,-1,-1]
dy=[1,1,0,-1,-1,-1,0,1]
for i in range(h):
    for j in range(w):
        if L[i][j]=='#':
            for k in range(8):
                xr=j+dx[k]
                yr=i+dy[k]
                if (yr>=0 and yr<h and xr>=0 and xr<w):
                    if L[yr][xr]=='.':
                        L[yr][xr]=1
                    elif L[yr][xr]=='#':
                        continue
                    else:
                        L[yr][xr]+=1
        elif L[i][j]=='.':
            L[i][j]=0
for i in range(h):
    print(*L[i],sep='')
                

                    

Measured memory_bytes: 3444
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

const int INF = -1000000000;

int main(){
  int n,k;
  vector<int> C[10];
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++){
    int c,g;
    scanf("%d%d",&c,&g);
    C[g-1].push_back(c);
  }
  for(int i=0;i<10;i++){
    sort(C[i].begin(),C[i].end());
    reverse(C[i].begin(),C[i].end());
    for(int j=0;j<C[i].size();j++){
      if(j>0) C[i][j] += C[i][j-1] + 2 * j;
    }
  }
  int dp[11][k+1];
  fill(dp[0],dp[0]+k+1,INF);
  dp[0][0] = 0;
  for(int i=1;i<=10;i++){
    for(int j=0;j<=k;j++){
      for(int l=0;l<=C[i-1].size();l++){
        if(l==0) dp[i][j] = dp[i-1][j];
        else if(j-l>=0) dp[i][j] = max(dp[i][j],dp[i-1][j-l] + C[i-1][l-1]);
      }
    }
  }
  printf("%d\n",dp[10][k]);
  return 0;
}

Measured memory_bytes: 2788
#include<stdio.h>
int main(){
	int S,h,m,s;
	
	scanf("%d",&S);
	
	h=S/3600;
	m=(S%3600)/60;
	s=S%60;
	
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

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

int main() {
	// your code goes here
	int INF=1e9+5;
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	int dp[n];
	for(int i=0;i<n;i++)
	    dp[i]=INF;
	dp[0]=0;
	for(int i=0;i<n;i++){
	    if(i+1<n)
	        dp[i+1]=min(dp[i]+abs(arr[i+1]-arr[i]),dp[i+1]);
	    if(i+2<n)
	        dp[i+2]=min(dp[i]+abs(arr[i+2]-arr[i]),dp[i+2]);
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 4408
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

struct MyStruct {
	int num, honsu;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.honsu != t.honsu)
		return s.honsu < t.honsu; // 昇順
	return s.num > t.num;
}



int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;

	int ans = H*W - h*W - H*w + h*w;
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256