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

using namespace std;
int n,cnt[4];

int idx(char a) {
	if(a=='A')
	  return 0;
	if(a=='W')
	  return 1;
	if(a=='T')
	  return 2;
	if(a=='R')
	  return 3;
}

int main() {
	cin>>n;
	while(n--) {
		string a;
		cin>>a;
		cnt[idx(a[0])]++;
	}
	printf("AC x %d\n",cnt[idx('A')]);
	printf("WA x %d\n",cnt[idx('W')]);
	printf("TLE x %d\n",cnt[idx('T')]);
	printf("RE x %d\n",cnt[idx('R')]);
	return 0;
}


Measured memory_bytes: 3700
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cctype>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

inline char gc() {
    static const int L = 233333;
    static char sxd[L], *sss = sxd, *ttt = sxd;
    if (sss == ttt) {
        ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
        if (sss == ttt) {
            return EOF;
        }
    }
    return *sss++;
}

#ifndef _AT_HOME
#define dd c = gc()
#else
#define dd c = getchar()
#endif
inline char readalpha() {
    char dd;
    for (; !isalpha(c); dd);
    return c;
}

inline char readchar() {
    char dd;
    for (; c == ' '; dd);
    return c;
}

template <class T>
inline bool read(T& x) {
    bool flg = false;
    char dd;
    x = 0;
    for (; !isdigit(c); dd) {
        if (c == '-') {
            flg = true;
        } else if(c == EOF) {
            return false;
        }
    }
    for (; isdigit(c); dd) {
        x = (x * 10) + (c ^ 48);
    }
    if (flg) {
        x = -x;
    }
    return true;
}
#undef dd

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    if (x < 10) {
        putchar(x | 48);
        return;
    }
    write(x / 10);
    putchar((x % 10) | 48);
}

template <class T>
inline void writesp(T x) {
    write(x);
    putchar(' ');
}

template <class T>
inline void writeln(T x) {
    write(x);
    puts("");
}

#define lowbit(x) (x & -x)

namespace dfcmd {

    typedef long long LL;
    typedef unsigned long long ULL;

    const int maxn = 250005;
    const ULL bse = 233;

    int n;
    char s[maxn];
    map<ULL, int> mp;
    ULL f[maxn], g[maxn];

    int Main() {
        scanf("%d%s", &n, s + 1);
        ULL inv = 1, xx = bse;
        for (int i = 1; i <= 63; ++i) {
            inv = inv * xx;
            xx = xx * xx;
        }
        mp.clear();
        // cout << bse << ' ' << inv << ' ' << bse * inv << endl;
        f[0] = 0, g[0] = 1;
        for (int i = 1; i <= n; ++i) {
            f[i] = f[i - 1], g[i] = g[i - 1];
            switch (s[i]) {
                case '+':
                    f[i] += g[i];
                    break;
                case '-':
                    f[i] -= g[i];
                    break;
                case '<':
                    g[i] *= inv;
                    break;
                case '>':
                    g[i] *= bse;
                    break;
                default:
                    puts("dfcmd");
            }
            mp[f[i]]++;
        }
        LL ans = 0;
        for (int i = 1; i <= n; ++i) {
            ans += mp[f[n] * g[i - 1] + f[i - 1]];
            mp[f[i]]--;
        }
        writeln(ans);
        return 0;
    }
}

int main() {
    return dfcmd::Main();
}


Measured memory_bytes: 39060
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x= sc.nextLong();
        long happinessCount = 0;
        while (x>4){
            if(x>=500){
                happinessCount += 1000;
                x -= 500;
            }else {
                happinessCount += 5;
                x -= 5;
            }
        }
        System.out.println(happinessCount);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cmath>
#include<map>

using namespace std;

int main(){

	int A;
	int B;
	int X;

	cin >> A >> B >> X;

	if(X < A){
		cout << "NO";
		return 0;
	}

	if(X > A + B){
		cout << "NO";
	}else{
		cout << "YES";
	}


    return 0;

}

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

constexpr int INF = 1e9;

int d[4][11][100][100];

