akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <utility>
#include <cstdio>
#include <vector>
#define MOD 1000000007
#define pb push_back
typedef long long ll; 
typedef std::pair<int, int> frac; 
std::vector<frac> vec; 
inline bool comp(const frac &a, const frac &b)
{
	return (ll)a.first * b.second < (ll)a.second * b.first; 
}
int main()
{
	// freopen("CF17-QC-E.in", "r", stdin); 
	int a, b, c, d; 
	scanf("%d%d%d%d", &a, &b, &c, &d); 
	for (int i = 0; i <= d; i++)
	{
		if (i < a)
		{
			vec.pb({i, a}); 
			vec.pb({a - i - 1, a}); 
		}
		if (i < b)
		{
			vec.pb({i, b}); 
			vec.pb({b - i - 1, b}); 
		}
		if (i < c)
		{
			vec.pb({i, c}); 
			vec.pb({c - i - 1, c}); 
		}
	}
	std::sort(vec.begin(), vec.end(), comp); 
	ll ans = (ll)(std::min(a - 1, d) + 1) * (std::min(b - 1, d) + 1) % MOD
		 * (std::min(c - 1, d) + 1) % MOD, x = 0, y = 0, z = 0; 
	for (int i = 1; i < vec.size(); i++)
	{
		ll curx = (ll)a * vec[i].first / vec[i].second;
		ll cury = (ll)b * vec[i].first / vec[i].second;
		ll curz = (ll)c * vec[i].first / vec[i].second; 
		ll dx = std::min((ll)a - 1, x + d) - std::max(0ll, x - d) + 1; 
		ll dy = std::min((ll)b - 1, y + d) - std::max(0ll, y - d) + 1; 
		ll dz = std::min((ll)c - 1, z + d) - std::max(0ll, z - d) + 1; 
		if (curx + d < a)
			(ans += (curx - x) * dy % MOD * dz) %= MOD; 
		if (cury + d < b)
			(ans += (cury - y) * dx % MOD * dz) %= MOD; 
		if (curz + d < c)
			(ans += (curz - z) * dx % MOD * dy) %= MOD; 
		x = curx; 
		y = cury; 
		z = curz; 
	}
	printf("%lld\n", ans);
	return 0; 
}


Measured memory_bytes: 6512
#include <iostream>
#include <map>
using namespace std;
string str;
int main(){
    cin>>str;
    int n = str.length();
    map<char,int> d;
    for(int i = 0;i < n - 7;){
	bool flag = true;
	d.clear();

	for(int j = i;j < i + 8;j++){ 

	    if(str[j] != 'A'&& str[j] !='I' && str[j] != 'D'
	       &&str[j] !='U' && str[j] != 'Y' && str[j] != 'N'){
		flag =false;
		break;
	    }
	    d[str[j]]++;
	}
	
	if(flag&&d['A'] == 2 && d['I'] == 1 && d['D'] == 1 && d['U'] == 1 &&d['N'] == 2 && d['Y'] == 1){
	    str.replace(str.begin() + i ,str.begin() + i + 8, "AIZUNYAN");
	    i += 8;
	}else{
	    i++;
	}
    }
    cout <<str<<endl;
}

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

int main(void){
  double n;
  long long a[5];
  cin >> n;
  for(int i = 0; i < 5; i++) cin >> a[i];
  sort(a, a + 5);
  double b = (double)(a[0]);
  long long ans = ceil(n / b) + 4;
  cout << ans << endl;
  return 0;
}


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

int main(void){
    int n;
    string s;
    cin >> n >> s;
    int count = 0;
    for(int i=0;i<s.size()-2;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
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 main(){
    ll n,k;cin >> n >>k;
    ll ans=k;
    rep(i,n-1)ans*=(k-1);
    cout << ans <<endl;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a >= 1&&a <= 9){
    if(b >= 1 && b <= 9){
      cout << a * b;
    }
    else{
      cout << -1;
    }
  }
  else{
    cout << -1;
  }
}

Measured memory_bytes: 3696
'use strict';

var input = require('fs').readFileSync('/dev/stdin', 'utf8'); // import 'fs' module, using readFileSync()
var lines = input.split('\n');
while (lines.length > 1) {
	var A = lines.shift().split(' ');
	var B = lines.shift().split(' ');
	var hit = 0;
	var blow = 0;
	for (var i = 0; i < B.length; ++i) {
		if (B[i] === A[i]) {
			hit += 1;
		} else {
			for (var j = 0; j < A.length; ++j) {
				if (B[i] === A[j]) {
					blow += 1;
					break;
				}
			}
		}
	}
	console.log('%d %d', hit, blow);
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n & 1) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n/2+i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
  int N,i,super;
  int A[200000];
  scanf("%d",&N);
  for(i=0;i<200000;i++) A[i]=0;
  for(i=0;i<N-1;i++){
    scanf("%d",&super);
    A[super-1]++;
  }
  for(i=0;i<N;i++) printf("%d\n",A[i]);
  return 0;
}

