akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

int effort(int a,int b){
   //cout<<a<<" "<<b<<" ";
	if (((LL)a*b)>=0){
	  //  cout<< max(abs(a),abs(b))<<endl;
		return max(abs(a),abs(b));
	}
	else{
	  //  cout<< abs(b)+abs(a)+min(abs(a),abs(b))<<endl;
		return abs(b)+abs(a)+min(abs(a),abs(b));
	}
}

int main(){
	DRII(n,k);
	VI x(n);
	
	REP(i,n){
		RI(x[i]);
	}
	int mineffort=effort(x[0],x[k-1]);
	
	REPP(i,1,n-k+1){
		mineffort=min(mineffort,effort(x[i],x[i+k-1]));
	}
	printf("%d\n",mineffort);
}


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

vector<pair<ll, ll> > prime_factorize(ll N) {
  vector<pair<ll, ll> > res;
  for (ll a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    ll ex = 0;
    while (N % a == 0) {
        N /= a;
        ex++;
    }
    res.push_back({a, ex});
  }
  if (N != 1) res.push_back({N, 1});
  return res;
}

ll comb(ll b, ll a) {
  ll res = 0;
  ll mod = 1000000007;
  vector<ll> inv(min(a,b)+1);
  inv[1] = 1;
  for (int i = 2; i < inv.size(); i++) {
	inv[i] = ((mod - (mod/i))*inv[mod%i])%mod;
  }
  res++;
  for (int i = 1; i <= min(a, b); i++) {
	res *= (a+b+1-i);
	res %= mod;
	res *= inv[i];
    res %= mod;
  }
  return res;
}

