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

long long n, x;

int main() {
  cin >> n >> x;
  if(x == 1 || x == 2 * n - 1) {
    cout << "No" << endl;
    return 0;
  }
  else
    cout << "Yes" << endl;
  if(x == n) {
    for(int i = 0; i < 2 * n - 1; ++i) {
      if(i != 0) cout << " ";
      cout << i + 1;
    }
    cout << endl;
  }
  else if(x < n) {
    for(int i = x + 1; i <= n; ++i) {
      if(i != x + 1) cout << " ";
      cout << i;
    }
    for(int i = 1; i <= n * 2 - 1; ++i)
      if(i <= x || i > n) {
        cout << " ";
        cout << i;
      }
    cout << endl;
  }
  else {
    for(int i = 1; i <= 2 * n - 1; ++i)
      if(i < n || i >= x) {
        if(i != 1) cout << " ";
        cout << i;
      }
    for(int i = n; i <= x - 1; ++i) {
      cout << " ";
      cout << i;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n;
  cin >> n;
  vector<pii> a(n);
  rep(i,n){
    cin >> a.at(i).first;
    a.at(i).second = i+1;
  }
  sort(a.begin(),a.end());
  rep(i,n) cout << a.at(i).second << " ";
  cout << endl;
}


Measured memory_bytes: 1664
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  double R;
  int numerator,denominator;
  while(cin>>R,R){
    for(denominator=1; denominator<100000; denominator++){
      numerator = (int)(denominator*M_PI);
      if(fabs((double)numerator/denominator - M_PI) <= R)break;
      if(fabs((double)(numerator+1.0)/denominator - M_PI) <= R){
	numerator++;
	break;
      }
    }
    cout<<numerator<<"/"<<denominator<<endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>

int main(){

    std::string s;

    std::cin >> s;

    auto cnt0 = std::count(s.begin(), s.end(), '0');
    auto cnt1 = std::count(s.begin(), s.end(), '1');

    if(cnt0 > 0 && cnt1 > 0){
        std::cout << 2 * std::min(cnt0, cnt1) << std::endl;
    }else{
        std::cout << 0 << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

  vector<ll> grand_garden(n); ll max_h = 0;
  rep(i, n) {
      cin >> grand_garden[i];
      max_h = max(grand_garden[i],max_h);
  }

  ll water_num = 0;
  while (true) {
    if (*max_element(grand_garden.begin(), grand_garden.end()) == 0) break;
    ll i = 0;
    while (i < n) {
        if (grand_garden[i] == 0) i++;
        else
        {
            water_num++;
            while (i < n && grand_garden[i] > 0)
            {
                /* code */
                grand_garden[i]--;
                i++;
            }
        }
    }
  }
  cout << water_num << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int n;
ll h[100010];
ll dp[100010];

ll rec(int i){
    if(dp[i]<INF)
        return dp[i];
    if(i==0)
        return 0;

    ll res = INF;
    rep(j,n)
    chmin(res, rec(i - 1) + abs(h[i] - h[i - 1]));
    if(i>1)
        chmin(res, rec(i - 2) + abs(h[i] - h[i - 2]));
    return dp[i] = res;
}
int main()
{
    int k;
    cin >> n>>k;
    rep(i, n) cin >> h[i];
    rep(i, 100010) dp[i] = INF;

    dp[0] = 0;

    rep(i,n){
        rep2(j,1,k+1){
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[n-1] << endl;

    return 0;
    
}

Measured memory_bytes: 1792
MOD=10**9+7
n,k=map(int,input().split())
a=list(map(int,input().split()))

a.sort(reverse=True)

#前計算
fact = [1]
fact_inv = [1]
mod=10**9+7
for i in range(n+1):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))

def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod
#前計算終わり
  
c=[]
for i in range(1,n-k+1+1):
  c.append(mod_comb_k(n-i,k-1,MOD))
  
lc=len(c)
sum=0
for i in range(lc):
  sum+=c[i]*(a[i]-a[-i-1])%MOD
  
print(sum%MOD)


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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define mod             1000000007
#define maxn            200001
#define PI              3.1415926535897932384626433832795
#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i];
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i];
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" ";
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" ";
#define manu            cout<<(checkerCounter++)<<endl;
static int checkerCounter = 1;
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int k;cin>>k;
    string s;cin>>s;
    if(s.size()<=k)cout<<s;
    else {
        s.erase(s.begin()+k,s.end());
        s+="...";
        cout<<s<<endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1e9 + 7;

int main(void) {
    int n;
    cin >> n;
    vector<int> A(n);
    for (int &a : A) cin >> a;

    long long result = 0, sum = 0;
    for (int i = n - 1; i > 0; i--) {
        sum = (sum + A[i]) % MOD;
        result = (result + A[i - 1] * sum) % MOD;
    }
    cout << result << endl;

    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vector<pll> task(n);
  REP(i,n){
    ll a,b;
    cin >> a >> b;
    task[i] = make_pair(a,b);
  }
  sort(task.begin(),task.end(),[](pll a,pll b){return a.second<b.second;});
  ll time = 0;
  REP(i,n){
    time += task[i].first;
    if(time>task[i].second){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a<b) {
			if(b<c) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 26344
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
    string S, T;
    cin >> S >> T; 
    map<char, char> mp1;
    map<char, char> mp2;

    for (int i = 0; i < T.length(); i++) {
        if ( mp1[T[i]] == 0 ) {
            mp1[T[i]] = S[i];
        } else if ( mp1[T[i]] != S[i] ) {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = 0; i < S.length(); i++) {
        if ( mp2[S[i]] == 0 ) {
            mp2[S[i]] = T[i];
        } else if ( mp2[S[i]] != T[i] ) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  ll ans=0;
  REP(i,1,n-1) {
    ll c[3]={a[i-1],a[i],a[i+1]};
    sort(c,c+3);
    if(c[1]==a[i]) ans++;
  }
  pr(ans);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  ll count = 0;
  int rem = 0;
  rep(i,N){
    ll x;cin >> x;
    if(rem==1 && x>0){
      --x;
      ++count;
    }
    count+=x/2;
    rem = x%2;
  }
  cout << count << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  ll ans = 0, cnt = 0, i;
  for (i = 0; i < s.size(); ++i) {
    if (s[i] == 'B') {
      ++cnt;
    }
    if (s[i] == 'W') {
      ans += cnt;
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

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

    int t[N], x[N], y[N];
    for (int i=0; i<N; i++){
	cin >> t[i] >> x[i] >> y[i];
    }
    
    int tc = 0, xc = 0, yc = 0;  bool res = true;
    for (int i=0; i<N; i++){
	int dt  = (t[i] - tc);
	int dis = abs((yc-y[i])+(xc-x[i]));
	//cout << t[i] << " : dis = " << abs(dis%2) << " ,dt = " << dt%2 << endl;
	if (dis%2 != dt%2 || dis > dt){ res = 0; break; }
	
	tc = t[i];
	xc = x[i];
	yc = y[i];
    }
    
    if (res){ cout << "Yes" << endl; }
    else {    cout << "No"  << endl; }
    
    return 0;
}


Measured memory_bytes: 1408
// F - Strivore
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// nCr(mod m)
#define MOD 1000000007
#define MAX 2000001// [n+1] 1_origin
#define mul(a,b) ((a)*(b)%MOD)
ll fac[MAX]; // 階乗 n!
ll inv[MAX]; // 逆元 1/n
ll finv[MAX]; // 逆元の階乗 (n^-1)! = (1/n)!
// n 個の配列に、mod で前処理する
void init(int n){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<=n; ++i){
		fac[i] = mul(fac[i-1], i);
		inv[i] = MOD - mul(inv[MOD%i], MOD/i);
		finv[i] = mul(finv[i-1], inv[i]);
	}
}
// nCr(mod m)
ll nCr(int n, int r){
	if(n<r || n<0 || r<0) return 0;
	return mul(fac[n], mul(finv[n-r], finv[r]));
}

int main(){
	int K; string S; cin>>K>>S;
	init(K + S.size());
	ll i25[K+1], i26[K+1];
	i25[0] = i26[0] = 1;
	for(int i=0; i<K; ++i){
		i25[i+1] = mul(i25[i], 25);
		i26[i+1] = mul(i26[i], 26);
	}
	ll ans = 0;
	for(int i=0; i<=K; ++i){
		ans += mul(mul(i25[i], i26[K-i]), nCr(i+S.size()-1, S.size()-1));
		ans %= MOD;
	}
	cout<< ans <<endl;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  ll ans = 0;
  using StA = pair<ll, ll>;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end(), greater<ll>());
  priority_queue<StA> pque;
  pque.emplace(A.at(1), A.at(0));
  pque.emplace(A.at(1), A.at(0));
  ans = A.at(0);
  for (ll i = 2; i < N; i++) {
    auto [x, y] = pque.top(); pque.pop();
    ans += x;
    pque.emplace(A.at(i), y);
    pque.emplace(A.at(i), x);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 8968
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


ll dp[1111][11111];

int main(void) {
  ll H, N;
  cin >> H >> N;
  ll i, j;
  ll a[1111], b[1111];
  ll max=0;
  
  for(i=0; i<N; i++) {
    cin >> a[i] >> b[i];
    chmax(max, a[i]);
  }
  
  
  for(i=0; i<N; i++) {
    for(j=0; j<=H; j++) {
      dp[i][j]=INF;
    }
  }
  dp[0][0]=0;
  
  for(i=0; i<N; i++) {
    for(j=0; j<=H; j++) {
      chmin(dp[i+1][j], dp[i][j]);
      chmin(dp[i][min(j+a[i], H)], dp[i][j]+b[i]);
    }
  }
  
  pt(dp[N-1][H]);
  
}



Measured memory_bytes: 88192
<?php

while (($line = trim(fgets(STDIN))) !== '') {
    if ($line === '-') {
        break;
    }

    $card = $line;
    fscanf(STDIN, '%d', $m);
    for ($i = 0; $i < $m; $i++) {
        fscanf(STDIN, '%d', $h);
        $card1 = substr($card, 0, $h);
        $card2 = substr($card, $h);
        $card = $card2 . $card1;
    }

    echo $card, PHP_EOL;
}

Measured memory_bytes: 6568
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int ans=0;
  for(int i=0; i<S.size(); i++){
    if(S.at(i)=='+')
      ans++;
    else if(S.at(i)=='-')
      ans--;
  }
  cout << ans << endl;
}


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

int main(void) {
  long long N;
  cin >> N;

  if (N % 2 != 0) {
    cout << 0 << endl;
  } else {
    long long five = 0;
    long long tmp = N;
    while (tmp > 0) {
      five += (tmp / 5) / 2;
      tmp /= 5;
    }
    cout << five << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#define SIZE 1000000007
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

int main(){
    string s;
    cin>>s;
    int ans=0,a=0;
    rep(i,s.size()){
        if(s[i]=='A')a++;
        else if(s[i]=='G')a++;
        else if(s[i]=='C')a++;
        else if(s[i]=='T')a++;
        else{
            if(ans<a)ans=a;
            a=0;
        }
    }
    if(ans<a)ans=a;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
R,G,B,N=map(int,input().split())
ans=0
 
for i in range(N//R+1):
    for j in range((N-R*i)//G+1):
        b=N-(R*i+G*j)
        if b==0 or  b%B==0: 
            ans+=1
 
print(ans)

Measured memory_bytes: 3060
/*
AOJ - ITP1_10_c
Date: 20181013
Author: Mikoron * ♡mikoiwate_351♡
*/

#include<stdio.h>
#include<math.h>
#include<stdlib.h>

#define NMAX 1000

int main(void) {

        short n, i;
        double s[NMAX], sum, m, a;

        while(1) {
                scanf("%hd", &n);

                if(n == 0) break;

                sum = 0.0;
                for(i = 0; i < n; i++) {
                        scanf("%lf", &s[i]);
                        sum += s[i];
                }
                m = sum / n;

                sum = 0.0;
                for(i = 0; i < n; i++) {
                        sum += pow(s[i]-m,2);
                }
                a = sqrt(sum/n);

                printf("%.7lf\n", a);
        }

        return 0;
}



Measured memory_bytes: 2068
use std::io::*;
use std::str::FromStr;

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

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let x = read::<i64>();
  let y = read::<i64>();
  let z = read::<i64>();

  println!(
    "{}",
    if x == y {
      z
    } else if x != z {
      x
    } else {
      y
    }
  );
}



Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char chr;
    char ans;
    cin >> chr;
    if (chr == 'A') {
        ans = 'T';
    } else if (chr == 'C') {
        ans = 'G';
    } else if (chr == 'G') {
        ans = 'C';
    } else {
        ans = 'A';
    }
    cout << ans;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0,a, count,ans=1;
		for(int i = 2;i <= n;i++) {
			count = 0;
			if(i % 2 == 1)continue;
			a = i;
			for(;;) {
				if(a / 2 != 0) {
					a = a/2;
					count++;
				}
				else {
					count++;
					break;
				}
			}
			if(max < count) {
				max = count;
				ans = i;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(A: int, B: float):
    s = int(B[0]) * 100
    x = int(B[2:])
    #ret = (B * 100 * A) // 100
    ret = ((s + x) * A) // 100
    print(int(ret))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = str(next(tokens))  # type: float
    solve(A, B)

if __name__ == '__main__':
    main()


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

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;

  cout << (X - Z) / (Y + Z) << endl;
  return 0;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  
  int na = n * a;

  if (na == b) {
    cout << na << endl;
  }
  else if (na > b) {
    cout << b << endl;
  }
  else {
    cout << na << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define N 10000

int main()
{
  int n, i, j, arr[N], count = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &arr[i]);
  }

  for(i = 0; i < n; i++){
    if(arr[i] == 2) count++;
    if(arr[i] < 2 || arr[i] % 2 == 0) continue;
    for(j = 3; j <= sqrt(arr[i]); j+=2){
      if(arr[i] % j == 0) break;

    }

    if(j > sqrt(arr[i])) count++;

  }

  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 628
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
N = int(input())
for i in range(N) :
    b, f, r, v = map(int,input().split())
    count[b - 1][f - 1][r - 1] += v
for i in range(4) :
    if i > 0 :
        print("#"*20)
    for j in range(3) :
        for k in range(10) :
            print(" ", end = "")
            print(count[i][j][k], end = "")
        print()


Measured memory_bytes: 5636
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int X;
   cin >> X;
   X = abs(X);
   int min = sqrt(2 * X) - 2;
   int max = sqrt(2 * X) + 1;
   
   for (int i = min; i <= max; i++) {
      if (i * (i + 1) < 2 * X && 2 * X <= (i + 1) * (i + 2)) cout << i + 1 << endl;
   }

   return 0;
}


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

int main(){

  double a[5],d,c;
  int n;

  while(cin >> a[0] >> a[1] >> a[2], a[0], a[1], a[2]){
    cin >> n;

    sort(a,a+3);

    c = sqrt(a[0]*a[0] + a[1]*a[1]);

    for(int i=0;i<n;i++){
      cin >> d;

      if(2*d > c) cout << "OK" << endl;
      else cout << "NA" << endl;

    }
  }
}

Measured memory_bytes: 1240
//##MohK..
//21/04/2020....6.00...
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ld a;
    cin>>a;
    cout<<a*6.28318530717958623200;

    return 0;
}


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

using namespace std;

typedef long long ll;

bool check(ll ans)
{
	ans++;
	while(ans % 10 == 0) ans /= 10;
	return ans == 1;
}

int main()
{
	ll ans = -1;
	for(ll l = 1e9, r = 1e10 - 1; l <= r; ) {
		ll md = (l + r) / 2;
		printf("? %lld\n", md), fflush(stdout);
		char ch[5];
		scanf("%s", ch);
		if(ch[0] == 'Y') ans = md, r = md - 1; else l = md + 1;
	}
	for(; ans ;) {
		printf("? %lld\n", ans + 1), fflush(stdout);
		char ch[5];
		scanf("%s", ch);
		if(!check(ans) && ch[0] == 'N' || check(ans) && ch[0] == 'Y') {printf("! %lld\n", ans * 10), fflush(stdout); return 0;}
		if(ans % 10 != 0) {printf("! %lld\n", ans), fflush(stdout); return 0;}
		ans /= 10;
	}
	/*ll n = (long long) (1e17) - 1;
	for(ll i = 1, o = 1e16; ; o /= 10, i++) {
		int ans = -1;
		/*if(i != 1) {
			printf("? %lld\n", n);
			fflush(stdout);
			char ch[5];
			scanf("%s", ch);
			if(ch[0] == 'Y') {printf("! %lld\n", n / o / 10); fflush(stdout); return 0;}
		}
		for(int l = 0, r = 9; l <= r; ) {
			int md = (l + r) / 2;
			printf("? %lld\n", n + md * o);
			fflush(stdout);
			char ch[5];
			scanf("%s", ch);
			if(ch[0] == 'Y') ans = md, r = md - 1; else l = md + 1;
		}
		if(ans == -1) {printf("! %lld\n", n / o / 10); fflush(stdout); return 0;}
		n += ans * o;
	}*/
	return 0;
}

Measured memory_bytes: 596
/* 	* In the name of GOD 
 	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long

bool is_prime(int x){
	for (int i = 2; i * i <= x; i++){
		if (x % i == 0)
			return false;
	}
	return true;
}

int32_t main(){
	int n;
	cin >> n;
	if (n == 1)
		return cout << 0, 0;
	if (is_prime(n))
		return cout << 1, 0;
	int x = n;
	int ans = 0;
	map <int, int> mp;
	for (int i = 2; i * i <= n; i++){
		if (x == 1)
			break;
		if (x % i == 0){
			while (x % i == 0)
				mp[i]++, x /= i;
		}
		if (x == 1)
			break;
		int y = n / i;
		if (x % y == 0){
			if (!is_prime (y))
				continue;
			while (x % y == 0)
				mp[y]++, x /= y;
		}
	}
	for (auto g : mp){
//		cout << g.F << ' ' << g.S << endl;
		int y = max(0ll, (ll)(sqrt(g.S * 2)) - 5);
		int an;
		for (int i = y; i < y + 10; i++){
			if ((i * (i + 1)) / 2 <= g.S)
				an = i;
		}
		ans += an;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3720
#include<stdio.h>

int selectionSort(int A[],int N){
	int sw=0,i,j,minv,minj;
	for(i=0;i<N;i++){
		minv=A[i];
		minj=i;
		for(j=i+1;j<N;j++){
			if (A[j]<minv){
				minv=A[j];
				minj=j;
			}
		}
		if(minj!=i){
			sw++;
			int tmp=A[i];
			A[i]=A[minj];
			A[minj]=tmp;
		}
	}
	return sw;
}

int main(){
	int A[100],N,i;
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	int sw=selectionSort(A,N);
	printf("%d",A[0]);
	for(i=1;i<N;i++) printf(" %d",A[i]);
	printf("\n%d\n",sw);
	return 0;
}



Measured memory_bytes: 2768
from bisect import bisect_left as lower_bound, bisect_right as upper_bound

mod = 10**9 + 7

def inversion_count(arr, n, k):
	b = []
	cnt = 0
	for i in range(n-1, -1, -1):
		pos = lower_bound(b, arr[i])
		cnt = (cnt + pos)%mod
		b.insert(pos, arr[i])
	
	cnt = (cnt*k)%mod	
	
	for i in range(n):
		pos = lower_bound(b, arr[i])

		cnt = (cnt + ((k*(k-1))//2)*pos)%mod

	
	return cnt



def main():
	n,k = list(map(int, input().strip().split()))

	arr = list(map(int, input().strip().split()))

	print (inversion_count(arr, n, k))

if __name__ == "__main__":
	main()


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<unordered_map>
#include<string.h>
#include<math.h>
using namespace std;
using ll = long long;
int main(){
    ll N;
    cin >> N;
    ll A[200020];
    ll sum = 0;
    ll now = 0;
    ll ans = 1e18;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        sum += A[i];
    }
    for(int i = 0;i < N;i++){
        now += A[i];
        sum -= A[i];
        if(abs(now - sum) < ans)ans = abs(now - sum);
    }
    cout << ans;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    int n;
    cin>>n;
    vector<ll> l(n);
    rep(i,0,n)cin>>l[i];

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

    int ans=0;
    rep(i,0,n){
        rep(j,i+1,n){
            rep(k,j+1,n){
                if(l[i]+l[j]<=l[k])continue;
                if(l[i]<l[j]&&l[j]<l[k]){ans++;}
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

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

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

        if x == y:
            return

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

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
ab = [list(map(int, input().split())) for i in range(m)]

ans=0
u=UnionFind(n)
for a,b in ab:
    u.union(a-1,b-1)

for i in range(n):
    ans=max(ans,u.size(i))
    
print(ans)






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

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

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

       if x == y:
           return

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

       self.parents[x] += self.parents[y]
       self.parents[y] = x

   def size(self, x):
       return -self.parents[self.find(x)]

   def same(self, x, y):
       return self.find(x) == self.find(y)

   def members(self, x):
       root = self.find(x)
       return [i for i in range(self.n) if self.find(i) == root]

   def roots(self):
       return [i for i, x in enumerate(self.parents) if x < 0]

   def group_count(self):
       return len(self.roots())

   def all_group_members(self):
       return {r: self.members(r) for r in self.roots()}

   def __str__(self):
       return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,k,l = map(int,input().split())
uf1 = UnionFind(n)
uf2 = UnionFind(n)

for _ in range(k):
   p,q = map(int,input().split())
   p -= 1
   q -= 1
   uf1.union(p,q)

for _ in range(l):
   r,s = map(int,input().split())
   r -= 1
   s -= 1
   uf2.union(r,s)

from collections import defaultdict
dic = defaultdict(int)
pair = []
for i in range(n):
   pair.append((uf1.find(i), uf2.find(i)))
   dic[(uf1.find(i), uf2.find(i))] += 1

for i in range(n):
   print(dic[pair[i]])

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

class UnionFind
{
public:
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL)
    {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i;
    }
    void init(ll sz_)
    {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i)
            par[i] = i;
    }

    ll root(ll x)
    {
        while (par[x] != x)
        {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool merge(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y)
    {
        return root(x) == root(y);
    }

    ll size(ll x)
    {
        return siz[root(x)];
    }
};

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, halfP);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

/*
int num = 200010;
vector<ll> fact(num), ifact(num);
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i < num; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= mod;
}
for (int i = 0; i < num; i++) {
    ifact[i] = modpow(ifact[i], mod-2);
    ifact[i] %= mod;
}
*/

vector<int> link[100010];
int dist[2][100010];

void dfs(int v, int p, int d, int w) {
    dist[w][v] = d;
    for (int nv : link[v]) {
        if (nv == p) continue;
        dfs(nv, v, d + 1, w);
    }
}

int main() {
    int n; cin >> n;
    int c1 = 0, c2 = 0;
    rep(i, n-1) {
        int x, y; cin >> x >> y;
        x--; y--;
        link[x].pb(y);
        link[y].pb(x);
    }

    dfs(0, -1, 0, 0);
    dfs(n - 1, -1, 0, 1);

    rep(i, n) {
        if (dist[0][i] <= dist[1][i]) {
            c1++;
        } else {
            c2++;
        }
    }
    if (c1 > c2) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    return 0;
}

Measured memory_bytes: 12800
import numpy as np

n, k, q = map(int, input().split())
A = [int(input())-1 for i in range(q)]
P = np.ones(n) * k - q
for a in A:
    P[a] += 1
P = np.where(P > 0, 'Yes', 'No')
for p in P:
    print(p)

Measured memory_bytes: 18884
f1,f2,f3 = map(int,input().split())
d1 = f2 - f1
d2 = f3 - f2
flag = True
for _ in range(2):
    c1,c2,c3 = map(int, input().split())
    if c2-c1 != d1 or c3-c2 != d2:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int b[3][3];
	for(int i=0;i<3;i++)
	{
		cin>>a;
		b[i][0]=a[0];
		b[i][1]=a[1];
		b[i][2]=a[2];
	}
	string c;
	c.push_back(b[0][0]);
	c.push_back(b[1][1]);
	c.push_back(b[2][2]);
	cout<<c;
	return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int> > vc(M, vector<int>(4));
  for (int i=0; i<M; i++){
    int p, y;
    cin >> p >> y;
    vc[i][0] = i, vc[i][1] = p, vc[i][2] = y;
  }
  sort(vc.begin(), vc.end(), [](const auto& a, const auto& b){return a[2]<b[2];});
  vector<int> num(N+1,1);
  for (int i=0; i<M; i++){
    vc[i][3] = num[vc[i][1]];
    num[vc[i][1]]++;
  }
  sort(vc.begin(), vc.end(), [](const auto& a, const auto& b){return a[0]<b[0];});
  for (int i=0; i<M; i++){
    cout << setfill('0') << right << setw(6) << vc[i][1];
    cout << setfill('0') << right << setw(6) << vc[i][3] << endl;
  }
}


Measured memory_bytes: 7808
S = input()
stack_0 = []
stack_1 = []
cnt = 0
for s in S:
    if s == '0':
        if stack_1:
            cnt += 1
            stack_1.pop()
        else:
            stack_0.append('0')
    else:
        if stack_0:
            cnt += 1
            stack_0.pop()
        else:
            stack_1.append('1')

print(cnt*2)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
bool cmp(pair<ll, ll>& a, pair<ll, ll>& b)
{
  if(a.first == b.first)
  {
    return a.second < b.second;
  }
  return a.first < b.first;
}

int main()
{
 ll q,n, r, avg, i, j, x, y, d, a, c;
 string s;
 while(cin >> s)
 {
   c = 0, d = 0;
   for(i = 0; i < s.size(); i++)
   {
     if(i % 2 == 1 && s[i] == '0'){
       c++;
     }else if(i % 2 == 0 && s[i] == '1'){
       c++;
     }

   }
   for(i = 0; i < s.size(); i++)
   {
     if(i % 2 == 1 && s[i] == '1'){
       d++;
     }else if(i % 2 == 0 && s[i] == '0'){
       d++;
     }

   }
   cout << min(c, d) << endl;
  
 }
 return 0;
}

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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define mod             1000000007
#define maxn            200001
#define PI              3.1415926535897932384626433832795
#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i];
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i];
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" ";
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" ";
#define manu            cout<<(checkerCounter++)<<endl;
static int checkerCounter = 1;
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    h=(int)h%12;
    m=(int)m%60;
//    cout<<"H:"<<h<<" M:"<<m<<endl;
    double theta1,theta2;
    theta1=(h*2*PI)/12;
    theta2=(m*2*PI)/60;
    theta1+=(theta2/12);
//    cout<<"th1:"<<theta1<<" th2:"<<theta2<<endl;
//    cout<<"hr:"<<theta1<<" min:"<<theta2<<endl;
    double x1,x2,y1,y2;
    x1=a*(sin(theta1));
    y1=a*(cos(theta1));
    x2=b*(sin(theta2));
    y2=b*(cos(theta2));
//    cout<<"hr:"<<x1<<" "<<y1<<endl;
//    cout<<"min:"<<x2<<" "<<y2<<endl;
    double x=abs(x1-x2);
    double y=abs(y1-y2);
//    cout<<"x: "<<x<<" y:"<<y<<endl;
    x*=x;y*=y;
    double dis=sqrt(x+y);
    cout<<setprecision(30)<<dis<<endl;
}


Measured memory_bytes: 4128
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int N;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s.at(i);
    }
    int M;
    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++) {
        cin >> t.at(i);
    }
    
    auto counter = [&] (string u) {
        int cnt = 0;
        for (string scomp : s) {
            if (u == scomp) cnt++;
        }
        for (string tcomp : t) {
            if (u == tcomp) cnt--;
        }
        return cnt;
    };
    
    int ans = 0;
    for (string scomp : s) {
        ans = max(ans, counter(scomp));
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int n;
int h[101010];

int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> h[i];
        if(!i)h[i]--;
        else{
            if(h[i - 1] < h[i])h[i]--;
            else if(h[i - 1] > h[i]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    ll K, N;
    cin >> K >> N;
    vector<ll> A(N);
    REP(i, N) cin >>A[i];
    ll d = 0;
    REP(i, N-1) d = max(A[i+1]-A[i], d);
    d = max(d, K-A[N-1]+A[0]);
    cout << K - d << endl;
    return 0;
}

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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    long long a;
    while (cin >> a) {
        cout << a*a*a + a*a + a << endl;
    }
}

















Measured memory_bytes: 3620
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

n, s = nm()
a = nl()
mod = 998244353
dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
    v = a[i]
    for j in range(s, -1, -1):
        dp[i+1][j] = dp[i][j] * 2 % mod
        if v + j <= s:
            dp[i+1][v+j] = (dp[i+1][v+j] + dp[i][j]) % mod

print(dp[-1][-1])


Measured memory_bytes: 132468
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;} 
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n-8) cout << s[i];
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)

p1 = p[:X]
q1 = q[:Y]

pqr = p1 + q1 + r

pqr.sort(reverse = True)

ans = 0
for i in range(X+Y):
  ans += pqr[i]
  
print(ans)

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

ll H, W;
vector<vector<ll>> c(10, vector<ll>(10));
vector<vector<ll>> A, d(10, vector<ll>(10, 0));

void Warshall_Floyd() {
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

void solve() {
  d = c;
  Warshall_Floyd();

  ll res = 0;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A[i][j] != -1) {
        res += d[A[i][j]][1];
      }
    }
  }

  cout << res << "\n";
}

int main() {
  cin >> H >> W;
  A.resize(H, vector<ll>(W));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
    }
  }
  solve();
  return 0;
}


Measured memory_bytes: 512
<?php
list($N,$L)=sscanf(trim(fgets(STDIN)),"%d %d");
$total = 0;
$total2 = 0;
for($i=1;$i<=$N;$i++){
    $total += $i + $L - 1;
}

$min = 8888888888888;
for($j = 1; $j <= $N; $j++){
    for($i=1;$i<=$N;$i++){
        if($j != $i){
            $total2 += $i + $L - 1;
        }
    }
        if (abs($total - $total2) < $min){
            $min = abs($total - $total2);
            $age = $total2;
        }
        $total2 = 0;
    
}
printf($age);

Measured memory_bytes: 4728
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    while(true) {
      if(isPrime(n)) {
        System.out.println(n);
        break;
      } else {
        n = nextOdd(n);
      }
    }
  }

  private static int nextOdd(final int n) {
    if(n % 2 == 1) {
      return n + 2;
    } else {
      return n + 1;
    }
  }

  private static boolean isPrime(final int n) {
    if(n == 2) {
      return true;
    }
    if(n < 2 || n % 2 == 0) {
      return false;
    }
    for (int i = 3; i <= Math.sqrt(n); i = nextOdd(i)) {
      if(n % i == 0) {
        return false;
      }
    }
    return true;
   }
}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define N 100010
#define inf 2^32-1
char a[N];
int main()
{
    int x,t;
    while(scanf("%s",a)!=EOF){
        int len=strlen(a);
        for(int i=0;i<len;i++){
            if(i%2==0) cout<<a[i];
        }
        cout<<endl;
    }
    return 0;
}


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

import bisect 

def func(x):
  C = 0
  for p in l:
    q = x -p
    j = bisect.bisect_left(l, q)
    C += n-j
  if C >= m:
    return True
  else:
    return False
  
l_ = 0
r_ = 2*10**5 +1
while l_+1 < r_:
  c_ = (l_+r_)//2
  if func(c_):
    l_ = c_
  else:
    r_ = c_
    
ans = 0
cnt = 0
lr = sorted(l, reverse=True)
from itertools import accumulate
cum = [0] + list(accumulate(lr))
for i in lr:
  j = bisect.bisect_left(l, l_-i)
  ans += i*(n-j) + cum[n-j]
  cnt += n -j
ans -= (cnt-m)*l_
print(ans)

Measured memory_bytes: 61516
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int main() {
	int a, b;

	std::cin >> a >> b;

	std::cout << (a*b) - b - a + 1 << std::endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

    static long N;
    static int M;
    static int A;
    static long B;
    static long C;
    static int[] map = new int[1000000];
    static int min = 9999999;




    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while(true) {
            int N = scanner.nextInt();
            if(N == 0)break;
            int[] A = new int[N];
            int[][] dp = new int[N][N];
            for (int i = 0; i < N; i++) {
                A[i] = scanner.nextInt();
            }

            for (int w = 1; w < N; w++) {
                for (int i = 0; i < N - w; i++) {
                    int j = i + w;
                    int max = 0;

                    for (int k = i; k <= j - 1; k++) {
                        max = Math.max(max, dp[i][k] + dp[k + 1][j]);
                    }

                    if(Math.abs(A[i] - A[j]) <= 1 && w % 2 == 1 && dp[i + 1][j - 1] == w - 1){
                        max = w + 1;
                    }
                    dp[i][j] = max;
                }
            }

            System.out.println(dp[0][N - 1]);

        }




    }
}




Measured memory_bytes: 66812