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

using ll = long long;

// Disjoint Set
template<typename T>
class UnionFind {
 public:
  // n要素で生成
  explicit UnionFind(T n) : _size{n}, _parent{vector<T>(n, -1)} {}
  // 木の根を求める
  T find(T x) {
    if (x < 0 || x >= _size) return x;
    if (_parent[x] < 0) return x;
    return _parent[x] = find(_parent[x]);
  }
  // xとyの属する集合を併合する
  bool unite(T x, T y) {
    if (x < 0 || x >= _size || y < 0 || y >= _size) return false;
    x = find(x), y = find(y);
    if (x == y) return false;
    if (_parent[x] > _parent[y]) swap(x, y);
    _parent[x] += _parent[y];
    _parent[y] = x;
    return true;
  }
  // xとyが同じ集合に属するか
  bool same(T x, T y) { return find(x) == find(y); }
  // xの属する集合の個数を求める
  T size(T x) {
    if (x < 0 || x >= _size) return 1;
    return -_parent[find(x)];
  }
  // 全体の個数を求める
  T size() { return _size; }
 private:
  T _size;
  vector<T> _parent; // 親の番号（親自身はー（マイナス）集合要素の個数）
};

constexpr int MAX_N = 1e5;
set<int> like[MAX_N];
int ans[MAX_N];

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind<int> uf(N);
  for (int i{}; i < M; ++i) {
    int A, B;
    cin >> A >> B;
    --A, --B;
    like[A].insert(B), like[B].insert(A);
    uf.unite(A, B);
  }
  for (int i{}; i < K; ++i) {
    int C, D;
    cin >> C >> D;
    --C, --D;
    like[C].insert(D), like[D].insert(C);
  }

  for (int i{}; i < N; ++i) {
    int root = uf.find(i);
    ans[i] = uf.size(i) - 1;
    for (const auto &j : like[i]) {
      if (root == uf.find(j)) --ans[i];
    }
  }

  cout << ans[0];
  for (int i{1}; i < N; ++i) {
    cout << ' ' << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 25088
// Created by new_sm
//
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n;
cin>>n;
//(x1,y1)
vi v(n);
for(int i=1;i<=n;i++)
v[i-1]=i;
vector<pii>coord(n);
for(int i=0;i<n;i++)
{
	int x,y;
	cin>>x>>y;
	coord[i]={x,y};
}
double sum=0;
do{
	for(int i=1;i<n;i++)
	{
		double x=(coord[v[i]-1].first-coord[v[i-1]-1].first)*(coord[v[i]-1].first-coord[v[i-1]-1].first);
		double y=(coord[v[i]-1].second-coord[v[i-1]-1].second)*(coord[v[i]-1].second-coord[v[i-1]-1].second);
	//	cout<<x<<" "<<y<<endl;
		sum+=(sqrt(x+y));
	}
//	cout<<sum<<endl;
}
while(next_permutation(all(v)));
int f=1;
for(int i=1;i<=n;i++)
f*=i;
sum=sum/f;
SET(10)<<sum;
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}



Measured memory_bytes: 3816
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=999999999999;

bool comp(pair<ll,ll> p1, pair<ll,ll> p2){
    return p1.first>p2.first;
}

bool check(vector<pair<ll,ll> > vp){
    ll h=0;
    for(pair<ll,ll> p:vp){
        if(h+p.first<0){
            return false;
        }
        h+=p.second;
    }
    return true;
}

int main(){
    int n;
    cin>>n;
    vector<pair<ll, ll> > pos, neg;
    ll total=0;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        int h=0; int b=0;
        for(char c:s){
            if(c=='('){
                h++;
            }else{
                h--;
            }
            b=min(b,h);
        }
        if(h>=0){
            pos.push_back(make_pair(b,h));
        }else{
            neg.push_back(make_pair(b-h,-h));
        }
        total+=h;
    }
    sort(pos.begin(),pos.end());
    reverse(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());
    reverse(neg.begin(),neg.end());
    //for(pair<ll,ll> p:pos){
    //    cout<<p.first<<" "<<p.second<<endl;
    //}
    if(check(pos) && check(neg) && total==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 34596
#!ruby -pal
$c={}
def f l,*a
a[0]?($c[a.sort<<l]||=a.map{f(*a.rotate!)+(4*a[0]*l)**0.5}.min):l
end
m,*r=$F.map &:to_i
$_=r.map{f(*r.rotate!)+r[0]}.min<=m ?:OK: :NA

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

string s, t;
int k;

bool match (int x) {
    rep(i,t.size()) {
        if(s[i+x]!='?' && s[i+x]!=t[i]) return false; 
    }
    return true;
}

int main() { 
    cin >> s >> t;
    for(k = s.size()-t.size(); k >= 0; --k) {
        if(!match(k)) continue;
        rep(j, t.size()) if(s[j+k]=='?') s[k+j] = t[j];
        rep(j, s.size()) if(s[j]=='?') s[j] = 'a';
        cout << s << endl;
        return 0;
    }    
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		    int a = sc.nextInt();
		    if((a / 10) % 111 == 0 ) {
		    	System.out.println("Yes");
		    }
		    else if((a - a/1000*1000) % 111 == 0) {
		    	System.out.println("Yes");
		    }
		    else {
		    	System.out.println("No");
		    }
		    sc.close(); }
}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int main(){
	int x[10000] = { 0 };
	int y[10000] = { 0 };
	for (int i = 0; i < 3000; i++){
		cin >> x[i];
		cin >> y[i];
		if (x[i] == 0 && y[i] == 0){
			break;
		}
	}
		for (int i = 0; i < 3000; i++){
			if (x[i] == 0 && y[i] == 0){
				break;
			}
			if (x[i] >= y[i]){
				cout << y[i]<<" "<< x[i] << endl;
			}
		if (x[i] < y[i]){
			cout << x[i] <<" "<< y[i] << endl;
		}
		

	
	}
	return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 3.1415926535897932384626433832795028841971693993751058
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  //freopen("input.txt","r",stdin);
#endif
  int n;
  cin>>n;
  cout<<setprecision(10)<<2*pi*n<<endl;
  
  return 0;
}

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

