akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

void clr(auto &a,int n){
  a.clear();
  a.resize(n);
}

void unq(auto &a){
  sort(all(a));
  a.resize(unique(all(a))-a.begin());
}

const int N=200005;

bool check(string s){
  string z=s;
  reverse(all(z));
  return z==s;
}


void solve(){
  int n;
  cin>>n;
  double val=n/3.0;
  cout<<setprecision(20)<<fixed<<val*val*val;
  
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    //cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



Measured memory_bytes: 256
from collections import defaultdict

N = int(input())


def fun(x, y, z):
  return x**2 + y**2 + z**2 + x*y + y*z + z*x

res = defaultdict(int)

for x in range(1, 100):
  for y in range(1, 100):
    for z in range(1, 100):
      res[fun(x, y, z)] += 1
        
for n in range(1, N+1):
  print(res[n])

Measured memory_bytes: 11676
from math import gcd
N = int(input())
A = list(map(int,input().split()))

def solve():
    g = 0
    for a in A:
        g = gcd(g,a)
    if g > 1:
        print('not coprime')
        exit()

    MAXA = 10**6
    B = [0] * (MAXA+1)
    for a in A:
        if a==1: continue
        if B[a]:
            print('setwise coprime')
            exit()
        B[a] = 1

    for n in range(2,MAXA+1):
        c = 0
        for m in range(n,MAXA+1,n):
            c += B[m]
            if c > 1:
                print('setwise coprime')
                exit()

    print('pairwise coprime')
solve()

Measured memory_bytes: 132608
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b;
    if(1<=a&&a<=9&&1<=b&&b<=9)Cout(a*b);
    else Cout(-1);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
    ll a,b,c,x,y,ans=0;
    cin>>a>>b>>c>>x>>y;
    ll m=(a+b>c*2)?c*2:a+b;
    //メインのピザを集める手段
    while(x>0&&y>0){
        x--;y--;
        ans+=m;
    }
    if(x==0&&y==0){
        cout<<ans<<endl;return 0;
    }
    ll rem=max(x,y),d=(x!=0)?a:b;
    if(c*2>d){
        //残りの一個の方は単品買いがいい
        while(rem!=0){
            rem--;ans+=d;
        }
        cout<<ans<<endl;return 0;
    }
    else{
        //残りの一個集めるのにもダブルの買うのがいい
        while(rem!=0){
            rem--;ans+=2*c;
        }
        cout<<ans<<endl;return 0;
    }
    return 0;
}


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

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
  	if(c>=b||d<=a)cout<<"0"<<endl;
  	else if(d>=b&&c>=a)cout<<b-c<<endl;
  	else if(b>d&&c>a)cout<<d-c<<endl;
  	else if(d>=a&&a>=c&&b>=d)cout<<d-a<<endl;
  	else cout<<b-a<<endl;
  	return 0;
}

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

char c[3][3];

int main() {
    rep(i, 3)rep(j, 3) cin >> c[i][j];

    rep(i, 3) cout << c[i][i];

    cout << endl;
}

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

using namespace std;

#define LIMIT 100
#define MOD 1000000007ll
#define INF 1e9
typedef long long ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){

  //ios::sync_with_stdio(false);
  cin.tie(NULL);

  int h, w, d;
  cin >> h >> w >> d;

  map<int, ii> m;

  int a;

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a;
      m[a] = ii(i, j);
    }
  }
  int prefix[90003];

  prefix[0] = 0;

  for (int i = 1; i <= h*w; ++i) {
    if(i <= d){
      prefix[i] = 0;
    }
    else {
      prefix[i] = prefix[i-d] + abs(m[i].first - m[i-d].first) + abs(m[i].second - m[i-d].second);
    }
  }

  int q, l, r; cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> l >> r;
    std::cout << prefix[r] - prefix[l] << std::endl;
  }

  return 0;
}



Measured memory_bytes: 7040
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;
using pr  = pair<ll, ll>;

const ll MOD = 1000000007;

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

	vec A(N);
	for (auto& a : A) { cin >> a; --a; }

	ll M = 1;

	vec used(N, -1);

	ll now = 0;

	for (ll i = K-1; i >= 0; --i)
	{
		if (used[now] != -1)
		{
			i = i % (used[now] - i);
		}

		used[now] = i;
		now = A[now];
	}
	
	cout << now+1 << endl;

	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

