akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

struct max_min {
  long double max;
  long double min;
};

struct xy {
  max_min x;
  max_min y;
};

void update(max_min &vec, long double v) {
  vec.max = max(vec.max, v);
  vec.min = min(vec.min, v);
}

void derive(long double &ans, xy &fixed, xy &plus, xy &minus, long double time) {
  auto Xmax = max(fixed.x.max, max(plus.x.max + time, minus.x.max - time));
  auto Xmin = min(fixed.x.min, min(plus.x.min + time, minus.x.min - time));
  auto Ymax = max(fixed.y.max, max(plus.y.max + time, minus.y.max - time));
  auto Ymin = min(fixed.y.min, min(plus.y.min + time, minus.y.min - time));
  ans = min(ans, (Xmax-Xmin)*(Ymax-Ymin));
}

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

  max_min INFTY = {-1e9, 1e9};
  xy fixed, plus, minus;
  fixed = plus = minus = {INFTY, INFTY};

  rep(i,n) {
    int x, y; char d; cin >> x >> y >> d;
    if (d == 'R') {
      update(fixed.y, y);
      update(plus.x, x);
    }
    else if (d == 'L') {
      update(fixed.y, y);
      update(minus.x, x);
    }
    else if (d == 'U') {
      update(fixed.x, x);
      update(plus.y, y);
    }
    else {  // G[i][2] == 'D'
      update(fixed.x, x);
      update(minus.y, y);
    }
  }

  long double ans = 1e18;
  long double time = 0;
  derive(ans, fixed, plus, minus, time);

  rep(i,(1<<4)) {
    bitset<4> s(i);
    auto &tmp1 = s[0] ? fixed : s[1] ? plus : minus;
    auto &tmp2 = s[1] ? minus : plus;
    auto &tmp3 = s[2] ? tmp1.x : tmp1.y;
    auto &tmp4 = s[2] ? tmp2.x : tmp2.y;
    auto object1 = s[3] ? tmp3.max : tmp3.min;
    auto object2 = s[3] ? tmp4.max : tmp4.min;
    time = abs(object1 - object2) / (s[0] ? 1 : 2);
    if (time > 2e8) continue;
    derive(ans, fixed, plus, minus, time);
  }

  printf("%.10Lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
    int n;cin>>n;
    vi v(n);
    rep(i,n){
        cin>>v[i];
    }
    vi p(100005,0),e(100005,0);
    rep(i,n){
        if(i%2==0)p[v[i]]++;
        else e[v[i]]++;
    }
    int pf = max_element(been(p))-p.begin();
    int ef = max_element(been(e))-e.begin();
    if(pf==ef){
        int pc =p[pf],ec=e[ef];
        p.erase(p.begin()+pf);e.erase(e.begin()+ef);
        pf = max_element(been(p))-p.begin();
        ef = max_element(been(e))-e.begin();
        cout<<min(n-pc-e[ef],n-ec-p[pf])<<endl;
    }
    else {
        cout<<n-p[pf]-e[ef]<<endl;
    }
}

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

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("maxflow.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int res=0;
    string str="";
    string t="";
    for(int i=0;i<s.size();i++){
        if(t==str){
            t+=s[i];
            continue;
        }
        else{
            res++;
            str=t;
            t="";
            t+=s[i];
        }
    }
    if(t!=str){
        res++;
    }
    cout<<res<<endl;
    return 0;
}

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