int isPar(string s, int l, int r){
  int ans = 1;
  for (; l<r; l++, r--){
    ans &= (s[l]==s[r]);
  }
  return ans;
}

int main(void){
  string s;
  int n;
  
  cin >> s;
  n = s.size();
  cout << (isPar(s,0,n-1)&&isPar(s,0,n/2-1)?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,W;
  cin>>N>>W;
  VI A(N),B(N);
  rep(i,N) cin>>A[i]>>B[i];
  VVL dp(N+1,VL(100100,-1));
  dp[0][0]=0;
  rep(i,N){
    rep(j,100100){
      if(dp[i][j]!=-1){
        dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
        if(j+A[i]<=W) dp[i+1][j+A[i]]=max(dp[i+1][j+A[i]],dp[i][j]+B[i]);
      }
    }
  }
  ll ans=0;
  rep(i,W+1) ans=max(ans,dp[N][i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 80256
/*????§?????????? by AZQ*/

#include <stdio.h>

int main(void){
    FILE *fp;
    fp = stdin;
    if(fp==NULL){
        printf("Error opening file\n");
        return 1;
    }
    
    char station[100];
    int station0[100];
    int key[100];
    int count;
    int i,j;
    while(1){
        fscanf(fp,"%d",&count);
        if(count==0){
            return 0;
        }
        for(i=0;i<count;i++){
            fscanf(fp,"%d",&key[i]);
        }
        fscanf(fp,"%s",station);
        i=0;
        j=0;
        while(station[i] != '\0'){
            station0[i]=(int)station[i];
            //printf("%d station:%d ",i,station0[i]);
            if(station0[i] <= 90 && station0[i]>=65){//65~90
                station0[i]=(station0[i]-65-key[j%count]+52)%52;

            }else if(station0[i]<=122 && station0[i]>=97){//97~122
                station0[i]=(station0[i]-71-key[j%count]+52)%52;
            }else{
                printf("error\n");
            }
            //printf("%d\n",station0[i]);
            if(station0[i]<26){
                station[i] = station0[i]+65;
            }else{
                station[i] = station0[i]+71;
            }
            j++;
            i++;
        }
        printf("%s\n",station);
    }
    
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] x = sc.IntArray();

        int[] ans = new int[n * n];
        for (int i = 0; i < n; i++)
        {
            ans[x[i] - 1] = i + 1;
        }

        var q = new Queue<int>();
        for (int i = 0; i < n * n; i++)
        {
            if (ans[i] == 0)
            {
                q.Enqueue(i);
            }
            else
            {
                if (q.Count < ans[i] - 1)
                {
                    Console.WriteLine("No");
                    return;
                }

                for (int j = 0; j < ans[i] - 1; j++)
                {
                    ans[q.Dequeue()] = ans[i];
                }
            }
        }

        bool[] f = new bool[n+1];
        q = new Queue<int>();
        for (int i = n * n - 1; i >= 0; i--)
        {
            if (ans[i] == 0)
            {
                q.Enqueue(i);
            }
            else
            {
                if(f[ans[i]]) continue;
                if (q.Count < n - ans[i])
                {
                    Console.WriteLine("No");
                    return;
                }

                for (int j = 0; j < n - ans[i]; j++)
                {
                    ans[q.Dequeue()] = ans[i];
                }

                f[ans[i]] = true;
            }
        }

        Console.WriteLine("Yes");
        Console.WriteLine(string.Join(" ", ans));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 43628
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;

const long long TIME_LIMIT=10000;

ll scorecalc(vector<vector<ll>> a, vector<ll> los, ll d, vector<ll> an)
{
    ll ans = 0;
    
    vector<ll> last(los.size(), 0);
    for (int i = 0; i < an.size(); i++)
    {
        ll loss = 0;
        for (int j = 0; j < 26; j++)
        {
            if (j == an[i] - 1)
                continue;

            loss += los[j] * (d - last[j]);
        }
        ans += a[i][an[i] - 1] - loss;
        last[an[i] - 1] = i + 1;
    }

    return ans;
}

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

    ll d;
    cin >> d;
    vector<ll> c(26);
    rep(i, 26)
    {
        cin >> c[i];
    }
    vector<vector<ll>> s(d, vector<ll>(26));
    rep(i, d)
    {
        rep(j, 26)
            cin >> s[i][j];
    }

    vector<ll> ans(d);

    vector<ll> last(26, 0);

    for (ll i = 0; i < d; i++)
    {
        ll lost = 0;
        for (int j = 0;j < 26; j++)
        {
            lost += c[j] * (i + 1 - last[j]);
        }
        ll man = s[i][0]-lost+c[0]*(i+1-last[0]);
        ll manu = 1;
        for (int j = 0; j < 26; j++)
        {
            if (man <= s[i][j]-lost+c[j]*(i+1-last[j]))
            {
                man = s[i][j] - lost + c[j] * (i + 1 - last[j]);
                manu = j + 1LL;
                last[j] = i + 1;
            }
        }
        ans[i] = manu;
    }
    ll score = scorecalc(s, c, d, ans);
    ll times = 0;
    while (times < 10000)
    {
        ll tmpD = (ll)rand() % d;
        ll tmpN = ans[tmpD];
        ans[tmpD] = (ll)rand() % 26 + 1;

        if (score >= scorecalc(s, c, d, ans))
            ans[tmpD] = tmpN;
        else
            score = scorecalc(s, c, d, ans);

        times++;
    }

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

	return 0;

}

Measured memory_bytes: 3868
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=4005;
const long long mod=998244353;
int c[nmax][nmax],sum[nmax][nmax],dp[nmax][nmax];
long long ans;
int k,n,i,j,suma,x;
long long comb(int a,int b)
{
    if(a==-1&&b==-1) return 1;
    if(a<0||b<0) return 0;
    return c[a][b];
}
int main()
{
    //freopen("data.in","r",stdin);
    cin>>k>>n;
    sum[0][0]=1;dp[0][0]=1;
    for(j=1;j<=n;j++)
        sum[0][j]=1;
    for(i=1;i<=k;i++)
    {
        dp[i][0]=sum[i][0]=1;
        for(j=1;j<=n;j++)
        {
            dp[i][j]=(dp[i-1][j]+1LL*sum[i-1][j-1]*2)%mod;
            sum[i][j]=(sum[i][j-1]+dp[i][j])%mod;
        }
    }
    c[0][0]=1;
    for(i=1;i<=n+k;i++)
    {
        c[i][0]=1;
        for(j=1;j<=n+k;j++)
            c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
    }
    for(suma=2;suma<=2*k;suma++)
    {
        x=0;ans=0;
        for(i=1;i<=k;i++)
          if(suma-i>0&&suma-i<=k)
            x++;
        //i-cate zaruri luam in perechi cu complement
        if(suma%2)
        {
            for(i=0;i<=n;i++)
             ans=(ans+1LL*dp[x/2][i]*comb(k-x+n-i-1,k-x-1))%mod;
        }
        else
        {
             for(i=0;i<=n;i++)
           {
             ans=(ans+1LL*dp[x/2][i]*comb(k-x+n-i-1,k-x-1))%mod;//nu luam suma/2
             ans=(ans+1LL*dp[x/2][i]*comb(k-x+n-i-2,k-x-1))%mod;//luam suma/2
           }
        }
        //k-x valori,n-i zaruri ramase
        cout<<ans<<'\n';
    }
    return 0;
}

Measured memory_bytes: 128256
#include <iostream>
#include <cstring>

using namespace std;

string s;

int main()
{
    cin >> s;
    if (s[s.length() - 1] != 's')
    {
	cout << s << "s" << endl;
    }
    else
    {
	cout << s << "es" << endl;
    }
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    set<string> st;
    int N;
    cin >> N;
    rep(i, N) {
        string S;
        cin >> S;
        st.insert(S);
    }

    cout << (int)st.size() << endl;
    return 0;
}

Measured memory_bytes: 19160
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







int main(void) {

    ll g = 100;
    int ans = 0;
    ll X; cin >> X;
    while (X > g) {
        g = g + g / 100;
        ++ans;
    }
    out(ans);
    

    return 0;
}











Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int money;
	int change;
	int coin;
	
	while (scanf("%d", &money) != EOF){
		coin = 0;
		if (money == 0){
			break;
		}
		else{
			change = 1000 - money;
			if (change / 500 != 0){
				coin += change / 500;
				change %= 500;
			}	
			if (change / 100 != 0){
				coin += change / 100;
				change %= 100;
			}
			if (change / 50 != 0){
				coin += change / 50;
				change %= 50;
			}
			if (change / 10 != 0){
				coin += change / 10;
				change %= 10;
			}
			if (change / 5 != 0){
				coin += change / 5;
				change %= 5;
			}
			if (change != 0){
				coin += change;
			}
			printf("%d\n", coin);
		}
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

map<int,int> hist;
int n;
vector<int> vs;
vector<int> cs;

bool isOK(int k, int h) {
  int idx = lower_bound(vs.begin(), vs.end(), h) - vs.begin();
  ll total = cs[idx] + ll(vs.size()-idx) * h;
  // cerr << "> " << k << " " << h << " " << idx << " " << total << " " << ll(k) * h << endl;
  return total >= ll(k) * h;
}

int main(void) {
  scanf("%d", &n);
  REP(i, n) {
    int v;
    scanf("%d", &v);
    hist[v]++;
  }
  for(auto it : hist) {
    vs.push_back(it.second);
  }
  sort(vs.begin(), vs.end());
  cs.push_back(0);
  for(int v : vs) {
    int last = cs.back();
    cs.push_back(last + v);
    // cerr << ">>" << v << " " << cs.back() << endl;
  }
  for(int k = 1; k <= n; ++k) {
    int left = 0;
    int right = n+1;
    while(left + 1 < right) {
      int mid = (left + right) / 2;
      if(isOK(k, mid)) {
        left = mid;
      } else {
        right = mid;
      }
    }
    printf("%d\n", left);
  }
  
  return 0;
}


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

#define int long long
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

//Length of longest directed path in a graph

vi dp;
vector<vi> adj;
vi topo,topo2;
vector<bool> visited;

void dfs(int root) {
    visited[root] = true;
    for (auto u: adj[root]) {
        if (!visited[u]) dfs(u);
    }
    topo.push_back(root);
}


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

    int n,m,a,b;
    cin >> n >> m;
    adj.assign(n,vector<int>());
    rep(i,m) {
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
    }

    visited.assign(n,false);
    rep(i,n) {
        if (visited[i]) continue;
        dfs(i);
    }

    rep(i,n) topo2.push_back(topo[n-1-i]);
    rep(i,n) topo[topo2[i]] = i;
    dp.assign(n,0);
    rep(i,n) {
        for (auto u: adj[topo2[i]]) {
            dp[topo[u]] = max(dp[topo[u]], dp[i] + 1);
        }
    }

    //topo[i] has the position of node i in the topo2 vector (0-based)
    //topo2[i] is the topological sort of nodes (0-based)
    //dp[i] is the longest path ending in node i (0-based)

    int mx = -1;
    rep(i,n) if (dp[i] > mx) mx = dp[i];

    cout << mx << '\n';

    return 0;
    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}

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

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

  for (int i = 0; i < n.size(); i++) {
    if (n.at(i) == '1') {
      n.at(i) = '9';
    } else if (n.at(i) == '9') {
      n.at(i) = '1';
    }
  }

  printf("%d", stoi(n));
  return 0;
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<int> a, b;
    a.push_back(0);
    for(int i = 1; i < n; ++i){
        if(s[i-1] == '0' && s[i] == '1'){
            a.push_back(i);
        }
    }
    if(s[n-1] == '0')a.push_back(n);

    b.push_back(0);
    for(int i = n-2; i >= 0; --i){
        if(s[i+1] == '0' && s[i] == '1'){
            b.push_back(n - i - 1);
        }
    }
    if(s[0] == '0') b.push_back(n);

    if(a.size() <= k) cout << n << "\n";
    else {
        int ans = 0;
        for(int i = 0; i <= a.size() - k - 1; ++i){
            ans = max(ans, n - a[i] - b[b.size() - 1 - k - i]);
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 972
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

template<class T>
struct BinaryIndexedTree
{
  vector< T > data;

  BinaryIndexedTree(int sz)
  {
    data.assign(++sz, 0);
  }

  T sum(int k)
  {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x)
  {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

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

    llint N, K;
    cin >> N >> K;
    vector<llint> a(N+1), b(N+1);
    llint sum = 0;
    a[0] = 0; b[0] = 0;
    FOR(i, 1, N+1){
        int x;
        cin >> x;
        sum += x;
        a[i] = sum - i*K;
        b[i] = a[i];
    }
    sort(All(b));
    b.erase(unique(All(b)), b.end());
    map<llint, int> c;
    REP(i, b.size()){
        c[b[i]] = i;
    }
    BinaryIndexedTree<int> BIT(N+1);
    llint ans = 0;
    REP(i, N+1){
        //cout << a[i] << "\n";
        ans += BIT.sum(c[a[i]]);
        BIT.add(c[a[i]], 1);
    }
    cout << ans << "\n";

    return 0;
}


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

int main() {
  long N, X, A = 0, B, ans = 0;
  cin >> N >> X;
  while (cin >> B) {
    if (A + B > X) ans += A + B - X, B -= A + B - X;
    A = B;
  }
  cout << ans << "\n"; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int a, b;
  cin >> a >> b;

  if(a == 1) a = 100;
  if(b == 1) b = 100;

  if(a == b) cout << "Draw";
  else if(a > b) cout << "Alice";
  else cout << "Bob";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long n,a,b;
	cin >>n>>a>>b;
	if((b-a)%2==0)cout<<(b-a)/2;
	else{
	long ans = 0;
		if(a-1>n-b){
			a += n-b;
			ans += n-b;
			b+=n-b;
			ans++;
			a++;
			ans += (n-a)/2;
		}else{
			b-=a-1;
			ans+=a-1;
			a=1;
			b--;
			ans++;
			ans+=(b-1)/2;
		}
		cout <<ans;
	}
}

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

int n;
long long ans;
string s;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
 	cin >> s;
 	n = s.size() - 1;

 	for (int i = 0; i < (1 << n); i++) {
 		long long m = 1;
 		for (int j = s.size()-1; j >= 0; j--) {
 			int shift = s.size() - j - 1;
 			ans += (s[j] - '0') * m;
 			if (i & (1 << shift)) {
 				m = 1;
 			}
 			else {
 				m *= 10;
 			}
 		}
 	}

 	cout << ans << '\n';

	return 0;
}

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

void print(vector<int> vec) {
	cout << vec[0];
	for(int i = 1; i < vec.size(); ++i) {
		cout << " " << vec[i];
	}
	cout << endl;
}

void SelectionSort(vector<int>& vec, int& count) {
	int n = vec.size();
	for (int i = 0; i < n; ++i) {
		int min = i;
		for (int j = i + 1; j < n; ++j) {
			if (vec[j] < vec[min])
				min = j;
		}
		if (i != min) {
			++count;
			swap(vec[i], vec[min]);
		}
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> vec;
	for (int i = 0; i < n; ++i) {
		int tmp;
		cin >> tmp;
		vec.push_back(tmp);
	}
	int count = 0;
	SelectionSort(vec, count);
	print(vec);
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int n,m;
int f[26][5000001];
char a[5000001];
int lowbit(int x)
{
	return x&(-x);
}
void build()
{
	for(int i=0;i<26;i++)
	for(int j=1;j<=n;j++)
	if(lowbit(j)<=n)
	f[i][j+lowbit(j)]+=f[i][j];
}
void change(int x,int y,int z)
{
	while(x<=n)
	{
		f[y][x]+=z;
		x+=lowbit(x);
	}
}
int find(int x,int y)
{
	int tot=0;
	while(y)
	{
		tot+=f[x][y];
		y-=lowbit(y);
	}
	return tot;
}
int ask(int l,int r)
{
	int ans=0;
	for(int i=0;i<26;i++)
	if(find(i,r)-find(i,l-1)>0)
	ans++;
	return ans;
}
void A()
{
	int x;
	char y;
	scanf("%d",&x);
	y=getchar();
	while(y>'z'||y<'a')
	y=getchar();
	if(a[x]!=y)
	{
		change(x,a[x]-'a',-1);
		a[x]=y;
		change(x,a[x]-'a',1);
	}
}
void B()
{
	int l,r;
	scanf("%d%d",&l,&r);
	printf("%d\n",ask(l,r));
}
signed main()
{
	int x;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		a[i]=getchar();
		while(a[i]>'z'||a[i]<'a')
		a[i]=getchar();
		f[a[i]-'a'][i]=1;
	}
	build();
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&x);
		if(x==1)
		A();
		else
		B();
	}
	return 0;
}

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

#define LL long long int 
#define ii pair<int, int>
#define x first
#define y second
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<ii>
#define mp make_pair
#define pb push_back
#define INF int(1e9)
#define MOD 1000000007
#define TAM int(2e5)

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);

    int k, n;

    cin >> k >> n;

    vi arr(n);

    LL sum = 0;
    for(int i=0; i<n; i++) cin >> arr[i], sum+=arr[i];

    cout << (k-sum>=0 ? k-sum : -1) << endl;

    return 0;
}

Measured memory_bytes: 3708
unittest
{
	assert( [ "4" ].parse.expand.solve == 48 );
	assert( [ "15" ].parse.expand.solve == 675 );
	assert( [ "80" ].parse.expand.solve == 19200 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto r = input.front.to!( long );
	return tuple( r );
}

auto solve( long r )
{
	return 3 * r * r;
}


Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        v_a: [i32; n],
    }
    let mut mx: i32 = v_a[0];
    let mut sum: i64 = 0;
    for a in v_a {
        if a < mx {
            sum += (mx - a) as i64;
        } else {
            mx = a;
        }
    }
    println!("{}", sum);
}


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

int n, k;
bool v[15];

bool f(int p) {
	for (; p; p /= 10) if (v[p % 10]) return 0;
	return 1;
}

int main()
{
	int t;
	cin >> n >> k;
	while (k--) scanf("%d", &t), v[t] = 1;
	for (; ; n++) if (f(n)) return !printf("%d", n);
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    int X,A,B;
    cin >> X >> A >> B;
    cout << (X-A)%B << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i = 0; i < n; i++)
const int INF = 1e9;
const int N = 2e5+7;
const int MOD = 1e9+7;

int a[N];
int cnt2,cnt4;

int main(){

  int n; cin >> n;

  REP(i,n){
    cin >> a[i];
    if(a[i]%2 == 0){
      cnt2++;
      if(a[i]%4 == 0) cnt4++;
    }
  }

  int need = n/2;
  int sum = cnt4 + (cnt2 - cnt4)/2;

  cout << ((need <= sum)?"Yes":"No") << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
        int a,b,n,x;
        cin>>a>>b;
        if((a+b)%2==0)
        cout<<(a+b)/2<<endl;
        else
            cout<<(a+b)/2+1<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,n;
  cin>>x>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  int ans;
  int a=0;
  for(int i=0;i<n;i++){
    if(p[i]==x){
      a++;
    }
  }
  if(a==0){
    ans=x;
  }
  int s=x;
  int t=x;
  //sはまいなす　tはプラス
  if(a!=0){
    for(int i=0;i<100;i++){
      s--;
      t++;
      int u=0;
      int v=0;
      for(int i=0;i<n;i++){
        if(s==p[i]){
          u++;
        }
        if(t==p[i]){
          v++;
        }
      }
      if(u==0){
        ans=s;
        break;
      }
      else{
        if(v==0){
          ans=t;
          break;
        }
      }
    }
  }
  cout<<ans<<endl;
      
}

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 100500;

int n, k, a[N];
ll ans, p[N], pref[N], suf[N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n >> k;

	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		p[i] = p[i - 1] + a[i];
	}

	for (int i = 1; i <= n; i++)
		pref[i] = pref[i - 1] + max(0, a[i]);
	for (int i = n; i >= 1; i--)
		suf[i] = suf[i + 1] + max(0, a[i]);

	for (int i = k; i <= n; i++)
		ans = max(ans, max(0ll, p[i] - p[i - k]) + pref[i - k] + suf[i + 1]);

	cout << ans;

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 3072
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include<iomanip>
#include<queue>
#include <cstdint>


using namespace std;


int main() {
	int x;
	cin>>x;
	if(x==3||x==5||x==7){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

	return 0;

}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();

		int ans = 0;
		for (int i = 0; i < n; i++) {
			Set<Character> set1 = new HashSet<>();
			for (int j = 0; j < i; j++) {
				set1.add(s.charAt(j));
			}
			Set<Character> set2 = new HashSet<>();
			for (int j = i; j < n; j++) {
				set2.add(s.charAt(j));
			}
			int cnt = 0;
			for (Character c : set1) {
				if (set2.contains(c)) {
					cnt++;
				}
			}
			ans = Math.max(ans, cnt);
		}
		System.out.println(ans);
	}
}


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