int main() {
    int N, M, A;
    cin >> N >> M >> A;
    vector<string> v(N);
    int sy, sx, gy, gx;
    for(int i=0; i<N; ++i) {
        cin >> v[i];
        for(int j=0; j<M; ++j) {
            if(v[i][j] == 'S') {
                sy = i;
                sx = j;
            }
            if(v[i][j] == 'G') {
                gy = i;
                gx = j;
            }
        }
    }
    for(int i=0; i<4; ++i) {
        for(int j=0; j<11; ++j) {
            for(int k=0; k<100; ++k) {
                for(int l=0; l<100; ++l) {
                    d[i][j][k][l] = INF;
                }
            }
        }
    }
    d[2][0][sy][sx] = 0;
    using state = tuple<int, int, int, int, int>;
    priority_queue<state, vector<state>, greater<state>> que;
    que.push(make_tuple(0, 2, 0, sy, sx));
    // 0: N, 1: E, 2: S, 3: W
    // 0: straight, 1: right, 2: left
    constexpr int dx[4][3] = {{0, 1, -1}, {1, 0, 0}, {0, -1, 1}, {-1, 0, 0}};
    constexpr int dy[4][3] = {{-1, 0, 0}, {0, 1, -1}, {1, 0, 0}, {0, -1, 1}};
    constexpr int P[4][3] = {{0, 0, 1}, {0, 1, 0}, {0, 0, 1}, {0, 1, 0}};
    constexpr int Q[4][3] = {{0, 1, 0}, {0, 0, 1}, {0, 1, 0}, {0, 0, 1}};
    while(!que.empty()) {
        int qcnt, dir, pcnt, y, x;
        tie(qcnt, dir, pcnt, y, x) = que.top();
        que.pop();
        if(d[dir][pcnt][y][x] < qcnt) {
            continue;
        }
        for(int i=-1; i<=1; ++i) {
            if(y == sy && x == sx && i != 0) {
                continue;
            }
            int j = (i + 3) % 3;
            int nqc = d[dir][pcnt][y][x] + Q[dir][j], npc = pcnt + P[dir][j];
            int ny = y + dy[dir][j], nx = x + dx[dir][j];
            int nd = (dir + i + 4) % 4;
            if(npc > A || nqc > A || ny < 0 || N <= ny || nx < 0 || M <= nx || v[ny][nx] == '#' || nd == 0 && v[ny][nx] == 'S') {
                continue;
            }
            if(d[nd][npc][ny][nx] > nqc) {
                d[nd][npc][ny][nx] = nqc;
                que.push(make_tuple(d[nd][npc][ny][nx], nd, npc, ny, nx));
            }
        }
    }
    int res = INF;
    for(int i=0; i<4; ++i) {
        for(int j=0; j<11; ++j) {
            res = min(res, d[i][j][gy][gx] + j);
        }
    }
    cout << (res == INF ? -1 : res) << endl;
}


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

std::vector<std::vector<int>> init_square(int width, int height) {
        std::vector<std::vector<int>> square;
        square.resize(width);
        for (auto &block: square) {
                block.resize(height);
                for (int j = 0; j < height; j++) {
                        block[j] = 0;
                }
        }
        return square;
}

void paint(std::vector<std::vector<int>> &square, int width, int height) {
        int x = 0;
        int y = 0;
        int a = 0;
        while (std::cin >> x && std::cin >> y && std::cin >> a) {
                switch (a) {
                case 1:
                        for (int i = 0; i <= x - 1; i++) {
                                for (int j = 0; j < height; j++) {
                                        square[i][j] = 1;
                                }
                        }
                        break;
                case 2:
                        for (int k = width - 1; k >= x; k--) {
                                for (int l = 0; l < height; l++) {
                                        square[k][l] = 1;
                                }
                        }
                        break;
                case 3:
                        for (int m = 0; m < width; m++) {
                                for (int n = 0; n < y; n++) {
                                        square[m][n] = 1;
                                }
                        }
                        break;
                case 4:
                        for (int o = 0; o < width; o++) {
                                for (int p = height - 1; p >= y; p--) {
                                        square[o][p] = 1;
                                }
                        }
                        break;
                }
        }
}

int calc_white(std::vector<std::vector<int>> const &square) {
        int result = 0;
        for (auto &block: square) {
                for (int i = 0; i < block.size(); i++) {
                        if (block[i] == 0) {
                                result++;
                        }
                }
        }
        return result;
}


