akhauriyash/Code-Regression huggingface dataset:
from collections import deque
n = int(input())
a_list = list(map(int, input().split()))
q = deque([]) 
if n%2 == 0:
    for i in range(n):
        if i%2 == 0:
            q.append(a_list[i])
        else:
            q.appendleft(a_list[i])
else:
    for i in range(n):
        if i%2 == 1:
            q.append(a_list[i])
        else:
            q.appendleft(a_list[i])
b = map(str, list(q))
print(' '.join(b))


Measured memory_bytes: 30660
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

vector<int> g[55];

int main(void){
	int n,m,i,a,b,j,x,ans=0;
	bool done[55];
	vector<P> e;
	queue<int> q;
	cin >> n >> m;
	for(i=0; i<m; ++i){
		cin >> a >> b;
		e.push_back(P(a,b));
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(i=0; i<m; ++i){
		a = e[i].first;
		b = e[i].second;
		fill(done,done+55,false);
		q.push(a);
		while(!q.empty()){
			x = q.front();
			q.pop();
			if(done[x]){
				continue;
			}
			done[x] = true;
			for(j = (g[x].l_ength()-1); j>=0; --j){
				if((a == x && b == g[x][j]) || (a == g[x][j] && b == x)){
					continue;
				}
				q.push(g[x][j]);
			}
		}
		if(!done[b]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	map<int,int> mp;
	for(int i = 2;i <= 13;i++)mp[i] = i-2;
	mp[1] = 12;
	int a,b;cin >> a >> b;
	int p = mp[a],q = mp[b];
	if(p < q)cout << "Bob" << endl;
	else if(p > q)cout << "Alice" << endl;
	else cout << "Draw" << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
using namespace std;

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

Measured memory_bytes: 3628
def main
  n, m = gets.split.map(&:to_i)

  cities = Array.new(m)
  m.times do |i|
    cities[i] = gets.split.map(&:to_i) << i
  end
  # puts cities

  cities.sort!
  # puts cities

  # 県内での順位を追加
  last_p = 0
  c_idx = 0
  cities.each do |city|
    if last_p != city[0]
      c_idx = 0
      last_p = city[0]
    end
    # puts "%06d%06d" % [p, c_idx]

    c_idx += 1
    city << c_idx
  end
  # puts cities

  # 入力順に昇順ソート
  cities.sort_by! { |city| city[2] }
  # puts cities

  cities.each do |(p, _, _, c_idx)|
    puts "%06d%06d" % [p, c_idx]
  end

end

if __FILE__ == $0
  main
end


Measured memory_bytes: 29808
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>

using namespace std;
#define REP(i,n) for(int i=0;i##_len=(n);i<i##_len;i++)
#define REPi(i,a,b) for(int i=a;i##_len=(b);i<i##_len;i++)
#define ALL(x) (x).begin(),(x).end()
int main(){
    int A,P;
    cin>>A>>P;
    P+=3*A;
    if(P%2==0){
        cout<<P/2<<endl;
    }else{
        cout<<(P-1)/2<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
using namespace std;

#define rep(i,end)          rep2(i,0,(end))
#define rep2(i,beg,end)   for (int i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

string gets(bool skipnewline);
vi get_n_array(int n);


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi v = get_n_array(n);
    int error = 0;
    rep(i, v.size())
    {
        if (v[i] != i + 1) error++;
    }
    if (error > 2) {
        cout << "NO" << endl;
    }
    else {
        cout << "YES" << endl;
    }
    return 0;
}

string gets(bool skipToNextline)
{
    if (skipToNextline) gets(false);
    const int LINE_MAX = 1024;
    char buf[LINE_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}

vi get_n_array(int n)
{
    vi v;
    while (n-- > 0) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    return v;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if(A+B==C+D){
        cout << "Balanced";
    }else if(A+B>C+D){
        cout << "Left";
    }else{
        cout << "Right";
    }
}


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

using namespace std;

int main() {
  int N;
  
  cin >> N;
  
  if (N == 1) {
    cout << "Hello World" << endl;
  } else if (N == 2) {
    int A, B;
    
    cin >> A >> B;
    
    cout << A + B << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define INF 1000000001
using namespace std;

int main()
{
  int N,I,S,P;
  char c;
  vector<pair<int,pair<int,int> > > V;

  while(1){
    cin>>N;
    if(N==0)break;
    V.clear();
    V.push_back(make_pair(-1,make_pair(-1,-1)));
    V.push_back(make_pair(INF,make_pair(INF,INF)));
    for(int i=0;i<N;i++){
      cin>>c;
      if(c=='W'){
	cin>>I>>S;
        for(int i=1;i<V.size();i++){
	  int a=V[i-1].second.second,b=V[i].second.first;
	  if(a+1!=b){
	    int c=min(a+S,b-1);
	    V.insert(V.begin()+i,make_pair(I,make_pair(a+1,c)));
	    S-=b-(a+1);
	    if(S<=0)break;
	  }
	}
      }
      else if(c=='D'){
	cin>>I;
        for(int i=0;i<V.size();i++){
	  if(V[i].first==I){
	    V.erase(V.begin()+i);
	    i--;
	  }
	}/*
	for(int i=0;i<V.size();i++)cout<<V[i].first<<" "<<V[i].second.first<<" "<<V[i].second.second<<endl;
	cout<<endl;*/
      }
      else {
	cin>>P;
	for(int i=1;i<V.size();i++){
	  if(V[i].second.first<=P && P<=V[i].second.second){
	    cout<<V[i].first<<endl;
	    break;
	  }
	  if(i==V.size()-1)cout<<"-1"<<endl;
	}
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1288
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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


    int N, Z, W; cin >> N >> Z >> W;
    vi A(N); REP(i, N) cin >> A[i];

    vvl dp(N + MGN, vl(2));
    // dp[i][j] := the score when player j takes card i

    for(int i=N-1; i>=0; i--) {
        // X
        dp[i][0] = -INF;
        ll y = i == 0 ? W : A[i - 1];
        dp[i][0] = max(dp[i][0], abs(A[N - 1] - y));
        for(int j=i+1; j<N; j++) {
            dp[i][0] = max(dp[i][0], dp[j][1]);
        }

        // Y
        dp[i][1] = INF;
        ll x = i == 0 ? Z : A[i - 1];
        dp[i][1] = min(dp[i][1], abs(x - A[N - 1]));
        for(int j=i+1; j<N; j++) {
            dp[i][1] = min(dp[i][1], dp[j][0]);
        }
    }

    ll ans = dp[0][0];
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 384
#include "iostream"
#include "algorithm"
using namespace std;
static const int MAX = 200000;


int main(int argc, char const *argv[]) {
    int R[MAX], n;

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

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 1940
N = input()
if int(N[1] + N[2]) <= int(N[0] + N[0]):
	print(int(N[0] + N[0] + N[0]))
else:
	print((int(N[0]) + 1) * 100 + (int(N[0]) + 1) * 10 + (int(N[0]) + 1))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	if(n>=0&&n<1200)cout<<"ABC"<<endl;
	if(n>=1200&&n<2800)cout<<"ARC"<<endl;
	if(n>=2800&&n<=4208)cout<<"AGC"<<endl;
	return 0;	
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
unsigned int bitCount(unsigned int n)
{
	n = n - ((n >> 1) & 0x55555555);
	n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
	n = (n + (n >> 4)) & 0x0f0f0f0f;
	n = n + (n >> 8);
	n = n + (n >> 16);
	return (n & 0x3f);
}

int main()
{
	int N;
	int F_bit[105] = {};
	int P[105][11];

	cin >> N;
	for ( int i = 0; i < N; i++ ) {
		for ( int j = 0; j < 10; j++ ) {
			int a;
			cin >> a;
			F_bit[i] |= (a << j);
		}
	}

	for ( int i = 0; i < N; i++ ) {
		for ( int j = 0; j <= 10; j++ ) {
			cin >> P[i][j];
		}
	}
	int maxv = -INF;
	for ( int bit = 1; bit < (1 << 10); bit++ ) {
		int point = 0;
		for ( int i = 0; i < N; i++ ) {
			int data = F_bit[i] & bit;
			int num = bitCount(data);
			point += P[i][num];	
		}
		maxv = max(maxv, point);
	}
	cout << maxv << endl;
	return ( 0 );
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b) swap(a, b);
    if (a < c) swap(a, c);
    if (b < c) swap(b, c);
    int res = 0;
    res += a - b;
    c += res;
    res += (a - c) / 2;
    if ((a - c) & 1) {
	res += 2;
    }
    printf("%d", res);
    return 0;
}


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

using namespace std;

int main()
{
    int a,b,sum,cnt=1;
    cin>>a>>b;
    if(b==1){
        cout<<0<<endl;
        return 0;
    }
    sum = a;
    while(sum<b){
        cnt++;
        sum+=(a-1);
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}


int main(){
	
	int n;
	cin>>n;
	vector<int>a(n);
	rep(i,n){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	int ans=0;
	int i=1;
	int c=1;
	int x=a[0];
	while(i!=n){
		if(x==a[i]){
			c++;
			i++;
		}else{
			if(c>=x)ans+=c-x;
			else ans+=c;
			x=a[i];
			c=0;
		}
	}
	if(c>=x)ans+=c-x;
	else ans+=c;
	cout<<ans<<endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int a, b;
	cin >> a >> b;
	int ans = max({a + b, a - b, a * b});
	cout << ans << endl;
}

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

	solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;

int ar[100],br[100][100];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m,x;
    cin >> n >> m >> x;
    for(int i=1; i<=n; i++)
    {
        cin >> ar[i];

        for(int j=1; j<=m; j++)
        {
            cin >> br[i][j];
        }
    }
    int ans = INT_MAX;
    for(int i=0; i<(1<<n); i++)
    {
        int sum=0;
        vector<int>v(m,0);
        for(int j=0; j<n; j++)
        {
            if(i&(1<<j))
            {
                sum+=ar[j+1];
                for(int k=1; k<=m; k++)
                {
                    v[k-1] += br[j+1][k];
                }
            }
        }
        int f=1;
        for(int j=0; j<m; j++)
        {
            if(v[j]<x)
            {
                f=0;
                break;
            }
        }
        if(f)
        {
            ans = min(ans,sum);
        }
    }
    if(ans==INT_MAX)
        cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std ; 
#define ll              long long int
// #define cini(x)	        scanf("%lld",&x)
// #define cins(s)	        scanf("%s",s)
#define deb(x)          cout << (x) << "  " ;
#define out(x)          cout << (x) << endl ;
#define endl            '\n'
#define pb              push_back
#define mk              make_pair
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define loop(x,n,v)     for(ll v=x; v<n; v++)
#define loopr(n,x,v)     for(ll v=n-1; v>=x; v--)
#define mod             1000000007
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define PI              3.1415926535897932384626
#define setbits(x)      __builtin_popcount(x)
#define zrobits(x)      __builtin_ctz(x)
#define ps(x,y)         fixed << setprecision(y) << (x)
#define w(t)            int t; cin>>t; while(t--) 
#define     vi          vector<ll>
#define     vtt         vector<pair<ll,ll>> 
#define     pii         pair<ll,ll> 
#define  mapp           map<ll,ll> 
#define  sett           set<ll>
int dp[1000][1000] ;
ll mpow(ll base, ll exp); 
// =================================
// =================================


// ll solve(ll *arr, ll n, ll i){
//     if(i == n-1 || i == n){
//         return max(arr[n-1],arr[n]);
//     }
//     return min( solve(arr,n,i+1), solve(arr,n,i+2));
// }


int main(){
    fastio ;
    // w(t)
    // {
        ll a=0, b=0, c=0, d=0, e=0, p=0, q=0, r=0 ;
        ll ans=0, res=0, cnt=0, sum=0, diff=0, mul=1, val=0, k=0 ;
        // loop(0,n,i) brr[i]=0;
        // char s[100005];
        string s ;
        ll n,m ;
        cin >> n ;
        ll arr[n], brr[n+1];
        brr[0]=0;
        loop(0,n,i)
            cin >> arr[i];
        brr[1] = abs(arr[0]-arr[1]);
        loop(2,n,i)
            brr[i] = min(brr[i-1]+abs(arr[i]-arr[i-1]),brr[i-2]+abs(arr[i]-arr[i-2]));
        cout << brr[n-1];

    // }
    return 0 ;
}

// g++ x.cpp -o as && ./as


// f_io;
//     ll n;
//     cin >> n;
//     vector<ll> arr(n),dp(n);
//     foi(0,n)
//         cin >> arr[i];
//     dp[1] = abs(arr[0]-arr[1]);
//     foi(2,n)
//         dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
//     cout << dp[n-1];
//     return 0;
// }


Measured memory_bytes: 5176
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <string>
#include <cstring>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f
#define MAX_N (1<<30)
#define eps 1e-5
#define ms(x, n) memset(x,n,sizeof(x));
using namespace std;
void optimize_cpp_stdio()
{
    std::ios::sync_with_stdio(false);
    std::cout.tie(NULL);
    std::cin.tie(NULL);
}
typedef long long ll;

int main()
{
    ll x, y;
    scanf("%lld%lld", &x, &y);
    if(llabs(x - y) >= 2)
        printf("Alice\n");
    else
        printf("Brown\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

   int k,a,b;
   cin >> k >> a >> b;
   for (int i=a;i<=b;i++){
      if (i%k==0)
        {cout << "OK"<<"\n";
      return 0;}
   }
    cout << "NG"<< "\n";
   
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;



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

	int s,w;
	cin>>s>>w;
	if (s<=w) cout<<"unsafe"; else cout<<"safe";
	cout<<'\n';
}


Measured memory_bytes: 3640
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll q[51];
ll p[51];

ll solve(ll X, int N){
  if(X == 0){
    return 0;
  }else if(N == 0){
    return 1;
  }else if(X >= q[N]){
    return p[N];
  }else if(X > q[N-1] + 2){
    return solve(X-q[N-1]-2, N-1) + 1 + p[N-1];
  }else if(X == q[N-1] + 2){
    return p[N-1] + 1;  
  }else if(X < q[N-1] + 2) {
    return solve(X-1, N-1);
  }
}

int main(void){
  int N;
  ll X;
  cin >> N >> X;

  q[0] = 1;
  p[0] = 1;
  for(int i=0; i<N; i++){
    q[i+1] = 2*q[i] + 3;
    p[i+1] = 2*p[i] + 1;
//    cout << p[i+1] << endl;
  }
//  cout << q[N] << endl;
  ll ans = solve(X, N);
  cout << ans << endl;  
  return 0;
}

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

using ll = long long;

using P = pair<int, int>;

constexpr int INF = 1e9;

P memo[201][201];

P rec(int l, int r, string const& s) {
    P& res = memo[l][r];
    if(res != make_pair(-INF, INF)) {
        return res;
    }
    if(l == r) {
        int v = s[l] - '0';
        return make_pair(v, v);
    }
    if(s[r] == ')' && r-l >= 3) {
        P p = rec(l, r-1, s);
        res.first = max(res.first, p.first);
        res.second = min(res.second, p.second);
    }
    if(s[l] == '(' && r-l >= 3) {
        P p = rec(l+1, r, s);
        res.first = max(res.first, p.first);
        res.second = min(res.second, p.second);
    }
    for(int i=l+1; i<r; ++i) {
        char op = s[i];
        if(op == '+' || op == '-') {
            P rl = rec(l, i-1, s);
            P rr = rec(i+1, r, s);
            if(op == '+') {
                res.first = max(res.first, rl.first + rr.first);
                res.second = min(res.second, rl.second + rr.second);
            } else {
                res.first = max(res.first, rl.first - rr.second);
                res.second = min(res.second, rl.second - rr.first);
            }
        }
    }
    return res;
}

int main() {
    string s;
    cin >> s;
    for(int i=0; i<s.size(); ++i) {
        for(int j=0; j<s.size(); ++j) {
            memo[i][j] = make_pair(-INF, INF);
        }
    }
    cout << rec(0, s.size()-1, s).first << endl;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main( )
{
	ll n;
	cin>>n;
	string a="";
	while(n){
		n--;
		a+=char('a'+n%26);
		n=n/26;
	}
	reverse(a.begin( ),a.end( ));
	cout<<a<<endl;
}
	

Measured memory_bytes: 3624
#pragma GCC optimize("O2") 

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define test(t)		int t; cin>>t; while(t--)
#define f(i, a, b)	for(int i = a; i < b; ++i)
#define all(a)		a.begin(), a.end()
#define endl 		"\n"
#define deb(x)		cout << #x << "--" << x << "--" << endl;
#define deb2(x,y)	cout << #x << "-" << x << "-" << " ~~ " <<  #y << "-" << y << "-" << endl;
#define deb3(x,y,z)	cout << #x << "-" << x << "-" << " ~~ " <<  #y << "-" << y << "-" << " ~~ " << #z << "-" << z << "-" << endl;
#define deba(arr)	cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define fast 		ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
  long double a, b;
  cin >> a >> b;
  ll pro = floor(a * b);
  cout << pro << endl;
}
int main()
{
    fast;
    //test(t)
        solve();
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int n;
	int a[100];
	
	cin >> n;
	REP(i, n) scanf("%d", a + i);
	
	sort(a, a + n);
	
	cout << a[n - 1] - a[0] << endl;
	
	return 0;
}

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

int main(){
  int n[3];
  
  for(int i = 0; i < 3; i++){
    cin >> n[i];
  }
  
  if(n[0] == 1){
    cout << "Hello World" << endl;
  } else if(n[0] == 2){
    cout << n[1] + n[2] << endl;
  }
  
  return 0;
}
  

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	map<string, int> freq;
	freq["AC"] = 0;
	freq["TLE"] = 0;
	freq["WA"] = 0;
	freq["RE"] = 0;
	for (int i = 1; i <= n; i++) {
		string s; cin >> s;
		freq[s]++;
	}

	cout << "AC x " << freq["AC"] << endl;
	cout << "WA x " << freq["WA"] << endl;
	cout << "TLE x " << freq["TLE"] << endl;
	cout << "RE x " << freq["RE"] << endl;

	return 0;
}

Measured memory_bytes: 3228
import sys
input = sys.stdin.readline
H, N = [int(x) for x in input().split()]
AB = []
for _ in range(N):
    AB.append([int(x) for x in input().split()])
AB = sorted(AB)
A = []
B = []
for i in range(N):
    A.append(AB[i][0])
    B.append(AB[i][1])
dp = [10 ** 10] * 10001
dp[0] = 0
for i in range(1, H + 1):
    dp_ = 10 ** 10
    for j in range(N):
        if i - A[j] >= 0:
            dp_ = min(dp_, dp[i - A[j]] + B[j])
        else:
            dp_ = min(dp_, B[j])
    dp[i] = dp_
print(dp[H])

    



Measured memory_bytes: 42092
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i +1):
        if i*10000 + j*5000 + (n-i-j)*1000 == y:
            print(i, j, n-i-j)
            exit()

print("-1 -1 -1")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long



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

    ll n,m,x=0;
    cin>>n;
    map<string,ll>s;
    string a[101],b[101];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        s[a[i]]++;
    }cin>>m;
    for(int i=1;i<=m;i++){
        cin>>b[i];
        s[b[i]]--;
    }
    for(int i=1;i<=n;i++){
        x=max(x,s[a[i]]);
    }
    cout<<x;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> board(h);
    for(int hh = 0; hh < h; hh++) {
	cin >> board[hh];
    }
    int ans = 0;
    for(int mask = 0; mask < (1 << (h + w)); mask++) {
	int cnt = 0;
	for(int x = 0; x < w; x++){
	    for(int y = 0; y < h; y++) {
		if(board[y][x] != '#')continue;
		if((mask & ((1 << x) | (1 << (w+y)))) != 0)continue;
		cnt++;
	    }
	}
	if(cnt == k)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

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

  if (S / 100 == 7 || S / 10 % 10 == 7 || S % 10 == 7) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>

using namespace std;

int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;

	int start=max(a,c);
	int end=min(b,d);
	if(end-start>=0)cout<<end-start<<endl;
	else cout<<0<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int match[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
int N, M;
string dp[10100], INF = "-";

string max_str(string s, string t) {
    if (s == INF) return t;
    if (s.size() == t.size()) return (s > t ? s : t);
    else return (s.size() > t.size() ? s : t);
}

int main() {
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; i++) cin >> A[i];
    for (int i = 0; i < 10100; i++) dp[i] = INF;
    dp[0] = "";
    for (int i = 0; i <= N; i++) {
        if (dp[i] == "-") continue;
        for (int j = 0; j < M; j++) {
            dp[i + match[A[j] - 1]] = max_str(dp[i + match[A[j] - 1]], dp[i] + to_string(A[j]));
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 33024
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;
int A,B,m;
int a[maxn],b[maxn];
map< pair<int,int>,int > mp;
int main()
{
	scanf("%d%d%d",&A,&B,&m);
	for(int i=1;i<=A;++i)scanf("%d",&a[i]);
	for(int i=1;i<=B;++i)scanf("%d",&b[i]);
	int ans=0;
	int am=100000,bm=100000;
	for(int i=1;i<=A;++i)am=min(am,a[i]);
	for(int i=1;i<=B;++i)bm=min(bm,b[i]);
	ans=am+bm;
	for(int i=1;i<=m;++i)
	{
		int x,y,c;
		scanf("%d%d%d",&x,&y,&c);
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),m=sc.nextInt(),count=0;
    int[] h=new int[n];
    boolean[] res=new boolean[n];
    Arrays.fill(res, true);
    for(int i=0;i<n;i++)h[i]=sc.nextInt();

    for(int i=0;i<m;i++) {
    	int x=sc.nextInt()-1,y=sc.nextInt()-1;
    	if(h[x]<h[y]) {
    		res[x]=false;
    	}else if(h[x]>h[y]) {
    		res[y]=false;
    	}else {
    		res[x]=false;
    		res[y]=false;
    	}
    }
    for(int i=0;i<n;i++) {
    	if(res[i])count++;
    	//System.out.print(res[i]+" ");
    }
    //System.out.println();
    System.out.println(count);
  }
}


Measured memory_bytes: 59540
r,c = map(int,input().split())
matrix = [list(map(int,input().split())) for i in range(r)]
for i in range(r):
    matrix[i].append(sum(matrix[i]))

row = []

for i in range (c+1):
    row_sum = 0
    for j in range(r):
        row_sum += matrix[j][i]
    row.append(row_sum)

matrix.append(row)
for i in range(r+1):
    for j in range(c+1):
        print(matrix[i][j],end="")
        if j != c:
            print(" ",end="")
        if j == c :
            print("")

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

typedef long long ll;
#define pb push_back

const int N = 300000;
const int mo = 998244353;

void fail() { puts("0"); exit(0); }

int n;
int ty[N + 5];
int a[N + 5], b[N + 5];
int l[N + 5], r[N + 5];

void input() {
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) {
        scanf("%d", a + i);
    }

    if(*min_element(a, a + n) != 1) { fail(); }
    if(*max_element(a, a + n) == 1) { 
        int res = 1;
        for(int i = 1; i <= n; ++i) res = (ll) res * i % mo;
        printf("%d\n", res);
        exit(0);
    }
    
    for(int i = n - 1; i >= 0; --i) if(a[i] == 1 && (i == 0 || a[i-1] != 1)) {
        for(int j = 0; j < n; ++j) b[j] = a[(i + j) % n];
        break;
    }

    memcpy(a, b, sizeof a);
    memset(l, -1, sizeof l);

    for(int i = 0; i < n; ++i) {
        int x = a[i];
        if(i == 0 || a[i] != a[i-1]) {
            if(~l[x]) { fail(); }
            l[x] = i;
        } r[x] = i;
    }
}

int mx[(N << 2) + 5];
void modify(int x, int y, int v, int u = 1, int L = 0, int R = n - 1) {
    if(x <= L && R <= y) {
        mx[u] = max(mx[u], v);
    } else {
        int mid = (L + R) >> 1;
        if(x <= mid)
            modify(x, y, v, u << 1, L, mid);
        if(mid < y)
            modify(x, y, v, u << 1 | 1, mid+1, R);
    }
}

int query(int p, int u = 1, int L = 0, int R = n - 1) {
    if(L == R) return mx[u];
    int mid = (L + R) >> 1;
    return std::max(mx[u], (p <= mid) ? query(p, u << 1, L, mid) : query(p, u << 1 | 1, mid+1, R));
}

void solve() {
    for(int i = 0; i <= (N << 2); ++i) { mx[i] = 1; }

    vector<int> seq;
    for(int i = 0; i < n; ++i) {
        if(!seq.empty() && a[i] == seq.back())
            continue;
        seq.pb(a[i]);
    }

    static bool vis[N + 5];
    int len = r[1] - l[1], ans = 1;

    for(int i = 0; i < (int) seq.size(); ++i) {
        if(r[seq[i]] - l[seq[i]] > len) fail();

        if(i == 0 || seq[i-1] > seq[i]) { ty[i] |= 1; }
        if(i+1 < (int) seq.size() && seq[i + 1] > seq[i]) { ty[i] |= 2; }

        if(ty[i] == 3 && r[seq[i]] - l[seq[i]] != len) fail();
        if(ty[i] == 0) ans = (ll) ans * (len - (r[seq[i]] - l[seq[i]]) + 1) % mo;

        modify(l[seq[i]]-len, r[seq[i]], seq[i]);

        if(ty[i] == 0) vis[l[seq[i]]] = true;
        if(ty[i] == 1) vis[l[seq[i]]] = true;
        if(ty[i] == 3) vis[l[seq[i]]] = true;
        if(ty[i] == 2) vis[r[seq[i]] - len] = true;
    }

    vector<int> lim;
    for(int i = 0; i < n; ++i) if(!vis[i]) {
        lim.pb(query(i)); 
    }

    std::sort(lim.begin(), lim.end());

    int cur = 0;
    for(int i = n; i >= 1; --i) {
        if(!~l[i]) { ++ cur; }
        while(!lim.empty() && lim.back() == i) {
            ans = (ll) ans * (cur --) % mo;
            lim.pop_back();
        }
    }
    printf("%d\n", ans);
}

int main() {

    input();
    solve();

    return 0;
}


Measured memory_bytes: 13044
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  ll cnt = N % 10;
  if(cnt == 3) cout << "bon" << endl;
  else if(cnt == 0 or cnt == 1 or cnt == 6 or cnt == 8) cout << "pon" <<endl;
  else cout << "hon" << endl;


}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <cmath>

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

  std::vector<int> boundary;
  boundary.push_back(0);
  std::vector<int> collpo;
  for(int i = 0 ; i < (int)S.size() - 1; i++){
    if(S[i] == 'L' && S[i + 1] == 'R'){
      boundary.push_back(i+1);
    }
    if(S[i] == 'R' && S[i + 1] == 'L'){
      collpo.push_back(i);
    }
  }

  boundary.push_back((int)S.size());
  std::vector<int> num_child(S.size());
  int p = 0;
  for(int i = 0 ; i < (int)S.size() ; i++){
    if(i < boundary[p+1]){
      if(i!=collpo[p]){
	num_child[i] = 0;
      }
      if(i==collpo[p]){
	int num = (collpo[p] - boundary[p]) / 2 + 1;
	num += (boundary[p+1]-collpo[p]-1)/2;
	num_child[i]=num;
      }
      if(i == collpo[p]+1){
	int num = (collpo[p]+1 - boundary[p]) /2;
	num += (boundary[p+1] - collpo[p] - 1 -1)/2 + 1;
	num_child[i]=num;
      }
      if(i == boundary[p+1] - 1){
	p++;
      }
    }
  }
  for(int i = 0 ; i < (int) S.size() ; i++){
    std::cout << num_child[i] << " ";
  }
  std::cout << std::endl;
  return 0;
  
}



Measured memory_bytes: 1532
#include <iostream>
#include <stdlib.h>
using namespace std;

void amida(int w, int n, int a[], int b[]);

int main(void){
  int w, n;
  int a[30], b[30];
  char s[20], tmp[10];

  while(cin >> w){
    cin >> n;
    for(int i = 0; i < n; i++){
      cin >> s;
      int j, k;

      for(j = 0; s[j] != ','; j++){
        tmp[j] = s[j];
      }
      tmp[j++] = 0;
      a[i] = atoi(tmp);

      k = 0;
      while(s[j]){
        tmp[k++] = s[j++];
      }
      tmp[k] = 0;
      b[i] = atoi(tmp);
    }

    amida(w, n, a, b);
  }
}

void amida(int w, int n, int a[], int b[]){
  int ans[31];
  int tmp;

  for(int i = 1; i <= w; i++){
    ans[i] = i;
  }

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

  for(int i = 1; i <= w; i++){
    cout << ans[i] << "\n";
  }
}

Measured memory_bytes: 1172
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  if(s[0] == '9' || s[1] == '9') puts("Yes");
  else puts("No");
  return 0;
}

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

using namespace std;

const int M = 1e5 + 5;
long long n, k, t[M], dp[M];

long long solve (int id) {
    if (id >= n) return 2e9;
    if (id == n-1) return 0;
    long long &ret = dp[id];
    if (ret != -1) return ret;
    ret = 2e9;
    for (int i = 1; i <= k; i++)
        ret = min (ret, solve(id+i)+abs(t[id]-t[id+i]));
    return ret;
}

int main () {
    scanf("%lld %lld", &n, &k);
    for (int i = 0; i < n; i++) scanf("%lld", &t[i]);
    t[n] = 2e9;
    memset(dp, -1, sizeof dp);
    printf("%lld", solve (0));
}


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

int m[110][26];

int main(){
  int n; cin >> n;
  string s; cin >> s;
  for (int i = 0; i < n; i++){
    m[i][s[i]-'a']++;
  }
  for (int i = 0; i < n; i++){
  	for (int j = 0; j < 26; j++){
      m[i+1][j] += m[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++){
    int cnt = 0;
    for (int j = 0; j < 26; j++){
      if (m[i][j] > 0 && m[n][j] - m[i][j] > 0) cnt++;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _overload2(_1,_2,name,...) name
#define _re(n) _rep(i,n)
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define _repc(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep,_re)(__VA_ARGS__)
#define _rre(n) _rrep(i,n)
#define _rrep(i,n) _rrepi(i,0,n)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep,_rre)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,size_t size>
istream& operator >> (istream& is, array<T,size>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
inline void out(){cout<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}


int main(){
    INT(n);
    vector<vector<int>>a;
    rep(n){
        VEC(int,x,3);
        sort(x.begin(), x.end());
        a.push_back(x);
    }
    sort(a.begin(), a.end());
    int ans=0;
    rep(i,1,n)if(a[i]==a[i-1])ans++;
    out(ans);
}
















Measured memory_bytes: 3276
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
#include <array>
int a(void);


int main(void) {
	a();
	return 0;
}


int a(void) {
	int A1, A2, A3;
	std::cin >> A1 >> A2 >> A3;
	
	if (A1+A2+A3 >= 22) {

		std::cout << "bust";
	}
	else {
		std::cout << "win";
	}
	return 0;
}

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

# 整数 > 整数型
def I(): return int(input())

# 整数列 '1 2 3 4' > 整数型リスト
def IsIl(): return list(map(lambda x: int(x), input().split()))

# 改行挟む整数列　'1/n 2/n 3/n' > 整数型りすと
def InIl(n): return [input() for i in range(n)]

# 整数列 '1 2' > 整数型タプル
def IsIt(): return map(lambda x: int(x), input().split())

# 改行挟む整数列　'1\n 2\n 3\n' > 整数型たぷる
def InIl(n): return map(input() for i in range(n))

# 文字列 'abcd' > 文字型リスト
def SsSl(): return list(map(lambda x: x, input()))

# 整数 '1234' > 整数型リスト

# 文字列 'aba' > 辞書（文字型:個数）{'a':2,'b':1}
def SSd():
    from collections import defaultdict
    A = input() # [int(i) for i in input().split()]
    dd=defaultdict(int)
    for a in A:
        dd[a]+=1
    return dd

#リストにn個要素を読み込む

# その他アルゴリズムテンプレート
# https://qiita.com/chun1182/items/ddf2b6cba932b2bb0d4e

n,k = IsIt()

lis_h = IsIl()

ans = 0
for i_h in lis_h:
    if i_h >= k:
        ans += 1


print(ans)
    


Measured memory_bytes: 11908
from collections import defaultdict
from heapq import heappop, heappush
import sys
input = sys.stdin.readline


N, M, S = map(int, input().split())

d = defaultdict(list)
e = defaultdict(int)

for _ in range(M):
    U, V, A, B = map(int, input().split())
    d[U].append((A, B, V))
    d[V].append((A, B, U))

for i in range(1, N+1):
    C, D = map(int, input().split())
    e[i] = (C, D)

dist = defaultdict(lambda :10**30)
ans = defaultdict(lambda :10**30)

source = (1, S)
dist[source] = 0
q = [(0, source)]

while q:
    cost, (s, nokori) = heappop(q)
    ns = (s, nokori)

    u, v = e[s]
    if dist[ns] < cost:
        continue

    if nokori > 2500:
        nokori = 2500
    else:
        n_nokori = nokori + u
        n_cost = v
        if n_nokori > 2500:
            n_nokori = 2500
        nt = (s, n_nokori)
        
        if dist[nt] > dist[ns]+n_cost:
            dist[nt] = dist[ns]+n_cost
            heappush(q, (dist[nt], nt))
    
    for a, b, t in d[s]:
        n_nokori = nokori - a
        n_cost = b
        
        nt = (t, n_nokori)

        if n_nokori < 0:
            continue
        if dist[nt] > dist[ns]+n_cost:
            dist[nt] = dist[ns]+n_cost
            heappush(q, (dist[nt], nt))

for (s, _), v in dist.items():
    ans[s] = min(ans[s], v)

for i in range(2, N+1):
    print(ans[i])

Measured memory_bytes: 118908
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define MOD 1000000007
#define MAXE9 1000000000
 
int i,j,k,l;
int main(){
  int N = 0;
  int T, A;
  int H;
  int tmp = 0;
  int ans = 1;
  int min = 2000000000;
  
  scanf("%d", &N);
  scanf("%d%d", &T, &A);
  for(i=1;i<=N;i++){
    scanf("%d", &H);
    tmp = abs((1000*T-6*H)-1000*A);
    if(tmp < min){
      	min = tmp;
        ans = i;
    }
  }
  printf("%d", ans);
}

Measured memory_bytes: 128
S = input()
N = len(S)
j1 = S == S[::-1]

j2_str = S[0:int((N+1)/2-1)]
j2 = j2_str == j2_str[::-1]


j3_str = S[int((N+3)/2-1):]
j3 = j3_str == j3_str[::-1]

if j1&j2&j3:
    ans = 'Yes'
else :
    ans = 'No'
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[200010],h[200010];
long long bt[200010];
long long p[200010];
long long lb(long long x){
	return x&-x;
}
void gx(long long pos,long long x){
	for(;pos<=n;pos+=lb(pos))
		bt[pos]=max(bt[pos],x);
}
long long cx(long long pos){
	long long ans=0;
	for(;pos;pos-=lb(pos))
		ans=max(ans,bt[pos]);
	return ans;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int j=1;j<=n;j++)
		cin>>a[j];
	for(int i=1;i<=n;i++)
		p[h[i]]=i;
	for(int i=1;i<=n;i++)
		gx(p[i],cx(p[i])+a[p[i]]);
	long long ans=0;
	for(int i=1;i<=n;i++)
		ans=max(ans,bt[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6528
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N, L = map(int, input().split())

# 自然数の和を用いる
# 初項Lで，N個の自然数の和
total = N*(2*L + N-1)/2

# 味がなるべく変わらないには，途中の項で絶対値が一番小さいものを選べば良い
aji_list = range(L, L+N, 1)
aji_abs_list = list(map(abs, aji_list))
aji_abs_list.sort()
min_list = aji_abs_list[0]

min_minus = min_list * -1
if L <= min_minus <= L+N:
    min_list = min_minus

# 上記を選んでtotalから弾く
print(int(total - min_list))


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).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; }

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


int main() {
    cout<<fixed<<setprecision(10);


    ll a,b,c;
    scanf("%ld %ld.%ld", &a, &b, &c);

    // cout<<a<<b<<c;

    ll ans = a*b + (a*c)/100;
    cout<<ans<<endl;


    return 0;

}

Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main(){
	int n;
	long long int a[100000];
	int count = 0;
	map<long int, int> m;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		m[a[i]] = i;
	}
	sort(a, a + n);
	for(int i = 0;i < n;i++){
		if((m[a[i]] - i) % 2){
			count++;
		}
	}
	cout << (count / 2) << endl;
}

Measured memory_bytes: 7296