akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a) (a).begin(), (a).end()
#define out(a) cout << (a) << endl

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> s >> k;

	n = s.size();
	vector<string> vs;
	rep(i, n){
		for(j = 1; j < k+1 && i+j < n+1; j++){
			vs.push_back(s.substr(i, j));
		}
	}

	sort(ALL(vs));

	vs.erase(unique(ALL(vs)), vs.end());

	out(vs[k-1]);
}

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

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i += 2) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll ar[M];

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

	ll n,m,i,c = 0,s = 0;

	cin >> n >> m;
	for(i=1;i<=n;++i)
	{
		cin >> ar[i];
		s += ar[i];
	}

	for(i=1;i<=n;++i)
	{
		if(4*m*ar[i]>=s)
			c++;
	}

	if(c<m)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans=1;
ll x[100005],y[100005],z[100005];
vector<ll> p[3];
bool dpx[100005],dpy[100005];
char s[100005];

int main(){
	cin>>k>>a;
	for(i=0;i<a;i++){
		cin>>x[i];
	}
	sort(x,x+a);
	num=x[a-1];
	b=k-num;
	
	p(max(num-b-1,0ll));
	return 0;
}

Measured memory_bytes: 5504
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

INF = 10 ** 20
n = int(input())
h = [INF] + list(map(int, input().split())) + [INF]

dp = [INF] + [INF] * n + [INF]
dp[1] = 0

for i in range(1, n):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))

print(dp[n])


