akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t n;
  cin >> n;
  vector<int64_t> p(n);
  rep(i,n) cin >> p.at(i);
  int64_t minnum = 200001;
  int64_t cnt = 0;
  rep(i,n){
    if(p.at(i) <= minnum){
      cnt++;
      minnum = p.at(i);
    }
  }
  cout << cnt << endl;
}

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

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	int a;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
	}
	--n;
	cout<<(n+k-2)/(k-1)<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
dp = [-1]*N


def dfs(n):
    global dp
    if dp[n] >= 0:
        return dp[n]

    ma = 0
    for b in G[n]:
        ma = max(ma, dfs(b) + 1)
    dp[n] = ma
    return ma


def main():
    for i in range(N):
        dfs(i)
    print(max(dp))


if __name__ == '__main__':
    main()


Measured memory_bytes: 59056
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;


int n;

int a[120000];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);
	int pr = 0;
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ll k = (a[i] - 1) / (pr + 1);
		ans += k;
		if (k == 0)
			pr = max(pr, a[i]);
		else
			pr = max(pr, 1);
	}
	cout << ans << "\n";
	return 0;
}




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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  vector <string> s;
  for(int i = 0; i < n; i++) {
    string t;
    cin >> t;
    s.push_back(t);
  }

  vector < map<char, int> > mp;
  for(int i = 0; i < n; i++) {
    map<char, int> mpp;
    for(int j = 0; j < s[i].length(); j++) {
      mpp[s[i][j]]++;
    }
    mp.push_back(mpp);
  }

  for(char c = 'a'; c <= 'z'; c++) {
    int mn = 50;
    for(int i = 0; i < n; i++) {
      mn = min(mn, mp[i][c]);
    }
    for(int i = 0; i < mn; i++) {
      cout << c;
    }
  }

  cout << endl;
}

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

int main() {
  int i, b_cnt = 0;
  long long sum = 0;
  int N = 2 * pow(10, 5);
  vector<char> ishi(N);
  for (i = 0; i < N; i++) {
    cin >> ishi.at(i);
  }
  for (i = 0; i < ishi.size(); i++) {
    if (ishi.at(i) == 'B') b_cnt++;
    else if (ishi.at(i) == 'W') sum += b_cnt;
  }
  cout << sum << endl;
}



Measured memory_bytes: 384
n,m = map(int,input().split())

li1 = [False] * n
lin = [False] * n

for _ in range(m):
    a,b = map(int,input().split())
    if a == 1:
        li1[b-1] = True
    elif b == n:
        lin[a-1] = True

for i in range(n):
    if li1[i] and lin[i]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')


Measured memory_bytes: 6132
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

void dfs(vvi &g, vi &sum, vi &pass, int pos, int num){
    sum[pos]+=num;
    // fin(pos);
    rep(i,g[pos].size()){
        if(pass[g[pos][i]]==1)continue;
        pass[g[pos][i]]=1;
        dfs(g,sum,pass,g[pos][i], sum[pos]);
    }
}

int main(void) {
    
    int n,q;
    cin>>n>>q;
    vi a(n),b(n);
    vvi g(n,vi(0));
    rep(i,n-1){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        g[a[i]].pb(b[i]);
        g[b[i]].pb(a[i]);
    }
    vi pass(n,0);
    vi sum(n,0);
    rep(i,q){
        int p,x;
        cin>>p>>x;
        sum[p-1]+=x;
    }
    pass[0]=1;
    dfs(g,sum,pass,0,0);
    rep(i,n){
        if(i==0)cout<<sum[i];
        else cout<<' '<<sum[i];
    }
    cout<<endl;
}


Measured memory_bytes: 20992
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> x(n);
  vector<int> y(n);
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }
  vector<int> rect(4,0);
  for(int i=0;i<n;i++){
    if(x[i]+y[i]>x[rect[0]]+y[rect[0]]){
      rect[0]=i;
    }
    if(x[i]-y[i]>x[rect[1]]-y[rect[1]]){
      rect[1]=i;
    }
    if(y[i]-x[i]>y[rect[2]]-x[rect[2]]){
      rect[2]=i;
    }
    if(x[i]+y[i]<x[rect[3]]+y[rect[3]]){
      rect[3]=i;
    }
  }
  cout<<max(abs(x[rect[0]]-x[rect[3]])+abs(y[rect[0]]-y[rect[3]]),abs(x[rect[1]]-x[rect[2]])+abs(y[rect[1]]-y[rect[2]]))<<endl;
}