int main() {
  ll N, M;
  cin >> N >> M;
  const auto &res = prime_factorize(M);
  ll ans = 1;
  for (int i = 0; i < res.size(); i++) {
    ans *= comb(N - 1, res[i].second);
    ans %= 1000000007;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5+10;
int n,m,t[N<<2],t1[N<<2],t2[N<<2];
void update(int l,int r,int k)
{
    t1[k] = t[k]+r-l,t2[k] = t[k];
    if(l!=r)
    {
        int m = l+r>>1;
        t[k<<1]=t[k];
        t[k<<1|1] = t[k]+m+1-l;
    }
    t[k] = 0;
}
int query(int l,int r,int k,int x)
{
    if(t[k]) update(l,r,k);
    if(l>x) return m+1;
    if(r<=x) return t1[k];
    int m = l+r>>1;
    int a = query(l,m,k<<1,x),b = query(m+1,r,k<<1|1,x);
    if(x<=r) a+= x>=m?x-m:0;
    else a+=r-m;
    t2[k] = min(t2[k<<1],t2[k<<1|1]);
    t1[k] = min(t1[k<<1]+r-m,t1[k<<1|1]);
    return min(a,b);
}
void update(int l,int r,int k,int x,int y,int d)
{
    if(t[k])update(l,r,k);
    if(r<x||l>y) return;
    if(l>=x&&r<=y)
    {
        t[k] = d+l-x;
        update(l,r,k);
        return ;
    }
    int m = l+r>>1;
    update(l,m,k<<1,x,y,d);
    update(m+1,r,k<<1|1,x,y,d);
    t2[k]= min(t2[k<<1],t2[k<<1|1]);
    t1[k] = min(t1[k<<1]+r-m,t1[k<<1|1]);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i = 1,a,b,d;i<=n;++i)
    {
        scanf("%d%d",&a,&b);
        d = min(m+1,query(1,m,1,a-1)+1);
        update(1,m,1,a,b,d);
        printf("%d\n",t2[1]>=m?-1:t2[1]+i);
    }
    return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  int ans=0;
  char now=s[0];
  irep(i,1,s.size()){
    if(s[i]!=now){
      now=s[i];
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

struct UnionFind {vector<int> par, cnt;
    UnionFind(int NV) { par.clear(); cnt.resize(NV, 1); rep(i, NV) par.push_back(i); }
    void reset() { rep(i, (int)cnt.size()) cnt[i] = 1; rep(i, (int)par.size()) par[i] = i; }
    int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
    void operator()(int x, int y) {x = operator[](x); y = operator[](y);
        if (x != y) par[x] = y, cnt[y] += cnt[x];}};

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<pll> va,vb;
  rep(i,n){
    ll x,y;
    cin >> x >> y;
    va.pb({x,i}),vb.pb({y,i});
  }
    vector<tuple<ll,ll,ll>> edges;
    sort(all(va)),sort(all(vb));

    rep(i,n-1){
      edges.pb(make_tuple(va[i+1].fi-va[i].fi, va[i].se, va[i+1].se));
      edges.pb(make_tuple(vb[i+1].fi-vb[i].fi, vb[i].se, vb[i+1].se));
    }
  sort(all(edges));

  UnionFind uf(n);
  ll ans=0;

  for(auto p:edges){
    int x,y,cost;
    tie(cost,x,y)=p;
    if(uf[x]!=uf[y]){
      uf(x,y);
      ans+=cost;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12896
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    string S;
    cin >> S;
    bool flag = true;
    REP(i, S.length()-1) {
        if (S[i] == S[i+1]) {
            flag = false; 
            break;
        }
    }
    if (flag) {
        print("Good");
    } else {
        print("Bad");
    }
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
from math import gcd
from collections import defaultdict
n=int(input())
A=defaultdict(int)
AA=defaultdict(int)
B=[]
C=[]
X=[]
mod=10**9+7
for i in range(n):
  a,b=map(int,input().split())
  if a<0:
    a=a*-1
    b=b*-1
  if a*b>0:
    l=a*b//gcd(a,b)
    A[str(l//b)+":"+str(l//a)]+=1
  elif a*b<0:
    l=a*(-b)//gcd(a,-b)
    AA[str(l//a)+":"+str(l//(-b))]+=1
  else:
    if a==0 and b==0:
      X.append(i)
    elif a==0:
      B.append(i)
    else:
      C.append(i)
E=set(list(A.keys())+list(AA.keys()))
a=1
for i in E:
  a=(a*(2**A[i]+2**AA[i]-1))%mod
a=(a*(2**len(B)+2**len(C)-1)-1)%mod
print((a+len(X))%mod)

Measured memory_bytes: 180044
N = int(input())
A = [int(x) for x in input().split()]

d = {}
for a in A:
	if a not in d:
		d[a] = 1
	else:
		d[a] += 1

ans = 0
for i in d:
	if i<=d[i]:
		ans += d[i]-i
	else:
		ans += d[i]
print(ans)

Measured memory_bytes: 18168
#include <iostream>
#include <map>
#include <queue>
#include <algorithm>
#include <complex>
#include <cassert>

using namespace std;
typedef long long ll;

typedef long double R;
typedef complex<R> P;


namespace std {
    bool operator < (P a, P b) {
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    }
    bool operator > (P a, P b) {
        return (b < a);
    }
}

const R EPS = 1e-7;
const R PI = acos(-1);

int sgn(R a) {
    if (a < -EPS) return -1;
    if (a > EPS) return 1;
    return 0;
}


bool near(P a, P b) {
    return !sgn(abs(a-b));
}

R cross(P a, P b) { return imag(conj(a)*b); }
R dot(P a, P b) { return real(conj(a)*b); }

/* 1->cclock
  -1->clock
   0->on
   2->back
  -2->front
  */
int ccw(P a, P b, P c) {
    assert(!near(a, b));
    if (near(a, c) || near(b, c)) return 0;
    int s = sgn(cross(b-a, c-a));
    if (s) return s;
    if (a > b) swap(a, b);
    if (dot(b-a, c-a) < 0) return 2;
    if (dot(a-b, c-b) < 0) return -2;
//    if (c < a) return 2;
//    if (b < c) return -2;
    return 0;
}

struct L {
    P x, y;
    L() {};
    L(P x, P y) :x(x), y(y) {};
};

P vec(const L &l) {
    return l.y - l.x;
}

R abs(const L &l) {
    return abs(vec(l));
}



struct C {
    P p;
    R r;
    C () {};
    C (P p, R r) : p(p), r(r) {};
};

R distLP(const L &l, const P &p) {
	assert(!near(l.x, l.y));
    return abs(cross(vec(l), p-l.x)/abs(l));
}

//need Intersect/distLP
int crossP(const C &c, const L &l, L &r) {
    R u = distLP(l, c.p);
    int si = sgn(u - c.r);
    if (si == 1) return 0;
    P v = (l.y-l.x) / abs(l) * P(0, -1); //l?????´???????????????????????????
    v *= u;
    if (ccw(l.x, l.y, c.p) < 0) v *= -1;
    //v?????????????????????l?????¨??????????????????????????????
    if (si == 0) {
        r.x = r.y = c.p + v;
        return 1;
    }
    r.x = c.p+v+polar<R>(sqrt(c.r*c.r - u*u), arg(vec(l)));
    r.y = c.p+v-polar<R>(sqrt(c.r*c.r - u*u), arg(vec(l)));
    return 2;
}


C ci[110];
int main() {
	while (true) {
		int n;
		cin >> n;
		if (!n) break;
		for (int i = 0; i < n; i++) {
			R x, y, r;
			cin >> x >> y >> r;
			ci[i] = C(P(x, y), r);
			assert(r);
		}
		int m;
		cin >> m;
		for (int i = 0; i < m; i++) {
			R tx, ty, sx, sy;
			cin >> tx >> ty >> sx >> sy;
			P t = P(tx, ty), s = P(sx, sy);

			bool f = true;
			for (int j = 0; j < n; j++) {
				L l;
				int cp = crossP(ci[j], L(t, s), l);
//				printf("%d %d %d\n", i, j, cp);
				if (!cp) continue;
//				cout << l.x << " " << l.y << endl;
//				cout << t << " " << s << " " << l.x << " " << ccw(t, s, l.x) << endl;
				if (!ccw(t, s, l.x) || !ccw(t, s, l.y)) {
					f = false;
					break;
				}
			}
			if (f) {
				cout << "Danger" << endl;
			} else {
				cout << "Safe" << endl;
			}
		}
	}
	return 0;
}

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

vector<int> W;

int main() {
  int N;
  cin >> N;
  int w;
  rep(i, N) {
    cin >> w;
    W.push_back(w);
  }
  int total=0;
  rep(i, N) {
    total+=W[i];
  }
  int total_tmp=0;
  rep(i, N) {
    total_tmp+=W[i];
    if(total_tmp>total/2) {
      cout << min(abs(total-total_tmp*2), abs(total-(total_tmp-W[i])*2)) << endl;
      return 0;
    }
  }
  return 0;
}



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

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;

    for(int i = 0;i < 3;i++){
        if(s[i] == t[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b;
int n;
char s[100001];
int ans;
main(){
	cin>>n;
	ans=n;
	scanf("%s",s);
	int now=0;
	while(now<n-1){
		if(s[now]==s[now+1]) --ans;
		++now;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s,t;
  cin>>s;
  cin>>t;
  int q;
  cin>>q;
  int slen=s.size();
  int tlen=t.size();

  vi sa(slen,0),sb(slen,0);
  vi ta(tlen,0),tb(tlen,0);
  rep(i,slen)
    if(s[i]=='A')sa[i]++;
    else sb[i]++;
  rep(i,tlen)
    if(t[i]=='A')ta[i]++;
    else tb[i]++;

  rep(i,slen-1){//imos                               
    sa[i+1]+=sa[i];
    sb[i+1]+=sb[i];
  }
  rep(i,tlen-1){//imos                               
    ta[i+1]+=ta[i];
    tb[i+1]+=tb[i];
  }

  rep(i,q){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;b--;c--;d--;
    ll sn=sa[b]-sb[b];//a-b                          
    ll tn=ta[d]-tb[d];//a-b                          
    if(a)sn-=sa[a-1]-sb[a-1];
    if(c)tn-=ta[c-1]-tb[c-1];
    //    cout<<sn<<" "<<tn<<endl;                   
    sn+=100000;
    tn+=100000;
    if(sn%3==tn%3)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {
	public static int getDigit(int num){
	    int digit=0;
	    while(num!=0){
	        num /= 10;
	        digit++;
	    }
	    return digit;
	}
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count =0;
		for(int i = 1;i<N+1;i++) {
			if(getDigit(i) % 2 == 1) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}

}

Measured memory_bytes: 21972
#include <stdio.h>
#include <string.h>
main(){
  char s[11111];
  int kazu=0,i;
  fgets(s,sizeof(s),stdin);
  kazu=strlen(s);
  for(i=0;i<kazu;i++){
    if(s[i]>='a' && s[i]<='z'){
      s[i]=s[i]-32;
    }
  }
  printf("%s",s);
  return 0;
}

Measured memory_bytes: 524
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int n,A,B,x[110000];
int main(){
	scanf("%d%d%d",&n,&A,&B);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	long long int ans=0;
	for (int i=1;i<n;i++)
		ans+=min(1ll*(x[i+1]-x[i])*A,1ll*B);
	cout<<ans<<endl;
}

Measured memory_bytes: 640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

char f(char c) {
	return c - 'a' + 'A';
}

int main() {

	string ans = "";

	for (int i = 0; i < 3; i++) {
		string s; cin >> s;
		ans += (s[0] - 'a' + 'A');
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

vector<int> v[26];

int main(){
	string s, t; cin >> s >> t;
	int ns = s.l_ength();
	int nt = t.l_ength();
	for( int k = 0; k < 26; ++k ){
		for( int i = 0; i < ns; ++i ){
			if( s[i]-'a' == k ){
				v[k].push_back(i);
			}
		}
	}
	ll ans = 0;
	int prev = -1;
	for( int i = 0; i < nt; ++i ){
		int c = t[i]-'a';
		if( v[c].empty() ){
			cout << -1 << endl;
			return 0;
		}
		auto itr = upper_bound( v[c].begin(), v[c].end(), prev );
		if( itr == v[c].end() ){
			auto itr = upper_bound( v[c].begin(), v[c].end(), -1 );
			ans += ns;
			prev = *itr;
		} else {
			prev = *itr;
		}
		if( i == nt-1 ) ans += (prev+1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1216
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

vector<string> s;
vector<vector<vector<int> > > cnt;

void solve(const vector<int>& index, int pos)
{
    if(index.size() == 1)
        return;

    vector<vector<int> > nextChar(27);
    for(int i : index){
        if(s[i].size() == pos)
            nextChar[26].push_back(i);
        else
            nextChar[s[i][pos]-'a'].push_back(i);
    }

    bool isSame = false;
    for(int i=0; i<27; ++i){
        if(nextChar[i].size() == index.size())
            isSame = true;
    }
    if(isSame){
        solve(index, pos+1);
        return;
    }

    for(int i=0; i<27; ++i){
        if(nextChar[i].empty())
            continue;

        for(int k : nextChar[i]){
            for(int j=0; j<27; ++j){
                cnt[k][j][i] += nextChar[j].size();
            }
        }
        solve(nextChar[i], pos+1);
    }
}

int main()
{
    int n;
    cin >> n;
    s.resize(n);
    for(int i=0; i<n; ++i)
        cin >> s[i];

    vector<int> index(n);
    for(int i=0; i<n; ++i)
        index[i] = i;
    cnt.assign(n, vector<vector<int> >(27, vector<int>(27, 0)));
    solve(index, 0);

    int q;
    cin >> q;
    while(--q >= 0){
        int k;
        string p;
        cin >> k >> p;
        -- k;

        vector<int> priority(27, -1);
        for(int i=0; i<26; ++i)
            priority[p[i]-'a'] = i;

        int ans = 1;
        for(int i=0; i<27; ++i){
            for(int j=0; j<27; ++j){
                if(priority[i] < priority[j])
                    ans += cnt[k][i][j];
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main(int argc, const char * argv[]) {
    int n, b, f, r, v;
    int i1, i2, i3;
    
    int num[4][3][10]={{{}}};
    
    n=0;
    cin >> n;
    
    for(i1=0;i1<n;i1++){
        cin >> b >> f >> r >> v;
        num[b-1][f-1][r-1] += v;
    }
    
    for(i1=0;i1<4;i1++){                    //棟
        for(i2=0;i2<3;i2++){                //階
            for(i3=0;i3<10;i3++){
                cout << " ";
                cout << num[i1][i2][i3];
            }
            cout << endl;
        }
        if(i1<3){
            cout << "####################" << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
ll mpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1){
            res=res*x%MOD;
        }
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
int main(){
    ll n,c;cin>>n>>c;
    vector<ll> a(n+10),b(n+10);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    vector<vector<ll>> dp(n+10,vector<ll>(c+10));
    vector<vector<ll>> sum(410,vector<ll>(410));
    for(int i=0;i<=400;i++){
        for(int j=1;j<=400;j++){
            sum[i][j]=sum[i][j-1]+mpow(j,i);
            sum[i][j]%=MOD;
        }
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=c;j++){
            for(int k=0;k<=j;k++){
                dp[i][j]+=dp[i-1][j-k]*(sum[k][b[i]]-sum[k][a[i]-1]+MOD)%MOD;
                dp[i][j]%=MOD;
            }
        }
    }
    cout<<dp[n][c]<<endl;
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n;i++)
using pii = pair<int,int>;
using piii = pair<pii,int>;
using ll = long long;
#define int ll
signed main(){
    int v,e; cin>>v>>e;
    vector<piii>edge;
    rep(i,e){
        int a,b,c; cin>>a>>b>>c;
        edge.push_back(piii(pii(a,b),c));
    }
    vector<string>ans;
    rep(s,v){
        vector<int>d(v,LLONG_MAX/1000);
        d[s]=0;
        rep(i,v){
            bool update=false;
            rep(j,e){
                int to,from,cost;
                to=edge[j].first.second;
                from=edge[j].first.first;
                cost=edge[j].second;
                if(d[from]==LLONG_MAX/1000)continue;
                if(d[to]>d[from]+cost){
                    d[to]=d[from]+cost;
                    update=true;
                }
            }
            
            if(i==v-1&&update==true) return puts("NEGATIVE CYCLE")*0;
        }
        string temp;
        rep(i,v){
            if(i)temp+=" ";
            if(d[i]==LLONG_MAX/1000)temp+="INF";
            else temp+=(to_string(d[i]));
        }
        ans.push_back(temp);
    }
    rep(i,v)cout<<ans[i]<<endl;
}

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

int A;
int B;

void input() {
    cin >> A;
    cin >> B;
}

int main() {
    input();

    if((A*B % 2) == 0){
        printf("Even\n");
        
    } else{
        printf("Odd\n");

    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}
int main()
{
  int x;cin>>x;
  int ans;
  while(1){
    if(IsPrime(x)){
      ans=x;
      break;
    }else{
      x++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 200000, A = 1000000000;

int count(int *aa, int n, int l) {
	int k = 0;
	for (int i = 0; i < n; i++)
		k += (aa[i] - 1) / l;
	return k;
}

int aa[N];

int main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> aa[i];
	int lower = 0, upper = A;
	while (upper - lower > 1) {
		int l = lower + upper >> 1;
		if (count(aa, n, l) <= k)
			upper = l;
		else
			lower = l;
	}
	cout << upper << '\n';
	return 0;
}


Measured memory_bytes: 4400
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define int long long 
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define MAX 1e18
#define PI 3.14159265
const int mod = 1e9 + 7;

int power(int x, int y) 
{ 
   int res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  
 
        y = y>>1; 
 
        if (x<=100000000)
        x = (long long)(x*x);
 
        //cout<<x<<'\n'; 
    } 
    return res; 
} 


void solve()
{
  int x;
  int n;
  cin>>x>>n;
  vector<int>v;

  for(int i=1;i<=n;i++){
    int a;
    cin>>a;
    v.push_back(a);


  }
  sort(v.begin(),v.end());
  if(binary_search(v.begin(),v.end(),x))
  {
    for(int i=1;i<=n;i++){
        if(binary_search(v.begin(),v.end(),x-i)){
            if(binary_search(v.begin(),v.end(),x+i)){
                ;
            }
            else{
                cout<<x+i<<endl;
                return;
            }
        }

        
        else{
            cout<<x-i<<endl;
            return;
        }
    }

}
 
  else{
    cout<<x<<endl;
}
  

   
    return;
}


   
int32_t main()
{
    solve();
    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    int n; cin >> n;
    V<int> v(n);
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        a--;
        v[i] = a;
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(v[v[i]] == i) {
            ans++;
            v[v[i]] = -1;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int k, a, b;
  cin >> a >> b;

  k = (a+b);
  if (k % 2 ==0){
    cout << (k/2);
  } else {
    cout << "IMPOSSIBLE";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int x = tmp[0], y = tmp[1];

	int[] p = new int[206];
	p[1] = 300000;
	p[2] = 200000;
	p[3] = 100000;

	int ans = p[x] + p[y] + (x == 1 && y == 1 ? 400000 : 0);
	WriteLine(ans);
    }
}

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

long long int modPow(long long int a, long long int n){//繰り返し自乗法(a^n mod p)。計算量 O(logN)
    long long int p = pow(10, 9) + 7;//任意のp(素数) modのやつで使える 
    if(n == 0){
        return 1;
    }
    if(n == 1){
        return a % p;
    }
    if (n % 2 == 1){ 
        return (a * modPow(a, n - 1)) % p;
    }      
    long long t = modPow(a, n / 2);
    return (t * t) % p;
}

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++){
        cin >> l.at(i);
    }
    
    long long int count = 0;
    for(int i = 0; i < n - 2; i++){
        for(int j = i + 1; j < n - 1; j++){
            if(l.at(i) == l.at(j)){
                continue;
            }
            for(int k = j + 1; k < n; k++){
                if(l.at(i) == l.at(k) || l.at(j) == l.at(k)){
                    continue;
                }
                if(l.at(i) + l.at(j) > l.at(k) && l.at(i) + l.at(k) > l.at(j) && l.at(j) + l.at(k) > l.at(i)){
                    count++;
                }
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for (int x=y; x<=z; x++)
#define downrep(x,y,z) for (int x=y; x>=z; x--)
#define ms(x,y,z) memset(x,y,sizeof(z))
#define LL long long
#define repedge(x,y) for (int x=hed[y]; ~x; x=edge[x].nex)
inline int read(){
	int x=0; int w=0; char ch=0;
	while (ch<'0' || ch>'9') w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w? -x:x;
}
const LL P=1e9+7;
void ex_gcd(LL a,LL b,LL c,LL &x,LL &y){
	if (!a){ x=0; y=c/b; return; }
	if (!b){ y=0; x=c/a; return; }
	ex_gcd(b,a%b,c,y,x);
	y-=(a/b)*x;
}
LL inv(LL t){
	LL x,y; ex_gcd(t,P,1,x,y); return (x%P);
}
LL C(int n,int m){
	if ((m<0)||(n<m)) return 0; if (!m) return 1; LL ans=1;
	for(int i=n; i>=n-m+1; i--) ans=(ans*i)%P;
	for(int i=1; i<=m; i++) ans=(ans*inv(i))%P;
	return ans;
}
int cnt,a[105];
int main(){
	int n=read(); int m=read(); int x=m;
	for(int i=2; i*i<=m; i++)if (!(x%i)){
		++cnt; while (!(x%i)){ ++a[cnt]; x/=i; }
	}
	if (x>1) a[++cnt]=1; LL ans=1;
	for(int i=1; i<=cnt; i++) ans=(ans*C(a[i]+n-1,n-1))%P;
	printf("%lld\n",ans); return 0;
}

Measured memory_bytes: 256
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

suba=[0]
subb=[0]

for i in range(n):
    suba.append(a[i]+suba[i])
for j in range(m):
    subb.append(b[j]+subb[j])

ans=0
j=m
for i in range(n+1):
        #print(i,j)
    if k<suba[i]:
        break

    while subb[j]>k-suba[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 126756
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(m)]
a.sort(key=lambda x:x[1])
ans = 0
x=-1
for i in range(m):
    if a[i][0]>x:
        x=a[i][1]-1
        ans +=1
print(ans)


Measured memory_bytes: 64684
s = input()
k = 0
ans = 0
tmp = -1 * float('inf')
for i in range(len(s)):
  if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
    k = k + 1
    if k >= tmp:
      tmp = k
      ans = k
  else:
    k = 0
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,s[5];

int main(){
	bool f=0;
	while(cin>>n){
		if(f)cout<<endl;
		for(int i=0;i<5;i++)s[i]=(n/(int)pow10(4-i))%10;
		for(int i=0;i<8;i++){
			for(int j=0;j<5;j++){
				if(i==0){
					if(s[j]<5)cout<<"*";
					else cout<<" ";
				}
				if(i==1){
					if(s[j]>4)cout<<"*";
					else cout<<" ";
				}
				if(i==2)cout<<"=";
				if(i>2){
					if(s[j]%5==i-3)cout<<" ";
					else cout<<"*";
				}
			}
			cout<<endl;
		}
		f=1;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
main(){
  int n,num;
  int i,j;
  int ans = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num);
    for(j=2;j<=sqrt(num*1.0)+1;j++){
      if(num%j==0){
        ans--;
        break;
      }
    }
    ans++;
    if(num==2){
      ans++;
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}

vector<pair<long long,long long>> prime_factorize(long long N){
  vector<pair<long long,long long>> res;
  
  for(long long i=2;i*i<=N;i++){
    if(N%i!=0){
    continue;
    }
    
    long long ex=0;
    while(N%i==0){
      ex++;
      N/=i;
    }
    
    res.push_back({i,ex});
  }
  
  if(N!=1){
  res.push_back({N,1});
  }
  
  return res;
}


int main() {
  
  int N;
  cin>>N;
  
  long long X=1;
  for(int i=1;i<=N;i++){
    X*=10;
    X%=MOD;
  }
  
  long long Y=1;
  for(int i=1;i<=N;i++){
    Y*=9;
    Y%=MOD;
  }
  
  long long Z=1;
  for(int i=1;i<=N;i++){
    Z*=8;
    Z%=MOD;
  }
  
  long long ans=(((X-Y)%MOD-Y)%MOD+Z)%MOD;
  
  ans%=MOD;
  
  cout<<(ans+MOD)%MOD;
}

Measured memory_bytes: 3620
import java.util.*;
import java.io.*;
 
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        
        int n = sc.nextInt();
        long[] fib = new long[n+1];
        
        fib[0]=1;
        fib[1]=1;
        for(int i=2; i <= n; i++){
            fib[i] = fib[i-1]+fib[i-2];
        }
        
        out.println(fib[n]);
        out.flush();
    }
    
}
 
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 24500
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define r_rep(i, n) for(int i = (int)n-1; i >= 0; i--)
#define ll long long
#define pb push_back
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int N; // 頂点の数
const int MAX_N = 16;
ll dp[1 << MAX_N][MAX_N];
ll d[1100][1100];

void solve(){
  // テーブルを大きな値で初期化
  for(int S = 0; S < 1 << N; S++){
    fill(dp[S], dp[S]+N, INF);
  }
  dp[(1 << N) - 1][0] = 0;

  // 漸化式に従って順に計算
  for(int S=(1 << N) - 2; S >= 0; S--){
    for(int v = 0; v < N; v++){
      for(int u = 0; u < N; u++){
        if(!(S >> u & 1)){
          dp[S][v] = min(dp[S][v], dp[S | 1 << u][u]+ d[v][u]);
        }
      }
    }
  }

  if(dp[0][0] == INF){
    cout << -1 << endl;
  } else {
    cout << dp[0][0] << endl;
  }
  
}

int main() {
  int E;
  cin >> N >> E;
  // INFで初期化
  rep(i, 1100){
    rep(j, 1100){
      d[i][j] = INF;
    }
  }

  int a, b, distance;
  rep(i, E){
    cin >> a >> b >> distance;
    d[a][b] = distance;
  }
  solve();
}



Measured memory_bytes: 16644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int n, k; cin >> n >> k;
    vint a(n);
    rep(i,n) cin >> a[i];
    vint dp(k+1);
    rep(i,k+1) {
        bool ok = false;
        for (int x : a) {
            if (i-x < 0) break;
            if (dp[i-x] == -1) ok = true;
        }
        if (ok) dp[i] = 1;
        else dp[i] = -1;
    }
    if (dp[k] == 1) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := getInt()
	as := getIntSlice(n)

	ans := make([]int, n)
	for i, a := range as {
		if i%2 == 0 {
			ans[0] += a
		} else {
			ans[0] -= a
		}
	}
	for i := n - 1; i >= 0; i-- {
		ans[i] = as[i]*2 - ans[(i+1)%n]
	}

	for _, a := range ans {
		fmt.Fprintln(wr, a)
	}
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long N; cin >> N;
    long long Ans = 1;
    constexpr long long inf = 1e18;
    for (int i = 0; i < N; i++) {
        long long a; cin >> a;
        if (a == 0) Ans = 0;
        if (Ans == -1 || Ans == 0) continue;
        if (inf / a < Ans) {
            Ans = -1;
            continue;
        }
        Ans *= a;
        if (Ans > inf) Ans = -1;
    }
    cout << Ans << "\n";
    return 0;
}

Measured memory_bytes: 3656
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
observ = [set() for _ in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    observ[a-1].add(b-1)
    observ[b-1].add(a-1)

cnt = 0
for i, o in enumerate(observ):
    height = h[i]
    flg = True
    for oh in o:
        if height <= h[oh]:
            flg = False
            break
    if flg:
        cnt += 1

print(cnt)


Measured memory_bytes: 45352
N = int(input())
Hs = list(map(int, input().split()))[::-1]
# 後ろから貪欲のほうが良くない？
pre = 10**10
for h in Hs:
    # print(h)
    if pre - h  >= 0:
        pre = h
    elif pre - h == -1:
        pre = h -1 
    else:
        print("No")
        exit(0)
print("Yes")

Measured memory_bytes: 14252
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

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

    if (n == "AAA" or n == "BBB") {
        cout << "No";
    }
    else {
        cout << "Yes";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long i64;

template <i64 MOD> struct ModInt {
  i64 value;

  ModInt(i64 v = 0) { value = v % MOD; }

  operator i64() { return value; }
  ModInt<MOD> operator+(int v) { return (value + v) % MOD; }
  ModInt<MOD> operator+(i64 v) { return (value + v) % MOD; }

  ModInt<MOD> operator-(i64 v) {
    v %= MOD;
    return (MOD + value - v) % MOD;
  }

  ModInt<MOD> operator*(i64 v) { return (value * v) % MOD; }
};

const i64 mod = 1e9 + 7;

int n,x,y,z;
int main(){
	cin >> n >> x >> y >> z;
	vector<vector<ModInt<mod>>> dp(41,vector<ModInt<mod>>(1 << 17,0));

	dp[0][0] = 1;

	int ng = (1 << (x + y + z - 1)) | (1 << (y + z - 1)) | (1 << (z - 1));

	for(int i = 1;i <= n;i++){
		for(int state = 0;state < (1 << 17);state++){
			for(int j = 1;j <= 10;j++){
				int next = (state << j) | (1 << (j - 1));
			 	next &= (1 << 17) - 1;
				if((next & ng) == ng) continue;
				dp[i][next] = dp[i][next] + dp[i - 1][state];
			}
		}
	}

	ModInt<mod> ans = 0;
	for(int i = 0;i < (1 << 17);i++){
		ans = ans + dp[n][i];
	}
	ModInt<mod> all = 1;
	for(int i = 0;i < n;i++){
		all = all * 10LL;
	}

	cout << all - ans << endl;
}


Measured memory_bytes: 43392
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
    std::cout << std::fixed << std::setprecision(10);
ll n;
cin>>n;
ll a;
double sum=0;
for(int i=0;i<n;i++){
    cin>>a;
    sum+=(double)1/a;
}
cout<<(double)(1/sum)<<endl;
}










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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> k(m);
	vector<vector<int>> s(m);
	vector<int> p(m);
	rep(i, m) {
		cin >> k[i];
		rep(j, k[i]) {
			int a;
			cin >> a;
			s[i].push_back(a);
		}
	}
	rep(i, m) cin >> p[i];

	int ans = 0;
	for (int bit = 0; bit < (1 << n); bit++) {
		bool valid = true;
		for (int i = 0; i < m; i++) {
			int sum = 0;
			for (int j : s[i]) {
				if (bit & (1 << j - 1)) sum++;
			}
			if (sum % 2 != p[i]) valid = false;
		}
		if (valid) ans++;
	}
	cout << ans << endl;
}

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

#define rep(i, x) for(int i=0;i<(x);i++)

int main(){
    float A, B;
    int A2[10], B2[10];
    cin >> A >> B;
    for(float i = 0;i < 1; i=i+0.1){
        int no = i * 10;
        A2[no] = round((A + i) / 0.08);
        B2[no] = round((B + i) / 0.1);
    }
    for(int i = 0;i < 10;i++){
        for(int j = 0;j < 10;j++){
            if(A2[i] == B2[j]){
                cout << A2[i] << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    int sum=0;
    for(int i=1;i<=n;++i)
    {
        if(i%5!=0 && i%3!=0)
            sum+=i;
    }

    cout<<sum;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3652