akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
typedef pair<int , int > pii;
#define MOD 1000000007
#define MOD1 998244353
#define ff first
#define ss second
#define bn cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define sz(a) int((a).size())
#define o(a) cout << a
#define MAX6 1000006
#define int ll
#define all(x) x.begin(), x.end()
#define ppii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define viii vector<ppii>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define MAX5 300005
#define MAX7 10000007
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<=(b);i++)
#define nrep(i,b,a)  for (__typeof((b)) i=(b);i>=(a);i--)
#define mem(a) memset(a,0,sizeof(a))
#define memneg(a) memset(a,-1,sizeof(a))
//#define se second
#define LN 14
#define LIM 22
#define MAX_ALPHA 26
const long long INF64 = 1e18;
const ll INF = 1e9;
const double PI = acos(-1);
#define ld long double
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
inline void max_self(ll &a, ll b)
{
  a = max(a,b);
}
 
inline void min_self(ll &a,ll b)
{
  a = min(a,b);
}
 
inline void add_self(ll &a, ll b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
inline void sub_self(ll &a, ll b) {
  a -= b;
  if (a < 0) a += MOD;
}
 
inline int mul(int a, int b) {
  return (int) ((long long) a * b % MOD);
}
 
 
ll gcd(ll a,ll b)
{
  if(b == 0)
    return a;
  else 
    return gcd(b, a%b);
}
 
 
int countDigits(int x)
{
  int cnt = 0;
  while(x)
  {
    x /= 10;
    cnt++;
  }
  return cnt;
}
 
 
ll binExpo(ll a,ll b)
{
  ll res = 1;
  while(b)
  {
    if(b&1)
      res = (res * a)%MOD;
    a = (a * a)%MOD;
    b /= 2;
  }
  return res%MOD;
}
 
int sum(int a) {
    int result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}

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

  int n;
  cin>>n;
  vector<int > dp(3, 0);
  for(int day = 0;day < n;day++)
  {
    vector<int > new_dp(3, 0);
    vector<int > c(3);
    for(int i = 0;i < 3;i++)
      cin>>c[i];
    for(int i = 0;i < 3;i++)
    {
      for(int j = 0;j < 3;j++)
      {
        if(i != j)
        {
          new_dp[j] = max(new_dp[j], dp[i] + c[j]);
        }
      }
    }
    dp = new_dp;
  }
  int mx = -1;
  for(int i = 0;i < 3;i++)
    mx = max(mx, dp[i]);
  cout<<mx<<endl;
  return 0;
}

Measured memory_bytes: 256
use = input()

total = 0
p = 0
p1 = len(use) - 1
while p < p1:
	if use[p] == use[p1]:
		p += 1
		p1 -= 1
	elif use[p] == "x":
		p += 1
		total += 1
	elif use[p1] == "x":
		p1 -= 1
		total += 1
	else:
		total = -1
		break
print(total)

Measured memory_bytes: 3316
#include <iostream>
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;

const int MAX_N = 100;