Measured memory_bytes: 4792
using System;
using System.Collections.Generic;

class Program
{
	public static int Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split(' ');
		int sum = 0;
		for (int i = 0; i < str.Length;i++){
			sum += int.Parse(str[i])-1;
		}
		Console.WriteLine(sum);
		return 0;
	}
}


Measured memory_bytes: 13212
#include<stdio.h>

#define N 8
#define FREE -1
#define NOT_FREE -2

int row[N], col[N], dpos[2*N-1], dneg[2*N-1];
int Q[N][N];

void initialize()
{
  int i, j;
  
  for( i=0; i<N; i++ )
    {
      row[i] = FREE;
      col[i] = FREE;
    }
  for( i=0; i<2*N-1; i++ )
    {
      dpos[i] = FREE;
      dneg[i] = FREE;
    }

}

void printBoard()
{
  int i, j;

  for( i=0; i<N; i++ )
    {
      for( j=0; j<N; j++ )
	{
	  if( Q[i][j] )
	    {
	      if( row[i] != j ) return;
	    }
	}
    }
  
  for( i=0; i<N; i++ )
    {
      for( j=0; j<N; j++ )
	{
	  if( row[i] == j ) printf("Q");
	  else printf(".");
	  if( j == N-1 ) printf("\n");
	}
    }

}


void putQueen( int i )
{
  int j;

  if( i == N )
    {
      printBoard();
      return;
    }

  for( j=0; j<N; j++ )
    {
      if( col[j] == NOT_FREE || dpos[i+j] == NOT_FREE ||
	  dneg[i-j+N-1] == NOT_FREE ) continue;

      row[i] = j;  /*put a queen at (i, j)*/
      col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;  

      putQueen(i+1); /*try the next row*/
      
      col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
    }
  
}


int main()
{
  int i, j, k, r, c;

  initialize();

  for( i=0; i<N; i++ )
    {
      for( j=0; j<N; j++ )
	{
	  Q[i][j] = 0;
	}
    }
  
  scanf("%d", &k);

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

  putQueen(0);

  return 0;
}



Measured memory_bytes: 2112
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 10010;
const int INF = 2147483600;
const LL Mod = 1000000007LL;

int N; int a[MAXN+1]; 

int f[19][MAXN+1],g[19][MAXN+1],Log2[MAXN+1],mn;
inline LL Pow(LL a,LL b){
	LL ret=1; for(;b;b>>=1,a=a*a%Mod) if(b&1) ret=ret*a%Mod; return ret;
}
inline int qry(int l,int r){
	int x=Log2[r-l+1]; mn=min(f[x][l],f[x][r-(1<<x)+1]);
	if(f[x][l]<=f[x][r-(1<<x)+1]) return g[x][l];
	else return g[x][r-(1<<x)+1];
}
inline void Init(){
	for(int i=1;i<N;i++) f[0][i]=a[i],g[0][i]=i;
	for(int i=2;i<N;i++) Log2[i]=Log2[i>>1]+1;
	for(int j=1;j<=15;j++){
		for(int i=1;i+(1<<j)-1<N;i++){
			f[j][i]=min(f[j-1][i],f[j-1][i+(1<<(j-1))]); g[j][i]=INF;
			if(f[j-1][i]==f[j][i]) g[j][i]=min(g[j][i],g[j-1][i]);
			if(f[j-1][i+(1<<(j-1))]==f[j][i]) g[j][i]=min(g[j][i],g[j-1][i+(1<<(j-1))]); 
		}
	}
} int cnt; LL Len[MAXN+1],ln[MAXN+1],rn[MAXN+1],To[MAXN+1]; LL Sum[MAXN+1];
int nxt[MAXN+1];
inline int div(int base,int l,int r){
	int x=qry(l,r); int bs=mn,id=cnt+1,nx; ln[++cnt]=l; rn[cnt]=r; Sum[cnt]=bs-base; Len[cnt]=Sum[cnt];
	int last=l-1; while(x<=r&&x){ if(last+1<x) {nx=div(bs,last+1,x-1); Sum[id]+=Sum[nx];} last=x; x=nxt[x]; } 
	if(last<r) nx=div(bs,last+1,r),Sum[id]+=Sum[nx];
	To[id]=cnt+1;
	return id;
}
int b[MAXN+1],pos[MAXN+1]; LL h[MAXN+1]; LL Pw2[MAXN+1];