public class Main {
	private static void solve(){
		//Implement solution here.
		String s = next();
		String k = "keyence";
		if(s.startsWith(k) || s.endsWith(k)) {
			System.out.println("YES");
			return;
		} else {
			char[] kc = k.toCharArray();
			for(int i = 1; i <= kc.length; i++) {
				String l = k.substring(0,i);
				String r = k.substring(i,kc.length);
				if(s.startsWith(l) && s.endsWith(r)) {
					System.out.println("YES");
					return;
				}
			}
		}
		System.out.println("NO");
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 22612
#include <stdio.h>

int main() {
  int n;
  scanf("%d",&n);
  int ans=0;
  while(n--) {
    int x,i;
    scanf("%d",&x);
    for(i=2; i*i<=x; i++) {
      if(x%i==0) break;
    }
    if(i*i>x) ans++;
  }
  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 2100
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

bool is_ok(const string &s) {
    rep(i, (int)s.size() / 2) if (s[i] != s[(int)s.size() - i - 1]) return false;
    return true;
}

int main() {
    double l;
    cin >> l;
    double x = l / 3;
    printf("%.10lf\n", x * x * x);
}

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

long long int dfs(long long int s);
long long int N;

int main(){
    scanf("%lld",&N);
    
    printf("%lld",dfs(0));

    return 0;
}

long long int dfs(long long int s){
    if (s > N) return 0;
    int check[3] = {0,0,0};
    int t[10];
    long long int u = s;
    int k[3] = {3,5,7};
    int ret = 1;

    for(int i = 0;i <= 9;i++){
        t[i] = u%10;
        u = u/10;
        for(int j = 0;j <= 2;j++){
            if(t[i] == k[j]){
                check[j] = 1;
            }
        }
    }

    if(check[0]*check[1]*check[2] == 0){
        ret = 0;
    }


    for(int i = 3;i <= 7;i += 2){
        ret += dfs(10*s+i);
    }

    return ret;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String buf;
        ArrayList<Double> mountain = new ArrayList<Double>();
        while((buf = br.readLine())!=null){
            mountain.add(new Double(buf));
        }
        Collections.sort(mountain);
        System.out.println((mountain.get(mountain.size() -1) - mountain.get(0)));
    }
}

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

struct edge { int from, to, cost; };

void dfs(int u, const auto& g, vector<bool>& vis) {
    vis[u] = true;
    for (int v : g[u]) {
        if (vis[v]) continue;
        dfs(v, g, vis);
    }
}

signed main() {
    int N, M, P;
    cin >> N >> M >> P;
    vector<edge> es(M);
    vector<vector<int>> Gf(N); // forward
    vector<vector<int>> Gr(N); // reverse
    for (auto& e : es) {
        cin >> e.from >> e.to >> e.cost;
        e.cost -= P;
        e.cost *= -1;
        e.from--; e.to--;
        Gf[e.from].push_back(e.to);
        Gr[e.to].push_back(e.from);
    }

    vector<bool> ff(N);
    dfs(0, Gf, ff);
    vector<bool> fr(N);
    dfs(N - 1, Gr, fr);

    vector<bool> f(N);
    for (int i = 0; i < N; i++) {
        f[i] = ff[i] & fr[i];
    }

    const int inf = 1e18;
    vector<int> d(N, inf);
    d.front() = 0;
    int n = 2 * N;
    bool upd = false;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < M; j++) {
            edge e = es[j];
            if (!f[e.from] || !f[e.to]) continue;
            if (d[e.to] <= d[e.from] + e.cost) continue;
            d[e.to] = d[e.from] + e.cost;
            upd |= (i == n - 1);
        }
    }
    cout << (upd ? -1 : max(0LL, -d[N - 1])) << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
        int N,M;
        int i,j;
        cin >> N >> M;
        int a[N],b[N],c[M],d[M];
        for(i=0; i<N; i++) {
                cin >> a[i] >> b[i];
        }
        for(i=0; i<M; i++) {
                cin >> c[i] >> d[i];
        }
        for(i=0; i<N; i++) {
                int min=abs(a[i]-c[0])+abs(b[i]-d[0]),flag=1;
                for(j=0; j<M; j++) {
                        int cur=abs(a[i]-c[j])+abs(b[i]-d[j]);
                        if(min>cur) {
                                min = cur;
                                flag = 1+j;
                        }
                }
                cout << flag << endl;
        }
        return 0;
}


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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/

/**************************************/

/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    double a,b,c; cin >> a >> b >> c;
    int x,y; cin >> x >> y;

    double c2 = c*2;
    double ab = a+b;

    int nowx = 0, nowy = 0;

    int ans = 0;
    while(nowx < x || nowy < y){
        if(nowx < x && nowy < y){
            if(ab<c2){
                ans += ab;
                nowx++;
                nowy++;
            }else{
                ans += c2;
                nowx++;
                nowy++;
            }
        }else if(nowx < x){
            if(c2<a){
                ans += c2;
                nowx++;
                nowy++;
            }else{
                ans += a;
                nowx++;
            }
        }else if(nowy < y){
            if(c2<b){
                ans += c2;
                nowx++,nowy++;
            }else{
                ans += b;
                nowy++;
            }
        }
    }

    cout << ans << endl;
}
/********  Main() Ends Here *************/


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

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int temp;
  temp=a;
  a=b;
  b=temp;
  
  temp=a;
  a=c;
  c=temp;
  
  cout<<a<<" "<<b<<" "<<c<<endl;
}
  

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; cin>>n>>k;
	vector<int>a(n,0);
	for(int i=0;i<n;++i){
		int A; cin>>A;
		++a.at(A-1);
	}
	sort(a.begin(),a.end());
	int cnt=0;
	while(a.at(cnt)==0)++cnt;
	int ans=0;
	for(int i=cnt,size=n-cnt;size>k;++i,--size){
		ans+=a.at(i);
	}
	cout<<ans<<"\n"s;
}

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

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