int main(int argc, char *argv[]) {
        int width = 0;
        int height = 0;
        int num_of_point = 0;

        std::cin >> width;
        std::cin >> height;
        std::cin >> num_of_point;

        std::vector<std::vector<int>> square(init_square(width, height));

        paint(square, width, height);

        std::cout << calc_white(square) << std::endl;
        return 0;
}

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

int main()
{
  int a,b;
  cin >> a >> b;
  
  int k = (a + b) / 2;

  if(abs(a - k) == abs(b - k)){
      cout << k << endl;
  }else{
      cout << "IMPOSSIBLE" << endl;
  }



}


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

int main(){
	int coin500, coin100, coin50, x;
	cin >> coin500 >> coin100 >> coin50 >> x;
	int pattern = 0;
	for(int num500=0; num500<=coin500; ++num500){
		int money500 = 500*num500;
		if(money500 > x) break;
		for(int num100=0; num100<=coin100; ++num100){
			int money100 = money500 + 100*num100;
			if(money100 > x) break;
			for(int num50=0; num50<=coin50; ++num50){
				int money = money100 + 50*num50;
				if(money > x) break;
				if(money == x) pattern ++;
			}
		}
	}
	cout << pattern << endl;
	return 0;
}


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

const int MAX_N = (int)100 + 5;

int n, a[MAX_N];

int alice, bob;

int main(void){
  // Here your code !
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  sort(a, a + n, std::greater<int>());
  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) alice += a[i];
    else bob += a[i];
  }

  printf("%d\n", alice - bob);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
        int a,b;
        int x;
        cin >> a >> b;
        if((a+b)%2==0){
            x=(a+b)/2;
        }else{
            x=(a+b+1)/2;
        }
        cout << x;
    }

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


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

    int N, M; cin >> N >> M;
    dsu uf(N);
    REP(_, M) {
        int A, B; cin >> A >> B;
        --A; --B;
        uf.merge(A, B);
    }

    int ans = SZ(uf.groups()) - 1;
    cout << ans << endl;

    return 0;
}


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

int main(){
	int N, M, A[100], B, S[100] = {};

	cin>>N>>M;
	for(int i = 0; i < M; i++) cin>>A[i];
	
	for(int i = 0; i < M; i++){
		for(int j = 0; j < N; j++){
			cin>>B;
			if(B == A[i]) S[j]++;
			else S[A[i] - 1]++;
		}
		
	}
	for(int i = 0; i < N; i++) cout<<S[i]<<endl;

	
	return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
//int read(){int a;scanf("%lld",&a);return a;}

const int mod = 1e9 + 7;

ll inv[200010];
ll fac[200010], fac_inv[200010];

ll C(int n, int k) {
	return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}

void comb_init()
{
	int N = 200005;
	inv[1] = 1;

	for (int i = 2; i <= N; ++i) {
		inv[i] = mod - (mod / i) * inv[mod % i] % mod;
	}

	fac[0] = fac_inv[0] = 1;

	for (int i = 1; i <= N; ++i) {
		fac[i] = (fac[i - 1] * i) % mod;
		fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
	}
}

int N;
int a[100010];
bool used[100010];

signed main()
{
	cin >> N;

	if (N == 1) {
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}

	int l, r;

	rep(i, N + 1) {
		cin >> a[i];
		if (used[a[i]]) {
			r = i + 1;
			rep(j, i) {
				if (a[j] == a[i]) {
					l = j + 1;
					break;
				}
			}
		}
		used[a[i]] = true;
	}

	comb_init();

	int s = r - l - 1;

	rep1(k, N + 1) {
		int ans = 0;

		ans += C(N + 1 - 2, k);
		ans %= mod;

		if (k - 2 >= 0) {
			ans += C(N + 1 - 2, k - 2);
			ans %= mod;
		}

		if (N + 1 - 2 >= k - 1) {
			ans += C(N + 1 - 2, k - 1) * 2 % mod;
			ans %= mod;
		}

		if (N + 1 - s - 2 >= k - 1) {
			ans += (mod - C(N + 1 - s - 2, k - 1)) * 2 % mod;
			ans %= mod;
			ans += C(N + 1 - s - 2, k - 1);
			ans %= mod;
		}

		cout << ans << endl;
	}
}



Measured memory_bytes: 6400
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();

        int tmp = 0;

        tmp = x;
        x = y;
        y = tmp;
        tmp = x;
        x = z ;
        z = tmp;
        

        System.out.println(x+" "+y+" "+z);
    }
}

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