Measured memory_bytes: 2516
/* Strings with the Same Length */

#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  for(int i=0;i<n;i++){
    cout << s[i] << t[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s, rs;
    cin >> n >> s;
    rs = s.substr(n);
    reverse(all(rs));

    vector<pair<string, string> > ves(1<<n);
    rep(i, 1<<n) {
        string x, y;
        rep(j, n) {
            if(i>>j&1) x += s[j];
            else y += s[j];
        }
        ves[i] = make_pair(x, y);
    }
    sort(all(ves));

    ll ans = 0;
    rep(i, 1<<n) {
        string x, y;
        rep(j, n) {
            if(i>>j&1) x += rs[j];
            else y += rs[j];
        }
        auto pitr = equal_range(all(ves), make_pair(x, y));
        ans += pitr.second - pitr.first;
    }

    cout << ans << endl;
}

Measured memory_bytes: 19580
N, M = list(map(int, input().split()))
AB = []
for i in range(M):
    AB.append(list(map(int, input().split())))

rinsetu = {}
mitisirube = {}
kyori = {}
for i in range(1, N+1):
    rinsetu[i] = []
    mitisirube[i] = None
    kyori[i] = None
kyori[1]=0

for ab in AB:
    rinsetu[ab[0]].append(ab[1])
    rinsetu[ab[1]].append(ab[0])

queue = [1]
while queue:
    this = queue.pop(0)
    #print(this, ":", rinsetu[this])
    for r in rinsetu[this]:
        if kyori[r] is None:
            kyori[r] = kyori[this] + 1
            mitisirube[r] = this
            queue.append(r)


#for n in range(1, N+1):
#    print(n, ":", mitisirube[n], kyori[n])

all_mitisirube = [mitisirube[i] for i in range(2, N+1)]
if None in all_mitisirube:
    print("No")
else:
    print("Yes")
    for i in range(2, N+1):
        print(mitisirube[i])


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

int
read_data(FILE *fp, unsigned int n, unsigned int data[])
{
    int i;

    for (i = 0; i < n; i++) {
        if (1 != fscanf(fp, "%u\n", &data[i])) {
            fprintf(stderr, "Invalid data at line %u.\n", i+2);
            return 1;
        }
    }
    return 0;
}

unsigned long
calc_total_wait(unsigned int n, unsigned int data[])
{
    unsigned long total_wait = 0;
    int i;

    int compare(const void *a, const void *b) {
        return *((unsigned int*)a)-*((unsigned int*)b);
    };
    qsort(data, n, sizeof(data[0]), compare);
    for (i = 0; i < (n-1); i++) {
        total_wait += data[i] * (n - (i+1));
    }

    return total_wait;
}

int
main(int argc, char *argv[])
{
    int NUM_DATA_MAX = 10000;
    unsigned int n, data[NUM_DATA_MAX];

    while ((1 == scanf("%u\n", &n)) && n) {
        unsigned long total_wait;
        int ret;

        if ((ret = read_data(stdin, n, data))) {
            return ret;
        }
        total_wait = calc_total_wait(n, data);
        printf("%lu\n", total_wait);
    }

    return 0;
}

Measured memory_bytes: 740
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	std::vector<int> b(n);
	std::vector<int> c(n-1);
	rep(i,n) std::cin >> a[i];
	rep(i,n) std::cin >> b[i];
	rep(i,n-1) std::cin >> c[i];

	int sum = 0;
	rep(i,n-1) {
		sum+=b[a[i]-1];
		if(a[i]+1==a[i+1]) sum+=c[a[i]-1];
	}
	sum+=b[a[n-1]-1];
	print(sum);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a;
    cin >> a;
    if(a < 1200) cout << "ABC" << endl;
    else if(a < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#[warn(unused_imports)]
use std::io::*;
use std::str::FromStr;
use std::cmp;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut A: Vec<i64> = Vec::new();
    for _ in 0..3 {
        let tmp = read::<i64>();
        A.push(tmp);
    }
    A.sort_by(|a, b| a.cmp(b));
    let mut total = 0;
    for i in 1..3 {
        let tmp = A[i] - A[i-1];
        total += tmp;
    }

    println!("{}", total);

}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
string s;
int cnt = 0;
cin >> s;
for (int i = 0; i < 3; i++){
  if (s[i] == 'A'){
    cnt ++;
  }
  else{
    cnt --;
  }
}
if (cnt == 3 || cnt == -3){
  cout << "No\n";
}
if (cnt != 3 && cnt != -3){
  cout << "Yes\n";
}
return 0;   
}

