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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 1e9+7;

class mint{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(value_type _n):n(_n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    mint operator==(const mint &m) const {return n==m.n;}
    mint operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

//-------------------------------------------------
ll cnt[60];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    mint sum(0);
    rep(i,n){
        ll a; cin>>a;
        sum += a;
        rep(i,60){
            if (a%2) cnt[i]++;
            a/=2;
        }
    }
    sum *= n-1;
    rep(i,60){
        mint tmp;
        tmp = 1ll<<i;
        tmp *= cnt[i]*(cnt[i]-1);
        sum -= tmp;
    }
    cout << sum << endl;
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    int od=0,ev=0;
    for(int i=1;i<=n;i++){
        if(i%2==0)ev++;
        else od++;
    }
    cout<<ev*od;
}


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

using namespace std;

int main(void){
	vector<int> input;

	while (1){
		int n;
		cin >> n;
		if (n != 0){
			input.push_back(n);
		}
		else{
			break;
		}
	}

	for (int i = 0; i < input.size(); i++){
		cout << "Case " << i + 1 << ": " << input[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1320
import sys
input = sys.stdin.readline
def root(s):
    global pa
    if pa[s] == s:
        return s
    pa[s] = p = root(pa[s])
    return p

def unite(s, t):
    global pa
    a = root(s);b = root(t)
    if a == b:
        return 1
    elif rank[a] == rank[b]:
        pa[b] = a
        rank[a] += 1
    else:
        if rank[a] < rank[b]:
            pa[a] = b
        else:
            pa[b] = a

n, q = map(int, input().split())
pa = [i for i in range(n)]
rank = [1]*n
for i in range(q):
    a, b, c = map(int, input().split())
    if a == 0:unite(b,c)
    else:
        if root(b) == root(c):
            print(1)
        else:print(0)
        


Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
# define ll long long
ll N;
ll h[100010];
ll dp[100010];
ll call(int i)
{
    if(i==N) return 0;
    
    if(dp[i]!=-1) return dp[i];
    
    dp[i]=abs(h[i+1]-h[i]) + call(i+1);
    if(i+2<=N)
    dp[i]=min(dp[i],abs(h[i+2]-h[i]) + call(i+2));
    return dp[i];
}
int main()
{
    cin>>N;
    for(ll i=1;i<=N;i++)
    {
        cin>>h[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<call(1);
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

// using ll = long long;
// using P = pair<int, int>;
// using minpq = priority_queue<int, vector<int>, greater<int> >;


int main() {
    while (true) {
        int n,m;
        cin>>n>>m;
        if(n==0&&m==0)break;
        vector<int>a(n);
        for(int i=0;i<n;i++){
            cin>>a.at(i);
        }
        int MAX = -1;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(a.at(i)+a.at(j)<=m){
                    MAX = max(MAX, a.at(i)+a.at(j));
                }
            }
        }
        if(MAX == -1){
            cout<<"NONE"<<endl;
        }
        else{
            cout<<MAX<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define int long long
using namespace std;

int x,y,A,B,C,now,sum;
priority_queue< int,vector<int>,greater<int> >q1;
priority_queue< int,vector<int>,greater<int> >q2;
signed main(){
	scanf("%d%d%d%d%d",&x,&y,&A,&B,&C);
	for (register int i=1; i<=A; ++i)
	{
		scanf("%lld",&now);
		if (q1.size()<x) q1.push(now),sum+=now;
		else if (q1.top()<now) sum-=q1.top(),q1.pop(),q1.push(now),sum+=now; 
	}
	while (q1.size()<x) q1.push(0);
	
	for (register int i=1; i<=B; ++i)
	{
		scanf("%lld",&now);
		if (q2.size()<y) q2.push(now),sum+=now;
		else if (q2.top()<now) sum-=q2.top(),q2.pop(),q2.push(now),sum+=now; 
	}
	while (q2.size()<y) q2.push(0);
	
	for (register int i=1; i<=C; ++i) 
	{
		int add1,add2;
		scanf("%lld",&now);
		add1=now-q1.top();
		add2=now-q2.top();
		if (max(add1,add2)<=0) continue;
		if (add1>add2) q1.pop(),q1.push(now),sum+=add1;
		else q2.pop(),q2.push(now),sum+=add2;
	}
	
	printf("%lld\n",sum); 
return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N,K;
  cin >> N >> K;
  
  int flag=0;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  for (int j = 0; j < N-K; j++) {
    if(A.at(j) < A.at(j+K)){
      cout<<"Yes"<<endl;
    }else{
      cout <<"No"<<endl;
    }
  }
  
}


Measured memory_bytes: 4048
#include <stdio.h>
int main(void){

    int a, b, c;
    scanf("%d %d %d\n", &a, &b, &c);
    
    if(a < b){
        if(b < c){
        printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else{
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 2036
n,m=map(int, input().split())
l=[]
for i in range(n):
	a=list(map(int, input().split()))
	l.append(a)
l=sorted(l)


p=0
v=m
for i in range(n):
	if l[i][1]<=v:
		p+=l[i][0]*l[i][1]
		v=v-l[i][1]
		if v==0:
			print(p)
			exit()
	else:
		p+=v*l[i][0]
		print(p)
		exit()
	

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

using namespace std;
using ll=long long;

#undef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool x) { return (x ? "T" : "F"); }
string to_string(const char* s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename V>
string to_string(V v) {
    bool f = true; string res = "[";
    for (const auto& x: v) {
        if (!f) res += ", ";
        f = false;
        res += to_string(x); } res += "]";
    return res;
}
void debug() { cerr << endl; }
template <typename H, typename... T>
void debug(H h, T... t) { cerr << " " << to_string(h); debug(t...); }
#ifdef LOCAL
#define dbg(args...) cerr<<"("<<#args<<") =", debug(args)
#else
#define dbg(args...) 2019
#endif

const int L = 16;
const int N = 200005; 
ll dp[L][N];

int log4(ll x, ll y) {
    if (x >= y) {
        int e = 0;
        while (x > y) {
            y <<= 2;
            e++;
        }
        return e;
    } else {
        int e = 1;
        while (x <= y) {
            x <<= 2;
            e--;
        }
        return e;
    }
}

vector<ll> calc(const vector<int>& a) {
    int n = a.size();
    for (int j = 0; j < L; j++) {
        dp[j][n-1] = j;
    }
    for (int i = n-1; i >= 1; i--) {
        int e = log4(a[i-1], a[i]);
        for (int j = 0; j < L; j++) {
            dp[j][i-1] = j;
            int k = max(j+e, 0);
            dp[j][i-1] += k<L? dp[k][i] : dp[L-1][i] + (k-L+1)*(n-i);
        }
    }
    vector<ll> res(n);
    for (int i = 0; i < n; i++) {
        res[i] = dp[0][i] << 1;
    }
    return res;
}

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    auto suf = calc(a);
    reverse(a.begin(), a.end());
    auto pre = calc(a);
    reverse(pre.begin(), pre.end());
dbg(suf, pre);
    ll res = min(suf[0], pre[n-1]+n);
    for (int i = 1; i < n; i++) {
        ll tmp = pre[i-1] + i + suf[i];
        res = min(res, tmp);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

int main(void) {
    long long n, a, b;
    cin >> n >> a >> b;
    long long k = a + b;
    long long rest = n % k;
    long long l = n / k;
    cout << a * l + min(a, rest) << endl;
    return 0;
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

int main( void ){
	// initialize();
	rep(i,1,6){
		int input; cin >> input;
		if(input == 0)
			cout << i << endl;
	}
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define print(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
const int INF = 2e9 + 7;

int ans = 0, N;

bool fnc(ll n) {
    int chk[10] = {};

    while (n) {
        int rem = n % 10;
        chk[rem] = 1;
        n /= 10;
    }

    if (chk[3] && chk[5] && chk[7])
        return true;

    return false;
}

void dfs(ll n) {
    if (n > N) {
        return;
    }
    if (fnc(n)) {
        ans++;
    }
    dfs(n * 10 + 3);
    dfs(n * 10 + 5);
    dfs(n * 10 + 7);
}

int main() {
    cin >> N;
    dfs(0);
    print(ans);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(max(a)+1)]
for x in a:
    b[x] += 1
c = sum([x*(x-1)//2 for x in b])
for i in range(n):
    print(c-b[a[i]]+1)

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

int main() {
  int g[3][3];
  bool b[3][3];
  for (int i = 0; i < 3; i++) 
    for (int j = 0; j < 3; j++)
      cin >> g[i][j], b[i][j] = 0;
  int n; cin >> n;
  while (n--) {
    int t; cin >> t;
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        if (t == g[i][j]) b[i][j] = 1;
    for (int i = 0; i < 3; i ++)
      if ((b[i][0]&&b[i][1]&&b[i][2]) || (b[0][i]&&b[1][i]&&b[2][i])) {
        cout << "Yes";
        return 0;
      }
    if ((b[0][0]&&b[1][1]&&b[2][2]) || (b[0][2]&&b[1][1]&&b[2][0])) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define MAX_N 1000
#define MAX_M 100
using namespace std;

int n, m;
int a[MAX_N][MAX_M];

int main() {
  while(cin >> n >> m && n && m) {
    vector<int> v(m);
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < m; ++j) {
        cin >> a[i][j];
        v[j] += a[i][j];
      }
    }
    
    for(int i = 0; i < m; ++i) {
      auto idx = distance(v.begin(), max_element(v.begin(), v.end()));
      cout << idx + 1;
      cout << (i < m - 1 ? ' ' : '\n');
      v[idx] = 0;
    }
  }
  return 0;
}



Measured memory_bytes: 3452
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
namespace AtCoder.AGC015
{
    class A
    {
        static public void Main()
        {
            var nab = ReadLine().Trim().Split(' ').Select(i => long.Parse(i)).ToArray();
            var n = nab[0]; var a = nab[1]; var b = nab[2];
            if (IsValid(n, a, b)) WriteLine(Max(n, a, b) - Min(n, a, b) + 1);
            else WriteLine(0);
        }
        static bool IsValid(long n, long a, long b)
        {
            return (n == 1) ? (a == b) : (a <= b);
        }
        static long Max(long n, long a, long b)
        {
            return b * (n - 1) + a;
        }
        static long Min(long n, long a, long b)
        {
            return a * (n - 1) + b;
        }
    }
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
        using namespace std;
        #define ll long long int   
        # define pi 3.141592653589793238
     
     
     
          int main()
            {
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

             
            ios_base::sync_with_stdio(false);
     
              cin.tie(NULL);
     
     
  
ll n,i,ans=0,d,x,y;
cin>>n>>d;
for(i=0;i<n;i++)
{
cin>>x>>y;
if((ll)pow(x,2)+(ll)pow(y,2)<=(ll)pow(d,2))
ans++;
}
cout<<ans<<"\n";

return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim 1e5
using namespace std;

const lld mod=MAX;


lld n;
std::vector<lld> v(500);
lld dp[500+1][500+1];

lld qsum(lld l,lld r)
{
	lld sum=0;

	for(lld i=l;i<=r;i++)
		sum+=v[i];

	return sum;
}

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

	
	cin>>n;
	

	for(lld i=0;i<n;i++)
		cin>>v[i];

	

	for(lld l=n-1;l>=0;l--)
	{
		for(lld r=l;r<n;r++)
		{
			if(l==r)
				dp[l][r]=0;

			else
			{
				dp[l][r]=MAX;
				lld temp=qsum(l,r);
				for(lld k=l;k<r;k++)
				{
					dp[l][r]=min(dp[l][r],dp[l][k] + dp[k+1][r] + temp);
				}
			}
		}
	}

	cout<<dp[0][n-1]<<endl;
	
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
struct state { long long cx, cy; };
bool operator<(const state& s1, const state& s2) { return s1.cx < s2.cx; }
int N, sp, c1, c2, dl, dr; long long D, x[33], y[33], qx[14348915], qy[14348915]; state s1[14348915], s2[14348915];
void dfs1(int cur, long long cx, long long cy) {
	if (cur == sp) {
		if(cx < 0 || (cx == 0 && cy <= 0)) s1[c1++] = state{ cx, cy };
		return;
	}
	dfs1(cur + 1, cx, cy);
	dfs1(cur + 1, cx + x[cur], cy + y[cur]);
	dfs1(cur + 1, cx - x[cur], cy - y[cur]);
}
void dfs2(int cur, long long cx, long long cy) {
	if (cur == N) {
		if(cx < 0 || (cx == 0 && cy <= 0)) s2[c2++] = state{ cx, cy };
		return;
	}
	dfs2(cur + 1, cx, cy);
	dfs2(cur + 1, cx - x[cur], cy + y[cur]);
	dfs2(cur + 1, cx + x[cur], cy - y[cur]);
}
int main() {
	cin >> N >> D;
	for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
	sp = N / 2;
	dfs1(0, 0, 0);
	dfs2(sp, 0, 0);
	sort(s1, s1 + c1);
	sort(s2, s2 + c2);
	for (int i = 0; i < c1; i++) s1[c1 * 2 - i - 1] = state{ -s1[i].cx, -s1[i].cy }; c1 *= 2;
	for (int i = 0; i < c2; i++) s2[c2 * 2 - i - 1] = state{ -s2[i].cx, -s2[i].cy }; c2 *= 2;
	int l = 0, r = 0; long long ret = -1LL << 60;
	for (int i = 0; i < c1; i++) {
		while (r < c2 && s2[r].cx <= s1[i].cx + D) {
			while (dl != dr && s2[r].cy >= qy[dr - 1]) dr--;
			qx[dr] = r;
			qy[dr] = s2[r].cy;
			dr++;
			r++;
		}
		while (l < c2 && s2[l].cx < s1[i].cx - D) {
			if (qx[dl] == l) dl++;
			l++;
		}
		if (dl != dr) {
			ret = max(ret, qy[dl] + s1[i].cy);
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 495776
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<tuple>
#include<map>
#include<set>
#include<algorithm>
 
#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
struct edge{int from, to; ll cost;};
 
signed main(){
	int H, W;
	cin >> H >> W;
	vector<string> s(H);
	map<P, int> count;
	int sharp = 0;
	rep(H){
		cin >> s[i];
		repp(j, W){
			if(s[i][j] == '#'){
				sharp++;
				count[P(i,j)] = 1;
			}
		}
	}
	
	queue<P> que;
	que.push(P(0, 0));
	bool success = false;
	while(!que.empty()){
		P t = que.front();que.pop();
		int h = t.first, w = t.second;
		//cout << h << w << " " << count[P(h,w)] << endl;
		if(count[P(h, w)] == sharp){
			success = true;
			break;
		}
		if(w+1 < W && s[h][w+1] == '#'){
			count[P(h,w+1)] = count[P(h,w)] + 1;
			que.push(P(h, w+1));
		}
		if(h+1 < H && s[h+1][w] == '#'){
			count[P(h+1,w)] = count[P(h,w)] + 1;
			que.push(P(h+1, w));
		}
	}
	if(success){
		cout << "Possible";
	}else{
		cout << "Impossible";
	}
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

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

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   string s;
   cin >> s;
   for(int i=0;i<s.size()-8;i++){
      cout << s[i];
   }
   return 0;
}

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

using namespace std;

int main(){
        set <int> s;
        int N;
        cin>>N;
        for(int i=0;i<N;i++){
                int ss;
                cin>>ss;
                if(s.count(ss)==0){
                        s.insert(ss);
                }
                else{
                        s.erase(ss);
                }
        }
        cout<<s.size()<<endl;
        return 0;
}


Measured memory_bytes: 4864
// defines
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define casti static_cast<int>
#define cast static_cast
#define ll long long int
#define vi vector<int>
#define vpi vector<pair<int,int >>

// includes
#include <bits/stdc++.h>

using namespace std;

ll modF=1e9+7;

// topcoder


//codechef and codeforces

void solve1(){
    int x,y;
    cin>>x>>y;
    int h=4*x-y;
    if(h>=0 && h%2==0 && (h/2)<=x){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}

int main(){
    boost_io;
    solve1();
    return 0;
}


Measured memory_bytes: 3644
a,b=map(int,input().split())
a=input()
c=[0]*len(a)
for i in range(len(a)-1):
    if (a[i]+a[i+1])=="AC":c[i+1]=c[i]+1
    else:c[i+1]=c[i]
for i in range(b):
    d,e=map(int,input().split())
    print(c[e-1]-c[d-1])

Measured memory_bytes: 6188
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  ll n,k;
  cin >> n >> k;
  ll arr[n];
  ll size = 200000+10;
  ll cnt[size];
  for(ll i=0;i<size;i++){
    cnt[i]=0;
  }
  ll distinct = 0;
  for(ll i=0;i<n;i++){
    cin >> arr[i];
    if(!cnt[arr[i]])
      distinct++;
    cnt[arr[i]]+=1;
  }
  if(distinct<=k)
    cout << "0" << endl;
  else{
    std::vector<ll> v;
    for(ll i=1;i<=size;i++){
      if(cnt[i]!=0)
        v.push_back(cnt[i]);
    }
    sort(v.begin(),v.end());
    ll ans = 0;
    ll num  =abs(k-distinct);
    for(ll i=0;i<num;i++){
      ans+=v[i];
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
int main(){
    ll N,M;
    cin>>N>>M;
    vl H(N);
    rep(i,N) cin>>H.at(i);
    vector<bool> check(N,true);
    rep(i,M){
        ll a;
        ll b;
        cin>>a>>b;
        if(H.at(a-1)>H.at(b-1)){
            check.at(b-1)=false;
        }else if(H.at(b-1)>H.at(a-1)){
            check.at(a-1)=false;
        }else{
            check.at(a-1)=false;
            check.at(b-1)=false;
        }
    }
    ll count=0;
    rep(i,N){
        if(check.at(i)){
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
double pi=3.1415926535897932384626433;
int main()
{
    IO
    ll r;
    cin>>r;
    double ans=((2.0)*pi)*r;
    printf("%.8lf",ans);
    return 0;
}

Measured memory_bytes: 3792
#include<cstdio>
using namespace std;

int main(){
  bool g[1000][1000];
  int p[2][1000],i,j,h,w,n,t;
  while(scanf("%d%d%d",&h,&w,&n) && (h||w||n)){
    for(i=0;i<h;i++)
      for(j=0;j<w;j++){
	scanf("%d",&t);
	g[i][j]=t?1:0;
	p[i&1][j]=0;
      }

    p[0][0] = n-1;
    for(i=0;i<h;i++)
      for(j=0;j<w;j++){
	t=i&1;
	n=p[t][j];
	p[1-t][j]+=n/2;
	p[t][j+1]+=n/2;
	if(n&1){
	  g[i][j]?p[t][j+1]++:p[1-t][j]++;
	  g[i][j]=!g[i][j];
	}
	p[t][j]=0;
      }

    i=j=0;
    while(i<h && j<w)g[i][j]?j++:i++;
    printf("%d %d\n",i+1,j+1);
  }
}

Measured memory_bytes: 1748
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <random>
#include <unordered_map>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

int main(){
    ll n,m;
//    string s;
    cin >> n>>m;
//    vector<ll> vl;
//    vector<string> vs;
//    rep(i, n) cin >>;
    ll sum = 0;
    if (n==1 and m==1) {
        sum=1;
    }else if (n==1){
        sum = m-2;
    }else if(m==1){
        sum=n-2;
    }else {
        ll a = (m-2)*(n-2);
        ll b = 2*m+2*n-8;
        ll c =4;
        sum=a;
    }
    pr(sum);
    return 0;
}



Measured memory_bytes: 888
#include<stdio.h>
int main()
{
  char enki[1];
  
  scanf("%s", &enki[0]);
  
  if(enki[0]=='A')
    printf("T\n");
  else if(enki[0]=='T')
    printf("A\n");
  else if(enki[0]=='C')
    printf("G\n");
  else if(enki[0]=='G')
    printf("C\n");
  
  

  return 0;
}

Measured memory_bytes: 128
K, N = map(int, input().split())
A_array = list(map(int, input().split()))

distance_max = 0
for i in range(1, N):
    distance_max = max(distance_max, A_array[i]-A_array[i-1])
distance_max = max(distance_max, K-A_array[N-1]+A_array[0])

print(K-distance_max)


Measured memory_bytes: 77388
<?php
fscanf(STDIN, '%d %d %d', $N, $M, $C);
$Bs = explode(' ', trim(fgets(STDIN)));
$ans = 0;
for ($i=0; $i < $N; $i++) { 
    $line = explode(' ', trim(fgets(STDIN)));
    $exp = 0;
    foreach ($line as $key => $value) {
        $exp += $value * $Bs[$key];
    }
    $exp += $C;
    if ($exp > 0) {
        $ans++;
    }
}
echo $ans."\n";

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    ll n;
    cin >> n;

    ll t = n;
    ll i = 2;
    ll sum = 0;
    for(ll i = 2; i * i <= t and n > 1; i++) {
        ll m = 1;
        ll c = 0;
        while(n % i == 0) {
            c++;
            if(c == m) {
                c = 0;
                sum++;
                m++;
            }
            n /= i;
        }
    }

    cout << sum + (n > 1) << endl;

  
    return 0;
}



Measured memory_bytes: 3648
N = int(input())
H = list(map(int, input().split()))
count = 0
i = 0

while i < N-1:
  moving = 0
  for j in range(i, N-1):
    if H[j] >= H[j+1]:
      moving += 1
    else:
      i = j + 1
      break
      
    if moving > count:
      count = moving
      
    i += 1
      
print(count)

Measured memory_bytes: 15020
from math import sqrt
def crosscircle(c1, c2):
    (x1, y1, r1) = c1
    (x2, y2, r2) = c2
    if (x1-x2)**2 + (y1-y2)**2 > (r1+r2)**2:
        return ()
    elif x1 == x2 and y1 == y2:
        return ()
    elif (x1-x2)**2 + (y1-y2)**2 == (r1+r2)**2:
        x = (x1*r2+x2*r1)/(r1+r2)
        y = (y1*r2+y2*r1)/(r1+r2)
        return ((x, y),)
    elif y1 == y2:
        x = (r1**2-r2**2-x1**2+x2**2)/(2*(x2-x1))
        if y1**2-(y1**2-r1**2+(x-x1)**2) >= 0:
            yans1 = y1+sqrt(y1**2-(y1**2-r1**2+(x-x1)**2))
            yans2 = y1-sqrt(y1**2-(y1**2-r1**2+(x-x1)**2))
            return ((x, yans1), (x, yans2))
        else:
            return ()
    elif x1 == x2:
        y = (r1**2-r2**2-y1**2+y2**2)/(2*(y2-y1))
        if x1**2-(x1**2-r1**2+(y-y1)**2) >= 0:
            xans1 = x1+sqrt(x1**2-(x1**2-r1**2+(y-y1)**2))
            xans2 = x1-sqrt(x1**2-(x1**2-r1**2+(y-y1)**2))
            return ((xans1, y), (xans2, y))
        else:
            return ()
    else:
        A = ((x1-x2)/(y1-y2))**2 + 1
        B = (x1-x2)*(r1**2-r2**2-x1**2+x2**2+(y1-y2)**2)/(y1-y2)**2 - 2*x1
        C = ((r1**2-r2**2-x1**2+x2**2+(y1-y2)**2)/(2*(y1-y2)))**2 + x1**2 - r1**2
        if B**2 - 4*A*C >= 0:
            xans1 = (-B+sqrt(B**2-4*A*C))/(2*A)
            xans2 = (-B-sqrt(B**2-4*A*C))/(2*A)
            yans1 = -((r1**2-r2**2-x1**2+x2**2-y1**2+y2**2))/(2*(y1-y2))-xans1*(x1-x2)/(y1-y2)
            yans2 = -((r1**2-r2**2-x1**2+x2**2-y1**2+y2**2))/(2*(y1-y2))-xans2*(x1-x2)/(y1-y2)
            return ((xans1, yans1), (xans2, yans2))
        else:
            return ()

N, K = map(int, input().split())
li = [tuple(map(int, input().split())) for i in range(N)]
eps = 1e-6
U = 2e05
L = 0
while U - L > 1e-6:
    T = (U+L)/2
    points = []
    for i in range(N-1):
        for j in range(i+1, N):
            c1 = (li[i][0],li[i][1],T/li[i][2])
            c2 = (li[j][0],li[j][1],T/li[j][2])
            p = crosscircle(c1,c2)
            if p == ():
                continue
            for a in p:
                points.append(a)
    for i in range(N):
        points.append((li[i][0], li[i][1]))
    Max = 0
    for p in points:
        cnt = 0
        for i in range(N):
            x,y,r = li[i][0],li[i][1],T/li[i][2]
            if (p[0]-x)**2+(p[1]-y)**2<= (r+eps)**2:
                cnt += 1
        Max = max(Max, cnt)
    if Max < K:
        L = T
    else:
        U = T
print(T)

Measured memory_bytes: 61016
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h1: usize = iterator.next().unwrap().parse().unwrap();
    let m1: usize = iterator.next().unwrap().parse().unwrap();
    let h2: usize = iterator.next().unwrap().parse().unwrap();
    let m2: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();
    let ans = h2 * 60 + m2 - h1 * 60 - m1 - k;

    return ans.to_string();
}


Measured memory_bytes: 2136
a, b = list(map(int, input().split()))
 
s = 16
for i in range(16):
	if i%2 == 0:
		if a > 0:
			s -= 1
			a -= 1
	else:
		if b > 0:
			s -= 1
			b -= 1
	if s < 0:
		break
 
if a > 0 or b > 0:
	print(':(')
else:
	print('Yay!')

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

void solve(long long N, long long K, std::vector<long long> x){
    int sum = 0;
    REP(i, N)
        sum += min(K - x[i], x[i]) * 2;
    cout << sum << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> x(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
    }
    solve(N, K, std::move(x));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void Bubble();
void Select();
int isStable();
void printresult();

char C[36][2], out[36][2];
int n;

int main(){
  int i;

  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%s",&C[i][0]);

  Bubble();
  Select();

  return 0;
}

void Bubble(){
  int i, j;
  char temp;
  
  for(i = 0; i < n; i++){
    out[i][0] = C[i][0];
    out[i][1] = C[i][1];
  }
  
  for(i = 0; i < n; i++){
    for(j = n-1; j > i; j--){
      if(out[j][1] < out[j-1][1]){
	temp = out[j][0];
	out[j][0] = out[j-1][0];
	out[j-1][0] = temp;

	temp = out[j][1];
	out[j][1] = out[j-1][1];
	out[j-1][1] = temp;
      }
    }
  }

  printresult();
}

void Select(){
  int i, j, minj;
  char temp;

  for(i = 0; i < n; i++){
    out[i][0] = C[i][0];
    out[i][1] = C[i][1];
  }
  
  for(i = 0; i < n; i++){
    minj = i;
    for(j = i; j < n; j++){
      if(out[j][1] < out[minj][1]){
        minj = j;
      }
    }

    temp = out[i][0];
    out[i][0] = out[minj][0];
    out[minj][0] = temp;

    temp = out[i][1];
    out[i][1] = out[minj][1];
    out[minj][1] = temp;
  }

  printresult();
}
      

int isStable(){
  int i, j, a, b;
  
  for(i = 0; i < n; i++){
    for(j = i+1; j < n; j++){
      for(a = 0; a < n; a++){
	for(b = a+1; b < n; b++){
	  if(C[i][1] == C[j][1] &&
	     C[i][1] == out[b][1] && C[i][0] == out[b][0] &&
	     C[j][1] == out[a][1] && C[j][0] == out[a][0]) return 0;
	}
      }
    }
  }

  return 1;
}

void printresult(){
  int i;
  
  for(i = 0; i < n-1; i++){
    printf("%c%c ",out[i][0],out[i][1]);
  }
  printf("%c%c\n",out[i][0],out[i][1]);
  
  if(isStable() == 1) printf("Stable\n");
  else printf("Not stable\n");
}


Measured memory_bytes: 2048
#include <stdio.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int n, k;
int w[100002];
 
int check(int x)
{
    int i, f, s;
 
    f = 0, s = 0;
    for (i = 0; i < n; i++) {
        if (s + w[i] > x) {
            s = 0;
            if (++f >= k) break;
        }
        s += w[i];
    }
    return ++f <= k;
}
 
int main()
{
    int i, a, lo, hi, mi;
     
    n = in(), k = in();
    lo = 0, hi = 0;
    for (i = 0; i < n; i++) {
        w[i] = a = in();
        if (a > lo) lo = a;
        hi += a;
    }
    if (k == 1)    { printf("%d\n", hi); return 0; }
    if (check(lo)) { printf("%d\n", lo); return 0; }
    while (lo+1 < hi) {
        mi = (lo + hi) >> 1;
        if (check(mi)) hi = mi; else lo = mi;
    }
    printf("%d\n", hi);
    return 0;
}



Measured memory_bytes: 2212
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
#define LENGTH 100

int cnt=0;

void dfs(int sum, int s, int n, int i){
  if(sum==s && n==0){
    cnt++;
  }

  if(n<=0 || sum>s || i>9){
    return;
  }
  
  
  dfs(sum+i, s, n-1, i+1);
  dfs(sum, s, n, i+1);
}

int main(){
  int n;
  int s;
  while(cin >> n >> s){
    if(n==0 && s==0){
      break;
    }

    dfs(0, s, n, 0);
    cout << cnt << endl;
    cnt = 0;
  }
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vi a(n), b(n);
	REP(i, n)cin >> a[i];
	REP(i, n)cin >> b[i];
	int ans = 0;
	REP(i, n)ans += max(0, a[i] - b[i]);
	cout << ans << endl;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n;
    int ans = 0;
    cin >> n;
    vi v(n);
    vi c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    rep(i, n) {
        ans += max(0, v[i] - c[i]);
    }
    out(ans);
    return 0;
}


Measured memory_bytes: 256
S = input()
if len(S) % 2 == 1:
    S = S[-1]
for i in reversed(range(2, len(S) + 1, 2)):
    length = i
    fl = 0
    for j in range(i // 2):
        # print(S[j], S[j + length // 2])
        if S[j] != S[j + length // 2]:
            fl = 1
    if fl == 0 and length != len(S):
        print(length)
        exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  vector<ll> F(N);
  rep(i, N) cin >> F[i];
  sort(A.begin(), A.end());
  sort(F.rbegin(), F.rend());
  ll left = -1, right = 1e12;
  while (left+1 < right) {
    ll mid = (left + right) / 2;
    bool ok = [&]{
      ll sum = 0;
      rep(i, N) {
        sum += max(0ll, A[i] - mid/F[i]);
      }
      return sum <= K;
    }();
    if (ok) right = mid; else left = mid;
  }
  cout << right << '\n';
  return 0;
}

Measured memory_bytes: 6420
#include<cstring>
#include<set>
#include<cstdio>
#include<cstdlib>
using namespace std;

int par[1010], h[1010];

void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
    h[i] = 0;
  }
}

int find(int x){
  if(par[x] == x)return x;
  return par[x] = find(par[x]);
}

bool same(int a,int b){
  return find(a) == find(b);
}

void unite(int a, int b){
  a = find(a); b = find(b);
  if(same(a,b))return;

  if(h[a] < h[b])par[a] = b;
  else{
    par[b] = a;
    if(h[a] == h[b])h[a]++;
  }
}

const int N = 1001;

int main(){
  int v,d,f[1010];
  f[0] = f[1] = 1;
  for(int i=0;i<N;i++)f[i+2] = (f[i] + f[i+1]) % N;

  while(scanf("%d%d",&v,&d)!=EOF){
    init(v);
    for(int i=0;i<v;i++){
      for(int j=i+1;j<v;j++){
	if( abs(f[i+2]-f[j+2]) < d )unite(i,j);
      }
    }

    set<int> s;
    for(int i=0;i<v;i++)s.insert(find(i));
    printf("%d\n",s.size());
  }
}

Measured memory_bytes: 1048
n = int(input())
s = str(input())
c1 = [False for _ in range(10)]
c2 = [0 for _ in range(1000)]
count = 0
for i in range(n-2):
  si = int(s[i])
  if c1[si] != True:
    c1[si] = True
    c3 = [False for _ in range(10)]
    for j in range(i+1,n-1):
      sj = int(s[j])
      if c3[sj] != True:
        c3[sj] = True
        c4 = [False for _ in range(10)]
        for k in range(j+1,n):
          sk = int(s[k])
          if c4[sk] != True:
            c4[sk] = True
            count += 1
print(count)

Measured memory_bytes: 42204
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
using namespace std;
long long inf=100000000000007;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int to,cost;};
vector<edge> G[22];
vector<int> O[10];
P sg[10];
int d[1005][1005]={};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
pair<int,double> s[1005];
int c=0;
int fi[1005][1005];
int ans[1005][1005]={};
bool graph[55][55];
bool visited[55];
int a[55],b[55];

signed main(){
    string s;cin>>s;
    int al[2][26]={};
    for(int i=0; i<s.length();i++){
        rep(j,26){
            if(s[i]==alph[j])al[0][j]++;
        }
    }string rs={};
    rep(i,26){
        while(al[0][i]>0){
            rs+=alph[i];
            al[0][i]--;
        }
    }
    string t;cin>>t;
    for(int i=0; i<t.length();i++){
        rep(j,26){
            if(t[i]==alph[j])al[1][j]++;
        }
    }string rt={};
    for(int i=25;i>=0;i--){
         while(al[1][i]>0){
            rt+=alph[i];
            al[1][i]--;
        }
    }
    if(rs<rt)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;



int main(){
	ll h; cin>>h;
	ll pow2=1ll;
	while(pow2<=h) pow2*=2;
	pow2/=2;
	cout<<2*pow2-1;
	
	return 0;
}


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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<": ";REP(i,v.size())cout<<" "<<v[i];cout<<endl

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))


//====


class UnionFind
{
private:
	Vi par;
	Vl sizes;
public:
	UnionFind(int N) : par(N), sizes(N, 1) {
		REP(i, N) par[i] = i;
	}

	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (sizes[x] < sizes[y]) swap(x, y);
		par[y] = x;
		sizes[x] += sizes[y];
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	lli size(int x) {
		return sizes[find(x)];
	}
};

int main()
{
	lli N, M;
	cin >> N >> M;
	Vi A(M), B(M);
	REP(i, M) {
		cin >> A[i] >> B[i];
		--A[i], --B[i];
	}
	
	Vl ans(M);
	ans[M - 1] = N * (N - 1) / 2;

	UnionFind uf(N);

	FORR(i, 0, M - 1) {
		if (uf.same(A[i + 1], B[i + 1])) {
			ans[i] = ans[i + 1];
			continue;
		}
		ans[i] = ans[i + 1] - uf.size(A[i + 1]) * uf.size(B[i + 1]);
		uf.unite(A[i + 1], B[i + 1]);
	}

	REP(i, M) {
		cout << ans[i] << endl;
	}
}



Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
//#define vi vector<int>
#define vb vector<bool>
#define pii pair<int, int>
#define mii map<int, int>
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define inf (long long)1e18
#define F first
#define S second
#define SZ(x) ((int)(x).size())
//#define rep(i,n)  for(int i=0;i<n;i++)
//#define repd(i,n) for(int i=n-1;i>=0;i--)
//#define rep1(i,n) for(int i=1;i<=n;i++)
const int N = 1e9 + 7;

int pow(int x, int y)
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = ((res) * (x));
        res %= N;
        y = y >> 1;
        x = ((x) * (x));
    }
    return res;
}
int powm(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

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

void solve()
{
    string s;
    cin >> s;
    int mx = 0;
    int cnt = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'R')
        {
            cnt++;
        }
        else
        {
            mx = max(cnt, mx);
            cnt = 0;
        }
    }
    mx = max(cnt, mx);
    cout << mx << "\n";
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin >> t;
    // while (t--)
    // {
     solve();
    // }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
const bool debug = 0;
//---------------------------------//

int A, B, C, D;
int imos[300];

int main() {
	cin >> A >> B >> C >> D;
	
	imos[A]++;
	imos[B]--;
	
	imos[C]++;
	imos[D]--;
	
	FOR(i, 1, 300) imos[i] += imos[i - 1];
	
	int ans = 0;
	REP(i, 300) if (imos[i] == 2) ans++;
	cout << ans << endl;
	
	return 0;
}

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

int main(){

 int j,N,flag,a,i=0;
 int *A;


  scanf("%d",&N);
  A = (int *)malloc(N * sizeof(int));
  for(j=0;j<N;j++)
  scanf(" %d",&A[j]);
  
  flag = 1;
 
  while(flag == 1){
      flag = 0;
      for(j=N-1;j>=0;j--){
	
	  if(A[j] < A[j-1]){
	  a = A[j];
	  A[j] = A[j-1];
	  A[j-1] = a;
          flag = 1;
          i++;
          }
         
       }
  }
  for(j=0;j<N;j++){
        printf("%d",A[j]);
        if(j != N-1) printf(" ");
        }
  printf("\n%d\n",i);

  return 0;
}



Measured memory_bytes: 2052
#include<iostream>
#include<map>
#include<vector>

using namespace std;

typedef long long ll;

struct cum_sum_lm {
	vector<int> sum;
	int N;
	cum_sum_lm() = default;
	cum_sum_lm(int _N) {
		N = _N;
		sum.resize(N + 1);
	}

	void setup(vector<int>& _ar) {
		sum.resize(_ar.size() + 1);
		for (int i = 0; i < N; i++) {
			sum[i + 1] = sum[i] + _ar[i];
		}
	}
	ll getval(int l, int r) {
		//[l, r)
		ll ret = sum[r] - sum[l];
		return ret;
	}
};

int N;
vector<int> A(300000 + 10);
vector<int> B(300000 + 10);
cum_sum_lm sum(300000 + 10);

int main() {
	cin >> N;
	ll X = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A[a]++;
		B[A[a]]++;
	}

	X = N;
	ll s = X;
	sum.setup(B);
	
	for (int i = 1; i <= N; i++) {
		ll l = 0, u = N + 1;
		while (u - l > 1) {
			long long x = (u + l) / 2;
			if (sum.getval(0, x + 1) >= i * x) l = x;
			else u = x;
		}
		cout << l << endl;
	}

	return 0;
}


Measured memory_bytes: 4352
module Main where

import Control.Applicative
import Control.Monad
import Data.List (unfoldr)

dsum :: Int -> Int
dsum n = sum $ unfoldr f n
  where
    f 0 = Nothing
    f x = let (q, r) = x `divMod` 10 in Just (r, q)

main :: IO ()
main = do
    n <- readLn :: IO Int
    if n `mod` (dsum n) == 0
        then putStrLn "Yes"
        else putStrLn "No"

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
int cnt[50][26],min_cnt[26];
int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++) {
		string S;
		cin>>S;
		for(int j=0;j<S.size();j++) {
			cnt[i][S[j]-'a']++;
		}
	}
	string ans="";
	for(int i=0;i<26;i++) {
		min_cnt[i]=1<<30;
		for(int j=0;j<n;j++) {
			min_cnt[i]=min(min_cnt[i],cnt[j][i]);
		}
		ans+=string(min_cnt[i],'a'+i);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256