enum Sauce{ NOT_DETERMINED = 0, Tomato = 1, Cream = 2, Basil = 3 };
enum Seq{ SAME, DIFF };

const int divisor = 10000;

class Pasta{
public:
	Pasta(int _N);
	~Pasta();

	Sauce* sauceary;
	int schedule(int i, Sauce yesterday, Seq seq);

private:
	int N;
	int*** memo;
};

Pasta::Pasta(int _N){
	N = _N;
	sauceary = new Sauce[N + 1];
	memo = new int**[N + 1];

	for (int i = 0; i <= N; i++) sauceary[i] = NOT_DETERMINED;

	for (int i = 0; i <= N; i++){
		memo[i] = new int*[4];
		for (int j = 0; j < 4; j++){
			memo[i][j] = new int[2];
			memo[i][j][SAME] = -1;
			memo[i][j][DIFF] = -1;
		}
	}
}

Pasta::~Pasta(){
	delete[] sauceary;
	delete[] memo;
}

int Pasta::schedule(int i, Sauce yesterday, Seq seq){
	if (i == N + 1) return 1;
	if (memo[i][yesterday][seq] >= 0) return memo[i][yesterday][seq];

	if (seq == SAME && yesterday == sauceary[i]){
		memo[i][yesterday][SAME] = 0;
		return 0;
	}

	if (sauceary[i] == NOT_DETERMINED){
		int tmpmemo = 0;

		for (int si = 1; si <= 3; si++){
			if ((Sauce)si == yesterday && seq == SAME) continue;
			else if ((Sauce)si == yesterday && seq == DIFF) tmpmemo += schedule(i + 1, (Sauce)si, SAME) % divisor;
			else tmpmemo += schedule(i + 1, (Sauce)si, DIFF) % divisor;
		}
		memo[i][yesterday][seq] = tmpmemo;
		return tmpmemo;
	}
	else {
		if (yesterday == sauceary[i]) memo[i][yesterday][seq] = schedule(i + 1, sauceary[i], SAME) % divisor;
		else memo[i][yesterday][seq] = schedule(i + 1, sauceary[i], DIFF) % divisor;
			
		return memo[i][yesterday][seq];
	}
}

int main(){
	int N, K;
	cin >> N >> K;

	Pasta* pasta = new Pasta(N);

	for (int i = 0; i < K; i++){
		int A, B;
		cin >> A >> B;
		pasta->sauceary[A] = (Sauce)B;
	}

	int ans;
	if (pasta->sauceary[1] == NOT_DETERMINED){
		ans = pasta->schedule(2, Tomato, DIFF) + pasta->schedule(2, Cream, DIFF) + pasta->schedule(2, Basil, DIFF);
	}
	else {
		ans = pasta->schedule(2, pasta->sauceary[1], DIFF);
	}

	cout << ans % divisor << endl;

	delete pasta;
	return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  int ans = 0;
  int A = 0;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      A++;
    } else if (i + 1 < s.size() and s[i] == 'B' and s[i + 1] == 'C') {
      ans += A;
      i++;
    } else {
      A = 0;
    }
  }
  cout << ans << endl;

  return 0;
}


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

#define AndIamIronMan ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
 
using namespace std;
 
typedef  long long int lli; 

int main(){
    
    lli i,x,j,k,n,y,m,t,a,b; 	
    AndIamIronMan;
//    cin>>t;
//    while(t--){
	cin>>n;
	lli ar[n];
	x=0;
	map<lli,lli>mp;
	for(i=0;i<n;i++){
		cin>>ar[i];
		x+=ar[i];
		mp[ar[i]]++;
	}
	cin>>t;
	while(t--){
		cin>>a>>b;
		x=x-(a*mp[a]);
		y=mp[a];
		mp[b]+=mp[a];
		mp[a]=0;
		x=x+(b*y);
		cout<<x<<'\n';
	}
	
	
//	}
	return 0;
}