int main()
{
  int N, A[MAX_N];
  cin >> N;
  REP(i, N) cin >> A[i];

  REP(i, N) {
    int v = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    REP(j, N-1) cout << A[j] << ' ';
    cout << A[N-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 3076
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	p := make([]int, n)
	for i := range p {
		fmt.Scan(&p[i])
	}

	ans := 1
	min := p[0]
	for i := 1; i < n; i++ {
		if p[i] < min {
			ans++
			min = p[i]
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6016
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        String S = sc.next();
        String T = sc.next();
        int min = INF;
        for(int i=0;i<S.length()-T.length()+1;i++){
            int cnt = 0;
            for(int j=0;j<T.length();j++){
                if(S.charAt(i+j)!=T.charAt(j))cnt++;
            }
            min = Math.min(min,cnt);
        }
        System.out.println(min);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    ll A;
    double long B;     //long
    cin >> A >> B;
    ll ans = A * B + 0.001;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): any => {
  let tmp = ``
  const S = lines[0]
  const T = lines[1]
  const obj = { S, T }
  debug(obj)
  return obj
}

// solver
export const solve = (lines: string[]): string => {
  const { S, T } = parseLines(lines)

  let count = 0
  for(let i = 0; i < S.length; i++) {
   if (S.charAt(i) === T.charAt(i)) {
    count++
   }
  }
  return `${count}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 11596
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//222
	int n;
	cin>>n;
	string s;
	cin>>s;
	int mcnt=0;
	REP(i,1,n-2) {
		unordered_map<char,int> a,b;
		REP(j,0,i-1)a[s[j]]++;
		REP(j,i,n-1)b[s[j]]++;
		int cnt =0;
		for(auto c:a) {
			if(b.count(c.F))cnt++;
		}
		mcnt=max(cnt,mcnt);
	}
	cout<<mcnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define MOD 1e9+7
#define EPS 1e-8
#define INF 1e9+10
typedef long long ll;
using namespace std;
int main()
{
  ll N;
  cin >> N;

  ll ans = 1e12;
  rep(i,1,sqrt(N)+1){
    if(N%i!=0){continue;}

    ll sum=(i-1)+((N/i)-1);
    ans=min(ans,sum);
  }

  cout << ans << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
deque<int>line;
ll maxim(){
    auto val = line.front();
    line.pop_front();
    return val;
}
ll minimum(){
    auto val = line.back();
    line.pop_back();
    return val;
}
signed main(){
    int n; cin >> n;
    if(n == 2){
        int a,b;cin>>a>>b;
        return cout << abs(a-b) << endl,0;
    }
    vector<int>v(n);
    erep(e,v) cin >> e;
    sort(all(v),greater<int>());
    int fans = 0;
    rep(_,2){
        rep(i,n)line.push_back(v[i]);
        deque<int>deq;
        bool rising = _%2;
        while(!line.empty()){
            if(deq.empty()){
                deq.push_front( (rising ? maxim() :minimum()) );
                deq.push_front( (rising ? minimum() :maxim()) );
                deq.push_back( (rising ? minimum() :maxim())  );
                
            }else {
                if(line.size() >= 2){
                    int a = (rising ? minimum(): maxim());
                    int b = (rising ? minimum(): maxim());
                    if(abs(deq.front() - a) + abs(deq.back() - b) >
                       abs(deq.front() - b) + abs(deq.back() - a) ) {
                        deq.push_front(a);
                        deq.push_back(b);
                    } else {
                        deq.push_front(b);
                        deq.push_back(a);
                    }
                } else {
                    int val = (rising ? minimum():maxim());
                    if(abs(deq.front() - val) > abs(deq.back() - val)){
                        deq.push_front(val);
                    } else {
                        deq.push_back(val);
                    }
                }
            }
            rising = !rising;
        }
        int ans = 0;
  //      join(deq); cout << endl;
        int top = deq.front();
        deq.pop_front();
        while(deq.size()){
            ans += abs(top - deq.front());
            top = deq.front();
            deq.pop_front();
        }
        cmax(fans, ans);
    }
    cout << fans << endl;
}





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

using namespace std;

#define FOR(x,n) for(int i = x; i < n; i++)
#define FORJ(x,n) for(int j=x; j < n; j++)
#define FORE(x,n) for(int i=x; i<=n; i++)
#define FORJE(x,n) for(int j=x; j <= n; j++)
#define ll long long
#define MOD 1000000007
#define pb push_back
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

int main() {
	FAST_IO
	int D,T,S;
	cin>>D>>T>>S;

	// D - distance
	// T - time
	// S - speed
	//
	double res = (double) D/S;

	if(res<=T) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
typedef struct{ char c; int n; } card;
card B[36], S[36];
int bubble(card A[36], int N)
{
	int i, j, c = 0, flag = 1;
	card stock;
	while (flag)
	{
		flag = 0;
		for (i = N - 1; i>0; i--)
		{
			if (A[i].n<A[i - 1].n)
			{
				stock = A[i];
				A[i] = A[i - 1];
				A[i - 1] = stock;
				flag = 1;
				c++;
			}
		}
	}
	return c;
}
int selection(card A[36], int N)
{
	int i, j, d, minj, c = 0;
	card stock;
	for (i = 0; i<N; i++)
	{
		minj = i;
		for (d = 0, j = i; j<N; j++)
		{
			if (A[j].n<A[minj].n){ minj = j; d = 1; }
		}
		stock = A[i];
		A[i] = A[minj];
		A[minj] = stock;
		if (d)c++;
	}
	return c;
}
int main(void)
{
	int n, i, j;
	scanf("%d", &n);
	for (i = 0; i<n; i++){ scanf(" %c%d", &B[i].c, &B[i].n); }
	memcpy(S, B, sizeof(B));
	bubble(B, n);
	selection(S, n);
	for (i = 0; i<n; i++)
	{
		printf("%c%d", B[i].c, B[i].n);
		if (i<n - 1){ printf(" "); }
		else{ printf("\n"); }
	}
	printf("Stable\n");
	for (i = 0; i<n; i++)
	{
		printf("%c%d", S[i].c, S[i].n);
		if (i<n - 1){ printf(" "); }
		else{ printf("\n"); }
	}
	if (!memcmp(B, S, sizeof(B))){ printf("Stable\n"); }
	else{ printf("Not stable\n"); }

	return 0;
}

Measured memory_bytes: 624
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
double p;
class edge{
public:
	int t;
	double c;
	edge(){}
	edge(int tt,double cc){
		t=tt;
		c=cc;
	}
};

vector<edge> G[100001];
int depth[100001];
int cnt[100001];
double sum=0.0;
bool flag[100001];

void dfs(int v,int d){
	flag[v]=true;
	depth[v]=d;
	for(int i=0;i<G[v].size();i++){
		if(!flag[G[v][i].t]){
			sum+=G[v][i].c*pow(p,(d+1.0));
			dfs(G[v][i].t,d+1);
		}
	}
}

int main(void){
	scanf("%lf",&p);
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int f,t,c;
		scanf("%d%d%d",&f,&t,&c);
		f--;
		t--;
		G[f].push_back(edge(t,(double)c));
		G[t].push_back(edge(f,(double)c));
	}
	memset(flag,false,sizeof(flag));
	dfs(0,0);
	for(int i=0;i<n;i++){
		cnt[depth[i]]+=1;
	}
	cnt[0]++;
	double res=0.0;
	for(int i=0;i<n;i++){
		res+=(double)cnt[i]*sum*pow(p,i);
	}
	printf("%.9f\n",res);
	return 0;
}

Measured memory_bytes: 17608
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    int n, a, b;
    cin >> n >> a >> b;

    if ((b - a - 1) % 2 == 1) {
        cout << "Alice" << endl;
    } else {
        cout << "Borys" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
int p(int a,int x){
      int t=1;
      if(a==0)return 0;
      if(x==0)return 1;
      t=p(a,x/2);
      t=t*t%mod;
      if(x%2)t=t*a%mod;
      return t;
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n,mx=0;
      cin>>n;
      vector<int>data(n,0);
      for(int i=0;i<n;i++){
            int x;
            cin>>x;
            if(i==0&&x!=0){
                  cout<<0;
                  return 0;
            }
            data[x]++;
            mx=max(x,mx);
      }
      int ans=1;
      if(data[0]!=1)ans=0;
      for(int i=1;i<=mx;i++){
            ans=ans*p(data[i-1],data[i])%mod;
      }
      cout<<ans;
}


Measured memory_bytes: 1024
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  n = readline() |> parseInt

  f = zeros(Int, 10000)

  for x in 1:100
    for y in 1:100
      for z in 1:100
        m = x*x + y*y + z*z + x*y + y*z + z*x
        m <= 10000 && (f[m] += 1)
      end
    end
  end
  println.(f[1:n])
end

main()


Measured memory_bytes: 173224
#include<bits/stdc++.h>
using namespace std;
#define rp(i,j) for(long long i=0;i<j;i++)
#define rep(i,j,k) for(long long i=j;i<k;i++)
#define mod 1000000007
#define NIL -1
#define MAX 10000
static const int INFTY=(1<<21);
typedef long long ll;
int n;int d[MAX],color[MAX];
vector<pair<int,int>>adj[MAX];
void dijkstra(){
    rp(i,n){
        d[i]=INFTY;
        color[i]=0;
    }
    d[0]=0;
    priority_queue<pair<int,int>>PQ;
    PQ.push(make_pair(0,0));
    color[0]=1;
    while(!PQ.empty()){
        pair<int,int>f=PQ.top();PQ.pop();
        int u=f.second;
        color[u]=2;
        if(d[u]<f.first*(-1))continue;
        rp(j,adj[u].size()){
            int v=adj[u][j].first;
            if(color[v]==2)continue;
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
                color[v]=1;
            }
        }
    }
    rp(i,n)cout<<i<<" "<<d[i]<<endl;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int u,k,v,c;
    cin>>n;
    rp(i,n){
        cin>>u>>k;
        rp(j,k){
            cin>>v>>c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra();
}


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

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

using namespace std;

struct interval{ int a,b; };

int case1(vector<interval> I){
	int n=I.size();
	multiset<int> L,R;
	rep(i,n){
		L.emplace(I[i].a);
		R.emplace(I[i].b);
	}

	int res=0;
	rep(i,n){
		int l1=I[i].a,r1=I[i].b;
		L.erase(L.find(l1));
		R.erase(R.find(r1));
		int l2=*L.rbegin();
		int r2=*R.begin();
		res=max(res,(r1-l1)+max(r2-l2,0));
		L.emplace(l1);
		R.emplace(r1);
	}
	return res;
}

int case2(vector<interval> I){
	int n=I.size();
	sort(I.begin(),I.end(),[](const interval& I,const interval& J){
			return make_pair(I.a,-I.b)<make_pair(J.a,-J.b);
	});

	int p=0,q=0;
	rep(i,n){
		if(make_pair(I[i].b,-I[i].a)<make_pair(I[p].b,-I[p].a)) p=i;
		if(make_pair(I[i].a,-I[i].b)>make_pair(I[q].a,-I[q].b)) q=i;
	}

	multiset<int> L1,R2;
	rep(i,n) R2.emplace(I[i].b);

	int res=0;
	int r1=I[p].b; L1.emplace(I[p].a);
	int l2=I[q].a; R2.emplace(I[q].b);
	rep(i,n+1){
		int l1=*L1.rbegin();
		int r2=*R2.begin();
		res=max(res,max(r1-l1,0)+max(r2-l2,0));
		if(i<n){
			L1.insert(I[i].a);
			R2.erase(R2.find(I[i].b));
		}
	}
	return res;
}

int main(){
	int n; scanf("%d",&n);
	vector<interval> I(n);
	rep(i,n) scanf("%d%d",&I[i].a,&I[i].b), I[i].a--;

	printf("%d\n",max(case1(I),case2(I)));

	return 0;
}


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

bool isMade( int *arr, unsigned int arr_size, unsigned int from_i, int key ){

	if( key==0 ){
		return true;
	}else if( from_i >= arr_size ){//?????¶????????????????????§???! ?????????????´?????????£?????????????????°????????????????????????????????????
		return false;
	}else{
		return isMade( arr, arr_size, from_i+1, key)/*arr[from_i]????????°????????´???*/ || isMade( arr, arr_size, from_i+1, key -arr[from_i] );//arr[from_i]????????¶??´???(key??????????????£?????°????????????????????????????????????)
	}
}

																																		

int main()
{
	int sSrc, *src, sKeys;
	cin>>sSrc;
	src=new int[sSrc];
	for( int i=0; i<sSrc; i++ ){
		cin>>src[i];
	}

	cin>>sKeys;
	for( int i=0, key; i<sKeys; i++ ){
		cin>>key;
		cout<<( isMade( src, sSrc, 0, key ) ? "yes" : "no" )<<endl;
	}
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vll vector <pll>
#pragma 03
using namespace std;
ll INF = 1e18;
ll a[100005];
ll dp[100005];
int main(){
	for (int i = 0; i<100005; i++) dp[i] = INF;
	ll n;
	cin >> n;
	for (int i = 0; i<n; i++) cin >> a[i];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i<n; i++){
		dp[i] = min(dp[i], dp[i-2] + (abs(a[i] - a[i-2])));
		dp[i] = min(dp[i], dp[i-1] + (abs(a[i] - a[i-1])));
	}
	cout << dp[n-1] << endl;
	return 0;
}
 


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

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

	int n,m,k,t;
	int count[31];
	int res = 0;

	memset(count,0,sizeof(count));
	cin >> n >> m;

	for(int i=0;i<n;i++)
	{
		cin >> k;
		for(int j=0;j<k;j++)
		{
			cin >> t;
			count[t]++;
		}
	}

	for(int i=1;i<=m;i++)
	{
		if(count[i]==n)
		{
			res++;
		}
	}

	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
import math
a, b, C = map(int, input().split())
rad = C/180*math.pi
print('%.8f' % (a*b*math.sin(rad)/2))
print('%.8f' % ((a**2-2*a*b*math.cos(rad)+b**2)**0.5 + a + b))
print('%.8f' % (b * math.sin(C/180*math.pi)))


Measured memory_bytes: 5720
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")


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

	int n;
	cin >> n;
	vector<int> h(n);
	int ans = 0;
	rep(i, n)
	{
		cin >> h[i];
		rep(j, i)
		{
			if (h[i] < h[j])
			{
				break;
			}
			if (j + 1 == i)
			{
				ans++;
			}
		}
	}

	cout << ans + 1 << endl;

	debug;

}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<(int)n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<=(int)n:i>=(int)n;k<n?i++:i--)
#define input(v,n) fo(i,n)cin>>v[i]
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pi;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667
const int inf = numeric_limits<int> :: max();
// ===================== MANASH =================== //

int n,m;

void test() {

    string s;
    cin >> s;
    if ( s[2] == s[3] and s[4] == s[5]) {
        cout << "Yes";
    } else cout << "No";
}

signed main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif

    int T = 1;
    //cin >> T;
    while(T--) {
        test();
        cout << "\n";
    }
    return 0;

}

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

const int mod = 1e9 + 7;

int main() {
  int n; cin >> n;
  vector<int> t(n), a(n);
  rep(i, n) cin >> t[i];
  rep(i, n) cin >> a[i];

  vector<int> ans(n);
  bool flag = true;
  if (n == 1 && a[0] != t[0]) flag = false;
  ans[0] = 1;
  for (int i = 1; i < n; i ++) {
    if (t[i - 1] < t[i]) {
      if (a[i] < t[i]) flag = false;
      ans[i] = 1;
    } else {
      ans[i] = t[i];
    }
  }
  ans[n - 1] = 1;
  for (int i = n - 2; i >= 0; i --) {
    if (a[i] > a[i + 1]) {
      if (t[i] < a[i]) flag = false;
      ans[i] = 1;
    } else {
      ans[i] = min(ans[i], a[i]);
    }
  }

  if (flag) {
    LL res = 1;
    rep(i, n) {
      res *= ans[i];
      res %= mod;
    }
    cout << res << endl;
  } else {
    cout << 0 << endl;
  }
}

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

const int B[3] = { 10, 5, 1 };
int N, Y;

int main(void) {
	cin >> N >> Y;
	Y /= 1000;

	int x, y, z;
	x = y = z = -1;
	if (N <= Y / B[2] && N >= Y / B[0]) {
		for (int i = 0; i <= Y / B[0]; ++i) {
			for (int j = 0; j <= Y / B[1]; ++j) {
				int k = (Y - B[0] * i - B[1] * j) / B[2];
				if (k >= 0 && i + j + k == N) {
					x = i; y = j; z = k;
					i = Y;
					break;
				}
			}
		}
	}

	cout << x << ' ' << y << ' ' << z << '\n';
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

S = gets.chomp

odds = ['R', 'U', 'D']
evens = ['L', 'U', 'D']

ans = true
S.split('').each.with_index do |s, i|
  n = i + 1
  target = n % 2 == 0 ? evens : odds
  unless target.include?(s)
    ans = false
    break
  end
end

puts ans ? 'Yes' : 'No'


Measured memory_bytes: 14468
#include <stdio.h>
#include <math.h>



#ifndef DEBUG 
#define fprintf (void)
#endif 

double absval(double x);

int main(void){
	int d[2][7];
	int c[7];
	
	int i,j,k,n;
	int rec=0;
	int ans=0;
	int top, front;
	char roll;
	char trash;
	
	for(i=0;i<2;i++){
		for(j=1;j<7;j++){	
			scanf("%d",&d[i][j]);
		}
	}
	
	int turn[3][7]={{d[0][1],d[0][2],d[0][6],d[0][5],d[0][1],d[0][2],d[0][6]},
					{d[0][2],d[0][3],d[0][5],d[0][4],d[0][2],d[0][3],d[0][5]},
					{d[0][1],d[0][3],d[0][6],d[0][4],d[0][1],d[0][3],d[0][6]}
					};
	
	for(j=0;j<3;j++){
		for(k=0;k<4;k++){
			if(d[1][1]==turn[j][k]&&d[1][2]==turn[j][k+1]){
				rec=1;
				fprintf(stdout,"%d,%d:%d %d %d ,%d\n",j,k,turn[j][k],turn[j][k+1],turn[j][k+3],rec);
				break;
			}else if(d[1][1]==turn[j][k]&&d[1][2]==turn[j][k+3]){
				rec=-1;
				fprintf(stdout,"%d,%d:%d %d %d ,%d\n",j,k,turn[j][k],turn[j][k+1],turn[j][k+3],rec);
				break;
			}
			fprintf(stdout,"%d,%d:%d %d %d ,%d\n",j,k,turn[j][k],turn[j][k+1],turn[j][k+3],rec);
		}
		if(rec!=0){
			break;
		}
	}
	
	if(j==0){
		if(rec==1){
			if(d[1][3]==d[0][3] && d[1][4]==d[0][4] && d[1][6]==turn[j][k+2] && d[1][5]==turn[j][k+3]){
				ans=1;
			}
		}else{
			if(d[1][3]==d[0][4] && d[1][4]==d[0][3] && d[1][6]==turn[j][k+2] && d[1][5]==turn[j][k+1]){
				ans=1;
			}
		}
	}else if(j==1){
		if(rec==1){
			if(d[1][3]==d[0][1] && d[1][4]==d[0][6] && d[1][6]==turn[j][k+2] && d[1][5]==turn[j][k+3]){
				ans=1;
			}
		}else{
			if(d[1][3]==d[0][6] && d[1][4]==d[0][1] && d[1][6]==turn[j][k+2] && d[1][5]==turn[j][k+1]){
				ans=1;
			}
		}
	}else if(j==2){
		if(rec==1){
			if(d[1][3]==d[0][5] && d[1][4]==d[0][2] && d[1][6]==turn[j][k+2] && d[1][5]==turn[j][k+3]){
				ans=1;
			}
		}else{
			if(d[1][3]==d[0][2] && d[1][4]==d[0][5] && d[1][6]==turn[j][k+2] && d[1][5]==turn[j][k+1]){
				ans=1;
			}
		}
	}
	
	rec=0;
	
	if(ans==1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    ans += A.back();
    A.back();
    A.pop_back();
    N -= 2;
    while(N>0) {
        if(N>1) {
            ans += 2*A.back();
            N -= 2;
        }
        else {
            ans += A.back();
            N = 0;
        }
        A.pop_back();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

//#define DEBUGGING
#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

struct Node {
    ll depth;
    V<ll> children_idx;
    Node(ll depth) 
        : depth(depth),
          children_idx(2, -1) 
    {
    }
    Node() : Node(0) {}
};

V<Node> nodes_heap = { Node() };

Node& get_root() { return nodes_heap[0]; }
Node& get_node(ll idx) { return nodes_heap[idx]; }

void create_node(const string &s, ll depth, ll s_idx, ll node_idx) {
    if(s_idx == s.size()) return;
    ll nxt_label = s[s_idx] - '0';
    ll nxt_idx = get_node(node_idx).children_idx[nxt_label];
    if(nxt_idx == -1) {
        nxt_idx = nodes_heap.size();
        nodes_heap.push_back(Node(depth + 1));
        get_node(node_idx).children_idx[nxt_label] = nxt_idx;
    }
    create_node(s, depth + 1, s_idx + 1, nxt_idx);
}

ll search_node(const string &s, ll idx, Node &now) {
    if(idx + 1 == s.size()) return now.depth;
    ll nxt_label = s[idx] - '0';
    ll nxt_idx = now.children_idx[nxt_label];
    return (nxt_idx == -1 ? now.depth : search_node(s, idx + 1, get_node(nxt_idx)));
}

void create_node(const string &s) { create_node(s, 0, 0, 0); }
ll search_node(const string &s) { return search_node(s, 0, get_root()); }

int main() {
    init_io();
    ll N, L;
    cin >> N >> L;
    V<ll> imos(1e5 + 10);
    imos[0] = 2;
    for(ll i = 0; i < N; i++) {
        string s;
        cin >> s;
        ll d = search_node(s);
        DEBUG(d, s.size());
        imos[d]--;
        imos[d + 1] += 1 + (d != 0);
        imos[s.size()]--;
        create_node(s);
    }

    ll gxor = 0;
    for(ll i = 1; i < imos.size() - 1; i++) imos[i + 1] += imos[i];
#ifdef DEBUGGING
    for(ll i = 0; i < 10; i++) cout << "imos[" << i << "] = " << imos[i] << endl;
    cout << flush;
#endif
    for(ll i = 0; i < imos.size(); i++) {
        if(imos[i] % 2 == 0) continue;
        bitset<64> bs(L - i);
        for(ll j = 0; j <= 63; j++) {
            if(!bs.test(j)) continue;
            gxor ^= (1ll << j);
            break;
        }
    }
    cout << (gxor ? "Alice" : "Bob") << endl;
    return 0;
}


Measured memory_bytes: 19004
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string.h>

using namespace std;
char s[7];
int main(){
	scanf("%s",s);
	if(s[2]==s[3]&&s[4]==s[5]){
		printf("Yes\n");
	}
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define inf 1e18
#define all(v) (v).begin(),(v).end()
using namespace std;

vector <int> dx = {-1,1,0,0};
vector <int> dy = {0,0,-1,1};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin >>n;
	int ans = 0;
	while(n > 0){
		--n;
		int i = 1;
		while(i*i <= n){
			if(n%i == 0){
				ans += 2;
				if(n/i == i){
					ans--;
				}
			}
			i++;
		}
	}
	cout << ans<<"\n";
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(void)
{
	int s,i=1;
	cin>>s;
	while(1){
		if(s==1 || s==2 || s==4) break;
		else s=(s%2)?3*s+1:s/2;
		i++;
	}
	cout<<i+3<<endl;
	return 0;
}

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

int Partition(int *, int, int);

int n;

int main(){
        int *A;
        int i, p, r, q;

        scanf("%d", &n);
        A = malloc(sizeof(int) * n);
        for(i = 0 ; i < n ; i++){
                scanf("%d", &A[i]);
        }
        p = 0;
        r = n - 1;

        q = Partition(A, p, r);

        for(i = 0 ; i < n ; i++){
                if(i == q)printf("[");
                printf("%d", A[i]);
                if(i == q)printf("]");
                if(i + 1 != n)printf(" ");
        }
        printf("\n");

        return 0;
}

int Partition(int *A, int p, int r){
        int x, buf, i, j;
        x = A[r];
        i = p - 1;
        for(j = p  ; j < r ; j++){
                if(A[j] <= x){
                        i = i + 1;
                        buf = A[i];
                        A[i] = A[j];
                        A[j] = buf;
                }
        }
        buf = A[i + 1];
        A[i + 1] = A[r];
        A[r] = buf;
        return i + 1;
}



Measured memory_bytes: 2108
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var A = S.ToCharArray().Select(c => (int)(c - '0')).ToArray();
		for(int s = 0; s < (1 << 3); s++){
			int tot = A[0];
			for(int j=0;j<3;j++){
				if(((s >> j)&1) == 0) tot += A[1 + j];
				if(((s >> j)&1) == 1) tot -= A[1 + j];
			}
			if(tot == 7){
				var pm = "+-";
				Console.WriteLine("{0}{1}{2}{3}{4}{5}{6}=7",A[0],pm[(s >> 0)&1],A[1],pm[(s >> 1)&1],A[2],pm[(s >> 2)&1],A[3]);
				return;
			}
		}
		
		
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13396
// review
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 100010;

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

void solve() {
  sort(a, a + n);
  sort(b, b + n);
  sort(c, c + n);
  ll cnt = 0;
  for (int i=0;i<n;i++) {
    ll aCnt = lower_bound(a, a + n, b[i]) - a;
    ll cCnt = n - (upper_bound(c, c+n, b[i]) - c);
    cnt += aCnt * cCnt;
  }
  cout << cnt << endl;
}

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


Measured memory_bytes: 2560
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		long scs[][] = new long[8][n];
		for (int i=0; i<n; i++){
			long vals[] = new long[3];
			vals[0] = scanner.nextLong();
			vals[1] = scanner.nextLong();
			vals[2] = scanner.nextLong();
			for (int k=0; k<8; k++){
				long sc = 0;
				int tmpk = k;
				for (int j=0; j<3; j++){
					sc += (long)Math.pow(-1,tmpk%2)*vals[j];
					tmpk /= 2;
				}
				scs[k][i] = sc;
			}
		}

		long ans = 0;
		for (int i=0; i<8; i++){
			long sorted[] = scs[i];
			Arrays.sort(sorted);
			long score = 0;
			for (int k=1; k<=m; k++){
				score += sorted[n-k];
			}
			ans = Math.max(ans, score);
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 27144
# -*- coding: utf-8 -*-

# 入力
A, B, C, X, Y = map(int, input().split())

# 処理
ans = [i * 2*C + max(0, X-i)*A + max(0, Y-i)*B for i in range(0, 100001)]

# 出力
print(min(ans))

Measured memory_bytes: 45424
# -*- coding: utf-8 -*-

# Sを取得
s = input()

topping_count = 0
for i in range(3):
    if s[i] == 'o':
        topping_count += 1
    
price = 700 + (100 * topping_count)

# 結果を出力
print("{}".format(price))


Measured memory_bytes: 2940
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    int cnt = 0;
    int ofst = 0;
    rep(i, n) {
        bool ok = true;
        rep(j, i+1) {
            if (s[n-1+j-i] != t[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cnt = i+1;
        }
    }
    cout << 2 * n - cnt << endl;
    return 0;
}


Measured memory_bytes: 3596
even = ['R','U','D']
odd = ['L','U','D']
poss=1
s=input()
for i in range(len(s)):
    if(i%2==0 and s[i] not in even):
        poss=0
        break
    elif(i%2 and s[i] not in odd):
        poss=0
        break
if(poss):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int factrial(int n){
//   if(n == 0) return 1;
//   return n*factrial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }



int main(){
  int a,b;
  cin >> a >> b;
  cout << max(0,a-2*b) << endl;
}
  





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

int main() {
	int N;
	string a;
	vector<int> A;
	
	cin >> N;
	A.assign(N, 0);
	
	rep(i, N-1) {
		int a;
		cin >> a;
		A[a-1] += 1;
	}
	rep(i, N) cout << A[i] << endl;
}

Measured memory_bytes: 4056
N,C = map(int,input().split())
T = [[0 for j in range(C)] for i in range(10**5+1)]

for _ in range(N):
    s,t,c = map(int,input().split())
    T[s][c-1] += 1
    T[t][c-1] -= 1
for i in range(10**5):
    for j in range(C):
        T[i+1][j] += T[i][j]

ans = 0
for i in range(10**5):
    a = 0
    for j in range(C):
        if T[i][j] or T[i+1][j]:
            a += 1
    ans = max(ans,a)
print(ans)

Measured memory_bytes: 87040
//解説
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int mod = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int main() {
    int a, p; cin >> a >> p;
    p += a * 3;
    int ans = p / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
x1,y1,x2,y2 = gets.chomp.split(" ").map(&:to_i)

#これは必ず右上に向かう直線になっているはず。
vec = [x2-x1,y2-y1]

vec90 = [-vec[1],vec[0]]

ans = "#{(x2+vec90[0]).to_s} #{(y2+vec90[1]).to_s} #{(x1+vec90[0]).to_s} #{(y1+vec90[1]).to_s}"
puts ans


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    long long L[100] = {};
    cin >> N;
    int i = 2;
    
    L[0] = 2;
    L[1] = 1;
    
    if(N == 1){
        cout << L[1] << endl;
        return 0;
    }
    
    while(true){
        L[i] = L[i-2] + L[i-1];
        if(i == N){
            cout << L[i] << endl;
            return 0;
        }
        i++;
    }
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 2e5+1;
int n, sub[N];
vector <int> a[N];
long fact[N], ifact[N], dp[N];

long POW(long x, long n){
  if (n == 0) return 1;
  long y = POW(x, n / 2);
  y = y * y % MOD;
  if (n % 2) return x * y % MOD;
  else return y;
}

void dfs(int p, int u){
  sub[u] = 1; dp[u] = 1;
  for (int v : a[u]){
    if (v == p) continue;
    dfs(u, v); sub[u] += sub[v];
    dp[u] *= (dp[v] * ifact[sub[v]]) % MOD; dp[u] %= MOD;
  }  
  dp[u] *= fact[sub[u] - 1]; dp[u] %= MOD;
}

void rdfs(int p, int u){
  for (int v : a[u]){
    if (v == p) continue;
    long cur = dp[u] * ifact[n - 1] % MOD;
    cur = cur * fact[sub[v]] % MOD;
    cur = cur * POW(dp[v], MOD - 2) % MOD;
    cur = cur * fact[n - sub[v] - 1] % MOD;
    dp[v] = dp[v] * ifact[sub[v] - 1] % MOD;
    dp[v] = dp[v] * cur % MOD;
    dp[v] = dp[v] * ifact[n - sub[v]] % MOD;
    dp[v] = dp[v] * fact[n - 1] % MOD;
    rdfs(u, v);
  }
}

int main()
{
  fastio;
  cin >> n;
  for (int i = 1; i < n; i++){
    int u, v; cin >> u >> v;
    a[u].push_back(v); a[v].push_back(u);
  }
  fact[0] = 1;
  for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % MOD;
  ifact[n] = POW(fact[n], MOD - 2);
  for (int i = n - 1; i >= 0; i--) ifact[i] = ifact[i + 1] * (i + 1) % MOD;
  dfs(0, 1); rdfs(0, 1);
  for (int i = 1; i <= n; i++) cout << dp[i] << '\n';
  return 0;
}

Measured memory_bytes: 19444
// SeeAlso: https://atcoder.jp/contests/abc052/tasks/abc052_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

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

    int x = 0;
    int ans = 0;
    REP(i,N) {
        char c = S[i];
        if(c=='I') {
            x++;
        }
        if(c=='D') {
            x--;
        }
        ans = max(ans, x);
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]

for i in range(n-1):
    a[i+1]+=a[i]

j=0
k=2
ans=10**9

for i in range(1,n-1):
    while abs(a[j]*2-a[i])>abs(a[j+1]*2-a[i]):
        j+=1
    while abs(a[k]*2-a[i]-a[n-1])>abs(a[k+1]*2-a[i]-a[n-1]):
        k+=1
    t=[a[j],a[i]-a[j],a[k]-a[i],a[n-1]-a[k]]
    ans=min(ans,max(t)-min(t))
print(ans)


Measured memory_bytes: 24684
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int D;

            D = int.Parse(Console.ReadLine());


            if (D == 25)
                Console.Write("Christmas");
            else if (D == 24)
                Console.Write("Christmas Eve");
            else if (D == 23)
                Console.Write("Christmas Eve Eve");
            else if (D == 22)
                Console.Write("Christmas Eve Eve Eve");

            Console.ReadKey();


        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll> H(N);

    rep(i,N){
        cin>>H[i];
    }
    reverse(all(H));
    ll now = H[0];
    rep(i,N){
        if(now+1< H[i]){
            cout<<"No"<<endl;
            return 0;
        }else if(now+1 == H[i]){
            now = H[i]-1;
        }else{
            now = H[i];
        }
    }
    cout << "Yes" << endl;


    return 0;
    

}

Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  ll N;
  cin>>N;
  ll P[N+1],A[N+1],B[N+1];
  RREP(i,N){
    ll a;
    cin>>a;
    P[a]=i;
  }
  RREP(i,N) A[i]=N*i;
  
  ll X=N*N+1-P[N];  
  B[N]=1;
  RREP(i,N-1) B[i]=P[i]+X-A[i];
  
  RREP(i,N) cout<<A[i]<<" ";
  cout<<endl;
  RREP(i,N) cout<<B[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll INF=(ll)2e18;
const int M_V=4e6+2;
typedef pair<ll,int> P;

int H,W,K;
char c[(int)1e6];
vector<ll> d(M_V,INF);

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P>> q;
  d[s]=0;
  q.push({0,s});
  while(!q.empty()){
    P p=q.top();
    q.pop();
    int v=p.second;
    if(d[v]<p.first)continue;
    for(int i=0;i<4;i++){
      if(d[v%(H*W)+i*H*W]>((d[v]+K-1)/K)*K){
        d[v%(H*W)+i*H*W]=((d[v]+K-1)/K)*K;
        q.push({d[v%(H*W)+i*H*W],v%(H*W)+i*H*W});
      }
    }
    if((v%(H*W))%W!=W-1 && c[v%(H*W)+1]!='@'){
      if(d[v%(H*W)+1]>d[v%(H*W)]+1){
        d[v%(H*W)+1]=d[v%(H*W)]+1;
        q.push({d[v%(H*W)+1],v%(H*W)+1});
      }
    }
    if((v%(H*W))/W!=0 && c[v%(H*W)-W]!='@'){
      if(d[v%(H*W)+(H*W)-W]>d[v%(H*W)+(H*W)]+1){
        d[v%(H*W)+(H*W)-W]=d[v%(H*W)+(H*W)]+1;
        q.push({d[v%(H*W)+(H*W)-W],v%(H*W)+(H*W)-W});
      }
    }
    if((v%(H*W))%W!=0 && c[v%(H*W)-1]!='@'){
      if(d[v%(H*W)+2*(H*W)-1]>d[v%(H*W)+2*(H*W)]+1){
        d[v%(H*W)+2*(H*W)-1]=d[v%(H*W)+2*(H*W)]+1;
        q.push({d[v%(H*W)+2*(H*W)-1],v%(H*W)+2*(H*W)-1});
      }
    }
    if((v%(H*W))/W!=H-1 && c[v%(H*W)+W]!='@'){
      if(d[v%(H*W)+3*(H*W)+W]>d[v%(H*W)+3*(H*W)]+1){
        d[v%(H*W)+3*(H*W)+W]=d[v%(H*W)+3*(H*W)]+1;
        q.push({d[v%(H*W)+3*(H*W)+W],v%(H*W)+3*(H*W)+W});
      }
    }
  }
}

int main(){
  cin>>H>>W>>K;
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  for(int i=0;i<H*W;i++){
    cin>>c[i];
  }
  dijkstra(W*(x1-1)+y1-1);
  if(d[W*(x2-1)+y2-1]==INF){cout<<-1<<endl;return 0;}
  cout<<(d[W*(x2-1)+y2-1]+K-1)/K<<endl;
}


Measured memory_bytes: 43860