pll S[100005];
ll T[3];
char C[3] = {'A', 'B', 'C'};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N >> T[0] >> T[1] >> T[2];
    REP(i, N) {
        string t;
        cin >> t;
        if (t == "AB")
            S[i] = pll(0, 1);
        if (t == "BC")
            S[i] = pll(1, 2);
        if (t == "AC")
            S[i] = pll(0, 2);
    }

    REP(i, 3) {
        T[i] = std::min(T[i], 2LL);
    }

    stack<tuple<ll, ll, ll, ll>> s;
    vector<ll> v(N, -1);
    ll index = 0;
    while (index < N) {
        ll n = S[index].first, m = S[index].second;
        if (T[n] == T[m]) {
            if (T[n] == 0) {
                if (s.empty()) {
                    cout << "No" << endl;
                    return 0;
                }
                auto t = s.top();
                s.pop();
                index = get<0>(t);
                T[0] = get<1>(t);
                T[1] = get<2>(t);
                T[2] = get<3>(t);
                swap(T[S[index].first], T[S[index].second]);
                v[index] = S[index].second;
            }
            else {
                v[index] = n;
                T[n]++;
                T[m]--;
                s.push(make_tuple(index, T[0], T[1], T[2]));
            }
        }
        else {
            if (T[n] > T[m]) {
                T[n]--;
                T[m]++;
                v[index] = m;
            }
            else if (T[n] < T[m]) {
                T[n]++;
                T[m]--;
                v[index] = n;
            }
        }
        index++;
    }

    cout << "Yes" << endl;
    REP(i, N) {
        cout << C[v[i]] << endl;
    }

    return 0;
}

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

vector<int> u, v, w;

int makegraph(int l){
    if(l == 1){
        return 1;
    }
    int n = makegraph(l / 2);
    u.push_back(n);
    v.push_back(n + 1);
    w.push_back(0);    u.push_back(n);
    v.push_back(n + 1);
    w.push_back(l / 2);
    if(l % 2 == 1){
        u.push_back(1);
        v.push_back(n + 1);
        w.push_back(l - 1);
    }
    return n + 1;
}

int main()
{
    int l;
    cin >> l;
    int n = makegraph(l);
    int m = v.size();
    cout << n << " " << m << endl;
    for(int i = 0; i < m; i++){
        cout << u[i] << " " << v[i] << " " << w[i] << endl;
    }
}

Measured memory_bytes: 256
N=int(input())
i=0
placelist=[]
for _ in range(N):
  placelist.append([int(x) for x in input().split()])

mode=(placelist[0][0]+placelist[0][1])%2
for x in placelist:
  if mode!=(x[0]+x[1])%2:
    print(-1)
    exit()

mlist=[2**i for i in range(32,-1,-1)]


if mode:
  m=33
else:
  m=34
  mlist.append(1)


print (m)
print (' '.join(list(map(str,mlist))))

for x,y in placelist:
  xarm=0
  yarm=0
  route=''
  for arm in mlist:
    if (x-xarm)+(y-yarm)>0:
      if (x-xarm)-(y-yarm)>0:
        route+='R'
        xarm+=arm
      else:
        route+='U'
        yarm+=arm
    elif (x-xarm)-(y-yarm)>0:
      route+='D'
      yarm-=arm
    else:
      route+='L'
      xarm-=arm
  print(route)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

const int K = 2000;

int n, k, ans;
int cnt[K + 5][K + 5];
int sa[K + 5], sb[K + 5];

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif 

    read(n); read(k);
    for(int i = 1; i <= n; ++i) {
        int x, y;
        char col[5];

        read(x), read(y); scanf("%s", col);

        if(((x/k + y/k)&1) ^ (col[0] == 'W')) {
            ++ sa[x % k];
            ++ sb[y % k];
            ++ cnt[x % k][y % k];
        } else {
            ++ ans;

            -- sa[x % k];
            -- sb[y % k];
            -- cnt[x % k][y % k];
        }
    }

    for(int i = 0; i <= k; ++i) {
        if(i > 0) sa[i] += sa[i-1];
        if(i > 0) sb[i] += sb[i-1];

        for(int j = 0; j <= k; ++j) if(j > 0) cnt[i][j] += cnt[i][j-1];
        for(int j = 0; j <= k; ++j) if(i > 0) cnt[i][j] += cnt[i-1][j];
    }

    int res = ans;
    for(int A = 0; A < k; ++A) {
        for(int B = 0; B < k; ++B) {
            chkmax(res, ans + sa[A] + sb[B] - 2*cnt[A][B]);
            chkmax(res, n - (ans + sa[A] + sb[B] - 2*cnt[A][B]));
        }
    }
    printf("%d\n", res);

    return 0;
}


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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


int n, m;
string s;
vector<int> g[200005];
bool ok[200005];
bool used[200005];
void dfs(int i) {
    if (!ok[i] || used[i]) return;
    used[i] = true;
    bool b1 = false, b2 = false;
    rep(j, sz(g[i])) {
        auto v = g[i][j];
        dfs(v);
        if (s[v] == 'A') b1 |= ok[v];
        else b2 |= ok[v];
    }
    if (!b1 || !b2) {
        ok[i] = false;
        rep(j, sz(g[i])) {
            auto v = g[i][j];
            used[v] = false;
            dfs(v);
        }
    }
}