Measured memory_bytes: 55120
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    int h,w;
    int n;
    cin>>h>>w>>n;
    int cnt=0;
    int sum=0;
    while(1){
        if(sum<n){
            cnt++;
            sum+=max(h,w);
        }
        else{
            break;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d\n",&W,&H,&x,&y,&r);
    if((x <= W-r && r <= x) && (r <= y && y <= H-r)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}


Measured memory_bytes: 2604
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    ll ans = 0LL;

    vector<vector<ll>> cnt(10, vector<ll>(10, 0));
    for(int i=1;i<=n;++i) {
        int ld = i % 10;
        int md = ld;
        int ii = i;
        while(ii >= 10) {
            ii /= 10;
            md = ii % 10;
        }
        if(md != 0 && ld != 0) {
            ++cnt[md][ld];
        }
    }

    for(int i=1;i<=9;++i) {
        for(int j=1;j<=9;++j) {
            // cerr << i << ", " << j << ": " << cnt[i][j] << endl;
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;
}


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

int main()
{
long long int n,i,j,a;

while(1)
{
   cin>>n>>a;
   if(n==0 && a==0)
        break;

for(i=0;i<n;i++)
{
    for(j=0;j<a;j++)

    {
          cout<<"#";
    }
cout<<endl;
}
cout<<endl;
}



}



Measured memory_bytes: 3088
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll,ll>pll;



int main(){
	ll r, d;
	cin >> r >> d;
	vector<ll>x(20);
	cin >> x[0];

	rep(i, 0, 10) {
		x[i + 1] = r * x[i] - d;
		cout << x[i + 1] << endl;
	}


	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = 1e9;

ld dp[3005][3005];

int main() {
  ll n;
  ld ans = 0;
  cin >> n;
  vector<ld> p(n);
  rep(i, n) cin >> p[i];

  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]);
    }
  }
  for (int i = (n + 1) / 2; i <= n; ++i) ans += dp[n][i];

  cout << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 139264
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXN = 200;

int n;
ll a[MAXN];
char s[MAXN + 1];

vector<ll> b;

int solve() {
	b.clear();
	for (int i = n - 1; i >= 0; --i) {
		ll x = a[i];
		REPSZ(j, b) {
			ll y = x ^ b[j];
			x = min(x, y);
		}
		if (x == 0) continue;
		if (s[i] == '1') return 1;
		b.PB(x);
	}
	return 0;
}

void run() {
	scanf("%d", &n);
	REP(i, n) scanf("%lld", &a[i]);
	scanf("%s", s); assert(strlen(s) == n);
	printf("%d\n", solve());
}

int main() {
	int ncase; scanf("%d", &ncase); FORE(i, 1, ncase) run();
	return 0;
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

ll factorial(ll x) {
    ll f = 1;
    if (x == 0) return 1;
    for (ll i = 0; i < x; i++) {
        f = (f*(i + 1))%mod;
    }
    return f;
}

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

int main(){
    ll N,M;
    cin>>N>>M;
    ll cmb = (factorial(M) * pow(factorial(M-N),mod-2,mod))%mod;
    ll cnt = 1;
    ll C = 1;
    ll P = 1;
    ll ans = 0;
    for(ll i = 0; i < N+1; i++){
        ans = (ans + cnt*(C*((P*((cmb*cmb)%mod))%mod)%mod))%mod;
        cnt *= -1;
        C = (C * (((N-i) * pow(i+1,mod-2,mod))%mod))%mod;
        P = (P*(M-i))%mod;
        cmb = (cmb * pow(M-i,mod-2,mod))%mod;
    }
  	if(ans<0) ans+=mod;
    cout<<ans<<endl;
}

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


int main()
{
  double a,b,h,m;
  cin>>a>>b>>h>>m;
  
  const double pi = 3.141592653589793;
  
  double rad_h=2*pi*((60*h+m)/720);
  double rad_m=2*pi*(m/60);
  
  double rad=rad_h-rad_m;
  double result=0;
  double sum=a*a+b*b-2*a*b*cos(rad);
  result=sqrt(sum);
  
  cout.precision(10);
  cout<<result<<endl;
}
  
  

Measured memory_bytes: 4228
#include <stdio.h>

int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A < C && B > C){
        printf("Yes\n");
    }else if(A > C && B < C){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#include <set>
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define vii vector<pair<int, int> >
#define si stack<int>
#define pb push_back
#define mp make_pair
#define ALL(T) (T).begin(), (T).end()
#define MODU 1000000007
typedef long long ll;
using namespace std;

ll intmax = (1LL<<32)-1;
ll llmax = (1LL<<60)-1;

const int INF = 1e9 + 5;

class fastio{
public:
	fastio(){
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	}
} __fastio;

template <typename T>
T abs(T x){
	if(x<0)	return -x;
	else return x;
}

void DFSVisit(int u, vector<int> g[], vector<bool> &visited){ 
    visited[u] = true;
    for(int i=0; i<g[u].size(); i++){
        if(!visited[g[u][i]]){
            DFSVisit(g[u][i], g, visited); 
        }
    }
} 
  
void DFS(vector<int> adj[], int V){
    vector<bool> visited(V, false); 
    for(int u=0; u<V; u++) 
        if(!visited[u]) 
            DFSVisit(u, adj, visited);
}


void solve(){
	
}

int main(){
	int n, l;
	cin >> n >> l;
	int x = l;
	int ans = INF;
	for(int i=0; i<n; i++){
		if(abs(x) < abs(ans))
			ans = x;
		x++;
	}
	int sum = 0;
	for(int i=0; i<n; i++){
		sum += i;
	}
	sum += n*l;
	cout << sum - ans;
}

Measured memory_bytes: 256
# include <stdio.h>

int main(){
    char str[4];
    scanf("%s", str);
    int ma = 0;
    
    for (int i =0; i < 3; ++i){
        if (str[i] == '1')
            ma += 1;
    }
    printf("%d\n", ma);
    
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int n,m,M=1e9+7,i,a,c[100010],d[100010]={};
  c[0]=c[1]=1;
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d",&a);
    d[a]=1;
  }
  for(i=1;i<n;i++)c[i+1]=(c[i]*(1-d[i])+c[i-1]*(1-d[i-1]))%M;
  printf("%d\n",c[n]);
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
ll n,l[101],result=0;
cin>>n;
if(n<=2){
 cout<<"0";
 return 0; 
}
for(ll i=0;i<n;i++){
    cin>>l[i];
}
for(ll i=1;i<=n;i++){
    for(ll k=i+1;k<=n;k++){
        
        for(ll m=k+1;m<=n;m++){
            //cout<<i<<" "<<k<<" "<<m<<"    ";
            if(l[m-1]==l[k-1]||l[m-1]==l[i-1]||l[k-1]==l[i-1]){
              ll a=0;
            }else{
          	
            ll sum_length=l[m-1]+l[k-1]+l[i-1];
            if(max(l[m-1],max(l[i-1],l[k-1]))*2<sum_length){
                result++;
                //cout<<"answer:"<<l[m-1]<<" "<<l[k-1]<<" "<<l[i-1];
            }
            }
       	//cout<<"\n";
        }
    }
}
cout<<result;
return 0;
}






ll gcd(ll a, ll b){

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

}

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


int check_around(int i, int j, int h, int w, vector<string>& vec) {
	bool hz = i > 0;
	bool hh = i < h - 1;
	bool wz = j > 0;
	bool ww = j < w - 1;

	int count = 0;
	if (hz) count += (vec[i-1][j] == '#' ? 1 : 0);
	if (hh) count += (vec[i+1][j] == '#' ? 1 : 0);
	if (wz) count += (vec[i][j-1] == '#' ? 1 : 0);
	if (ww) count += (vec[i][j+1] == '#' ? 1 : 0);
	if (hz&&wz) count += (vec[i-1][j-1] == '#' ? 1 : 0);
	if (hz&&ww) count += (vec[i-1][j+1] == '#' ? 1 : 0);
	if (hh&&wz) count += (vec[i+1][j-1] == '#' ? 1 : 0);
	if (hh&&ww) count += (vec[i+1][j+1] == '#' ? 1 : 0);
	
	return count;
}

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> vec(h);
	for(int i = 0; i < h; i++) cin >> vec[i];

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (vec[i][j] == '.') {
				cout << check_around(i, j, h, w, vec);
			} else {
				cout << vec[i][j];
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
import sys
a=int(input())
c=0
b=list(map(int,input().split()))
for i in range(a):
  if b[i]%2==0:
    
    if b[i]%3==0 or b[i]%5==0:
      pass
    else:
      print('DENIED')
      sys.exit()
  else:
    c+=1
    pass
print('APPROVED')

    


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;


int main(){
    
    
    while(true){
    int n,k;
    cin>>n>>k;
        if(n==0&&k==0)break;
    vector<ll> a(n);
    REP(i,n)cin>>a[i];
    
    ll sum=0;
    REP(i,k)sum+=a[i];
    
    ll ans=sum;
    for(int i=k;i<n;i++){
        sum-=a[i-k];
        sum+=a[i];
        ans=max(ans,sum);
    }
    
    cout<<ans<<endl;
    
    }
    return 0;
}

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

using namespace std;

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

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,k;
    cin >> n >> k;
    double ans = 0;
    double t = 1;
    for(int i = n; i > 0; i--){
        if(i >= k)ans += 1.0*t/n;
        else{
            while(i*t < k){
                t *= 2;
            }
            ans += 1.0/t/n;
        }
        //cout << shosu(10) << t << " " << ans << endl;
    }
    cout << shosu(10) << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dl cout<<"LINE"<<__LINE__<<endl;
#define dbg(x) cout<<#x<<" = "<<x<<endl; 
using namespace std;
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	if(n<=a)cout<<n<<endl;
	else{
		cout<<(n/(a+b))*a+(min(n%(a+b),a))<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;

int main()
{
  string n;
  in n;

  cout<<n[0]<<n[1]<<n[2]<<endl;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.length();
    int odd = 0, even = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0 && s.at(i) == '0') even++;
        else if(i % 2 == 1 && s.at(i) == '0') odd++;
    }
    if(n % 2 == 0){
        int half = n / 2;
        cout << min((half - even + odd), (half - odd + even)) << endl;
    }
    else{
        int half = n / 2;
        cout << min((half + 1 - even + odd), (half - odd + even)) << endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>

int n;
ll a[111111];


int main(){
    cin>>n;
    rep(i,n)cin>>a[i+1];
    
    a[0]=-1;
    a[n+1]=111111111111LL;
    
    for(int i=1;i<=n;i++){
        if(a[i-1]<=a[i]-1&&a[i]-1<=a[i+1])a[i]--;    
    }
    
    //rep(i,n)cout<<a[i]<<" ";cout<<endl;
    //for(int i=1;i<=n;i++)cout<<a[i]<<" ";cout<<endl;
    
    for(int i=1;i<=n-1;i++){
        if(a[i]>a[i+1]){cout<<"No"<<endl;
        return 0;
        }
    }
    
    cout<<"Yes"<<endl;
    
    
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }

ull gcd(ull x, ull y) {
  if (y > x)
    return gcd(y, x);

  auto r = x % y;
  if (r == 0)
    return y;
  else
    return gcd(y, r);
}

int main() {
  ull n;
  vector<ull> abcde;
  cin >> n;
  each(i, 5) {
    ull tmp;
    cin >> tmp;
    abcde.push(tmp);
  }

  ull result = 0;
  auto bottleneck = *min_element(abcde.begin(), abcde.end());
  if (n % bottleneck == 0) {
    result = (n / bottleneck) + 4;
  } else {
    result = (n / bottleneck) + 5;
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// square1001氏.
// https://atcoder.jp/contests/code-festival-2016-quala/submissions/1939048
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int N, M, Q, a[100009], c[100009], p[100009], inv[100009];
int main(){
    scanf("%d%d%d", &N, &M, &Q);
    rep(i, Q) scanf("%d", &a[i]), a[i]--;
    rep(i, M) inv[i] = -1;
    int cur = 0;
    repr(i, Q - 1, 0){
        if(inv[a[i]] == -1){
            inv[a[i]] = cur;
            c[cur] = 1;
            p[cur++] = a[i];
        }else{
            if(c[inv[a[i]]] < (inv[a[i]] == 0 ? N : c[inv[a[i]] - 1])) c[inv[a[i]]]++;
        }
    }
    rep(i, M) if(inv[i] == -1) p[cur++] = i;
    bool ret = true;
    rep(i, M) if(i >= 1 && c[i - 1] != N && p[i - 1] > p[i]) ret = false;
    printf(ret ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7
vector<int>dp; 

int min_cost(int b[],int n){
//	cout<<n<<" ";
         if(n==0){
		   dp[n]=b[n]; 
		   return 0;}
		 if(n==1)
		    return  dp[n]=abs(b[n]-b[n-1]);
         if(dp[n] !=-1)
         return dp[n];
         
       return  dp[n]=min( (abs(b[n]-b[n-1])+min_cost(b,n-1)),
                           (abs(b[n]-b[n-2])+min_cost(b,n-2) ) );
                           
         

}

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);    
          int n;
             cin>>n;
             dp.resize(n+1);
             for(int i=0; i<=n; i++)
               dp[i]=-1;
        //     memset(dp,-1,sizeof(dp));
             int b[n];
             for(int i=0; i<n; i++)
                cin>>b[i];
                
          cout<<min_cost(b,n-1)<<endl;; 
      //   for(int i=0; i<n; i++)
        //   cout<<dp[i]<<" ";           
    }
//a z q !

Measured memory_bytes: 4224
# Author: cr4zjh0bp
# Created: Sat Mar 14 11:48:11 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n, k = nin(2)
x = na()

ans = 0
for i in range(n):
    ans += min(abs(x[i] - k) * 2, abs(x[i]) * 2)

print(ans)

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

int main()
{
    std::string s;
    std::cin>>s;
    if(s[0]=='S')std::cout<<"Cloudy"<<std::endl;
    if(s[0]=='C')std::cout<<"Rainy"<<std::endl;
    if(s[0]=='R')std::cout<<"Sunny"<<std::endl;
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k;
  string s;
  cin >> n >> k >> s;
  string t = s;
  reverse(t.begin(), t.end());
  string mi = s;
  s += t;
  for (int i = 0; i < n; i++) {
    mi = min(mi, s.substr(i,n));
  }
  k--;
  while (k--) {
    char c = mi[0];
    int cs = 0;
    while (cs < n && mi[cs] == c) cs++;
    if (cs == n) break;
    mi = (mi.substr(0,cs)+mi).substr(0,n);
  }
  cout << mi << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


ll gcd(ll x, ll y) {
  return y ? gcd(y, x%y) : x;
}

vector<pair<ll, int>> factorization(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n % i) continue;
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n, 1);
  return res;
}

vector<bool> sieve(vector<bool> IsPrime, ll n) {
  if (n+1 > IsPrime.size()) {
    IsPrime.resize(n+1, true);  // IsPrime に必要な要素数を確保
  }
  IsPrime[0] = false;
  IsPrime[1] = false;

  for (ll i = 2; i*i <= n; ++i) {
    if (IsPrime[i]) {
      for (ll j = 2; j*i <= n; ++j) {
        IsPrime[j] = false;
      }
    }
  }
  return IsPrime;
}


int main() {
  ll A, B;  cin >> A >> B;

  ll g = gcd(A, B);
  vector<pair<ll, int>> f = factorization(g);
  ll ans = f.size() + 1;
  print(ans);
  return 0;
}


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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const ll MOD = 1e9 + 7;
int n, m, k;
vector<int> eds[100];
int h[100];
int was[100];
int was1[100];
int cl[100];
vector<pair<int, int> > ed2;
ll dp1[120];
ll cnk[220][220];

ll pw(ll a, ll b) {
	ll ans = 1;
	while (b) {
		while (!(b & 1))
			b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD;
		--b;
	}
	return ans;
}

void dfs1(int v, int hh = 0) {
	h[v] = hh;
	was1[v] = 1;
	for (int u: eds[v])
		if (!was1[u])
			dfs1(u, hh + 1);
}
ll gans = 1;


void upd(vector<int> vv) {
	int cnt = 0;
	memset(cl, 0, sizeof(cl));
	for (int i: vv)
		cl[i] = 1;
	for (pair<int, int> i: ed2) {
		if (cl[i.first] && cl[i.second])
			++cnt;
	}
	ll ans = 0;
	if (cnt == (int)vv.size()) {
		for (int j = 1; j <= cnt; ++j)
			if (cnt % j == 0)
				ans = (ans + dp1[j]) % MOD;
	}
	else {
		ans = cnk[cnt + k - 1][k - 1];
	}
	gans = (gans * ans) % MOD;
}

pair<int, vector<int> > dfs2(int v) {
	was[v] = 1;
	vector<int> ans;
	ans.push_back(v);
	int mx = h[v];
	for (int u: eds[v]) {
		if (!was[u]) {
			pair<int, vector<int> > tmp = dfs2(u);
			if (tmp.first < h[v]) {
				mx = min(mx, tmp.first);
				for (int x: tmp.second)
					ans.push_back(x);
			}
			else if (tmp.first == h[v]) {
				tmp.second.push_back(v);
				upd(tmp.second);
			}
			else {
				gans = (gans * k) % MOD;
			}
		}
		else {
			mx = min(mx, h[u]);
		}
	}
	return make_pair(mx, ans);
}

int main() {
	cin >> n >> m >> k;
	dp1[0] = 0;
	for (int i = 1; i <= n; ++i) {
		dp1[i] = 1;
		for (int j = 0; j < i; ++j)
			dp1[i] = (dp1[i] * k) % MOD;
		for (int j = 1; j < i; ++j)
			if (i % j == 0)
				dp1[i] = (dp1[i] - dp1[j] + MOD) % MOD;
	}
	for (int i = 1; i <= n; ++i) {
		dp1[i] = (dp1[i] * pw(i, MOD - 2)) % MOD;
	}
	for (int i = 0; i < 220; ++i)
		for (int j = 0; j < 220; ++j) {
			if (i == j || j == 0)
				cnk[i][j] = 1;
			else if (j > i)
				cnk[i][j] = 0;
			else
				cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]) % MOD;
		}
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		eds[a].push_back(b);
		eds[b].push_back(a);
		ed2.push_back(make_pair(a, b));
	}
	for (int i = 0; i < n; ++i) {
		if (was1[i])
			continue;
		dfs1(i);
		auto x = dfs2(i);
		if ((int)x.second.size() != 1) {
			upd(x.second);
		}
	}
	cout << gans << "\n";
	return 0;
}




Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> ac(N, Q);
    for (int i = 0; i < Q; i++) {
        int a;
        cin >> a;
        ac[--a]--;
    }

    for (int i = 0; i < N; i++) {
        if (K - ac[i] > 0) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}


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

//#define int long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
    int A,B;
    cin >>A>>B;
    if (A<6){
        cout << 0 <<endl;
    }
    else if (A<13){
        cout << (B)/2 <<endl;
    }
    else cout << B <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
template <class T1, class T2>void print(T1 a[], T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " ";} cout << endl;}
template <class T1, class T2>void print(vector<T1> a, T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl;}
ll modexpo(ll a, ll b, ll m) {if (b == 0) {return 1;} else if (a == 1) {return 1;} if (b % 2 == 0) {ll t = modexpo(a, b / 2, m); t = (t * t) % m; return t;} else {ll t = modexpo(a, b / 2, m); t = (t * t) % m; t = (t * a) % m; return t;}}










