akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> T lcm(T a, T b){return a / gcd(a,b) * b;}


int main() {
  int n; cin >>n;
  int d;
  if (n==2){
    int a,b; cin >>a >>b;
    d = gcd(a,b);
  }else{
    int a,b,c; cin >>a >>b >>c;
    d = gcd(gcd(a,b), gcd(b,c));
  }
  for (int i=1; i<=d; i++){
    if (d % i == 0) cout <<i <<endl;
  }
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE=1e6+1000;
const int SIZE2=5010;
const int SIZE3=400;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string S;
ut N,M,K,X,L,W,H;
// ut A,B,C,D,E,F,G,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;

////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////
LL A[SIZE];
LL solve(){
	cin >> N;
	int maxer=0;
	EFOR(i,1,N){
		cin >> A[i];
		if(abs(A[maxer])<=abs(A[i])){
			maxer=i;
		}
	}
	cout << N*2-1 << endl;
	EFOR(i,1,N){
			cout << maxer << " "<< i << endl;
	}
	if(A[maxer]>=0){
		EFOR(i,1,N-1){
			cout << i << " "<<i+1 << endl;
		}
	}
	else{
		RFOR(i,N,2){
			cout << i << " " << i-1 << endl;
		}
	}
	return 0;
}
signed main(){
	solve();
	return 0;
}

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

char a[51][51];
char b[51][51];

int main(void){
    
    int n,m;
    cin >> n >> m;
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < m; j++){
            cin >> b[i][j];
        }
    }
    
    for(int i = 0; i < n-m+1; i++){
        for(int j = 0; j < n-m+1; j++){
            bool f = true;
            for(int k = 0; k < m; k++){
                for(int l = 0; l < m; l++){
                    if(a[i+k][j+l] != b[k][l]) f = false;
                }
            }
            if(f){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
    
    
}


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

int main() {
  int n;
  string s;

  cin >> n;
  cin >> s;
  map<char, int> Map;
  for (int i = 0; i < n; i++) ++Map[s[i]];
  long long sum = Map['R'] ;
  sum *= Map['G'];
  sum *= Map['B'];

  long long comp = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int p = j + i + 1;
      int q = p + i + 1;
      if (q < n) {
        if (s[j] != s[p] && s[j] != s[q] && s[p] != s[q]) ++comp;
      }
    }
  }
  cout << sum - comp << endl;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define int long long
#define il inline 
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
const int maxn = 2333, mod = 1000000007;
inline int read()
{
	register char cc = getchar(); register int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus;
}
string s,t,p;
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
int n, m, dp[maxn][4][2];
char c[maxn];
il int dfs(int u, int use, int li) 
{
	if(use > m) return 0;
	if(u > n) return use == m;
	if(dp[u][use][li] != -1) return dp[u][use][li];
	int p = li == 1 ? c[u] - '0' : 9, ans = 0;
	rep(i, 0, p) ans += dfs(u + 1, use + (i != 0), li && i == p);
	return dp[u][use][li] = ans;
} 
signed main() 
{
	scanf("%s", c + 1), n = strlen(c + 1), m = read(), memset(dp, -1, sizeof(dp));
	cout << dfs(1, 0, 1);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        sc.close();

        if (N % 2 > 0) {
            System.out.println("No");
        } else if (S.substring(0, N/2).equals(S.substring(N/2, N))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21204
#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>;
const int INF = 1 << 29;
 
int main() {
	int n, a[102], b[102];
	cin >> n;
	rep(i, n-1) cin >> b[i];
	int ans = 0;
	rep(i, n) {
		if (i == 0) ans += b[i];
		else if (i == n-1) ans += b[i-1];
		else ans += min(b[i-1], b[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int N; cin >> N;
    int H[100];
    for(int i=0;i<N;i++){
        cin >> H[i];
    } 
    int ans = 0;
    int highest = -1;
    for(int i=0;i<N;i++){
        if(H[i] >= highest){
            ans += 1;
            highest = H[i];
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    int n,m;
    cin>>n;
    int t[n];
    rep(i,n) cin>>t[i];
    cin>>m;
    int p[m],x[m];
    rep(i,m){
        cin>>p[i]>>x[i];
    }

    rep(i,m){
        int temp=t[p[i]-1];
        t[p[i]-1]=x[i];
        int ans=0;
        rep(j,n){
            ans+=t[j];
        }
        cout<<ans<<endl;
        t[p[i]-1]=temp;
    }
    return 0;
}

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

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool visited[12][12];

void dfs(int y,int x,char data[12][12]){
	visited[y][x]=true;

	int d[]={-1,0,1,0,-1};
	rep(i,4){
		if( y+d[i]>=0 && x+d[i+1]>=0 && 12>y+d[i] && 12>x+d[i+1] )
			if( data[y+d[i]][x+d[i+1]]=='1' && visited[y+d[i]][x+d[i+1]]==false )
				dfs(y+d[i],x+d[i+1],data);
	}
}


int main(){
	char data[12][12];

	while(cin>>data[0]){
		int sum=0;
		for(int i=1;i<12;i++){
			cin>>data[i];
		}

		rep(i,12)rep(j,12)visited[i][j]=false;

		rep(i,12){
			rep(j,12){
				if( visited[i][j]==false && data[i][j]=='1' ){
					dfs(i,j,data);
					sum++;
				}
			}
		}
		cout<<sum<<endl;
	}
}

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

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int a,b;
	cin>>a>>b;
	if(abs(a-b)%2==0){
		cout<<min(a,b)+abs(a-b)/2<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
//FIRST THINK, THEN CODE.


#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}
 
const ll mxn=1e6+5;





int main()
{ 
IOS;


ll n;

cin>>n;

ll m=1;

ll c=n;

vl temp;

while(c){
  ll d=c%26;
if(!d)d+=26;
temp.pb(d);
c/=26;
if(d==26)c--;
m*=26;

}

for(int i=temp.size()-1;i>=0;i--){
  cout<<char('a'+temp[i]-1);
}

 return 0;
 
 
 
}

Measured memory_bytes: 3652
h, w, k = map(int, raw_input().split())
mod = 1000000007

def check(s):
	for i in xrange(1, w):
		if (((s>>i)&1) and ((s>>(i-1))&1)):
			return False
	return True

dp = [[0] * 101 for _ in xrange(101)]

nxt = 0
dp[0][0] = 1;
for i in xrange(1, h+1):
	for pre in xrange(0, w):
		for mask in xrange(0, 1<<(w-1)):
			if check(mask):
				if (((1)&(mask>>pre)) == 1):
					nxt = pre + 1
				elif (pre > 0 and ((mask>>(pre-1))&1) == 1):
					nxt = pre - 1
				else:
					nxt = pre
				dp[i][nxt] += dp[i-1][pre]
				dp[i][nxt] %= mod

print dp[h][k-1]


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

static const int MOD = 1000000007;

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

    if (N > M) swap(N, M);

    long long res = 1;
    if (M - N >= 2) {
        res = 0;
    } else if (N == M) {
        for (int i = 1; i <= N; i++)
            res = res * i % MOD;
        res = res * res % MOD;
        res = res * 2 % MOD;
    } else {
        for (int i = 1; i <= N; i++)
            res = res * i % MOD;
        res = res * res % MOD;
        res = res * M % MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<ll> a(n);
	vector<ll> b(n);

	ll suma = 0;
	ll sumb = 0;

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

		suma += a[i];
	}

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

		sumb += b[i];
	}

	ll c = sumb - suma;

	ll r = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] > b[i]) {
			r -= (a[i] - b[i]);
		}
		else if (b[i] > a[i]) {
			r += (b[i] - a[i]) / 2;
		}
	}

	if (r>=0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    int res;
    res = 800 * N - (N / 15) * 200;
    cout << res << endl;



    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iterator>
#include <limits>
#include <sstream>
#include <vector>

using namespace std;
int main() {
  cin.ignore(numeric_limits<streamsize>::max(), '\n');
  string s;
  getline(cin, s);
  istringstream is{s};
  istream_iterator<int> ii{is}, eol;
  vector<int> v{ii, eol};
  cin.ignore(numeric_limits<streamsize>::max(), '\n');

  auto vend = unique(v.begin(), v.end());
  cout << v[0];
  for (auto it = ++v.begin(); it != vend; ++it)
    cout << " " << *it;
  cout << endl;
}


Measured memory_bytes: 5700
//K-OS WITH THE OCDE

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007



void solve()
{
     ll n;
     cin >> n;
     cout << 1 - n;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);cin.tie(0);   
    //TEST
     solve();
}



Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/abc107/tasks/arc101_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

struct BIT {
    ll N;
    vector<ll> bit;
    BIT(ll N):N(N) {
        /* BITは[1..N]で扱う */
        bit.resize(N + 1, 0);
    }
    
    void add(int x, ll val){
        while (x <= N) {
            bit[x] += val;
            x += x & -x;
        }
    }
    
    ll sum(int x){
        ll ret = 0;
        while (x) {
            ret += bit[x];
            x &= (x - 1);
        }
        return (ret);
    }
};
ll solve(){
    ll res = 0;
    ll N; cin >> N;
    vector<ll> a(N); for(auto& in:a) cin >> in;
    
    vector<ll> ta = a;
    sort(ta.begin(),ta.end());
    ll l = 0,r = N;
    
    ll M = N*(N+1)/2;
    ll HM = (M+1)/2;
    while(r-l>1){
        ll m = (r+l)/2;
        ll ma = ta[m];
        vector<ll> cusum(N+1);
        for(int i = 0; i < N;i++){
            cusum[i+1] = cusum[i];
            if(a[i]>=ma) cusum[i+1]++;
            else cusum[i+1]--;
        }

        ll sum = 0;
        BIT bit(2*N);
        
        for(int i = 0; i <= N;i++){
            sum += bit.sum(cusum[i]+N);
            bit.add(cusum[i]+N,1);
        }
        if(sum >= HM){
            l = m;
        }else{
            r = m;
        }
    }
    res = ta[l];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 4224
INF = - 1 * 10 ** 6
n, k, c = gets.split.map(&:to_i)
days = gets.chomp.split("")
reversed_days = days.reverse

greedy_from_left = []
prev = INF
days.each_with_index do |day, i|
  next if prev + c >= i
  if day == "o"
    greedy_from_left << i + 1
    prev = i
  end
end

greedy_from_right = []
prev = INF
reversed_days.each_with_index do |day, i|
  next if prev + c >= i
  if day == "o"
    greedy_from_right << n - i
    prev = i
  end
end

if greedy_from_left.size > k || greedy_from_right.size > k
  puts
else
  (greedy_from_left & greedy_from_right).each { |day| puts day }
end


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

using ll = long long;
using ull = unsigned long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

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

    int N;
    string S;
    cin >> N >> S;
    vector<int> L(N);
    vector<int> R(N);
    L[0]   = S[0]   == 'W' ? 1 : 0;
    R[N-1] = S[N-1] == 'E' ? 1 : 0;
    
    rep1(i, N-1) {
        L[i]     = L[i-1] + (S[i]     == 'W' ? 1 : 0);
        R[N-1-i] = R[N-i] + (S[N-1-i] == 'E' ? 1 : 0);
    }    

    int ans = INT_MAX;
    chmin(ans, R[1]);
    rep1(i, N-1) {
        chmin(ans, L[i-1] + R[i+1]);
    }
    chmin(ans, L[N-2]);
    cout << ans << endl;
}


Measured memory_bytes: 2964
def main():
    n = int(input())
    cards = list(map(str, input().split()))
    bubbleSortedCards = cards[:]
    selectionSortedCards = cards[:]


    bubbleSort(bubbleSortedCards, n)
    print(' '.join(map(str, bubbleSortedCards)))
    print('Stable')

    selectionSort(selectionSortedCards, n)
    print(' '.join(map(str, selectionSortedCards)))
    print(isStable(bubbleSortedCards, selectionSortedCards, n))


def bubbleSort(numbers, n):
    for i in range(n - 1, 0, -1):
        for j in range(i):
            if int(numbers[j][1]) > int(numbers[j + 1][1]):
                numbers[j], numbers[j + 1] = numbers[j + 1], numbers[j]

def selectionSort(numbers, n):
    minj = 0

    for i in range(n):
        minj = i
        for j in range(i, n, 1):
            if int(numbers[j][1]) < int(numbers[minj][1]):
                minj = j

        if i != minj:
            numbers[i], numbers[minj] = numbers[minj], numbers[i]

def isStable(bubbleSortedCards, selectionSortedCards, n):
    for i in range(n):
        if bubbleSortedCards[i] != selectionSortedCards[i]:
            return 'Not stable'

    return 'Stable'

if __name__ == '__main__':
    main()



Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N, x; std::cin >> N >> x;
  std::vector<ll> a(N); rep(i,N) std::cin >> a[i];

  ll ans = 0;
  rep(i,N-1) {
    if ( a[i] + a[i+1] > x ) {
      ll diff = (a[i]+a[i+1]) - x;
      if ( a[i+1] >= diff ) {
        a[i+1] -= diff; ans += diff;
      }
      else {
        a[i+1] = 0;
        a[i] -= (x-a[i+1]); ans += diff;
      }
    }
  }
  std::cout << ans << std::endl;

  return 0;
}


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

using namespace std;

int main(){
    
    int a, b;

    cin >> a >> b;

    if(a >= 13) cout << b;
    else if(a < 13 and a > 5) cout << b/2;
    else cout << 0;

    cout << endl;

    return 0;

}

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

int main() {
  int n;
  cin>>n;
  int cnt=0;
  for(int i=1;i<n+1;i++){
    string s=to_string(i);
    if(s.size()%2==1)cnt++;
  }
  cout<<cnt<<endl;
}

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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n, k;
  cin >> n >> k;

  vector<int> vec;
  rep(i, n) {
    int l; cin >> l;
    vec.push_back(l);
  }

  sort(all(vec), greater<>());

  int ans = 0;
  rep(i, k) {
    ans += vec[i];
  }

  cout << ans << "\n";

  return 0;
}

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

const double delta = 1.0e-9;

int main() {
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	
	double menseki;
	int method;
	
	menseki = max(
		{double(min({y, H - y}) * W) + delta,
		double(min({x, W - x}) * H) + delta,
		double(W)*double(H)/2.0}
		);
	
	if ((W==2*x)&&(H==2*y)) 
		method = 1;
	else
		method = 0;
	
	cout << menseki << " " << method << endl;

	return 0;
}


Measured memory_bytes: 256
import fractions
import numpy as np

N, M = map(int,input().split())
A = list(map(int,input().split()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

bef = 1
LCM = 1
ans = []
for i,a in enumerate(A):
    LCM = lcm(LCM,a)
    if bef !=1:
        c, d = bef, a//2
        while c % 2 == 0 and d % 2 == 0:
            c //= 2
            d //= 2
        if c%2 != d%2:
            print(0)
            exit()
    
    b = a//2
    bef = lcm(bef,b)
    ans.append(bef)

print((M-bef)//LCM+1)

Measured memory_bytes: 29676
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a=sc.nextDouble();
        double b=sc.nextDouble();
        double c=sc.nextDouble();
        double S,L,h;
        double a1=a*a;
        double b1=b*b;
        double R=b1+a1;
        double k=Math.sqrt(R);
         
        double deg1 = c;
        double rad1 = Math.toRadians(deg1);
        double Z1= Math.cos(rad1);
        double E=a1+b1-2*a*b*Z1;
        double e=Math.sqrt(E);
         
         
        double deg = c;
        double rad = Math.toRadians(deg);
        double Z= Math.sin(rad);
        S=a*b*Z/2;
        L=a+b+e;
        h=b*Z;
        System.out.println(S);
        System.out.println(L);
        System.out.println(h);
    }
}


Measured memory_bytes: 27804
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
ll seg[800000];
ll lazy[800000];
ll power[200050];
ll prefpow[200050];
ll mod = 998244353;
int sz;
int n,q;
void init(){
    sz = 1;
    while(sz<n) sz*=2;
    power[0] = 1;
    for(int i=1;i<=200005;i++){
        power[i] = (power[i-1]*10%mod);
    }
    for(int i=1;i<=200005;i++){
        prefpow[i] = prefpow[i-1]+power[i-1];
    }
}
ll getSum(int lx,int rx){
    return (prefpow[n-lx]-prefpow[n-rx])%mod;
}
void prop(int x,int lx,int rx){
    if(lazy[x]==0) return;
    seg[x] = lazy[x]*1LL*getSum(lx,rx)%mod;
    if(rx-lx!=1){
        lazy[2*x+1] = lazy[x];
        lazy[2*x+2] = lazy[x];
    }
    lazy[x] = 0;
}
void build(int x=0,int lx=0,int rx=sz){
    if(rx-lx==1) seg[x] = power[n-lx-1];
    else{
        int m = (lx+rx)/2;
        build(2*x+1,lx,m);
        build(2*x+2,m,rx);
        seg[x] = (seg[2*x+1]+seg[2*x+2])%mod;
    }
}
void upd(int l,int r,int d,int x=0,int lx=0,int rx=sz){
    prop(x,lx,rx);
    if(lx>=l && rx<=r){
        seg[x] = d*1LL*getSum(lx,rx)%mod;
        if(rx-lx!=1){
            lazy[2*x+1] = d;
            lazy[2*x+2] = d;
        }
        return;
    }
    if(lx>=r || rx<=l) return;
    int m = (lx+rx)/2;
    upd(l,r,d,2*x+1,lx,m);
    upd(l,r,d,2*x+2,m,rx);
    seg[x] = (seg[2*x+1]+seg[2*x+2])%mod;
}
ll query(){
    prop(0,0,sz);
    if(seg[0]<0) seg[0]+=mod;
    return seg[0];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q;
    init();
    build();
    for(int i=0;i<q;i++){
        int l,r,d;
        cin >> l >> r >> d;
        --l;
        upd(l,r,d);
        cout << query() << endl;
    }
}



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

int main() {

    int a, b;
    cin >> a >> b;
    int n_hole = 1;
    int i=0;
    for ( i=0; n_hole < b; i++)
    {
        n_hole += a-1;   
    }
    cout << i;
    
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    AB = [list(map(int, input().split())) for _ in range(n)]

    res = 0
    for i in reversed(range(n)):
        a, b = AB[i]
        a += res
        if a % b != 0:
            res += (a // b + 1) * b - a
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 27380
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
const int maxn=2005;
//i_am_noob
int n,dp[maxn];

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    dp[0]=1,dp[1]=0,dp[2]=0;
    rep2(i,3,n+1){
        dp[i]=0;
        rep1(j,i-2) dp[i]=(dp[i]+dp[j])%MOD;
    }
    print1(dp[n]);
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int i,n,a=0,b=0;
	n=s.size();
	for(i=0;i<n;i++)
	{
		if(s[i]=='A')
		{
			a=i;
			break;
		}
	}
	for(i=n-1;i>=0;i--)
	{
		if(s[i]=='Z')
		{
			b=i;
			
			break;
		}
	}
	b=b-a+1;
	cout<<b<<endl;
}

Measured memory_bytes: 3724
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# xor shift（F_2上の多項式）に関する gcd を計算する

from functools import reduce

X = int(readline().split()[1],2)
A = [int(x,2) for x in readlines()]

MOD = 998244353

def gcd(a,b):
    if a < b:
        a,b = b,a
    while b:
        LA = a.bit_length()
        LB = b.bit_length()
        a ^= b << (LA - LB)
        if a < b:
            a,b = b,a
    return a

g = reduce(gcd,A)

# g の "倍数" で、X以下のものを作る方法の数を数える
# 上位の桁を決めると、gの倍数は一意に決まる。
# よって、上位の桁がXに一致するときのみが問題

LX = X.bit_length()
Lg = g.bit_length()
answer = X >> (Lg - 1)

prod = 0
x = X; Lx = LX
while Lx >= Lg:
    prod ^= g << (Lx - Lg)
    x ^= g << (Lx - Lg)
    Lx = x.bit_length()

if prod <= X:
    answer += 1

answer %= MOD
print(answer)

Measured memory_bytes: 3828
/*
      author : nishi5451
      created: 11.08.2020 23:19:15
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int tmp;
    rep(i,5) {
        cin >> tmp;
        if(tmp==0){
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
# dfs.rb
#ALDS1_11_B

$n = STDIN.gets.split[0].to_i
$rinsetu = Array.new(101).map{Array.new(101,0)}
$d = Array.new(101,0)
$f = Array.new(101,0)

1.upto($n){|i|
  $rinsetu[0][i]=1
}

1.upto($n){|i|
  s = STDIN.gets.split
  u = s[0].to_i
  k = s[1].to_i
  0.upto(k-1){|j| 
    v = s[2+j].to_i
    $rinsetu[u][v] = 1
  }
}

def dfs(node,time)
    $d[node]=time
    1.upto($n) {|i|
      time = dfs(i,time+1) if node != i && $rinsetu[node][i]==1 && $d[i]==0
    }
    $f[node]=time+1
    time+1
end

dfs(0,0)

1.upto($n){|i|
  printf("%d %d %d\n",i,$d[i],$f[i])
}

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

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vunique(v) unique(v.begin(), v.end());

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

	int X, A, B;
	cin >> X >> A >> B;
	int rslt = X - A;
	rslt %= B;
	cout << rslt << endl;
}


Measured memory_bytes: 256
import random
import time
import numpy as np

def search(day, schedule, c, s, satisfy):
    score = 0
    date = [0] * 26
    for d in range(day):
        tmp = 0
        contest = 0
        nmax = -float('inf')
        for i in range(26):
            tmp += c[i] * (d + 1 - date[i])
        for i in range(26):
            tmp2 = s[d][i] - tmp + c[i] * (d + 1 - date[i])
            if nmax < tmp2:
                nmax = tmp2
                contest = i
        
        date[contest] = d + 1
        satisfy.append(tmp - c[contest] * (d + 1 - date[contest]))
        schedule.append(contest)
        score += s[d][contest] - satisfy[d]

    return score
    
# def decrease(day, schedule, c, s, satisfy):
#     ret = 0
#     date = [0] * 26

#     for d in range(day):
#         now = schedule[d] + 1
#         date[now - 1] = d + 1
#         tmp = 0
#         for i in range(26):
#             tmp += c[i] * (d+1 - date[i])
#         ret += tmp
#         satisfy.append(tmp)

#     return ret

def change(_from, _to, schedule, c, s, satisfy):
    ret = 0
    date = [0] * 26

    for d in range(_to):
        if d < _from-1:
            ret += satisfy[d]
            continue

        now = schedule[d] + 1
        date[now - 1] = d + 1
        tmp = 0
        for i in range(26):
            tmp += c[i] * (d+1 - date[i])
        ret += tmp
        satisfy[d] = tmp

    return ret

def Main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]
    
    dissatisfy=[]
    schedule = []
    score = 0
    start = time.time()

    #最大値を足すだけ
    # for i in range(D):
    #     schedule.append(np.argmax(s[i]))
    #     score += np.max(s[i])
    ans = search(D, schedule, c, s, dissatisfy)
    for i in range(D):
        score+=s[i][schedule[i]]
    
    while time.time() - start < 1.85:
        contest = random.randint(0, 25)
        day = random.randint(0, D - 1)
        if schedule[day] == contest:
            continue

        save = dissatisfy.copy()
        dec2 = change(day + 1, D, schedule, c, s, dissatisfy)
        score2 = score - s[day][schedule[day]] + s[day][contest]

        if ans < score2 - dec2:
            ans = score2 - dec2
            score = score2
            schedule[day] = contest
        else:
            dissatisfy = save

    for i in range(D):
        print(schedule[i] + 1)

if __name__ == "__main__":
    Main()


Measured memory_bytes: 27420
// AtCoder ABC130: B - Bounding
// 2019.9.4 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}
int main()
{
	int i, N, X, L;
	
	N = in(); X = in();
	L = 0; for (i = 1; i <= N; i++) {
		if ((L += in()) > X) break;
	}
	printf("%d\n", i);
	return 0;
}


Measured memory_bytes: 128
function Main(input){
	input = input.trim()
  input = input + "#";
  var max = 0;
  var hoge = {G:"C",C:"G",T:"A",A:"T"};
  var cnt = 0;
  for(var i = 0; i < input.length; i++){
  	var t = input[i];
    if(hoge.hasOwnProperty(t)){
    	cnt++;
    }else{
    	max = Math.max(cnt,max);
      cnt = 0;
    }
  }
  return max;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
HATAGAYA
`);

Measured memory_bytes: 21064
a, b, c, d = (int(i) for i in input().split())

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

cmax=b//c
cmin=(a-1)//c
dmax=b//d
dmin=(a-1)//d
cd=c*d//gcd(c, d)
cdmax=b//cd
cdmin=(a-1)//cd

yakuc=cmax-cmin
yakud=dmax-dmin
yakucd=cdmax-cdmin

yaku=yakuc+yakud-yakucd
ans=b-a+1-yaku
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

int main(void){
  long N,k,Q;
  cin >> N >> k >> Q;
  vector<long> a(Q);
  for(int i = 0;i < Q;i++){
    cin >> a[i];
  }
  vector<long> people(N,k); 
  int min = 0;

  for(int i = 0;i < Q;i++,min++){
    people[a[i] - 1]++;
  }

  for(int i = 0;i < N;i++){
    if(min >= people[i]) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  
  return 0;    
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x,y;
    cin>>a>>b>>c;
    x=min(min(a,b),c);
    y=a+b+c-x-max(max(a,b),c);
    cout<<x+y;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class SuffixArray:
    """
    construct:
        suffix array: O(N(logN)^2)
        lcp array: O(N)
        sparse table: O(NlogN)
    query:
        get_lcp: O(1)
    """
    def __init__(self, s):
        """
        s: str
        """
        self.__s=s
        self.__n=len(s)
        self.__suffix_array()
        self.__lcp_array()
        self.__sparse_table()

    # suffix array
    def __suffix_array(self):
        s=self.__s; n=self.__n
        # initialize
        sa=list(range(n))
        rank=[ord(s[i]) for i in range(n)]
        tmp=[0]*n
        k=1
        cmp_key=lambda i:(rank[i],rank[i+k] if i+k<n else -1)
        # iterate
        while(k<=n):
            sa.sort(key=cmp_key)
            tmp[sa[0]]=0
            for i in range(1,n):
                tmp[sa[i]]=tmp[sa[i-1]]+(cmp_key(sa[i-1])<cmp_key(sa[i]))
            rank=tmp[:]
            k<<=1
        self.__sa=sa
        self.__rank=rank

    # LCP array
    def __lcp_array(self):
        n=self.__n; s=self.__s;
        sa=self.__sa; rank=self.__rank
        lcp=[0]*n
        h=0
        for i in range(n):
            j=sa[rank[i]-1]
            if h > 0: h -= 1
            while j+h<n and i+h<n and s[j+h]==s[i+h]: h+=1
            lcp[rank[i]]=h
        self.__lcp=lcp

    # sparse table (LCPのminをとるindexを持つ)
    def __sparse_table(self):
        n=self.__n
        logn=max(0,(n-1).bit_length())
        table=[[0]*n for _ in range(logn)]
        table[0]=list(range(n))
        # construct
        for i in range(1,logn):
            for k in range(n):
                if k+(1<<(i-1))>=n:
                    table[i][k]=table[i-1][k]
                    continue
                if self.__lcp[table[i-1][k]]<=self.__lcp[table[i-1][k+(1<<(i-1))]]:
                    table[i][k]=table[i-1][k]
                else:
                    table[i][k]=table[i-1][k+(1<<(i-1))]
        self.__table=table

    def get_lcp(self,a,b):
        """
        a,b: int 0<=a,b<n
        return LCP length between s[a:] and s[b:]
        """
        if a==b: return self.__n-a
        l,r=self.__rank[a],self.__rank[b]
        l,r=min(l,r)+1,max(l,r)+1
        if r-l==1: return self.__lcp[l]
        i=(r-l-1).bit_length()-1
        if self.__lcp[self.__table[i][l]]<=self.__lcp[self.__table[i][r-(1<<i)]]:
            return self.__lcp[self.__table[i][l]]
        else:
            return self.__lcp[self.__table[i][r-(1<<i)]]
def resolve():
    n=int(input())
    s=input()
    sa=SuffixArray(s)
    ans=0
    for i in range(n):
        for j in range(n):
            ans=max(ans,min(sa.get_lcp(i,j),j-i))
    print(ans)
resolve()

Measured memory_bytes: 53572
#pragma comment(linker, "/stack:640000000")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <list>
#include <map>
//#include <unordered_map>
/// unordered map only when c++ 11 is ticked :p
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

const double EPS = 1e-9;
const double PI=acos(-1.0);

#define    READ(f)       freopen(f, "r", stdin)
#define    WRITE(f)      freopen(f, "w", stdout)

#define    INF           999999999999999
#define    pii           pair<int, int>
#define    pdd           pair<double, double>
#define    pll           pair<long long int, long long int>
#define    ii            long long int
#define    uii           unsigned long long int
#define    ui            unsigned int
#define    bitCheck(a,k) ((bool)(a&(1<<(k))))
#define    bitOff(a,k)   (a&(~(1<<(k))))
#define    bitOn(a,k)    (a|(1<<(k)))
#define    bitFlip(a,k)  (a^(1<<(k)))
#define    iseq(a,b)     (fabs(a-b)<EPS)

template< class T > inline T _abs(T n) { return ((n) < 0 ? -(n) : (n)); }
template< class T > inline T _max(T a, T b) { return (!((a)<(b))?(a):(b)); }
template< class T > inline T _min(T a, T b) { return (((a)<(b))?(a):(b)); }
template< class T > inline T _swap(T &a, T &b) { a=a^b;b=a^b;a=a^b;}
template< class T > inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); }
template< class T > inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); }


///******************DELETE****************

#ifdef rafiul41
     #define debug(args...) {cerr<<"Debug: "; dbg,args; cerr<<endl;}
#else
    #define debug(args...)  // Just strip off all debug tokens
#endif

struct debugger{
    template<typename T> debugger& operator , (const T& v){
        cerr<<v<<" ";
        return *this;
    }
}dbg;

int strToint(string x)
{
    stringstream ss(x);
    int i;
    ss>>i;
    return i; /// this int does not have any leading zeros !!!
}
///**************************************************

int main()
{
#ifdef rafiul41
//
//    READ("in.txt");
//    WRITE("out.txt");

#endif // rafiul41
    //ios_base::sync_with_stdio(false);cin.tie(NULL);
    string x;
    cin>>x;
    if(x[0]==x[2])
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int q;
  cin >> q;
  bitset<64> a(0);

  vector<ull> ans;
  rep(i,q) {
    int command;
    cin >> command;
    if (command == 0) {
      int x; cin >> x;
      ans.push_back(a[x]);
    } else if (command == 1) {
      int x; cin >> x;
      a.set(x);
    } else if (command == 2) {
      int x; cin >> x;
      a.reset(x);
    } else if (command == 3) {
      int x; cin >> x;
      a.flip(x);
    } else if (command == 4) {
      ans.push_back(a.all());
    } else if (command == 5) {
      ans.push_back(a.any());
    } else if (command == 6) {
      ans.push_back(a.none());
    } else if (command == 7) {
      ans.push_back(a.count());
    } else if (command == 8) {
      ans.push_back(a.to_ullong());
    }
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 4876
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            int n = in.nextInt();
            int ans = Integer.MAX_VALUE;

            for (int i = 0; i <= n; i++) {
                int cc = 0;
                for (int cn = i; cn > 0; cn /= 6) cc += cn % 6;
                for (int cn = n - i; cn > 0; cn /= 9) cc += cn % 9;
                if (cc < ans) ans = cc;
            }

            out.println(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 23252
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;
 
int main(){
	int n;
	cin >> n;
	ll a[n];
	ll sum = 0;
	REP(i, n){
		int x;
		cin >> x;
		sum += x;
		a[i] = sum;
	}
	int f = 1;
	ll ans1 = 0, ans2 = 0;
	ll fix = 0;
	REP(i, n){
		if(f == 1){
			if(a[i] + fix <= 0){
				ans1 += 1 - (fix + a[i]);
				fix += 1 - (fix + a[i]);
			}
			f = -1;
		}
		else{
			if(a[i] + fix >= 0){
				ans1 += (fix + a[i]) + 1;
				fix -= ((fix + a[i]) + 1);
			}
			f = 1;
		}
	}
	f = -1;
	fix = 0;
	REP(i, n){
		if(f == 1){
			if(a[i] + fix <= 0){
				ans2 += 1 - (fix + a[i]);
				fix += 1 - (fix + a[i]);
			}
			f = -1;
		}
		else{
			if(a[i] + fix >= 0){
				ans2 += (fix + a[i]) + 1;
				fix -= ((fix + a[i]) + 1);
			}
			f = 1;
		}
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 1024