Measured memory_bytes: 256
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x,val) memset(x,val,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
    template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    bool IN(ll x,ll l,ll r){return l<=x and x<=r;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    char col[N];set<int> to[N];queue<int> q;bool del[N];
    int dis[N];int ans=0;
    void solve(int x,int fa)
    {
        dis[x]=dis[fa];
        if(sz(to[x])==1) dis[x]++;
        else dis[x]+=((sz(to[x])&1)!=(col[x]=='1'))*2;
        for(auto y:to[x]) if(y!=fa) solve(y,x);
    }
    void main()
	{
        int n=qread();fo(i,2,n) {int x=qread(),y=qread();to[x].insert(y),to[y].insert(x);}
        scanf("%s",col+1);fo(i,1,n) col[i]='0'+(col[i]=='W');
        fo(x,1,n) if(sz(to[x])<=1 and col[x]=='0') q.push(x);
        while(sz(q))
        {
            int x=q.front();q.pop();del[x]=1;
            for(auto y:to[x]) {to[y].erase(x);if(sz(to[y])<=1 and col[y]=='0') q.push(y);}
        }
        int rt=0;fo(x,1,n) if(!del[x]) rt=x;if(!rt) {puts("0");return;}
        solve(rt,0);int t=rt;fo(x,1,n) if(dis[x]>dis[t]) t=x;
        int mx=0;solve(t,0);fo(x,1,n) chmax(mx,dis[x]);mx-=2;
        fo(x,1,n) if(!del[x]) ans+=sz(to[x])+(((sz(to[x]))&1)!=(col[x]=='1'));
        write(ans-mx);//原本dis是边数，上面求的点数；另外起点没算
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 64512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<class T>inline void read(T &res)
{
    char c;
    T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
    res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';
    res*=flag;
}
void gcd(ll a,ll b,ll &d,ll &x,ll &y)
{
    if(!b)
    {
        d=a;
        x=1;
        y=0;
    }
    else
    {
        gcd(b,a%b,d,y,x);
        y-=x*(a/b);
    }
}
ll in(ll a,ll mod)
{
    ll d,x,y;
    gcd(a,mod,d,x,y);
    return d==1?(x+mod)%mod:-1;
}

ll qp(ll a,ll x,ll mod)
{
    ll ans=1;
    while(x)
    {
        if(x%2==1)
            ans=(ans*a)%mod;
        a=(a*a)%mod;
        x/=2;
    }
    return ans;
}
int cmp(ll a,ll b)
{
    return a<b;
}

int ok(ll a,ll b,ll c)
{
    if(a==b||a==c||b==c)
        return 0;
    if(a+b>c)
        return 1;
    return 0;
}
int main()
{
    ll x,k,d;
    cin>>x>>k>>d;
    if(x==0)
    {
    	if(k%2==0)
    		printf("0\n");
    	else
    		printf("%lld\n",d);
	}
    else if(abs(x)>abs(k*d))
    {
        cout<<abs(abs(x)-k*d)<<endl;
    }
    else
    {
    	if(x<0)
    	{
    		x=-x;
		}
        ll t=x/d;
        x=x-t*d;
        k=k-t;
        if(k%2==0)
            cout<<x<<endl;
        else
            cout<<abs(x-d)<<endl;
    }
    return 0;

}

Measured memory_bytes: 3680
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
	int a,b,c,ans=1;
	cin>>a>>b>>c;
	if(a!=b)ans++;
	if(a!=c&&b!=c)ans++;
	cout<<ans<<endl;
	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(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








      

 
int a[3];
int b[3];
int c[3][3];
 
int main() {
	for(int i=0;i<3;i++) {
		for(int j=0;j<3;j++) {
			cin>>c[i][j];
		}
	}
	a[0]=0;
	a[1]=c[1][0]-c[0][0];
	a[2]=c[2][0]-c[0][0];
	b[0]=c[0][0];
	b[1]=c[0][1];
	b[2]=c[0][2];
    string ans="Yes";
	for(int i=0;i<3;i++) {
		for (int j=0;j<3;j++) {
			if(a[i]+b[j]!=c[i][j]) ans="No";
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3572
#include <vector>

#include <iostream>

// nの素因数分解を行う
std::vector<int> prime_factorization(int n) {
  std::vector<int> ret;
  for (int d = 2; d * d <= n; d++) {
    while (n % d == 0) {
      ret.push_back(d);
      n /= d;
    }
  }
  if (n != 1)
    ret.push_back(n);
  return ret;
}

// verify: https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_A
int main() {
  int n;
  std::cin >> n;
  std::vector<int> ans = prime_factorization(n);
  int m = ans.size();
  std::cout << n << ": ";
  for (int i = 0; i < m; i++) {
    std::cout << ans[i] << (i == m - 1 ? "\n" : " ");
  }
  return 0;
}



Measured memory_bytes: 3164
#!/usr/local/gnu/bin/bash
read n a b
s=(`fold -1`)
an=0
bn=0
for x in ${s[@]}
do
    case $x in
        "a" )
            if((an+bn<a+b))
            then
                an=$((an+1))
                echo Yes
            else
                echo No
            fi;;
        "b" )
            if((an+bn<a+b&&bn<b))
            then
                bn=$((bn+1))
                echo Yes
            else
                echo No
            fi;;
        "c" )
            echo No;;
    esac
done


Measured memory_bytes: 26156
using System;


namespace ConsoleApplication
{
    public class A
    {
        int a, b;
        string op;
        public A() 
        {
            string[] s = Console.ReadLine().Split(' ');
            this.a = int.Parse(s[0]);
            this.b = int.Parse(s[2]);
            this.op = s[1];
        }

        public void run() 
        {
            if (op == "+") {
                System.Console.WriteLine(a+b);
            } else {
                System.Console.WriteLine(a-b);
            }
        }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            var a = new A();
            a.run();
        }
    }
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>a(N+1);
  for(int i=1;i<=N;i++){
    cin>>a[i];
  }
  int s=1;
  for(int i=0;i<=N+1;i++){
    if(s==2){cout<<i<<endl;return 0;}
    s=a[s];
  }
  cout<<-1<<endl;
  return 0;  
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N, T; cin >> N >> T;
    vector<ll> t(N);
    rep(i, N) cin >> t.at(i);
    ll sum = T;
    for (int i = N-1; i > 0; i--) {
        ll d = t[i] - t[i-1];
        sum += min(d, T);
    }
    cout << sum << endl;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return -self.parents[self.find(x)]

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return -self.parents[self.find(x)]

def main():
    N, M = map(int, input().split())
    uf = UnionFind(N+1)
    ans = 1
    if M == 0:
        print(ans)
        return

    for i in range(M):
        x, y = map(int, input().split())
        ans = max(uf.union(x,y), ans)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14676
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
#define mp make_pair
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll n,m;
  cin >> n >> m;
  if(n==1){
    n=3;
  }
  if(m==1){
    m=3;
  }
  n-=2,m-=2;
  cout << n*m << endl;
}


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

long long dp[200007],ara[200007],mod=998244353;

int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz=0,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,z=0,cnt=0,res=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld %lld",&n,&k); n--;

        for(i=1;i<=k;i++)
        {
            scanf("%lld %lld",&a,&b);  vct.push_back(make_pair(a,b));
        }

        sort(vct.begin(),vct.end());

        long long cap;

        for(cap=0;cap<=n;cap++)
        {

            if(cap==0){  dp[cap]=1; ara[cap]=dp[cap];  }
            else
            {
                sum=0;

                for(i=0;i<k;i++)
                {
                    fr=vct[i].first; sc=vct[i].second;

                    g=cap-fr; h=cap-sc;

                    if(g>=0)
                    {
                         p=ara[g];  q=0; if(h-1>=0){  q=ara[h-1];   }

                         if(p>=q){  r=p-q;  }
                         else{  r=(mod-q)+p;    }

                         sum=(sum+r)%mod;

                    }
                    else
                    {
                        break;
                    }

                }

                dp[cap]=sum; ara[cap]=(ara[cap-1]+dp[cap])%mod;


            }


        }



        printf("%lld\n",dp[n]);



        return 0;
}





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

using namespace std;
using ll = long long int;

int main() {
    ll N, K;
    ll c;
    vector<ll> A;

    cin >> N >> K;
    for (ll i = 0; i < N; i++){
        cin >> c;
        A.push_back(c);
    }
    sort(A.begin(), A.end());
    ll ans = 0;
    for (ll i = 0; i < N - K; i++){
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int ans=100000000;
void dfs(int n,int m,int x,vector<int>& cost,vector<vector<int> >& understand,int index,vector<int> curr,int spent){
	if(index == n){
		
		for(int i=0;i<curr.size();i++){
			if(curr[i]<x)return;
		}
		ans = min(ans,spent);
		return ;
	}
	for(int i=0;i<curr.size();i++){
		curr[i] += understand[index][i];
	}
	dfs(n,m,x,cost,understand,index+1,curr,spent+cost[index]);
	for(int i=0;i<curr.size();i++){
		curr[i] -= understand[index][i];
	}
	dfs(n,m,x,cost,understand,index+1,curr,spent);
	
	
}


int main(){
	
	int n,m,x;
	cin>>n>>m>>x;
	vector<int> cost(n);
	vector<vector<int> > understand(n,vector<int>(m));
	for(int i=0;i<n;i++){
		cin>>cost[i];
		for(int j=0;j<m;j++){
			cin>>understand[i][j];
		}
	}
	vector<int> curr(m);
	dfs(n,m,x,cost,understand,0,curr,0);
	if(ans==100000000)cout<<-1;
	else
	cout<<ans;	
	
}



Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int n, k;
int main() {
    cin >> n >> k;
    if (k == 0) {
        return !printf("%lld\n", (long long)n*n);
    }
    long long ans = 0;
    for (int b = k+1; b <= n; b ++) {
        int t = (n+1)/b;
        if (t*b-1<n) t ++;
        ans += t*(b-k) - min(t*b-1 - n, b-k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int n, k, mon = 0;
	cin >> n;
	vector<int>v(10);
	for (int i = 0; i < n; ++i) {
		cin >> k;
		if (k < 3200) ++v[k / 400];
		else ++v[8];
	}
	for (int i = 0; i <= 7; ++i) {
		if (v[i])++mon;
	}
	cout << max(mon, 1) << " " << mon + v[8] << endl;
}

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

int main()
{
	int A, B,C;
	cin >> A >> B >> C;

	if (A == B && B == C)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}


Measured memory_bytes: 3668
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC140A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(Math.Pow(n, 3));
        }
    }
}


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

using namespace std;
int n,k;
int v[105],w[105];
long long mem[105][100005];

long long solve(int ind,int cw){
    if(cw<0){
        return -1e18;
    }
    if(ind==n){
        return 0;
    }
    if(mem[ind][cw]!=-1){
        return mem[ind][cw];
    }
    return mem[ind][cw]=max(solve(ind+1,cw-w[ind])+v[ind],solve(ind+1,cw));
}

int main() {
    //freopen("input.in", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(mem,-1,sizeof mem);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    cout<<solve(0,k)<<endl;
    /*for(int i=0;i<=k;i++){
        dp[0][i]=0;
    }
    */
    return 0;
}

Measured memory_bytes: 82304
// a possible solution with explanation
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	/*int r,c,i,j;cin>>r>>c;
	ll a[r+1][c+1];
	if(r==1&&c==1)cout<<0;
	else if(r==1)
	{
		for(i=1;i<=c;i++)cout<<1+i<<" ";
	}
	else if(c==1)
	for(i=1;i<=r;i++)
	{
		cout<<1+i<<endl;
	}
	else
	for(i=1;i<=r;i++)
	{
		for(j=1;j<=c;j++)
		{
			a[i][j]=j*(i+c);
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}*/
	ll n,i,j;
	cin>>n;
	for(i=1;i*i<=n;i++)
	{
		if(n%i==0)j=i;
	}
	cout<<(j-1)+(n/j-1);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 10010;
int A[4],a,b,c;
int main()
{
    for(int i=0;i<3;i++){
        cin>>A[i];
    }
    a=A[0];
    b=A[1];
    c=A[2];
    sort(A,A+3);
    if(A[0]==5 && A[1]==5 && A[2]==7)
    {
        cout<<"YES"<<endl;

    }
    else
        cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"container/list"
	"fmt"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	var ch, cw, dh, dw int
	fmt.Scan(&ch, &cw, &dh, &dw)
	ch--
	cw--
	dh--
	dw--

	ss := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&ss[i])
	}

	const inf int = 1e12

	ds := [1100][1100]int{}
	for i := 0; i < len(ds); i++ {
		for j := 0; j < len(ds[i]); j++ {
			ds[i][j] = inf
		}
	}

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

	q := list.New()
	q.PushBack(Point{cw, ch})

	ds[ch][cw] = 0
	e := q.Front()
	for e != nil {
		p := e.Value.(Point)
		q.Remove(e)

		cx, cy := p.x, p.y
		if cx == dw && cy == dh {
			break
		}

		for d := 0; d < len(dx); d++ {
			nx := cx + dx[d]
			ny := cy + dy[d]
			if 0 <= nx && nx < w && 0 <= ny && ny < h {
				if ds[ny][nx] > ds[cy][cx] && ss[ny][nx] == '.' {
					ds[ny][nx] = ds[cy][cx]
					q.PushFront(Point{nx, ny})
				}
			}
		}

		for ox := -2; ox <= 2; ox++ {
			for oy := -2; oy <= 2; oy++ {
				nx := cx + ox
				ny := cy + oy
				if 0 <= nx && nx < w && 0 <= ny && ny < h {
					if ds[ny][nx] == inf && ss[ny][nx] == '.' {
						ds[ny][nx] = ds[cy][cx] + 1
						q.PushBack(Point{nx, ny})
					}
				}
			}
		}
		e = q.Front()
	}

	if ds[dh][dw] == inf {
		fmt.Println(-1)
		return
	}

	fmt.Println(ds[dh][dw])
}

// Point .
type Point struct {
	x, y int
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

using namespace std;

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

	int n;
	unsigned long long x;
	cin >> n;

	unsigned long long ans = 1;
	bool flag = false;

	for (int i = 0; i < n; i++) {
		cin >> x;
		if (x == 0) {
			flag = false;
			ans = 0;
			break;
		}
		if (ans > (unsigned long long)1e18 / x)
			flag = true;
		ans *= x;
	}

	if (flag) {
		cout << -1 << "\n";
	}
	else
		cout << ans << "\n";


}


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

int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    /* 1m -> 6 degree, 
     1h -> 30 degree => 1m -> 0.5 degree
    */
    double bd = h * 30 + (double)(m * 0.5) - m * 6;
    double rad = bd * (M_PI/180.0);
    double ans = sqrt(a*a + b*b - 2*a*b * cos(rad));    // cosはradianを引数としてる
    cout << fixed << setprecision(20) << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4204
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	vector<int>in(5);
	rep(i,5)cin>>in[i];
	sort(all(in));
	rep(i,5){
		if(i)cout<<' ';
		cout<<in[4-i];
	}
	cout<<endl;
}