int main() {

    // taskkill /IM "cp.exe" /F
    fast



    // memset(dp, -1, sizeof(dp));
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int dp[k + 1];
    dp[0] = 2;
    for (int i = 1; i <= k; i++) {
        dp[i] = 2;
        for (int j = 0; j < n; j++) {
            if (i - a[j] >= 0 && dp[i - a[j]] == 2) {
                dp[i] = 1;
                break;
            }
        }
    }
    if (dp[k] == 1) {
        cout << "First\n";
    }
    else {
        cout << "Second\n";
    }
}

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

int main(){
    int appearance[26] = {};

    string w;
    cin >> w;

    for(int i = 0; i < w.length(); i++){
        appearance[w[i]-'a']++;
    }

    for(int i = 0; i < 26; i++){
        if(appearance[i]&1){
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int x[400];
 
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    FOR(i,a,b-1) x[i] += 1;
    FOR(i,c,d-1) x[i] += 1;
    int ans = 0;
    REP(i,400) ans += (x[i] == 2);
    cout << ans << endl;
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    ll ans = 0, curmax = 0;
    rep(i, 0, n) {
        ll h;
        cin >> h;
        if(curmax <= h) ans++;
        chmax(curmax, h);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N];
		int[] Q = new int[N];
		int cnt = 0;

		int Pno = 0;
		for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
			cnt = 0;
			for (int j = 0; j < i; j++) {
				if (P[j] < P[i]) {
					cnt++;
				}
			}
			Pno += Math.abs((P[i] - cnt - 1) * factorial(N - i - 1));
		}
		Pno+=1;

		int Qno = 0;
		for (int i = 0; i < N; i++) {
			Q[i] = sc.nextInt();
			cnt = 0;
			for (int j = 0; j < i; j++) {
				if (Q[j] < Q[i]) {
					cnt++;
				}
			}
			Qno += Math.abs((Q[i] - 1 - cnt) * factorial(N - i - 1));
		}
		Qno += 1;

		System.out.print(Math.abs(Pno - Qno));
	}

	public static int factorial(int n) {
		int fact = 1;
		for (int i = 2; i <= n; i++) {
			fact = fact * i;
		}
		return fact;
	}
}


