akhauriyash/Code-Regression huggingface dataset:
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, A);
    IN(ll, V);
    IN(ll, B);
    IN(ll, W);
    IN(ll, T);
    ll d = abs(B - A);
    if (W >= V)
    {
        OUT("NO");
        return 0;
    }
    ll dv = V - W;
    ll t = (d + dv - 1) / dv;
    YES(t <= T, "YES", "NO");
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> ba(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ba.at(i) = make_pair(b, a);
	}

	sort(ba.begin(), ba.end());
	string ans = "Yes";
	int64_t now = 0;
	for (int i = 0; i < n; i++) {
		now += ba.at(i).second;
		if (now > ba.at(i).first) {
			ans = "No";
			break;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize("-Ofast")
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define LL long long
#define inline __inline__ __attribute__((always_inline))
inline LL read() {
  long long x = 0, w = 1;
  char ch = getchar();
  while (!isdigit(ch)) w = ch == '-' ? -1 : 1, ch = getchar();
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * w;
}
const int Max_n = 1e4 + 5;
const LL lim = 1e17, inf = 2e17;
int n, Res;
int f[65][2][3];
LL m, N, a[Max_n], b[Max_n];
bool res[3];
inline bool check(LL x, LL y) {
  bool ans = 0;
  for (int i = 1; i <= n; i++) {
    LL M = b[i] - y, N = x - a[i];
    if (M < 0 || M < 0) continue;
    ans ^= ((N & M) == N);
  }
  return ans;
}
inline void DP(int Res) {
  memset(f, 0, sizeof(f));
  f[64][1][0] = 1;
  for (int i = 64; i; i--)
    for (int l = 0; l < 2; l++)
      for (int j = 0; j < 3; j++)
        for (int k = 0; k <= (m >> i - 1 & 1); k++) {
          if (l && k > (N >> i - 1 & 1)) continue;
          f[i - 1][l && (k == (N >> i - 1 & 1))][(j << 1 | k) % 3] ^= f[i][l][j];
        }
  for (int i = 0; i < 3; i++) {
    int now = (i - Res + 3) % 3;
    res[i] ^= f[0][0][now] ^ f[0][1][now];
  }
}
inline void work(LL L, LL R, LL a, LL b) {
  m = b + lim, N = R - a;
  if (N < 0) return;
  DP(((a % 3) + 3) % 3);
  if (L > a) {
    N = L - 1 - a;
    DP(((a % 3) + 3) % 3);
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read(), b[i] = read();
  LL l = -inf, r = inf;
  while (l != r) {
    LL mid = (l + r) >> 1;
    res[0] = res[1] = res[2] = 0;
    for (int i = 1; i <= n; i++) work(l, mid, a[i], b[i]);
    if (res[0] || res[1] || res[2])
      r = mid;
    else
      l = mid + 1;
  }
  LL L = l, R = l;
  for (int k = 63; ~k; k--)
    if (check(L - (1ll << k), -lim)) L -= (1ll << k);
  for (int k = 63; ~k; k--)
    if (check(R + (1ll << k), -lim)) R += (1ll << k);
  cout << L << " " << -lim + R - L;
}


Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a,b,c) for(b=(c);b<(a);b++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll combination(ll, ll);
int main() {
	int n;
	cin >> n;
	int count = 0;
	bool ans = false;
	while (1) {
		int check = count * 7;
		if (check > n) {
			break;
		}
		if ((n - check) % 4 == 0) {
			ans = true;
			break;
		}
		count++;
	}
	if (ans) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}




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

int main(void)
{
    string s;
    getline(cin, s);  // 1行読み込む
    for(int i = 0; i < s.size(); i++) {
        char c = s[i];
        if ('A' <= c && c <= 'Z') {
            //c = tolower(c);
            c = c + 32;
        }
        else if('a' <= c && c <= 'z') {
            c = c - 32;
        }
        cout << c;
    }
    cout << endl;
}


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

int main(){
  int n;
  int A=0, W=0, T=0, R=0;
  cin >> n;
  for(int i=0; i<n; i++){
    string s;
    cin >> s;
    if(s == "AC"){
    	A += 1;
    }
    else if(s == "WA"){
    	W += 1;
    }
    else if(s == "TLE"){
    	T += 1;
    }
    else if(s == "RE"){
    	R += 1;
    }
  }
  cout << "AC x " << A << endl;
  cout << "WA x " << W << endl;
  cout << "TLE x " <<T << endl;
  cout << "RE x " << R  << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>

using namespace std;

template<typename T>
class RangeUpdateQuery {
public:
    explicit RangeUpdateQuery(int n, T def) : N(calcN_(n)) {
        mVal.assign(2*N+1, make_pair(-1, def));
    }
    void update(int l, int r, T value, int ts){
        updateImpl_(l, r, make_pair(ts, value), 0, 0, N);
    }
    T get(int idx){
        int i = N + idx - 1;
        auto res = mVal[i];
        while(i > 0){
            i = (i-1)/2;
            res = max(mVal[i], res);
        }
        return res.second;
    }
    void debug() { for(auto t: mVal) cout << t.first<<","<<t.second << " "; cout << endl; }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void updateImpl_(int l, int r, pair<int, T> value, int idx, int rangeL, int rangeR){
        if(r <= rangeL || rangeR <= l) return;
        if(l <= rangeL && rangeR <= r){
            mVal[idx] = value;
        } else {
            int rangeM = (rangeL+rangeR)/2;
            updateImpl_(l, r, value, 2*idx+1, rangeL, rangeM);
            updateImpl_(l, r, value, 2*idx+2, rangeM, rangeR);
        }
    }
    const int N;
    vector<pair<int,T>> mVal; 
};

int main(){
    int n, q;
    while(cin >> n >> q){
        const int INF = 0x7FFFFFFF;
        RangeUpdateQuery<int> ruq(n, INF);
        for(int i=0;i<q;i++){
            int c; cin >> c;
            if(c == 0){
                int s, t, x; cin >> s >> t >> x;
                ruq.update(s, t+1, x, i);
            } else {
                int p; cin >> p;
                cout << ruq.get(p) << endl;
            }
        }
    }
}



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

int main() {
        int x;
        cin >> x;
        if (x >= 30){
                cout << "Yes" << endl;
                return 0;
        }
        cout << "No" << endl;
        return 0;
}

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

int N;
long long C;
vector<long long> x, xinv;
vector<long long> v;

int main()
{
    cin >> N >> C;
    x.resize(N);
    xinv.resize(N);
    v.resize(N);
    for (int i=0; i<N; i++)
    {
        cin >> x[i] >> v[i];
        xinv[i] = C - x[i];
    }

    // 時計回りに(i+1)貫目まで食っていいときに片道/往復で得られる利得の最大値
    vector<long long> onewayR(N), roundR(N);
    long long kcalSum = 0;
    for (int i=0; i<N; i++)
    {
        kcalSum += v[i];
        if (i == 0)
        {
            onewayR[i] = fmax(kcalSum - x[i], 0);
            roundR[i] = fmax(kcalSum - 2 * x[i], 0);
        }
        else
        {
            onewayR[i] = fmax(kcalSum - x[i], onewayR[i-1]);
            roundR[i] = fmax(kcalSum - 2 * x[i], roundR[i-1]);
        }
    }

    vector<long long> onewayL(N), roundL(N);
    kcalSum = 0;
    for (int i=0; i<N; i++)
    {
        kcalSum += v[N-i-1];
        if (i == 0)
        {
            onewayL[N-i-1] = fmax(kcalSum - xinv[N-i-1], 0);
            roundL[N-i-1] = fmax(kcalSum - 2 * xinv[N - i - 1], 0);
        }
        else
        {
            onewayL[N-i-1] = fmax(kcalSum - xinv[N-i-1], onewayL[N-i]);
            roundL[N-i-1] = fmax(kcalSum - 2 * xinv[N-i-1], roundL[N-i]);
        }
    }

    long long result = fmax(onewayR[N-1], onewayL[0]);
    for (int i=1; i<N-1; i++)
    {
        long long tmp = fmax(onewayR[i] + roundL[i+1], onewayL[i] + roundR[i-1]);
        result = fmax(result, tmp);
    }

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


Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false); 
    int n;
    string s;
    cin>>n>>s;
    if(n%2==0&&s.substr(0,n/2)==s.substr(n/2,n/2)){
        cout<<"Yes";
    }    else{
        cout<<"No";
    }
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i=0; i<n; ++i) {
        cin >> h.at(i);
    }
    Graph G(n);
    for (int i=0; i<m; ++i) {
        int a, b;
        cin >> a >> b;
        G.at(a-1).push_back(b-1);
        G.at(b-1).push_back(a-1);
    }

    int res = 0;
    for (int i=0; i<n; ++i) {
        bool ok = true;
        for (int x : G.at(i)) {
            if (h.at(x) >= h.at(i)) {
                ok = false;
                break;
            }
        }
        if (ok) ++res;
    }

    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 8724
#include<iostream>
#include<stdio.h>
using namespace std;
char t[17];
int a=1,b,c,mx=0;
char re(char ch){
  if(ch=='('){
    return ')';
  }else if(ch==')'){
    return '(';
  }else if(ch=='{'){
    return '}';
  }else if(ch=='}'){
    return '{';
  }else if(ch=='['){
    return ']';
  }else if(ch==']'){
    return '[';
  }else{
    return ch;
  }
}
void compute(int a,int c,int cnt){
  if(t[b-a]=='\n'||t[b+c]=='\n'){
    if(mx<cnt)mx=cnt;
    return;
  }
  int d=0;
  compute(a+1,c,cnt);
  while(1){
    if(t[b+c+d]=='\n')break;
    if(t[b+c+d]==re(t[b-a])){
      compute(a+1,c+d+1,cnt+2);
    }
    d++;
  }
}
int main(){
  t[0]='\n';
  while(1){
    scanf("%c",&t[a]);
    if(t[a]=='\n')break;
    if(t[a]=='w')b=a;
    a++;
  }
  a=c=2;
  compute(2,2,3);
  cout<<mx<<endl;
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <queue>
#include <stdio.h>
using namespace std;


void calc(char* cs){
    std::queue<char> qu;
    int size;
    for(int i=0;cs[i]!='\0';i++){
        qu.push(cs[i]);
    }
    int n,h;
    scanf("%d",&n);
    size=qu.size();
    while(n--){
        scanf("%d",&h);
        for(int i=0;i<h;i++){
            int a=qu.front();
            qu.pop();
            qu.push(a);
        }
    }
    while(qu.empty()==false){
        printf("%c",qu.front());
        qu.pop();
    }
    printf("\n");
}


int main() {
    // your code goes here
    char cs[201];
    while(1){
        scanf("%s",cs);
        if(cs[0]=='-')break;
        calc(cs);
    }
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  if(s==t){
    cout<<n<<endl;
    return 0;
  }
  int i,j;
  int mis=0;
  for(i=0;i<n;i++){
    if(s[i]==t[0]){
      for(j=0;j<n-i;j++){
        //cout<<s[i+j]<<t[j]<<endl;
        if(s[i+j]!=t[j]){
          break;
        }
      }
    }
    mis=max(mis,j);
  }
  cout<<2*n-mis<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1000000010;

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

    int h[n];
    rep(i, n) {
        cin >> h[i];
    }

    int dp[n+1];
    rep(i, n+1) {
        dp[i] = INF;
    }

    dp[0] = 0;
    dp[1] = 0;
    for(int i = 1; i < n; i++) {
        rep(j, k) {
            if(i <= j) {
                break;
            }

            dp[i+1] = min( dp[i+1], dp[i-j] + abs(h[i-(j+1)] - h[i]) );
        }
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("NO");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=5e6+10;
	ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=1e6+10;
	//------------------FIXED------------------
	int a[N];
	vc<int> to[N],to2[N];bool vis[N];int in[N];
	void dfs(int x)
	{
		vis[x]=1;for(auto y:to[x]) if(!vis[y]) dfs(y),to2[x].PB(y),in[y]++,debug("%d->%d\n",x,y);
	}
	void main()
	{
		int n=qread();fo(i,1,n) a[i]=qread();sort(&a[1],&a[n+1]);
		fo(i,1,n) fo(j,i+1,n) if(gcd(a[i],a[j])!=1) to[i].PB(j),to[j].PB(i);//�߱�����
		fo(x,1,n) if(!vis[x]) dfs(x);
		priority_queue<int> q;fo(i,1,n) if(!in[i]) q.push(i);
		while(sz(q)){ int x=q.top();q.pop();write1(a[x]);for(auto y:to2[x]){in[y]--;if(!in[y])q.push(y);} }
	}
};//����������
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();//����Ԥ����ģ����
	mine::main();
	debug("\n---------------------Zory---------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 186368
#include <iostream>
#include <string>
using namespace std;
int main(){
 string s;
cin>>s;
if (s=="A")
  cout<<"T";
else if (s=="T")
  cout<<"A";
else if (s=="G")
  cout<<"C";
else if (s=="C")
  cout<<"G";
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
    long long w,h,x,y,r,f=0;
    scanf("%lld%lld%lld%lld%lld",&w,&h,&x,&y,&r);
    if(x-r<0)
        f=1;
    if(x+r>w)
        f=1;
    if(y-r<0)
        f=1;
    if(y+r>h)
        f=1;
    if(f==0)
        printf("Yes\n");
    else if(f==1)
        printf("No\n");
    return 0;
}

Measured memory_bytes: 3164
import itertools
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
ls = [i+1 for i in range(N)]
per = []
for j in itertools.permutations(ls,N):
    per.append(j)
print(abs(per.index(P) - per.index(Q)))

Measured memory_bytes: 7924
N = int(input())
X=[list(map(int,input().split())) for i in range(N)]
#print(X)
dp = [[0] * 3 for _ in range(N+1)]
for i in range(N):
  for j in range(3):
    for k in range(3):
      if j==k:
        continue
      dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + X[i][k])	
ans=0
for j in range(3):
  ans=max(ans,dp[N][j])
print(ans)

Measured memory_bytes: 47336
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

	void submit() {
		HashMap<Long, Integer> map = new HashMap<>();
		long sum = 0;
		map.put(0L, 1);
		
		int n = nextInt();
		
		long ans = 0;
		
		for (int i = 0; i < n; i++) {
			sum += nextInt();
			int prv = map.getOrDefault(sum, 0);
			ans += prv;
			map.put(sum, prv + 1);
		}
		
		out.println(ans);
	}

	void test() {

	}

	void stress() {
		for (int tst = 0;; tst++) {
			if (false) {
				throw new AssertionError();
			}
			System.err.println(tst);
		}
	}

	Main() throws IOException {
		is = System.in;
		out = new PrintWriter(System.out);
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();
	static final int C = 5;

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	private InputStream is;
	PrintWriter out;

	private byte[] buf = new byte[1 << 14];
	private int bufSz = 0, bufPtr = 0;

	private int readByte() {
		if (bufSz == -1)
			throw new RuntimeException("Reading past EOF");
		if (bufPtr >= bufSz) {
			bufPtr = 0;
			try {
				bufSz = is.read(buf);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
			if (bufSz <= 0)
				return -1;
		}
		return buf[bufPtr++];
	}

	private boolean isTrash(int c) {
		return c < 33 || c > 126;
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isTrash(b))
			;
		return b;
	}

	String nextToken() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!isTrash(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	String nextString() {
		int b = readByte();
		StringBuilder sb = new StringBuilder();
		while (!isTrash(b) || b == ' ') {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	char nextChar() {
		return (char) skip();
	}

	int nextInt() {
		int ret = 0;
		int b = skip();
		if (b != '-' && (b < '0' || b > '9')) {
			throw new InputMismatchException();
		}
		boolean neg = false;
		if (b == '-') {
			neg = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				ret = ret * 10 + (b - '0');
			} else {
				if (b != -1 && !isTrash(b)) {
					throw new InputMismatchException();
				}
				return neg ? -ret : ret;
			}
			b = readByte();
		}
	}

	long nextLong() {
		long ret = 0;
		int b = skip();
		if (b != '-' && (b < '0' || b > '9')) {
			throw new InputMismatchException();
		}
		boolean neg = false;
		if (b == '-') {
			neg = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				ret = ret * 10 + (b - '0');
			} else {
				if (b != -1 && !isTrash(b)) {
					throw new InputMismatchException();
				}
				return neg ? -ret : ret;
			}
			b = readByte();
		}
	}
}


Measured memory_bytes: 46124
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  const int M = 100000;
  int n; cin >> n;
  vector<int> cnt(M, 0);
  while (n--) {
    int a; cin >> a;
    ++cnt[a];
  }
  int ans = 0;
  REP(i, M - 2) ans = max(ans, cnt[i] + cnt[i + 1] + cnt[i + 2]);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>a;
    string s;
    cin>>s;
    if(a<3200){
        cout<<"red";
    }else{
        cout<<s;
    }
    return 0;
}
//.........

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


int main() {
  int r, g, b, num;
  cin >> r >> g >>b;
  
  num = r*100 + g*10 + b;
    
  if (num%4 == 0){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}
 


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

#define PI 4*atan(1)
#define INF 1e8

typedef long long ll;

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

int s;
bool check;
vector<int> v;
void dfs(int n, int p, vector<vector<int>> &G){
  // if(n == s && p != -1){
  //   cout << "s: " << s << " n: " << n << "p: " <<p << endl;
  //   check = true;
  //   return;
  // }  
  v[n] = 1;
  for(auto g : G[n]){
    if(v[g] == 0){
      // cout << "n: " << n << "g: " << g << endl;
      dfs(g, n, G);
    }else if(p != -1 && g == s){
      check = true; 
    }
  }
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans = 0;
  // for(int i = 0; i < N; i++){
  // for(int i = 0; i < N; i++){
  //   for(auto g : G[i])cout << g << " ";
  //   cout << endl;
  // }
  //   for(auto g : G[i])cout << g << " ";
  //   cout << endl;
  // }
  for(int i = 0; i < N; i++){
    // cout << "i " << i << endl;
    s = i;
    for(auto g : G[i]){
      check = false;
      v.assign(N, 0);
      v[i] = 1;
      if(g > i){
        dfs(g, -1, G);
        if(!check)ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  vector<int> vec;
  vec.push_back(a+b);
  vec.push_back(a-b);
  vec.push_back(a*b);
  cout<<*max_element(vec.begin(),vec.end());
}

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

int main(){
	int N,M , X; cin >> N >> M >> X;
  	vector<vector<int>> book (N,vector<int>(M+1));
  	for(int i=0; i<N ; i++){
    	for(int j=0; j<M+1 ; j++){
        	cin >> book.at(i).at(j);
        }
    }
  	
  	bool kaiaru =false;
  	int kai=INT_MAX;
  	
  	
  	for(int tmp=0; tmp <(1 << N); tmp++){
      	bitset<13> flag(tmp);
      	vector<int> skill(M,0);
      	int money=0;
    	for(int i=0; i<N ; i++){
        	if(flag.test(i)){
            	for(int j=0; j<M;j++){
                	skill[j]+=book[i][j+1];
                }
              	money+=book[i][0];
              	
            }
        }
      	for(int i=0; i<M; i++){
        	if(skill[i] < X){break;}
          	else if(i == M-1){
              kaiaru = true;
              if(money < kai){kai = money;}
            }
        }
    }
  	if(kaiaru){cout << kai << endl;}
  	else{cout << -1 << endl;}
  	
  	
  
}


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

using namespace std;

int main()
{
	int p[5];
	int t;

	while (1){
		int pro, loss;
		int medal = 100;

		for (int i = 0; i < 5; i++){
			scanf("%d", &p[i]);
		}
		scanf("%d", &t);

		if (p[0] == 0 && p[1] == 0 && p[2] == 0 && p[3] == 0 && p[4] == 0 && t == 0){
			break;
		}

		medal -= 3 * (t - (p[0] * 6 + p[1] * 4 + p[2] + p[3] + p[4]));
		medal += p[0] * 77 + p[1] * 51 + p[2] * 4 + p[3] * -1;

		cout << medal << endl;
	}

	return (0);
}

Measured memory_bytes: 1204
#include <stdio.h>

int main(void) {
  int n, m, i, j;
  scanf("%d %d", &n, &m);
  int a[n][m];
  int b[m];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }
  int c[n];
  for (i = 0; i < n; i++) {
	  c[i] = 0;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      c[i] += (a[i][j] * b[j]);
    }
  }
  for (i = 0; i < n; i++) {
	  printf("%d\n", c[i]);
  }
  return 0;
}



Measured memory_bytes: 1996
#include "bits/stdc++.h"
#define long int64_t
using namespace std;

struct Solver {
	void solve() {
		int A, V, B, W, T;
		cin >> A >> V >> B >> W >> T;

		int x = abs( A-B );
		long y = V - W;
		if( x <= y*T ) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3608
n=int(input())
a=list(map(int,input().split()))
count=0
count2=0
for i in range(n):
  if a[i]%2==0:
    count2=count2+1
    if a[i]%3 ==0 or a[i]%5==0:
      count=count+1
if count2==count:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
N,M = map(int, input().split())
ans = 10000
t = ""
sc = []

for i in range(M):
    sc.append(list(map(int, input().split())))

if N == 1:
    for i in range(10):
        k = 0
        t = str(i)
        for j in sc:
            if j[0]>len(t):
                k = 1
            elif str(j[1])!=t[j[0]-1]:
                k = 1
        if k==0:
            ans = min(ans,i)
elif N == 2:
    for i in range(10,100):
        k = 0
        t = str(i)
        for j in sc:
            if j[0]>len(t):
                k = 1
            elif str(j[1])!=t[j[0]-1]:
                k = 1
        if k==0:
            ans = min(ans,i)
else:
    for i in range(100,1000):
        k = 0
        t = str(i)
        for j in sc:
            if j[0]>len(t):
                k = 1
            elif str(j[1])!=t[j[0]-1]:
                k = 1
        if k==0:
            ans = min(ans,i)

if ans == 10000:
    ans = -1
print(ans)


Measured memory_bytes: 3064
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        if (n == m) System.out.println("Yes");
        else System.out.println("No");

        sc.close();
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	long long int n, k;
	string str;
	cin >> n >> k;
	cin >> str;
	vector<long long int> vec;
	vec.push_back(0);
	long long int wa = 0;
	long long int i = 0;
	while (i < n) {
		long long int a = 0;
		for (; str[i] == '1'; i++, a++);
		wa += a;
		vec.push_back(wa);
		a = 0;
		for (; str[i] == '0'; i++, a++);
		wa += a;
		vec.push_back(wa);
		
	}
	long long int m = vec[1];
	for (int i = 1; i < vec.size(); i+=2) {
		//cout << vec[i] << endl;
		if (i + k * 2+1 < vec.size()) {
			m = max(m, vec[i + k * 2] - vec[i-1]);
		}
		else if(i + k * 2 + 1 >= vec.size()) {
			m= max(m, vec[vec.size()-1] - vec[i - 1]);
		}
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
// #define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n) {
        cin >> a[i];
        --a[i];
    }
    int ans = 0;
    rep(i, 0, n) {
        if (a[a[i]] == i) ans++;
    }
    cout << ans / 2 << "\n";
}

Measured memory_bytes: 3976
A,B,C,X,Y=map(int,input().split())

ans=A*X+B*Y
a=0

for i in range(max(X,Y)+1):
    a=A*max(X-i,0)+B*max(Y-i,0)+C*i*2
    if(a<ans):
        ans=a
print(ans)

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, x;
    cin >> n >> x;

    ll a[n];
    rep(i, n) cin >> a[i];

    ll ans = 0;

    ans += max(0LL, a[0]-x);
    a[0] -= ans;

    rep(i, n-1){
        if(a[i]-x+a[i+1] > 0 ){
            ans += a[i]-x+a[i+1];
            a[i+1] -= a[i]-x+a[i+1];
        }
    }
    ppp(ans);



    return 0;
}


Measured memory_bytes: 1024
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
ans = [[0]*w for _ in range(h)]

def dfs(x,y):
    if 0 <= x < h and 0 <= y < w:
        if ans[x][y] != "#":
            ans[x][y] += 1
        

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            ans[i][j] = '#'
            dfs(i+1, j)
            dfs(i+1, j+1)
            dfs(i+1, j-1)
            dfs(i-1, j+1)
            dfs(i-1, j)
            dfs(i-1, j-1)
            dfs(i, j+1)
            dfs(i, j-1)

for i in range(h):
    a = map(str,ans[i])
    print(''.join(a))

Measured memory_bytes: 9248
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.*;

public class Main{
	public static void main(String[] args) throws IOException {
		StreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
		in.nextToken();
		int n=(int)in.nval;
		int point[]=new int[n+1];
		point[1]=1;
		point[n]=-1;
		ArrayList<LinkedList<Integer>> way=new ArrayList<LinkedList<Integer>>(n+1);
		for(int i=0;i<=n;i++){
			way.add(new LinkedList<Integer>());
		}
		for(int i=1;i<n;i++){
			in.nextToken();
			int a=(int)in.nval;
			in.nextToken();
			int b=(int)in.nval;
			way.get(a).add(b);
			way.get(b).add(a);
		}
		Queue<Integer> q1=new LinkedList<Integer>();
		Queue<Integer> q2=new LinkedList<Integer>();
		q1.offer(1);q2.offer(n);
		Iterator<Integer> it;
		int ans1=0,ans2=0,temp1=1,temp2=1,temp11,temp22,edge;
		while(!q1.isEmpty()||!q2.isEmpty()){
			temp11=0;temp22=0;
			for(int i=0;i<temp1;i++){
				int com=q1.poll();
				it=way.get(com).iterator();
				while(it.hasNext()){
					edge=it.next();
					if(point[edge]==0){
						point[edge]=1;
						q1.add(edge);
						temp11++;
						ans1++;
					}
				}
			}
			temp1=temp11;
			for(int i=0;i<temp2;i++){
				int com=q2.poll();
				it=way.get(com).iterator();
				while(it.hasNext()){
					edge=it.next();
					if(point[edge]==0){
						point[edge]=-1;
						q2.add(edge);
						temp22++;
						ans2++;
					}
				}
			}
			temp2=temp22;
		}
		if(ans1>ans2)out.println("Fennec");
		else out.println("Snuke");
		out.flush();
	}
}

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

ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	int n;
	cin >> n;
	cout << (n - 1) / 2 << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string first,second;
  cin >> first >> second;
  string answer = "YES";
  for(int i = 0; i < 3; ++i){
    if(first[i] != second[2-i]) answer = "NO";
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

using int64 = long long;

class Combination {
 public:
  constexpr Combination() { Build(); }
  static constexpr int mod_ = 1000000007;
  static constexpr int n_ = 800000;
  class LookupTable {
   public:
    int64 factorial_[n_];
    int64 inverse_[n_];
    int64 finverse_[n_];
  };
  LookupTable lt{};
  // return nCk
  constexpr int64 Get(int n, int k) const noexcept {
    if (n < k || n < 0 || k < 0) return 0;
    return lt.factorial_[n] * (lt.finverse_[k] * lt.finverse_[n - k] % mod_) %
           mod_;
  }

 private:
  constexpr void Build() noexcept {
    lt.factorial_[0] = 1;
    lt.factorial_[1] = 1;
    lt.finverse_[0] = 1;
    lt.finverse_[1] = 1;
    lt.inverse_[1] = 1;
    for (int i = 2; i < n_; ++i) {
      lt.factorial_[i] = lt.factorial_[i - 1] * i % mod_;
      lt.inverse_[i] = mod_ - lt.inverse_[mod_ % i] * (mod_ / i) % mod_;
      lt.finverse_[i] = lt.finverse_[i - 1] * lt.inverse_[i] % mod_;
    }
  }
};

template<typename T> void fastin(T &num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

Combination com;

int main() {
 int x, y; fastin(x); fastin(y);
  auto ok = [](int xx, int yy) -> bool {
    return (xx + yy) % 3 == 0;
  };
 
  if (!ok(x, y)) {
    printf("%d\n", 0);
    return 0;
  }
 
  int nn = (x + y) / 3;
  int r = x - nn;
 
  int64 ans = com.Get(nn, r);
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 128
#define pb push_back
#define ll long long
#define maxn 30000000
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;

int arr[100005][3], dp[100005][3], n;

int rec(int pos, int flag){
    if(dp[pos][flag] != -1) return dp[pos][flag];
    if(pos == n+1) return 0;
    int res = 0;
    for(int i=0;i<3;i++){
        if(i == flag) continue;
        res = max(res, arr[pos][i] + rec(pos+1, i));
    }
    return dp[pos][flag] = res;

}

int main() {
    memset(dp, -1, sizeof dp);
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }
    cout << rec(0, 3) << endl;
    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T & a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T & a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	ll ans;
	makel(k);
	makel(a);
	makel(b);
	if (k <= a || b - a <= 2)ans = k + 1;
	else {
		k -= a - 1;
		ans = a + (b - a) * (k / 2) + k % 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){int k,i;
int a[33];
for(i=0;i<=32;i++){a[i]=1;}
a[4]=2,a[6]=2,a[8]=5,a[9]=2,a[10]=2,a[12]=5,a[14]=2,a[16]=14,a[18]=5,a[20]=5,a[21]=1,a[22]=1;
a[24]=15,a[25]=2,a[26]=2,a[27]=5,a[28]=4,a[30]=4,a[32]=51;
cin>>k;
cout<<a[k];
    return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
double x,ans;
string s;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x>>s;
        if(s=="JPY")ans+=x;
        else ans+=x*380000;
    }
    printf("%.6f",ans);
    return 0;
}

Measured memory_bytes: 256
T = int(input())

for _ in range(T):
    N = int(input())
    A = list(map(int,input().split()))
    S = input()

    list0 = [0] * 64

    for a, s in zip(A[::-1], S[::-1]):
        if s == '1':
            while a:
                b = a.bit_length() - 1
                if list0[b]:
                    a ^= list0[b]
                else:
                    break

            if a:
                ans = 1
                break

        else:
            while a:
                b = a.bit_length() - 1
                if list0[b]:
                    a ^= list0[b]
                else:
                    list0[b] = a
                    break

    else:
        ans = 0

    print(ans)


Measured memory_bytes: 9064
//OM
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <sstream>
#include <algorithm>
using  namespace  std;

#define  x first
#define  y second
#define  pb push_back
#define  mp make_pair
#define  PI (acos(-1.0))
#define  mem(a,b) memset(a,b,sizeof(a))
#define  Sort(x) sort(x.begin(),x.end())
#define  FOR(i, b, e) for(int i = b; i <= (int)(e); i++)
#define  FORR(i, b, e) for(int i = b; i >=(int)(e); i--)
#define  FORI(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define  pr(x) cout<<x<<"\n"
#define  prs(x) cout<<x<<" "
#define  pr2(x,y) cout<<x<<" "<<y<<"\n"
#define  pr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define  ppr(a) cout<<a.x<<" "<<a.y<<"\n"
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef  long long ll;
typedef  pair <int, int> pii;
typedef  pair <double, double> pdd;
typedef  vector <int> vi;
typedef  vector <pii> vpii;


//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};
//int dy[]={0,1,1,1,0,-1,-1,-1};//8 Direction

#define  EPS 1e-9
#define  MAX 100007
#define  MOD 1000000007

int main()
{
//    READ("in.txt");
//    WRITE("out.txt");
    int T,n;
    ll a[100];
    scanf("%d",&n);
    a[0]=2;
    a[1]=1;
    FOR(i,2,n){
        a[i]=a[i-1]+a[i-2];
    }
    pr(a[n]);
    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for i in a:
    d[i] += 1

if len(d) >= 4:
    print("No")
    exit()

if len(d) == 1:
    if 0 in d:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

if len(d) == 2:
    if (N % 3) == 0 and 0 in d and d[0] == N // 3:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

if len(d) == 3:
    l = list(d.values())
    l.sort()
    if l[0] == l[-1]:
        keys = list(d.keys())
        if keys[0] ^ keys[1] == keys[2]:
            print("Yes")
            exit()

print("No")


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int l, r;
    l = r = 0;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == 'E') ++r;

    }

    int res = INF;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == 'E') --r;
        res = min(res, l + r);
        if(s[i] == 'W') ++l;

    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 720