void solve() {
    cin >> n >> m >> s;
    rep(i, m) {
        int a, b; cin >> a >> b; --a; --b;
        g[a].push_back(b); g[b].push_back(a);
    }

    rep(i, n) {
        bool b1 = false, b2 = false;
        rep(j, sz(g[i])) {
            auto v = g[i][j];
            if (s[v] == 'A') b1 = true;
            else b2 = true;
        }
        if (b1 && b2) ok[i] = true;
    }

    rep(i, n) dfs(i);

    bool ans = false;
    rep(i, n) if (ok[i]) { ans = true; break; }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 22352
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
void read(T...)(auto ref T args){ 
	auto line = readln().split(); 
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
int sum(int n){return n * (n + 1)/ 2;}
void main(){
	int m;m.read;
	for(;m>0;m--){
		string cars;cars.read;
		bool[string] exist;
		foreach(i;1..cars.length){
			auto f = (string a) =>[a,a.dup.reverse.idup];
			foreach(c1;f(cars[0..i])) {
				foreach(c2;f(cars[i..$])){
					exist[c1 ~ c2] = true;
					exist[c2 ~ c1] = true;
				}
			}
		}
		exist.length.writeln;
	}
}

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

using namespace std;

int main(){
  string s;
  string t;
  vector<int> ans;
  int count=0;
  cin >> s >> t;
  for(int i=0;i<=s.size()-t.size();i++){
    count = 0;
    for(int j=0;j<t.size();j++){
      if(s.at(i+j)!=t.at(j)){
        count++;
      }
    }
    ans.push_back(count);
  }
  sort(ans.begin(), ans.end());
  cout << ans.at(0) << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

string Sd, T, S; cin >> Sd >> T;
S = Sd;

if (Sd.find('?') == string::npos) {
    if (Sd.find(T) == string::npos){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    else {
        cout << Sd << endl;
        return 0;
    }
}

int lenT = T.size(), lenSd = Sd.size();
if (Sd.size() < lenT) {
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Rrep(i, lenSd - lenT, 0){
    bool a = false;
    string subSd = Sd.substr(i, lenT);
    rep(j, 0, lenT){
        if (subSd[j] != '?' && subSd[j] != T[j]) {
            a = true;
            break;
        }
    }
    if (a) continue;
    S.replace(i, lenT, T);
    rep(j, 0, lenSd){
        if (S[j] == '?') S[j] = 'a';
    }
    cout << S << endl;
    return 0;
}

cout << "UNRESTORABLE" << endl;
return 0;


}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
#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++)
typedef int64_t Int;
typedef pair<int,Int> p;
const Int INF = 1e18;

int N; 
vector<Int> A(200010);
vector<vector<int>> G(200010);

vector<bool> visited(200010, false);
vector<int> ans(200010);
vector<Int> dp(200010, INF);

stack<p> updates;

void dfs(int from){
    visited[from] = true;

    for(int to : G[from]){
        if(!visited[to]){
            int it = lower_bound(dp.begin(), dp.end(), A[to]) - dp.begin();
            updates.push(p(it, dp[it]));
            dp[it] = A[to]; 
            ans[to] =  lower_bound(dp.begin(), dp.end(), INF) - dp.begin();

            dfs(to);

            dp[updates.top().first] = updates.top().second;
            updates.pop();
        }
    }
}

int main(){
    cin >> N;
    rep(i,N) cin >> A[i];

    rep(i,N-1){
        int u, v; cin >> u >> v; u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }


    dp[0] = A[0]; ans[0] = 1;

    dfs(0);

    rep(i,N) cout << ans[i] << endl;
}


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

int main(void){
  int h, w, row, column;
  cin >> h >> w;
  vector<vector<char>> map(h, vector<char>(w));

  for(row = 0; row < h; row++){
    for(column = 0; column < w; column++){
      cin >> map[row][column];
    }
  }

  for(row = 0; row < h; row++){
    for(column = 0; column < w; column++){
      if(map[row][column] == '#') break;
    }
    if(column == w){
      map.erase(map.begin() + row);
      row--;
      h--;
    }
  }

  for(column = 0; column < w; column++){
    for(row = 0; row < h; row++){
      if(map[row][column] == '#') break;
    }
    if(row == h){
      for(row = 0; row < h; row++){
        map[row].erase(map[row].begin() + column);
      }
      column--;
      w--;
    }
  }

  for(row = 0; row < h; row++){
    for(column = 0; column < w; column++){
      cout << map[row][column];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  string s;
  cin >> s;

  if (s.size() % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  for (int i = 0; i < (int) s.size(); i++) {
    if (i % 2 == 0) {
      if (s[i] != 'h') {
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      if (s[i] != 'i') {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector<double> vd;
typedef std::vector<std::string> vs;
typedef std::vector<pii> vpii;
typedef std::vector<vi> vvi;
typedef std::vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { rep(i,v.size()) is >> v[i]; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int &s = 0, const int &d = 0, const Weight &w = 0) : src(s), dst(d), weight(w) {}
};

typedef std::vector<Edge> Edges;
typedef std::vector<Weight> Array;
typedef std::vector<Array> Matrix;

class Graph {
  std::vector<Edges> g;

public:
  Graph(const int &size = 0) : g(size) {}
  int size() const { return g.size(); }
  const Edges &operator[](const int &i) const { return g[i]; }
  void addArc(const int &src, const int &dst, const Weight &w = 1) { g[src].emplace_back(src, dst, w); }
  void addEdge(const int &node1, const int &node2, const Weight &w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }
};

template<int inf = std::numeric_limits<Weight>::max() / 8> std::pair<std::vector<Weight>, std::vector<int>> dijkstra(const Graph &g, const int &src) {
  using state = std::pair<Weight, int>;
  std::priority_queue<state, std::vector<state>, std::greater<state>> q;
  std::vector<Weight> dist(g.size(), inf);
  std::vector<int> via(g.size());
  dist[src] = 0;
  q.emplace(0, src);
  while (q.size()) {
    Weight d;
    int v;
    std::tie(d, v) = q.top();
    q.pop();
    if (dist[v] < d) continue;
    for (auto &e : g[v]) {
      if (cmin(dist[e.dst], dist[v] + e.weight)) {
        via[e.dst] = v;
        q.emplace(dist[e.dst], e.dst);
      }
    }
  }
  return {dist, via};
}

main {
  int n;
  while (cin >> n, n) {
    Graph g(10);
    set<int> s;
    rep(i, n) {
      int a, b, c;
      cin >> a >> b >> c;
      s.insert(a), s.insert(b);
      g.addEdge(a, b, c);
    }
    vi v(s.size());
    copy(all(s), v.begin());
    Matrix dist(10, Array(10));
    rep(i, 10) {
      vector<Weight> d = dijkstra<INF>(g, i).first;
      rep(j, 10) dist[i][j] = d[j];
    }
    int ms = INF, mp;
    rep(i, 10) {
      int s = 0;
      for (int j : v) s += dist[i][j];
      if (cmin(ms, s)) mp = i;
    }
    cout << mp << ' ' << ms << endl;
  }
}

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

int main() {
  vector<int> a(5);
  for (int i = 0; i < 5; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < 5; ++i) {
    if (a[i] == 0) {
      cout << i + 1 << endl;
    }
  }
}


Measured memory_bytes: 3488
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        String s = sc.next();
        int len = s.length();

        int ans = len;
        int index = 0;
        while (true) {
            int next;
            char c = s.charAt(index);
            if (c == '0') {
                next = s.indexOf('1', index + 1);
            } else {
                next = s.indexOf('0', index + 1);
            }

            if (next == -1) {
                break;
            }

            ans = Math.min(ans, Math.max(next, len - next));
            index = next;
        }

        System.out.println(ans);
    }

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


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 200000
typedef pair<i64, i64> P;
i64 N;
P A[MAX_N];


int main() {
  cin >> N;
  i64 a;
  REP(i, N) {
    cin >> a;
    A[i] = mp(a, i);
  }
  sort(A, A + N);

  i64 maxi = A[N - 1].S;
  REP(i, N) {
    if (i == maxi) {
      cout << A[N - 2].F << endl;
    } else {
      cout << A[N - 1].F << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define MAX 200200
#define MOD 1000000007
using namespace std;
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,X,Y,ans;
struct Ball{int c,w;}B[MAX];
bool operator<(Ball a,Ball b){if(a.c!=b.c)return a.c<b.c;return a.w<b.w;}
int jc[MAX],jv[MAX],inv[MAX];
int pmn[MAX],smn[MAX],sz[MAX],W[MAX],p[MAX];
bool cmp(int i,int j){return W[i]<W[j];}
int main()
{
	n=read();X=read();Y=read();
	for(int i=1;i<=n;++i)B[i].c=read(),B[i].w=read();
	jc[0]=jv[0]=inv[0]=inv[1]=1;
	for(int i=2;i<=n;++i)inv[i]=1ll*inv[MOD%i]*(MOD-MOD/i)%MOD;
	for(int i=1;i<=n;++i)jc[i]=1ll*jc[i-1]*i%MOD,jv[i]=1ll*jv[i-1]*inv[i]%MOD;
	sort(&B[1],&B[n+1]);
	memset(pmn,63,sizeof(pmn));
	memset(smn,63,sizeof(smn));
	memset(W,63,sizeof(W));
	for(int i=1,j;i<=n;i=j+1)
	{
		j=i;while(j<n&&B[i].c==B[j+1].c)++j;
		pmn[B[i].c]=smn[B[i].c]=B[i].w;
	}
	for(int i=1;i<=n;++i)pmn[i]=min(pmn[i],pmn[i-1]);
	for(int i=n;i>=1;--i)smn[i]=min(smn[i],smn[i+1]);
	for(int i=1,j;i<=n;i=j+1)
	{
		j=i;while(j<n&&B[i].c==B[j+1].c)++j;
		int d=min(pmn[B[i].c-1],smn[B[i].c+1]);
		int cnt=1;
		for(int k=i+1;k<=j;++k)
			if(B[i].w+B[k].w<=X||B[k].w+d<=Y)++cnt;
			else break;
		sz[B[i].c]=cnt;W[B[i].c]=B[i].w;
	}
	for(int i=1;i<=n;++i)p[i]=i;
	sort(&p[1],&p[n+1],cmp);
	for(int i=1;i<=n;++i)
		if(i==1||W[p[i]]+W[p[1]]<=Y)
			ans+=sz[p[i]];
	ans=jc[ans];
	for(int i=1;i<=n;++i)
		if(i==1||W[p[i]]+W[p[1]]<=Y)
			ans=1ll*ans*jv[sz[p[i]]]%MOD;
	printf("%d\n",ans);
	return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  string s; cin>>s;
  int ans=0;
  for (char c: s) ans += c=='1';
  cout<<ans;
  

  return 0;
}


Measured memory_bytes: 256
def main(n,k,s):
  l=[0]
  for i in range(1,n):
    if s[i]==s[i-1]:
      l[-1]+=1
    else:
      l.append(0)
  print(min(n-1,sum(l)+k*2))
    
if __name__=='__main__':
  import sys
  input = sys.stdin.readline
  n,k=map(int,input().split())
  s=input()
  main(n,k,s)


Measured memory_bytes: 4116
#include <stdio.h>
int main(){
	int x,y,a,b,z;
	scanf("%d%d",&x,&y);
	z=y-2*x;
	if(z%2){printf("No\n");return 0;}
	b=z/2;
	a=x-b;
	if(b<0||a<0){printf("No\n");return 0;}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1660
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
#include <list>

#include <random>
using namespace std;

int main(void) {
	int N, t;
	scanf("%d", &N);
	bool prev_match = false;
	int count = 0;
	for (int i = 1; i <= N; i++) {
		scanf("%d", &t);
		if (t == i) {
			if (prev_match) {
				prev_match = false;
			}
			else {
				count++;
				prev_match = true;
			}
		}
		else {
			prev_match = false;
		}
	}

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <memory.h>
using namespace std;

int par[1000];
int Rank[1000];

void init(int n) {
  for(int i = 0; i < n; i++) {
    par[i] = i;
    Rank[i] = 0;
  }
}

int find(int x) {
  if(par[x] == x) {
    return x;
  }
  return par[x] = find(par[x]);
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if(x == y) return;

  if(Rank[x] < Rank[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if(Rank[x] == Rank[y]) Rank[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int main() {
  int V,d;
  long long fib[1000];
  fib[0] = 2L;
  fib[1] = 3L;
  for(int i = 2; i < 1000; i++) {
    fib[i] = (fib[i-1] + fib[i-2]) % 1001;
  }
  while(cin >> V >> d) {
    init(V);
    for(int i = 0; i < V; i++) {
      for(int j = 0; j < V; j++) {
        if(abs(fib[i] - fib[j]) < d) {
          unite(i,j);
        }
      }
    }
    int count = 0;
    for(int i = 0; i < V; i++) {
      if(find(i) == i) count++;
    }
    printf("%d\n",count);

  }



}

Measured memory_bytes: 1160
_ = $stdin.gets
Perm = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }

grp = [[]]
Perm.each_with_index { |n,i|
  if n != i+1
    grp << []
  else
    grp[-1] << n
  end
}

grp.select! { |g| g.size > 0 }
#p grp

p grp.map{ |g| (g.size+1)/2 }.inject(:+) || 0


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

template <class T>  inline void smax(T &x,T y){ x = max((x), (y)); }
template <class T>  inline void smin(T &x,T y){ x = min((x), (y)); }

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

int a[200005] ;

int main()
{
    int i , j , k , l , m , n ;

    scanf("%d %d",&n,&k) ;

    for(i=1 ;i<=n ; i++)
    {
        scanf("%d",&m) ;
        a[m]++ ;
    }

    int ans = n ;

    j = 0 ;

    sort(a+1,a+n+1) ;

    for(i=n ; i>=1 ; i--)
    {
        if( j<k && a[i]!=0 )
        {
            ans -= a[i] ;
            j++ ;
        }
    }

    printf("%d",ans) ;

    return 0 ;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Amondai
{
    static void Main()
    {
        var str=Console.ReadLine();
        var ans = 0L;
        var length = str.Count();
        var place = 0;
        for (int i=length-1;-1<i;--i)
        {
            if (str[i] == 'B')
            {
                ans += place;
                place--;
            }
            place++;
        }


        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11744
#include<iostream>

int main(void){
    long long a, b, n;
    std::cin >> a >> b >> n;
    if(b - 1 <= n){
	std::cout << (a * (b - 1)) / b - a * ((b - 1) / b) << std::endl;
    }else{
	std::cout << (a * n) / b - a * (n / b) << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        String input = Console.ReadLine();
        char A = char.Parse(input);
        if (A >= 'a') { Console.WriteLine("a"); }
        else { Console.WriteLine("A"); }
    }
}

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

int size;
vector<long long> val;
vector<long long> lazy;
vector<int> width;

void lazy_propagate(int p) {
    if (lazy[p] > 0) {
        val[p] += lazy[p] * width[p];
        if (p < size-1) {
            lazy[p*2+1] += lazy[p];
            lazy[p*2+2] += lazy[p];
        }
        lazy[p] = 0;
    }
}

void add(int wishl, int wishr, int watchl, int watchr, int k, int x) {
    if (wishr <= watchl || watchr <= wishl) {
        lazy_propagate(k);
        return;
    }
    if (wishl <= watchl && watchr <= wishr) {
        lazy[k] += x;
        lazy_propagate(k);
        return;
    }
    int mid = (watchl+watchr)/2;
    lazy_propagate(k);
    add(wishl, wishr, watchl, mid, k*2+1, x);
    add(wishl, wishr, mid, watchr, k*2+2, x);
    val[k] = val[k*2+1] + val[k*2+2];
}
void add(int wishl, int wishr, int x) {
    add(wishl, wishr, 0, size, 0, x);
}

long long getsum(int wishl, int wishr, int watchl, int watchr, int k) {
    if (wishr <= watchl || watchr <= wishl) {
        return 0;
    }
    if (wishl <= watchl && watchr <= wishr) {
        lazy_propagate(k);
        return val[k];
    }
    int mid = (watchl+watchr)/2;
    lazy_propagate(k);
    long long sl = getsum(wishl, wishr, watchl, mid, k*2+1);
    long long sr = getsum(wishl, wishr, mid, watchr, k*2+2);
    return sl + sr;
}
long long getsum(int wishl, int wishr) {
    return getsum(wishl, wishr, 0, size, 0);
}

signed main() {
    int n, q;
    cin >> n >> q;
    size = 1;
    while (size < n) size <<= 1;
    val = vector<long long>(size*2, 0);
    lazy = vector<long long>(size*2, 0);
    width = vector<int>(size*2, 1);

    for (int i = size-2; i >= 0; i--) {
        width[i] = width[i*2+1] + width[i*2+2];
    }

    while (q--) {
        int type, l, r;
        cin >> type >> l >> r;
        if(type == 0) {
            int x;
            cin >> x;
            add(l-1, r, x);
        } else {
            cout << getsum(l-1, r) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7828
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
    lli n,k;
    cin >> n >> k;
    vector<lli> pos, neg;
    lli zero = 0;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        if(a == 0) zero++;
        else if(a > 0) pos.push_back(a);
        else if(a < 0) neg.push_back(-a);
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    lli lb=-2e18, ub=2e18;
    while(lb+1 < ub){
        lli mid = (lb+ub)/2;
        lli count = 0;
        if(mid < 0){
            for(lli x: pos){
                count += neg.end() -lower_bound(neg.begin(), neg.end(), (-mid+x-1)/x);
            }
        }else{
            lli ps=pos.size(), ns=neg.size();
            count += ps*ns +zero*(ps+ns) +zero*(zero-1)/2;
            for(int i=0; i<(int)pos.size(); i++){
                int idx = upper_bound(pos.begin(), pos.end(), mid/pos[i]) -pos.begin();
                count += min(idx, i);
            }
            for(int i=0; i<(int)neg.size(); i++){
                int idx = upper_bound(neg.begin(), neg.end(), mid/neg[i]) -neg.begin();
                count += min(idx, i);
            }
        }
        if(count < k){
            lb = mid;
        }else{
            ub = mid;
        }
    }
    cout << ub << endl;
    return 0;
}


Measured memory_bytes: 2420
from math import pi, cos, sqrt
import numpy as np

H_len, M_len, H, M = map(int, input().split())

#H_len = Lis[0]
#M_len = Lis[1]

#H = Lis[2]
#M = Lis[3]

M_deg = 2*pi * M / 60
H_deg = 2*pi * (60 * H + M) / 12 / 60

deff = 0.0

deff = abs(M_deg - H_deg)

ans = sqrt(H_len ** 2 + M_len ** 2 - (2 * H_len * M_len * cos(deff)))

print(ans)


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

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

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

long long modpow(long long x, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}


int n, a, b;
// string s;

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

    Vi inv(max(a, b)+1, 1);
    for (int i = 2; i <= max(a, b); i++) {
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    }

    ll x = 1, y = 1;
    RREP(i, n, n-a+1) {
        x *= i;
        x %= MOD;
    }
    RREP(i, a, 2) {
        x *= inv[i];
        x %= MOD;
    }
    RREP(i, n, n-b+1) {
        y *= i;
        y %= MOD;
    }
    RREP(i, b, 2) {
        y *= inv[i];
        y %= MOD;
    }

    cout << (modpow(2, n, MOD) + 3 * MOD - 1 - x - y)%MOD << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<int>g[100005];
int dp[100005];
int ind[100005];
queue<int>q;
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		ind[y]++;
	}
	for(int i=1;i<=n;i++) if(!ind[i]) q.push(i);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(int i=0;i<g[x].size();i++){
			int k=g[x][i];
			dp[k]=max(dp[k],dp[x]+1);
			ind[k]--;
			if(!ind[k]) q.push(k);
		}
	} 
	int ans=0;
	for(int i=1;i<=n;i++) ans=max(ans,dp[i]);
	cout<<ans<<endl; 
	return 0;
}

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

#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,l,r) for(int i = l; i <= r; i++)
#define TR(e,x) for(auto e = x.begin(); e != x.end(); e++)
#define DEBUG(x) cout << #x << "=" << x << endl;
#define SHOW1(A,n) { REP(i,n-1) printf("%d ", A[i]); printf("%d\n", A[n-1]); }
#define SHOW2(A,m,n) { REP(i,m) { REP(j,n-1) printf("%d ", A[i][j]); printf("%d\n", A[i][n-1]); } }
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)((x).size())
typedef long long LL;
const int MAXN  = 8e5, INF = ~0U>>1, MOD = ~0U>>1;



int main()
{
#ifdef LOCAL
    //freopen("i.txt", "r", stdin);
    //freopen("o.txt", "w", stdout);
#endif //LOCAL

    string s;
    int n;
    cin >> s >> n;
    set<string> S;
    for (int i = 0; i < SZ(s); i++) {
        for (int j = 1; j+i <= SZ(s); j++) {
            S.insert(s.substr(i,j));
            if (SZ(S) > n) {
                auto it = --S.end();
                string tmp = *it;
                S.erase(--S.end());
                if (tmp == string(s.substr(i,j))) break;
            }
        }
    }
    auto it = --S.end();
    cout << *it << endl;

    return 0;
}


















































































Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=0
maenomax=a[0]
for i in range(n):
    if maenomax > a[i]:
        ans += maenomax-a[i]
    elif maenomax < a[i]:
        maenomax=a[i]
print(ans)

Measured memory_bytes: 32360
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;
typedef bitset<100> bits;

int solve(int pos, bits covered, bits goal, vector<bits> &c){
    if(covered == goal){
        return 0;
    }
    // 使う意味がない
    if((covered|c[pos]) == covered){
        return solve(pos+1, covered, goal, c);
    }
    // 必ず使う
    if(goal[pos]==1 and covered[pos]==0){
        return solve(pos+1, covered|c[pos], goal, c) +1;
    }
    // 自分以降の誰かに完全包含されている
    for(int i=pos+1; i<(int)c.size(); i++){
        if((covered|c[i]|c[pos]) == (covered|c[i])){
            return solve(pos+1, covered, goal, c);
        }
    }
    return min(solve(pos+1, covered, goal, c),
                solve(pos+1, covered|c[pos], goal, c) +1);
}

int main(){
    while(1){
        int w,h;
        cin >> w >> h;
        if(h == 0) break;

        bits goal;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                int a;
                cin >> a;
                goal[i*w+j] = a;
            }
        }
        // 各地点を左上にしたときの最大カーペットのビット表現
        vector<bits> carpet; 
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                bits a;
                for(int k=1; k+i<h+1 and k+j<w+1; k++){
                    bool ok = true;
                    bits b;
                    for(int s=i; s<i+k; s++){
                        for(int t=j; t<j+k; t++){
                            b[s*w+t] = 1;
                            if(goal[s*w+t] == 0) ok = false;
                        }
                    }
                    if(!ok) break;
                    a = b;
                }
                carpet.push_back(a);
            }
        }
        // 必ず敷かなければいけない
        vector<bits> must;
        bits covered;
        for(int i=0; i<(int)carpet.size(); i++){
            bits other;
            for(int j=0; j<(int)carpet.size(); j++){
                if(i == j) continue;
                other |= carpet[j];
            }
            if((carpet[i]|other) != other){
                must.push_back(carpet[i]);
                covered |= carpet[i];
            }
        }
        cout << solve(0, covered, goal, carpet) +(int)must.size() << endl;
    }
    return 0;
}


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

int main(void) {
    int n;
    int array_2[20001] = {};
    int array_5[20001] = {};
    
    for(int i = 1; i <= 20000; ++i) {
        int j = i;
        array_2[i] = array_2[i - 1];
        array_5[i] = array_5[i - 1];
        while(j % 2 == 0) {
            ++array_2[i];
            j /= 2;
        }
        while(j % 5 == 0) {
            ++array_5[i];
            j /= 5;
        }
    }
    
    while(cin >> n) {
        if(n == 0)   break;
        int ans = (array_2[n] < array_5[n]) ? array_2[n] : array_5[n];
        cout << ans << endl;
    }
    
    return 0;
}


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

vector<vector<bool>> flg(3, vector<bool>(3, false));

void isHit(vector<vector<int>> vp, int b){
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      if(b == vp[i][j]) flg[i][j] = true;
    }
  }
}

int main(){
  vector<vector<int>> vp(3, vector<int>(3));
  int a, b;
  bool flag = false;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> a;
      vp[i][j] = a;
    }
  }
  for(int i = 0; i < 9; i++){
    cin >> b;
    isHit(vp, b);
  }
  for(int i = 0; i < 3; i++){
    if(flg[i][0] && flg[i][1] && flg[i][2]) flag = true;
    if(flg[0][i] && flg[1][i] && flg[2][i]) flag = true;
  }
  if(flg[0][0] && flg[1][1] && flg[2][2]) flag = true;
  if(flg[2][0] && flg[1][1] && flg[0][2]) flag = true;
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    if (!(i % 3)) {
      printf(" %d", i);
      continue;
    } else {
      int x = i;
      while (x) {
        if (x % 10 == 3) {
          printf(" %d", i);
          break;
        }
        x /= 10;
      }
    }
  }
  printf("\n");
  return 0;
}



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

using namespace std;
using namespace __gnu_pbds;
#define int long long
typedef pair <int, int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N = 1e5 + 5;
int a[N], n, pref[N];
ordered_set S;

int check(int mid) {
	S.clear();
	memset(pref, 0, sizeof pref);
	int res = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] > mid) pref[i] = -1;
		else pref[i] = 1;
	}
	for (int i = 1; i <= n; ++i) pref[i] += pref[i - 1];
	S.insert({0, 0});
	for (int i = 1; i <= n; ++i) {
		res += S.order_of_key({pref[i], 0});
		S.insert({pref[i], i});
	}
	return res;
}

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

	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	int bound = (n * (n + 1) / 2) / 2 + 1;
	int l = 0, r = (int)1e9, ans = r;
	while (l <= r) {
		int mid = (l + r) >> 1;
		int d = check(mid);
		if (d >= bound) {
			r = mid - 1;
			ans = min(ans, mid);
		} else l = mid + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10112
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int r, c, k; cin >> r >> c >> k;
	vector<vector<array<int, 2>>> items(r+1);
	for (int i = 0; i < k; ++i) {
		int x, y, v; cin >> x >> y >> v;
		items[x].push_back({y, v});
	}
	for (auto &vec : items)
		sort(begin(vec), end(vec));

	vector<ll> best(c+1);
	vector<vector<ll>> dp(r+1);
	vector<vector<array<ll, 3>>> dp2(r+1);
	ll ans = 0;
	for (int row = 1; row <= r; ++row) {
		auto &v = items[row];
		auto &cur = dp[row];
		auto &cur2 = dp2[row];
		cur.resize(v.size()); cur2.resize(v.size());
		ll best1 = -1, best2 = -1;
		for (int j = 0; j < (int)v.size(); ++j) {
			auto [col, val] = v[j];
			cur2[j][0] = best[col] + val;
			if (best1 >= 0) cur2[j][1] = best1 + val;
			if (best2 >= 0) cur2[j][2] = best2 + val;
			best1 = max(best1, cur2[j][0]);
			best2 = max(best2, cur2[j][1]);
			cur[j] = *max_element(begin(cur2[j]), end(cur2[j]));
			ans = max(ans, cur[j]);
		}
		for (int j = 0; j < (int)v.size(); ++j)
			best[items[row][j][0]] = max(best[items[row][j][0]], cur[j]);
		for (int j = 2; j <= c; ++j)
			best[j] = max(best[j], best[j-1]);
	}
	cout << ans << '\n';
}

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

using namespace std;

int main() {
	string str;
	bool ccc = false;
	cin >> str;

	for (int i = 0; i < str.length(); i++) {
		if (ccc) {
			if (str.at(i) == 'F') {
				cout << "Yes" << endl;
				return 0;
			}
		}
		else {
			if (str.at(i) == 'C') {
				ccc = true;
			}
		}
	}

	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256