akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

using namespace std;

int main(){
	int m; scanf("%*d%d",&m);
	pair<int,int> I[100000];
	rep(i,m) scanf("%d%d",&I[i].second,&I[i].first), I[i].first--;

	sort(I,I+m);

	int ans=0,pos=-1;
	rep(i,m) if(pos<I[i].second) pos=I[i].first, ans++;
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,k,ba=0;
	cin>>a>>b>>k;
	for(int t=min(a,b);t>0;t--)
	{
		if(a%t==0&&b%t==0)
		{
			ba++;
			//cout<<t<<" ";
		}
		if(ba==k)
		{
			cout<<t;
			return 0;
		}
	}
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(X) for(int i=1; i<=X; i++)
#define REPinv(X) for(int i=X; i>=1; i--)
using namespace std;

const int MAX_INDEX = int(1e6);
int leftGcd[MAX_INDEX];
int rightGcd[MAX_INDEX];
int A[MAX_INDEX];

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

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

	REP(N){ leftGcd[i] = __gcd(A[i], leftGcd[i - 1]); }

	REPinv(N){ rightGcd[i] = __gcd(A[i], rightGcd[i + 1]); }

	int ans = 0;
	REP(N){ ans = max(ans, __gcd(leftGcd[i - 1], rightGcd[i + 1])); }
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N;
    cin >> N;
    vec A(N);
    vec exist(1e6+10, 0);
    Rep (i, N) {
        cin >> A[i];
        exist[A[i]]++;
    }

    ll ans = 0;
    Rep (i, N) {
        bool flag = true;
        exist[A[i]]--;
        for (ll j = 1; j*j <= A[i]; j++) {
            if (A[i] % j == 0) {
                if (exist[A[i]/j] or exist[j]) flag = false; 
            }
        }
        if (flag) ans++;
        exist[A[i]]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 12684
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
	int a, b;
	char s;

	cin >> a >> s >> b;

	if (s == '+')	
	{
		cout << a + b << endl;
	} else {
		cout << a - b << endl;
	}
	return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pll = P<LL,LL>;
using Pdd = P<double,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

const int INF = 1999999999;
const LL INFLL = 999999999999999LL;

/* graph */
struct edge{
    int src; int dst; int weight;
    edge() : src(0), dst(0), weight(0) {}
    edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};

using edges = V<edge>;
using graph = V<edges>;

void add_edge(edges &g,int s, int d, int w=1){g.pb(edge(s,d,w));}
void add_edge(graph &g,int s, int d, int w=1){g[s].pb(edge(s,d,w));}

Vll dijkstra(graph &g,int s){
    int i,j,k; int n=g.size(); int visit[n]; Vll dist(n);
    priority_queue<Pll,V<Pll>,greater<Pll>> q;
    REP(i,n){visit[i]=0; dist[i]=INFLL/2;}
    dist[s]=0;
    q.push(mp(0,s));
    while(!q.empty()){
        LL d,t; tie(d,t)=q.top(); q.pop();
        if(visit[t]==1){continue;}
        visit[t]=1; dist[t]=d;
        for(auto &e:g[t]){
            if(dist[e.dst]<=d+e.weight){continue;}
            q.push(mp(d+e.weight,e.dst));
        }
    }
    return dist;
}

int main(){
    int n;
    cin>>n;
    graph G(n);
    REP(i,n-1){
        int u,v,w;
        cin>>u>>v>>w;
        u--;
        v--;
        add_edge(G,u,v,w);
        add_edge(G,v,u,w);
    }

    Vll d = dijkstra(G,0);

    REP(i,d.size()){
        cout<<d[i]%2<<endl;
    }

    return 0;
}

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

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

        List<int> list = new List<int>();
        for (int i = 0; i < N; i++)
        {
            list.Add(int.Parse(Console.ReadLine()));
        }
        var dec = list.OrderByDescending(e => e).ToArray();
        var a = dec[0];
        var b = dec[1];

        foreach (int y in list)
        {
            if (y == a)
            {
                Console.WriteLine(b);
            }
            else
            {
                Console.WriteLine(a);
            }
        }
    }
}


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

#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long int lli;
typedef pair<int, int> Pii;

typedef vector<vector<int> > Matrix;

Matrix mul(const Matrix& A, const Matrix & B, const int mod) {
  Matrix C(A.size(), vector<int>(B[0].size()));
  
  for(int i = 0; i < A.size(); i++) {
    for(int k = 0; k < B.size(); k++) {
      for(int j = 0; j < B[0].size(); j++) {
        C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
      }
    }
  }

  return C;
}

// A^n
Matrix pow(Matrix A, int n, int mod) {
  Matrix B(A.size(), vector<int>(A.size()));
  
  for(int i = 0; i < A.size(); i++) {
    B[i][i] = 1;
  }

  while(n) {
    if(n & 1) B = mul(B, A, mod);
    A = mul(A, A, mod);
    n >>= 1;
  }

  return B;
}