Measured memory_bytes: 10300
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(0, 0); }
	V<V<pin>> qab(2);
	int sz = ab.size();
	qab[0].reserve(sz);
	qab[1].reserve(sz);
	for (pin& x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	int c = 0;
	for (pin& x : qab[0]) {
		int qc = (2 * x.first + x.second) % 3;
		c ^= (qc + 1);
	}
	if (!c) {
		pin ans = solve(qab[1], ex - 1);
		ans.first *= 2; ans.second *= 2; ans.second++;
		return ans;
	}
	pin ans = solve(qab[0], ex - 1);
  	c=0;
  	for (pin& x : qab[1]) {
		int qc = (2 * x.first + x.second) % 3;
		c ^= (qc + 1);
	}
  	if (!c) {
		ans.first *= 2; ans.second *= 2;
		return ans;
	}
	c = 0;
	for (pin& x : qab[1]) {
		int w = ans.second - x.second-1;
		if ((w & x.first) == w) { c ^= 1; }
	}
	ans.first *= 2; ans.first++; ans.second *= 2; ans.second -= c;
	return ans;
}
signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long inf = 1e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 59);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}


Measured memory_bytes: 10468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s, t;
    cin >> s >> t;
    rep(i, 0, s.size()) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;

bool niren(int n , vector<char> a){
  bool x;
for(int i=0;i<n/2;i++){
if(a.at(i)== a.at(i+n/2)) x=true;
else{
x= false;
  break;
}
  
}
  return x;
}

int main(){
int n;
  cin>>n;
  vector<char> a(n);
  rep(i,n) cin>>a.at(i);
  
  bool x= niren(n,a);
  if(n%2==1) cout<<"No";
  else if(x) cout <<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int n,h,w ;
	cin >> n >> h >> w ;
	int cnt = 0 ;
	for(int i=0;i<n;i++){
		int a,b ;
		cin >> a >> b ;
		if(a>=h&&b>=w) cnt++ ;
	}
	cout << cnt << endl ;
}


Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

int pw[10];

char query(ll x) {
	printf("? %lld\n",x),fflush(stdout);
	char s[5]; scanf("%s",s); return s[0];
}

void answer(int x) {
	printf("! %d\n",x),fflush(stdout);
}

int main() {
	for (int i=pw[0]=1;i<10;++i) pw[i]=10*pw[i-1];
	if (query(pw[9])=='Y') {
		for (int i=9;i;--i)
			if (query(pw[i]-1)=='N') { answer(pw[i]); return 0; }
		answer(1); return 0;
	}
	int len=0;
	for (;len<10;++len)
		if (query(pw[len])=='N') break;
	--len;
	if (len==9) { answer(pw[9]); return 0; }
	int L=pw[len],R=pw[len+1]-1;
	while (L<R) {
		int mid=(L+R)>>1;
		if (query(10ll*mid)=='N') L=mid+1;
		else R=mid;
	}
	answer(L);
	return 0;
}

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

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

    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A.at(i);

    int64_t sum = 0;

    for(int i = 0; i < N-1; i++){
        if(A.at(i) > A.at(i+1)){
            sum += A.at(i) - A.at(i+1);
            A.at(i+1) = A.at(i);
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 3960
using System;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);
        int[] B = (int[])A.Clone();
        Array.Sort(B);
        Array.Reverse(B);
        for (int i = 0; i < N; i++)
        {
            if (A[i] == B[0]) Console.WriteLine(B[1]);
            else Console.WriteLine(B[0]);
        }

    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
        
    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}





Measured memory_bytes: 17984
def divisors(x):
    div=[]
    for i in range(1,x+1):
        if i*i>x:
            break
        if x%i==0:
            div.append(i)
            if x%i!=i:
                div.append(x//i)
    return div

n=int(input())
ans=set([])
for k in divisors(n):
    if k==1:continue
    N=n
    while  N%k==0:
        N//=k
    N%=k
    if N==1:
        ans.add(k)

for j in divisors(n-1):
    if j==1:continue
    ans.add(j)
print(len(ans))

Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define N 500000



int merge(int *A,int l,int r,int m){
  
  int cnt=0,i,j,k,n1,n2;
  n1=m-l;
  n2=r-m;
  int L[n1+1],R[n2+1];
  for(i=0;i<n1;i++) L[i]=A[l+i];
  for(i=0;i<n2;i++) R[i]=A[m+i];
  L[n1]=(int)INFINITY;
  R[n2]=(int)INFINITY;
  i=0;
  j=0;
  for(k=l;k<r;k++){
    if(L[i]<=R[j])  A[k]=L[i++];
    else            A[k]=R[j++];
    cnt++;
  }
  return cnt;
}

int mergeSort(int *A,int l,int r){
  int m,cnt=0;
  if(l+1<r){
    m=(l+r)/2;
    cnt+=mergeSort(A,l,m);
    cnt+=mergeSort(A,m,r);
    cnt+=merge(A,l,r,m);
  }
  return cnt;
}

int main(){

  int cnt,n,i,r,l;
  int S[N];

  scanf("%d",&n);

  l=0;
  r=n;
  
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  cnt=mergeSort(S,l,r);

  for(i=0;i<n;i++){
    if(i!=0) printf(" ");
    printf("%d",S[i]);
  }
  printf("\n%d\n",cnt);
  
  return 0;
}



Measured memory_bytes: 5600
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var a = G();
		Array.Sort(a);
		Console.WriteLine(a[0] + a[1]);
	}
}


