akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main() {
#define int long long
	int n;
	cin >> n;
	vector<long long> a;
	REP(i, n) {
		long long tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	long long ans = 0;
	if (n % 2 == 1) {
		long long tmp = 0;
		REP(i, n/2) {
			tmp += a[n - i - 1] * 2;
		}
		REP(i, (n + 1) / 2) {
			tmp -= a[i] * 2;
		}
		tmp += a[(n + 1) / 2 - 1] + a[(n + 1) / 2 - 2];
		ans = tmp;
		tmp = 0;
		REP(i, n / 2) {
			tmp -= 2 * a[i];
		}
		REP(i, (n + 1) / 2) {
			tmp += 2 * a[n - i - 1];
		}
		tmp -= a[(n + 1) / 2 - 1] + a[(n + 1) / 2];
		ans = max(ans, tmp);
	}
	else {
		REP(i, n/2) {
			ans += -a[i]*2;
		}
		REP(i, n / 2) {
			ans += a[n-1-i] * 2;
		}
		ans -= a[n / 2];
		ans += a[n / 2 - 1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2032
#include <stdio.h>

int det(int a11,int a12,int a13,int a21,int a22,int a23,int a31,int a32,int a33);

int main(void) {
    int xo,yo,zo,xe,ye,ze,x1,y1,z1,x2,y2,z2,x3,y3,z3,detA,dets,dett,detk;
    double s,t,k;
    scanf("%d %d %d\n%d %d %d\n%d %d %d\n%d %d %d\n%d %d %d\n",&xo,&yo,&zo,&xe,&ye,&ze,&x1,&y1,&z1,&x2,&y2,&z2,&x3,&y3,&z3);
    detA=det(-x1+x2,-x1+x3,-xe+xo,-y1+y2,-y1+y3,-ye+yo,-z1+z2,-z1+z3,-ze+zo);
    dets=det(-x1+xo,-x1+x3,-xe+xo,-y1+yo,-y1+y3,-ye+yo,-z1+zo,-z1+z3,-ze+zo);
    dett=det(-x1+x2,-x1+xo,-xe+xo,-y1+y2,-y1+yo,-ye+yo,-z1+z2,-z1+zo,-ze+zo);
    detk=det(-x1+x2,-x1+x3,-x1+xo,-y1+y2,-y1+y3,-y1+yo,-z1+z2,-z1+z3,-z1+zo);
    s=1.0*dets/detA;
    t=1.0*dett/detA;
    k=1.0*detk/detA;
    if (k>0.0&&k<=1.0&&s>=0.0&&t>=0.0&&s+t<=1.0) {
        printf("MISS\n");
    } else {
        printf("HIT\n");
    }
    return 0;
}

int det(int a11,int a12,int a13,int a21,int a22,int a23,int a31,int a32,int a33) {
    return a11*a22*a33+a12*a23*a31+a13*a21*a32-a11*a23*a32-a12*a21*a33-a13*a22*a31;
}

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

int main()
{
	int n;
	bool f = 0;

	cin >> n;

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < 15; j++) {
			if (4 * i + 7 * j == n) {
				f = 1;
				break;
			}
		}
		if (f)
			break;
	}

	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
#define MAX 26
#define Astart 65
#define Aend 90
#define Atoa 32
#define astart 97
#define aend 122
using namespace std;

int main()
{
	int count[MAX]={0};
	string ss;

	while(1)
	{
		cin >> ss ;
		if(cin.eof()) break;

		for(int i=0;i<(int)ss.size();i++)
		{
			if(((int)ss[i] >=Astart)&&((int)ss[i]<=Aend))
			{
				ss[i] = ss[i] + Atoa;
			}

			if(((int)ss[i] >=astart)&&((int)ss[i]<=aend))
			{
				count[((int)ss[i]-astart)]++;
			}
		}

	}
	
	for(int i=0;i<MAX;i++)
	{
		cout << (char)(astart+i) << " : " << count[0+i] << endl ; 
	
	}

	return 0;
}

Measured memory_bytes: 1180
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {

	for (;;) {

		int m, n;
		set<pair<int, int>> mstar, nstar;
		/*int mstar[234][2], nstar[1234][2];

		scanf("%d", &m);
		rep(i, m) scanf("%d %d", &mstar[i][0], &mstar[i][1]);

		scanf("%d", &n);
		rep(i, n) scanf("%d %d", &nstar[i][0], &nstar[i][1]);*/

		//printf("%d\n");

		scanf("%d", &m);
		if (!m) break;
		rep(i, m) {
			int x, y;
			scanf("%d %d", &x, &y);
			mstar.insert(make_pair(x, y));
		}

		scanf("%d", &n);
		rep(i, n) {
			int x, y;
			scanf("%d %d", &x, &y);
			nstar.insert(make_pair(x, y));
		}

		int dx, dy;
		for (auto ns : nstar) {
			dx = ns.first - (*mstar.begin()).first;
			dy = ns.second - (*mstar.begin()).second;
			bool izryt = true;
			for (auto ms : mstar) {
				if (nstar.find(make_pair(ms.first + dx, ms.second + dy)) == nstar.end()) {
					izryt = false;
					break;
				}
			}
			if (izryt) {
				printf("%d %d\n", dx, dy);
				break;
			}
		}

	}

	return 0;
}

Measured memory_bytes: 2736
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll x = max(a,c)-min(a,c);
    ll y = max(b,d)-min(b,d);
    ll g = __gcd(x,y);
    if(g==0){
        cout << 0 << endl;
        return 0;
    }
    x /= g;
    y /= g;
    cout << (x + y - 1) * g << endl;
}

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

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

    int ans = -99;
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j < n; j++) {
            ans = max(ans, abs(a[i] - a[j]));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))
 
 