int main() {
  int n, m, a, b, c, t;
  
  while(cin >> n >> m >> a >> b >> c >> t) {
    if((n | m | a | b | c | t) == 0) break;

    Matrix B(n, vector<int>(1));
    rep(i, n) cin >> B[i][0];

    Matrix A(n, vector<int>(n));
    rep(i, n) {
      if(i - 1 >= 0) A[i][i - 1] = a;
      A[i][i] = b;
      if(i + 1 < n) A[i][i + 1] = c;
    }

    A = pow(A, t, m);
    A = mul(A, B, m);
    
    rep(i, n) {
      cout << A[i][0] << (i + 1 == n ? '\n' : ' ');
    }
  }

  return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int a[3] = {};
    rep(i,3)cin >> a[i];
    sort(a,a+3);
    if(a[0] != a[2] && (a[0] == a[1] || a[1] == a[2]))yn;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int s[n];
    int t[n];
    long long ans=0;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    for(int i=0;i<n;i++){
        if(s[i]>t[i]){
            ans-=s[i]-t[i];
        }
        else{
            ans+=(t[i]-s[i])/2;
        }
    }
    if(ans>=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int N, M; cin >> N >> M;
		if (N == 0) break;
		vector< pair<int, i_i> > v(M);
		for (int i = 0; i < M; i++) {
			int t, s, d; cin >> t >> s >> d;
			s--; d--;
			v[i] = make_pair(t, i_i(s, d));
		}
		sort(v.begin(), v.end());
		vector<bool> a(N);
		a[0] = true;
		for (int i = 0; i < M; i++) {
			int s = v[i].second.first, t = v[i].second.second;
			a[t] = a[t] || a[s];
		}
		int cnt = 0;
		for (int i = 0; i < N; i++)
			cnt += a[i];
		cout << cnt << endl;
	}
}

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

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

  int max_number = 1;
  int max_count = 0;
  for (int i = 1; i <= n; i++) {
    int count = 0;
    int num = i;
    while (num % 2 == 0) {
      count++;
      num /= 2;
    }
    if (count > max_count) {
      max_number = i;
      max_count = count;
    }
  }

  cout << max_number << endl;
  return 0;
}

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

using namespace std;

