akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main(){
    cin >> n;
    vector<ll> b(n);
    vector<ll> ans;
    vector<ll> f(n+1,false);
    rep(i,n)cin >> b[i];
    b.push_back(INF);
    rep(i,n){
        ll p = -1;
        ll cnt = 1;
        rep(j,n){
            if(f[j])continue;
            if(cnt == b[j])p = j;
            cnt++;
        }
        if(p == -1){
            cout << -1 << endl;
            return 0;
        }
        f[p] = true;
        ans.push_back(b[p]);
    }
    // rep(i,n){
    //     ll cnt = 0;
    //     ll l = 0;
    //     // rep(j,n+1)cout << f[j] << " ";
    //     // cout << endl;
    //     rep(j,n+1){
    //         if(f[j])continue;
    //         if(cnt + 1 != b[j]){
    //             f[l] = true;
    //             if(j == 0){
    //                 cout << -1 << endl;
    //                 return 0;
    //             }
    //             // cout << "!" << cnt + 1 << ":" << b[j] << endl;
    //             ans.push_back(cnt);
    //             break;
    //         }
    //         // cout << j << " ";
    //         l = j;
    //         cnt++;
    //     }
    //     // cout << endl;
    // }
    reverse(ALL(ans));
    rep(i,n){
        cout << ans[i] << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


mint modPow(mint a, int n){
	//cout << a << endl;
	if(n == 0) return 1;
	if(n == 1) return a;
	if(n % 2) return a * modPow(a, n-1);
	else return modPow(a*a, n/2);
}

int main(){
	int n; cin >> n;
	vector<pl> d(63, pl(0,0));
	rep(bar,n){
		unsigned long long a; cin >> a;
		rep(i,63){
			if(a>>i & 1) d[i].first ++;
			else d[i].second ++;
		}	
	}
	mint ans = 0;
	rep(i,63){
		mint tmp = d[i].first*d[i].second;
		ans += tmp * modPow(2,i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second

using namespace std;

const int N=2e5+5;
const int MOD=998244353;

typedef long long ll;

ll n, c[4][N], BIT[N], pow2[N];
pair<ll, ll> arr[N];

ll query(ll x)
{
	ll ret=0;
	for(;x>0; x-=x&-x)
		ret+=BIT[x];
	return ret;
}

void upd(ll x)
{
	for(;x<=n; x+=x&-x)
		BIT[x]+=1;
}

int main()
{
	pow2[0]=1;
	for(ll a=1; a<N; a++)
		pow2[a]=(pow2[a-1]*2LL)%MOD;
	// n=5;
	// upd(2);
	// upd(3);
	// upd(4);
	// printf("%lld %lld %lld\n", query(2), query(3), query(4));
	scanf("%lld", &n);
	for(ll a=1; a<=n; a++)
		scanf("%lld%lld", &arr[a].f, &arr[a].s);
	sort(arr+1, arr+n+1);
	for(ll a=1; a<=n; a++)
	{
		arr[a].f=a;
		swap(arr[a].f, arr[a].s);
	}
	sort(arr+1, arr+n+1);
	for(ll a=1; a<=n; a++)
	{
		arr[a].f=a;
		swap(arr[a].f, arr[a].s);
	}
	// printf("here\n");
	sort(arr+1, arr+n+1);
	for(ll a=1; a<=n; a++)
	{
		// printf("%lld %lld %lld\n", a, arr[a].f, arr[a].s);
		c[0][a]=query(arr[a].s);//LEFT AND DOWN
		c[1][a]=a-c[0][a]-1;//LEFT AND UP
		upd(arr[a].s);
	}
	// printf("here\n");
	for(ll a=0; a<=n; a++)
		BIT[a]=0;
	for(ll a=n; a>=1; a--)
	{
		c[2][a]=query(arr[a].s);//RIGHT AND DOWN
		c[3][a]=n-a-c[2][a];//RIGHT AND UP
		upd(arr[a].s);
	}
	// for(int a=1; a<=n; a++)
	// {
	// 	printf("%d: ", a);
	// 	for(int b=0; b<4; b++)
	// 		printf("%lld ", c[b][a]);
	// 	printf("\n");
	// }
	ll ans=(n*(pow2[n]-1)+MOD)%MOD;
	for(ll a=1; a<=n; a++)
	{
		ll subhere=0;
		for(ll b=0; b<4; b++)
			subhere=(subhere+pow2[c[b][a]]-1)%MOD;
		subhere+=((pow2[c[0][a]]-1)*(pow2[c[1][a]]-1))%MOD;
		subhere%=MOD;
		subhere+=((pow2[c[1][a]]-1)*(pow2[c[3][a]]-1))%MOD;
		subhere%=MOD;
		subhere+=((pow2[c[3][a]]-1)*(pow2[c[2][a]]-1))%MOD;
		subhere%=MOD;
		subhere+=((pow2[c[2][a]]-1)*(pow2[c[0][a]]-1))%MOD;
		subhere%=MOD;
		ans-=subhere;
		ans+=MOD;
		ans%=MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
ll n, a, b;
int main() {
    cin >> a >> b;
    int amin, bmin;
    amin = ((a * 100) / 8) + 1;
    bmin = ((b * 100) / 10) + 1;
    if ((a * 100) % 8 == 0) {
        amin = ((a * 100) / 8);
    }
    if ((b * 100) % 10 == 0) {
        bmin = ((b * 100) / 10);
    }
    int amax, bmax;
    amax = (((a + 1) * 100) / 8);
    bmax = (((b + 1) * 100) / 10);
    if (((a+1) * 100) % 8 == 0) {
        amax = (((a + 1) * 100) / 8) - 1;
    }
    if (((b+1) * 100) % 10 == 0) {
        bmax = (((b + 1) * 100) / 10) - 1;
    }
    if (amax < bmin || bmax < amin) {
        cout << "-1" << endl;
    } else {
        cout << max(amin, bmin) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<ll, ll> II;
typedef vector<II> vi;

ll n;
map<II, ll> ma;

ll solve(ll s, ll x)
{
    if (ma.count(II(s,x))) return ma[II(s,x)];
    if (s == 0 && x == 0) return ma[II(s,x)] = 1;
    ll res = solve(s/2, x/2);
    if (s >= 1 && x >= 1) res = (res + solve((s-1)/2, (x-1)/2)) % base;
    if (s >= 2) res = (res + solve((s-2)/2, x/2)) % base;
    return ma[II(s,x)] = res;
}

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n;
    cout << solve(n, n);
    return 0;
}


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

int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> st(n);
  vector<pair<int,int>> ch(m);

  for(int i=0; i<n; i++)cin>>st.at(i).first>>st.at(i).second;
  for(int i=0; i<m; i++)cin>>ch.at(i).first>>ch.at(i).second;

  vector<int> ans(n, 0);
  for(int i=0; i<n; i++){
    for(int j=1; j<m; j++){
      if(abs(st.at(i).first-ch.at(ans.at(i)).first)+abs(st.at(i).second-ch.at(ans.at(i)).second)>
         abs(st.at(i).first-ch.at(j).first)+abs(st.at(i).second-ch.at(j).second))ans.at(i)=j;
    }
  }

  for(int i=0; i<n; i++)cout<<ans.at(i)+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
typedef long long ll;
using namespace std;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (A && C) {
        C-=B;
        if (C<=0) {
            cout << "Yes" << endl;
            return 0;;
        }
        A-=D;
        if (A<=0) {
            cout << "No" << endl;
            return 0;;
        }
    }
    
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define F first
#define S second
#define REP(i, a, b, c) for (int i = a; i <= b; i += c)
#define pb push_back
#define int long long int
#define MOD 1000000007
using namespace std;


int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  //cin >> t;
  for (int tt = 1; tt <= t; tt++)
  {
    string s;
    cin >> s;
    if(s[s.size()-1] == 's'){
      s += "es";
    }
    else
      s += 's';
    cout << s;
 }
}


Measured memory_bytes: 3648
N = int(input())
n = input()    
m = n.split()
p = [int(i) for i in m]
a = 0
b = 1
import fractions
for i in p:
    c = fractions.gcd(i, b)
    a = (a * i // c + b // c) % 1000000007
    b = b * i // c
 

print(a)

Measured memory_bytes: 6300
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }

double pi = 3.14159265358979323846264338327950288419716939937510582097494459230;
int modulo = 1e9 + 7;

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin >> n;
    double p[n];
    FOR(i,0,n) cin >> p[i];
    double dp[n+1][n+1]; memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            dp[i+1][j+1] += (dp[i][j] * p[i]);
            dp[i+1][j] += (dp[i][j] * (1-p[i]));
        }
    }
    double ans = 0;
    for (int i = n; i > n/2; --i) ans += dp[n][i];
    cout << setprecision(10) << fixed << ans;
    return 0;
}

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

typedef pair<int,int> P;
char data[1010][1010] = {};
int done[1010][1010];
int H,W,ans=0;
const int inf = 99999;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
queue<P> que;

void bfs(){
  while(!que.empty()){
    P p = que.front(); que.pop();
    for(int i=0; i<4; i++){
      int new_y=p.first+dy[i], new_x=p.second+dx[i];
      if (new_y <= 0 || H < new_y || new_x <= 0 || W < new_x || done[new_y][new_x]!=inf) { continue; }	// out of area??
      que.push(P(new_y,new_x));  
      done[new_y][new_x] = done[p.first][p.second]+1;
      ans = max(done[new_y][new_x],ans);
  	}
  }
}

int main() {
  cin >> H >> W;
  for(int i=1; i<=H; i++){ for(int j=1; j<=W; j++){ 
    cin >> data[i][j]; 
    if(data[i][j]=='#'){
      que.push(P(i,j));
      done[i][j]=0;
    } else {
      done[i][j]=inf;
    }
  } }
  bfs(); 
  cout << ans << endl; 
  return 0;
}  


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

typedef long long ll;

int main() {
  int n;
  cin >> n;
  map<int, int> m;
  for (int i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    a--;
    m[a]++;
  }

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

  return 0;
}

Measured memory_bytes: 12992
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)

int main() {

    int n;
    char s[100][13] = {{}};
    scanf("%d", &n);

    bool a = false;

    Rep( i,n ){
        scanf("%s", s[i]);
    }
    
    char f,e;

    Repe( i, n-1, 0 ){
        e = s[i][strlen(s[i])-1];
        f = s[i+1][0];
        if( e != f ) {
            a=true;
        }
    }

    Rep( i,n ){
        Rep( t,n ){
            if ( i == t ) continue;
            Rep( j,11 ){
                if( j == 10 ){
                    a = true;
                }
                if( s[i][j] != s[t][j] ) break;
            }
        }
    }

    if( a ){
        printf ("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int a,b,i,c;
  cin>>a>>b;
  c=b;
  for(i=0;c/10!=0;i++,c/=10);
  for(int j=0;j<=i;j++,a*=10);
  a+=b;
  for(int i=0;i<a;i++){
    if(i*i==a){
      cout<<"Yes"<<endl;
      return 0;
    }
  }


cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, 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 LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n = II()
	a = LI()
	a.sort(reverse=True)
	a = np.array(a)
	print(np.sum(a[0::2]) - np.sum(a[1::2]))


if __name__ == '__main__':
	main()

Measured memory_bytes: 12272
n = str(input())
m = n[-1]
if m == '2' or m == '4' or m == '5' or m == '7' or m == '9':
    print('hon')
elif m == '0' or m == '1' or m == '6' or m == '8':
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9112
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
	int R[MAX],n;

	cin>>n;
	for(int i=0;i<n;i++)	cin>>R[i];

	int maxv=-2000000000;
	int minv=R[0];

	for(int i=1;i<n;i++){
		maxv=max(maxv,R[i]-minv);
		minv=min(minv,R[i]);
	}

	cout<<maxv<<endl;

	return 0;
}

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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int whiteArea = 0;
  vector<vector<int>> v(h, vector<int>(w, 1));
  for (int i = 0; i < n; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {// <xi
      for (int j = 0; j < h; j++) {
        for (int k = 0; k < x; k++) v.at(j).at(k) = 0;
       }
    }else if (a == 2) {// >xi
      for (int j = 0; j < h; j++) {
        for (int k = x; k < w; k++) v.at(j).at(k) = 0;
      }
    }else if (a == 3) {// <yi
      for (int j = 0; j < y; j++) v[j] = vector<int>(w, 0);
    }else {// >yi
      for (int j = y; j < h; j++) v[j] = vector<int>(w, 0);
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (v.at(i).at(j) == 1) whiteArea++;
    }
  }
  cout << whiteArea;
}

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

const int maxn = 1e6+5;
int n, a[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; i++) {
        char c; cin >> c;
        a[i] = c-'0'-1;
    }
    int par = 0;
    for (int i = 0; i < n; i++) {
        if (((n-1)|i) == n-1) {
            par ^= (a[i]%2);
        }
    }
    if (par) {
        cout << 1 << '\n';
    }
    else {
        for (int i = 0; i < n; i++) {
            if (a[i] == 1) {
                cout << 0 << '\n';
                return 0;
            }
        }
        for (int i = 0; i < n; i++) {
            a[i] /= 2;
        }
        par = 0;
        for (int i = 0; i < n; i++) {
            if (((n-1)|i) == n-1) {
                par ^= (a[i]%2);
            }
        }
        cout << 2*par << '\n';
    }
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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 namespace std;

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    ll l = -1, r = 1e12;

    while(l+1 < r){
        ll c = (l+r)/2;
        bool ok = [&]{
          ll s = 0;
          rep(i,n){
              s += max(0ll, a[i]-c/f[i]);
          }

          return s <= k;
        }();
        if (ok) r = c; else l = c;
    }


    cout << r << endl;
    return 0;


}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
        int N;
        scanf("%d", &N);

        if (N == 1) {
                puts("Hello World");
        } else {
                int A, B;
                scanf("%d%d", &A, &B);
                printf("%d\n", A + B);
        }

        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

int ar[11];

bool ok(int a){
    while(a>0){
        if(ar[a%10])
            return false;
        a/=10;
    }
    return true;
}

int main()
{
    int n,k;
    cin>>n>>k;
    int b;
    for(int ctr1=0;ctr1<k;ctr1++)
        cin>>b,ar[b]++;
    for(int ctr2=n;;ctr2++){
        if(ok(ctr2)){
            cout<<ctr2<<"\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
//cod2016_qualC_c.cpp
//Sun Aug  4 17:23:50 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int t[n];
	int h[n];
	fill(h,h+n,0);
	int flag[n];
	fill(flag,flag+n,0); //1->fixed 2->upper limit selected.
	for (int i=0;i<n;i++){
		cin >> t[i];
		if (i==0 || t[i]!=t[i-1]){
			h[i] = t[i];
			flag[i] = 1;
		}else{
			h[i] = t[i];
			flag[i] = 2;
		}
	}

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

	for (int i=n-1;i>=0;i--){
		if (i==n-1 || a[i]!=a[i+1]){
			if (flag[i] == 1 && a[i]!=h[i]){
				cout << 0 << endl;
				return 0;
			}else if (flag[i] == 2 && a[i]>h[i]){
				cout << 0 << endl;
				return 0;
			}else {
				h[i] = a[i];
				flag[i] = 1;
			}
		}else {
			if (flag[i] == 1 && a[i]<h[i]){
				cout << 0 << endl;
				return 0;
			}else if (flag[i] == 2 && a[i]<h[i]){
				h[i] = a[i];
			}
		}
	}

	ll ans = 1;
	for (int i=0;i<n;i++){
		if (flag[i]==2){
			ans = ans * h[i] % 1000000007;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 1792
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 1e9+7;
//}}}

ll a[200000];
ll sum[200000];
int main(){
  int N;
  cin >> N;
  rep(i, N) cin >> a[i];
  rep(i, N) a[i] -= (i + 1);
  sort(a, a + N);
  ll a0 = a[0];
  rep(i, N) a[i] -= a0;
  sum[0] = a[0];
  rep(i, 1, N) sum[i] = sum[i - 1] + a[i];
  ll ans = sum[N - 1];
  rep(i, N){
    ll ansI = a[i] * (i + 1) - sum[i];
    ansI += sum[N - 1] - sum[i] - a[i] * (N - 1 - i);
    ans = min(ans, ansI);
  }

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


Measured memory_bytes: 3328
N, T = map(int, input().split())
cts = []
for i in range(N):
  c, t = map(int, input().split())
  cts.append((c, t))
cts2 = list(filter(lambda ct: ct[1] <= T, cts))
if len(cts2) == 0:
  print("TLE")
  exit()
r = min(map(lambda ct: ct[0], cts2))
print(r)


Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
	int b,f,r,v;
	int n;
	int i,j,k;
	
	int A1[3][10],A2[3][10],A3[3][10],A4[3][10];
	
	for(i = 0;i < 3;i++){
		for(j = 0;j <10;j++){
			A1[i][j] = 0;
			A2[i][j] = 0;
			A3[i][j] = 0;
			A4[i][j] = 0;
		}
	}
	
	scanf("%d",&n);
	
	for(i = 0;i < n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		if(b > 4||f > 3||r > 10|| v > 9||v < -9){
			i--;
		}else{
			switch(b){
				case 1:A1[f-1][r-1] += v;
					break;
				case 2:A2[f-1][r-1] += v;
					break;
				case 3:A3[f-1][r-1] += v;
					break;
				case 4:A4[f-1][r-1] += v;
					break;
			}
		}
	}
	
	for(i = 0;i < 4;i++){
		for(j = 0;j < 3;j++){
			for(k = 0;k < 10;k++){
				switch(i){
					case 0:if(k != 9){
								printf(" %d",A1[j][k]);
							}else{
								printf(" %d\n",A1[j][k]);
							}
							break;
							
					case 1:if(k != 9){
								printf(" %d",A2[j][k]);
							}else{
								printf(" %d\n",A2[j][k]);
							}
							break;
					case 2:if(k != 9){
								printf(" %d",A3[j][k]);
							}else{
								printf(" %d\n",A3[j][k]);
							}
							break;
					case 3:if(k != 9){
								printf(" %d",A4[j][k]);
							}else{
								printf(" %d\n",A4[j][k]);
							}
							break;
				}
			}
		}
		if(i < 3){
			printf("####################\n");
		}		
	}
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    bool ok = 1;
    rep(i, s.length() / 2 ) {
        if ( s[i] != s[s.length() - 1 - i] ) {
            ok = 0;
            break;
        }  
    }
    if ( !ok ) {
        cout << "No" << endl;
        return 0;
    }
    string s_first = s.substr(0, (s.length()-1)/2);
    string s_last = s.substr((s.length()+3)/2-1, s.length() - (s.length()+3)/2 + 1);
//    cout << s_first << endl;
//    cout << s_last << endl;
    rep(i, s_first.length()/2){
        if ( s_first[i] != s_first[s_first.length() - 1 -i] ) {
            ok = 0;
        }
    }
    rep(i, s_last.length()/2){
        if ( s_last[i] != s_last[s_last.length() - 1 -i] ) {
            ok = 0;
        }
    }
    if ( !ok ) {
        cout << "No" << endl;
    }  
    else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var item = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var A = item[0];
            var B = item[1];

            var answer = this.Calc(A, B);
            Console.WriteLine(answer);
        }

        private int Calc(int A, int B)
        {
            if (A > 9)
            {
                return -1;
            }

            if (B > 9)
            {
                return -1;
            }

            return A * B;
        }
    }
}


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

int main(){

    int mp[20][10];
    int flg[20][10];

    for(int h; cin >> h, h;){
        for(int y = 0; y < 20; y++){
            for(int x = 0; x < 10; x++){
                mp[y][x] = 0;
            }
        }
        for(int y = h; y >= 1; y--){
            for(int x = 1; x <= 5; x++){
                cin >> mp[y][x];
            }
        }
        int ans = 0;
        for(int f = 1; f;){
            f = 0;
            for(int y = 0; y < 20; y++){
                for(int x = 0; x < 10; x++){
                    flg[y][x] = 0;
                }
            }
            for(int y = 1; y <= h; y++){
                for(int x = 1; x <= 3; x++){
                    if(mp[y][x] == 0)continue;
                    if(mp[y][x] == mp[y][x + 1] && mp[y][x+1] == mp[y][x+2]){
                        flg[y][x] = 1;
                        flg[y][x+1] = 1;
                        flg[y][x+2] = 1;
                    }
                }
            }
            for(int y = 1; y <= h; y++){
                for(int x = 1; x <= 5; x++){
                    if(flg[y][x] == 0)continue;
                    f = 1;
                    ans+=mp[y][x];
                    mp[y][x] = 0;
                }
            }
            for(int x = 1; x <= 5; x++){
                for(int y = 1; y <= h; y++){
                    if(mp[y][x])continue;
                    for(int y2 = y; y2 <= h; y2++){
                        if(mp[y2][x]){
                            swap(mp[y][x], mp[y2][x]);
                            break;
                        }
                    }
                }
            }
            // for(int y = h; y >= 1; y--){
            //     for(int x = 1; x <= 5; x++){
            //         cout << mp[y][x];
            //     }
            //     cout << endl;
            // }
            // cout << endl;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3068
#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; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 100005;

int N, U, V, A, B;
vi tree[MX];
int parent[MX], depth[MX], maxDepth[MX];
ll ans;

int dfs(int v, int p) {
    depth[v] = depth[p] + 1;
    int maxD = depth[v];
    trav(u, tree[v]) {
        if (!depth[u]) {
            parent[u] = v;
            maxD = max(maxD, dfs(u, v));
        }
    }
    maxDepth[v] = maxD;
    return maxD;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> N >> U >> V;
    F0R(i, N - 1) {
        cin >> A >> B;
        tree[A].pb(B);
        tree[B].pb(A);
    }
    
    dfs(V, 0);
    ans += (depth[U] - depth[V] - 1) / 2;
    F0R(i, ans) U = parent[U];
    if (depth[U] - (depth[V] + ans) == 2) ans++;
    ans += maxDepth[U] - depth[U];
    cout << ans;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 10752
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char s[1000010];

int main()
{
	scanf("%s",s);int n=strlen(s);
	int l=1,r=1000000;
	while (l<=r)
	{
		int mid=(l+r)>>1;
		int x=mid*9,g=0;
		for (int i=n-1;i>=0;i--)
		{
			while (x>=0&&(x+g)%10!=s[i]-'0') x--;
			if (x<0) break;
			g=(x+g)/10;
		}
		if (x>=0) r=mid-1; else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000000000000
#define mod 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

class UnionFind {
private:
	vector<int>par;
public:
	UnionFind(int n) {
		for (int i = 0; i < n; i++) {
			par.push_back(-1);
		}
	}

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	void unite(int x, int y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

struct Edge {
	int a, b, cost;
	bool operator<(const Edge& o) const {
		return cost < o.cost;
	}
};

class Graph {
public:
	int n;
	vector<Edge> es;

	int kruscal() {
		sort(es.begin(), es.end());
		UnionFind uf(n);
		int min_cost = 0;
		for (int ei = 0; ei < es.size(); ei++) {
			Edge ed = es[ei];
			if (!uf.same(ed.a, ed.b)) {
				min_cost += ed.cost;
				uf.unite(ed.a, ed.b);
			}
		}
		return min_cost;
	}
};

signed main() {
	Graph g;
	int m;
	cin >> g.n >> m;
	rep(i, m) {
		Edge e;
		cin >> e.a >> e.b >> e.cost;
		g.es.push_back(e);
	}
	cout << g.kruscal() << endl;

	return 0;
}



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

int main() {
    string S;
    int ans = 0;
    cin >> S;
    if(S == "SSS"){
        ans = 0;
    }else if(S == "SRR" || S == "RRS"){
         ans = 2;
    }else if(S == "RRR"){
        ans = 3;
    }else{
        ans = 1;
    }
    cout << ans << endl;
}

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

int main(){
	int n;
	scanf("%d",&n);
	bool poss=1;
	int arr;
	for(int i=0;i<n;i++){
		scanf("%d",&arr);
		if(arr%2==0){
			if(arr%3==0||arr%5==0){
				continue;
			}else{
				poss=0;break;
			}
		}
	}
	if(poss)printf("APPROVED");
	else printf("DENIED");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1005;
const char END = '\n';

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N, Ans = 0;
	cin >> N;
	
	vector<ll> h(N + 1, 0);
	rep(i, N)
		cin >> h[i];
	
	while (1) {
		ll sub = Ans;
		rep(i, N) {
			if (h[i] > 0) {
				h[i] --;
				if (h[i + 1] == 0)
					Ans++;
			}
		}
		if (sub == Ans)
			break;
	}

	cout << Ans << END;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val pList = readLine()!!.split(" ").map { it.toInt() }

    var sum = 0
    for (i in 1 until n-1) {
        val prev = pList[i-1]
        val curr = pList[i]
        val next = pList[i+1]

        val list = mutableListOf(prev, curr, next)
        list.sort()
        if (list[1] == curr) sum++
    }

    println(sum)
}


Measured memory_bytes: 37908
#include<stdio.h>
int main(void){
    long long n,temp,ans;
    scanf("%lld",&n);
    ans=1;
    temp=1;
    while(1){
        if(temp*temp>n){
            break;
        }
        ans=temp*temp;
        temp++;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
N,*A=map(int,open(0).read().split())
M = max(A); m = min(A)
ans = []
if -m < M:
    idx = A.index(M)
    for i in range(N):
        A[i] += A[idx]
        ans.append((idx, i))
    for i in range(1, N):
        A[i] += A[i-1]
        ans.append((i-1, i))
else:
    idx = A.index(m)
    for i in range(N):
        A[i] += A[idx]
        ans.append((idx, i))
    for i in range(N-1, 0, -1):
        A[i-1] += A[i]
        ans.append((i, i-1))
#print(*A)
print(len(ans))
for x, y in ans:
    print(x+1, y+1)


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

int main(void){
    long int n = 0;
    long int check_num = 1;
    long int ans = -1;

    scanf("%ld", &n);

    for(long int i = 1; i <= n; i++){
        long int tmp = 0;
        scanf("%ld", &tmp);
        if(tmp == check_num){
            check_num++;
        }
    }
    if(check_num > 1){
        ans = n - (check_num - 1);
    }

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

    return 0;

} 


Measured memory_bytes: 256
import java.util.*;
import java.text.*;

public class Main {
    public static void main(String args[]) {
      Scanner in = new Scanner(System.in);
      int n = in.nextInt();
      int[] a = new int[n];
      int[] c = new int[4];
      double[][][] DP = new double[1+n][1+n][1+n];
      for(int i = 0; i< DP.length; i++)
        for(int j = 0; j< DP[i].length; j++)
            for(int k = 0; k< DP[i][j].length; k++)
                DP[i][j][k] = -1;
      for(int i = 0; i< n; i++)c[in.nextInt()]++;
      System.out.println(new DecimalFormat("0.000000000").format(calc(DP, n, c[1], c[2], c[3])));
    }
    static double calc(double[][][] DP, int n, int c1, int c2, int c3){
        if(Math.min(c1, Math.min(c2, c3)) < 0)return 0;
        if(c1+c2+c3 == 0)return 0.0;
        if(DP[c1][c2][c3] > -0.5)return DP[c1][c2][c3];
        int c0 = n-c1-c2-c3;
        double p0 = c0*1.0/n, p1 = c1*1.0/n, p2 = c2*1.0/n, p3 = c3*1.0/n;
        DP[c1][c2][c3] = (1+p1*calc(DP, n, c1-1, c2, c3)+p2*calc(DP, n, c1+1, c2-1, c3)+p3*calc(DP, n, c1, c2+1, c3-1))*1.0/(1-p0);
        return DP[c1][c2][c3];
    }
}

Measured memory_bytes: 306900
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> a{"AC","WA","TLE","RE"};
    ll n;
    cin >> n;
    vector<ll> cnt(4,0);
    string s;
    rep(i,n){
        cin >> s;
        rep(j,4){
            if (s == a[j]) cnt[j]++;
        }
    }
    rep(i,4){
        cout << a[i] << " x " << cnt[i] << endl;
    }
}


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

int main(){
  string s;
  cin>>s;
  int changes=0,n=s.length();
  for(int i=0;i<(n+1)/2;i++){
    if(s[i]!=s[n-i-1]) changes++;
  }
  cout<<changes<<"\n";
  return 0;
}

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

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

using namespace std;

int main(){
	int cub[54];	rep(i,54)	cub[i]=i*i*i;
	int tet[96];	rep(i,96)	tet[i]=i*(i+1)*(i+2)/6;

	for(int n;scanf("%d",&n),n;){
		int ans=0;
		rep(i,54)rep(j,96){
			int a=cub[i]+tet[j];
			if(a>n)	break;
			ans=max(ans,a);
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
n = int( raw_input() )
house = [ [ [ 0 for i in range(10) ] for j in range(3) ] for k in range(4) ]
for i in range(n):
  b, f, r, v = map( int , raw_input().split() )
  house[b-1][f-1][r-1] += v
     
for i in range(4):
  for j in range(3):
    ans=''
    for k in range(10):
      ans += ' ' + str( house[i][j][k] )
    print ans
  if i != 3: 
    print '#'*20

Measured memory_bytes: 6468
#include <cstdio>
#include <cstdlib>
using namespace std;
int main(){
	int L,N,R=0;
	scanf("%d%d",&L,&N);
	for(int i=0;i<N;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		R+=a*b;
	}
	if(R==0){
		puts("0");
	}else{
		printf("1\n%d %d\n",R>0?-1:1,abs(R));
	}
}

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

ret0 = 0
count0 = 0
for i in range(N):
    ret0 += A[i]
#     print("ret0",ret0)
#     print("count0",count0)
    if ret0 < 0 and i % 2 == 0:
#         print("A")
        count0 += abs(ret0) + 1
        ret0 = 1
    if ret0 > 0 and i % 2 == 1:
#         print("B")
        count0 += ret0 + 1
        ret0 = -1
#     print("ret0",ret0)
    if ret0 == 0 and i % 2 == 0:
        count0 += 1
        ret0 = 1
    if ret0 == 0 and i % 2 == 1:
        count0 += 1
        ret0 = -1
# print(count0)

ret1 = 0
count1 = 0
for i in range(N):
    ret1 += A[i]
#     print("ret1",ret1)
#     print("count1",count1)
    if ret1 > 0 and i % 2 == 0:
        count1 += ret1 + 1
        ret1 = -1
    if ret1 < 0 and i % 2 == 1:
        count1 += abs(ret1) + 1
        ret1 = 1
#     print("ret1",ret1)
    if ret1 == 0 and i % 2 == 0:
        count1 += 1
        ret1 = -1
    if ret1 == 0 and i % 2 == 1:
        count1 += 1
        ret1 = 1
# print(count1)

print(min(count0, count1))

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

int solve(string ss,string tt){
  int c[1001][1001];
  int m=ss.size();
  int n=tt.size();
  int k=0;
  ss=' '+ss;
  tt=' '+tt;
  for(int i=0;i<=m;i++)c[0][i]=0;
  for(int i=0;i<=n;i++)c[i][0]=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(ss[i]==tt[j]){
        c[i][j]=c[i-1][j-1]+1;
      }
      else{
        c[i][j]=max(c[i][j-1],c[i-1][j]);
      }
      k=max(k,c[i][j]);
    }
  }
  return k;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string ss,tt;
    cin>>n;
    rep(i,n){
      cin>>ss>>tt;
      cout<<solve(ss,tt)<<endl;
    }
   return 0;
}



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

N, K, Q = map(int, input().split())
As = [int(input()) for _ in range(Q)]

pts = [K-Q] * N
for A in As:
    pts[A-1] += 1

anss = []
for pt in pts:
    anss.append('Yes' if pt > 0 else 'No')

print('\n'.join(anss))


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

int main(){
int A, B, C, K;  cin >> A >> B >> C >> K;
int max_val = max(A, B);
max_val = max(max_val, C);

cout << (A + B + C) + max_val*(pow(2, K) - 1) << endl;
}

Measured memory_bytes: 384
function foo(arr) {
    var a = [], b = [], prev;
    
    arr.sort();
    for ( var i = 0; i < arr.length; i++ ) {
        if ( arr[i] !== prev ) {
            a.push(arr[i]);
            b.push(1);
        } else {
            b[b.length-1]++;
        }
        prev = arr[i];
    }
    
    return [a, b];
}

function Main(input) {
	input = input.split("\n");
	
	var N = parseInt(input[0], 10);
	var array = input[1].split(" ");
	array.forEach((elem, index, array) => array[index] = parseInt(elem, 10));
	
	result = foo(array);
	
	var count = 0;
	
	for(var i=0; i<result[0].length; i++) {
		var num = result[0][i];
		var countOfNum = result[1][i];
		if(num != countOfNum) {
			if(num < countOfNum) {
				//数を減らせばいける
				count += countOfNum - num;
			}
			if(num > countOfNum) {
				//救いはないね♂
				count += countOfNum;
			}
		}
	}
	
	console.log(count);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define sc(x) scanf("%d",&x);
#define rep(x ,n) for(int x=0; x<n; x++)
#define ll long long
#define finish(x) return cout << x << endl,0;
#define scarr(a,n) for(int x=0; x<n; x++)scanf("%d",&a[x]);

int main()
{
    int n ,k;
    string s;
    sc(n)sc(k)
    cin >> s;
    if('A' <= s[k-1] && s[k-1] <= 'Z')
        s[k-1] = s[k-1]-('A'-'a');
    cout << s << endl;;
}


Measured memory_bytes: 256
n = int(input())

restrunt=[]

for i in range(n):
    a, b = input().split()
    restrunt.append( {"s":a, "p":int(b), "nom":i+1} )

restrunt.sort(key=lambda res:res["p"], reverse=True)
restrunt.sort(key=lambda res: res["s"])

for res in restrunt:
    print(res["nom"])


Measured memory_bytes: 3060
a = "keyence"
s = gets.chomp

f = a.size.times.map{|i|a[i]==s[i]}
r = a.size.times.map{|i|a[-1-i]==s[-1-i]}

ans = 0
f.each{|b|
  break if !b
  ans+=1
}
r.each{|b|
  break if !b
  ans+=1
}

puts (ans>=7)? "YES":"NO"

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int A[3];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A[0]>>A[1]>>A[2];
	
	if(A[0]==A[1]) cout<<A[2]<<endl;
	if(A[0]==A[2]) cout<<A[1]<<endl;
	if(A[1]==A[2]) cout<<A[0]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 896
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		int a=sc.nextInt();
		int b=sc.nextInt();
		String u=sc.next();
		if(u.equals(s))System.out.println((a-1)+" "+b);
		else System.out.println(a+" "+(b-1));
	}
}

Measured memory_bytes: 21972
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
    cout << fixed << setprecision(10);
    int x;
    cin >> x;
    if (30 <= x)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }


    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(iinclude<snt i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

typedef pair<int, P> speP;

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

int h, w;
char mp[50][50];
int d[50][50];
void solve() {
	int n;
	cin >> n;
	vector<int> a(n+1);
	rep(i, n)cin >> a[i+1];
	vector<ll> dp(n+1), dp2(n+1);
	vector<int> isprime(1000001, 1);
	isprime[0] = isprime[1] = 0;
	for (int i = 2; i <= 1000000; ++i) {
		if (!isprime[i])continue;
		for (int j = 2 * i; j <= 1000000; j += i) {
			isprime[j] = false;
		}
	}
	dp[0] = 1;
	rep(i, n) {
		dp[i + 1] += dp2[i];
		if (a[i + 1] > a[i] && isprime[a[i + 1]])(dp2[i + 1] += dp2[i])%=mod;
		if (i >= 1 && a[i + 1] > a[i - 1] && isprime[a[i + 1]])(dp2[i + 1] += dp[i]) %= mod;
		if (i ==0  && isprime[a[i + 1]])dp2[i + 1] += dp[i];
	}
	cout << (dp[n] + dp2[n]) % mod << endl;

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	stop
		return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N;
    cin >> N;
    vec B(N-1);
    REP(i,0,N-1) cin >> B[i];

    ll sum = B[0];
    REP(i,1,N-1) sum += MIN(B[i],B[i-1]);
    sum += B[N-2];
    PR(sum);

    return 0;
}

/*

  B[i] >= max(A[i], A[i+1])
  <=> B[i] >= A[i] and B[i] >= A[i+1]
  
*/

Measured memory_bytes: 256
s = list(input())
s.reverse()
wl = 0 
rwl = 0 
ret = 0 
l = len(s)
for i in range(l):
    if s[i] == "W":
        wl += 1
    else:
        ret += rwl + wl
        rwl += wl
        wl = 0 
print(ret)

Measured memory_bytes: 4840
l = "qwertasdfgzxcvb"
r = "yuiophjklnm"
while True:
    s=input()
    if(s=='#') : break
    a = 0
    f = '0'
    for i in range(len(s)):
        if(s[i] in l):
            if(f!='l'):
                f='l'
                a+=1
        else:
            if(f!='r'):
                f='r'
                a+=1
    print(a-1)



Measured memory_bytes: 5564