akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    int n,sum=0;
    char str[20],str2[10];
    cin>>str2;
    cin>>n;
    for(int i=0;i<n;i++){
        memset(str,NULL,sizeof(str));
        cin>>str;
        strcat(str,str);
       // cout<<str<<endl;
        for(int x=0;x<strlen(str);x++){
            int len=strlen(str2);
            for(int j=0;j<len&&j<strlen(str);j++){
                if(str[j+x]!=str2[j]){
                    break;
                }
                if(j==len-1){
                    sum++;
                    x=strlen(str);
                }
            }
        }
    }
    cout<<sum<<endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
if (a % 2 == 1 && b % 2 == 1) {
  cout << "Odd" << endl;
}
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	string s;
	cin >> s;
	if(s == "ABC")cout << "ARC\n";
	else cout << "ABC\n";

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    string S;
    cin >> S;
    int A, B;
    A = ( S.at(0) - '0' ) * 10 + ( S.at(1) - '0' );
    B = ( S.at(2) - '0' ) * 10 + ( S.at(3) - '0' );
    if ( ( 1 <= A && A <= 12 ) && ( 1 <= B && B <= 12 ) ){
        cout << "AMBIGUOUS" << endl;
    }
    else if ( 1 <= A && A <= 12 ){
        cout << "MMYY" << endl;
    }
    else if ( 1 <= B && B <= 12 ){
        cout << "YYMM" << endl;
    }
    else cout << "NA" << endl;
    return 0;
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int r, g, b; cin >> r >> g >> b;

	int n = r*100+g*10+b;
	
	if(n%4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <map>


int main() {
	long long a, b, c, d;

	std::cin >> a >> b >> c >> d;

	if (b > d) {
		std::cout << 1 << std::endl;
	}
	else {
		std::cout << 0 << std::endl;
	}

	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
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 pair<int,int> pi;

int main(){

    int n,m;
    cin>>n>>m;
    rep(i,m){
        int tmp;
        cin>>tmp;
        n-=tmp;
    }
    cout<<max(-1,n)<<"\n";

    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void) {
	int S, h, m, s;
	scanf("%d", &S);
	h = S / 3600;
	S = S - h * 3600;
	m = S / 60;
	s = S % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}



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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
struct edge { int v, w; };
const int INF = INT_MAX / 2;
const int MOD = 1e9 + 7;
const ll e18 = 1e18;

void f(int N, vector<vector<int>>& a) {
	vector<vector<int>> A(N + 1, vector<int>(N + 1));
	rep(i, N) rep(j, N) A[i + 1][j + 1] = A[i + 1][j] + A[i][j + 1] - A[i][j] + a[i][j];
	a = A;
}

int g(vector<vector<int>>& A, int i1, int i2, int j1, int j2) {
	return A[i1][j1] - A[i1][j2] - A[i2][j1] + A[i2][j2];
}

int main() {
	int N, Q; cin >> Q >> N;
	vector<vector<int>> a(N * 4 + 1, vector<int>(N * 4 + 1)), b = a;
	while (Q--) {
		int i, j; string s; cin >> i >> j >> s;
		i %= N * 2, j %= N * 2;
		rep(x, 2) rep(y, 2) {
			int _i = i + x * (N * 2);
			int _j = j + y * (N * 2);
			if (s == "B") a[_i][_j]++;
			if (s == "W") b[_i][_j]++;
		}
	}
	f(N * 4, a), f(N * 4, b);
	int ma = 0;
	rep(i, N * 2) rep(j, N * 2) {
		int sum = 0;
		sum += g(a, i, i + N, j, j + N);
		sum += g(a, i + N, i + N * 2, j + N, j + N * 2);
		sum += g(b, i, i + N, j + N, j + N * 2);
		sum += g(b, i + N, i + N * 2, j, j + N);
		ma = max(ma, sum);
	}
	cout << ma << endl;
}


Measured memory_bytes: 188320
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

bool isP(string s) {
	for(int i = 0; i < s.size()/2; i++) {
		if(s[i]!=s[s.size()-i-1]) return false;
	}
	return true;
}

signed main() {
	EmiliaMyWife

	string s;
	cin >> s;
	bool ans = true;
	if((s.size()&1)^1) ans=false;
	ans&=isP(s);
	//cout << ans;
	if(ans) ans&=isP(s.substr(0, s.size()/2));
	if(ans) ans&=isP(s.substr(s.size()/2+1, s.size()/2));
	if(ans)cout << "Yes";
	else cout << "No";
	cout << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main (){
	int w,n,a,b;
	int c[31];
	cin>>w>>n;
	for(int i=1;i<=w;i++)c[i]=i;
	for(int i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		swap(c[a],c[b]);
	}
	for(int i=1;i<=w;i++){
		cout<<c[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
void dfs(int cur,int mx,string s){
	if(cur==n){
		cout<<s<<endl;
		return;
	}
	for(int i=0;i<=mx+1;i++){
		char c='a'+i;
		dfs(cur+1,max(mx,i),s+c);
	}
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	dfs(1,0,"a");
	return 0;
}
/*
aaa
aab
abc
*/

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  sort(v.begin(), v.end());
  vector <pair <ll, ll>> u(m);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    u.at(i) = make_pair(b, a);
  }
  sort(u.begin(), u.end());
  ll ans = 0;
  ll tmp1 = n-1, tmp2 = m-1;
  rep(i, n) {
    if (tmp2 < 0) {
      ans += v.at(tmp1);
      tmp1--;
    } else {
      if (v.at(tmp1) >= u.at(tmp2).first) {
        ans += v.at(tmp1);
        tmp1--;
      } else {
        ans += u.at(tmp2).first;
        u.at(tmp2).second--;
        if (u.at(tmp2).second == 0) {
          tmp2--;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void) {
	long long int L,R,i,j,tmp,ans=2020;
	scanf("%lld %lld",&L,&R);
	if(R-L>2019){
		printf("0");
	}else{
		for(i=L;i<R;i++){
			for(j=i+1;j<=R;j++){
				tmp=(i*j)%2019;
				if(ans>tmp){
					ans=tmp;
				}
			}
		}
		printf("%lld",ans);
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;


class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());

        var ret = 0L;
        for (var i = 1; i < n; i++)
        {
            ret += i;
        }

        Console.Write(ret);
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N,W;
	cin >> N >> W;
	vector<int> w(N), v(N);
	vector<vector<long long int>> dp(N + 1, vector<long long int>(100101,10000000000));
	for (int i = 0; i < N ; i++) {
		cin >> w.at(i) >> v.at(i);
	}
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 100100; j++) {
			if (j >= v[i]) {
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
			}
			dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
		}
	}
	long long int res = 0;
		for (int j = 0; j < 100100; j++) {
			if (dp[N][j] <= W) {
				res = j;
			}
		}
		cout << res << endl;
	return 0;
}

Measured memory_bytes: 80256
from collections import defaultdict
from collections import deque
#import time

def main():
    # Read stdin
    #start = time.clock()
    fl = input().split(" ")
    V = int(fl[0])
    E = int(fl[1])
    R = int(fl[2])
    # Adjacency list
    G = defaultdict(dict)
    for i in range(E):
        s, t, w = [int(x) for x in input().split(" ")]
        G[s][t] = w
    # initialized
    d = {}
    INF = float('inf')
    # INF = 10001
    for i in range(V):
        d[i] = INF
    d[R] = 0
    # deque is better than list aka double link list O(1) for pop head and append
    q = deque([R])
    while q:
        # u = heappop(q)
        u = q.popleft()
        for v in G[u].keys():
            if d[v] > d[u] + G[u][v]:
                d[v] = d[u] + G[u][v]
                # heappush(q, v[0])
                q.append(v)
    #end = time.clock() - start
    for k in range(V):
        if d[k] == float('inf'):
            print("INF")
        else:
            print(d[k])
    #print('Computation time : {}'.format(end))


if __name__ == '__main__':
    main()

Measured memory_bytes: 98996
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

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


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve()
{
    int x, y, z;
    cin >> x >> y >> z;
    x -= z;
    y += z;
    int ans = x / y;
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3624
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
ll a[100009];
ll cnt[100009];
int main()
{
    ll i,n,t,k,j,x=0,y=0,m,sum=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+= a[i];
        cnt[a[i]]++;

    }
    cin>>m;
    while(m--)
    {
        cin>>x>>y;
        if(cnt[x]==0)
        {
            cout<<sum<<endl;
            continue;
        }
        k  = y-x;
        sum+= k*cnt[x];
        cnt[y]+= cnt[x];
        cnt[x]  =0;
        cout<<sum<<endl;
    }
    return 0;
}



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

int main(){

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

    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0])
        cout << "YES\n";
    else cout << "NO\n";

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main() {
  int n,c = 0,d = 0;
  long long m;
  cin >> n;
  vector<long long> a(n);
  __int128_t sum = 1;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    if (sum * a[i] > 1000000000000000000){
      c++;
    }
    if (a[i] == 0){
      d++;
    }
    sum *= a[i];
  }
  if (c != 0 && d == 0){
    cout << "-1\n";
    return 0;
  }
  m = sum;
  cout << m << "\n";
  return 0;
}

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

#ifdef HELTHAZAR
#define dout if (true) cout
#else
#define dout if (false) cout
#endif

#define rep(i, from, to) for (ll i = from; i < ll(to); i++)
#define repn(i, from, to) for (ll i = from; i <= ll(to); i++)
#define repr(i, from, to) for (ll i = ll(to); i >= from; i--)
#define trav(a, x) for (auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<vector<ll> > vvi;

struct point {
    long long x, y;
};

bool cmp(point a, point b) {
    return a.x < b.x || a.x == b.x && a.y < b.y;
}
bool cw(point a, point b, point c) {
    return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y) < 0;
}

bool ccw(point a, point b, point c) {
    return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y) > 0;
}

vector<point> polygon_convex_hull(vector<point> v) {
    if (v.size() == 1)
        return v;
    sort(v.begin(), v.end(), &cmp);
    point p1 = v.front();
    point p2 = v.back();
    vector<point> up, down;
    up.push_back(p1);
    down.push_back(p1);
    for (int i = 1; i < v.size(); i++) {
        if (i == v.size() - 1 || cw(p1, v[i], p2)) {
            while (up.size() >= 2 && !cw(up[up.size() - 2], up[up.size() - 1], v[i]))
                up.pop_back();
            up.push_back(v[i]);
        }
        if (i == v.size() - 1 || ccw(p1, v[i], p2)) {
            while (down.size() >= 2 && !ccw(down[down.size() - 2], down[down.size() - 1], v[i]))
                down.pop_back();
            down.push_back(v[i]);
        }
    }
    vector<point> hull;
    for (int i = 0; i < up.size(); i++)
        hull.push_back(up[i]);
    for (int i = down.size() - 2; i > 0; i--)
        hull.push_back(down[i]);
    return hull;
}

const double PI = acos(-1.0);

double sqr(double a) {
    return a * a;
}

double point_dis(point a, point b) {
    return sqrt((double) sqr(b.x - a.x) + sqr(b.y - a.y));
}

double point_dot(point a, point b, point c) {
    return (b.x - a.x) * (c.x - a.x) + (b.y - a.y) * (c.y - a.y);
}

double point_angle(point a, point b, point c) {
    return acos(point_dot(a, b, c) / (point_dis(a, b) * point_dis(a, c)));
}

void solve() {
	int n;
	cin >> n;
	vector<point> v(n);
	map<pi, int> mp;
	rep(i, 0, n) {
		cin >> v[i].x >> v[i].y;
		mp[{v[i].x, v[i].y}] = i;
	}
	vector<point> hull = polygon_convex_hull(v);
	int m = sz(hull);
	vector<double> ans(n, 0);
	if (m == 2) {
		rep(i, 0, m) {
			int ind = mp[{hull[i].x, hull[i].y}];
			ans[ind] = 0.5;
		}
	}
	else {
		rep(i, 0, m) {
			int l = (i + m - 1) % m, r = (i + 1) % m;
			double ang = fabs(PI - fabs(point_angle(hull[i], hull[l], hull[r]))) / (2.0 * PI);
			int ind = mp[{hull[i].x, hull[i].y}];
			ans[ind] = ang;
		}
	}
	rep(i, 0, n)
		printf("%0.12lf\n", ans[i]);
}

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

	solve();
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
D=list(map(int,input().split()))

temp=[]
for i in range(10):
    if D.count(i)==0:
        temp.append(i)
D=temp[:]
preK=0
K=10-K

opt=D[:]
ans=10**18

for item in opt:
    if item>=N:
        ans=min(ans,item)

for t in range(5):
    for d in D:
        for i in range(preK,K):
            if opt[i]==0:
                pass
            else:
                num=int(str(opt[i])+str(d))
                if num>=N:
                    ans=min(ans,num)
                else:
                    opt.append(num)
    preK,K=K,len(opt)        
print(ans)


Measured memory_bytes: 3188
a = gets.strip
cnt="No"

cnt = "Yes" if a[0]==a[1] && a[2]==a[3] && a[0]!=a[2]
cnt = "Yes" if a[0]==a[2] && a[1]==a[3] && a[0]!=a[1]
cnt = "Yes" if a[0]==a[3] && a[1]==a[2] && a[0]!=a[1] 

puts cnt


Measured memory_bytes: 3836
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;
using llint = long long int;

int n, m;
vector<vector<int>> graph;

vector<bool> marked;
vector<int> nodes;

llint a, b, c, k;

int main()
{
  cin >> a >> b >> c >> k;
  llint ans = a - b;
  if (k % 2 != 0)
  {
    ans *= -1;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef complex<double> Point;
typedef vector<Point> Polygon;
const double eps = 1e-10;

double cross(const Point &a,const Point &b)
{
    return imag(b*conj(a));
}

double getArea(const Polygon &g)
{
    int sz=g.size();
    double area=0;
    for(int i=0;i<sz;i++)
    {
        area+=cross(g[i],g[(i+1)%sz]);
    }

    return abs(area)/2.0;
}

int ccw(Point a,Point b,Point c)
{
    c-=a;b-=a;
    a=c*conj(b);
    if(a.imag()>0) return 1;
    if(a.imag()<0) return -1;
    if(a.real()<0) return 2;
    if(abs(c)>abs(b)) return -2;
    return 0;
}

Point crossPoint(Point a,Point b,Point c,Point d)
{
    Point ac=c-a,ab=b-a;
    Point tmp=ac*conj(ab);
    double d1=tmp.real()/abs(ab);
    double d2=abs(tmp.imag()/abs(ab));
    Point cd=d-c;
    tmp=cd*conj(ab);
    d2*=tmp.real()/abs(tmp.imag());
    return a+ab*(d1+d2)/abs(ab);
}

Polygon cutPolygon(const Polygon &g,Point a,Point b)
{
    Polygon rs;
    int sz=g.size();
    for(int i=0;i<sz;i++)
    {
        Point A=g[i],B=g[(i+1)%sz];
        if(ccw(a,b,A) != -1) rs.push_back(A);
        if(ccw(a,b,A)*ccw(a,b,B)==-1) rs.push_back(crossPoint(a,b,A,B));
    }
    return rs;
}

double getCutArea(const Polygon &g,Point a,Point b)
{
    Polygon half=cutPolygon(g,a,b);
    return getArea(half);
}

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

    int n;
    cin>>n;
    Polygon g;
    for(int i=0;i<n;i++)
    {
        double x,y;
        cin>>x>>y;
        g.push_back(Point(x,y));
    }
    int q;
    cin>>q;
    while(q--)
    {
        double x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        cout<<setprecision(10)<<fixed<<getCutArea(g,Point(x1,y1),Point(x2,y2))<<endl;;
    }

    return 0;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;


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

	ll N;
	cin >> N;

	vector<ll> A(N), B(N);
	rep(i, N) {
		cin >> A[i] >> B[i];
	}

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());

	if (N % 2 == 0) {
		cout << B[N / 2 - 1] + B[N / 2] - A[N / 2 - 1] - A[N / 2] + 1 << endl;
	}
	else {
		cout << B[N / 2] - A[N / 2] + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc044_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S;
  cin >> S;

  map<char, int> m;
  rep(i, S.size()) {
    m[S[i]] += 1;
  }

  bool ok = true;
  for (auto kv : m) {
    ok &= kv.second % 2 == 0;
  }

  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
n=int(input())
newlist = list(map(int, input().split()))

switch=0
counter=0
mazu=newlist[0]
if newlist[0]>=0:
    seihu=1
else:
    seihu=-1
konzai=0

for nl in newlist:
    if mazu!=nl:
        switch=1

if switch==1:
    wa=0
    list2=[]
    for nl in range(n):
        list2.append([newlist[nl], abs(newlist[nl])])
        if seihu*newlist[nl]<0:
            konzai=1
            numb=nl
            numba=newlist[numb]
    if konzai==1:
        wa=0
        for nl in range(n):
            wa+=abs(newlist[nl])
        print(wa)
        now=newlist[numb]
        #print(newlist)
        newlist.remove(numba)
        #print(newlist)
        #print(now,newlist[0])
        #print('d', now, newlist[0], newlist[1])
        if newlist[1]>0:
            if now>=0:
                #now*=-1
                print(newlist[0], now)
            else:
                #now*=-1
                print(now,newlist[0])
        else:
            if now>=0:
                print(now, newlist[0])
            else:
                print(newlist[0], now)
            
        now=abs(now)+abs(newlist[0])
        if newlist[1]>0:
            now=now*(-1)
        for xi in range(n-3):
            #print('d', now, newlist[xi+1], newlist[xi+2])
            if newlist[xi+2]>0:
                if now>=0:
                    print(newlist[xi+1], now)
                else:
                    print(now, newlist[xi+1])
                now=-abs(now)-abs(newlist[xi+1])
            else:
                if now>=0:
                    print(now, newlist[xi+1])
                else:
                    print(newlist[xi+1], now)
                now=abs(now)+abs(newlist[xi+1])
        if newlist[-1]>0:
            print(newlist[-1], now)
        else:
            print(now, newlist[-1])
    elif seihu==1:
        newlist=sorted(newlist)
        wa=0
        for nl in range(n):
            wa+=abs(newlist[nl])
        wa-=newlist[0]*2
        print(wa)
        print(newlist[0], newlist[1])
        now=newlist[0]-newlist[1]
        for ll in range(n-2):
            if counter==n-3:
                print(newlist[ll+2], now)
                now=-(abs(now)+abs(newlist[ll+2]))
            else:
                print(now, newlist[ll+2])
                now=-(abs(now)+abs(newlist[ll+2]))
            counter+=1
    elif seihu==-1:
        newlist=sorted(newlist, reverse=True)
        wa=0
        for nl in range(n):
            wa+=abs(newlist[nl])
        wa+=newlist[0]*2
        print(wa)
        print(newlist[0], newlist[1])
        now=newlist[0]-newlist[1]
        for ll in range(n-2):
            if counter==n-3:
                print(now, newlist[ll+2])
                now=(abs(now)+abs(newlist[ll+2]))
            else:
                print(now, newlist[ll+2])
                now=(abs(now)+abs(newlist[ll+2]))
            counter+=1
    
else:
    print(abs(mazu*(len(newlist)-2)))
    for i in range(len(newlist)-2):
        print(mazu*(1-i), mazu)
    if mazu>=0:
        print(mazu, mazu*(3-len(newlist)))
    else:
        print(mazu*(3-len(newlist)), mazu)

Measured memory_bytes: 22264
# = int(input())
# = str(input())
X, K, D = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

if X == 0:
    ans = [D, 0]

elif X>0:
    if X == D:
        ans = [0, D]
    elif X-D<0:
        ans = [D-X, X]
    else:
        if X-D*K>=0:
            print(X-D*K)
            exit()
        else:
            plus = X%D
            minus = D-X%D
            if (X//D)%2 == 1:
                ans = [plus, minus]
            else:
                ans = [minus, plus]

else:
    T = -1*X
    if T == D:
        ans = [0, T]
    elif T-D<0:
        ans = [D-T, T]
    else:
        if T-D*K>=0:
            print(T-D*K)
            exit()
        else:
            plus = T%D
            minus = D-T%D
            if (T//D)%2 == 1:
                ans = [plus, minus]
            else:
                ans = [minus, plus]

if K%2 == 1:
    print(ans[0])
else:
    print(ans[1])


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

using namespace std;
int n,a,b;
int main()
{
    scanf("%d%d%d",&a,&b,&n);
    int t=a*b;
    if(t>n)
        printf("%d\n",n);
    else
        printf("%d\n",t);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < (N); i++)  

int main()
{
    // 入力
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long result;

    result = a*c;

    if (result<a*d){
        result = a*d;
    }
    if (result<b*d){
        result = b*d;
    }
    if (result<b*c){
        result = b*c;
    }

    cout << result << endl;
    return 0;  
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll a, b, n, ans = 0, x;
  cin >> n >> a >> b;
  cin >> x;
  ll now = x;
  rep(i, n - 1)  cin >> x, ans += min((x - now) * a, b), now = x; 

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


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a[][];
		int count;

		a = new int[12][12];
		while (sc.hasNext()) {
			count = 0;
			for (int i = 0; i  <12; i++) {
				String str = sc.next();
				for (int j = 0; j < 12; j++) {
					a[i][j] = str.charAt(j) - '0' - 1;
				}
			}
			while (check(a)) {
				for (int i = 0; i < 12; i++) {
					for (int j = 0; j < 12; j++) {
						if (a[i][j] == 0) {
							count++;
							expand(a, count, i, j);
						}
					}
				}
			}
			System.out.println(count);
		}
	}

	public static boolean check(int a[][]) {
		for (int i = 0; i < 12; i++) {
			for (int j = 0; j < 12; j++) {
				if (a[i][j] == 0) {
					return true;
				}
			}
		}
		return false;
	}

	public static void expand(int a[][], int num, int i, int j) {
		if (0 <= i && i < 12 && 0 <= j && j < 12 && a[i][j] == 0) {
			a[i][j] = num;
		} else {
			return ;
		}
		expand(a, num, i - 1, j);
		expand(a, num, i + 1, j);
		expand(a, num, i, j - 1);
		expand(a, num, i, j + 1);
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	int n; cin >> n;
	vi a(n);
	map<int, int> mp;
	rep(i, n) {
		cin >> a.at(i);
		mp[a.at(i)]++;
	}
	sort(all(a));
	int ans = 0;
	int tmp;
	for (int x = a.at(0); x <= a.at(a.size() - 1); x++) {
		tmp = 0;
		tmp += mp[x - 1] + mp[x] + mp[x + 1];
		ans = max(tmp, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  string s;
  ll k;
  cin >> s >> k;
  ll same = 0;
  if (s.size() == 1) {
    cout << k / 2 << endl;
    return;
  }
  REP(i, s.size() - 1) {
    if (s[i] == s[i + 1]) {
      same++;
      i++;
    }
  }
  int fc = 0, lc = 0;
  REP(i, s.size()) {
    if (s[i] == s[0]) {
      fc++;
    } else {
      break;
    }
  }
  RREP(i, s.size()) {
    if (s[i] == s.back()) {
      lc++;
    } else {
      break;
    }
  }
  if (fc == s.size()){
    cout << fc * k / 2 << endl;
  } else if (s[0] == s.back() && fc % 2 && lc % 2) {
    cout << same * k + k - 1 << endl;
  } else {
    cout << same * k << endl;
  }
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXSIZE=10000020;
int bufpos;
char buf[MAXSIZE];
#define NEG 0
void init(){
    #ifdef LOCAL
        freopen("D.txt","r",stdin);
    #endif
    buf[fread(buf,1,MAXSIZE,stdin)]='\0';
    bufpos=0;
}
#if NEG
int readint(){
    bool isneg;
    int val=0;
    for(;!isdigit(buf[bufpos]) && buf[bufpos]!='-';bufpos++);
    bufpos+=(isneg=buf[bufpos]=='-');
    for(;isdigit(buf[bufpos]);bufpos++)
        val=val*10+buf[bufpos]-'0';
    return isneg?-val:val;
}
#else
int readint(){
    int val=0;
    for(;!isdigit(buf[bufpos]);bufpos++);
    for(;isdigit(buf[bufpos]);bufpos++)
        val=val*10+buf[bufpos]-'0';
    return val;
}
#endif
char readchar(){
    for(;isspace(buf[bufpos]);bufpos++);
    return buf[bufpos++];
}
int readstr(char* s){
    int cur=0;
    for(;isspace(buf[bufpos]);bufpos++);
    for(;!isspace(buf[bufpos]);bufpos++)
        s[cur++]=buf[bufpos];
    s[cur]='\0';
    return cur;
}
int dp[302][302][302];
char s[302];
inline void relax(int &x,int y){
    if (x>y)
        x=y;
}
int main(){
    init();
    int n=readstr(s+1),m=readint();
    memset(dp,0x3f,sizeof(dp));
    for(int i=0;i<=n+1;i++){
        memset(dp[i][i],0,sizeof(dp[i][i]));
        if (i)
            memset(dp[i][i-1],0,sizeof(dp[i][i-1]));
    }
    for(int len=2;len<=n;len++)
        for(int i=1;i<=n;i++){
            int j=i+len-1;
            if (j>n)
                break;
            for(int k=0;k<=m;k++){
                if (k)
                    dp[i][j][k]=dp[i+1][j-1][k-1];
                if (s[i]==s[j])
                    relax(dp[i][j][k],dp[i+1][j-1][k]);
                relax(dp[i][j][k],dp[i+1][j][k]+1);
                relax(dp[i][j][k],dp[i][j-1][k]+1);
            }
        }
    printf("%d",n-dp[1][n][m]);
}

Measured memory_bytes: 108800
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<map>
#include<utility>
#include<climits>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define LSTAGE 1
#define max 10000007


bool binary(ll r[], ll st, ll ed,const ll& key, ll& m)
{
    ll mid;
    while(st<=ed)
    {
        mid = (st+ed)/2;
        if(r[mid]==key)
        {
            m = mid;

            return true;
        }
        else if(r[mid]< key)
        {
            ed = mid - 1;
        }
        else
            st = mid + 1;
    }
    m = 0;
//    cout <<"False\n";
    return false;
}

int main()
{
    int n , k;
    cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr+n);

    int m = INT_MAX;
    for(int  i= n - 1; i >= k-1; i--) m = min(m,arr[i]-arr[i-k+1]);
    cout << m;



}


Measured memory_bytes: 640
N = int(input())
S = input()

e = [0 for _ in range(N)]
w = [0 for _ in range(N)]

for i in range(N-1):
    e[i+1] = e[i] + (S[i] == "W")
for i in range(1, N)[::-1]:
    w[i-1] = w[i] + (S[i] == "E")

ans = N
for i in range(N):
    ans = min(ans, e[i] + w[i])
print(ans)


Measured memory_bytes: 33160
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
  Scanner sc  = new Scanner(System.in);
  int a       = sc.nextInt();
  int b       = sc.nextInt();
  int area    = a*b;
  int length  = 2*(a+b);
  System.out.println(area + " " + length);
  }
}



Measured memory_bytes: 26052
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int main()
{ 
    int n;
    cin>>n;
    if(n%2==0){n=n/2;}
    else{n=n/2+1;}

    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 764
#include<iostream>

using namespace std;

int main(){
    
    int x,y;
    int w,h,r;
    
    cin>>x>>y>>w>>h>>r;
    
    if(w+r>x || h+r>y ||w-r<0 ||h-r<0) {
        cout<<"No"<<endl;
        
    }else{
        cout<<"Yes"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

namespace _{struct _{_(){ // initialize
  cin.tie(0); ios::sync_with_stdio(false);
}}_;}
template <typename T, size_t size>
inline size_t len(const T (&)[size]) { return size; }
#define println(s) cout << s << '\n';
#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()

#define MAX_A 17
#define MAX_B 17

int a, b; // 1 <= a, b <= 16
int n;    // 1 <= n <= 40
bool ok[MAX_A+1][MAX_B+1];
// evaluate score with starting point (x, y)
int eval(int x, int y) {
  // cout << "("<<x<<", " << y << ")"<<endl;
  // goal
  if (x == (a-1) && y == (b-1)) return 1;
  if (x >= a || y >= b) return 0;

  bool up    = ok[y+1][x];
  bool right = ok[y][x+1];
  if (up && right) return eval(x+1, y) + eval(x, y+1);
  if (!up && !right) return 0; // stop
  if (up)    return eval(x, y+1);
  if (right) return eval(x+1, y);

  return INT_MIN;
}
int main() {
  while (true) {
    // input
    cin >> a >> b;
    if (a == 0 && b == 0) break;
    cin >> n;
    rep(y, b) {
      rep(x, a) {
        ok[y][x] = true;
      }
    }
    rep(i, n) {
      int x, y;
      cin >> x >> y;
      ok[y-1][x-1] = false;
    }
    /*
    for (int y=b-1; y>=0; y--) {
      rep(x, a) {
        cout << (ok[y][x]?"o":"x");
      }
      cout << endl;
    }
    */
    //
    cout << eval(0, 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
# -*- coding: utf-8 -*-
S = input()

s_frq_dict = {'a': 0, 'b': 0, 'c': 0}
for s in S:
    s_frq_dict[s] += 1

frqs = list(s_frq_dict.values())
if max(frqs) - min(frqs) <= 1:
    print('YES')
else:
    print('NO')





Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
string s;
bool can[500003],fr[500003],bk[500003];
long long num[500003],cntt,hashes[500003],pw[500003];
bool cmp(long long a,long long b,long long x,long long y){
	long long fr=(hashes[b]-hashes[a]+mod)%mod;
	long long sc=(hashes[y]-hashes[x]+mod)%mod;
	if(fr*pw[x]%mod==sc*pw[a]%mod)return 1;
	return 0;
}
int main(){
	pw[0]=1;
	for(long long i=1;i<500003;i++)pw[i]=pw[i-1]*26%mod;
	cin>>s;long long y=s.size();
	hashes[0]=0;
	for(long long i=1;i<=s.size();i++)
		hashes[i]=(hashes[i-1]+(s[i-1]-'a')*pw[i-1])%mod;
	bool bad=1;
	for(long long i=1;i<s.size();i++)
		if(s[i]!=s[i-1])
			bad=0;
	if(bad){cout<<s.size()<<endl<<1;return 0;}
	long long x=s.size(),cnt=2;
	vector<long long>v;
	while(cnt<=x){
		if(x%cnt==0&&y/cnt!=1)v.push_back(cnt);
		cnt++;
	}bad=0;
	for(long long i=0;i<v.size();i++){
		bool good=0;
		for(long long j=v[i];j+v[i]<=s.size();j+=v[i])
			if(!cmp(0,v[i],j,j+v[i]))
				good=1;
		if(!good)bad=1;
	}
	if(!bad){cout<<1<<endl<<1;return 0;}
	cout<<2<<endl;
	memset(fr,1,sizeof(fr));
	for(long long i=1;i<s.size();i++)
		for(long long j=i;j+i<=s.size();j+=i){
			if(!cmp(0,i,j,j+i))
				can[i]=1;
			fr[j+i-1]&=can[i];
		}
	reverse(s.begin(),s.end());
	memset(can,0,sizeof(can));
	memset(bk,1,sizeof(bk));
	for(long long i=1;i<=s.size();i++)
		hashes[i]=(hashes[i-1]+(s[i-1]-'a')*pw[i-1])%mod;
	for(long long i=1;i<s.size();i++)
		for(long long j=i;j+i<=s.size();j+=i){
			if(!cmp(0,i,j,j+i))
				can[i]=1;
			bk[j+i-1]&=can[i];
		}
	long long res=0;
	for(long long i=0;i<s.size()-1;i++)res+=(fr[i]&bk[s.size()-2-i]);
	cout<<res;
}

Measured memory_bytes: 12036
#include <stdio.h>
#define NIL -1

struct node{
  int parent, left, right;
};
struct node t[25];

void preorder(int);
void inorder(int);
void postorder(int);

int main(){

  int n, vec, left ,right, root;
  int i;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    t[i].parent =t[i].left =t[i].right = NIL;
  }

  for(i=0; i<n; i++){
    scanf("%d %d %d", &vec, &left, &right);

    t[vec].left=left; t[vec].right=right;

    if(left!=NIL) t[left].parent=vec;
    if(right!=NIL) t[right].parent=vec;
  }
  for(i=0; i<n; i++){
    if(t[i].parent == NIL) root=i;
  }
  printf("Preorder\n");
  preorder(root);
  printf("\nInorder\n");
  inorder(root);
  printf("\nPostorder\n");
  postorder(root);
  printf("\n");
  
  return 0;

}
void preorder(int x){
  if(x==NIL) return;

  printf(" %d", x);
  preorder(t[x].left);
  preorder(t[x].right);

}
void inorder(int x){
  if(x==NIL) return ;

  inorder(t[x].left);
  printf(" %d", x);
  inorder(t[x].right);
}
void postorder(int x){
  if(x==NIL) return ;

  postorder(t[x].left);
  postorder(t[x].right);
  printf(" %d", x);
}



Measured memory_bytes: 2132
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
#define Mod = 1e9 + 7;
#define mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
void spsp(vector<ll>&v) {
	for (int i = 0; i < v.size(); i++) {
		printf("%lld%s", v[i], (i == v.size() - 1 ? "\n" : " "));
	}
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int n;
	vector<H>a;
	cin >> n;
	int mx = -Inf, mn = Inf;
	for (int i = 0; i < n; i++) {
		int u, v;
		cin >> u >> v;
		a.push_back(H{ --u,v });
		chmax(mx, a[i].x);
		chmin(mn, a[i].y);
	}
	int ans = 0;
	for (auto z : a) {
		chmax(ans, max(0ll, mn - mx) + z.y - z.x);
	}
	vector<H>v;
	for(int i=0;i<n;i++){
		int c = max(0ll, mn - a[i].x);
		int d = max(0ll, a[i].y - mx);
		v.push_back(H{ d, -c });
	}
	sort(all(v));
	int w = inf;
	for(int i=0;i<n;i++){
		auto z = v[i];
		z.y = -z.y;
		if (i) chmax(ans, w + z.x);
		chmin(w, z.y);
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

int main(){
	int x, y;
	cin >> x >> y;
	if(x * 4 >= y && y >= x * 2 && y % 2 == 0) cout << "Yes" << '\n';
	else cout << "No" << '\n';
}


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

int main() {
  int n, k, c = 0;
  cin >> n >> k;
  int a[n];
  rep(i, n) cin >> a[i];
  while (1) {
    if ((n - 1) <= 0) break;
    n -= k - 1;
    c++;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>

using namespace std;

bool sym(string s)
{
	for(int i=0;i<s.length()/2;i++)
	{
		if(s[i]!=s[s.length()-1-i])return false;
	}
	return true;
}

int main(void)
{
	vector<string> s;
	while(1)
	{
		string t;
		cin>>t;
		if(cin.eof())break;
		s.push_back(t);
	}
	int ans=0;
	for(int i=0;i<s.size();i++)
	{
		if(sym(s[i]))ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1196
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int main(){

	int a, b, c;

	double S, L, h, d;

	cin >> a >> b >> c;


	d = ( acos( -1.0) * c) / 180.0;

	S = a * b * sin(d) / 2.0;

	L = a + b + sqrt( a * a + b * b - 2 * a * b * cos(d));

	h = b * sin(d);


	printf( "%1f\n%1f\n%1f\n", S ,L, h);

	return 0;

}

Measured memory_bytes: 1196
N = int(input())
A = list(map(int, input().split()))
B = map(int, input().split())

ans = 0
for i, b in enumerate(B):
    if b >= A[i]:
        ans += A[i]
        b -= A[i]
        A[i] = 0
        if b >= A[i+1]:
            ans += A[i+1]
            A[i+1] = 0
        else:
            ans += b
            A[i+1] -= b
    else:
        ans += b

print(ans)

Measured memory_bytes: 16212
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define int long long
using namespace std;
const int INF = 10000000000000;//5000000000000000

signed main() {
	int N;
	cin >> N;
	vector<int> house(N);
	for (int i = 0; i < N; i++) cin >> house[i];
	sort(house.begin(), house.end());
	cout << house[N - 1] - house[0] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <regex>

using namespace std;

int main(void) {
    string s;
    cin >> s;
    if (regex_search(s, regex("^(dream|dreamer|erase|eraser)+$"))) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 39808
#include <iostream>

using namespace std;

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

  int W, a, b;
  cin >> W >> a >> b;

  if (a + W < b) {
    cout << b - (a + W) << endl;
  } else if (b + W < a) {
    cout << a - (b + W) << endl;
  } else {
    cout << "0" << endl;
  }

  return 0;
}


Measured memory_bytes: 256