int main(){
	
	int n;
	
	char str[2000];
	
	cin >> n;
	
	cin.ignore();
	
	for(int loop = 0; loop < n; loop++){
		gets(str);
		
		for(int i = 0; i <= 1000; i++){
			if(str[i] == 'H' && str[i + 1] == 'o' && str[i + 2] == 's' && str[i + 3] == 'h' && str[i + 4] == 'i' && str[i + 5] == 'n' && str[i + 6] == 'o'){
				str[i + 6] = 'a';
			}
			if(str[i] == '\0'){
				break;
			}
			cout << str[i];
		}
		
		cout << endl;
	}
	
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	int (*coord)[100] = new int[100][100];
	int xs[100];
	int ys[100];
	int x, y, h;
	int k = 0;
	while (cin >> x >> y >> h)
	{
		xs[k] = x;
		ys[k++] = y;
		coord[x][y] = h;
	}
	
	long long int pre_H;
	long long int H = 1;
	long long int max_H = 1000000000 + 201;
	int i = 0;
	int Cx = 0;
	int Cy = 0;
	for (Cx = 0; i < N && Cx <= 100; Cx++)
		for (Cy = 0; i < N && Cy <= 100; Cy++)
		{
			long long int temp_H = 0;
			for (i = 0; i < N; i++)
			{
				if (coord[xs[i]][ys[i]] > 0)
				{
					H = abs(xs[i] - Cx) + abs(ys[i] - Cy) + coord[xs[i]][ys[i]];
					if (temp_H == 0)
						temp_H = H;
					if (H != temp_H || H > max_H) 
						break;
				}
				else
				{
					max_H = abs(xs[i] - Cx) + abs(ys[i] - Cy) + coord[xs[i]][ys[i]];
					if (temp_H > max_H)
						break;
				}
			}
				
		}
	delete[] coord;
	cout << Cx - 1 << ' ' << Cy - 1 << ' ' << H;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int x, y;
    cin >> x >> y;
    int m = 2 * x;
    int M = 4 * x;
    if (y < m || M < y) {
        cout << "No" << endl;
        return 0;
    }
    if ((y - m) % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define int long long
//#define int __int128
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")

#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")

#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const int N = 100005;

string S;
int n;
int a[N];

void solve () {
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    cin >> S;
    S = "#" + S;
    vector < int > V;
    V.pb (0);
    for (int i = n; i >= 1; i--){
        for (int x : V)
            if ((a[i] ^ x) < a[i])
                a[i] ^= x;
        if (S[i] == '1'){
            if (a[i]){
                cout << 1 << endl;
                return;
            }
            continue;
        }
        if (a[i])
            V.pb (a[i]);
        sort (V.begin(), V.end());
        reverse (V.begin(), V.end());
    }
    cout << 0 << endl;
}

main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    int T;
    cin >> T;
    while (T--){
        solve ();
    }
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n, m; cin >> n >> m;
  ll sum = 0;
  for(ll i=0; i<m; ++i){
    ll x; cin >> x;
    sum += x;
  }
  ll res = sum>n ? -1 : n-sum;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
int n;
string s;
// 四則演算の式をパースして、その評価結果を返す。
pair<int,int> expression(int &begin);

// 乗算除算の式をパースして、その評価結果を返す。
pair<int,int> term(int &begin);
// 数字の列をパースして、その数を返す。
pair<int,int> number(int &begin);
pair<int,int> number(int &begin) {
    int ret = 1;
    begin++;
    return MP(1,1);
}
pair<int,int> factor(int &begin) {
    if (s[begin]== '(') {
        begin++; // '('を飛ばす。
        pair<int,int> ret = expression(begin);
        begin++; // ')'を飛ばす。
        return ret;
    } else {
        return number(begin);
    }
}
pair<int,int> term(int &begin) {
    pair<int,int> ret = factor(begin);
    vector<pair<int,int> > v;
    v.push_back(ret);
    for (;;) {
        if(begin==n)break;
        if(s[begin]!='&')break;
        begin++;
        pair<int,int> p = factor(begin);
        v.push_back(p);
    }
    pair<int,int> res=MP(inf,inf);
    int smz = 0;
    int smo = 0;
    for(auto x:v){
        res.first = min(res.first,smo + x.first);
        smz += x.first;
        smo += x.second;

    }
    res.second = min(res.second,smo);
    
    return res;
}

pair<int,int> expression(int &begin) {
    pair<int,int> ret = term(begin);
    vector<pair<int,int> > v;
    v.push_back(ret);
    for (;;) {
        if(begin==n)break;
        if (s[begin] != '|') {
           break;
        }
        begin++;
        pair<int,int> p = term(begin);
        v.push_back(p);
    }
    pair<int,int> res=MP(inf,inf);
    int smz = 0;
    int smo = 0;
    for(auto x:v){
        res.second = min(res.second,smz + x.second);
        smz += x.first;
        smo += x.second;

    }
    res.first = min(res.first,smz);
    return res;
}
int main(){
    cin >> s;
    n = s.size();
    int id = 0;
    pair<int,int> res = expression(id);
    cout << res.first << " " << res.second << endl;
    return 0;
}


Measured memory_bytes: 3336
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)
LB = A[-1] * 2  # 一回の握手で上がる幸福度の下限は、左手も右手もパワーが一番低い人を握った場合
UB = A[0] * 2   # 一回の握手で上がる幸福度の上限は、左手も右手もパワーが一番高い人を握った場合

# cgs[i] は パワーがi以上のゲストの数
cgs = [0] * (UB + 1)
for a in A:
    cgs[a] += 1
for i in range(UB, 0, -1):
    cgs[i - 1] += cgs[i]


# 組み合わせの数がM以上になる一回で発生する幸福度の閾値を二分探索する
def is_ok(n):
    m = 0
    for a in A:
        m += cgs[max(n - a, 0)]
    return m >= M


ok = LB
ng = UB + 1
while ng - ok > 1:
    m = (ok + ng) // 2
    if is_ok(m):
        ok = m
    else:
        ng = m

# cps[i] は A[0]～A[i] の累積和
cps = A[:]
for i in range(1, N):
    cps[i] += cps[i - 1]

result = 0
for a in A:
    t = cgs[max(ok - a, 0)]
    if t != 0:
        result += a * t + cps[t - 1]
        M -= t
result += ok * M
print(result)


Measured memory_bytes: 16944
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

ll g1(ll n, ll p){
	if(n==0){
		return 0;
	}
	return g1(n / p, p) + n / p;
}

ll g(ll n,ll p){
	if(p==2){
		return g1(n / 2, p) + n / 2;
	}
	return g1(n / 2, p);
}

int main()
{
	ll n;
	cin >> n;
	if (n % 2 || n < 10)
	{
		cout << 0 << endl;
		return 0;
	}
	cout << min(g(n, 2), g(n, 5)) << endl;
}


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

using namespace std; 

const int maxn = 1e5; 

int n, a[4][maxn + 5], p[maxn + 5], num[2]; 

int main() {
    scanf("%d", &n); 
    for (int i = 1; i <= 3; i++) {
        for (int j = 1; j <= n; j++) {
            scanf("%d", &a[i][j]); 
            if (i == 2) {
                p[j] = (a[i][j] + 1) / 3;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        if (abs(a[1][i] - a[3][i]) != 2 || abs(a[1][i] - a[2][i]) != 1 || abs(a[2][i] - a[3][i]) != 1) {
            puts("No"); 
            return 0; 
        }
        if (p[i] % 2 != i % 2) {
            puts("No");
            return 0; 
        }
        int mn = min(a[1][i], a[3][i]), mx = max(a[1][i], a[3][i]); 

        if (mx % 3 != 0 || mn % 3 != 1) {
            puts("No");
            return 0; 
        }
        if (a[1][i] % 3 == 0) {
            num[i & 1]++; 
        }
    }
    for (int i = 1; i <= n; i++) {
        while (p[i] != i) {
            num[!(i & 1)]++; swap(p[i], p[p[i]]); 
        }   
    }
    if ((num[0] & 1) or (num[1] & 1)) puts("No");  
    else puts("Yes"); 
    return 0; 
}

Measured memory_bytes: 1792
#include<stdio.h>

  int main() 

{

    int i, j = 0, seisu[10000], max = -10000000, min = 10000000, num;

    long int sum = 0;

    scanf("%d", &i);

      while(j != i)

    {

        scanf("%d", &seisu[j]);

          j++;

    }

      j = 0;

      for(j=0; j<i; j++)    {

        num = seisu[j];

          if(max < num)         {

            max = num;

        }

                 if(min > num)         {

            min = num;

        }

          sum = sum + num;

    }

      printf("%d %d %ld\n", min, max, sum);

      return 0;

} 

Measured memory_bytes: 636
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    e = [0] * n
    w = [0] * n
    for i in range(n):
        if s[i] == "W":
            w[i] += 1 if i == 0 else w[i-1] + 1
        else:
            w[i] += 0 if i == 0 else w[i-1]

        if s[-i-1] == "E":
            e[-i-1] += 1 if i == 0 else e[-i] + 1
        else:
            e[-i - 1] += 0 if i == 0 else e[-i]
    mt = 10 ** 10
    for i in range(n):
        mt = min(mt, e[i] + w[i] - 1)
    print(mt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 46708
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
#define all(x) (x).begin(),(x).end()


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

    int n, x, y;
    cin >> n >> x >> y;
    x--, y--;
    vector<vector<int>> dist(n,vector<int>(n, -1));
    for(int i=0; i<n; i++){
        queue<int> que;
        que.push(i);
        dist[i][i] = 0;
        while(!que.empty()){
            int v = que.front(); que.pop();
            vector<int> nvs;
            if(v > 0) nvs.push_back(v-1);
            if(v < n+1) nvs.push_back(v+1);
            if(v == x) nvs.push_back(y);
            if(v == y) nvs.push_back(x);
            for(int nv: nvs){
                if(dist[i][nv] == -1){
                    dist[i][nv] = dist[i][v] + 1;
                    que.push(nv);
                }
            }
        }
    }
    vector<int> res(n, 0);
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            res[dist[i][j]]++;
        }
    }
    for(int d=1; d<n; d++){
        cout << res[d] << endl;
    }
}

Measured memory_bytes: 16000
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
using Graph =vector<vector<int>>;
int main(){
    int n,m;
    cin >> n >> m;
    Graph g(n+1);
    vector<vector<int>> ab(m,vector<int>(1));//a,b
    for(int i=0; i<m; i++){
        int a,b;
        cin >> ab[i][0] >> ab[i][1];
        a=ab[i][0];
        b=ab[i][1];
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> dist(n+1,-1);
    queue<int> que;
    dist[1]=0;
    que.push(1);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(int nv : g[v]){
            if(dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
    bool ans=true;
    vector<int> to(n+1);
    for(int i=0; i<m; i++){
        int a,b;
        a=dist[ab[i][0]];
        b=dist[ab[i][1]];
        if(abs(a-b)>1){
            ans=false;
            break;
        }
        else{
            if(a>b) to[ab[i][0]]=ab[i][1];
            else if(b>a) to[ab[i][1]]=ab[i][0];
        }  
    }
    if(ans){
        cout << "Yes" << endl;
        for(int i=2; i<=n; i++){
            cout << to[i] << endl;
        }
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 21584
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
int main() {
    fastio
    double D,T,S;
    cin>>D>>T>>S;
    if(D/S<=T)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

using namespace std;

int num1[300010];
int num2[300010];
int main()
{
    int n;
    string s;
    scanf("%d",&n);
    memset(num1,0,sizeof(num1));
    memset(num2,0,sizeof(num2));
    cin >> s;
    for(int i=1;i<n;i++)
    {
        if(s[i-1]=='E')
            num1[i]=num1[i-1]+1;
        else
            num1[i]=num1[i-1];
    }
    for(int i=n-2;i>=0;i--)
    {
        if(s[i+1]=='W')
            num2[i]=num2[i+1]+1;
        else
            num2[i]=num2[i+1];
    }
    int imax=0;
    for(int i=0;i<n;i++)
        imax=max(imax,num1[i]+num2[i]);
    cout << n-1-imax << endl;
    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    ll a, b, c; cin >> a >> b >> c;
    vector<ll> d;
    if(a % 2 != 0){
        d.push_back(b * c);
    }else d.push_back(0);
    if(b % 2 != 0){
        d.push_back(a * c);
    }else d.push_back(0);
    if(c % 2 != 0){
        d.push_back(a * b);
    }else d.push_back(0);
    cout << *min_element(d.begin(), d.end()) << endl;
    
}

Measured memory_bytes: 256
import itertools
import decimal
import math
import collections
import sys
input = sys.stdin.readline
import copy

# S=(input())
# N=int(input())
# N,K=map(int,input().split())
# ListA=list(map(int,input().split()))
# ListA.sort()#reverse=True)



def resolve():
    H,W,K=map(int,input().split())

    s=[list(map(str,list(input()))) for i in range(H)]

    lisH= [num for num in range(1,H+1)]
    resultH = []
    for n in range(1,len(lisH)+1):
        for conb in itertools.combinations(lisH, n):
            resultH.append(list(conb))
    resultH.append([0])

    lisW= [num for num in range(1,W+1)]
    resultW = []
    for n in range(1,len(lisW)+1):
        for conb in itertools.combinations(lisW, n):
            resultW.append(list(conb))
    resultW.append([0])

    ans=0
    for h in range(len(resultH)):
        paintH=resultH[h]
        for w in range(len(resultW)):
            paintW=resultW[w]
            tmp=copy.deepcopy(s)
            for delH in paintH:
                if(delH!=0):
                    for i in range(W):
                        tmp[delH-1][i]="."
            for delW in paintW:
                if(delW!=0):
                    for i in range(H):
                        tmp[i][delW-1]="."  
            Cnt=0
            for i in range(H):
                Cnt+=tmp[i].count("#")
            if(Cnt==K):
                ans+=1
            

    print(ans) 



resolve()




Measured memory_bytes: 10040
#!/usr/bin/env ruby
a, b, c, x, y = gets.chomp.split.map(&:to_i)

ans_a = 0
ans_b = 0
ans_c = 0

if (a + b) >= 2 * c
  if x >= y
    if a >= 2 * c
      ans_c = x * 2
      ans_a = 0
      ans_b = 0
    else
      ans_c = y * 2
      ans_a = x - y
      ans_b = 0
    end
  else
    if b >= 2 * c
      ans_c = y * 2
      ans_a = 0
      ans_b = 0
    else
      ans_c = x * 2
      ans_a = 0
      ans_b = y - x
    end
  end
else
  ans_a = x
  ans_b = y
  ans_c = 0
end

puts a * ans_a + b * ans_b + c * ans_c


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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() {
  int A = in(), P = in();
  print((A * 3 + P) / 2);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
int main(){int n,ans = 0;cin>>n;vector<string>lis(n);REP(i, 0, n){cin >>lis[i];}REP(b, 0, n){vector<vector<char>>afterlis(n,vector<char>(n));REP(i, 0, n){REP(l, 0, n){afterlis[i][l]=lis[i][(l + b) % n];}}int f = 1;REP(i, 0, n){REP(l, 0, n){if(afterlis[i][l] != afterlis[l][i]){f=0;i=n;break;}}}ans+=f;}cout<<ans*n<<endl;}

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

using namespace std;

typedef long long ll;

struct kraw
{
    int a, b;
};

vector<ll> f, wlk;

void Stworz(int n)
{
    for (int i = 0; i < n; ++i)
    {
        f.push_back(i);
        wlk.push_back(1);
    }
}

int Find(int a)
{
    if (a == f[a])
        return a;
    int fa = Find(f[a]);
    f[a] = fa;
    return fa;
}

ll Union(int a, int b)
{
    int fa = Find(a);
    int fb = Find(b);
    int nowe = 0;
    if (fa != fb)
    {
        nowe = wlk[fa] * wlk[fb];
        f[fb] = fa;
        wlk[fa] += wlk[fb];
    }
    return nowe;
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, m;
    cin >> n >> m;
    vector<kraw> K(m);
    for (int i = 0; i < m; ++i)
    {
        cin >> K[i].a >> K[i].b;
        --K[i].a;
        --K[i].b;
    }
    vector<ll> polaczone(m, 0);
    Stworz(n);
    polaczone[m - 1] = 0;
    for (int i = m - 2; i >= 0; --i)
        polaczone[i] = polaczone[i + 1] + Union(K[i + 1].a, K[i + 1].b);
    for (int i = 0; i < m; ++i)
        cout << (n * (n - 1) / 2) - polaczone[i] << endl;
    return 0;
}


Measured memory_bytes: 4716
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int N;cin>>N;
    vector<pair<int,int>> v(N);
    REP(i,N) cin>>v[i].second>>v[i].first;
    sort(All(v));
    bool ok=true;
    ll t=0;
    REP(i,N){
        t+=v[i].second;
        if(v[i].first<t) ok=false;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 1792
n, q = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)

h = Hash.new(0)
numbers = [0]
arr.each{|x|
    h[x] += 1
    numbers << x
}

arr2 = []
q.times{
    arr2 << gets.chomp.split.map(&:to_i)
    numbers << arr2.last[0]
    numbers << arr2.last[1]
}
numbers.uniq!
numbers.sort!

idx = {}
numbers.each_with_index{|x, i| idx[x] = i}

cum = Array.new(numbers.length, 0)
h.each{|k, v| cum[idx[k]] = v}
1.upto(cum.length - 1){|i| cum[i] += cum[i - 1]}

arr2.each{|l, r| puts cum[idx[r]] - cum[idx[l] - 1]}


Measured memory_bytes: 47432
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int bit = 0;
        for(int i = 0; i < N; i++) {
        	bit |= sc.nextInt();
        }
        System.out.println(Integer.numberOfTrailingZeros(bit));
    }
}

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

int main(){
    int n;
    int t[110000], x[110000], y[110000];
    t[0] =x[0] =y[0] =0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }

    bool can = true;
    for (int i=0; i<n; i++){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        if (dt < dist) can = false;
        if (dist%2 != dt%2) can = false;
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define fs first
#define se second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int maxn=5e5+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

char s[maxn];
int mx1[maxn];
int mx2[maxn];
int kk[maxn];

int main(){
	int n,k,c;
	scanf("%d%d%d",&n,&k,&c);
	scanf("%s",s+1);
	int top=0;
	kk[0]=0;
	for(int i=1;i<=n;i++){
		mx1[i]=mx1[i-1];
		kk[i]=kk[i-1];
		if(i>kk[i]&&s[i]=='o'){
			kk[i]=i+c;
			mx1[i]++;
		}
	}
	top=n+1;
	for(int i=n;i>=1;i--){
		mx2[i]=mx2[i+1];
		if(i<top&&s[i]=='o'){
			top=i-c;
			mx2[i]++;
		}
	}
	for(int i=1;i<=n;i++){
		if(s[i]=='o'){
			if(mx1[i-1]+mx2[max(kk[i-1]+1,i+1)]<k){
				printf("%d\n",i);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  vector<double> sum(n + 1);
  for (int i = 0; i < n; ++i) {
    sum[i + 1] = sum[i] + (p[i] * (p[i] + 1)) / 2 / (1.0 * p[i]);
  }
  double ans = 0;
  for (int i = 1; i + k - 1 <= n; ++i) {
    ans = max(ans, sum[i + k - 1] - sum[i - 1]);
  }
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,mn,mx;
  int gap;
  int pass;
  while(1){
    gap=0;
    pass=0;
    cin>>m>>mn>>mx;
    if(m==0 && mn==0 & mx==0) break;
    int score[m];
    for(int i=0;i<m;i++){
      cin>>score[i];
    }
    for(int i=mn;i<=mx;i++){
      if(gap<=score[i-1]-score[i]){
	gap=score[i-1]-score[i];
	pass=i;
      }
      /* cout<<pass<<" "<<gap<<endl;*/
    }
    cout<<pass<<endl;
  }
  return 0;
}
  


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

using namespace std;

string s;
int res , ans;

int main() {
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'R') res++;
		else res = 0;
		ans = max(ans , res);
	}
	printf("%d" , ans);
	
	return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  ll n,k;cin>>n>>k;
  vector<ll> a(n);
  for(ll i=0;i<n;++i)cin>>a[i];
  vector<ll> pre(n,0LL),post(n,0LL);
  for(ll i=0;i<n;++i){
    ll cpre =0LL;
    ll cpost =0LL;
    for(ll j=0;j<n;++j){
      if(a[i]>a[j]){
        ++cpost;
        if(i<j)++cpre;
      }
    }
    pre[i] = cpre;
    post[i] = cpost;
  }
  ll out=0LL;
  for(int i=0;i<n;++i) out += (k*pre[i])%mod;
  out = out%mod;
  for(int i=0;i<n;++i) {
    ll ele = k*(k-1)/2LL;
    ele = ele%mod;
    out += post[i]*ele;
    out = out%mod;
  }
  cout << out << endl;
  return 0;
}


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

const int INF = 100000000;
typedef pair<int, int> P;

int main(){
    int H, W;
    char grid[51][51];
    int d[51][51];
    const int dh[4] = { 1,  0, -1,  0};
    const int dw[4] = { 0,  1,  0, -1};
    queue<P> que;
    int count_white = 0;

    cin >> H >> W;
    for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
            cin >> grid[h][w];
            d[h][w] = INF;
            count_white += (grid[h][w] == '.');
        }
    }

    que.push(P(0,0));
    d[0][0] = 0;

    while(que.size()){
        P p = que.front(); que.pop();
        if(p.first == H && p.second == W) break;

        for(int i=0;i<4;i++){
            int nh = p.first + dh[i];
            int nw = p.second + dw[i];

            bool can_move = (0 <= nh && nh < H) && (0 <= nw && nw < W) && (grid[nh][nw] != '#');
            bool never_been = (d[nh][nw] == INF);
            if(can_move && never_been){
                que.push(P(nh, nw));
                d[nh][nw] = d[p.first][p.second] + 1;
            }
        }
    }

    if(d[H-1][W-1] == INF){
        cout << -1 << endl;
    }
    else{
        cout << count_white - d[H-1][W-1] - 1 << endl;
    }
    return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;
const int ROW_MAX = 100;

struct Sushi {
    ll cost, nutrition;
};

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

    vector<Sushi> sushi_lr(n), sushi_rl;
    rep(i, n) cin >> sushi_lr[i].cost >> sushi_lr[i].nutrition;
    sushi_rl = sushi_lr;
    reverse(sushi_rl.begin(), sushi_rl.end());
    rep(i, n) sushi_rl[i].cost = c - sushi_rl[i].cost;

    vector<ll> candidate;

    if (n == 1) {
        ll e1 = sushi_lr[0].nutrition - sushi_lr[0].cost;
        ll e2 = sushi_lr[0].nutrition - (c - sushi_lr[0].cost);
        ll ans = max({0ll, e1, e2});
        cout << ans << endl;
        ret();
    }

    auto check = [&] {
        vector<ll> lr_nutrition_sum(n);
        vector<ll> rl_nutrition_sum(n);

        rep(i, n) {
            lr_nutrition_sum[i] = sushi_lr[i].nutrition;
        }
        rep(i, n) {
            if (i == 0)continue;
            lr_nutrition_sum[i] += lr_nutrition_sum[i - 1];
        }

        rep(i, n) {
            rl_nutrition_sum[i] = sushi_rl[i].nutrition;
        }
        rep(i, n) {
            if (i == 0)continue;
            rl_nutrition_sum[i] += rl_nutrition_sum[i - 1];
        }


        vector<ll> rl_max_total(n);
        rep(i, n)rl_max_total[i] = rl_nutrition_sum[i] - sushi_rl[i].cost;

        vector<ll> lr_max_total(n);
        rep(i, n)lr_max_total[i] = lr_nutrition_sum[i] - sushi_lr[i].cost * 2;

        candidate.push_back(*max_element(rl_max_total.begin(), rl_max_total.end()));

        rep(i, n) {
            if (i == 0)continue;
            lr_max_total[i] = max(lr_max_total[i], lr_max_total[i - 1]);
        }

        rep(i, n - 1) {
            int rl = i;
            int lr = n - rl - 2;

            ll now = rl_max_total[rl] + lr_max_total[lr];
            candidate.push_back(now);
        }

    };
    check();
    swap(sushi_lr, sushi_rl);
    check();

    cout << *max_element(candidate.begin(), candidate.end()) << endl;

}




Measured memory_bytes: 8500
#include <bits/stdc++.h>
#define l_ength size
const int inf = 1000000;
using ll = long long;
using namespace std;

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

int main(){
	int n, m; cin >> n >> m;
	int dist[n][n];
	vector<edge> graph;
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j < n; ++j ){
			dist[i][j] = ( i == j ) ? 0 : inf;
		}
	}
	for( int i = 0; i < m; ++i ){
		int a, b, c; cin >> a >> b >> c; --a; --b;
		dist[a][b] = dist[b][a] = c;
		graph.push_back( ( edge ){ a, b, c } );
	}
	for( int k = 0; k < n; ++k ){
		for( int i = 0; i < n; ++i ){
			for( int j = 0; j < n; ++j ){
				/*
				ここで inf の足し算が行われることに注意
				1<<30 のとき inf+inf == 1<<31 でオーバーフローする
				*/
				dist[i][j] = min( dist[i][j], dist[i][k]+dist[k][j] );
			}
		}
	}
	/*
	使われない辺の必要条件: 辺 s → t について，d(s, t) < c(s, t) （⇔ その辺を使わない最短経路がある）
	この必要条件に入らない辺については d(s, t) = c(s, t) となるが，これは s → t のルートでこの辺を使うことを示している
	よって「ある辺が使われる ⇔ d(s, t) = c(s, t) 」が成り立ち，これをチェックすれば O(M) で計算できる
	*/
	int ans = 0;
	for( auto e : graph ) if( dist[e.from][e.to] < e.cost ) ++ans;
	cout << ans << endl;
	return 0;
}

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

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


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  string a;cin>>a;
  int x;
  for(int i=0; i<3; i++){
    if(a[i]=='o'){
      x++;
    }
  }
  cout<<700+100*x<<endl;
}

Measured memory_bytes: 256
using System;
class Hello
{
    static void Main(string[] args)
    {
       
            string[] s = Console.ReadLine().Split(' ');
            int x = int.Parse(s[0]);
            int y = int.Parse(s[1]);
            if (x == y)
            {
                Console.WriteLine("a == b");
            }
            else if (x > y) 
            {
                Console.WriteLine("a > b");
            }
            else if (x < y) 
            {
                Console.WriteLine("a < b");
            }
    }
}


Measured memory_bytes: 17920
from math import *





s=input()

c=0

for i in range(len(s)):
	for j in range(i,len(s)):
		d=s[i:j+1]
		if(len(d)==(d.count('A')+d.count('C')+d.count('G')+d.count('T'))):
			c=max(c,len(d))
print(c)

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,v) VL v(n);rep(i,n)cin>>v[i]
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define LINE puts("------------------")
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
typedef struct{ll to;ll cost;} Graphs;
typedef V<V<Graphs>> AdjList;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}

template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<class T>T center(T a,T b,T c){
  if( (a<=b&&b<=c)||(a>=b&&b>=c) )return b;
  if( (b>=a&&a>=c)||(b<=a&&a<=c) )return a;
  return c;
}
void print(){cout<<endl;}
template<class Head,class... Tail>
void print(Head&& head, Tail&&... tail){
  cout<<head<<", ";
  print(forward<Tail>(tail)...);
}
void input(){}
template<class Head,class... Tail>
void input(Head&& head, Tail&&... tail){
  cin>>head;
  input(forward<Tail>(tail)...);
}
template<typename T>
ostream &operator<<(ostream&out,const vector<T>&v){
  if(!v.empty()){
    copy(v.begin(),v.end(),ostream_iterator<T>(out,", "));
    out<<"\b\b";
  }
  return out;
}
template<typename T1, typename T2>
ostream &operator<<(ostream&out,const pair<T1,T2>&p){
  out<<p.first<<", "<<p.second;
  return out;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  str s;
  cin>>s;

  stack<char> st;
  for(auto c:s){
    if(st.empty())st.push(c);
    else if(c=='T'){
      if(st.top()=='S')st.pop();
      else st.push(c);
    }
    else st.push(c);
  }
  out(SZ(st));


  return 0;
}


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

using namespace std;
using ll = long long;

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

    ll nums[5] = {0};

    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;

        char top = s.at(0);
        if (top == 'M') {
            nums[0]++;
        } else if (top == 'A') {
            nums[1]++;
        } else if (top == 'R') {
            nums[2]++;
        } else if (top == 'C') {
            nums[3]++;
        } else if (top == 'H'){
            nums[4]++;
        }
    }

    vector<bool> bit = {false, false, true, true, true};
    ll cnt = 0;

    do {
        ll tmp = 1;
        for (int i = 0; i < 5; ++i) {
            if (bit.at(i)) {

                tmp *= nums[i];
            }
        }
        cnt += tmp;
    } while (next_permutation(bit.begin(), bit.end()));

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
def make_tree(n):
    i = 2
    while True:
        if i >= n * 2:
            tree = [0] * i
            break
        else:
            i *= 2
    return tree