Measured memory_bytes: 13268
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a1, b1 = LI()
    a2, b2 = LI()
    a3, b3 = LI()

    l = [0, 0, 0, 0]
    l[a1-1] += 1
    l[a2-1] += 1
    l[a3-1] += 1
    l[b1-1] += 1
    l[b2-1] += 1
    l[b3-1] += 1

    return max(l) <= 2


if main():
    print('YES')
else:
    print('NO')



Measured memory_bytes: 7748
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;
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 const INF = 1 << 30;


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

Measured memory_bytes: 3600
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            long a = cin.ReadLong;
            long b = cin.ReadLong;
            long c = cin.ReadLong;

            long result = 0;

            if (a + b < c)
            {
                result = b + (a + b) + 1;
            }
            else
            {
                result = b + c;
            }

            Console.WriteLine(result);
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll h, n;
  cin >> h >> n;
  vl a(n), b(n);
  rep(i, n) {
    cin >> a[i] >> b[i];
  }

  constexpr ll inf = 1LL<<60;
  constexpr ll limit = 20000;

  vector<vl> dp(n+1, vl(limit, inf));
  dp[0][0] = 0;
  rep(i, n) {
    rep(j, limit) {
      if (j < a[i]) {
        dp[i+1][j] = dp[i][j];
      } else {
        dp[i+1][j] = min(dp[i][j], dp[i+1][j-a[i]] + b[i]);
      }
    }
  }

  ll ans = inf;
  for(ll i = 0; i+h < limit; i++) {
    cmin(ans, dp[n][i+h]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 160640
n,c=[int(j) for j in input().split()]
xv=[]
for i in range(n):
    xv.append([int(j) for j in input().split()])
ll=[[xv[0][0],max(0,xv[0][1]-xv[0][0])]]
lr=[[c-xv[-1][0],max(0,xv[-1][1]-c+xv[-1][0])]]
tmp=xv[0][1]
for i in range(1,n):
    x,v=xv[i]
    tmp+=v
    ll.append([x,max(tmp-x,ll[-1][1])])
tmp=xv[-1][1]
for i in range(n-1)[::-1]:
    x,v=xv[i]
    x=c-x
    tmp+=v
    lr.append([x,max(tmp-x,lr[-1][1])])
ans=0
for i in range(n+1):
    if i==0:
        ans=max(ans,lr[n-1][1])
    elif i==n:
        ans=max(ans,ll[n-1][1])
    else:
        ans=max(ans,ll[i-1][1]+lr[n-i-1][1]-ll[i-1][0])
        ans=max(ans,ll[i-1][1]+lr[n-i-1][1]-lr[n-i-1][0])

print(ans)






Measured memory_bytes: 51188
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   	string s;
   	int l,r,cnt=0;
   	cin >> s;
   	l=0; r= s.length()-1;
   	while(l<=r) {
   		if(s[l]!=s[r]) cnt++;
   		l++; r--;
   	}
   	cout << cnt << "\n";
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  As = list(map(int, input().strip().split()))
  Bs = list(map(int, input().strip().split()))
  Cs = list(map(int, input().strip().split()))
  score = 0
  for i in range(len(As)):
    score += Bs[As[i]-1]
    if i > 0 and As[i-1] != n and As[i-1] + 1 == As[i]:
      score += Cs[As[i-1]-1]
  print(score)

if __name__=='__main__':
  main()



Measured memory_bytes: 3064
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()

tate = [False]*h
yoko = [False]*w

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            tate[i] = True
            yoko[j] = True

for i in range(h):
    if tate[i]:
        for j in range(w):
            if yoko[j]:
                print(a[i][j], end = '')
        print()

Measured memory_bytes: 4468
#pragma region

#ifdef LOCAL
#define debug cout
#else
#define debug \
    if (0) cout
#endif

#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[ ";
    for (auto e : v) os << e << " ";
    return os << "]";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, set<T, V> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V, typename S>
ostream& operator<<(ostream& os, map<T, V, S> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, pair<T, V> x) {
    return os << "( " << x.first << ", " << x.second << " )";
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& e : v) is >> e;
    return is;
}

template <typename T, typename V>
istream& operator>>(istream& is, pair<T, V>& x) {
    return is >> x.first >> x.second;
}

void solve();

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    solve();
}