using namespace std;
 
 
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;
typedef unordered_set<int> ui;



int main(){
	std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	string s;
	cin>>s;
	int i = 0, j = (int)s.size()-1, ans = 0;
	while(i<j){
		int i1 = i, j1 = j;
		while(i1<j && s[i1]=='x') ++i1;
		while(j1>i && s[j1]=='x') --j1;
		if(i1>j1) break;
		if(s[i1]!=s[j1]){
			cout<<-1<<endl;
			return 0;
		}
		ans += abs((i1-i) - (j-j1));
		i = i1+1;
		j = j1-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

const int INF = 1e9;

struct SegTree {
    int N;
    vector<int> dat, lazy;
    SegTree() {}
    SegTree(int n) {
        N = 1;
        while(N < n) N *= 2;
        dat.resize(2 * N, 0);
        lazy.resize(2 * N, 0);
    }
    //?????¶??????
    void lazy_evaluate(int k, int l, int r){
        if(lazy[k] != 0){//?????¶????????????
            dat[k] += lazy[k] * (r - l);
            if(k < N - 1){//k????????§???????????????????????¬
                lazy[k * 2 + 1] += lazy[k];
                lazy[k * 2 + 2] += lazy[k];
            }
            lazy[k] = 0;
        }
    }
    int marge(int x, int y){
        return x + y;
    }
    //add x [a, b)
    void update(int a, int b, int x){ update(a, b, 0, 0, N, x); }
    void update(int a, int b, int k, int l, int r, int x){
        lazy_evaluate(k, l, r);        
        if(r <= a || b <= l) return;
        if(a <= l && r <= b){
            lazy[k] += x;
            lazy_evaluate(k, l, r);
        }else{
            int m = (l + r) / 2;
            update(a, b, k * 2 + 1, l, m, x);
            update(a, b, k * 2 + 2, m, r, x);
            dat[k] = marge(dat[k * 2 + 1], dat[k * 2 + 2]);
            // dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    // min [a, b)
    int query(int a, int b){ return query(a, b, 0, 0, N); }
    int query(int a, int b, int k, int l, int r) {
        lazy_evaluate(k, l, r);
        if(r <= a or b <= l) return 0;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        int x = query(a, b, k * 2 + 1, l, m);
        int y = query(a, b, k * 2 + 2, m, r);
        return marge(x, y);
        // return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};

signed main(){
    int n, q;
    cin >> n >> q;
    SegTree sg(n);
    rep(i, 0, q){
        int k, s, t, x;
        cin >> k;
        if(k == 0){
            cin >> s >> t >> x;
            sg.update(s - 1, t, x);
            // rep(i, 0, )
        }else{
            cin >> s >> t;
            cout << sg.query(s - 1, t) << endl;
            //  rep(j, 0, n){
            //     cout << sg.dat[n + j] << " ";
            // }
            // cout << endl;
        }
    }
}

Measured memory_bytes: 6980
#include<bits/stdc++.h>
#define L long long
using namespace std;
int n,a,b;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n>>a>>b;
	if(a-b&1)
	  printf("Borys\n");
	else
	  printf("Alice\n");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll n,x;
    cin>>n>>x;
    vector<ll> b(n),u(n),l(n);
    rep(i,n)cin>>b[i]>>l[i]>>u[i];
    vector<int> ord(n);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int i,int j){
        return l[i]*b[i]+u[i]*(x-b[i])>l[j]*b[j]+u[j]*(x-b[j]);
    });
    ll ok=n*x,ng=-1;
    ll sum[n];
    rep(idx,n){
        int i=ord[idx];
        sum[idx]=l[i]*b[i]+u[i]*(x-b[i]);
    }
    rep(i,n-1)sum[i+1]+=sum[i];
    ll y=0;
    rep(i,n)y+=b[i]*l[i];
    while(ok-ng>1){
        ll mid=(ok+ng)/2;
        ll ret=0;
        ll k=mid/x, t=mid%x;
        rep(i,n){
            int idx=ord[i];
            ll res=(t<=b[idx]?l[idx]*t : l[idx]*b[idx]+u[idx]*(t-b[idx]));
            if(k==0){
                ret=max(ret,res);
            }
            else if(i>k){
                ret=max(ret,sum[k-1]+res);
            }
            else {
                ret=max(ret,sum[k]+res-l[idx]*b[idx]-u[idx]*(x-b[idx]));
            }
        }
        if(ret>=y)ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
    return 0;
}

Measured memory_bytes: 3712
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] s = new int[n];
		for(int i=0; i<n; i++){
			s[i] = sc.nextInt();
		}
		int p = sc.nextInt();
		int ans = 0;
		for(int i=0; i<p; i++){
			int q = sc.nextInt();
			int upp = n - 1;
			int low = 0;
			int mid = (upp + low) / 2;
			while(low<=upp){
				if(s[mid]==q){
					ans++;
					break;
				}
				else if(s[mid]<q){
					low = mid + 1;
					mid = (low + upp) / 2;
				}
				else{
					upp = mid - 1;
					mid = (low + upp) / 2;
				}
			}
		}
		System.out.println(ans);
	}
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(void) {
	long long n, i, j, c;
	cin >> n;
	c = 0;
	for (i = 1; i < n; i++) {
		for (j = 1; i*j < n; j++) {
			c++;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3632
n=input()
m=int(input())
s=list(n)
if s[0]!="1":
    print(s[0])
elif s[0]=="1":
    p=0
    for i in s:
        if i=="1":
            p+=1
        else:
            q=i
            break
    if m<=p:
        print(1)
    else:
        print(q)
        

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll h, w;
	cin >> h >> w;
	ll n;
	cin >> n;
	cout << min((n + h - 1) / h, (n + w - 1) / w) << endl;
}


Measured memory_bytes: 256
/*input
5 7
*/
#include <bits/stdc++.h>
#pragma GCC optmize("O2")
using namespace std;
#define int long long
#define F first
#define S second
#define pii pair<int, int>
main () {
    int a, b; cin >> a >> b;
    cout << a * b - a - b + 1;
}

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

int main() {
  char alpha;
  cin >> alpha;

  int num = alpha - '0';
  if (num >= 'a' - '0' && num <= 'z' - '0') {
    cout << 'a' << endl;
  }
  if (num >= 'A' - '0' && num <= 'Z' - '0') {
    cout << 'A' << endl;
  }

  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>

using namespace std;

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


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

int a[10];

int main(){
    for(int i = 0;i<3;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+3);
   cout << a[0] << " " << a[1] <<" " <<a[2];
    cout << endl;

    return 0;
}


Measured memory_bytes: 3252
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0 for i in range(n)]
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])
if __name__=='__main__':
    main()

Measured memory_bytes: 13980
def main():
    N = int(input())
    Tt = [int(i) for i in input().split(" ")]
    M = int(input())
    for i in range(M):
        T = Tt[:]
        P , X = map(int,input().split(" "))
        T[P-1] = X
        print(sum(T))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;


int table[4096][4096];
int main()
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
			break;

		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				scanf("%d", &table[i][j]);

		for (int i = 0; i < n; ++i)
		{
			int s = 0;
			for (int j = 0; j < n; ++j)
				s += table[j][i];
			table[n][i] = s;
		}
		for (int i = 0; i <= n; ++i)
		{
			int s = 0;
			for (int j = 0; j < n; ++j)
				s += table[i][j];
			table[i][n] = s;
		}
		for (int i = 0; i <= n; ++i)
		{
			for (int j = 0; j <= n; ++j)
			{
				printf("%5d", table[i][j]);
			}
			printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, bool> P;

vector<P> ys[200];

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

	int N;
	while(cin >> N, N) {
		vector<ll> x(N), y(N), cx(4), cy(4);
		vector<ll> xv;
		for(int i = 0; i < N; i++) {
			cin >> x[i] >> y[i];
			xv.push_back(x[i]);
		}
		for(int i = 0; i < 4; i++) {
			cin >> cx[i] >> cy[i];
			xv.push_back(cx[i]);
		}
		sort(xv.begin(), xv.end());
		xv.erase(unique(xv.begin(), xv.end()), xv.end());
		for(int i = 0; i < xv.size(); i++) {
			ys[i].clear();
		}

		for(int i = 0; i < N; i++) {
			int j = (i + 1) % N;
			if(y[i] != y[j]) continue;
			ll lx = min(x[i], x[j]);
			ll rx = max(x[i], x[j]);
			for(int k = 0; k < xv.size() - 1; k++) {
				if(lx <= xv[k] && xv[k + 1] <= rx) {
					ys[k].push_back({ y[i], 0 });
				}
			}
		}

		for(int i = 0; i < 4; i++) {
			int j = (i + 1) % 4;
			if(cy[i] != cy[j]) continue;
			ll lx = min(cx[i], cx[j]);
			ll rx = max(cx[i], cx[j]);
			for(int k = 0; k < xv.size() - 1; k++) {
				if(lx <= xv[k] && xv[k + 1] <= rx) {
					ys[k].push_back({ cy[i], 1 });
				}
			}
		}
		for(int i = 0; i < xv.size(); i++) {
			sort(ys[i].begin(), ys[i].end());
		}

		ll ans = 0;
		for(int i = 0; i < xv.size() - 1; i++) {
			ll w = xv[i + 1] - xv[i];
			bool in = false, in_curtain = false;
			for(int j = 0; j < ys[i].size(); j++) {
				if(in && !in_curtain) {
					ans += w * (ys[i][j].first - ys[i][j - 1].first);
				}
				if(ys[i][j].second) in_curtain = !in_curtain;
				else in = !in;
			}
		}
		cout << ans << endl;
	}


}

Measured memory_bytes: 3156
z='abcdefghijklmnopqrstuvwxyz'
e=lambda x,i,j:z[(z.index(x)*i+j)%26]
def f():
 for i in range(1,26,2):
  for j in range(26):
   if''.join(e(c,i,j)for c in'that')in s or''.join(e(c,i,j)for c in'this')in s:return(i,j)
for _ in[0]*int(input()):
 s=input()
 k=f()
 a=''.join(e(c,*k)for c in z)
 t=str.maketrans(a,z)
 print(s.translate(t))


Measured memory_bytes: 5600
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int N=105;
const int NN=2e5+4;
bool dp[NN];
int mm[N];


inline string solve(int n, int k){
	memset(dp,false,sizeof(dp));
	dp[0]=false;
	FER(cap,1,k+1){
		dp[cap]=false;
		FER(j,0,n)if(cap-mm[j]>=0)dp[cap]|=!dp[cap-mm[j]];
	}
	if(dp[k])return "First";
	else return "Second";
}



int main(){	
	fastio;
	int n,k;cin>>n>>k;
	FER(i,0,n)cin>>mm[i];
	cout<<solve(n,k)<<endl;
	return 0;
}


Measured memory_bytes: 512
/*
[exawizards2019] C - Snuke the Wizard
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 2e5;
const int MAX_Q = 2e5;

int N, Q;
string s;
char t[MAX_Q], d[MAX_Q];

bool can(int x, int target) {
    for (int i = 0; i < Q; i++) {
        if (t[i] == s[x]) {
            x += d[i] == 'L' ? -1 : 1;
        }
    }

    return x == target;
}

ll solve() {
    ll cnt = 0;
    for (int target : {0, N + 1}) {
        int ok, ng;
        if (target == 0) {
            ok = 0;
            ng = N + 1;
        } else {
            ng = 0;
            ok = N + 1;
        }
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (can(mid, target)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        cerr << "ok: " << ok << endl;
        cnt += abs(ok - target);
    }

    return N - cnt;
}

int main() {
    cin >> N >> Q;
    cin >> s;
    s.insert(s.begin(), '@');
    s.push_back('@');
    for (int i = 0; i < Q; i++) {
        cin >> t[i] >> d[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 900
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}

		long pair = 0;
		for(int i = 0; i < n; i++){
			pair += a[i]/2;

			if(i != n - 1 && a[i]%2 == 1 && a[i + 1] != 0){
				a[i + 1]++;
			}
		}

		System.out.println(pair);
	}

}


Measured memory_bytes: 49496
import java.util.ArrayList;
import java.util.BitSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			int[] a = new int[n];
			int m = in.nextInt();
			int[] b = new int[m];
			if(n==0 && m==0) break;
			int sumA = 0;
			int sumB = 0;
			for(int i=0; i<n; i++){
				a[i] = in.nextInt();
				sumA += a[i];
			}
			for(int i=0; i<m; i++){
				b[i] = in.nextInt();
				sumB += b[i];
			}
			String res = "-1";
			out: for(int i=0; i<n; i++){
				for(int j=0; j<m; j++){
					if(sumA-a[i]+b[j] == sumB-b[j]+a[i]){
						res = a[i]+" "+b[j];
						break out;
					}
				}
			}
			System.out.println(res);
		}
	}
}

Measured memory_bytes: 21044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define mp make_pair
int main()
{
	ll n;
	cin>>n;
	ll a[n][3];
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<3;j++)
		{
			cin>>a[i][j];
		}	
	}
	ll dp[n][3];
	for(ll i=0;i<3;i++)
	{
		dp[n-1][i]=a[n-1][i];
	}
	for(ll i=n-2;i>=0;i--)
	{
		for(ll j=0;j<3;j++)
		{
			dp[i][j]=a[i][j]+max(dp[i+1][(j+1)%3],dp[i+1][(j+2)%3]);
		}
	}
	ll maxi=-1;
	for(ll i=0;i<3;i++)
	{
		maxi=max(maxi,dp[0][i]);
	}
	cout<<maxi;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  int now=0;
  for(int i=100;i>=1;i--){
    if(a%i==0&&b%i==0){
      now++;
      if(now==k){
        cout<<i<<endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
N, K = gets.split.map &:to_i
S = gets.chomp.chars.map &:to_i

A = S.chunk{|s| s < 1}.map{|_, a|
  a.size * (a[0] == 0 ? -1 : 1)
}
A.unshift(0) if A[0] < 0
A.push(0) if A[-1] < 0

l = r = 0
cnt = 0
ans = curr = A[r]
loop{
  r += 2
  break if r >= A.size
  curr += A[r-1].abs + A[r].abs
  ans = curr if curr > ans
  cnt += 1
  if cnt >= K
    cnt -= 1
    l += 2
    curr -= A[l-1].abs + A[l-2].abs
  end
}
p ans


Measured memory_bytes: 11388
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s ="";
    if(sc.hasNext())
    s= sc.next();
    if(s.length()==6 && s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5)){
      System.out.println("Yes");
      return;
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 22740
import java.util.*;
import java.io.*;
import java.lang.*;
import static java.lang.System.*;
public class Main{
  public static void main(String[] args) throws Exception {

			  Scanner sc=new Scanner(in);
			  int a=sc.nextInt();
			  int b=sc.nextInt();
			  int c=sc.nextInt();
			  if(b-a==c-b)
			  out.println("YES");
			  else
			  out.println("NO");

}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <stack>
#define LL long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=1;i<=n;i++)
#define repp(i,x,y) for(int i=x;i<=y;i++)
#define INF INT_MAX
using namespace std;
double n,m,d;
int main(){
	cin>>n>>m>>d;
	long double ans;
	if(d==0){
		ans=(m-1)/n;
	}else{
		ans=(m-1)*2*(n-d)/n/n;
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string s;
void input(){
    fast_io();
    cin >> s;
}

int solve(){
    char now = 'S';
    vector<int> cal;
    int num = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if(s[i]==now) num++;
        else{
            now = s[i];
            cal.push_back(num);
            num = 1;
        }        
    }
    cal.push_back(num);
    cal.push_back(0);
    DBG(cal)
    for (int i = 0; i < cal.size()-1; i++)
    {
        if(i%2==0){
            int m = 0;
            m = min(cal[i],cal[i+1]);
            cal[i] -= m;
            cal[i+1] -= m;
        }
        else{
            if(cal[i]==0)
            cal[i+1] += cal[i-1];
            cal[i-1] = 0;
        }
    }
    int ans = accumulate(cal.begin(),cal.end(),0);
    cout << ans << endl;
    return 0;
}   

int editorial_solve(){
    stack<char> st;
    for (int i = 0; i < s.length(); i++)
    {
        if(s[i]=='S') st.push(s[i]);
        else{
            if(st.empty()) st.push(s[i]);
            else {
                if(st.top()=='S') st.pop();
                else st.push(s[i]);
            }
        }
    }
    cout << st.size() << endl;
    return 0;
}

int main()
{
    input();
    editorial_solve();
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N,M,ans=0,k=0;cin>>N>>M;
    vector<pair<int,int>>vec(N);
    REP(i,N){
        int a,b;cin>>a>>b;
        vec[i]=mp(a,b);
    }
    sort(vec.begin(),vec.end());
    priority_queue<int> que;
    for(int i=M-1;i>=0;i--){
        while(k<=N&&vec[k].first==M-i){
            que.push(vec[k].second);
            k++;
        }
        if(!que.empty()){
			ans+=que.top();
        	que.pop();
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2936
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    string s;
    cin >> s;
    char tmp = s[0];
    bool check = false;
    for (int i = 1; i < s.size(); i++){
        if (s[i] == tmp) continue;
        check = true;
        break;
    }
    if (check) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let print_rectangle h w =
  for i = 1 to h do
    for j = 1 to w do
      if (i <> 1) && (i <> h) && (j <> 1) && (j <> w) then print_char '.'
      else print_char '#'
    done;
    print_newline ();
  done

let rec repl () =
  let l = read_line () in
  match List.map int_of_string (split l ' ') with
  | [] | [_] -> exit 1
  | h :: w :: _ ->
      if (h = 0) && (w = 0) then ()
      else begin
        print_rectangle h w;
        print_newline ();
        repl ()
      end

let () =
  try repl () with End_of_file -> ()

Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int N, M, X;
	cin >> N >> M >> X;
	int C[N];
	int A[N][M];
	rep(i,N){
		cin >> C[i];
		rep(j,M){
			cin >> A[i][j];
		}
	}
	int ans = INF;
	for(int bit=0;bit<(1<<N);++bit){
		int sum = 0;
		int cntA[M]{};
		bool ok = true;
		rep(i,N){
			if(bit & (1<<i) ){
				sum += C[i];
				rep(j,M){
					cntA[j] += A[i][j];
				}
			}
		}
		rep(i,M){
			if(cntA[i] < X){
				ok = false;
			}
		}
		if(ok){
			ans = min(ans, sum);
		}
	}
	if(ans == INF) cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
using namespace std;
int sum = 0;
char a[20][20];
void solve(int h, int w,  int i,int  j) {
	if (i + 1 < h&&a[i + 1][j] == '.') {
		sum++;
		a[i + 1][j] = '#';
		solve(h, w,  i+1, j);
	}
	if (i - 1 >= 0&&a[i - 1][j] == '.') {
		sum++;
		a[i - 1][j] = '#';
		solve(h, w,  i-1, j);
	}
	if (j + 1 < w&&a[i][j+1] == '.') {
		sum++;
		a[i][j+1] = '#';
		solve(h, w,  i, j+1);
	}
	if (j - 1 >= 0&&a[i][j-1] == '.') {
		sum++;
		a[i][j-1] = '#';
		solve(h, w,  i, j-1);
	}
}
int main() {
	int h, w;
	while (cin >> w >> h&&w != 0 && h != 0) {
		string b;
		int h2, w2;
		for (int i = 0; i < h; i++) {
			cin >> b;
			for (int j = 0; j < w; j++) {
				a[i][j] = b[j];
				if (a[i][j] == '@') {
					h2 = i;
					w2 = j;
				}
			}
		}
		sum = 0;
		solve(h, w,  h2, w2);
		cout << ++sum << endl;
	}
}

Measured memory_bytes: 3192
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;


struct Sta {
    uint64_t c;
    uint64_t s;
    uint64_t f;
};

uint64_t nex(const Sta& sta, uint64_t t) {
    uint64_t start;
    if (t < sta.s) {
        start = sta.s;
    }
    else {
        start = ((t + sta.f - 1)/ sta.f) * sta.f;
    }
    return start + sta.c;
}


int main()
{
    uint64_t N;
    std::cin >> N;

    std::vector<Sta> sta;
    for (size_t i = 0; i < N; ++i) {
        uint64_t c, s, f;
        std::cin >> c >> s >> f;
        sta.push_back({c, s, f});
    }

    for (size_t i = 0; i < N - 1; ++i) {
        uint64_t time = 0;
        for (size_t j = i; j < N - 1; ++j) {
            time = nex(sta[j], time);
        }
        std::cout << time << std::endl;
    }
    std::cout << 0 << std::endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main()
{
    char str[100000];
    gets(str);
    int i,count=0;
    int len=strlen(str);
    //printf("%d",len);
    for(i=0;i<len-1;i++)
    {
        if(str[i]=='0')
        {
            if(str[i+1]=='0')
            {
                str[i+1]='1';
                count++;
                continue;
            }
        }
        else if(str[i]=='1')
        {
            if(str[i+1]=='1')
            {
                str[i+1]='0';
                count++;
                continue;
            }
        }
    }
   // printf("%s",str);
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 1668
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
import sys
sys.setrecursionlimit(10**6)

n = ni()
def idx(u,v):
    return u*n+v
tree = [[] for i in range(n**2)]
go=[False]*n**2
back=[False]*n**2
memo = [1]*n**2 #memo[i] iからの深さ
start = []
for i in range(n):
    A1 = lma()
    pu,pv = i,A1[0]-1
    if pu>pv:pu,pv=pv,pu
    start.append(idx(pu,pv))
    for j in range(1,n-1):
        u,v = i,A1[j]-1
        if u>v:u,v=v,u
        tree[idx(pu,pv)].append(idx(u,v))
        pu,pv=u,v
        start.append(idx(pu,pv))
#print(tree)
def dfs(s):
    go[s]=True
    for node in tree[s]:
        if not go[node]:
            memo[s] = max(dfs(node)+1,memo[s])
        else:
            if back[node]:
                memo[s] = max(memo[node]+1,memo[s])
            else:
                print(-1)
                exit()
    back[s]=True
    return memo[s]
ans = 0
for s in start:
    if not go[s]:
        ans = max(ans,dfs(s))
print(ans)


Measured memory_bytes: 243360
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,b,k;
    cin>>a>>b>>k;
//    if(a==0&&b==0)
//    {
//
//        cout<<0<<" "<<0<<endl;
//    }
//    else if(a!=0&&b!=0&&k==0)
//        cout<<a<<" "<<b<<endl;
//
//   else if(a==0&&b!=0)
//    {
//        if(b<=k)
//            cout<<0<<" "<<b<<endl;
//        else
//            cout<<0<<" "<<k<<endl;
//    }
//   else if(a!=0&&b==0)
//    {
//        if(a<=k)
//            cout<<0<<" "<<a<<endl;
//        else
//            cout<<0<<" "<<k<<endl;
//    }
//  else if(a!=0&&b!=0&&k!=0)
//  {
//      if(a<=k)
//        cout<<0<<" "<<abs(b-(k-a))<<endl;
//      else
//        cout<<k<<" "<<abs(a-k)<<endl;
//  }

   if(k<=a)
    cout<<a-k<<" "<<b<<endl;
   else if(k<=a+b)
    cout<<0<<" "<<b-(k-a)<<endl;
   else
    cout<<0<<" "<<0<<endl;
   return 0;
}


Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
c = list(map(int, input().split()))
d = list(map(int, input().split()))
s = [list(input()) for _ in range(h)]

c = [i-1 for i in c]
d = [i-1 for i in d]

t0 = [(0, 1), (0, -1), (1, 0), (-1, 0)]
t1 = []
for i in range(-2, 3):
    for j in range(-2, 3):
        t1.append((i, j))
for i in t0:
    t1.remove(i)
t1.remove((0, 0))

check = [[-1]*w for _ in range(h)]
q = deque()
q.appendleft((c[0], c[1], 0))

while q:
    y, x, b = q.pop()
    if x == d[1] and y == d[0]:
        print(b)
        exit()
    if check[y][x] == -1:
        check[y][x] = b
        for dy, dx in t0:
            ydy, xdx = y+dy, x+dx
            if (0 <= xdx < w) and (0 <= ydy < h):
                if s[ydy][xdx] == '.' and check[ydy][xdx] == -1:
                    q.append((ydy, xdx, b))
        for dy, dx in t1:
            ydy, xdx = y+dy, x+dx
            if (0 <= xdx < w) and (0 <= ydy < h):
                if s[ydy][xdx] == '.' and check[ydy][xdx] == -1:
                    q.appendleft((ydy, xdx, b+1))
print(-1)


Measured memory_bytes: 202220
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    string s; cin >> s;
    if( s[s.length() - 1] == 's')
    {
        cout << s << "es" << endl;
    }
    else
    {
        cout << s << "s" << endl;
    }
    return 0;    
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#define maxint 2147483647;
typedef long long ll;
void dump(int a[],int n)
{
  for (int codeTest = 0; codeTest < n; ++codeTest) {
    if (codeTest!=0)std::cout << " ";
    std::cout << a[codeTest];
  }
  std::cout << '\n';
}

ll c=0;
void merge(int *a,int left,int mid,int right) {
  int n1=mid-left,n2=right-mid;
  int i,j=0,k=0;
  int l[300000],r[300000];
  for (i = 0; i < n1; ++i) {l[i]=a[left+i];}
  for (i = 0; i < n2; ++i) {r[i]=a[mid+i];}
  l[n1]=maxint;r[n2]=maxint;
  for (i = left; i < right; ++i) {
    if (l[j]<r[k]) {
      a[i]=l[j];
      ++j;
    }else{
      a[i]=r[k];
      c+=n1+k-i+left;
      ++k;
    }
  }
}

void mergeSort(int *a,int left,int right) {
  int mid;
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
  }
}
int main() {
  int n;
  int a[500000];
  std::cin >> n;
  for (int i = 0; i < n; ++i) {std::cin >> a[i];}
  mergeSort(a,0,n);
  std::cout << c << '\n';
  return 0;
}



Measured memory_bytes: 4672
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29

int main(){
	string s, current, previous = "NULL";
	int ans = 0, cnt = 0, n;
	cin >> s;
	n = 0;
	while (true) {
		current.push_back(s[n]);
		if (n == s.size() - 1) {
			if (current != previous) cnt++;
			ans = max(cnt, ans);
			break;
		}
		if (previous != current) {
			cnt++;
			previous = current;
			current.clear();
		}
		n++;
	}
	n = s.size() - 1;
	current.clear();
	previous.clear();
	cnt = 0;
	while (true) {
		if (current.size()) {
			current[1] = current[0];
			current[0] = s[n];
		}
		else current[0] = s[n];
		if (!n) {
			if (current != previous) cnt++;
			ans = max(cnt, ans);
			break;
		}
		if (previous != current) {
			cnt++;
			previous = current;
			current.clear();
		}
		n--;
	}
	cout << ans;
}

Measured memory_bytes: 640
// rawatabhi14@gmail.com
// Abhinav Rawat
#include<bits/stdc++.h>
using namespace std;

string to_string(string s) {
    return '"' + s + '"';
}
string to_string(char ch) {
    string s(1, ch);
    return '\'' + s + '\'';
}
string to_string(const char *s) {
    return to_string((string)s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define f(i, x, n) for (int i = x; i < n; i++)
#define fr(i, n, x) for(int i=n; i>x; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int ll;
#define int ll
typedef pair<ll, ll> pll;
typedef vector< vector <ll> > matrix;
typedef vector<ll> vll;

const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 1e5 + 10;

int32_t main() {
    fast_io();
    int x, y; cin >> x >> y;
    if( y > x * 4 or y < x* 2){
        cout << "No" << endl;
    }else{
        if(y % 2) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;


bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}
struct type{
    int k, i, j;
};
signed main() 
{
    cout<<fixed<<setprecision(12);
    fastio;
    int n,k;
    cin>>n>>k;
    vi a(n);
    f(i,n)cin>>a[i];
    double cur=0;
    f(i,k)
    {
        cur+=(1+a[i])/(2.0);
    }
    double ans=cur;
    for(int i=k;i<n;i++)
    {
        cur-=(1+a[i-k])/(2.0);
        cur+=(1+a[i])/(2.0);
        ans=max(ans,cur);
    }
    cout<<ans<<endl;
    
    
    
}


Measured memory_bytes: 1792
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] A = new long[N];
    long WA = 0;
    for(int k = 0;k<N;k++){
      A[k]=(long)sc.nextInt();
      WA+=A[k];
      WA = WA%1000000007;
    }
    long re = 0;
    for(int i = 0;i<N;i++){
      WA-=A[i];
      if(WA<0){
        WA+=1000000007;
      }
      re += (WA*A[i])%1000000007;
      if(re>1000000007){
        re = re%1000000007;
      }
    }
    System.out.println(re);
  }
}

Measured memory_bytes: 61724
#include<stdio.h>
#include<math.h>

int main(void){
	int l,i,j,a[6],count;
	long n,tmp,max,min,b[20],f=0;
	
	scanf("%ld %d",&n,&l);
	
	while(1){
		
		if(n==0 && l==0)break;
		
		max=0;
		min=0;
		tmp=0;
		count=0;
		f=0;
		for(i=0;i<20;i++){
			b[i]=0;
		}
		
		for(i=0;i<l;i++){
			a[i]=0;
		}
		
		
		while(f!=1){
			
			max=0;
			min=0;
			
			//if(f==1)break;
			
			if(count==0){
				b[count]=n;
			}else{
			
			for(i=0;i<count;i++){
				if(n==b[i] || i>=19){
					
					printf("%d %ld %d\n",i,b[i],count-i);
					
					f=1;
					break;
				}
				
			}
			}
		
		for(i=0;i<l;i++){
			a[i]=n%10;
			n=n/10;
			//if(max<a[i]) max=a[i];
			//if(min>a[i]) min=a[i];
			
			//fprintf(fout,"%d\n",a[i]);
		}
		
		for(i=0;i<l-1;i++){
			for(j=i+1;j<l;j++){
				if(a[i]<a[j]){
					tmp=a[i];
					a[i]=a[j];
					a[j]=tmp;
				}
			}
		}
		
		for(i=0;i<l;i++){
			max+=a[i]*pow(10,(l-i-1));
			min+=a[i]*pow(10,i);
		}
		
		count++;
		
		n=max-min;
		
		b[count]=n;
		
		//fprintf(fout,"max=%ld, min=%ld\n",max,min);
		
		}
		
		scanf("%ld %d",&n,&l);
	}

	return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main() {
    string s;
    int num;
    cin >> s >> num;
    vector<string> ans;
    for(int i = 0; i < num; i++){
        string instr;
        cin >> instr;
        int a, b;
        cin >> a >> b;
        if(instr == "print"){
            string tmp;
            tmp = s.substr(a, b-a+1);
            //cout << ans << endl;
            ans.push_back(tmp);
        }
        else if(instr == "replace"){
            string rep;
            cin >> rep;
            s.replace(a, b-a+1, rep);
            //cout << s << endl;
        }
        else if(instr == "reverse"){
            reverse(s.begin()+a, s.begin()+(b+1));
            //cout << s << endl;
        }
    }

    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3220
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
int main()
{	
	int a,b;
	char x;
	scanf("%d %c %d",&a,&x,&b);
	if(x == 45) printf("%d",a - b);
	else printf("%d",a + b);
	return 0;
}

Measured memory_bytes: 256
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

const static sl HMAX = 80;
const static sl WMAX = 80;
const static sl AijMAX = 80;
const static sl M = (HMAX + WMAX) * AijMAX;

static sl H, W;
static vector<vector<sl>> Aij;
static vector<vector<sl>> Bij;
static vector<vector<vector<bool>>> dp;

void solve(void) {
  dp.resize(H, vector<vector<bool>>(W, vector<bool>(M)));
  dp[0][0][abs(Aij[0][0] - Bij[0][0])] = true;
  FOR0(i, H) {
    FOR0(j, W) {
      FOR0(k, M) {
        sl diff = abs(Aij[i][j] - Bij[i][j]);
        if ((i != 0 && dp[i - 1][j][k]) || (j != 0 && dp[i][j - 1][k])) {
          dp[i][j][k + diff] = true;
          dp[i][j][abs(k - diff)] = true;
        }
      }
    }
  }
  FOR0(k, M) {
    if (dp[H - 1][W - 1][k]) {
      cout << k << endl;
      break;
    }
  }
}

int main(void) {
  cin >> H >> W;
  Aij.resize(H, vector<sl>(W));
  Bij.resize(H, vector<sl>(W));
  FOR0(i, H) {
    FOR0(j, W) {
      cin >> Aij[i][j];
    }
  }
  FOR0(i, H) {
    FOR0(j, W) {
      cin >> Bij[i][j];
    }
  }
  solve();
  return 0;
}

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

int main(){
	int height[10];
	int i,j;

	for(i=0;i<10;i++){
		cin>>height[i];
	}


	

	do{
		j=0;
		for( i=0;i<10 - 1;i++ ){
			if( height[i] < height[i+1] ){
				int temp = height[i+1];
				height[i+1] = height[i];
				height[i] = temp;
				j++;
			}
		}
	}while(j!=0);
	
	for(i=0;i<3;i++){
		cout<<height[i]<<endl;
	}


}

Measured memory_bytes: 1164
#include <stdio.h>
#include <math.h>
#define _USE_MATH_DEFINES
#define EARTH_HANKEI 6378.1
 
int main(void) {
    double a,b,c,d;
    double ax1,ay1,ax2,ay2;
    double x1,y1,z1,x2,y2,z2;
    double cosine;
    double result;
    while(1) {
        scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
        if(a==-1 && b==-1 && c==-1 && d==-1)
			break;
        ax1=b*M_PI/180;
		ay1=a*M_PI/180;
        ax2=d*M_PI/180;
		ay2=c*M_PI/180;
        y1=cos(ay1);
		z1=sin(ay1);
        x1=y1*sin(ax1);
		y1=y1*cos(ax1);
        y2=cos(ay2);
		z2=sin(ay2);
        x2=y2*sin(ax2);
		y2=y2*cos(ax2);
        cosine=x1*x2+y1*y2+z1*z2;
        result=EARTH_HANKEI*acos(cosine);
        printf("%d\n",(int)floor(result+0.5));
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int i;

  for(i=0; i<N; i++){
    string a;
    cin >> a;
    if(a=="Y"){
      cout<<"Four"<<endl;
      break;
    }
  }
  if(i==N){
    cout<<"Three"<<endl;
  }

  return 0;
}

Measured memory_bytes: 256