def update(i, x):
    i += len(tree) // 2
    tree[i] = x
    i //= 2
    while True:
        if i == 0:
            break
        tree[i] = max(tree[2 * i], tree[2 * i + 1])
        i //= 2
    return

def find(s, t):
    s += len(tree) // 2
    t += len(tree) // 2
    ans = 0
    while True:
        if s > t:
            break
        if s % 2 == 0:
            s //= 2
        else:
            ans = max(ans, tree[s])
            s = (s + 1) // 2
        if t % 2 == 1:
            t //= 2
        else:
            ans = max(ans, tree[t])
            t = (t - 1) // 2
    return ans

n, t = map(int, input().split())
a = list(map(int, input().split()))
tree = make_tree(n)
l = len(tree)
for i in range(n):
    update(i, a[i])
b = [0] * n
for i in range(n - 1):
    b[i] = find(i + 1, n - 1) - a[i]
print(b.count(max(b)))

Measured memory_bytes: 15060
import java.util.*;

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

        int D = sc.nextInt();

        if(D==22){
            System.out.println("Christmas Eve Eve Eve");
        }
        else if(D==23){
            System.out.println("Christmas Eve Eve");
        }
        if(D==24){
            System.out.println("Christmas Eve");
        }
        if(D==25){
            System.out.println("Christmas");
        }
    }
}

Measured memory_bytes: 19924