Measured memory_bytes: 1208
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] filter = new int[1 << 7];

	public static void main(String[] args) {
		while (sc.hasNext()) {
			char[] input = sc.next().toCharArray();
			if (input.length != filter.length) break;
			for (int j = 0; j < filter.length; ++j) {
				filter[j] = input[j] - '0';
			}
			System.out.println(solve() ? "yes" : "no");
		}
	}

	static boolean solve() {
		int[] outer = new int[5];
		for (int j = 0; j < (1 << 19); ++j) {
			outer[0] = (j & 0x7) << 2;
			outer[1] = ((j >> 3) & 0xF) << 1;
			outer[2] = (j >> 7) & 0x1F;
			outer[3] = (j >> 12) & 0xF;
			outer[4] = (j >> 16) & 0x7;
			int inner = 0;
			inner |= calc(outer, 2, 1);
			inner |= calc(outer, 3, 1) << 1;
			inner |= calc(outer, 1, 2) << 2;
			inner |= calc(outer, 2, 2) << 3;
			inner |= calc(outer, 3, 2) << 4;
			inner |= calc(outer, 1, 3) << 5;
			inner |= calc(outer, 2, 3) << 6;
			if (filter[inner] != ((inner >> 3) & 1)) {
				return false;
			}
		}
		return true;
	}

	static int calc(int[] ar, int x, int y) {
		int key = (ar[y - 1] >> x) & 0x3;
		key |= ((ar[y] >> (x - 1)) & 0x7) << 2;
		key |= ((ar[y + 1] >> (x - 1)) & 0x3) << 5;
		return filter[key];
	}
}