Measured memory_bytes: 23764
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m = MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------// 
vector<int> div(int n){
    vector<int> div;
    for(int i = 1; i * i <= n; i++){
	   if (n % i == 0){
		    div.push_back(i);
		    if ( i != n/i)div.push_back(n/i); 
		  }	
	   }	
 sort(all(div));
 return div;
}

void solve(){
   int n, m; 
   cin >> n >> m;
   vector<int> v = div(m);
   int mn = INT_MIN;
   for(auto it : v){
	    if (m/it >= n) mn = max(mn,it); 
	  }
   cout << mn << endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(In));
        }

        public long Min(params long[] a)
        {
            var min = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if (min > a[i]) min = a[i];
            }
            return min;
        }

        public long Max(params long[] a)
        {
            var max = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if (max < a[i]) max = a[i];
            }
            return max;
        }

        public void Solve(ConsoleInput input)
        {
            var s = input.Read.ToCharArray();
            var ks = "keyence".ToCharArray();

            for (var i = 0; i < s.Length; i++)
            {
                for (var j = 0; j < s.Length - i; j++)
                {
                    var ss = s.ToList();
                    ss.RemoveRange(i, j);
                    //WriteLine(new string(ss.ToArray()));
                    if (ss.SequenceEqual(ks))
                    {
                        WriteLine("YES");
                        return;
                    }
                }
            }
            WriteLine("NO");

            //Solve(input);
        }

        private long Xxor(long x, long[] a)
        {
            long fx = 0;
            foreach (var ai in a)
            {
                fx += x ^ ai;
            }
            return fx;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private readonly char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            _separator = separator;
            _stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n; cin>>n;
  vector<int> t(n), v(n);
  rep(i, n) cin>>t[i];
  rep(i, n) cin>>v[i];
  int T = 0;
  rep(i, n) T += t[i];
  vector<int> ub(2*T+1, INF);

  int x = 0;
  rep(i, n) rep(tt, t[i]) {
    ub[x] = min(ub[x], v[i]*2);
    ub[x+1] = min(ub[x+1], v[i]*2);
    ub[x+2] = min(ub[x+2], v[i]*2);
    x += 2;
  }
  ub[0] = ub[T*2] = 0;
  rep(x, 2*T) ub[x+1] = min(ub[x+1], ub[x] + 1);
  RREP(x, 2*T, 0) ub[x] = min(ub[x], ub[x+1] + 1);

  double ans = 0;
  rep(x, 2*T) ans += (ub[x] + ub[x+1]) / 2.0;
  cout << fixed << setprecision(10) << ans / 4 << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,int> pii;
typedef unsigned long long ULL;
const int N = 1e5+5;
const int M = 1e6+5;
const int Mod = 1e9+7;
#define pi acos(-1)
#define INF 1e8
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
// 18 5 3 
LL a[N];
int main()
{
    int n;sd(n);
    for(int i=1;i<=n;++i) sld(a[i]);
    LL tmp = 1e18,ans = 1;
    bool f = false;
    for(int i=1;i<=n;++i)
    {
        LL ma = tmp/ans;
        if(a[i] > ma){f = 1;}
        if(a[i] == 0){ans = 0;f = 0;break;}
        if(!f) ans *= a[i];
    }
    if(f) printf("-1\n");
    else plr(ans);
 //   system("pause");
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> line(N);
	for (int i = 0; i < N; i++) {
		cin >> line[i];
	}
	sort(line.begin(), line.end());
	int sum = 0;
	for (int i = 0; i < N-1; i++) {
		sum += line[i];
	}
	if (line[N-1] < sum) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define N 2000123
#define ll long long

using namespace std;

char cs[N];
int k, n, m;
string s;
ll fat[N], inv_fat[N], p[N], z[N];

ll gcd(ll a, ll b, ll& x, ll& y) {
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll g = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - ((a / b) * y1);
    return g;
}

ll inv(ll a) {
    ll x, y;
    gcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

ll C(int a, int b) {
    return (((fat[a] * inv_fat[b]) % MOD) * inv_fat[a - b]) % MOD;
}

ll partial, ans;

int main() {
    scanf("%d %s", &k, cs);

    n = strlen(cs);
    fat[0] = inv_fat[0] = p[0] = z[0] = 1;
    for(int i=1; i <= n + k + 5; ++i) {
        fat[i] = (fat[i - 1] * i) % MOD;
        inv_fat[i] = inv(fat[i]);
        p[i] = (p[i - 1] * 25LL) % MOD;
        z[i] = (z[i - 1] * 26LL) % MOD;
    }

    m = n - 1;
    for(int i=n; i <= n + k; ++i) {
        partial =  (C(i - 1, m) * p[i - m - 1]) % MOD;
        //printf("%d %d %lld\n",i - 1, m,  C(i - 1, m));

        ans = (ans + ( (partial * z[n + k - i]) % MOD) ) % MOD;

    
        //printf("%d %lld\n", n + k - i, z[n + k - i]);
    }
    
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 67288
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			int n = int.Parse(Console.ReadLine());
			int[,,] floorsss = new int[4, 3, 10];

			for (int j = 0; j < n; ++j) {
				var array = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
				int b = array[0];
				int f = array[1];
				int r = array[2];
				int v = array[3];
				floorsss[b - 1, f - 1, r - 1] += v;
			}

			for (int i = 0; i < floorsss.GetLength(0); ++i) {
				for (int j = 0; j < floorsss.GetLength(1); ++j) {
					for (int k = 0; k < floorsss.GetLength(2); ++k) {
						Console.Write($" {floorsss[i, j, k]}");
					}
					Console.WriteLine("");
				}

				if (i != floorsss.GetLength(0) - 1) {
					Console.WriteLine("####################");
				}
			}

			//Console.Out.Flush();

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 18384
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        l: [i64; n],
    }
    let mut tot = 0;
    for k in 0..n {
        for j in 0..k {
            for i in 0..j {
                let mut v = vec![l[i], l[j], l[k]];
                v.sort();
                if v[0] != v[1] && v[1] != v[2] && v[2] < v[0] + v[1] {
                    tot += 1;
                }
            }
        }
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2204