int main(){
    int n, ans;
    ans = 0;

    cin >> n;

    vector<int> aa(n);
    vector<int> ll(n+1);
    vector<int> rr(n+1);

    ll[0] = 0;
    rr[0] = 0;

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

    for(int i=0;i<n;i++){
        ll[i+1] = gcd(ll[i], aa[i]);
        rr[i+1] = gcd(rr[i], aa[n-i-1]);
    }

    for(int i=0;i<n;i++){
        ans = max(gcd(ll[i], rr[n-i-1]), ans);
    }

    cout << ans;
}


Measured memory_bytes: 1536
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	int n,m;
	cin>>n>>m;
	int x,y;
	int L = 0,R = N;
	while(m--){
		cin>>x>>y;
		L = max(L,x);
		R = min(R,y);
	}	

	cout<<max(0,(R - L + 1))<<endl;

	

	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int N;
  int sum;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    
    sum += r-l+1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
A = 0
W = 0
T = 0
R = 0
for i in range(1, N+1):
  s = str(input())
  if s == "AC":
    A = A + 1
  elif s == "WA":
    W = W + 1
  elif s == "TLE":
    T = T + 1
  elif s == "RE":
    R = R + 1
print("AC x " + str(A))
print("WA x " + str(W))
print("TLE x " + str(T))
print("RE x " + str(R))
  
  

Measured memory_bytes: 9140
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - (h * W + w * H - h * w) << endl;
    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<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<<']';
}

struct Point{
	int x,y;
	Point(){}
	Point(int x,int y):x(x),y(y){}
};

bool isrose(const vs& grid,int i,int j)
{
	int h=grid.size(),w=grid[0].size();
	return 0<=i && i<h && 0<=j && j<w && grid[i][j]=='#';
}

int main()
{
	for(int h,w;cin>>h>>w && h|w;){
		vs grid(h);
		rep(i,h) cin>>grid[i];
		reverse(all(grid));
		
		vector<tuple<int,int,int>> ts;
		rep(i,h+1) rep(j,w+1){
			int a=isrose(grid,i-1,j-1),b=isrose(grid,i-1,j),
					c=isrose(grid,i,j-1),d=isrose(grid,i,j);
			if(a==b && a==d && a!=c)
				ts.emplace_back(i,j,1);
			if(a==c && a==d && a!=b)
				ts.emplace_back(i,j,-1);
		}
		
		sort(all(ts),[&](tuple<int,int,int> a,tuple<int,int,int> b){
			int i1,j1,x1; tie(i1,j1,x1)=a;
			int i2,j2,x2; tie(i2,j2,x2)=b;
			//return i1/(i1+j1)!=i2/(i2+j2)?i1/(i1+j1)<i2/(i2+j2):x1<x2;
			return i1*(i2+j2)!=i2*(i1+j1)?i1*(i2+j2)<i2*(i1+j1):x1<x2;
		});
		
		int res=-1,cnt=1;
		for(auto t:ts) res=max(res,cnt+=get<2>(t));
		cout<<res<<endl;
	}
}

Measured memory_bytes: 3364
#include<cstdio>
char c[4001],d[4001],*a,*b;
int main(){
	while(~scanf("%s%s",c,d)){
		int mx=0,o,i,k,s;
		for(a=c,b=d,k=0;k++<2;a=d,b=c)for(o=0;a[o];o++)for(i=s=0;a[i+o]&&b[i];i++){
			if(a[i+o]==b[i]){
				s++;
				if(mx<s)mx=s;
			}
			else s=0;
		}
		printf("%d\n",mx);
	}
	return 0;
}

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

int main() {
  
  int  a,b,c,d;
  cin >>a >>b >>c >>d;
  
  	if( a + b > c +d ){
      cout << "Left"<< endl;
    }
  	else if(a +b == c + d ){
      cout << "Balanced" << endl;
    }
  	else {
      cout << " Right " << endl;
    }
}