int main(){
    int N, Q;
    string s;
    cin >> N >> Q;;
    cin >> s;

    int l[Q+1], r[Q+1];
    int AC[N+1];
    int ans[Q];

    for(int i = 0; i < Q; i++) {
	cin >> l[i] >> r[i];
	ans[i] = 0;
    }
    AC[0] = 0;
    for(int i = 0; i < N; i++) {	
    	if(s[i] == 'A'  && s[i+1] == 'C')
    	    AC[i+1] = AC[i] + 1;
	else
	    AC[i+1] = AC[i];
    }
    

    for(int i = 0; i<Q; i++) {
    	ans[i] = AC[r[i]-1] - AC[l[i]-1];
    }
    
    for(int i = 0; i<Q; i++)
    	cout << ans[i] << "\n";
	      
}


Measured memory_bytes: 2560
#include   <bits/stdc++.h>
using      namespace        std;
#define    int              long long int
#define    sz(a)            (int)(a).size()
#define    w(x)              int T; cin>>T; while(T -- > 0)
#define    debug             cout<<"~~~~\n";

void SolveTestCase() {

	// Code goes here

	int n;
	cin >> n;

	vector<int>v(n);
	bool flag = false;
	for (int &i : v) {
		cin >> i;
		if (i == 0)
			flag = true;
	}

	if (flag) {
		cout << 0 << endl;
		return ;
	}

	int res = 1;

	for (int i = 0; i < n; i++) {
		if (res > (1000000000000000000 / v[i]))
		{
			cout << -1 << endl;
			return;
		}
		res = res * v[i];
	}

	cout << res << endl;
}