Measured memory_bytes: 21052
N = int(input())
h = list(map(int, input().split()))
dp = [0] * N
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
    dp[i] = min(abs(h[i] - h[i - 2]) + dp[i - 2], abs(h[i] - h[i - 1]) + dp[i - 1])
print(dp[N - 1])

Measured memory_bytes: 20564
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> garden(0,0);
  int high=0;
  for(int i=0; i<N; i++){
    int h;
    cin >> h;
    garden.push_back(h);
    high=max(high, h);
  }
  int ans=0;
  for(int i=high; i>0; i--){
  bool swi=true;  
    for(int j=0; j<N; j++){
      if(garden[j]<i) swi=true;
      else{
        if(swi) ans++;
        swi=false;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
S = input()

L = []
for i in range(len(S)):
    L.append(S[i])

B = False
for i, v in enumerate(L):
    L.pop(i)
    if (v in L):
        B = True
        break
    else:
        L.insert(i, v)

if B:
    print('no')
else:
    print('yes')


Measured memory_bytes: 2940
<?php
$S=fgets(STDIN);
$l=strlen($S);
for($i=0;$i<$l;$i++){
	$n=ord($S[$i]);
	if(64<$n && $n<91) print chr($n+32);
	elseif(96<$n && $n<123) print chr($n-32);
	else print $S[$i];
}

Measured memory_bytes: 15388
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Anurag_Gupta ios_base::sync_with_stdio(0);
#define IIIT_ALLD cin.tie(0);cout.tie(0);
#define mod 987654319
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
    Anurag_Gupta
    IIIT_ALLD

  

        int a,b;
        cin>>a>>b;
        int xx = __gcd(a,b);

        int count=1;
        for(int i = 2;i*i<=xx;i++)
        {
          if(xx%i==0)
          {
              count++;
              while(xx%i==0)
                xx/=i;
          }
        }
        if(xx>1)
          count++;
        cout<<count<<"\n";

        












    #ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


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

int f[200002];


int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, ans = 0; cin >> n;
	for(int i = 1; i <= n; i++) {
		int x; cin >> x; 
		f[x]++;
		ans += x;
	}

	int q; cin >> q;

	for(int i = 1; i <= q; i++) {
		int b, c; cin >> b >> c;
		ans -= f[b] * b;
		ans += f[b] * c;
		f[c] += f[b];
		f[b] = 0;
		cout << ans << endl; 
	}
}

Measured memory_bytes: 4420
<?php
$k = (int)trim(fgets(STDIN));
// ルンルン数一覧
$l_list = [];
// $iから始まるルンルン数を
for ($i=1; $i <= 9; $i++) { 
	$l_list[] = $i;
	// 各10桁くらいまで求める
	$luns = [$i];
	$depth = 0;
	while ($depth < 10) {
		$new = [];
		foreach ($luns as $num) {
			lun_from($num, $new, $l_list);
		}
		$luns = $new;
		$depth += 1;
	}
}
sort($l_list);
echo $l_list[$k-1];



// $numに一桁付け足してできるルンルン数一覧
function lun_from($num, &$new, &$l_list){
	$s = (string)$num;
	$last = (int)$s[strlen($s) - 1];
	if ($last - 1 >= 0) {
		$new[]    = (int)($s . ($last - 1));
		$l_list[] = (int)($s . ($last - 1));
	}
	$new[]    = (int)($s . $last);
	$l_list[] = (int)($s . $last);
	if ($last + 1 < 10) {
		$new[]    = (int)($s . ($last + 1));
		$l_list[] = (int)($s . ($last + 1));
	}
}

Measured memory_bytes: 41584
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class SegmentTree():
    def __init__(self, n, func, init=float('inf')):
        '''
        n->配列の長さ
        func:func(a,b)->val,　func=minだとRMQになる
        木の高さhとすると,
        n:h-1までのノード数。h段目のノードにアクセスするために使う。
        data:ノード。
        parent:k->child k*2+1とk*2+2
        '''
        self.n = 2**(n-1).bit_length()
        self.init = init
        self.data = [init]*(2*self.n)
        self.func = func

    def set(self, k, v):
        '''
        あたいの初期化
        '''
        self.data[k+self.n-1] = v

    def build(self):
        '''
        setの後に一斉更新
        '''
        for k in reversed(range(self.n-1)):
            self.data[k] = self.func(self.data[k*2+1], self.data[k*2+2])

    def update(self, k, a):
        '''
        list[k]=aに更新する。
        更新ぶんをrootまで更新
        '''
        k += self.n-1
        self.data[k] = a

        while k > 0:
            k = (k-1)//2
            self.data[k] = self.func(self.data[k*2+1], self.data[k*2+2])

    def query(self, l, r):
        '''
        [l,r)のfuncを求める
        '''
        L = l+self.n
        R = r+self.n
        ret = self.init
        while L < R:
            if R & 1:
                R -= 1
                ret = self.func(ret, self.data[R-1])
            if L & 1:
                ret = self.func(ret, self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return ret


N = int(input())
L = list(map(int, input().split()))
ans = "Yes"

Seg = SegmentTree(N, min, init=float('inf'))
for i, h in enumerate(L):
    Seg.set(i, h)

Seg.build()

for i, h in enumerate(L[:-1]):
    if h <= Seg.query(i+1, N)+1:
        continue
    else:
        ans = "No"
        break
print(ans)


Measured memory_bytes: 68876
from collections import deque
n, m = map(int, input().split())
l = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    l[a - 1].append(b - 1)
    l[b - 1].append(a - 1)
que = deque([0])
visited = [False] * n
visited[0] = True
prev = [0] * n
while que:
    p = que.popleft()
    for i in l[p]:
        if visited[i]:
            continue
        visited[i] = True
        prev[i] = p
        que.append(i)
print("Yes")
for i in prev[1:]:
    print(i + 1)

Measured memory_bytes: 35648
import sys
input=sys.stdin.readline

def main():
    _ = int(input())
    H = list(map(int, input().split()))
    ma = 0
    tm = 0
    th = 0
    for h in H:
        if h > th:
            tm = 0
        else:
            tm += 1
        ma = max(ma, tm)
        th = h
    print(ma)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14252
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int H, W;
bool grid[50][50];

bool isInner(int _x, int _y) {
	if (_x < 0 || _x >= W || _y < 0 || _y >= H) return false;
	return true;
}

bool isBlack(int _x, int _y) {
	if (grid[_y][_x]) return true;
	return false;
}

bool canPaint(int _x, int _y) {
	if (isInner(_x - 1, _y)) {
		if (isBlack(_x - 1, _y)) return true;
	}
	if (isInner(_x + 1, _y)) {
		if (isBlack(_x + 1, _y)) return true;
	}
	if (isInner(_x, _y - 1)) {
		if (isBlack(_x, _y - 1)) return true;
	}
	if (isInner(_x, _y + 1)) {
		if (isBlack(_x, _y + 1)) return true;
	}
	return false;
}

int main() {
	cin >> H >> W;
	REP(i, H) {
		REP(j, W) {
			char c;
			cin >> c;
			if (c == '#') grid[i][j] = 1;
			else grid[i][j] = 0;
		}
	}

	string ans = "Yes";
	REP(i, H) {
		REP(j, W) {
			if (isBlack(j, i)) {
				if (!canPaint(j, i)) {
					ans = "No";
					break;
				}
			}
		}
		if (ans == "No") break;
	}
	cout << ans;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).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; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;
const long long INF = 1LL<<60;

const int MAX_N = 110;
const int MAX_V = 100100;
void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}
//dp[ i ][ sum_v ] := i-1 番目までの品物から価値が sum_v 以上を達成するように選んだときの、重さの総和 sum_w の最小値
int N;
ll W,weight[MAX_N],value[MAX_N];
// DPテーブル
long long dp[MAX_N][MAX_V];
int main ()
{
    cin>>N>>W;
    REP(i,N) cin>>weight[i]>>value[i];
    REP(i,MAX_N){
        REP(j,MAX_V){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    REP(i,N){
        REP(sum_v,MAX_V){
              if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);

            // i 番目の品物を選ばない場合
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }
    ll res = 0;
    REP(sum_v,MAX_V){
        if(dp[N][sum_v]<=W) res = sum_v;
    }

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

Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

Vec pn;

bool isPrime(ll n){
	if(n == 1) return false;
	for(ll i : pn){
		if(i * i > n) return true;
		if(n % i == 0) return false;
	}
	return true;
}

void init(ll n = 2e5){
	pn.pb(2);
	REP(num, 3, n) if(isPrime(num)) pn.pb(num);
}

VecP primeFactorization(ll n){
	VecP res;

	for(ll i : pn){
		ll cnt = 0;
		while(n % i == 0){
			n /= i;
			cnt++;
		}
		if(cnt) res.pb({i, cnt});
		if(n < i * i) break;
	}
	if(n != 1) res.pb({n, 1});

	return res;
}

Vec divisorEnumeration(ll n){
	auto v = primeFactorization(n);

	Vec res, a, b, cp;
	res.pb(1);
	for(auto p : v){
		cp.resize(res.size());
		copy(all(res), cp.begin());
		a.resize(res.size());
		repn(k, p.sc){
			ll t = pow(p.fs, k);
			rep(i, a.size()) a[i] = cp[i] * t;
			res.insert(res.end(), all(a));
		}
	}

	sort(all(res));
	return res;
}

ll sz = 1e6 + 5;

int main(void){
	init();
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	Vec cnt(sz);
	rep(i, n) cnt[a[i]]++;

	ll ans = 0;
	rep(i, n){
		cnt[a[i]]--;
		auto v = divisorEnumeration(a[i]);
		bool flg = true;
		for (ll j : v){
			if(cnt[j]){
				flg = false;
				break;
			}
		}
		if (flg) ans++;
		cnt[a[i]]++;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 12908
from collections import Counter

n = int(input())
d = list(map(int, input().split()))

mod = 998244353
c = Counter(d)

dp = [0]*n
if d[0] == 0 and c[0] == 1:
    dp[0] = 1
else:
    dp[0] = 0

for i in range(n):
    if i == 0:
        continue
    tmp = pow(c[i-1], c[i], mod)
    dp[i] = dp[i-1]*tmp % mod

ans = dp[-1]
print(ans)


Measured memory_bytes: 19936
#include<bits/stdc++.h>
#define ll long long
#define in insert
#define pb push_back
#define endl '\n'
#define ub upper_bound
#define lb lower_bound
#define pf pop_front
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);srand(time(0));
using namespace std;
ll mod=1e9+7;
void fun()
{
	string p,q;cin>>p>>q;
	int c=0;
	for(int i=0;i<p.size();i++)
	{
		if(p[i]!=q[i])c++;
	}
	cout<<c;
}
int main()
{
    fast;
    int t=1;
    //cin>>t;
    while(t--)
    {
    	fun();
	}
}

Measured memory_bytes: 3888
#include<stdio.h>
int main(void){
    char N[3];
    int i, check=0;
    scanf("%s", N);
    for(i=0; i<3; i++){
        if(N[i]=='7'){
            check=1;
        }
    }
    if(check==0){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}

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

int main() {
    string o, e; cin >> o >> e;
    for (int i=0; i<o.size(); ++i) {
        cout << o[i];
        if (i != o.size()-1) cout << e[i];
        if (o.size() == e.size() && i == o.size()-1) {
            cout << e[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 256