akhauriyash/Code-Regression huggingface dataset:
/*      ...वहां तूफान भी हार जाते हैं जहां कश्तियां जिद पर होती हैं !...        */
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define fl(i,a,n) for(int i=a; i<n; i++)
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define test()  int tt;  cin>>tt;  while(tt--)
#define nl  cout<<"\n"
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)    {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}
const int mod=1e9+7;

int main()  {
    fast;
    int n,k;    cin>>n>>k;
    vector<int> a(n);
    fl(i,0,n)   cin>>a[i];
    vector<bool> dp(k+1);
    fl(i,0,k+1)  {
        if(i<a[0])  dp[i]=false;
        else    {
            for(int j=0;j<n;j++)    {
                if(i-a[j]>=0)   {
                    if(!dp[i-a[j]])  {
                        dp[i]=true;
                        break;
                    }
                }
            }
        }
    }
    if(dp[k])   cout<<"First";
    else    cout<<"Second";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define M 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define tr(x,it) for(auto it = x.begin();it!=x.end();++it)
#define fpresent(x,c) ((c).find(x) != (c).end())  //set,map
#define present(c,x) (find(all(c),x) != (c).end()) //vector
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define setv(ar, val) memset(ar, val, sizeof(ar));
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //use mt19937_64 for 64 bit random no.

int main()
{
    // freopen("input.in","r",stdin);
    // freopen("output.in","w",stdout);
    fastio;
    cin.tie(NULL);
    ll n,m,a,b,c,i,j,k,ans=0;
    cin>>a>>b>>c>>k;

    if(k > a){
        ans += a, k-= a;
        if(k > b){
            k -= b;
            cout<<ans - k<<endl;
        }
        else
            cout<<ans<<endl;
    }
    else
        cout<<k<<endl;


    return 0;
}


Measured memory_bytes: 3656
m=gets.split[1].to_i
p gets.split
 .each_with_object([0]){|ai,o|o<<(o[-1]+ai.to_i)%m}
 .group_by{|i|i}
 .values
 .map{|i|i=i.size;i*(i-1)/2}
 .inject(:+)

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

int main( int argc, char *argv[] )
{
    int n;
    long long tot = 0;

    scanf( "%d", &n );

    for( int i=1; i<=n; i++ ) {
        if( i%3 == 0 ) continue;
        if( i%5 == 0 ) continue;
        tot += i;
    }

    printf( "%lld\n", tot );
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define LL "%I64d"
#define pb push_back
#define pp pop_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define vi vector<int>
#define vs vector<string>
#define vl vector<ll>
#define mp make_pair
#define all(v) v.begin(),v.end()
#define all(s) s.begin(),s.end()
#define ff first
#define ss second
#define endl "\n"
#define sz size()
#define r0 return 0
#define mi map<int>
#define ms map<string>
#define ml map<ll>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,b,a) for (int i=(b)-1;i>=(a);i--)
#define FORS(it,a,b) for(set<int>::iterator it=a;it!=b;it++)
#define all_sum(a,b,i) accumulate((a),(b),i)
using namespace std;
void adskiy_razgon(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int mxN=1e+9+7;
const ll INF=1e+18+7;
int nod(int a, int b) {
   if(a==0||b==0){
   	return 0;
   }
   else if(a==b){
   		return a;
   }
   else if (a>b){
   		return nod(a-b,b);
   }
   else{
   		return nod(a,b-a);
   }
}
int nok(int a,int b){
	return a*b/nod(a,b);
}
void sp(int a,double b){
	cout<<fixed<<setprecision(a)<<b;
}
void solve(){
	int a, b;
  	cin >> a >> b;
  	cout << a * b;
}
int main(){
	adskiy_razgon();
	ll t=1;
	//cin>>t;
	for(int i = 1; i <= t; ++i) {
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	r0;
}



Measured memory_bytes: 3656
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

ll comb(ll N_, ll C_) {
	const int NUM_ = 3000001;
	static ll fact[3000002], factr[3000002], inv[3000002];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%mod, factr[i] = factr[i - 1] * inv[i] % mod;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % mod*factr[N_ - C_] % mod;
}
ll modpow(ll a, ll n = mod - 2) {
	ll r = 1;
	while (n) r = r * ((n % 2) ? a : 1) % mod, a = a * a%mod, n >>= 1;
	return r;
}
const long long MAX = 500010;
long long fac[MAX], finv[MAX], inv[MAX];

void nPr_init() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

long long nPr(int n, int r) {
	if (n < 0 || r < 0 || n < r) return 0;
	return fac[n] * finv[n - r] % mod;
}

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

	nPr_init();
	int N, M; cin >> N >> M;
	int ans = 0;
	eREP(i, N) {
		int cnt = comb(N, i);
		cnt *= nPr(M, i);
		cnt %= mod;


		cnt *= nPr(M - i, N - i);
		cnt%= mod;
		cnt *= nPr(M - i, N - i);
		cnt %= mod;

		if (i & 1)cnt *= -1;
		ans += cnt;
		ans += mod;
		ans %= mod;
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 85604
#include<bits/stdc++.h>
#define YOU setprecision
using namespace std;
int i[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e,f;
  char s;
  cin >>s;
  if(s=='A') cout <<"T\n";
  if(s=='T') cout <<"A\n";
  if(s=='C') cout <<"G\n";
  if(s=='G') cout <<"C\n";
  return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    if(a.size()>b.size()){
        cout<<"GREATER"<<endl;
        return 0;
    }else if(a.size()<b.size()){
        cout<<"LESS"<<endl;
        return 0;
    }else{
        for(int i=0;i<a.size();i++){
            if(a.at(i)<b.at(i)){
                cout<<"LESS"<<endl;
                return 0;
            }else if(a.at(i)>b.at(i)){
                cout<<"GREATER"<<endl;
                return 0;
            }
        }
        cout<<"EQUAL"<<endl;
        return 0;
    }

}

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

int count = 0;

static void mergeSort(int* array, int size);
static void mergeSort_rec(int* array, int left, int right, int* work);
static void merge(int* array, int left, int right, int mid, int* work);
static void print(const int* array, int size);


void mergeSort(int* array, int size){

  int* work;
  work = malloc( sizeof(int) * size );
  mergeSort_rec( array, 0, size - 1, work );
  free( work );
  
}

void mergeSort_rec(int* array, int left, int right, int* work){

  int mid;
  
  if( right <= left ){
    return;
  }
        
  mid = (left + right) / 2;
  mergeSort_rec( array, left, mid, work );
  mergeSort_rec( array, mid + 1, right, work );

  merge( array, left, right, mid, work );
}

void merge(int* array, int left, int right, int mid, int* work){

  int i, j, k;

  for( i = left; i <= mid; ++i){
    work[i] = array[i];
  }

  for( i = mid + 1, j = right; i <= right; ++i, --j){
    work[i] = array[j];
  }

  i = left;
  j = right;
        
  for( k = left; k <= right; ++k) {
    if( work[i] <= work[j] ){
      array[k] = work[i];
      ++i;
    }
    else{
      array[k] = work[j];
      --j;
    }
    count++;
  }
}

void print(const int* array, int  size){
  size_t i;

  for( i = 0; i < size; ++i ){
    if(i == size-1) printf( "%d", array[i] );
    else printf("%d ", array[i]);
  }
  printf( "\n" );
}

int main(void)
{
  int i;
  int n;
  int array[500000];

  scanf("%d", &n);
  for(i=0; i<n; i++)
    scanf("%d", &array[i]);
  
  mergeSort( array, n);
  print( array, n);
  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 5184
#include <stdio.h>
 
// 数値のハッシュ関数
#define HASHSIZ 25013
int hash[HASHSIZ+3], *hashend = hash+HASHSIZ;
 
int lookup(int n)
{
    int *p;
     
    n++; p = hash + n % HASHSIZ;
    while (*p) {
        if (*p == n) return 1;
        if (++p == hashend) p = hash;
    }
    return 0;
}
 
void insert(int n)
{
    int *p;
     
    n++; p = hash + n % HASHSIZ;
    while (*p) {
        if (*p == n) return;
        if (++p == hashend) p = hash;
    }
    *p = n;
}
 
// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
    int n = 0, c = getchar_unlocked();
    do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
    return n;
}
 
int main()
{
    int n, q, C;
 
    n = in();
    while (n--) insert(in());
 
    C = 0;
    q = in();
    while (q--) if (lookup(in())) C++;
     
    printf("%d\n", C);
    return 0;
}



Measured memory_bytes: 2088
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int h, w, k; cin >> h >> w >> k;
  vector<vector<int> > c(w, vector<int>(h));
  REP(i, h) REP(j, w) {
    char ch; cin >> ch;
    c[j][h - 1 - i] = ch - '0';
  }
  swap(h, w);
  int ans = 0;
  function<void(vector<vector<int> >&)> solve = [&](vector<vector<int> > &sq) {
    int score = 0;
    for (int i = 0; ; ++i) {
      bool erased = false;
      vector<int> pos_y, pos_x, len;
      REP(x, w) {
        for (int y = 0; y < h;) {
          if (x >= sq[y].size()) {
            ++y;
            continue;
          }
          int z = y + 1;
          while (z < h && x < sq[z].size() && sq[z][x] == sq[y][x]) ++z;
          if (z - y >= k) {
            pos_y.emplace_back(y);
            pos_x.emplace_back(x);
            len.emplace_back(z - y);
            score += (1 << i) * sq[y][x] * (z - y);
            erased = true;
          }
          y = z;
        }
      }
      int n = pos_y.size();
      reverse(ALL(pos_y));
      reverse(ALL(pos_x));
      reverse(ALL(len));
      // REP(i, h) {
      //   REP(j, sq[i].size()) cout << sq[i][j] << ' ';
      //   cout << endl;
      // }
      // cout << "-----" << endl;
      REP(j, n) {
        for (int y = pos_y[j]; y < pos_y[j] + len[j]; ++y) {
          sq[y].erase(sq[y].begin() + pos_x[j]);
        }
      }
      if (!erased) break;
    }
    chmax(ans, score);
  };
  REP(i, h) REP(j, w) {
    vector<vector<int> > sq(c);
    sq[i].erase(sq[i].begin() + j);
    solve(sq);
  }
  cout << ans << '\n';
  return 0;
}


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

int main(void) {
	int N;
	cin >> N;
	string S;
	cin >> S;

	vector<int> s_int(N, -1);
	ll r_num = 0, g_num=0, b_num=0;
	for(int i=0; i<N; i++){
		if(S[i]=='R'){
			s_int[i] = 0;
			r_num++;
		}
		else if(S[i]=='G'){
			s_int[i] = 1;
			g_num++;
		}
		else if(S[i]=='B'){
			s_int[i] = 2;
			b_num++;
		}
	}

	ll rule1 = r_num * g_num * b_num;//条件１を満たす個数
	// ll rule1 = 1;
	// rule1 *= r_num;
	// rule1 *= g_num;
	// rule1 *= b_num;
	ll rule1_not2 = 0;//条件1を満たすが条件2を満たさない個数
	ll ans = 0; // ans = rule1 - rule1_not2;
	for(int i=0; i<N; i++){
		for(int j=i; j<N; j++){
			int k = 2*j - i;
			if(k < 0 || N <= k) continue;
			if(S[i] != S[j] && S[i] != S[k] && S[j] != S[k]){
				//cout << " i:" << i << " j: " << j << " k: " << k << endl;
				rule1_not2++;
			}
		}
	}
	
	//cout << " rule1: " << rule1 << " rule1_not2: " << rule1_not2 << endl;
	ans = rule1 - rule1_not2;
	cout << ans << endl;
}


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

int n, u, v;
int w[310];
int dp[310][310];

int main() {
  while(true){
    cin>>n;
    if(n==0) break;
    rep(i,n)w[i]=0;
    rep(i,n) cin>>w[i];

    rep(i,310)rep(j,310)dp[i][j] = 0;
    rep(i,n-1){
      if(abs(w[i+1]-w[i])<=1) dp[i][i+1]=2;
    }
    REP(k,3,n+1){
      rep(i,n-k+1){
        if(dp[i+1][i+k-1]>1 && abs(w[i]-w[i+k])<=1) dp[i][i+k]=k+1;
        rep(j,k){
          if(dp[i][i+j]>1 && dp[i+j+1][i+k]>1){
            dp[i][i+k]=k+1;
          }
        }
      }
    }
    rep(i,n)REP(j,i+1,n)REP(k,i,j){
      dp[i][j] = max(dp[i][j], dp[i][k]+dp[k+1][j]);
    }
    cout<<dp[0][n-1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int a,b,c,n=0;
	cin>>a>>b>>c;
	for(a;a<=b;a++){
		if(c%a==0) n++;
		}
	cout<<n<<endl;
	return 0;
}

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){
  double a;
  cin >> a;
  
  cout << a*6.283;

  return 0;
}


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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define inf (long long int) 1e18
#define eps 0.000001
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define mod 1000000007
#define MAXN 100001
ll spf[MAXN]; 
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);
void sieve();
ll ceil(ll a, ll b);
vl getFactorization(ll x);
void getZarr(string str, ll Z[]);


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

    ll n;
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }
    else if(n==2){
        ll a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
}

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

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

void sieve() { 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

vl getFactorization(ll x) 
{ 
    vl ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

ll ceil(ll a,ll b){
    return a/b+(a%b!=0);
}

void getZarr(string str, ll Z[]){
    ll n = str.length();
    ll L, R, k;
    L = R = 0;
    for (ll i = 1; i < n; ++i){
        if (i > R){
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        } else {
            k = i-L;
            if (Z[k] < R-i+1)
                Z[i] = Z[k];
            else {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
            }
        }
    }
}


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

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'
using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 2e5+5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
int get(char c){
  if(c=='R')return 0;
  if(c=='G')return 1;
  return 2;
}
int cntL[4005][6];
int cntR[4005][6];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
//
//  f(i,1,205)
//    f(j,1,205)
//      g[i][j]=__gcd(g[i][j]);
//
//  int k ;
//  cin >> k;
//  int ans = 0;
//  f(i,1,k+1)
//    f(j,1,k+1)
//      f(k1,1,k+1)
//        ans+=g[i][g[j][k1]];
//
//  cout<<ans<<'\n';

  string s;

  cin >>s>> s;

  f(i,1,s.size()){
    f(j,0,3)cntL[i][j]=cntL[i-1][j];
    cntL[i][get(s[i-1])]++;
  }
  for(int i = s.size()-2;i>=0;--i){
    f(j,0,3)cntR[i][j]=cntR[i+1][j];
    cntR[i][get(s[i+1])]++;
  }
  ll ans = 0;
  for(int i = 0; i < s.size(); i++)
    for(int j = i + 1; j < s.size(); j++){
      int lft = 3 ^ get(s[i])^get(s[j]);
      int tmp = cntL[i][lft];
      int d = j - i;
      if(i-d>=0&&get(s[i-d])==lft)tmp--;
//      cout<<i<<' '<<j<<' '<<tmp<<'\n';
      ans+=tmp;
    }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s;
  cin >> s;
  ll cnt = 0, ans = 0;
  if (s[0] == 'B') cnt++;
  for (int i = 1; i < (int)s.length(); ++i) {
    if (s[i] == 'B') cnt++;
    if (s[i] == 'W') ans += cnt;
  }
  cout << ans << endl;
  return 0;
}

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

#define int long long
typedef pair<int, int> P;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int N;
string S[330];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                if (S[(i + j) % N][k] != S[(k + i) % N][j]) {
                    goto check;
                }
            }
        }
        ans += N;
    check:;
    }
    cout << ans << endl;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i = 0;i < n;i ++){
        int a;
        cin >> a;
        mp[min(a/400,8)] ++;
    }
    int m=mp.size()-min(1,mp[8]);
    if(mp.size()==1&&mp[8]>0) cout << 1 << " " << mp[8] << endl;
    else {
        cout << m << " " << m + mp[8] << endl;
    }
    return 0;
 }

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