Measured memory_bytes: 256
import java.util.Comparator;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<String,Map<Integer,Integer>> restaurants = new TreeMap<>();
 
		int N=sc.nextInt();
 
 
		for(int i=0;i<N;i++) {
			String str = sc.next();
			int n = sc.nextInt();
			if(!restaurants.containsKey(str)) {
				restaurants.put(str, new TreeMap<>(Comparator.reverseOrder()));
			}
			restaurants.get(str).put(n,i+1);
		}
 
		for(Map.Entry<String,Map<Integer,Integer>> e: restaurants.entrySet()) {
			for(Map.Entry<Integer,Integer> ee : e.getValue().entrySet()) {
				System.out.println(ee.getValue());
			}
		}
	}
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[200005];

//! xrとnの各bitを調べ、共に1が立っているところがないか確認する
bool check(ll xr, ll n)
{
    for (; xr > 0 && n > 0; xr >>= 1, n >>= 1)
    {
        if ((xr & 1) == 1 && (n & 1) == 1)
            return false;
    }
    return true;
}

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }

    ll xr = 0;
    int pi = 0;
    ll ans = 0;
    REP(i, N)
    {
        if (!check(xr, A[i]))
        {
            FOR(j, i, pi)
            {
                xr = xr xor A[j];
                if (check(xr, A[i]))
                {
                    pi = j + 1;
                    break;
                }
            }
        }
        xr = xr xor A[i];
        ans += i - pi + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
B = list(map(int, input().split()))
def c(n, b):
    A = [0 for i in range(n)]
    for i in range(n):
        if(i == 0 or i == 1):
            A[i] = b[0]
        else:
            A[i] = b[i-1]
            if(b[i-1] < b[i-2]):
                A[i-1] = b[i-1]
    return sum(A)
print(c(N,B))

Measured memory_bytes: 3064
K = int(input())

k = K - 1

numbers = {
    0: 1
}

while k > 0:
    k -= 1
    for i in range(len(numbers)):
        n = numbers[i]
        if n == 9:
            continue

        if abs(numbers.get(i - 1, n) - (n + 1)) <= 1 and abs(numbers.get(i + 1, n) - (n + 1)) <= 1:
            numbers[i] += 1
            j = i - 1
            while j >= 0:
                numbers[j] = max(numbers[j + 1] - 1, 0)
                j -= 1
            break
    else:
        for key in numbers.keys():
            numbers[key] = 0
        numbers[len(numbers)] = 1

print(''.join([str(numbers[i]) for i in range(len(numbers))])[::-1])


Measured memory_bytes: 9212
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #l,r,d=map(int,input().split())
    n=int(input())
    a=list(map(int,input().split()))
    now=1000
    nokoritemp=1000
    kabu=0
    bos=[0 for i in range(n)] #0=buy 1=sell 2=none
    for i in range(n-1):
        if a[i]>a[i+1]:
            bos[i]=1
    bos[n - 1] = 1
#    for i in range(n-1):
 #       if bos[i+1]==1 and bos[i]==1:
 #           bos[i]=2



    for i in range(n):
        if bos[i]==1:
            now=now+kabu*a[i]
            kabu=0
        elif bos[i]==0:
            urukabu=0
            kaukabu=0
            for j in range(kabu+1):
                kaukabu=(a[i]*j+now)//a[i]
                temp=j*a[i]+now-((a[i]*j+now)//a[i])*a[i]
                if now>=temp:
                    now=temp
                    urukabu=j
            kabu=kabu+kaukabu-urukabu
    print(now)



if __name__ == "__main__":

    main()


Measured memory_bytes: 77320
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REPF(i, a, n) for (int i = a; i < (n); i++)
#define REP(i, n) REPF(i, 0, n)
#define ALL(x) begin(x),end(x)

signed main() {
    string S;
    cin >> S;
    int n = S.size();

    auto validate = [](string s) {
        if (s.size() == 0) return false;
        if (s[0] == '0' && s.size() == 1) return true;
        if (s[0] == '0') return false;
        int num = stoll(s);
        return (0 <= num && num <= 255);
    };

    int ans = 0;
    REPF(i, 1, n) {
        REPF(j, 1, n) {
            REPF(k, 1, n) {
                int l = n - i - j - k;
                if (l <= 0) continue;
                string a = S.substr(0, i);
                string b = S.substr(i, j);
                string c = S.substr(i + j, k);
                string d = S.substr(i + j + k, l);
                if (!validate(a) || !validate(b) || !validate(c) || !validate(d)) continue;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;

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

typedef pair<int,int> pair;

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

    for(int i=1;i<n;i++){
        if(p[i]<=min){
            ans++;
            min=p[i];
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 1024
<?php

$s = trim(fgets(STDIN));
$t = trim(fgets(STDIN));

if (strpos($t, $s) !== false) {
    // code...
    if (strlen($t) == strlen($s)+ 1) {
        // code...
        if(substr($t,0,-1) == $s){
            echo "Yes";
            return;
        }
    }
}
echo 'No';

Measured memory_bytes: 16152
#include <bits/stdc++.h>
#define ll long long
const ll m=1e9+7;
using namespace std;
ll add(ll i,ll j){
    return ((i%m)+(j%m))%m;
}
ll mod(ll i,ll j){
    return ((i%m)*(j%m))%m;
}
int main(){
    int n;
    cin>>n;
    vector<ll>v(n+1,0);
    vector<ll>presum(n+1,0);
    v[n]=0;
    presum[n]=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        v[i]=v[i]%m;
    }
    for(int i=n-1;i>=0;i--){
        presum[i]=add(presum[i+1],v[i+1]);  
    }
    ll ans=0;
    for(int i=n-1;i>=0;i--){
        ans+=mod(presum[i],v[i]);
        ans%=m;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6432
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<numeric>
#include<climits>
#include<stack>
#include<map>
#include<set>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

bool compare_by_b(pair<int, string> a, pair<int, string> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main(void) {
	int n;
	cin >> n;
	vector<pair<string, int>> sp_pair(n);
	vector<pair<string, int>> ans(n);
	set<string> st_set;
	for (int i = 0; i < n; i++)
	{
		string s;
		int p;
		cin >> s >> p;
		sp_pair[i] = make_pair(s, p);
		st_set.insert(s);
	}
	ans = sp_pair;
	sort(ALL(ans));

	stack<int> st;
	for (string tmp_st : st_set)
	{
		for (int i = 0; i < n; i++)
		{
			if (tmp_st == ans[i].first) {
				for (int j = 0; j < n; j++)
				{
					if (ans[i] == sp_pair[j]) {
						st.push(j + 1);
					}
				}
			}
		}
		while (!st.empty()) {
			cout << st.top() << endl;
			st.pop();
		}
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int tmp = n;
    for(int i = 1; i < 3; i++){
      n *= tmp;
    }
    
    System.out.println(n);
    
  }
}

Measured memory_bytes: 21844
from random import *
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=[0]*26
P=[]
Y,Z=0,0
V,W=0,0
T,U=0,0
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  Y,Z=-1,-10**20
  V,W=Y,Z
  T,U=V,W
  for j in range(26):
    if Y==-1:
      Y,Z=0,X[0]+S[i][0]
    if Z<X[j]+S[i][j]:
      T,U=V,W
      V,W=Y,Z
      Y,Z=j,X[j]+S[i][j]
    elif W<X[j]+S[i][j]:
      T,U=V,W
      V,W=j,X[j]+S[i][j]
    elif T<X[j]+S[i][j]:
      T,U=j,X[j]+S[i][j]
  XX[Y]-=X[Y]
  X[Y]=0
  P.append([Y,V,T])
  if randrange(0,50)==0:
    P[i][1]=randrange(0,26)
  if randrange(0,5)==0:
    P[i][2]=randrange(0,26)
  P[i]=tuple(P[i])
SCORE=0
X=[0]*26
for i in range(D):
  SCORE+=S[i][P[i][0]]
  for j in range(26):
    X[j]+=C[j]
  X[P[i][0]]=0
  SCORE-=sum(X)
SCORE2=0
YY=[]
for i in range(D):
  for k in range(10):
    k&=1
    d,q=i,P[i][k+1]
    SCORE2=SCORE
    YY=XX[:]
    SCORE2-=S[d][P[d][0]]
    SCORE2+=S[d][q]
    for j in range(26):
      X[j]=0
    YY[P[d][0]],YY[q]=0,0
    for j in range(D):
      if j==d:
        Z=q
      else:
        Z=P[j][0]
      X[P[d][0]]+=C[P[d][0]]
      X[q]+=C[q]
      X[Z]=0
      YY[P[d][0]]+=X[P[d][0]]
      YY[q]+=X[q]
    if SCORE2-sum(YY)>SCORE-sum(XX):
      z=[P[i][k+1]]
      for l in range(3):
        if l!=k:
          z.append(P[i][l])
      XX=YY[:]
      SCORE=SCORE2
for i in range(D):
  print(P[i][0]+1)


Measured memory_bytes: 85060
#include <iostream>
using namespace std;
#define MAX_N 100000
const int INF = 1e9;
int N;
int h[MAX_N];
int dp[MAX_N + 1];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> h[i];
    for (int i = 0; i < MAX_N; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i < N; i++) {
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));  
    }
    cout << dp[N-1] << endl;
}


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

using ll = long long;
using ld = long double;

int main()
{
    int ans=0;
    string s;
    cin >> s;
    
    for(int i = 0; i < 3; i++)
    {
        if(s.at(i)=='1')
        {
            ans++;
        }
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
ac
x,yが中央値になりうるなら、x<z<yも中央値になりうる。
そして、上限はBの中央値、下限はAの中央地である。
*/

ll n,a[200010],b[200010];

int main(void){
	cin>>n;
	rep(i,n)cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	if(n%2==1){
		cout<<b[n/2]-a[n/2]+1<<endl;
	}else{
		cout<<(b[n/2]+b[n/2-1])-(a[n/2]+a[n/2-1])+1<<endl;
	}
	return 0;
}

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

int main(){

  string s1,s2,s3;
  cin>>s1>>s2>>s3;

  cout<<(char)toupper(s1[0])<<(char)toupper(s2[0])<<(char)toupper(s3[0])<<endl;
  
  return 0;
}


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

using namespace std;

long long sol(long long x)
{
    if (x==1)return 1;
    long long ret;
    ret=2*sol(x/2)+1;
    return ret;
}
int main()
{
    long long x;
    cin>>x;
    cout<<sol(x);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   string s;
   cin>>s;

   for(auto &ele : s)
   ele = 'x';

   cout<<s;  

   return 0;
}

Measured memory_bytes: 256
import sys

M, K = map(int, sys.stdin.readline().strip().split())

if M == 1:
    if K == 0:
        print("0 0 1 1")
    else:
        print(-1)
else:
    if K >= 2**M:
        print(-1)
    else:
        a = [i for i in range(2**M) if i != K]
        b = sorted(a, reverse=True)
        print(" ".join(list(map(str, a + [K] + b + [K]))))

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int A,B,C,D; cin >>A>>B>>C>>D;
    int AB=A+B, CD=C+D;
    if (AB>CD) ANS("Left");
    else if (AB==CD) ANS("Balanced");
    else ANS("Right");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int n, m, p, d; bool x[32][100], y[32][100];
bool hantei() {
	int A = p;
	for (int i = d; i >= 1; i--) {
		if (y[i][A - 1] == true)A--;
		else if (y[i][A] == true)A++;
	}
	if (A == m)return true;
	return false;
}
int main() {
	while (true) {
		for (int i = 0; i < 3200; i++) { x[i / 100][i % 100] = false; y[i / 100][i % 100] = false; }
		cin >> n; if (n == 0)break; cin >> m >> p >> d;
		for (int i = 1; i <= d; i++) {
			string S; cin >> S;
			for (int j = 0; j < n - 1; j++) {
				x[i][j + 1] = (bool)(S[j] - '0'); y[i][j + 1] = x[i][j + 1];
			}
		}
		if (hantei() == true) { cout << "0" << endl; goto E; }
		for (int i = 1; i <= d; i++) {
			for (int j = 1; j < n; j++) {
				if (y[i][j - 1] == true || y[i][j + 1] == true || y[i][j] == true)continue;
				y[i][j] = true;
				if (hantei() == true) { cout << i << ' ' << j << endl; goto E; }
				y[i][j] = false;
			}
		}
		cout << "1" << endl;
	E:;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string S;cin>>S;
  bool b=true;
  if(S.size()%2==1)b=false;
  for (int i=0; i<S.size();i+=2){
    if(S.substr(i,2)!="hi"){
      b=false;
      break;
    }
  }
  if(b)puts("Yes");
  else puts("No");
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3568
import collections

s=list(input())
ans=0
for i in range(len(s)-1):
    if s[i]=="0" and s[i+1]=="0":
        s[i+1]="1"
        ans+=1
    elif s[i]=="1" and s[i+1]=="1":
        s[i+1]="0"
        ans+=1
    else:
        pass
    
print(ans)    

Measured memory_bytes: 4332
#include <iostream>
#include <unordered_map>

using namespace std;
long N;

int main() {
#ifdef __APPLE__
    freopen("input3.txt", "r", stdin);
#endif
    cin >> N;
    unordered_map<long, long> table;

    long ai = 0;
    for (int i = 0; i < N; ++i) {
        cin >> ai;
        ++table[ai];
    }

    long ans = 0;
    for (auto element: table) {
        if (element.first < element.second) {
            ans += element.second - element.first;
        }
        if (element.first > element.second) {
            ans += element.second;
        }
    }

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

Measured memory_bytes: 4260
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc  = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n];
		int total = 0;

		for(int i = 0;i < n;i++) {
			a[i] = sc.nextInt();
			total += a[i];
		}
		if(total >= h) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 47652
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  for (int i = 0; i < N; ++i) {
    cin >> V[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> C[i];
  }
  
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int gain = V[i] - C[i];
    if (gain > 0) ans += gain;
  }
  cout << ans << endl;
  
  return 0;
}


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

int main(){
    string s;
    string t;

    cin >> s >> t;

    int counter = 0;

    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i])
            counter++;
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);   
    Int a[5] = {};
    Int res = 0;
    Int mi = 10;
    for (Int i = 0; i < 5; i++) {
        cin >> a[i];
        if (a[i] % 10 != 0) {
            mi = min(mi, a[i] % 10);
            a[i] = a[i] - (a[i] % 10) + 10;            
        }
        res += a[i];
    }
    dump(res - (10 - mi));
    return 0;
}

Measured memory_bytes: 256
A,B,C,K = list(map(int,input().split()))

cardList = [A,B,C]
numList = [0,0,0]
Hand = K
count = 0

def check(card):
  global Hand
  if Hand - card <= 0:
    return Hand
  else:
    return card

for card in cardList:
  numList[count] = (check(card))
  Hand = Hand - card
  count += 1
  if Hand <= 0:
    break;

print(numList[0] * 1 + numList[1] * 0 + numList[2] * -1)

Measured memory_bytes: 9208
import numpy as np
s = [input() for i in range(2)]
N = int(s[0])
S = list(s[1])
eng = list('ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ')
idx = np.array([eng.index(S[i]) for i in range(len(S))])
N_l = np.array([N]*len(S))
new_idx = idx + N_l
ans = [eng[i] for i in new_idx]
fin_ans = ''
for x in ans:
    fin_ans += x
print(fin_ans)

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

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

    ll count = 0;
    ll maxCount = 0;
    for(ll i = 0; i < S.size(); i++)
    {
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')count++;
        else
        {
            maxCount = max(count,maxCount);
            count = 0;
        }
        if(i == S.size()-1)
        {
            maxCount = max(count,maxCount);
        }
    }

    cout << maxCount << endl;
}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    int X, Y; cin >> X >> Y;
    int turu = X, kame = 0;
    string ans = "No";
    if (2 * turu == Y) {
        ans = "Yes";
    }
    for (int i = 0; i < X; i++) {
        turu--;
        kame++;
        if (2 * turu + 4 * kame == Y) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
	using namespace std;
	signed main() {
		int n, a, b,cnt=0,ans=0;
		cin >> n >> a >> b;
		for (int j = 1; j <= n; j++) {
				cnt = j / 10000 + (j % 10000) / 1000 + (j % 1000) / 100 + (j % 100) / 10 + (j % 10) / 1;
				if (a<=cnt && cnt <= b)ans += j;
			cnt = 0;
		}
		cout << ans << endl;
		ll
	}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int N, M, S, T;

V<V<int>> step;

int bfs() {
    V<bool> vis(3*N, false);
    queue<tuple<int,int>> q;
    q.push(make_tuple(S, 0));
    vis[S] = true;
    while(!q.empty()) {
        int e, c;
        tie(e,c) = q.front(); q.pop();
        REP(i, step[e].size()) {
            int nx = step[e][i];
            if(vis[nx]) continue;
            if(nx == T) return (c+1)/3;
            q.push(make_tuple(nx,c+1));
            vis[nx] = true;
        }
    }
    return -1;
}

int main(){
    INIT;
    cin >> N >> M;
    step.resize(3*N);
    REP(i,M) {
        int a, b; cin >> a >> b;
        a--; b--;
        REP(i,3) step[a+N*i].push_back(b+N*((i+1)%3));
    }
    cin >> S >> T;
    S--; T--;
    cout << bfs();
}


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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;

using ll = long long;

using namespace std;

signed main() {
    int N, K;cin >> N >> K;
    vector<pair<ll, ll>> v1, v2;
    for(int i = 0;i < N;i++){
        ll a, b;cin >> a >> b;
        v1.push_back({a, b});
        v2.push_back({b, a});
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    ll ans = 1e18 * 5;
    for(int i = 0;i < N;i++){
        for(int j = i + 1;j < N;j++){
            for(int k = 0;k < N;k++){
                int cnt = 0;
                int l;
                for(l = k;l < N;l++){
                    pair<ll, ll> w = v2[l];
                    if(v1[i].first <=  w.second && w.second <= v1[j].first){
                        cnt++;
                    }
                    if(cnt == K)break;
                }
                //cout<<cnt<<endl;
                if(cnt == K)ans = min(ans, (v1[j].first - v1[i].first) *  abs(v2[l].first - v2[k].first));
            }
        }
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 10
 
struct P {
    int x, y;
};
 
int n;
P sp[MAX];
const int px[12] = {-2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2};
const int py[12] = {-1, 0, 1, -2, 2, -2, 2, -2, 2, -1, 0, 1};
const int dx[9] = {1, 1, 1, -1, -1, -1, 0, 0, 0};
const int dy[9] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
 
bool check(int x, int y)
{
    if (x < 0 || y < 0 || x > 9 || y > 9) {
	return 0;
    }
    return 1;
}
 
bool solve(int x, int y, int s)
{
    if (s == n) {
	return 1;
    }
 
    for (int i = 0; i < 12; i++) {
	int nx = x + px[i];
	int ny = y + py[i];
	
	if (!check(nx, ny)) continue;
	for (int j = 0; j < 9; j++) {
	    int spx = sp[s].x + dx[j];
	    int spy = sp[s].y + dy[j];
     
	    if (!check(spx, spy)) continue;
 
	    if (nx == spx && ny == spy) {
		if (solve(nx, ny, s+1)) {
		    return 1;
		}
	    }
	}
    }  
    return 0;
}
 
int main()
{
    int sx,sy;
    while (cin >> sx >> sy, (sx | sy)) {
	cin >> n;
	for (int i = 0; i < n; i++) {
	    cin >> sp[i].y >> sp[i].x;
	}
	if (solve(sy, sx, 0)) {
	    cout << "OK" << endl;
	} else {
	    cout << "NA" << endl;
	}
    } 
    return 0;
}

Measured memory_bytes: 3088
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000

int main(){
  int a,b,c;
  bool flag = true;
  

  cin >> a >> b >> c;

  if(a + b + c != 5 + 5 + 7) flag = false;

  if(!((a == 5 && b == 7) || (a == 5 && b == 5) || (a == 7 && b == 5)))
    flag = false;

  if(flag)
    puts("YES");
  else
    puts("NO");
  
  
  return 0;
}


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

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

  vector<int> w(n);
  int wtmp = 0;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'W') {
      wtmp++;
    }
    w.at(i) = wtmp;
  }
  w.insert(w.begin(), 0);

  vector<int> e(n);
  int etmp = n - wtmp;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'E') {
      etmp--;
    }
    e.at(i) = etmp;
  }
  e.insert(e.begin(), n - wtmp);


  int ans = n, tmp = 0;
  for (int i = 0; i <= n; i++) {
    tmp = w.at(i) + e.at(i);
    ans = min(tmp, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 5232
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
using namespace std;

int main() {
    long long W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if(W>=(x+r) && 0<=(x-r) && H>=(y+r) && 0<=(y-r)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



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

using namespace std;

static int N;
static long long X;

static vector<long long> B;
static vector<long long> P;

long long f(int N, long long X) {
  if (N == 0) {
    if (X <= 0) {
      return 0;
    } else {
      return 1;
    }
  } else if (X <= 1 + B[N - 1]) {
    return f(N - 1, X - 1);
  } else {
    return P[N - 1] + 1 + f(N - 1, X - 2 - B[N - 1]);
  }
}

void solve(int N, long long X) {
  B.resize(N + 1);
  P.resize(N + 1);
  B[0] = 1;
  P[0] = 1;
  for (int i = 0; i < N; i++) {
    B[i + 1] = 2 * B[i] + 3;
    P[i + 1] = 2 * P[i] + 1;
  }
  printf("%lld\n", f(N, X));
}

int main() {
  cin >> N >> X;
  solve(N, X);
  return 0;
}


Measured memory_bytes: 888