int main(){
	//freopen("a.in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); LL anspw=0;
	for(int i=1;i<=N;i++) a[i]=read();
	if(N==1){
		printf("%lld\n",Pow(2,a[1])); return 0;
	}
	for(int i=1;i<=N;i++){
		if(a[i]>a[i-1]&&a[i]>a[i+1]){
			int d=a[i];
			a[i]=max(a[i-1],a[i+1]); anspw+=d-a[i];
		}
	} for(int i=1;i<=N;i++) a[i]--;
	for(int i=1;i<N;i++) a[i]=min(a[i],a[i+1]),b[i]=a[i];
	sort(b+1,b+N); int n=unique(b+1,b+N)-b-1;
	for(int i=1;i<N;i++){
		int c=lower_bound(b+1,b+n+1,a[i])-b;
		nxt[pos[c]]=i; pos[c]=i;
	} Init(); div(0,1,N-1);
	h[1]=1; Pw2[0]=1;
	for(int i=1;i<=N;i++) Pw2[i]=Pw2[i-1]*2%Mod;
	ln[cnt+1]=rn[cnt+1]=N;
	for(int i=1;i<=cnt;i++){
		if(!To[i]) To[i]=cnt+1;
		(h[To[i]]+=h[i]*((Pow(2,Sum[i])-Pow(2,Sum[i]-Len[i])+Mod)%Mod)%Mod*Pw2[ln[To[i]]-rn[i]-1]%Mod)%=Mod;
		(h[i+1]+=h[i]*((Pw2[ln[i+1]-ln[i]]+Mod)%Mod)%Mod)%=Mod;
	} 	printf("%lld\n",h[cnt+1]*Pow(2,anspw)%Mod*2%Mod);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  map<char,int>	data;
  for(int i=0;i<4;i++){
    char c;	cin >> c;
    data[c]++;
  }
  
  if(data.size()==2){
    bool	ok=true;
    for (auto p : data) {
      auto v = p.second;
      if(v!=2)	ok=false;
    }
    if(ok)	cout << "Yes";
    else	cout << "No";
  }
  else cout << "No";
}

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

