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

using namespace std;

int CountFactors(int num, int factor)
{
    auto count = 0;
    while (num > 0 && num % factor == 0) {
        count += 1;
        num /= factor;
    }
    return count;
}

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

    auto operations = 0;
    for (auto i = 0; i < n; i += 1) {
        int num;
        cin >> num;

        operations += CountFactors(num, 2);
    }

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


Measured memory_bytes: 256
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   vector<int> a(n);
   f(i,0,n) cin >> a[i];
   sort(all(a));
   reverse(all(a));
   int ans = a.front();
   multiset<array<int,3>> s;
   s.insert({min(a[0],a[1]),a[0],a[1]});
   s.insert({min(a[0],a[1]),a[0],a[1]});
   f(i,2,n){
      auto mx = *s.rbegin();
      ans += mx[0];
      s.erase(s.find(mx));
      array<int,3> ff = {min(mx[1],a[i]),mx[1],a[i]};
      array<int,3> ss = {min(mx[2],a[i]),mx[2],a[i]};
      s.insert(ff);
      s.insert(ss);
   }
   cout << ans << '\n';
   return 0;
}


Measured memory_bytes: 17192
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String args[]) {
		new Main().run();
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		while(true) {
			final int N = sc.nextInt();
			if(N == 0) break;
			
			boolean[][] field = new boolean[21][21];
			for(int y = 0; y <= 20; y++)
				for(int x = 0; x <= 20; x++)
					field[y][x] = false;
		
			for(int i = 0; i < N; i++) {
				final int x = sc.nextInt();
				final int y = sc.nextInt();
				field[y][x] = true;
			}
			
			final int M = sc.nextInt();
			
			final int[] dx = {0, 1, 0, -1};
			final int[] dy = {1, 0, -1, 0};
			
			int curX = 10;
			int curY = 10;

			for(int i = 0; i < M; i++) {
				char dc = sc.next().charAt(0);
				int l = sc.nextInt();
				
				int d = "NESW".indexOf(dc);

				for(int j = 0; j < l; j++) {
					curX += dx[d];
					curY += dy[d];
					field[curY][curX] = false;
				}
			}
			
			boolean ok = true;

			for(int y = 0; y <= 20; y++)
				for(int x = 0; x <= 20; x++)
					if(field[y][x] == true)
						ok = false;

			System.out.println(ok ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <vector>
#include <utility>
#include <queue>
#include <bitset>
using namespace std;
typedef pair<int,long long int> pi;
typedef pair<long long int,pi> plpi;
#define F first
#define S second
#define PB push_back
const int N=1e5+10;
const long long int INF=1LL<<60;
int main(){
    int n,m,l,r;
    long long int ans=INF,dis[N],d,h[N],x;
    bitset<N>went;
    queue<plpi>q;
    priority_queue<plpi,vector<plpi>,greater<plpi>>pq;
    plpi nxt;
    vector<pi> graph[N];
    scanf("%d%d%lld",&n,&m,&x);
    for(int i=1;i<=n;i++){
        scanf("%lld",&h[i]);
        dis[i]=INF;
    }
    while(m--){
        scanf("%d%d%lld",&l,&r,&d);
        if(h[l]-d>=0)graph[l].PB({r,d});
        if(h[r]-d>=0)graph[r].PB({l,d});
    }
    went.reset();
    pq.push({0LL,{1,x}});
    while(!pq.empty()){
        nxt=pq.top();
        pq.pop();
        if(nxt.F>=ans)continue;
        if(nxt.S.F==n){
            ans=min(ans,nxt.F+h[n]-nxt.S.S);
            break;
        }
        else if(nxt.S.S==0){
            if(!went[nxt.S.F]&&dis[nxt.S.F]>=nxt.F){
                went[nxt.S.F]=true;
                for(pi i:graph[nxt.S.F])if(nxt.F+i.S*2<dis[i.F]){
                    dis[i.F]=nxt.F+i.S*2;
                    pq.push({nxt.F+i.S*2,{i.F,0}});
                }
            }
        }
        else if(!went[nxt.S.F]){
            went[nxt.S.F]=true;
            for(pi i:graph[nxt.S.F]){
                if(nxt.S.S-i.S<0){
                    if(dis[i.F]>nxt.F-nxt.S.S+i.S*2){
                        dis[i.F]=nxt.F-nxt.S.S+i.S*2;
                        pq.push({nxt.F-nxt.S.S+i.S*2,{i.F,0}});
                    }
                }
                else if(nxt.S.S-i.S>h[i.F]){
                    if(dis[i.F]>nxt.F+nxt.S.S-h[i.F]*2){
                        dis[i.F]=min(dis[i.F],nxt.F+nxt.S.S);
                        pq.push({nxt.F+nxt.S.S-h[i.F],{i.F,h[i.F]}});
                    }
                }
                else {
                    if(dis[i.F]>nxt.F+i.S*2-nxt.S.S){
                        dis[i.F]=min(dis[i.F],nxt.S.S+nxt.F);
                        pq.push({nxt.F+i.S,{i.F,nxt.S.S-i.S}});
                    }
                }
            }
        }
    }
    if(ans==INF)printf("-1\n");
    else printf("%lld\n",ans);
}


Measured memory_bytes: 26232
#include <bits/stdc++.h>
typedef long long       ll;
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define mt                make_tuple
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define fore(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define forr(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define deb(x)			  cerr << "# " << (#x) << " = " << (x) << endl;
#define sz(x)             (int)x.size()
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int INF = 1234567890;

ll MOD = 1e9 + 7;

ll modPow(ll b, ll e) {
    ll res = 1;
    while (e > 0) {
        if (e&1) res = b * res % MOD;
        e >>= 1;
        b = b * b % MOD;
    }
    return res;
}

const int tam = 1e6 + 10;

ll fact[tam], inv[tam];
ll nCk(int n, int k) {
    return (fact[n] * inv[k] % MOD) * inv[n-k] % MOD;
}

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    fact[0] = inv[0] = 1;
    fore(i, 1, tam) {
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = modPow(fact[i], MOD-2);
    }
    ll n;
    cin >> n;
    ll res = 0;
    //cout << "nck 2 2 = " << nCk(n, 2) << endl;
    fore(i, 2, n+1) {
        ll add = (modPow(2, i) - 2 + MOD) % MOD;
        //cout << "add " << add << endl;
        add = add * nCk(n, i) % MOD;
        //cout << "add " << add << endl;
        add = add * modPow(8, n-i) % MOD;
        //cout << "add " << add << endl;
        res = (res + add) % MOD;
    }
    cout << res << '\n';
    /*
    ll res = modPow(10, n);
    res = (res - modPow(9, n) + MOD) % MOD;
    res = (res - modPow(9, n) + MOD) % MOD;
    res = (res + modPow(8, n)) % MOD;
    cout << res << '\n';
    */
    return 0;
}
// Dinosaurs are cool!

Measured memory_bytes: 19272
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

    ll n,m;
    cin>>n>>m;
    ll ac[n+1]={0};
    ll wa[n+1]={0};
    for(ll i=0;i<m;++i)
    {
        ll a;
        string s;
        cin>>a>>s;
        if(s=="AC"){
            ac[a]=1;
        }
        else{
            if(ac[a]==0){++wa[a];}
        }
    }
    ll a=0,b=0;
    for(ll i=1;i<=n;++i)
    {
        a+=ac[i];
        if(ac[i])
        {b+=wa[i];}
    }
    cout<<a<<" "<<b;

    return (0);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

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;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vl v(n);
	rep(i,n)cin>>v[i];
	priority_queue<ll> q;
	rep(i,n)q.push(v[i]);
	while(m--){
		ll t=q.top();q.pop();
		t/=2;
		q.push(t);
	}
	ll ans=0;
	while(!q.empty()){
		ll t=q.top();q.pop();
		ans+=t;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2168
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

const int mod = 1e9 + 7;

struct Point {
  int x, y;
  int ind;
};

struct Edge {
  int a, b;
  int cost;
  bool operator>(const Edge &rhs) const {
    return cost > rhs.cost;
  }
};

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main() {
  int N;
  cin >> N;
  vector<Point> P(N), PX, PY;
  for (int i = 0; i < N; i++) {
    int x, y; cin >> x >> y;
    P[i] = (Point){x, y, i};
  }
  PX = PY = P;
  sort(PX.begin(), PX.end(), [](Point a, Point b){return a.x < b.x;});
  sort(PY.begin(), PY.end(), [](Point a, Point b){return a.y < b.y;});

  priority_queue<Edge, vector<Edge>, greater<Edge>> Q;
  for (int i = 0; i < N - 1; i++) {
    Q.push((Edge){PX[i].ind, PX[i + 1].ind, PX[i + 1].x - PX[i].x});
    Q.push((Edge){PY[i].ind, PY[i + 1].ind, PY[i + 1].y - PY[i].y});
  }

  UnionFind uf(N);
  ll ans = 0;
  while(!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (uf.findSet(e.a, e.b)) continue;
    uf.unionSet(e.a, e.b);
    ans += e.cost;
  }

  cout << ans << endl;

  return 0;
}

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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

int main() {
	li a[3];
	li prev[3];
	rep(i,3){
		cin>>a[i];
		prev[i]=a[i];
	}
	sort(prev,prev+3);

	li res=0;
	while(true){
		//dump(prev,3);
		bool term=false;
		rep(i,3){
			if(prev[i]%2>0){
				term=true;
				break;
			}
		}
		if(term)break;
		li tmp[3];
		rep(i,3){
			tmp[i]=prev[i]/2+prev[(i+1)%3]/2;
		}
		sort(tmp,tmp+3);
		++res;

		bool eq=true;
		rep(i,3){
			if(a[i]!=tmp[i]){
				eq=false;
				break;
			}
		}
		if(eq){
			res=-1;
			break;
		}
		rep(i,3){
			prev[i]=tmp[i];
		}
	}
	cout<<res<<endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b)    for (int i = a; i <= (int) b; ++i)
#define ii              pair <int, int>
using namespace std;
const int N = 1503;
int n, m;
vector <ii> adj[N];

void init() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

priority_queue <ii, vector <ii>, greater <ii> > Q;
int d[N][N], Max;
void dijk(int st) {
    d[st][st] = 0; Q.push({ 0, st });
    while (Q.size()) {
        int u = Q.top().second, du = Q.top().first;
        Q.pop();
        if (du != d[st][u]) continue;
        Max = max(Max, du);
        for (ii it : adj[u]) {
            int v = it.second, w = it.first;
            if (d[st][v] > du + w) d[st][v] = du + w, Q.push({ d[st][v], v });
        }
    }
}

queue <int> dm;
int vis[N];
void trace(int st) {
    FOR(i, 1, n) if (d[st][i] == Max) dm.push(i), vis[i] = st;
    while (dm.size()) {
        int u = dm.front(); dm.pop();
        for (ii it : adj[u]) {
            int v = it.second, w = it.first;
            if (d[st][u] == d[st][v] + w && vis[v] < st) vis[v] = st, dm.push(v);
        }
    }
}

void solve() {
    cin >> n >> m;
    FOR(i, 1, m) {
        int u, v, w;
        cin >> u >> v >> w;
        adj[u].push_back({ w, v }), adj[v].push_back({ w, u });
    }

    memset(d, 0x3f, sizeof d);
    FOR(i, 1, n) dijk(i);

    FOR(i, 1, n) trace(i);
    int dem = 0;
    FOR(i, 1, n) if (vis[i] == 0) ++dem;
    cout << dem << '\n';
    FOR(i, 1, n) if (vis[i] == 0) cout << i << '\n';
}

main() {
    init(); solve();
}




Measured memory_bytes: 12192
// Contest: AtCoder Beginner Contest 151 (https://atcoder.jp/contests/abc151)
// Problem: D: Maze Master (https://atcoder.jp/contests/abc151/tasks/abc151_d)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cpp_lib_nonmember_container_access >= 201411
#   define sz(x) ((int)size(x))
#else
#   define sz(x) ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define all(a)         (a).begin(),(a).end()
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __has_cpp_attribute(maybe_unused) >= 201603
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18;
//endregion }}}


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

    int h, w; cin >> h >> w;
    vector<string> g(h);
    trav(r, g) cin >> r;

    auto val = [&](int x, int y) { return 0 <= x && x < w && 0 <= y && y < h && g[y][x] == '.'; };
    int mx = 0;
    rep(xi, w) rep(yi, h) {
        if (!val(xi, yi)) continue;
        vvi d = vvi(w, vi(h, -1));
        d[xi][yi] = 0;
        queue<pi> q;
        q.emplace(xi, yi);
        while (sz(q)) {
            int x, y;
            tie(x, y) = q.front(); q.pop();
            for (auto off : {make_pair(-1,0), make_pair(1,0), make_pair(0,1), make_pair(0,-1)}) {
                int dx, dy; tie(dx, dy) = off;
                if (val(x+dx, y+dy) && d[x+dx][y+dy] == -1) {
                    d[x+dx][y+dy] = d[x][y] + 1;
                    q.emplace(x+dx,y+dy);
                }
            }
        }
        rep(x2, w) rep(y2, h)
            mx = max(mx, d[x2][y2]);
    }

    cout << mx << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define INF 500000
#define df 0

int main(){
  int n,m; cin >> n >> m;
  vector<vector<int>> adj(n,vector<int>(n,0));
  vector<vector<int>> sp(n,vector<int>(n,INF));
  for(int i=0;i<m;i++){
    int a,b,c; cin >> a >> b >> c;
    a--;b--;
    adj.at(a).at(b)=c;
    sp.at(a).at(b)=c;
    sp.at(b).at(a)=c;
  }
  for(int v=0;v<n;v++){
    for(int i=0;i<n;i++){
      if(i==v)continue;
      for(int j=0;j<n;j++){
	if(j==v)continue;
	int& w=sp.at(i).at(j);
	w=min(w,sp.at(i).at(v)+sp.at(v).at(j));
      }
    }
  }
  if(df){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	printf("%2d ",(sp[i][j]==INF?-1:sp[i][j]));
      }
      printf("\n");
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(adj.at(i).at(j)==0)continue;
      if(adj.at(i).at(j)!=sp.at(i).at(j))ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int k,s,ans;
int main(){
    cin>>k>>s;
    for(int i=0;i<=k;i++)
        for(int j=0;j<=k;j++)
            if(s-i-j>=0&&s-i-j<=k) ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cout << ", "; cetak(v...);}
 
#define debug(x...) cout << '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())


const int MOD = 1e9 + 7;

int add(int x, int y){
    int ret = x + y;
    if(ret >= MOD) ret -= MOD;
    return ret;
}
int sub(int x, int y){
    int ret = x - y;
    if(ret < 0) ret += MOD;
    return ret;
}
int mul(int x, int y){
    return (long long)x * y % MOD;
}


const int mx = 1e5 + 10;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n, a, b;
    cin >> n >> a >> b;
    if(a % 2 == b % 2){
        cout << abs(a - b) / 2 << endl;
        return 0;
    }
    long long ans;
    if(a > b) swap(a, b);
    {
        auto A = a;
        auto B = b;
        long long sem = 0;
        sem += A - 1;
        B -= A - 1;
        A -= A - 1;
        B -= 1;
        sem += 1;
        ans = sem + abs(A - B) / 2;
    }
    {
        auto A = a;
        auto B = b;
        long long sem = 0;
        sem += n - B;
        A += n - B;
        B += n - B;
        sem += 1;
        A += 1;
        ans = min(ans, sem + abs(A - B) / 2);
    }
    cout << ans << endl;
}

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

int w, h, n; 
int dp[20][20];// x y
bool memo[20][20];// x y
int main(void){
	while(1){
		rep(i, 20)rep(j, 20){//?????????
			dp[i][j] = 0;
			memo[i][j] = false;
		}

		cin >> w >> h;
		if(w == 0 && h == 0) return 0;
		cin >> n;
		rep(i, n){
			int x, y; cin >> x >> y;
			x--; y--;
			memo[x][y] = true;//??\???
		}
		dp[0][0] = 1;// x = 0, y = 0???????????????????????§????????????????????°
		for (int x = 0; x < w; ++x){
			for (int y = 0; y < h; ++y){
				if(memo[x][y]) continue;
				//?????????dp
				if(0 <= x - 1 && x - 1 < w){
					dp[x][y] += dp[x - 1][y];
				}
				if(0 <= h - 1 && h - 1 < h){
					dp[x][y] += dp[x][y - 1];
				}
			}
		}
		cout << dp[w - 1][h - 1] << endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
int main ()
{  long long  n,k; scanf("%lld %lld",&n,&k);
   if(n<k)
   {  long long  x=k-n,y=n;
      if(y>x) printf("%lld",x);
      else  printf("%lld",y);
   }
   else
   {    long long  x=n%k,y=k-n%k;
       if(y>x) printf("%lld",x);
      else  printf("%lld",y);
   }
}

Measured memory_bytes: 128
import itertools 

import sys
input = sys.stdin.readline
count=0
while True:
    N,X=map(int,input().split())
    if N==0 and X==0:
        
        exit()
    else:
        count=0
        T=[]
        for i in range(N):
            T.append(i+1)


        D=list(itertools.combinations(T,3))
        for Z in D:
            if Z[0]+Z[1]+Z[2]==X:
                count+=1
        print(count)

    



Measured memory_bytes: 31428
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int n, m;
	cin >> n;
	vector<int> t(n);
	for (int a = 0; a < n; a++) {
		cin >> t[a];
	}
	cin >> m;
	for (int a = 0; a < m; a++) {
		int p, x;
		cin >> p >> x;
		cout << accumulate(t.begin(), t.end(), 0) + x - t[p-1] << endl;
	}
}

Measured memory_bytes: 256
#40 フィボナッチ数列 - Time Limit Exceeded

n = int(input())
a = 1
b = 1
c = []
c.append(a)     #リストcの最後にaの値を付加
c.append(b)     #リストcの最後にbの値を付加
       
for i in range(n):
        c.append(a+b)   #リストcの最後にa+bの値を付加
        d = b           
        b += a
        a = d
print(c[n])



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

int main() {
    int K, A, B;
    cin >> K >> A >> B;

    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, ll> P;
 
int n;
 
int main(){
	while(scanf("%d", &n),n){
		vector<P> vec;
		for(int i = 0; i < n; i++){
			int x; ll p, q;
			scanf("%d%lld%lld", &x, &p, &q);
			bool ok = true;
			for(int j = 0; j < vec.size(); j++){
				if(vec[j].first == x){
					vec[j].second += p*q;
					ok = false;
					break;
				}
			}
			if(ok) vec.push_back(P(x,p*q));
		}
		bool ok = true;
		for(int i = 0; i < vec.size(); i++){
			if(vec[i].second >= 1000000){
				ok = false;
				printf("%d\n", vec[i].first);
			}
		}
		if(ok) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 1076
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);

using UINT64 = unsigned long long;

#define NMAX 1010


int main(void){
    IOS
    int n,k;
    cin >> n >> k;
    vector<UINT64> a;

    for(int i = 0; i < n; i++) {
        int j;
        cin >> j;
        a.emplace_back(j);
    }

    vector<UINT64> v;
    for(int i = 1;i <= n;i++){
        for(int j = 0;j <= n-i;j++){
            UINT64 sum = accumulate(a.begin()+j, a.begin()+j+i,0ULL);
            v.emplace_back(sum);
        }

    }
    //for(auto itr = v.begin();itr != v.end(); itr++) cerr << *itr << endl;
    sort(v.rbegin(),v.rend());

    UINT64 ans = 0;

    for(int m = 40; m >= 0; m--){
        UINT64 t2 = 1ULL << m;
        int cnt = 0;
        int vs = v.size();
        for(int s = 0; s < vs ; s++){
            if (((ans + t2) & v[s]) == (ans + t2)) {
                cnt++;
                if (cnt == k){
                    ans += t2;
                    break;
                }
            }
        }
    }

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



Measured memory_bytes: 6512
//*******Abhijit Burman***********// 
//Jalpaiguri Government Engineering College/ 

#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back 
#define mk make_pair 
#define MAXX (1000000000000000000+7)
#define mod 1000000007
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL) 

// ll powermod(ll base, ll exp, ll mod) 
// {
// 	ll result = 1;
// 	while (exp != 0) 
// 	{
// 		if ((exp % 2) == 1) 
// 		{
// 			result = (result * base) % mod;
// 		}
// 		base = (base * base) % mod;
// 		exp /= 2;
// 	}
// 	return result;
// }
map<ll,ll> visited;
// void bfs( vector<ll> adj[], ll node)
// {
//     map<ll,ll> mp;
//     queue<ll> q;
    
//     //strating node
//     q.push(node);
//     mp[node]=1;
//     while(!q.empty())
//     {
//         ll temp = q.front();
//         q.pop();
//         for(int i=0;i<adj[temp].size();i++)
//         {
//             if(mp[adj[temp][i]]==0)
//             {
//                 q.push(adj[temp][i]);
//                 mp[adj[temp][i]]=1;
//             }
//         }
//         cout<<temp<<" ";
        
//     }
//     cout<<endl;
// }
// void dfs(vector<ll> adj[],ll node)
// {
// 
//     visited[node] = 1;
//     for(int i=0;i<adj[node].size();i++)
//     {
//         if(visited[adj[node][i]]==0)
//         {
//             dfs(adj,adj[node][i]);
//         }
//     }
// }

ll firstDivisior(ll n){
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return i;
        }
    }
    return n;
    
}
bool isPallindrom(string s){
    ll i=0,j=s.size()-1;
    while(i<=j){
        if(s[i]==s[j]){
            i++;
            j--;
        }
        else{
            return false;
        }
    }
    return true;
}
void solve()
{
    ll a,b;
    cin>>a>>b;
    cout<<(a>b?"safe":"unsafe")<<endl;
}

int main()
{
    fio;
    int tt=1;
    // cin>>tt;
    while(tt--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <stdio.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int 
#define endl "\n" 

int32_t main()
{

    /* IOS 
     #ifndef ONLINE_JUDGE 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif*/
    string s; 
    cin >> s ;
    int len = s.size() ;
    int year = 1000*(s[0]-'0') + 100 * (s[1]-'0') + 10 * (s[2]-'0') + (s[3]-'0');
    int month = 10 * (s[5]-'0') + (s[6]-'0') ;
    int date =  10 *(s[8]-'0') + (s[9]-'0') ;
    if(year > 2019)
    {
       cout<<"TBD"<<endl;
    }
    else if( year == 2019 )
    {
         if(month > 4)
         {
           cout<<"TBD"<<endl;
         }
         else if( month == 4 )
         {
              if(date > 30 )
              {
                 cout<<"TBD"<<endl;
              }
              else cout<<"Heisei";
         }
         else 
         {
            cout<<"Heisei"<<endl;
         }
    }
    else cout<<"Heisei"<<endl;
    return 0 ;
}

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

using namespace std;

int grid[3][110];

int main (){
	int n;
	
	cin >> n;
	
	for(int i = 1 ; i <= 2 ; i++){
		for(int j = 1 ; j <= n ; j++){
			cin >> grid[i][j];
		}
	}
	
	for(int i = 1 ; i <= 2 ; i++){
		for(int j = 1 ; j <= n ; j++){
			grid[i][j] = max(grid[i - 1][j], grid[i][j - 1]) + grid[i][j];
		}
	}
	
	cout << grid[2][n] << '\n';
	
	return 0;
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int bfs(const vvvi& wall,pii src,pii dst)
{
	int h=wall.size(),w=wall[0].size();
	vvi dist(h,vi(w,INF));
	queue<tuple<int,int,int>> q;
	q.emplace(src.first,src.second,0);
	while(q.size()){
		int ci,cj,cd; tie(ci,cj,cd)=q.front(); q.pop();
		if(ci<0 || h<=ci || cj<0 || w<=cj || dist[ci][cj]!=INF) continue;
		dist[ci][cj]=cd;
		rep(k,4) if(!wall[ci][cj][k]){
			int ni=ci+"\xff\x1\0\0"[k],nj=cj+"\0\0\xff\x1"[k];
			q.emplace(ni,nj,cd+1);
		}
	}
	int res=dist[dst.first][dst.second];
	return res==INF?-1:res;
}

int main()
{
	for(int w,h,n;cin>>w>>h>>n && w|h|n;){
		vvvi wall(h,vvi(w,vi(4)));
		rep(i,h) rep(j,w) rep(k,4){
			int ni=i+"\xff\x1\0\0"[k],nj=j+"\0\0\xff\x1"[k];
			if(ni<0 || h<=ni || nj<0 || w<=nj) wall[i][j][k]=1;
		}
		rep(i,n){
			int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
			if(x1>x2) swap(x1,x2);
			if(y1>y2) swap(y1,y2);
			if(x1==x2)
				repi(y,y1,y2){
					//wall[y][x1][2]=wall[y][x1-1][3]=1;
					if(0<=x1 && x1<w  && 0<=y && y<h)
					wall[y][x1][2]=1;
					if(0<=x1-1 && x1-1<w  && 0<=y && y<h)
					wall[y][x1-1][3]=1;
				}
			else
				repi(x,x1,x2){
					//wall[y1][x][0]=wall[y1-1][x][1]=1;
					if(0<=x && x<w  && 0<=y1 && y1<h)
					wall[y1][x][0]=1;
					if(0<=x && x<w  && 0<=y1-1 && y1-1<h)
					wall[y1-1][x][1]=1;
				}
		}
		
		pii src,dst;
		cin>>src.second>>src.first>>dst.second>>dst.first;
		
		int d0=bfs(wall,src,dst),d1=0;
		rep(i,h) rep(j,w) rep(k,4) if(!wall[i][j][k]){
			wall[i][j][k]=1;
			d1=max(d1,bfs(wall,src,dst));
			wall[i][j][k]=0;
		}
		cout<<d1-d0<<endl;
	}
}

Measured memory_bytes: 1372
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



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

	ll all = 1;
	ll p2 = 2;
	
	for (int i = 0; i < 32;i++) {
		
		
		if (((n >> i) & 1) == 1) {
			all = (all * p2) % MOD_CONST;
		}
		p2 = (p2*p2) % MOD_CONST;
		
	}
	all--;
	
	
	vector<ll> inv_mod(b + 1);
	inv_mod[1] = 1;
	for (int i = 2; i <= b;i++) {
		inv_mod[i] = (MOD_CONST - (inv_mod[MOD_CONST%i] * (MOD_CONST / i)) % MOD_CONST) % MOD_CONST;
	}

	
	ll sum = all;
	ll com1 = 1;
	for (int i = 0;i < b;i++) {
		com1 = (com1 * (n - i)) % MOD_CONST;
		com1 = (com1 * inv_mod[i+1]) % MOD_CONST;
	}

	sum = (MOD_CONST + sum - com1) % MOD_CONST;
	ll com2 = 1;
	for (int i = 0;i < a;i++) {
		com2 = (com2 * (n - i)) % MOD_CONST;
		com2 = (com2 * inv_mod[i + 1]) % MOD_CONST;
	}

	sum = (MOD_CONST + sum - com2) % MOD_CONST;

	cout << sum << endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int max = 0;
  for(int i=1;i<n;++i){
    string x = s.substr(0,i), y = s.substr(i,n);
    map<char, int> mp;
    for(auto c:x){
      mp[c] = 1;
    }
    for(auto c:y){
      if(mp[c]==1) mp[c]++;
    }
    int cnt = 0;
    for(auto itr = mp.begin();itr != mp.end();++itr){
      if(itr->second == 2) cnt++;
    }
    if(max < cnt) max = cnt;
  }
  cout << max << endl;

  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:i32 = read();
    let k:i32 = read();

    println!("{}", if k==1 {0} else {n-k});

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  int cnt=0;
  int ans=0;
  if(n==1){
    cout << 0 << endl;
  }
  else{
  for(int i=1;i<n;i++){
    if(h[i-1]>=h[i]){
      cnt++;
    }
    else{
      ans=max(ans,cnt);
      cnt=0;
    }
  }
    ans=max(ans,cnt);
  cout << ans << endl;
  }
}

Measured memory_bytes: 640
n = int(input())
li_a = list()
for i in range(n):
    li_a.append(input().split())

s = input()
sum_t =0
for i in range(n):
    if li_a[i][0]==s:
        x = i+1
        break
for i in range(x,n):
    sum_t += int(li_a[i][1])
print(sum_t)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

const int MAX_DIGIT = 50;
ll dp[100][2];  //dp[上からi桁][smaller?]
ll N, K;
vector<ll> a;

int main() {
    cin >> N >> K; a.resize(N);
    for (int i = 0; i < N; i++) scanf("%Ld", &a[i]);

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    for (int d = 0; d < MAX_DIGIT; d++) {
        ll mask = 1ll<<(MAX_DIGIT - d - 1);

        ll num = 0;
        for (int i = 0; i < N; i++) if (a[i] & mask) ++num;

        ll cost0 = mask * num;
        ll cost1 = mask * (N - num);

        // smaller -> smaller
        if (dp[d][1] != -1) {
            chmax(dp[d+1][1], dp[d][1] + max(cost0, cost1)); //どっちも使える
        }

        //exact -> smaller
        if (dp[d][0] != -1) {
            if (K & mask) chmax(dp[d+1][1], dp[d][0] + cost0);
        }

        //exact -> exact Kと完全に一致
        if (dp[d][0] != -1) {
            if (K & mask) chmax(dp[d+1][0], dp[d][0] + cost1);
            else chmax(dp[d+1][0], dp[d][0] + cost0);
        }
    }

    cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]) << endl;

}

Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
    }
    let values = vec![a + b, a - b, a * b];
    println!("{}", values.iter().max().unwrap());
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
typedef long long LL;
int f(int x)
{
    for(LL n = 1; n <= x; n++)
        if(n*(n+1)/2 >= x)
            return n;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int x; cin >> x;
    cout<<f(x)<<endl;

    cout<<flush;
    return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;

/**
 * @author Tran Anh Tai
 * @template for CP codes
 */
public class Main{
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        public void solve(InputReader in, PrintWriter out) {
            int x = in.nextInt();
            int y = in.nextInt();
            if (y % 2 == 1 || y / 2 < x || y / 2 > 2 * x){
                out.println("No");
            }
            else{
                out.println("Yes");
            }
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}

Measured memory_bytes: 32836
N, K = map(int, input().split())
f_list = [0] * N
for _ in range(K):
  d = int(input())
  a_list = list(map(int, input().split()))
  for a in a_list:
    f_list[a-1] += 1

ans = 0
for f in f_list:
  if f == 0:
    ans += 1
print(ans)


Measured memory_bytes: 9204
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
    if b[i]>a[i]:
        ans+=a[i]
        b[i]-=a[i]
        if b[i]>a[i+1]:
            ans+=a[i+1]
            a[i+1]=0
        else:
            a[i+1]-=b[i]
            ans+=b[i]
    else:
        ans+=b[i]
print(ans)

Measured memory_bytes: 81892
#include<bits/stdc++.h>
using namespace std;
long long n,m;
long long f[100010],yh[100010];
long long bb(long long p){ 
	if(f[p]==p)return p;
	return f[p]=bb(f[p]); 
}
int main(){
	cin>>n>>m;
	long long i,x[m+1],y[m+1],ans[m],j,k,s,z=n;
	for(i=1;i<=n;i++){
		f[i]=i;
		yh[i]=1;
	}
	for(i=1;i<=m;i++)cin>>x[i]>>y[i];
	long long jk=ans[m-1]=n*(n-1)/2;
	for(i=m;i>0;i--){
		long long zux=bb(x[i]),zuy=bb(y[i]);
		if(zux!=zuy){
			f[zux]=zuy;
			jk-=yh[zux]*yh[zuy];
			yh[zuy]+=yh[zux];
		}
		ans[i-2]=jk;
	}
	for(i=0;i<m;i++)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 5248
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	
	cin>>N;
	int c = 1;
	
	for(int i = 0; i < 3; i++){
		c *= N;
	}
	
	cout<<c<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
t = int(input())
hash = {'AC' :0,'WA' : 0, 'TLE' : 0, 'RE' : 0}
for i in range(t):
	s = input()
	hash[s] = hash.get(s,0)+1
for i,j in hash.items():
	print(f'{i} x {j}')

Measured memory_bytes: 9184
s = input()
cons = 0
ans = [0]*(len(s))
left = 0
right = 0
check1 = True
check2 = False
for i in range(len(s)):
    if check1 == True and s[i] == "L":
        cons = i
        check1 = False
        check2 = True
    if check2 == True and (s[i] == "R" or i == len(s)-1):
        right = i-1
        if i == len(s)-1:
            right += 1
        dum = s[left:right+1]
        dum_index = dum.index("L")
        dum_len = len(dum)
        div,mod = divmod(dum_len,2)
        if dum_index%2 == 0:
            ans[cons] = div+mod
            ans[cons-1] = div
        else:
            ans[cons] = div
            ans[cons-1] = div+mod

        check1 = True
        check2 = False
        left = right+1
print(" ".join(map(str,ans)))

Measured memory_bytes: 17172
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
const int INF = 10000000;

int main(){
    int n; cin >> n;
    int t[110000], x[110000], y[110000];
    t[0] = x[0] = y[0] = 0;
    rep(i, n) cin >> t[i+1] >> x[i+1] >> y[i+1];

    bool ok = true;

    for(int i = 0; i < n; ++i){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if(dt < dist) ok = false;
        if(dt % 2 != dist % 2) ok = false;
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    if (N > 81) {
      System.out.println("No");
      return;
    }
    for (int i = 1;i < 10;i++) {
      if (N % i == 0) {
        if (N / i < 10) {
          System.out.println("Yes");
          return;
        }
      }
    }
    System.out.println("No");
  }
}


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

int a[31][100020], s[200020];

int main()
{
    int N, C; cin>>N>>C;
    for(int i=0; i<N; ++i) {
        int s, t, c; cin>>s>>t>>c;
        ++a[--c][s];
        --a[c][t];
    }
    for(int i=0; i<C; ++i)
        for(int j=1; j<100010; ++j) {
            a[i][j]+=a[i][j-1];
            if (a[i][j]==1 && a[i][j-1]==0)
                ++s[2*j-1];
            if (a[i][j]==0 && a[i][j-1]==1)
                --s[2*j];
        }

    int res=0;
    for(int i=1; i<200020; ++i)
        res=max(res, s[i]+=s[i-1]);
    cout<<res<<endl;
}


Measured memory_bytes: 12800
N = gets.to_i
S = gets.chomp.chars
Q = gets.to_i.times.map{ gets.split }

A_ORD = 'a'.ord
L = 1 << (N - 1).bit_length
ST = Array.new(2 * L, 0)
S.each_with_index do |c,i|
  ST[L + i] = (1 << (c.ord - A_ORD))
end
(1 ... L).each do |i|
  j = L - i
  ST[j] = (ST[2 * j] | ST[2 * j + 1])
end

class << ST
  def update(i,c)
    self[L + i] = (1 << (c.ord - A_ORD))
    j = (L + i) / 2
    while j > 0
      self[j] = self[2 * j] | self[2 * j + 1]
      j /= 2
    end
  end
  def kind(a,b)
    _kind(a, b, 1, 0, L).to_s(2).count('1')
  end
  def _kind(a, b, k, l, r)
    return 0 if r <= a || l >= b
    return self[k] if a <= l && r <= b
    mid = (l + r) / 2
    return (_kind(a, b, 2 * k, l, mid) | _kind(a, b, 2 * k + 1, mid, r))
  end
end


Q.each do |q|
  t = q.shift
  if t == '1'
    i = q.shift.to_i - 1
    c = q.shift
    ST.update(i, c)
    S[i] = c
  else
    a = q.shift.to_i
    b = q.shift.to_i
    puts ST.kind(a - 1, b)
  end
end



Measured memory_bytes: 46772
#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstring>
#include <queue>
#include<map>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const ll mod=1000000007,N=2009;
ll n,k,a[N],a1[N],a2[N];
ll power(ll b,ll p)
{
  if(p==0)
    return 1;
  if(p&1)
    return (b*power((b*b)%mod,p/2))%mod;
  else
    return power((b*b)%mod,p/2);
}
int main()
{
  M();
   cin>>n>>k;
  for(int i=1;i<=n;i++)
  {
     cin>>a[i];
  }
  
  for(int i=1;i<=n;i++)
  {
      int cnt=0;
      for(int j=i+1;j<=n;j++)
      {
          if(a[i]>a[j])
            cnt++;
      }
      a1[i]=cnt;
      cnt=0;
      for(int j=1;j<=n;j++)
      {
          if(a[i]>a[j])
            cnt++;
      }
      a2[i]=cnt;
  }
  ll ans=0;
  ll hf= power(2,mod-2);
  for(int i=1;i<=n;i++)
  {
      ll val=( (a1[i]*k)%mod+ ((a2[i]*( (k*k)%mod-( (k*(k+1))%mod * hf)%mod)%mod+mod)%mod)%mod);
      ans= (ans+val)%mod;
  }
  
  cout<<ans<<endl;
}
  
  
  
  
  
  
  
  
  
  
  
  
  

Measured memory_bytes: 256