#pragma endregion

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    cin >> h;
    vector<int> dp(n, 1e9);
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        for (int j = max(0, i - k); j < i; ++j) dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
    }
    cout << dp[n - 1] << "\n";
}

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

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

    vector<vector<int>> perm(0, vector<int>(5));
    for (int a = 0; a < 5; a++) {
        for (int b = 0; b < 5; b++) {
            if (b != a) {
                for (int c = 0; c < 5; c++) {
                    if (c != a && c!= b) {
                        for (int d = 0; d < 5; d++) {
                            if (d != a && d != b && d != c) {
                                for (int e = 0; e < 5; e++) {
                                    if (e != a && e != b && e != c && e != d) {
                                        perm.push_back({a,b,c,d,e});
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    int ans = 10000000;
    for (int i = 0; i < perm.size(); i++) {
        int time = 0;
        for (int j = 0; j < 5; j++) {
            if (t[perm[i][j]]%10 == 0 || j == 4)
                time += t[perm[i][j]];
            else {
                time += t[perm[i][j]] + 10 - t[perm[i][j]]%10;
            }
        }
        ans = min(ans, time);
    }
    cout << ans << endl;
}    

Measured memory_bytes: 3548
n,x = map(int,input().split())
a = list(map(int,input().split()))
a_abs = []
for i in range(n):
    a_abs.append(abs(x-a[i]))


def gcd(a,b):
    while b != 0:
        a, b = b, a % b
    return a


crt = a_abs[0]
for i in range(1, n):
    crt = gcd(crt,a_abs[i])
print(crt)





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

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

  string ans = "No";
  if (S[2] == S[3] && S[4] == S[5]) {
    ans = "Yes";
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    string s; cin >> s;
    if (s[2] == s[3] and s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

int main(){
  int h,w,a,b; cin>>h>>w>>a>>b;
  for(int i=0;i<b;i++){
    for(int j=0;j<a;j++){
      cout<<1;
    }for(int j=a;j<w-1;j++){
      cout<<0;
    }cout<<0<<endl;
  }for(int i=b;i<h;i++){
    for(int j=0;j<a;j++){
      cout<<0;
    }for(int j=a;j<w-1;j++){
      cout<<1;
    }cout<<1<<endl;
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main() {
    long long N,K; cin >> N >> K;
    long long ans;
    map<ll, ll> m{};
    for(ll i=0;i<N;i++){
        ll a,b; cin >> a >> b;
        m[a]+=b;
    }
    for(auto i:m){
        K-=i.second;
        if(K<=0) {ans=i.first; break;}
    }
    cout << ans << endl;
}



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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool p = min(abs(a - c), max(abs(a - b), (abs(b - c)))) <= d;
    if(p) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int max = 0;
		int max_i = 0;
		int next_max = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			if(A[i] >= max) {
				next_max = max;
				max = A[i];
				max_i = i;
			} else if(A[i] > next_max) {
				next_max = A[i];
			}
		}
		
		for(int i = 0; i < N; i++) {
			if(i != max_i) {
				System.out.println(max);
			} else {
				System.out.println(next_max);
			}
		}
	}
}


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

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

int main() {
    int n, a, b; cin >> n >> a >> b;
    if(n * a < b) cout << n * a << endl;
    else cout << b << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    ll ans = 0, numa = 0, numb = 0, numab = 0;
    rep(i, 0, n) {
        string s;
        cin >> s;
        for(int j = 0; j < (int)s.size()-1; j++) {
            if (s[j] == 'A' && s[j+1] == 'B') ans++;
        }
        if(s[0] == 'B' && s[s.size()-1] == 'A') numab++;
        else if(s[0] == 'B') numb++;
        else if(s[s.size()-1] == 'A') numa++;
    }
    if (numa == 0 && numb == 0) ans += max(0LL, numab-1);
    else ans += min(numa+numab, numb+numab);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

string s;
string s1 = "dream";
string s2 = "dreamer";
string s3 = "erase";
string s4 = "eraser";

int main(){
  cin >> s;
  string sub;
  while(true){
    if(s.size() == 0) break;
    if(s.size() >= 7){
      sub = s.substr((int)s.size()-7, (int)s.size());
      if(sub == "dreamer"){
        s.erase(s.end()-7, s.end());
        continue;
      }
    }
    if(s.size() >= 6){
      sub = s.substr((int)s.size()-6, (int)s.size());
      if(sub == "eraser"){
        s.erase(s.end()-6, s.end());
        continue;
      }
    }
    if(s.size() >= 5){
      sub = s.substr((int)s.size()-5, (int)s.size());
      if(sub == "erase" || sub == "dream"){
        s.erase(s.end()-5, s.end());
        continue;
      }
    }
    puts("NO");
    return 0;
  }
  puts("YES");
  return 0;
}


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

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

int n;
int a[200000];
bool isprime[1000001];

int main(){
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	sort(a,a+n);
	fill(isprime,isprime+1000001,true);
	for(int i=0;i<n;i++){
		int p = a[i];
		if(i>0&&a[i-1]==a[i]){
			isprime[p] = false;
			continue;
		}
		if(!isprime[p]) continue;
		for(int j=2*p;j<=1000000;j+=p){
			isprime[j] = false;
		}
	}

	int ans = 0;
	for(int i=0;i<n;i++){
		if(isprime[a[i]]) ans++;
	}

	cout << ans << endl;


	return 0;
}


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

int n, a[100010][3], dp[100010][3];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<=n; ++i)
		for(int j=0; j<3; ++j)
			cin >> a[i][j];
	for(int i=1; i<=n; ++i)
		for(int j=0; j<3; ++j)
			dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + a[i][j];
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << "\n";
}

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

int main(){

	int n;

  cin >> n;

  int *a = new int[n];

  for(int i=0; i<n; i++){
		cin >> a[i];
  }
  for(int i=n-1; i>=0; i--){
    cout << a[i];
    if(i==0){
		  cout << endl;
    }else{
      cout << " ";
    }
  }
}

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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int a[MAXN];
ll f[MAXN], g[MAXN];

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	scanf("%d", &n);
	for(int i = 1; i <= 3 * n; i++){
		scanf("%d", &a[i]);
	}
	set<PII> st;
	ll now = 0;
	for(int i = 1; i <= n; i++){
		st.insert(PII(a[i], i));
		now += a[i];
	}
	f[n] = now;
	for(int i = n + 1; i <= 3 * n; i++){
		now += a[i];
		st.insert(PII(a[i], i));
		now -= st.begin()->first;
		st.erase(st.begin());
		f[i] = now;
	}
	st.clear();
	now = 0;
	for(int i = 0; i < n; i++){
		st.insert(PII(-a[3 * n - i], 3 * n - i));
		now += a[3 * n - i];
	}
	g[2 * n + 1] = now;
	for(int i = 2 * n; i >= 1; i--){
		now += a[i];
		st.insert(PII(-a[i], i));
		now += st.begin()->first;
		st.erase(st.begin());
		g[i] = now;
	}
	ll ans = -(1ll << 60);
	for(int i = n; i <= 2 * n; i++)
		ans = max(ans, f[i] - g[i + 1]);
	printf("%lld\n", ans);
}

void printans(){

}


int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}



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

int main(){
    string S, a, b;
    cin >> S;
    int N = S.size();
    for(int i = 0; i < (N - 1) / 2; i++){
        a.push_back(S.at(i));
    }
    for(int i = (N +  3) / 2 - 1; i < N; i++){
        b.push_back(S.at(i));
    }
    if(a == b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3648