int main() {
  string S;
  cin >> S;
  int size = S.size();
  if(S.at(size - 1) == 's'){
    cout << S + "es" << endl;
  }
  else{
    cout << S + "s" << endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define IOS                \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0);
#define int long long
const unsigned int M = 1000000007;
using namespace std;
int32_t main()
{
  IOS int t = 1;
  string s, s1;
  cin >> s >> s1;
  int ans = 0;
  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] != s1[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3804
#include<stdio.h>
#include<string.h>
int main() 
{
	int x;
	scanf("%d", &x);
	char Str[100];
	scanf("%s", Str);
	if(x%2 != 0)
	{
		printf("No\n");
		return 0;
	}
	int N2 = x/2;
	int s1 = 0;
	int s2 = 0;
	char C1[50];
	char C2[50];
	for(int i = 0;i < N2; i++)
	{
		C1[i]=Str[i];
		s1 += C1[i];
	}
	for(int j = N2;j < x; j++)
	{
		C2[j-N2]=Str[j];
		s2 += C2[j-N2];
	}
	if(s1 == s2 &&(s1 != 0 && s2 != 0))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vi adj[155];
ii ans = mp(ll(1e18),ll(1e18));

ll child[155];
ll h[155];
ll maxc[155];

void dfs(int u, int p=-1)
{
	child[u]=0;
	for(int v:adj[u])
	{
		if(v==p) continue;
		h[v]=h[u]+1;
		dfs(v,u);
		child[u]++; 
	}
}

int n; 

void solve_center(int r)
{
	h[r]=0; dfs(r);
	memset(maxc,0,sizeof(maxc));
	ll maxh=0;
	for(int i=0;i<n;i++)
	{
		maxc[h[i]]=max(maxc[h[i]],child[i]); maxh=max(maxh,h[i]);
	}
	ii res = mp(maxh+1,1);
	for(int i=0;i<=maxh;i++)
	{
		if(maxc[i]>0) res.se*=maxc[i];
	}
	if(maxc[0]==1) res.se++;
	ans=min(ans,res);
}

void solve_edge(int u, int v)
{
	h[u]=0; h[v]=0;
	dfs(u,v); dfs(v,u);	memset(maxc,0,sizeof(maxc));
	ll maxh=0;
	for(int i=0;i<n;i++)
	{
		maxc[h[i]]=max(maxc[h[i]],child[i]); maxh=max(maxh,h[i]);
	}
	ii res = mp(maxh+1,2);
	for(int i=0;i<=maxh;i++)
	{
		if(maxc[i]>0) res.se*=maxc[i];
	}
	ans=min(ans,res);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int u,v; cin>>u>>v; u--; v--; adj[u].pb(v); adj[v].pb(u);
	}
	//solve center
	for(int i=0;i<n;i++)
	{
		solve_center(i);
	}
	//solve central edge
	for(int i=0;i<n;i++)
	{
		for(int v:adj[i])
		{
			if(i<v) solve_edge(i,v);
		}
	}
	cout<<ans.fi<<' '<<ans.se<<'\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (void)
{
    intmax_t A, B;
    intmax_t ans = 0;

    scanf("%jd%jd", &A, &B);

    while (((A - 1) * ans + 1) < B) ans++;

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#define int long long
#define ll long long
using namespace std;
signed main() {
	int a, b, cnt = 0;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i / 10000 == i % 10 && (i % 10000 - i % 1000) / 1000 == (i % 100 - i % 10) / 10)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;

typedef vector<int> vi;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;                   
const int MAXN = 300500; 

int a[MAXN], b[MAXN], c[MAXN];
int n;

int func(int a[], int c[]) {
    for (int i = 1; i <= n; i++) {
        if (c[i] == a[i]) {
            continue;
        }
        else {  
            int cnt = 1;
            while (next_permutation(c + 1, c + n + 1)) {
                cnt++;
                bool ok = 0;
                for (int i = 1; i <= n; i++) {
                    if (a[i] != c[i]) {
                        ok = 1;
                        break;
                    }
                }
                if (!ok) {
                    return cnt;         
                }
            }
        }
    }
    return 1;
}

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

    for (int i = 1; i <= n; i++) {
        cin >> b[i];
        c[i] = i;
    }

    int l = func(a, c);
    for (int i = 1; i <= n; i++) {
        c[i] = i;
    }
    int r = func(b, c);
    cout << abs(l - r);
}

int main() {      
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);   
    int tt = 1;
    
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin >> N >> K;
    vector<int> A(N+2,0);
    for(int i=1; i<=N; i++){
        cin >> A[i];
    }
    for(int i=0; i<K; i++){
        vector<int> nxt(N+2,0);
        for(int j=1; j<=N; j++){
            nxt[max(1,j-A[j])]++;
            nxt[min(N+1,j+A[j]+1)]--;
        }
        for(int j=1; j<=N; j++){
            nxt[j+1] += nxt[j];
        }
        bool fin = true;
        A = nxt;
        for(int j=1; j<=N; j++){
            if(A[j] < N) fin = false;
        }
        if(fin) break;
    }
    for(int i=1; i<=N; i++){
        cout << A[i] << " \n"[i == N];
    }
    return 0;
}

Measured memory_bytes: 5004
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main(void) {
  int k;
  int init, num;
  char tmp[5000];
  scanf("%s", tmp);
  scanf("%d", &k);
  string s = tmp;

  vector<string> substring;

  // cout << s << endl;

  for (init = 0; init <= s.size(); init++) {
    for (num = 1; num <= s.size()-init; num++) {
      string candidate = s.substr(init, num);
      // cout << candidate << endl;
      if (substring.size() == k && candidate > substring.back()) {
        break;
      }
      for (int j = 0; j < k; j++) {
        if (substring.size() == j) {
          substring.insert(substring.begin() + j, candidate);
          break;
        }
        if (candidate == substring[j]) {
          break;
        }
        if (candidate < substring[j]) {
          substring.insert(substring.begin() + j, candidate);
          if (substring.size() > k) {
            substring.pop_back();
          }
          break;
        }
      }
    }
  }
  cout << substring.back() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;

void solve()
  {
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   bool turn = 0;
   while(1)
     {
      if(!turn)
         {
           c -= b;
           if(c <= 0)
             {
              cout<<"Yes";
              return;
             }
           turn = 1;
         }
      else
         {
          a -= d;
          if(a <= 0)
             {
              cout<<"No";
              return;
             }
          turn = 0;
         }
     }
  }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
   /*int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1,tt;
const ll nax=2e18;
void solve(){
	ll x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef double Real;
typedef complex<Real> P;

int n;
pair<P,Real> walls[125];

bool hit(pair<P,Real> wall, Real tx,Real ty,Real sx,Real sy){
    P o = wall.first;
    Real r = wall.second;
    P t = P(tx,ty);
    P s = P(sx,sy);
    // s to origin
    o -= s;
    t -= s;
    // t on x axis
    if(s==t)return false;
    o = (o / t) * abs(t);
    
    Real d = r*r - o.imag()*o.imag();
    if(d < 0.0)return false;
    Real x0 = o.real() + sqrt(d);
    Real x1 = o.real() - sqrt(d);
    Real tb = abs(t);
    if(0.0 <= x0 && x0 <= tb)return true;
    if(0.0 <= x1 && x1 <= tb)return true;
    return false;
}

int main(void){
    // Here your code !
    while(true){
        scanf("%d",&n);
        if(n==0)break;
        REP(i,n){
            Real x,y,r;
            scanf("%lf%lf%lf",&x,&y,&r);
            walls[i] = make_pair(P(x,y),r);
        }
        int m;
        scanf("%d",&m);
        while(m--){
            Real tx,ty,sx,sy;
            scanf("%lf%lf%lf%lf",&tx,&ty,&sx,&sy);
            bool ishit = false;
            REP(i,n)if(hit(walls[i],tx,ty,sx,sy)){
                ishit = true;
                break;
            }
            puts(ishit?"Safe":"Danger");
        }
    }
}

Measured memory_bytes: 3244
#include<stdio.h>
int main()
{
    char s1[1000000],s2[1000000];
    int i,len,j=0;
    gets(s1);
    gets(s2);
    len=strlen(s1);
    for(i=0;i<len;i++){
        if(s1[i]!=s2[i])
            j++;
    }
    printf("%d\n",j);
}


Measured memory_bytes: 2000
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int n;
bool yes;
char str[400];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n*2;i++)
	{
		scanf("%c",&str[i]);
		if(str[i]=='Y')
		{
			yes=true;
//			break;
		}
	}
	if(yes) printf("Four");
	else printf("Three");
	return 0;
}

Measured memory_bytes: 256
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define input(A) for(auto &i:A) cin>>i;
signed main()
{
    fasino
    ll n;
    cin>>n;
    ll k = ceil(n/1000.00);
    cout << k*1000 - n;
    return 0;
}

Measured memory_bytes: 3760
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    long long n,m;cin>>n>>m;
    vector<string> a(n);
    vector<vector<long long>> dp(n,vector<long long>(m,0));
    for(int i=0;i<n;++i)cin>>a[i];
    dp[0][0] = 1;
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            if(a[i][j]=='.'){
                if(i>0)dp[i][j]+=dp[i-1][j];
                if(j>0)dp[i][j]+=dp[i][j-1];
                dp[i][j] %= M;
            }
        }
    }
    cout<<dp[n-1][m-1]<<endl;
    return 0;
}

Measured memory_bytes: 9216
#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(){
ll a;
ll sum=0;
ll ans=infll;
ll hiku[5];
for(int i=0;i<5;i++){
    cin>>a;
    ll tmp=0;
    while((a+tmp)%10>0){
        tmp++;
    }
hiku[i]=tmp;
sum+=a+tmp;
}
for(int i=0;i<5;i++){
    chmin(ans,sum-hiku[i]);
}
cout<<ans<<endl;

}












Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	cin >> N;
	vector<int> cnt(N, 0);
	REP(i, N) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	bool zero = false;
	if (N % 2) {
		if (cnt[0] != 1) zero = true;
		else {
			for (int i = 2;i <= N - 1;i += 2) {
				if (cnt[i] != 2) {
					zero = true;
					break;
				}
			}
		}
	}
	else {
		for (int i = 1;i <= N - 1;i += 2) {
			if (cnt[i] != 2) {
				zero = true;
				break;
			}
		}
	}
	int res = 0;
	if (!zero) {
		res = 1;
		const int mod = 1000000007;
		REP(i, N / 2) res = res * 2 % mod;
	}
	cout << res << "\n";
	
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10,INF=0x3f3f3f3f;
int n,q,op,x;
ll now;
struct segtree{
	int n;
	struct node{int l,r,mn;}e[N<<2];
	#define l(p) e[p].l
	#define r(p) e[p].r
	#define m(p) e[p].mn
	void bld(int p,int l,int r){
		l(p)=l;r(p)=r;m(p)=n;
		if(l==r){return;}
		int mid=l+r>>1;
		bld(p<<1,l,mid);bld(p<<1|1,mid+1,r);
	}
	void init(int _n){n=_n;bld(1,1,n);}
    void Min(int p,int ql,int qr,int v){
        if(ql<=l(p)&&r(p)<=qr){
            m(p)=min(m(p),v);
            return;
        }
		int mid=l(p)+r(p)>>1;
        if(ql<=mid)Min(p<<1,ql,qr,v);
		if(qr>mid)Min(p<<1|1,ql,qr,v);
    }
	int ask(int p,int x){
		if(l(p)==r(p))return m(p);
		int mid=l(p)+r(p)>>1;
		int ans=m(p);
		if(x<=mid)ans=min(ans,ask(p<<1,x));
		else ans=min(ans,ask(p<<1|1,x));
		return ans;
	}
}row,col;
int main(){
    scanf("%d%d",&n,&q);
    now=1ll*(n-2)*(n-2);
    row.init(n);
    col.init(n);
    for(int i=1;i<=q;++i){
        scanf("%d%d",&op,&x);
        if(op==1){
            int pos=col.ask(1,x);
            now-=pos-2;
            row.Min(1,1,pos-1,x);
        }
        else{
            int pos=row.ask(1,x);
            now-=pos-2;
            col.Min(1,1,pos-1,x);
        }
    }
    printf("%lld\n",now);
    return 0;
}


Measured memory_bytes: 16020
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

bool flag[100001];

int main() {
	int cnt = 0;
	makei(N);
	vi a = { 0 };
	rep(N) {
		int x;
		cin >> x;
		a.push_back(x);
	}
	int x = 1;
	while (true) {
		if (flag[x]) {
			say(-1);
			re;
		}
		else if (x == 2) {
			say(cnt);
			re;
		}
		else {
			flag[x] = true;
			++cnt;
			x = a[x];
		}
	}
}

Measured memory_bytes: 892
/*#### bits/stdc++.h */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<deque>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
/*####*/
#define ran 222222
char s[ran];
map<int,int> Map;
void chk(int&x,int y){
	if(Map.count(y)==0)return;
	if(x == -1 || x > Map[y] + 1)
		x = Map[y] + 1;
}
int main(){
	scanf("%s",s);
	Map[0] = 0;
	int mask = 0, bes;
	for(int i=0; s[i]; i++){
		mask ^= 1<<(s[i]-'a');
		bes = -1;
		chk(bes, mask);
		for(int i=0; i<26; i++)
			chk(bes, mask^(1<<i));
		if(Map.count(mask) == 0)
			Map[mask] = bes;
		else
			Map[mask] = min(Map[mask], bes);
	}
	printf("%d\n",bes);
	return 0;
}


Measured memory_bytes: 9856
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll x, a;
    cin >> x >> a;

    if (x < a)
            cout << 0 << endl;
    else
            cout << 10 << endl;

    return 0;
}


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

#define N 100 //史跡の数

int main(void) {
	int n, m;
	int a, b, d;
	int road[N][N]; //添え字から添え字への距離を1/100に縮小したもの
	bool ruin[N]; //通った史跡はtrue
	int count; //通った史跡の数
	int ans; //灯篭の数
	int min_a, min_b;
	
	while(true) {
		cin >> n;
		if(n == 0) break;
		
		//初期化
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < n; ++j) {
				road[i][j] = INT_MAX;
			}
			ruin[i] = false;
		}
		count = 0;
		ans = 0;
		
		cin >> m;
		
		for(int i = 0; i < m; ++i) {
			scanf("%d,%d,%d", &a, &b, &d);
			road[a][b] = road[b][a] = d / 100;
		}
		
		ruin[0] = true; //始点は0
		++count; //始点をカウント
		while(count != n) {
			min_a = min_b = 0; //road[0][0]はINT_MAXだから番兵として利用
			for(int i = 0; i < n; ++i) {
				if(ruin[i]) {
					for(int j = 0; j < n; ++j) {
						if(road[i][j] < road[min_a][min_b] && !ruin[j]) {
							min_a = i;
							min_b = j;
						}
					}
				}
			}
			
			ans += road[min_a][min_b] - 1;
			ruin[min_b] = true;
			++count;
			road[min_a][min_b] = road[min_b][min_a] = INT_MAX;
		}
		
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3196
N, a, b = gets.chomp.split(' ').map(&:to_i)
ans = 0
(1..N).each do |i|
  numbers = i.to_s.chars.map(&:to_i)
  digit_sum = numbers.inject(:+)
  ans += i if a <= digit_sum && digit_sum  <= b
end

puts ans


Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main()
{
    int n;
    int a,b;
    std::cin>>n;
    if(n==1)
        std::cout<<"Hello World"<<endl;
    else   
    {
        std::cin>>a>>b;
        std::cout<<a+b<<endl;
    }
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	string S; cin >> S;
	int N = S.size();
	ll cnt = 0, ans = 0;

	int i = 0;
	while (i < N && S[i] != 'A') i++;
	
	while (i < N) {
		while (i < N && S[i] == 'A') cnt++, i++;
		i++;
		while (i < N && S[i-1] == 'B' && S[i] == 'C') {
			ans += cnt, i += 2;
		}
		if (i >= N) break;
		i--;
		if (S[i] != 'A') {
			cnt = 0;
			while (i < N && S[i] != 'A') i++;
		}
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+9;
ll gcd(ll a,ll b){
    ll c;
    while(b){
        c=a%b;
        a=b;
        b=c;
    }
    return a;
}
int main(){
    ll n,h,w,a;
    while(cin>>n){
        for(a=1;a<=3500;a++){
            ll zi=4,mu=n;
            for(h=a;h<=3500;h++){
                ll tzi=a+h,tmu=h*a;
                ll g=gcd(tzi,tmu);
                tzi/=g,tmu/=g;
                if(zi*tmu<=tzi*mu)continue;
                ll t1=zi*tmu-tzi*mu,t2=tmu*mu;
                g=gcd(t1,t2);
                t1/=g,t2/=g;
                /*if(a==1&&h==2){
                    cout<<t1<<' '<<t2<<endl;
                }*/
                if(t1!=1)continue;
                w=t2;goto loop;
            }
        }
        loop:
        cout<<a<<' '<<h<<' '<<w<<endl;
    }
}


Measured memory_bytes: 256
input = gets.split(" ") 
num1 = input[0].to_i
num2 = input[1].to_i

X = num1 + num2
Y = num1 - num2
Z = num1 * num2

case
  when X>=Y && X>=Z
  puts X
  when Y>=X && Y>=Z
  puts Y
  when Z>=X && Z>=Y
  puts Z
end

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <climits>
#include <unordered_map>

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif

	auto start = high_resolution_clock::now(); 

	int a, b, c;
	cin >> a >> b >> c;
	int space = a - b;
	int rem = c - space;

	cout << max(0, rem) ;

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	cin >> N >> K;
	ll a = 0;
	ll b = 0;
	ll ans = 0;
	for(ll i = 1;i<=N;i++){
		if(i%K==0)a++;
		if(K%2==0 && i%K==(K/2))b++;
	}
	ans = (ll)pow(a,3) + (ll)pow(b,3);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
int n, K, MOD, f[305][305], s[305][305], C[305][305];
int main()
{
	n = read(), K = read(), MOD = read(); for(rint k = 0; k <= K; (s[0][k]=s[0][k-1]+(f[0][k]=1))<MOD?:s[0][k]-=MOD, k++);
	for(rint i = 0, j; i <= n; i++) for(j = C[i][0] = 1; j <= i; C[i][j] = C[i-1][j]+C[i-1][j-1], C[i][j]<MOD?:C[i][j]-=MOD, j++);
	for(rint i = 1, j, k; i <= n; i++) for(k = 1; k <= K; (s[i][k]=s[i][k-1]+f[i][k])<MOD?:s[i][k]-=MOD, k++)
		for(j = 1; j <= i; f[i][k] = (f[i][k]+1ll*f[i-j][k]*s[j-1][k-1]%MOD*C[i-1][j-1])%MOD, j++); printf("%d\n",f[n][K]); return 0;
}

Measured memory_bytes: 1280
// Problem : D - Brick Break
// Contest : AtCoder - AtCoder Beginner Contest 148
// URL : https://atcoder.jp/contests/abc148/tasks/abc148_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    cin>>n;
    vi a(n);
    for(int &i : a) cin>>i;
    int cur = 1;
    for(int i=0;i<n;i++){
        if(a[i] == cur) cur++;
    }
    cur--;
    if(cur == 0) cout<<-1<<endl;
    else cout<<n-cur<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4764
from itertools import *
from bisect import *
from math import *
from collections import *
from heapq import *
from random import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    n=II()
    tt=[]
    aa=[]
    for _ in range(n):
        t,a=MI()
        tt.append(t)
        aa.append(log10(10-a)-1)
    cm=[0]
    for a in aa:
        cm.append(cm[-1]+a)
    #print(cm)
    q=II()
    for _ in range(q):
        l,r=MI()
        li=bisect_left(tt,l)
        ri=bisect_left(tt,r)
        print(pow(10,cm[ri]-cm[li]+9))

main()



Measured memory_bytes: 18672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mk make_pair
#define r(i,n) for(int i=0;i<n;i++)
int main(void){
  int n,t;
  cin>>n>>t;
  map<pair<string,string>,int>mp;
  while(n--){
    int p;
    cin>>p;
    string s[p];
    r(i,p)cin>>s[i];
    for(int i=0;i<p;i++){
      for(int j=i+1;j<p;j++){
        if(s[i]<s[j])mp[mk(s[i],s[j])]++;
        else mp[mk(s[j],s[i])]++;
      }
    }
  }vector<pair<string,string> >v;int c=0;
  for(map<pair<string,string>,int>::iterator i=mp.begin();i!=mp.end();i++){
    if((*i).second>=t){
      v.push_back((*i).first);
      c++;
    }
  }
  cout<<c<<endl;
  for(vector<pair<string,string> >::iterator i=v.begin();i!=v.end();i++){
    cout<<(*i).first<<' '<<(*i).second<<endl;
  }
  return 0;
}

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

int main(){
  int x,a;
  cin >> x >> a;
  if(x < a) cout << 0 << endl;
  else cout << 10 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int n;
  	cin >> n;
  	for(int i = 1; i<10 ; i++){
     	if(n%i == 0 && n/i <= 9){
       		cout << "Yes";
          	return 0;
        }
    }
  	cout << "No";
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(V) V.begin(), V.end()
using namespace std;
using ll = int64_t;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;

int main() {
    ll N, M;
    cin >> N >> M;
    V<ll> cnt(100, 0);
    for(ll i = 0; i < N; i++) {
        ll K;
        cin >> K;
        for(ll j = 0; j < K; j++) {
            ll A;
            cin >> A;
            cnt[A]++;
        }
    }
    ll ans = 0;
    for(ll i = 0; i < 100; i++) if(cnt[i] == N) ans++;
    cout << ans << endl;
    return 0;
}


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

int main(){
  
  int N,M;
  cin >>N>>M;
  
  vector<int> p(M);
  vector<string> S(M);
  
  for(int i=0; i < M; i++){
    cin >> p[i];
    cin >> S[i];
  }
  
  vector<bool> isAC(N,0);
  vector<int> countWA(N,0);
  
  for(int i=0; i < M; i++){
    if(isAC[p[i]-1]){
    }else{
      if(S[i] == "AC"){
        isAC[p[i]-1] = 1;
      }else{
        countWA[p[i]-1] += 1;
      }
    }
  }
  
  int ansAC = 0;
  int ansWA = 0;
  
  for(int i=0; i < N; i++){
    ansAC += isAC[i];
    if(isAC[i]) ansWA += countWA[i];
  }
  
  cout << ansAC << " " << ansWA << endl;
}

Measured memory_bytes: 6528