int32_t main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	SolveTestCase();

	return 0;

}

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

using namespace std;

int main(){
   int N, M, X, Y;
   bool ans = false;
   cin >> N >> M >> X >> Y;
   vector<int> x(N+1);
   vector<int> y(M+1);
    x.at(0) = X;
    y.at(0) = Y;

   for(int i=0;i<N;i++){
       cin >> x.at(i+1);
   }
   for(int i=0;i<M;i++){
       cin >> y.at(i+1);
   }

       int A = *max_element(x.begin(),x.end());
       int B = *min_element(y.begin(),y.end());
       if(A>=B){
           ans = true;
       }

   cout << (ans==false ? "No War" : "War") << endl;
}

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

using namespace std;

#define ll long long
#define debug(n) cerr << #n << ':' << n << endl;

int main(){
  string s;cin >> s;
  const int sz = s.size();

  ll ans = 1;
  ll  idx = 1;
  for(int i = sz - 1; i >= 0; --i){
    if(s[i] == '1')ans = idx + 2 * ans;
    idx *= 3;
    ans %= (7 + (ll)(1.0e+9));
    idx %= (7 + (ll)(1.0e+9));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
n=int(input())
S=input()
D={}
for i in range(len(S)):
    s=S[i]
    if s in D:D[s]+=1
    else:D[s]=1
for _ in range(n-1):
    S=input()
    E={}
    DD={}
    for i in range(len(S)):
        s=S[i]
        if s in E:E[s]+=1
        else:E[s]=1
    for i in D:
        if i in E:DD[i]=min(E[i],D[i])
    D=DD
ans=[]
for j in D:
    for _ in range(D[j]):
        ans.append(j)
ans.sort()
print("".join(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  
  cin >> N >> A >> B;
  
  if(A * N < B)		cout << A*N << endl;
  if(A * N == B)	cout << B << endl;
  if(A * N > B)		cout << B << endl;
  
}

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


int main() {
  long long int  N, A, B;
  string S;
  //vector<vector<long long int>> a_b_v(1000000, vector<long long int>(10000000));
  //vector<vector<long long int>> hit_v;
  cin >> N >> A >> B;

  if (N*A < B) printf("%d\n", N*A);
  else {printf("%d\n", B);}
  
  //cout << c_cnt << " " << d_cnt << " " << cd_cnt << " " << endl;

  // k - C - D + CD
  // k = 0;
  // long long int tmp = A / C;
  // k = (tmp-1)*C;
  // while (1) {
  //   k += C;
  //   if (k > B) break;
  //   if (A <= k) c_cnt++;
  // }
  // k = 0;
  // long long int tmp = A / D;
  // k = (tmp-1)*D;
  // while (1) {
  //   k += D;
  //   if (k > B) break;
  //   if (A <= k) d_cnt++;
  // }
  // k = 0;
  // long long int a = lcm(C, D);
  // long long int tmp = A / a;
  // k = (tmp-1)*a;
  // //cout << a << endl;
  // while (1) {
  //   k += a;
  //   if (k > B) break;
  //   if (A <= k) cd_cnt++;
  // }
  //cout << c_cnt << " " << d_cnt << " " << cd_cnt << " " << endl;
  // for (int i = 0; i < Q; i++) {
  //   long long int l, r;
  //   cin >> l >> r;
  //   l_v.push_back(l);
  //   r_v.push_back(r);
  // }

  // for (int i = 0; i < S.size()-1; i++) {
  //   if (S[i] == 'A' && S[i+1] == 'C') {
  //     cnt++;
  //     hit_v.push_back({i, i+1});
  //   }
  // }
  // for (int i = 0; i < Q; i++) {
  //   cnt = 0;
  //   for (int j = 0; j < hit_v.size(); j++) {
  //     if (l_v[i]-1 <= hit_v[j][0] && hit_v[j][1] <= r_v[i]-1) {
  //       cnt ++;
  //     }
  //     else if (hit_v[j][1] > r_v[i]-1) {
  //       break;
  //     }
  //   }
  //   cout << cnt << endl;
  // } 
  
  // char S[1000000] = {0};
  // vector<int> s_v, s_01v, s_10v;
  // cin >> S;
  // //cout << strlen(S) << endl;
  // for (int i = 0; i < strlen(S); i++) {
  //   s_v.push_back(S[i] - '0');
  //   switch(i%2) {
  //   case 0:
  //     s_01v.push_back(0);
  //     s_10v.push_back(1);
  //     break;
  //   case 1:
  //     s_01v.push_back(1);
  //     s_10v.push_back(0);
  //     break;
  //   }
  // }
  // long long int cnt_01 = 0, cnt_10 = 0;

  // for (int i = 0; i < strlen(S); i++) {
  //   if (s_01v[i] != s_v[i]) cnt_01++;
  //   if (s_10v[i] != s_v[i]) cnt_10++;
  // }
  // if (cnt_01 > cnt_10) {
  //   cout << cnt_10 << endl;
  // }
  // else {
  //   cout << cnt_01 << endl;
  // }
  // for (int i = 0; i < strlen(S); i++) {
  //   printf("%d ", s_v[i]);
  // }
  return 0;
}


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

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





int main(){
  int A1, A2, A3, N;
  int bingo[3][3];
  bool check[3][3];
  bool flag = false;
  rep(i, 0, 3){
    cin >> A1 >> A2 >> A3;
    bingo[i][0] = A1;
    bingo[i][1] = A2;
    bingo[i][2] = A3;
    check[i][0] = false;
    check[i][1] = false;
    check[i][2] = false;
  }

  cin >> N;
  rep(k, 0, N){
    int b;
    cin >> b;
    rep(i, 0, 3){
      rep(j, 0, 3){
        if(b == bingo[i][j]){
          check[i][j] = true;
        }
      }
    }
  }

  rep(i, 0, 3){
    if(check[i][0] && check[i][1] && check[i][2]){
      flag = true;
    }
    if(check[0][i] && check[1][i] && check[2][i]){
      flag = true;
    }
  }
  if(check[0][0] && check[1][1] && check[2][2]){
      flag = true;
  }
  if(check[0][2] && check[1][1] && check[2][0]){
    flag = true;
  }

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


}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
   
	double a,b,c,d,e,f;
    double x,y;
    
    while (scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) == 6) {
        x = (c * e - b * f) / (a * e - b * d);
        if(x == -0.0){
            x = 0;
        }
        if (y == -0.0) {
            y = 0;
        }
        y = (c * d - a * f) / (b * d - a * e);
        printf("%.3f %.3f\n", x, y);
        
    }
	return 0;
}

Measured memory_bytes: 0
//正直者は確定
//不親切は、正直か嘘かも不明
//Nたったの15人なので、15人が正直、嘘、で仮定する
//2^15の処理くらいなら間に合う
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<vector<int>> say(N+1,vector<int>(N+1,-1));
  //証言の保存。-1は審議不明。0は嘘、1は正直 
  for(int i=1; i<=N; i++){
    int A; cin>>A;
    for(int j=0; j<A; j++){//A個の証言をする
      int x,y; cin>>x>>y;
      say[i][x]=y;//iさんが、xさんのことをyと言う
    }
  }
  int ans=0;
  for(int i=1; i<(1<<N); i++){ //(1<<4)=10000=2^4=16未満まで探索
    vector<bool> check(N+1,false);//正直者の配列を用意。
    for(int k=0; k<N; k++)
      if(1&(i>>k)) check[k+1]=true;//演算子、ビット%。1と等しいかどうか。等しければtrue。
    bool finish=false;
    for(int m=1; m<=N; m++){
      for(int n=1; n<=N; n++){//正直者の発言が正しいかどうか探索。嘘ならその時点でbreak
        if(check[m]){
          if((say[m][n]==0 && check[n]==1)//正直と仮定したmがnを嘘というが、nが正直なとき
           ||(say[m][n]==1 && check[n]==0)){//正直と仮定したmがnを正直というが、nが嘘なとき
              finish=true;
              break;
            }
         }
      }
      if(m==N && finish==false){
        int temp=__builtin_popcount(i);
        ans=max(ans, temp);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
using ll = long long;
const ll M = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> is;
ll power(ll x,ll y){
    if(y==0)
    return 1;
    ll res=power(x,y/2);
    res=(res*res)%M;
    if(y&(ll)1)
    res=(res*x)%M;
    return res;
}


/*int n,ma=0;
vector<vector<int>> gr;
vector<int> color;
void dfs(int c,int p)
{
    vector<int> v;
    int j;
    for(j=1;j<gr[c].size()+2;j++)
    {
        if(j==color[c]||j==color[p])
        continue;
        //cout<<j<<" ";
        v.pb(j);
    }
    //cout<<endl;
    j=0;
    for(int i=0;i<gr[c].size();i++)
    {
        if(gr[c][i]!=p)
        {
            color[gr[c][i]]=v[j];j++;
            dfs(gr[c][i],c);
        }
    }
}*/
void solve(){
    string s;
    cin>>s;
    int n=s.size();
    if(n&1)
    {
        cout<<"No"<<endl;
        return;
    }
    for(int i=0;i<n;i+=2)
    {
        if(s[i]!='h'||s[i+1]!='i')
        {
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	int n = 4;
	string s; cin >> s;
	vi v(n); rep(i,n) v[i] = s[i]-'0';
	bool yymm=true,mmyy=true;
	int a = v[0]*10+v[1];
	int b = v[2]*10+v[3];
	if( a>12 ) mmyy = false;
	if( b>12 ) yymm = false;
	if( a==0 ) mmyy = false;
	if( b==0 ) yymm = false;

	if(yymm&&mmyy) cout << "AMBIGUOUS" << endl;
	else if(yymm) cout << "YYMM" << endl;
	else if(mmyy) cout << "MMYY" << endl;
	else cout << "NA" << endl;

}




Measured memory_bytes: 256
#include<stdio.h>

static int N=100;

int main(){
  int h,i,j,k,l;
  int r[N+1],c[N+1],m[N+1][N+1];
  int matrix;

  scanf("%d",&h);

  for(i=1;i<=h;i++){
    scanf("%d%d",&r[i],&c[i]);
  }

  for(i=1;i<=h;i++)m[i][i]=0;

  for(l=2;l<=h;l++){
    for(i=1;i<=h-l+1;i++){
      j=i+l-1;
      m[i][j]=10000000;
      for(k=i;k<=j-1;k++){
	matrix=m[i][k]+m[k+1][j]+r[i]*c[k]*c[j];
	if(m[i][j]>matrix)m[i][j]=matrix;
      }
    }
  }
  printf("%d\n",m[1][h]);

  return 0;
}



Measured memory_bytes: 2112
#include<stdio.h>

int main(){
  int n, x, sum, i, j, k;

  while(1){
    scanf("%d%d",&n,&x);
    if(n==0 && x==0) break;

    sum=0;
    for(i=1;i<n-1;i++){
      for(j=i+1;j<n;j++){
	for(k=j+1;k<=n;k++){
	  if(i+j+k==x) sum++;
	}
      }
    }
    printf("%d\n",sum);
  }
  
  return 0;
}



Measured memory_bytes: 2076