using namespace std;

using ll = long long;

int main(){
    string s;
    cin >> s;
    ll arr[1000] = {0};
    for(ll i = 0; i < s.length(); ++i){
        arr[s[i]]++;
    }
    for(ll i = 97; i < 1000; ++i){
        if(i >= 123){
            cout << "None";
            return 0;
        }
        else if(arr[i] == 0){
            cout << (char)i;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 512
mod stdin_reader {
  use std::io::stdin;
  use std::io::Read;

  pub struct StdinReader {
    pub buf: Vec<String>,
    pub cursor: usize,
  }

  pub fn new() -> StdinReader {
    StdinReader::new()
  }

  impl StdinReader {
    pub fn new() -> Self {
      let mut s = String::new();
      let stdin = stdin();
      stdin.lock().read_to_string(&mut s).unwrap();
      let buf = s.split_whitespace().map(|s| s.to_string()).collect();
      return StdinReader { buf: buf, cursor: 0 }
    }

    pub fn read_all(&self) -> Vec<String> {
      return self.buf.clone()
    }

    pub fn next(&mut self) -> Option<String> {
      let val = self.buf.get(self.cursor).cloned();
      self.cursor += 1;
      return val
    }

    pub fn as_i64(&mut self) -> Option<i64> {
      self.next().and_then(|s| s.parse::<i64>().ok())
    }

    pub fn as_f64(&mut self) -> Option<f64> {
      self.next().and_then(|s| s.parse::<f64>().ok())
    }

    pub fn as_usize(&mut self) -> Option<usize> {
      self.next().and_then(|s| s.parse::<usize>().ok())
    }
  }
}

mod utils {
  pub fn is_int(n: f64) -> bool {
    let trunc = (n.trunc() as i64) as f64;
    return (n - trunc) < 0.0001
  }
}

fn main() {
  // stdout
  use std::io::{stdout, Write, BufWriter};
  let stdout = stdout();
  let mut writer = BufWriter::new(stdout.lock());

  // stdin
  let mut reader = stdin_reader::new();

  let n = reader.as_usize().unwrap();
  let a_list: Vec<_> = (0..n).map(|_| reader.as_i64().unwrap()).collect();

  let mut a_list_sorted = a_list.clone();
  a_list_sorted.sort();
  let max = a_list_sorted[n-1];
  let second_max = a_list_sorted[n-2];

  let mut a_max_i = 0;
  for i in (0..n) {
    if a_list[i] > a_list[a_max_i] {
      a_max_i = i;
    }
  }
  for i in (0..n) {
    if i == a_max_i {
      writeln!(writer, "{}", second_max);
    } else {
      writeln!(writer, "{}", max);
    }
  }
}

Measured memory_bytes: 16140
#include <stdio.h>

int main(void) {
  int A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;

  scanf("%d", &K);

  printf("%d\n", A[K - 1]);
  return (0);
}


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


class BIT():
    """区間加算、区間取得クエリをそれぞれO(logN)で答える
    add: 区間[l, r)にvalを加える
    get_sum: 区間[l, r)の和を求める
    l, rは0-indexed
    """
    def __init__(self, n):
        self.n = n
        self.bit0 = [0] * (n + 1)
        self.bit1 = [0] * (n + 1)

    def _add(self, bit, i, val):
        i = i + 1
        while i <= self.n:
            bit[i] += val
            i += i & -i

    def _get(self, bit, i):
        s = 0
        while i > 0:
            s += bit[i]
            i -= i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(self.bit0, l, -val * l)
        self._add(self.bit0, r,  val * r)
        self._add(self.bit1, l,  val)
        self._add(self.bit1, r, -val)

    def get_sum(self, l, r):
        """区間[l, r)の和を求める"""
        return self._get(self.bit0, r) + r * self._get(self.bit1, r) \
               - self._get(self.bit0, l) - l * self._get(self.bit1, l)


n, q = map(int, input().split())
query = [list(map(int, input().split())) for i in range(q)]
bit = BIT(n)

for i in range(q):
    if query[i][0] == 0:
        _, l, r, x = query[i]
        bit.add(l-1, r, x)
    else:
        _, l, r = query[i]
        print(bit.get_sum(l-1, r))


Measured memory_bytes: 31744
#include<iostream>
#include<string.h>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
int main()                         
{
int A,B;
cin>>A>>B;
cout<<(A-1)*(B-1); 
system("pause");
return 0;
}


Measured memory_bytes: 504
import java.util.Scanner

object Main extends App {
  // def readALine(c:Int, ac:List[Int]):List[Int] =
  //   if (c > 0) readALine(c-1, sc.nextInt::ac) else ac.reverse
  // def readLines(r:Int, c:Int, ac:List[List[Int]]):List[List[Int]] =
  //   if (r > 0) readLines(r-1, c, readALine(c, Nil)::ac) else ac.reverse
  def readLines(r:Int, ac:List[(String,Int)]):List[(String,Int)] =
    if (r > 0) readLines(r-1, (sc.next, sc.nextInt)::ac) else ac
  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val ls = readLines(N, Nil).map(_ match {
      case ("S", r) => ("S", r, 0)
      case ("H", r) => ("H", r, 1)
      case ("C", r) => ("C", r, 2)
      case ("D", r) => ("D", r, 3)
    }).sortWith((a,b) => {
      val (s,t,u) = a
      val (v,w,x) = b
      if (u == x) t < w else u < x
    })

  type Card = (String, Int, Int)

  def solver(ls:List[Card]):List[Card] = {
    val Suits = List("S","H","C","D")
    def suit(ls:List[Card],suits:List[String],ac:List[Card]):List[Card] = {
      if (suits.isEmpty) ac.reverse else {
        var (restCards, lostCards) = rank(ls, suits.head,(1 to 13).toList,ac)
        suit(restCards,suits.tail,lostCards)
      }
    }
    def rank(ls:List[Card],suit:String,ranks:List[Int],ac:List[Card]):(List[Card],List[Card]) = {
      if (ranks.isEmpty) (ls, ac) else {
        if (ls.isEmpty) rank(ls, suit, ranks.tail, (suit,ranks.head,0)::ac)
        else {
          var (s, r, o) = ls.head
          if (suit == s && ranks.head == r) rank(ls.tail, suit, ranks.tail, ac)
          else rank(ls, suit, ranks.tail, (suit,ranks.head,0)::ac)
        } 
      }
    }
    suit(ls,Suits,Nil)
  }

  for (t <- solver(ls)) {
    var (s, r, o) = t
    println(s"$s $r")
  }
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

struct node{
	ld x,y;
	node(ld x=0,ld y=0):x(x),y(y){}
	node operator+(const node c)const{return node(x+c.x,y+c.y);}
	node operator-(const node c)const{return node(x-c.x,y-c.y);}
	node operator*(const node c)const{return node(x*c.x-y*c.y,x*c.y+y*c.x);}
}A[150000],B[150000];

const int cys=65537;
const ld pi=acos(-1);
int n,k,N,l;
int r[150000],a[150000];
ll fac[150000],inv[150000];

ll qpow(ll x,ll p){
	ll ret=1;
	for(;p;p>>=1,x=x*x%cys) if(p&1) ret=ret*x%cys;
	return ret;
}

void fft(node *A,int N,int f){
	for(int i=0;i<N;i++) if(i<r[i]) swap(A[i],A[r[i]]);
	for(int i=1;i<N;i<<=1){
		node wn(cos(pi/i),f*sin(pi/i));
		for(int j=0;j<N;j+=(i<<1)){
			node w(1,0);
			for(int k=j;k<j+i;k++,w=w*wn){
				node x=A[k],y=w*A[k+i];
				A[k]=x+y; A[k+i]=x-y;
			}
		}
	}
	if(f<0){
		for(int i=0;i<N;i++) A[i].x/=N;
	}
}

int main(){
	int T=readint();
	while(T--){
		n=readint(); k=(readint()%cys+cys)%cys;
		fac[0]=inv[0]=1;
		for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%cys;
		inv[n]=qpow(fac[n],cys-2);
		for(int i=n-1;i>=1;i--) inv[i]=inv[i+1]*(i+1)%cys;
		for(int i=0;i<n;i++) a[i]=(readint()%cys+cys)%cys;
		l=0;
		for(N=1;N<n+n;N<<=1) l++;
		for(int i=0;i<N;i++) A[i]=B[i]=node(0,0);
		for(int i=0;i<N;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
		ll now=1;
		for(int i=0;i<n;i++){
			A[i].x=inv[i]*a[n-i-1]%cys;
			B[i].x=inv[i]*now%cys;
			if(i&1) B[i].x=(cys-(ll)B[i].x)%cys;
			now=now*k%cys;
		}
		fft(A,N,1); fft(B,N,1);
		for(int i=0;i<N;i++) A[i]=A[i]*B[i];
		fft(A,N,-1);
		for(int i=0;i<n;i++){
			printf("%lld",fac[i]*((ll)(A[i].x+0.5)%cys)%cys);
			if(i!=n-1) printf(" ");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 14396
def part_sum(a,A):
    #初期化
    N=len(a)
    dp=[[-1 for i in range(A+1)] for j in range(N+1)]
    dp[0][0]=[]
    #DP
    for i in range(N):
        for j in range(A+1):
            if a[i]<=j: #i+1番目の数字a[i]を足せるかも
                if dp[i][j] != -1:
                    dp[i+1][j] = dp[i][j]
                elif dp[i][j-a[i]] != -1:
                    dp[i+1][j] = dp[i][j-a[i]]+[a[i]]
            else: #入る可能性はない
                dp[i+1][j]=dp[i][j]
    #生成可能な自然数の配列(辞書型)
    """
    num_list = {}
    for i in dp:
        for num,j in enumerate(i):
            if j != -1:
                num_list[num] = j
    return num_list
    """
    return dp[N][A]
a = int(input())
num = list(map(int,input().split()))
q = int(input())
ans = list(map(int,input().split()))
for i in ans:
    check = part_sum(num,i)
    #print(check)
    if check == -1:
        print("no")
    else:
        print("yes")


Measured memory_bytes: 6044
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));

    int sum=a[0];
    int res=0;
    range(i,1,n){
        if(sum*2>=a[i]){
            sum+=a[i];
            res++;
        }else{
            res=0;
            sum+=a[i];
        }
    }
    cout<<res+1<<endl;

}

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

using namespace std;

int a, b, c;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c;
	if (a + b + c > 21) cout << "bust" << endl;
	else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d",&n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  /* your code */
  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1){
      printf(" ");
    }
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}


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

using namespace std;

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

    string c;
    int flag = 0;
    for (int i = 0; i < n; i++){
	cin >> c;
	if(c == "Y"){
	    flag = 1;
	    cout << "Four" << endl;
	    break;
	}
    }
    if(flag == 0){
	cout << "Three" << endl;
    }
    return 0;
}


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

void main_()
{
    int N, M;
    vector<pair<int, int>> roads;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        roads.emplace_back(a, b);
    }

    for (int i = 1; i <= N; i++) {
        auto road_num = count_if(
            begin(roads), end(roads),
            [i](auto&& road) {
                return road.first == i || road.second == i;
            });
        cout << road_num << "\n";
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main(){
    int a, b;
    char c[16];
 
    while(scanf("%d %d", &a, &b) != EOF) {
        sprintf(c, "%d", a+b);
        printf("%d\n", strlen(c));
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ab = a + b;
    int cd = c + d;
    string ans = "";
    if(ab > cd) ans = "Left";
    else if(ab < cd) ans = "Right";
    else ans = "Balanced";
    cout << ans << endl;
}

Measured memory_bytes: 256
package main
 
import(
  "fmt"
  "bufio"
  "os"
  "strings"
  "strconv"
  "log"
)
 

func main(){
    a,b,c := 0,0,0
    fmt.Scan(&a)
    fmt.Scan(&b)
    fmt.Scan(&c)
    if a < b && b < c{
      fmt.Println("Yes")
    }else{
      fmt.Println("No")
    }
}


var sc = bufio.NewScanner(os.Stdin)

func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}



//入力関係ライブラリ(Atcoder:yamanobori_oldさんのもの)
func make_liner(maxByte int) *bufio.Scanner {
  liner := bufio.NewScanner(os.Stdin)
  liner.Buffer(make([]uint8, 0, 8192), maxByte)
  return liner
}
func word_spliter() *bufio.Scanner {
  words := make_liner(8192) 
  words.Split(bufio.ScanWords)
  return words
}

func eGetLine(r *bufio.Scanner) string {
  if r.Scan() {
    return r.Text()
  }
  err := r.Err()
  if err != nil {
    log.Fatal(err)
  }
  // EOF
  return ""
}

func eGetInt(r *bufio.Scanner) int {
  line := eGetLine(r)
  return eAtoi(line)
}

func eAtoi(s string) int {
  n, err := strconv.Atoi(s)
  if err != nil {
    log.Fatal(err)
  }
  return n
}


Measured memory_bytes: 1120
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(), b = sc.nextInt();

    String x = "", y = "";
    for (int i = 0; i < a; i++) x += b;
    for (int i = 0; i < b; i++) y += a;

    System.out.println((x.compareTo(y) < 0) ? x : y);
  }
}

Measured memory_bytes: 23508
from collections import deque
S = input()
Q = int(input())
Query = []

S = deque([S])

for _ in range(Q):
    Query += [input()]

reversed = False
for i, q in enumerate(Query):
    if q == "1":
        reversed = not reversed
        # S = S[::-1]
    else:
        Ti, Fi, Ci = list(q.split())
        # print(f"Fi:{Fi} S:{S} reversed:{reversed} Ci:{Ci}")
        if Fi == "1":
            if not reversed:
                S.appendleft(Ci)
                # S = Ci + S
            else:
                S.append(Ci)
                # S = S + Ci
        elif Fi == "2":
            # print(f"S:{S} reversed:{reversed} Ci:{Ci}")
            if not reversed:
                S.append(Ci)
                # S = S + Ci
            else:
                S.appendleft(Ci)
                # S = Ci + S
    # print(f"i:{i} S:{S}")

s = "".join(S)

if reversed:
    print(s[::-1])
else:
    print(s)


Measured memory_bytes: 19540
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
using namespace std;
/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main()
{
	kira;
    lli T=1;
    //cin>>T;
    while(T--)
    {
    	lli n,a,l=1;
        cin>>n;
        forz(i,n)
        {
            cin>>a;
            if(a==l)
                l++;
        }
        l--;
        if(l==0)
            cout<<-1<<endl;
        else
            cout<<n-l<<endl;
        
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int S;
	int ans1;
	int ans2;
	int ans3;
	cin >> S;
	ans1 = S/3600;
	int x = S % 3600;
	ans2 = x / 60;
	int y = x % 60;

	cout <<ans1<<":"<<ans2<<":"<<y<< endl;




	return 0;
}


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

int main(){
//srandom((unsigned long)time(NULL));

long long n;
cin>>n;
vector<long long> a;
bool is1 = false;
for(long long i=0;i<n;i++){
    long long x;
    cin>>x;
    if(x==1) is1 = true;
    a.emplace_back(x);
}
if(!(is1)){
    cout<<-1<<endl;
    return 0;
}

long long cnt=1;
for(long long i=0;i<n;i++){
    if(cnt==a[i]){
        cnt++;
    }
}
//K+1gacnt
cout<<n-(cnt-1)<<endl;


return 0;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define endl '\n'
 
const ll MOD = 1000000007;

int main() {
   int d, t, s; scanf("%d%d%d", &d, &t, &s);
   if (s * t >= d) {
      printf("Yes");
   } else {
      printf("No");
   }
   return 0;
}

Measured memory_bytes: 3820
N=int(input())

mp=[0 for i in range(N)]
for a in input().split():
    mp[int(a)]+=1

res=True
if N%2==1:
    for i in range(2,N,2):
        if mp[i]!=2:
            res=False
    if mp[0]!=1:
        res=False
else:
    for i in range(1,N,2):
        if mp[i]!=2:
            res=False
if res:
    print(pow(2,N//2,10**9+7))
else:
    print(0)


Measured memory_bytes: 11224
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int total=0; 
	vector<ll> a(n),b(31,0);
	for(int i=0;i<n;i++){
		cin >> a[i];
		for(int j=0;j<31;j++){
			if(a[i]&(1LL<<j)){
				b[j]++;
				break;
			}
		}
		total^=a[i];
	}
	int ans=0;
	for(int j=30;j>=0;j--){
		if(total&(1LL<<j)){
			if(b[j]){
				ans++;
				total=(total^(1LL<<j))^((1LL<<j)-1);
			}
			else{
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

ll x;
cin>>x;
cout<<1-x;


    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
long long power(long long k , long long n , long long m=1e9+7)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
long long fact(long long n , long long m = 1e9+7)
{
    long long a = 1 ;
    if(n==0 || n==1)
    {
        return(1) ;
    }
    while(n>0)
    {
        a = (a%m * n%m)%m ;
        n-- ;
    }
    return(a) ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
  	cin>>a>>b ;
  	if(b%a==0)
    {
      cout<<b+a ;
    }
  	else
    {
      cout<<b-a ;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,s,tmp,ans;
	scanf("%lld %lld",&n,&s);
	for(int i=2;i<=sqrt(n);i++){
		tmp=n,ans=0;
		while(i<=tmp){
			ans+=(tmp%i);
			tmp/=i;
		}
		ans+=tmp;
		if(ans==s){
			printf("%lld",i);
			return 0;
		}
	}
	for(int i=sqrt(n)-1;i>=1;i--){
		if(s<i) continue;
		tmp=n-(s-i);
		if(tmp%i>0||tmp/i<=s-i||tmp/i==1) continue;
		printf("%lld",tmp/i);
		return 0;
	}
	if(s==n){
		printf("%lld",n+1);
		return 0;
	}
	else if(s==1){
		printf("%lld",n);
		return 0;
	}
	printf("-1");
}

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

int main(){
  int H,N;
  cin>>H>>N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i)>>B.at(i);
  }

  vector<int> dp(H+1,1000000000);
  dp.at(0)=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=H;j++){
      int nj=min(H,j+A.at(i));
      dp.at(nj)=min(dp.at(nj),dp.at(j)+B.at(i));
    }
  }

  cout<<dp.at(H)<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#define	MOD  1000000007;
#define PI = 3.14159265358979323846;
using namespace std;

int main()
{
	long long a, b, x;
	cin >> a >> b >> x;

	long long s = b / x;
	long long t = a / x;

	long long count = s - t;
	if (a % x == 0)
	{
		count++;
	}

	cout << count << endl;
}

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

int main(void){
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    ll diff = 0, add = 0;
    rep(i,n) {
        if(a[i] > b[i]){
            diff += a[i] - b[i];
        }else{
            add += (b[i]-a[i]+1)/2;
            if((b[i]-a[i])&1) diff++;
        }
    }
    cout<<(diff<=add ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    int n;
    int res = 0;
    cin >> n;
    for(int i=1; i<=n; ++i) {
        string ii = to_string(i);
        if (ii.size()%2 == 1) {
            ++res;
        }
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;

    int lowest;
    int p;
    int count = 0;

    int array[n];
    for(int i = 0; i < n; ++i) {
        cin >> p;

        if(i == 0) {
            lowest = p;
            ++count;
            continue;
        };

        if(p <= lowest) {
            lowest = p;
            ++count;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256