akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
using namespace std;
using ll = long long;

const int maxn = 2e5 + 5;
const ll inf = 1e17 + 7;

int n, a[maxn];
ll sm[maxn];

ll getsm(int l, int r) {
	if (!l) return sm[r];
	return sm[r] - sm[l - 1];
}

ll calcmn(int l, int r) {
	int lb = l, rb = r;
	while (lb + 1 < rb) {
		int md = lb + (rb - lb) / 2;
		if (getsm(l, md) <= getsm(md + 1, r))
			lb = md;
		else
			rb = md;
	}
	ll ans = getsm(l, lb);
	if (lb + 2 <= r && getsm(l, lb + 1) - getsm(lb + 2, r) < getsm(lb + 1, r) - getsm(l, lb))
		ans = getsm(lb + 2, r);
	return ans;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i ++) {
		scanf("%d", a + i);
		if (i) sm[i] = sm[i - 1];
		sm[i] += a[i];
	}
	ll ans = inf;
	for (int i = 0; i + 1 < n; i ++) {
		ll x = calcmn(0, i), y = calcmn(i + 1, n - 1);
		ll xx = getsm(0, i) - x, yy = getsm(i + 1, n - 1) - y;
		ll b[4] = {
			x, y, xx, yy
		};
		sort(b, b + 4);
		if (b[3] - b[0] < ans)
			ans = b[3] - b[0];
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	ll x, k, d; cin >> x >> k >> d;

	x = abs(x);
	ll div = x / d;
	ll mod = x % d;

	ll res = 0;
	if (x == d) {
		if (k % 2)
			res = 0;
		else
			res = d;
	}
	else if (x < d) {
		if (k % 2)
			res = abs(x - d);
		else
			res = x;
	}
	else if (div > k)
		res = abs(x - d * k);
	else {
		if ((k - div) % 2)
			res = abs(x - d * (div + 1));
		else
			res = abs(x - d * div);
	}

	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int max(int x, int y){
    if (x>=y) return x;
    else return y;
}

int main()
{
    int x;
    scanf("%d", &x);
    int i, j;
    int ans = 1;
    for (i=1; i<x; i++)
    {
        for (j=2; j<=10; j++)
        {
            if (pow(i, j) <= x) ans = max(ans, pow(i, j));
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  int N;
  cin >> N;
  vector<pair<ll, ll> > task;
  for(int i=0; i<N; i++){
    ll a, b;
    cin >> a >> b;
    task.push_back(make_pair(b, a));
  }
  sort(task.begin(), task.end());

  ll ans = 0;
  for(int i=0; i<N; i++){
    ans += task[i].second;
    if(ans > task[i].first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 6384
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B) cout << C;
	else if (B == C) cout << A;
	else if (C == A) cout << B;
	cout << endl;
	return 0;
}

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

string s, t;

int dp[3100][3100];

int main(void){
	cin>>s>>t;

	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < t.size(); j++) {
			if (s[i] == t[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
		}
	}

	string res = "";
	int i = s.size(), j = t.size();
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j]) --i;

		else if (dp[i][j] == dp[i][j - 1]) --j;

		else {
			res = s[i - 1] + res;
			--i; --j;
		}
	}

	cout<< res <<endl;
	
	return 0;
}

Measured memory_bytes: 37120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int oo = 1e9;
const int MOD = 1000000007;
const int BASE = 26;
const int N = 200010;
#define x first
#define y second
#define pb push_back
#define mp make_pair

int n , p[1001] , x[1001], sum[1001];
vector<int> g[1001];
bool can = true;
int dp[1002][5011], vis[1002][5002], vsId;

int calc(int idx , int rem, vector<pii> &cur) {
	if (rem < 0)
		return oo;
	if (idx == cur.size())
		return rem;
	int &ret = dp[idx][rem];
	if (vis[idx][rem] == vsId)
		return ret;
	vis[idx][rem] = vsId;
	ret = min(calc(idx + 1, rem - cur[idx].x, cur), calc(idx + 1, rem - cur[idx].y, cur));
	return ret;
}
pii dfs(int u) {
	sum[u] = 0;
	vector<pii> cur;
	for (int i = 0; i < g[u].size(); ++i) {
		int v = g[u][i];
		pii f = dfs(v);
		cur.pb(f);
		sum[u] += f.x;
		sum[u] += f.y;
	}
	if (!g[u].size()) {
		sum[u] = x[u];
		return mp(x[u], 0);
	}
	vsId++;
	int add = calc(0, x[u], cur);
	if (add == oo) {
		puts("IMPOSSIBLE");
		exit(0);
	}
	sum[u] += add;
	return mp(x[u], sum[u] - x[u]);
}
int main() {
	scanf("%d", &n);
	for (int i = 2; i <= n; ++i) {
		scanf("%d", &p[i]);
		g[p[i]].pb(i);
	}
	for (int i = 1 ; i <= n ; ++i)
		scanf("%d", &x[i]);
	dfs(1);
	puts("POSSIBLE");
	return 0;
}


Measured memory_bytes: 37632
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define setpr(pp) fixed<<setprecision(pp)
#define FOR(I,N) for(I=0;I<N;++I)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod	%1000000007
#define pi 3.141592653
#define MX 1000000007

int main()
{
	string s;
	cin>>s;
	ll a = 0;
	ll i,n = s.size();
	FOR(i,n)
	{
		a += (s[i]-48);
	}
	if(a%9==0)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for(int i=0;i<n;i++)
        cin>>h[i];
    vector<int> dp(n, INT_MAX);
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        int m=INT_MAX;
        for(int j=1;j<=min(i,k);j++)
            m=min(m,dp[i-j]+abs(h[i]-h[i-j]));
        dp[i]=m; }
    cout<<dp[n-1]; }

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#define LEN 100005
typedef struct pp
{
	char name[100];
	int t;
}P;
P Q[LEN];
int head,tail,n;
void enqueue(P x)
{
	Q[tail]=x;
	tail=(tail+1)%LEN;
}
P dequeue()
{
	P x=Q[head];
	head=(head+1)%LEN;
	return x;
}
int min(int a,int b){return a<b?a:b;}
int main()
{
	int elaps=0,c;
	int i,q;
	P u;
	scanf("%d %d",&n,&q);
	for(i=1;i<=n;i++)
	{
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	head=1;tail=n+1;
	while(head!=tail)
	{
		u=dequeue();c=min(q,u.t);
		u.t-=c;
		elaps +=c;
		if(u.t>0)
		enqueue(u);
		else {
			printf("%s %d\n",u.name,elaps);
		}
	}
	return 0;
}

Measured memory_bytes: 12716
#include <stdio.h>
long long n, m, i, j, k, a, b;
int main(){
	scanf("%lld%lld%lld", &a, &b, &n);
	if(n >= b) n = b - 1;
	printf("%lld\n", a*n/b-a*(n/b));
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int h, w;
    while(cin >> w >> h, w|h){
        vector<vector<int>> tate(h, vector<int>(w+1, 1));
        vector<vector<int>> yoko(h+1, vector<int>(w, 1));
        for (int i = 0; i < 2*h-1; ++i) {
            if(i%2 == 0){
                for (int j = 0; j < w-1; ++j) {
                    int x;
                    scanf("%d", &x);
                    tate[i/2][j+1] = x;
                }
            }else {
                for (int j = 0; j < w; ++j) {
                    int x;
                    scanf("%d", &x);
                    yoko[(i+1)/2][j] = x;
                }
            }
        }
        vector<vector<int>> dis(h+2, vector<int>(w+2, INF<int>));
        dis[1][1] = 1;
        queue<pair<int, int>> S;
        S.emplace(0, 0);
        while(!S.empty()){
            int y, x; tie(y, x) = S.front(); S.pop();
            int d = dis[y+1][x+1];
            if(!tate[y][x]) {
                if(d+1 < dis[y+1][x] ){
                    S.emplace(y, x-1);
                    dis[y+1][x] = d+1;
                }
            }
            if(!tate[y][x+1]) {
                if(d+1 < dis[y+1][x+2] ){
                    S.emplace(y, x+1);
                    dis[y+1][x+2] = d+1;
                }
            }
            if(!yoko[y][x]) {
                if(d+1 < dis[y][x+1] ){
                    S.emplace(y-1, x);
                    dis[y][x+1] = d+1;
                }
            }
            if(!yoko[y+1][x]) {
                if(d+1 < dis[y+2][x+1] ){
                    S.emplace(y+1, x);
                    dis[y+2][x+1] = d+1;
                }
            }
        }
        cout << (dis[h][w] == INF<int> ? 0 : dis[h][w]) << "\n";
    }
    return 0;
}


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

int main(){
  char c;
  cin >> c;
  string ans = "consonant";
  vector<char> vc = {'a','e','i','o','u'};
  for(auto& x : vc){
    if(c==x)
      ans = "vowel";
  }
  cout << ans << endl;
}

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

int main(void) {
    i64 n, ans = 1145141919;
    string s;
    cin >> n >> s;
    vector<i64> b(n + 1, 0), w(n + 1, 0);
    for (i64 i = 0; i < n; i++) {
        b[i + 1] = b[i];
        w[i + 1] = w[i];
        if (s[i] == '#') b[i + 1]++;
        if (s[i] == '.') w[i + 1]++;
    }
    for (i64 i = 0; i <= n; i++) {
        //cout << b[i] - b[0] << ' ' << w[n] - w[i] << endl;
        ans = min(ans, b[i] - b[0] + w[n] - w[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3716
n = int(input())
a_nums = []
tmp = input().split()
for i in range(n):
    a_nums.append(int(tmp[i]))

a_nums.sort(reverse=True)

num_sum = 0
for i in range(n):
    if i%2 == 0:
        num_sum = num_sum+a_nums[i]
    else:
        pass


sum_up = 0
for i in range(n):
    sum_up = sum_up + a_nums[i]

print(num_sum - sum_up + num_sum)



Measured memory_bytes: 3060
#include<iostream>
#include<list>

int main(){

	
	std::string ans;

	int D,T,S;
	std::cin >> D>>T>>S;
	if(S*T<D){
		ans = "No";
	}else{
		ans = "Yes";
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#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>;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        int sum = 0;
        int num = i;
        while(1){
            sum+=num%10;
            num/=10;
            if(num==0 || sum > b) break;
           
        }
        if(sum >= a && sum <= b)ans+=i;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    while(1){
        int N;
        cin>>N;
        if(N==0)break;
        vector<int> s(N);
        double sum=0.0;
        rep(i,N){
            cin>>s[i];
            sum+=s[i];
        }
        double mean = sum/N;
        double ss=0;
        rep(i,N){
            ss+=pow(mean-s[i], 2);
        }
        cout<<fixed<<setprecision(10)<<pow(ss/N, 0.5)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3440
import sys

input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def func(N, mod):
    F = [1]
    for i in range(1, N + 1):
        F.append(F[-1] * i % mod)
    return F


def inv(a, mod):
    return pow(a, mod - 2, mod)


def C(F, a, b, mod):
    return F[a] * inv(F[b], mod) * inv(F[a - b], mod) % mod


def main():
    N = int(input())
    R = [tuple(read_values()) for _ in range(N)]
    B = [tuple(read_values()) for _ in range(N)]
    B.sort()
    res = 0
    paired = [False] * N
    for bx, by in B:
        t = -1
        for i, (rx, ry) in enumerate(R):
            if paired[i]:
                continue

            if rx < bx and ry < by:
                if t == -1 or R[t][1] < ry:
                    t = i

        if t != -1:
            res += 1
            paired[t] = True
    print(res)


if __name__ == "__main__":
    main()



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

int main(void){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;

#define MAX 505
P p[1005];

int n,k;
int main(){
  cin>>n>>k;
  int border;
  if(n%2==0) border=n/2;
  else border=n/2+1;
  for(int i=0; i<k; i++){
    int ans;
    int a,b;
    cin>>a>>b;
    if(b>border) b=n-b+1;
    if(b<=a&&a<=n-(b-1)) ans=b%3;
    else if(a<b) ans=a%3;
    else ans=(n-a+1)%3;
    
    if(ans==0) ans=3;
    cout<<ans<<en
  }
  RE
}


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <array>

using namespace std;
using ll = long long;

ll solve(ll a, ll b, ll a1, ll b1, ll ans){
  //cout<<a<<" "<<b <<" "<<a1 << " "<< b1<<" "<<ans<<endl;
  if(a >= b * 2) return ans;
  if(a<=0 || b<=0)return ans-1;
  else {
    if(ans%2==1){//殺す
      ll b2 = a-b1;//HP1を殺したあと余っている攻撃数
      if(b2>=0){
        //b1を殺しきった後さらに抹殺する
        //if(b2%2==0)return solve(b-b2/2, a, 0, a1, ans+1);
        return solve(b-b2/2-b1, a, b2%2, a1, ans+1);//余ったので一人b1に
      }
      else return solve(b-a, a, -b2, a1, ans+1);//b1が大量にいたのでとりあえずa人殺す
    }else {//殺さない世界
      ll b2 = b-b1;//HP2の人の数
      //HP2の人から攻撃していく
      if(b2-a>=0)return solve(b, a, b1+a, a1, ans+1);//誰も殺さずb1が増える
      else return solve(b-(a-b2), a, b -(a-b2), a1, ans+1);//b1殺す数最小
    }
  }
}


int main(){
  ll n,m;
  cin>>n>>m;
  //cout<<solve(n,m,0, 0, 0)<<" "<<solve(n,m,0, 0,1)-1<<endl;

  cout<<min(solve(n,m,0, 0, 0),solve(n,m,0, 0,1)-1)<<endl;//*/

  /*for(int i=1;i<1000;++i){
    for(int j=1;j<1000;++j){
      cout<<"n="<<i<<" ,m="<<j<<" "<<solve(i,j,0,0,0)<<" "<<solve(i,j,0,0,1)-1<<endl;

    }
  }//*/

}



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N; cin>>N;
	ll ans=0;
	rep(i,N){
		ll tmp; cin>>tmp;
		while(1){
			if(tmp%2==0){
				tmp/=2;
				ans++;
			}
			else break;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
int n;
int f[101][20];
int p[100][20];
bool b[20];
int ff(int k) {
	if (k == 10) {
		bool b00l = 0;
		for (int i = 0; i < 10; i++)if (b[i])b00l = 1;
		if (!b00l)return -10000000000;
		int ret = 0;
		for (int i = 1; i <= n; i++) {
			int cnt = 0;
			for (int j = 0; j < 10; j++)if (f[i][j] && b[j])cnt++;
			ret += p[i][cnt];
		}
		return ret;
	}
	int r1, r2;
	b[k] = 1; r1 = ff(k + 1);
	b[k] = 0; r2 = ff(k + 1);
	return max(r1, r2);
}
signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> f[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= 10; j++) {
			cin >> p[i][j];
		}
	}
	cout << ff(0) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

int i,n,pref[N];
string s;

void solve()
{
    cin>>n>>s;
    s='.'+s;
    int ans=INF;
    for(i=1;i<=n;i++)
    {
        pref[i]=(s[i]=='R');
        pref[i]+=pref[i-1];
    }
    for(i=0;i<=n;i++)
    {
        int a=i-pref[i],b=pref[n]-pref[i];
        ans=min(ans,max(a,b));
    }
    cout<<ans;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5288
import sys
import numpy as np
# 場合によってはnp.unipueを使うのもあり
# 例えば集計値の範囲が狭い場合
input=sys.stdin.buffer.readline
N = int(input())
A = np.array(input().split(), dtype = np.int32)

counter = np.bincount(A)
B = counter.copy()
B[1:] += counter[:-1]
B[:-1] += counter[1:]
answer = B.max()
print(answer)

Measured memory_bytes: 17688
#-*- coding:utf-8 -*-
import math
import sys

t,x,y = [],[],[]
N = int(input())

t.append(0)
x.append(0)
y.append(0)

for i in range(N):
	a, b, c = map(int, input().split())
	t.append(a)
	x.append(b)
	y.append(c)

for i in range(N):
	T = t[i+1]-t[i]
	Z = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
	if (T < Z) or ((T%2) != (Z%2)):
		print("No")
		sys.exit()
print("Yes")


Measured memory_bytes: 11772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main() {
    string s;
    cin >> s;
    string t;
    rep(i, 5) {
        t += "hi";
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

#define REP(a,b) for(int i =(a);i < (b);i++)
#define FOR(n) for(int i = 0; i<(n); i++)
#define COUT(c)  cout<<(c)<<endl


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

int main(){
    int n;cin>>n;
    vector<int> enem(n+1);
    vector<int> man(n);
    long long int num = 0;
    int amari=0;
    FOR(n+1){
        cin >> enem[i];
    }
    FOR(n){
        cin >> man[i];
    }

    FOR(n+1){
        if(enem[i]<=amari){
            num+=enem[i];
            amari=man[i];
        }else if (enem[i] > amari){
            int tmp_enem = enem[i] - amari;
            if (tmp_enem > man[i]){
                num += man[i] + amari;
                amari = 0;
            }else{
                num += enem[i];
                amari = man[i] - tmp_enem;
            }
        }
    }
    COUT(num);

    return 0;    
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <list>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, q, t, f;
  bool ans = false, b;
  char s[100010], c;
  scanf("%s", s);
  scanf("%lld", &q);
  list<char> li;
  for(i = 0; s[i]; ++i) li.push_back(s[i]);
  for(i = 0; i < q; ++i) {
    scanf("%lld", &t);
    if(t == 1) ans = !ans;
    else {
      scanf("%lld %c\n", &f, &c);
      if(f == 1) b = true;
      else b = false;
      if(b != ans) li.push_front(c);
      else li.push_back(c);
    }
  }
  if(ans) {
    auto it = li.end();
    it--;
    for(; it != li.begin(); --it) printf("%c", *it);
    printf("%c", *it);
  } else {
    auto it = li.begin();
    for(; it != li.end(); ++it) printf("%c", *it);
  }
  return 0;
}

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

string rev(string s, int a, int b)
{
    for (int i = 0; i < b - a && a + i < b - i; i++)
    {
        swap(s[a + i], s[b - i]);
    }
    return s;
}

int main()
{
    string s, t, r;
    cin >> s;
    int n, a, b;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> t;
        if (t == "replace")
        {
            cin >> a >> b >> r;
            for (int i = 0; i < r.size(); i++)
            {
                s[i + a] = r[i];
            }
        }
        if (t == "print")
        {
            cin >> a >> b;
            cout << s.substr(a, b - a + 1) << endl;
        }
        if (t == "reverse")
        {
            cin >> a >> b;
            s = rev(s, a, b);
        }
    }
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    map<string, int> mp;
    for (int i = 0; i < n; i++){
        cin >> s[i];
    }

    ll ans = 0;
    for (int i = 0; i < n; i++){
        string ss = s[i];
        sort(ss.begin(), ss.end());
        ans += mp[ss];
        mp[ss]++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int ans=0;
    while(1){
        int p=0;
        for(int i=0;i<n;i++){
            if(h[i]!=0){
                h[i]=h[i]-1;
                p=1;
            }else{
                if(p==1){
                    goto a;
                }
            }
        }
        a:
        if(p==0){
            break;
        }else{
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int lcm(int a,int b){return a*b/gcd(a, b);}

int main()
{
  int n, k, ans = 1000000000;
  vector<int> h(100000);

  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> h[i];
  sort(h.begin(), h.begin() + n);
  for (int i = 0; i < n - k + 1; i++)
    ans = min(ans, h[i + k - 1] - h[i]);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, x, n) for(int i = x; i < n; i++) 
#define pb push_back
#define int long long
#define hii cout << "hii" << endl
#define si size()
#define ff first 
#define ss second
#define all(s) s.begin(), s.end()

const int N = 1e5 + 5;

int val[N], cost[N];

int ans = -999999;

void f(int i, int n, int X, int Y)
{
    if(i == n)
    {
        ans = max(ans, X - Y);
        return;
    }
    
    f(i + 1, n, val[i] + X, cost[i] + Y);
    f(i + 1, n, X, Y);
}



int32_t main()
{
   
   int n;
   cin >> n;
   
   FOR(i, 0, n) cin >> val[i];
   FOR(i, 0, n) cin >> cost[i];
   
   f(0, n, 0, 0);
   
   cout << ans;
   
   
}

Measured memory_bytes: 384
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
//        int int3 = Integer.parseInt(scan.next());
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
//        String str1 = scan.next();
//        String str2 = scan.next();
//        String str3 = scan.next();
        int ans_int = 0;
        String ans = "";
//        double ans_dob = 0;
        if(int1>=int2){
            ans = "10";
        }else{
            ans = "0";
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 23764
#include <stdio.h>
int max(int x,int y){
    if(x>y) return x;
    else return y;
}
int main(void){
    int n,i,j,k;
    scanf("%d",&n);
    int a[n][3],dp[100001][3] = {0};
    for(i=0;i<n;i++){
        for(j=0;j<3;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<3;j++){
            for(k=0;k<3;k++){
                if(j==k) continue;
                dp[i+1][k] = max(dp[i+1][k],dp[i][j]+a[i][k]);
            }
        }
    }
    int ans = 0;
    for(i=0;i<3;i++){
            ans = max(ans,dp[n][i]);
    }
    printf("%d",ans);
}

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

int main() {
  int h, w, a, b;
  cin>>h>>w>>a>>b;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (j < a && i < b) {
        cout<<1;
      } else if (j >= a && i >= b) {
        cout<<1;
      } else {
        cout<<0;
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define Nmax 3005

using namespace std;

const long long INF=1e18l;
ifstream f("1.in");
ofstream g("1.out");


long long dp[Nmax][Nmax];

int main()
{
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int L=n-1; L >= 0; L--)
    {
        for (int R=L; R <= n-1; R++)
            if(L==R) dp[L][R]=a[L];
            else dp[L][R]=max(a[R]-dp[L][R-1], a[L]-dp[L+1][R]);

    }

    cout << dp[0][n-1];

    return 0;
}


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

typedef long long ll;


class Union_Find {
private:
    std::vector<int> par;
    std::vector<int> rank;

public:
    Union_Find(int n) { // ?????????: O(n)
	par = rank = std::vector<int>(n);
	for(int i=0; i<n; i++) {
	    par[i]  = i;
	    rank[0] = 0;
	}
    }

    int root(int x) { // ??¨??????????±???????: O(?±(n)) 
	if(par[x] == x) return x;
	return par[x] = root(par[x]); // ??????????????????????????????????????????
    }

    void unite(int x, int y) { // x,y????????????????????????: O(?±(n)) 
	x = root(x); y = root(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) { //x,y??????????????????????????????????????????: O(?±(n)) 
	return root(x) == root(y);
    }
};

struct Edge {
    ll s,t;
    ll w;
    bool operator < (const Edge& tgt) const {
	return w > tgt.w;
    }
};

ll Kruskal(priority_queue<Edge>& edges, const int V) {

    ll res = 0;
    
    Union_Find uf(V);
    while( !edges.empty() ) {
	Edge e = edges.top(); edges.pop();
	if( !uf.same(e.s, e.t) ) {
	    uf.unite(e.s, e.t);
	    res += e.w;
	}
    }
    return res;
}


int main () {

    ll V;
    cin >> V;

    priority_queue<Edge> edges;
    
    for(int i=0; i<V; i++) {
	for(int j=0; j<V; j++) {
	    ll d;
	    cin >> d;
	    if( d != -1 )
		edges.push( Edge{i,j,d} );
	}	
    }

    ll res = Kruskal(edges,V);
    cout << res << endl;    
    return 0;
}

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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  bool found = false;
  int i = 0;
  for (; i <= 50000; ++i)
    if (N == floor(i * 1.08)) {
      found = true;
      break;
    }
  if (!found)cout << ":(" << endl;
  else cout << i << endl;
}


Measured memory_bytes: 256
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let d: i64 = sc.read();
    let a: i64 = sc.read();
    let mut xh = vec![];
    for _ in 0..n {
        let x: i64 = sc.read();
        let h: i64 = sc.read();
        xh.push((x, h));
    }
    xh.sort();
    let mut sum = 0;
    let mut acc = vec![0; n + 1];
    let mut tail = 0;
    let mut ans = 0;
    for i in 0..n {
        sum += acc[i];
        let (x, h) = xh[i];
        while tail < n && xh[tail].0 <= x + 2 * d {
            tail += 1;
        }

        let remain = cmp::max(0, h - sum);
        let count = (remain + a - 1) / a;
        acc[tail] -= count * a;
        sum += count * a;
        ans += count;
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 11344
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <climits>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long ll;

bool compare(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main(void) {
  int N, M; cin >> N >> M;
  vector<int> A(N, 0);
  for (int i = 0; i < N; i++) { cin >> A[i]; }
  vector<pair<int,int>> BC;
  for (int i = 0; i < M; i++) {
    int bi, ci; cin >> bi >> ci;
    // BC.push_back(make_pair(bi, ci));
    BC.push_back(make_pair(ci, bi));
  }
  std::sort(A.begin(), A.end());
  std::sort(BC.begin(), BC.end(), greater<pair<int,int>>());
  // reverse(BC.begin(), BC.end());

  int now = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] < BC[now].first) {
      A[i] = BC[now].first;
      BC[now].second--;
      if (BC[now].second == 0) {
        now++;
      }
    } else {
      break;
    }
  }

  ll res = 0;
  for (int i = 0; i < N; i++) {
    res += A[i];
  }
  cout << res << endl;
}


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

#define int long long

const int N = 2e3 + 10, mod = 1e9 + 7;
int n, k, dp[N][N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	fill(dp[0], dp[0] + N, 1);
	for (int i = 1; i < N; i++)
		for (int j = 1; j < N; j++)
			dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 1]) % mod;
			
	cin >> n >> k;
	for (int i = 1; i <= k; i++)
		cout << (dp[i - 1][k - 1] * dp[i][n - k + 1]) % mod << '\n';
}

Measured memory_bytes: 31872
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL) x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL) x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
    }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x=y;
    y=y->parent;
  }
  return y;  
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  
  if(y->left != NIL){
    x = y->left;
  }
  else{
    x = y->right;
  }

  if(x != NIL){
    x->parent = y->parent;
  }

  if(y->parent == NIL){
    root = x;
  }
  else{
    if(y == y->parent->left){
      y->parent->left = x;
    }
    else{
      y->parent->right = x;
    }
  }

  if(y != z){
    z->key = y->key;
  }

  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
      }
    else{
      x = x-> right;
      }
    }
    z->parent = y;
    if(y == NIL){
    root = z;
    }
    else{
      if(z->key < y->key){
        y->left = z;
      }
      else{
        y->right = z;
      }
   }
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL) return;
  printf( " %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


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

using namespace std;

vector<int> MSP;

bool isMSPFactor(int a)
{
  for(int i = 0; i < MSP.size(); i++){
    if(a % MSP[i] == 0) return false;
  }
  return true;
}

int main()
{
  int x;
  while(cin >> x, x != 1){
    cout << x << ":";
    for(int i = 6; i <= 300000; i++){
      if(i % 7 != 1 && i % 7 != 6) continue;
      if(isMSPFactor(i) && x % i == 0){
	cout << " " << i;
	MSP.push_back(i);
      }
    }
    cout << endl;
    MSP.clear();
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int a;
  cin >> a;
  if(a >= 30){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n, k;
    cin >> n >> k;
    int ans;
    if(n%k == 0) {
        ans = 0;
    }
    else {
        ans = 1;
    }

    cout << ans;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int a;
  cin>>a;
  V<int> b(a);
  fo(i,a)
  cin>>b[i];
  int c=0,d=b[0];
  fo(i,a){
    if(b[i]>=d){
      c++;
      d=b[i];
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int n;
int main(){

  scanf("%d",&n);
  int arra[n],arrw[n],i , minwr =1001,minwl =1001;

  
  for( i=0;i< n;i++){
    scanf("%d",&arra[i]);
  }

  for( i=0;i< n;i++){
    scanf("%d",&arrw[i]);

  }
  int f = 0;
  for( i=0;i< n;i++){
    if(arra[i]== 0 ){minwr = minwr > arrw[i]? arrw[i] : minwr; f += arra[i];}
    else if(arra[i]== 1 ){minwl = minwl > arrw[i]? arrw[i] : minwl; f += arra[i];}

  }

  if (f == 0 || f == n){printf("0\n");}
  else {
  printf("%d\n",minwr+minwl);
  }
  return 0;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

string create(string s, string t, ll index) {
    string temp = "";
    rep(i, s.length()) {
        if (index <= i && i < index + t.length()) {
            temp += t[i - index];
        } else {
            if (s[i] == '?') {
                temp += 'a';
            } else {
                temp += s[i];
            }
        }
    }
    return temp;
}

int main() {
source:
    string s, t;
    cin >> s >> t;

    vector<string> ans;
    rep(i, s.length() - t.length() + 1) {
        bool able = true;
        rep(j, t.length()) {
            if (s[i + j] != '?' && (t[j] != s[i + j])) {
                able = false;
            }
        }
        if (able) {
            ans.push_back(create(s, t, i));
        }
    }

    sort(ans.begin(), ans.end());
    if (ans.size() == 0) {
        cout << "UNRESTORABLE" << endl;
    } else {
        cout << ans[0] << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll a, b;
		cin >> a >> b;
		ll temp = 4 * a;
		temp = temp - b;
		// cout << temp << endl;
		if (temp < 0 || (temp % 2 != 0))
		{
			cout << "No" << endl;
			return 0;
		}
		temp = temp / 2;
		// cout << temp << endl;
		if (temp <= a && temp >= 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3640
n = int(input())
alist = [int(s) for s in input().split(" ")]
asum = alist[0]
for a in alist[1:]:
  asum ^= a

import copy
a_ans = []
for i in range(n):
  asum ^= alist[i]
  a_ans.append(asum)
  asum ^= alist[i]
print(" ".join([str(a) for a in a_ans]))

Measured memory_bytes: 41988
package main

import (
    "fmt"
)

func main() {
    var n, x int
    fmt.Scan(&n, &x)
    l := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&l[i])
    }
    sum := 0
    for i, v := range l {
        sum += v
        if sum > x {
            fmt.Println(i + 1)
            return
        }
    }
    fmt.Println(len(l) + 1)
}

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

const int MAX_n = 200;
int main(){
    int n, a[MAX_n], ans=0;
    bool can=true;
    cin >> n;
    rep(i, n) cin >> a[i];

    while(can){
        rep(i, n){
            if(a[i] % 2 == 0) a[i] = a[i]/2;
            else can = false;
        }
        if(can) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define inf 1e18
#define all(v) (v).begin(),(v).end()
using namespace std;

vector <int> dx = {-1,1,0,0};
vector <int> dy = {0,0,-1,1};
ll modexp(ll a,ll b){
	a %= MOD;
	ll res = 1;
	while(b > 0){
		if(b&1){
			res = (res*a)%MOD;
		}
		b >>= 1;
		a = (a*a)%MOD;
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n; cin>>n;
	if(n<2){
		cout << "0"<<"\n";
	}else{
	    ll ans = modexp(10,n) - modexp(9,n) - modexp(9,n) + modexp(8, n);
    	ans %= MOD;
    	if(ans < 0) ans += MOD;
    	cout<< ans <<"\n";
	}

	return 0;
}

Measured memory_bytes: 3640
// #pragma warning(disable:4996)
#include <memory.h>
#include <stdio.h>
#include <assert.h>

#include <list>
#include <bitset>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long int64;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int > vi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#define ALL(x) (x).begin(), (x).end()
#define CLEAR(x) (x).clear()
#define RESET(x) memset((x), 0, sizeof (x))
#define MP(X,Y) make_pair(X,Y)//NOTES:MP(

#define FOR(i, b, e) for ( int i = (b); i < (e); ++i)
#define RE(i, n) FOR(i, 0, (n))
#define FOREACH(i, x, y) for ( int i = (x); i <= (y); ++i)

const ll maxn = (ll)77777;
const ll maxm = (ll)1e6 + 10;
const ll MOD = 1e9 + 7;
const ll INF = 1e15;

int fast_read(){ int input; char c=0; while(c<33)c= getchar(); input=0; while(c>33){ input=input*10+c-'0'; c=getchar(); } return input; }

int main() {


	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

	int n;
	while (cin >> n) {
		vi a[2];
		vi b[2];
		RE(i, 2) {
			a[i].resize(n);
			b[i].resize(n);
			RE(j, n) cin >> a[i][j], b[i][j] = 1;
		}

		int last = -1;
		for (int i = 0; i < n; ++i) {
			if (a[0][i] > last) {
				last = a[0][i];
				b[0][i] = a[0][i];
			}
		}
		last = -1;
		for (int i = n - 1; i >= 0; --i) {
			if (a[1][i] > last) {
				last = a[1][i];
				b[1][i] = a[1][i];
			}
		}

		ll ans = 1;
		RE(i, n) {
			ll up = min(a[0][i], a[1][i]);
			ll down = max(b[0][i], b[1][i]);
			if (down > up) {
				ans = 0;
				break;
			}
			ans *= (up - down + 1);
			ans %= MOD;
		}
		cout << ans << endl;
	}

	// cout << (float)(clock() - start_time)/CLOCKS_PER_SEC << "s" << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int dp[3100][3100]={0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        for(int j=0;j<t.size();j++){
            if(s[i]==t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i+1][j]);
            chmax(dp[i+1][j+1],dp[i][j+1]);
        }
    }
    string res="";
    int i=(int)s.size(),j=(int)t.size();
    while(i>0 && j>0){
        //(i-1,j) -> (i,j)　と更新されていた場合
        if(dp[i][j]==dp[i-1][j]) --i;

        //(i,j-1) -> (i,j)　と更新されていた場合
        else if(dp[i][j]==dp[i][j-1]) --j;

        //(i-1,j-1) -> (i,j)　と更新されていた場合
        else{
            res = s[i-1] + res;
            --i,--j;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 37120