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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int incidencia[100001];
int tps[100001];
int altura[100001];
bool tocados[100001];

priority_queue<pii> explorar;

vi hojas;
int r = 0, n,k;

void calcularAltura(int nodo){
	if(tps[nodo] == 1)
		altura[nodo] = 1;
	else {
		if(altura[tps[nodo]] == 0)
			calcularAltura(tps[nodo]);
		
		altura[nodo] = 1 + altura[tps[nodo]];
	}
}

void reenchufar(){
	int actual = explorar.top().snd;
	int siguiente = tps[actual];

	explorar.pop();
	
	forn(i,k-1){
		if(tocados[actual])
			return;
		
		tocados[actual] = true;
		
		if(siguiente == 1)
			break;
		
		actual = siguiente;
		siguiente = tps[actual];
		
	}
	
	if(siguiente != 1){
		incidencia[siguiente]--;
		r++;
		tps[actual] = 1;
	}
	
	if(incidencia[siguiente] == 0)
		explorar.push(mp(altura[siguiente],siguiente));
	
	return;

}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
		
	// setear altura como -1 o con 0 anda;
		
	cin >> n >> k;
	forsn(i,1,n+1){
		cin >> tps[i];
		incidencia[tps[i]]++;
	}
	
	// Se enchufa la capital a si misma
	if(tps[1] != 1){
		incidencia[tps[1]]--;
		incidencia[1]++;
		tps[1] = 1;
		r++;
	}
	
	// Se meten las hojas en hojas y se calcula la altura de cada nodo, la capital nunca va a ser una hoja
	// Ahora se meten en la priqueue por orden de pistruli

	
	forsn(i,1,n+1){
		if(incidencia[i] == 0){
			hojas.pb(i);
			calcularAltura(i);
			explorar.push(mp(altura[i],i));
		}
	}
	
	// Con la pq se hace el reenchufe de antes
	while(si(explorar)){
		reenchufar();
	}
	
	cout << r << endl;
	
    return 0;
}

Measured memory_bytes: 8008
import java.util.Scanner;
import java.util.InputMismatchException;

class Main {
   public static void main(String args[]) {
      int N=0;
      int[] z;
      Scanner scanner = new Scanner(System.in);
      N = scanner.nextInt();
      z = new int[N];
      for (int i=0; i<N; i++) {
         z[i] = scanner.nextInt();
      }
      scanner.close();
      int max = -1;
      int count = 0;
      for (int i=0; i<N; i++) {
         if (z[i]>max) {
            //System.out.println(z[i]);
            max = z[i];
         }
      }
      for (int i=0; i<N; i++) {
         if (z[i] == max) {
            count++;
         }
      }
      int max2 = -1;
      for (int i=0; i<N; i++) {
         if (z[i] == max) {
            continue;
         } else if (z[i] > max2) {
            max2 = z[i];
         }
      }

      if (max2 == -1) {
         for (int i=0; i<N; i++) {
            System.out.println(max);
         }
      } else {
         for (int i=0; i<N; i++) {
            if (z[i] == max && count == 1) {
               System.out.println(max2);
            } else {
               System.out.println(max);
            }
         }
      }

   }
}


Measured memory_bytes: 94356
/*
I just got lost in thought. It was unfamiliar territory.
- Steven Wright
*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <vector>
//#include <boost/math/common_factor.hpp>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 1000000000;
const int MAX = 100005;
const int MAX1 = 2007;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1234567891;
//g++ -std=c++11 your_file.cpp -o your_program

bool arr[30][30];

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	string s, t;
	cin >> s >> t;
	REP(i, SZ(s)){
	    arr[s[i] - 'a'][t[i] - 'a'] = 1;
	}
	REP(i, 26){
	    int ct = 0;
	    REP(j, 26){
	        if (arr[i][j]) ++ct;
	    }
	    if (ct >= 2) {
	        cout << "No" << endl;
	        return 0;
	    }
	}
	REP(i, 26){
	    int ct = 0;
	    REP(j, 26){
	        if (arr[j][i]) ++ct;
	    }
	    if (ct >= 2){
	        cout << "No" << endl;
	        return 0;
	    }
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 916
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int wol = 3;
void add(int a,int b,int c){
  cout << "+ " << a << " " << b << " " << c << "\n";
}
void por(int a,int b,int c){
  cout << "< " << a << " " << b << " " << c << "\n";
}

int addnew(int a,int b){
  add(a,b,wol);
  return wol++;
}
void addself(int a,int b){
  add(a,b,a);
}
int pornew(int a,int b){
  por(a,b,wol);
  return wol++;
}
int rob1(){
  int x = addnew(0,1);
  int x2 = addnew(x,x);
  return pornew(x,x2);
}

//res += a * 2 ^ w
void dodaj(int res, int a,int w){
  int tmp = addnew(a, wol);
  R(i,w){
    add(tmp,tmp,tmp);
  }
  addself(res, tmp);
}
const int C = 31;
vector<int> p2(C);
vector<int> rozkladaj(int a){
  addself(a, p2[0]);
  int res = wol++;
  vector<int> bity(C);
  R(i,C)bity[i] = wol++;
  for(int i = C - 1; i >= 0;i--){
    int pom = addnew(p2[i], res);
    por(pom, a, bity[i]);
    dodaj(res, bity[i], i);
  }
  return bity;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cout << "33917\n";
  p2[0] = rob1();
  R(i,C-1){
    p2[i+1] = addnew(p2[i], wol);
    add(p2[i+1], p2[i], p2[i+1]);
  }
  vector<int> bity1 = rozkladaj(0);
  vector<int> bity2 = rozkladaj(1);
  R(i,C)R(j,C){
    int pom = addnew(bity1[i],bity2[j]);
    int pom2 = pornew(p2[0], pom);
    dodaj(2, pom2, i + j);
  }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  vector<P> X(N);
  vector<int> A(N);
  REP(i, N) {
    cin >> X[i].first;
    X[i].second = i;
    A[i] = X[i].first;
  }
  sort(X.begin(), X.end());
  int div = (N) / 2;
  REP(i, N) {
    if (X[div].first > A[i]) {
      cout << X[div].first << endl;
    } else {
      cout << X[div - 1].first << endl;
    }
  }
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            List<string> list = new List<string>();

            for (int i = 0; i < N; i++)
            {
                list.Add(Console.ReadLine());
            }

            var AN = list.Distinct();

            Console.WriteLine(AN.Count());
        }
    }
}


Measured memory_bytes: 48028
// Author - Abhishek giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 100000000007
#define V(type) vector<type> 
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)

/*##################################################################################*/


/*
bitset<10000000> prime ;
void calculateprime()
{
    //calculating primes
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; (ll)i*i <= 10000000 ; i++)
    {
        if(prime[i] == 0)
        {
            for(ll j = i*i ; j <= 10000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}
*/

bool isprime(long n)
{
    for(int i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}


/*
ll fib(int n) 
{ 
  ll a = 0, b = 1, c, i; 
  if( n == 0) 
    return a; 
  for (i = 2; i <= n; i++) 
  { 
    c = (a + b); 
    a = b; 
    b = c; 
  } 
  return b; 
}
*/


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


ll findgrouplcm(ll arr[], ll n) 
{ 
    ll ans = arr[0]; 
  
    for (ll i = 1; i < n; i++) 
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));
  
    return ans; 
}



ll powerwithmod(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t =1;
    //cin>>t;
    while(t--)
    {
        ll a;
        in(a);
        ll t = 0 ,temp =100;
        while(temp < a){
            ll i = (temp*1)/100;
            temp += i ;
            ++t;
        }
        out(t);
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MAX_DIGIT = 50;
long long dp[100][2]; // dp[上から i 桁まで][ smaller ]

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    memset(dp, -1, sizeof(dp)); // DP 配列を -1 で初期化
    dp[0][0] = 0; // 初期条件
    for (int d = 0; d < MAX_DIGIT; ++d) {
        long long mask = 1LL<<(MAX_DIGIT - d - 1);
        
        // A で元々 d 桁目にビットが立っているものの個数
        int num = 0;
        for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;
        
        // X の d 桁目を 0, 1 にしたときのコスト
        long long cost0 = mask * num;
        long long cost1 = mask * (N - num);
        
        // smaller -> smaller
        if (dp[d][1] != -1) {
            chmax(dp[d+1][1], dp[d][1] + max(cost0, cost1)); // 0 でも 1 でも自在に大きい方
        }
        
        // exact -> smaller
        if (dp[d][0] != -1) {
            if (K & mask) { // K の d 桁目が 1 だったら、X の d 桁目は 0 にする
                chmax(dp[d+1][1], dp[d][0] + cost0);
            }
        }
        
        // exact -> exact (K にぴったり合わせる)
        if (dp[d][0] != -1) {
            if (K & mask) chmax(dp[d+1][0], dp[d][0] + cost1);
            else chmax(dp[d+1][0], dp[d][0] + cost0);
        }
    }
    cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]) << endl;
}

Measured memory_bytes: 1152
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	y, _ := strconv.Atoi(strings.Split(s, "/")[0])
	m, _ := strconv.Atoi(strings.Split(s, "/")[1])
	d, _ := strconv.Atoi(strings.Split(s, "/")[2])
	if y <= 2019 && m <= 04 && d <= 30 {
		fmt.Println("Heisei")
		return
	}
	fmt.Println("TBD")
}


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

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

    vector<int> G[205];
    for (int i = 0; i < n; i++) {
        char s[205];
        cin >> s;
        for (int j = 0; j < n; j++) {
            if (s[j] == '1') G[i].push_back(j);
        }
    }

    queue<int> que;
    que.push(0);
    int v[205] = {};
    v[0] = 1;
    while (!que.empty()) {
        int q = que.front();
        que.pop();
        for (int i = 0; i < G[q].size(); i++) {
            if (v[G[q][i]] == 0) {
                v[G[q][i]] = -v[q];
                que.push(G[q][i]);
            }
            else if (v[G[q][i]] == v[q]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int w[205] = {}, idx = 0;
        bool t[205] = {};
        queue<int> que2;
        w[i] = 1;
        t[i] = 1;
        que2.push(i);
        while (!que2.empty()) {
            idx++;
            int loop = que2.size();
            for (int j = 0; j < loop; j++) {
                int q = que2.front();
                que2.pop();
                for (int j = 0; j < G[q].size(); j++) {
                    if (!t[G[q][j]]) {
                        que2.push(G[q][j]);
                        t[G[q][j]] = 1;
                    }
                }
            }
        }
        ans = max(idx, ans);
    }

    cout << ans << endl;


}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4

int main(){
  string S; cin >> S;
  int N = S.size();

  int count[N] = {};
  for (int i=0;i<N;i++){
    if (S[i]=='A' || S[i]=='T' || S[i]=='G' || S[i]=='C') count[i]=1;
  }
  
  int sum = 0,max_sum = 0;
  rep(i,N){
    sum += count[i];
    if (i==N-1 || count[i]==0){
      max_sum = max(max_sum, sum);
      sum=0;
    }
  }

  cout << max_sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() << 14)+rand()
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int x, y, n;
multiset<int> s;
vector<pii> v;
int main(){
    cin >> n;
    fox(l, n){
        cin >> x >> y;
        v.pb(mp(x, y+1));
    }
    fox(l, n){
        cin >> x >> y;
        v.pb(mp(x, -y-1));
    }
    int c=0;
    s.insert(1<<30);
    sort(v.begin(), v.end());
    fox(l, v.size()){
        //cout << v[l].x
        if (v[l].y>0) s.insert(v[l].y);
        else if (s.lb(-v[l].y)!=s.begin()){
            s.erase(--s.lb(-v[l].y));
            c++;
        }
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) begin(x),end(x)
#define oo(i,a) for (int i = 0; i < (a); i++)
#define ooo(i,a,b) for (int i = a; i < (b); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const char newl = 10;
const int MOD = 998244353;
const int N = 100005;
// set N | watch out for overflow | n == 1 |
void run(){
   int k;
   int n;
   cin >> k >> n;
   vector<int> a(n);
   for (int i = 0; i < n; i++) cin >> a[i];
   sort(all(a));
   int mx = k - a.back() + a[0];
   for (int i = 1; i < n; i++) {
      if (a[i] - a[i - 1] > mx) {
         mx = a[i] - a[i - 1];
      }
   }
   cout << k - mx;
   return ;
}
int main(){
   ios_base::sync_with_stdio(0);
   cout.tie(0);cin.tie(0);
   int t = 1;
   // cin >> t;
   for (int tc = 1; tc <= t; tc++) {
      // cout << "Case #" << tc << ": ";
      run();
   }
   return 0;
}

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

const int INF = 10000000;

int mp(vector<int> used, vector<int> target, vector<int> banboo){
    if (used[0] == target[0]){
        if (min(min(used[1], used[2]), used[3]) == 0)
            return INF;
        else
            return abs(used[1] - target[1]) + abs(used[2] - target[2]) + abs(used[3] - target[3]) - 30;
    }
    int retA = mp({used[0]+1, used[1]+banboo[used[0]], used[2], used[3]}, target, banboo) + 10;
    int retB = mp({used[0]+1, used[1], used[2]+banboo[used[0]], used[3]}, target, banboo) + 10;
    int retC = mp({used[0]+1, used[1], used[2], used[3]+banboo[used[0]]}, target, banboo) + 10;
    int ret0 = mp({used[0]+1, used[1], used[2], used[3]}, target, banboo);
    return min(min(retA, retB), min(retC, ret0));
}

int main(){
    int N, A, B ,C;
    cin >> N >> A >> B >> C;
    vector<int> banboo(N, 0);
    for (size_t i; i < N; ++i){
        cin >> banboo[i];        
    }
    int ret = mp({0,0,0,0}, {N, A, B, C}, banboo);
    cout << ret << endl;
    return 0;
}

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

const int maxn = 1e5 + 5;
long long dp[maxn];

int main() {
    for (int i = 0; i < maxn; ++i) dp[i] = 1e15;
    dp[0] = 0;
    int n, w; scanf("%d%d", &n, &w);
    int vsum = 0;
    for (int i = 0; i < n; ++i) {
        int x, y; scanf("%d%d", &x, &y);
        vsum += y;
        for (int j = vsum; j >= y; --j) dp[j] = min(dp[j], dp[j - y] + x);
    }
    int ans = 0;
    for (int i = 0; i < maxn; ++i) if (dp[i] <= w) ans = i;
    printf("%d\n", ans);
}


Measured memory_bytes: 1024
N,M= gets.chomp!.split.map(&:to_i)
Citys=[]

for i in 0...M
  Citys[i*2],Citys[i*2+1]= gets.chomp!.split.map(&:to_i)
end

for i in 0...N 
puts Citys.count(i+1)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a-=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}
const int n_max=1e5+10;

ll kai[2*n_max+1];
ll inv[2*n_max+1];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a,b,c;
  cin >> n >> a >> b >> c;
  
  kai[0]=1;
  rep1(i,2*n)  kai[i] = mu(kai[i-1],i);
  rep(i,2*n+1) inv[i] = dv(1,kai[i]);

  ll sum=0;
  ll cconv = dv(100, 100-c);  
  for(int i=n;i<=2*n-1;i++){
    ll comb=mu(mu(kai[i-1],inv[n-1]),inv[i-n]);
    ll proba =mu(pw(a,n),pw(b,i-n));
    ll probb =mu(pw(b,n),pw(a,i-n));
    sum = ad(mu(dv(mu(comb,proba),pw(a+b,i)), mu(cconv,i)),sum);
    sum = ad(mu(dv(mu(comb,probb),pw(a+b,i)), mu(cconv,i)),sum);
  }
  cout << sum  << endl;
  
  //  cout << dfs(0,0) << endl;
  
  
  return 0;
  

}


Measured memory_bytes: 3328
import math
import sys
input = sys.stdin.readline

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for j in range(N):
    for i in range(j):
        dist = 0
        for d in range(D):
            dist += (X[i][d] - X[j][d]) ** 2
        if math.sqrt(dist) % 1 == 0:
            cnt += 1
print(cnt)


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

int main()
{
	int n;
  	cin>>n;
  	int dp[n][3];
  	for(int i=0;i<n;i++){
      int x,y,z;
      cin>>x>>y>>z;
      if(i==0){
      	dp[i][0]=x;
      	dp[i][1]=y;
      	dp[i][2]=z;
      }
      else{
        dp[i][0]=x+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=y+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=z+max(dp[i-1][0],dp[i-1][1]);
      }
    }
  	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
  	return 0;
}

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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int n;
  cin >> n;
  for (int i = 1; i < 3501; i++)
  {
    for (int j = 1; j < 3501; j++)
    {
      int x = n * i * j;
      int y = 4 * i * j - n * i - n * j;
      if(y > 0)
      {
         if(x/y > 0 and x%y == 0)
         {
           cout<<i<<" "<<j<<" "<<x/y<<endl;
           return;
         }
      }
    }
  }

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

const int inf = 1001001001;

int main(){
  string s,t;
  cin >> s >> t;
  int n = sz(s);
  int m = sz(t);
  vector<vector<int>> is(26);
  rep(i,n) is[s[i] - 'a'].push_back(i);
  rep(i,n) is[s[i] - 'a'].push_back(i+n);
  ll ans = 0;
  int p = 0;
  rep(i,m){
    int c = t[i]-'a';
    if(sz(is[c]) == 0){
      puts("-1");
      return 0;
    }
    p = *lower_bound(is[c].begin(), is[c].end(), p)+1;
    if(p >= n){
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
}


Measured memory_bytes: 4640
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n = II()
    ans = n * 800
    print(ans-(n//15)*200)
    return

#B
def B():
    n = II()
    print(math.factorial(n)%mod)
    return

#C
def C():
    n, m = LI()
    if n >= m // 2:
        print(m // 2)
        return
    else:
        m -= 2 * n
        print(n+m//4)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 3700
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
#define LL long long

LL dp[55][2];

int main ()
{
    int n, p, x;
    scanf("%d%d",&n,&p);
    dp[0][0]=1;
    for (int i=1; i<=n; ++i) {
        scanf("%d",&x);
        if (x&1) dp[i][1]=dp[i-1][0]+dp[i-1][1], dp[i][0]=dp[i-1][1]+dp[i-1][0];
        else dp[i][1]=dp[i-1][1]*2, dp[i][0]=dp[i-1][0]*2;
    }
    printf("%lld\n",dp[n][p]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 50;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
int n,ans,a[N];
string s[N],x;
int main(){
	//freopen("input.txt","r",stdin);
	cin >> n;
	for(int i = 0;i < n;i++)cin >> s[i] >> a[i];
	cin >> x;
	for(int i = n - 1;i + 1;i--){
		if(x == s[i])break;
		ans+=a[i];
	}
	cout << ans << endl;
}

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

int main(){
    int s;
    std::cin >> s;
    int m[1000001] = {0};
    int a=s;
    int b = 0;
    m[s+1]++;
    int i=1;
    while(1){
        if(a%2 == 0) b = a/2;
        else    b = 3*a+1;
        std::cerr << b << "  ";
        if(m[b+1]==0){
            m[b+1] = i;
        }else{
            std::cout << ++i << std::endl;
            break;
        }
        a = b;
        i++;
    }
	return 0;
}

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

void solve(long long N, std::vector<long long> A){
  int i;
  for(i = 0; i < 10000; i++){
    REP(j, N) {
      if((A[j] % 2) == 1) {
        cout << i << endl;
        return;
      }
      A[j] /= 2;
    }
  }

  return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#ifndef ONLINE_JUDGE
#include "default.h"
#else
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#endif

using namespace std;
using namespace __gnu_pbds;


#pragma GCC target("popcnt")  //https://godbolt.org/z/yQv94Y 

typedef long long int ll;
typedef unsigned long long int  ull;
typedef long double ld;

const ld pi = 4.0*atan(1.0);
#define xlr8 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(10); cout<<fixed


typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// T.insert(a), T.erase(a), T.size()
// T.order_of_key(a) -- number of elements strictly less than a
// *T.find_by_order(k) -- k-th element in increasing order

struct Timer
{   chrono::time_point<chrono::high_resolution_clock> start , end; chrono:: duration<float> dur;
    Timer(){start = chrono::high_resolution_clock::now();}
    ~Timer(){   end = chrono::high_resolution_clock::now(); dur = end - start;  cout<<"\nTime Elapsed : " <<dur.count() << " s\n";  }
};


template<typename T>
void getVec(vector<T>& a , int st, int en)
{
    int dif = (en > st ? 1 : -1);
    for(int  i = st ; i!= en ; i+= dif)
        cin>>a[i];
}
template<typename T>
void getVecPair(vector<pair<T , T > >& a , int st, int en)
{
    int dif = (en > st ? 1 : -1);
    for(int  i = st ; i!= en ; i+= dif)
        cin>>a[i].first>>a[i].second;
}


//76149
template<int D, typename T> 
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template<typename... Args>
  Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
  }
};
template<typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, T val = T()) : vector<T>(n, val) {
  }
};


// const int MAX = 1000;
// Vec<2 , int > dp(MAX + 1, MAX + 1, -1);

struct SegmentTree
{
    ll n;
    vector<ll> t;
    SegmentTree(ll n) : n(n)
    {
        t.resize(2*n , 0);
    }

    void modify(int pos , int value)
    {
        for(t[pos += n] = value; pos > 0; pos >>= 1)
            t[pos>>1] = max(t[pos] , t[pos ^ 1]);
    }

    ll query(int l , int r)
    {
        ll resl = 0, resr = 0;
        for(l += n , r+= n ; l < r ; l>>=1 , r>>=1)
        {
            if(l&1)
                resl = max(resl , t[l++]);
            if(r&1)
                resr = max(t[--r] , resr);
        }
        return max(resl , resr);
    }
};


int main()
{
    xlr8;
    int testCases  = 1;
    // cin>>testCases;
    while (testCases--)
    {
        int n , k;
        cin>>n>>k;
        vector<int> a(n);
        getVec(a , 0 , n);

        const int MAX = 300000;
        SegmentTree T(MAX + 1);
        for(int i = 0 ; i< n ; i++)
        {
            ll tmp = T.query( max(0 , a[i] - k) , min(MAX + 1 , a[i] + k + 1 )) + 1;
            ll tmp2 = T.query(a[i] , a[i] + 1);
            T.modify(a[i] , max(tmp , tmp2));
        }

        cout<<T.query(0 , MAX + 1)<<"\n";
    }
}


Measured memory_bytes: 9004
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
  int x;
  cin >> x;
  if(x==3||x==5||x==7) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
     long long int n;
     long long int i,j,k,t;
     cin>>n;
     t=ceil(sqrt(n));
    

    for( i=t;i>0;i--)
    {
         if(n%i==0)
         {
            j=i;

            k=n/i;

            cout<<j+k-2<<endl;
            break;
         }
    }


     return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000001
#define PI 3.14159265358979323846
using namespace std;
int h, w, k, nb=0;
char c[6][6];
bool col[6], lig[6];
int count_black()
{
	int x=0;
	for(int i = 0; i < w; i++)
	{
		for(int j = 0; j < h; j++)
		{
			if(col[i] && lig[j] && c[i][j]=='#')
				x++;
		}
	}
	return x;
}
void choose_lig(int idx)
{
	if(idx==h)
	{
		if(count_black()==k)
			nb++;
		return;
	}
	lig[idx]=true;
	choose_lig(idx+1);
	lig[idx]=false;
	choose_lig(idx+1);
}
void choose_col(int idx)
{
	if(idx==w)
	{
		choose_lig(0);
		return;
	}
	col[idx]=true;
	choose_col(idx+1);
	col[idx]=false;
	choose_col(idx+1);
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> h >> w >> k;
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
			cin >> c[j][i];
	}
	choose_col(0);
	cout << nb << '\n';
}

Measured memory_bytes: 3648
<?php

$n = trim(fgets(STDIN));
$s = explode(' ', trim(fgets(STDIN)));

$count = 0;
for($i=0; $i<$n-2; $i++){
    $t = $i;
    $a = [$s[$t],$s[$t+1],$s[$t+2]];
    sort($a);
    if ($a[1] == $s[$t+1]) $count++;
}
  
echo $count;

?>

Measured memory_bytes: 4604
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iterator>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(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--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    ll x, ans=0;
    cin >> x;

    ans += (x / 500)*1000;
    ans += ((x%500)/5)*5;

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
import itertools
n=int(input())
f=[list(map(int,input().split())) for _ in range(n)]
p=[list(map(int,input().split())) for _ in range(n)]
ans=-(10**12)
for i in range(1,11):
    num=list(itertools.combinations(range(10),i))
    for j in range(len(num)):
        cnt=[0]*n
        cnt2=0
        for k in range(i):
            for l in range(n):
                if f[l][num[j][k]]==1:
                    cnt[l]+=1
        for k in range(n):
            cnt2+=p[k][cnt[k]]
        ans=max(cnt2,ans)
print(ans)


Measured memory_bytes: 9112
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int ans = 0;
    int maxi = 0; // 10分に満たない分の最大値
    for (int i = 0; i < 5; i++) {
      int a = sc.nextInt();
      int b = (a + 9) / 10 * 10; // 10分単位で切り上げ
      ans += b;
      if (maxi < b - a) {
        maxi = b - a;
      }
    }
    System.out.println(ans - maxi); // 最後の注文は10分待たない。
  }
}


Measured memory_bytes: 25300
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;
int main()
{
    int n = 0, tarou = 0, hanako = 0;
    string str1, str2;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> str1 >> str2;
        if (str1 > str2)
        {
            tarou += 3;
        }
        else if (str1 < str2)
        {
            hanako += 3;
        }
        else
        {
            tarou++;
            hanako++;
        }
        
    }
    cout << tarou << " " << hanako << endl;
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
    string S, SS, T, C;
    cin >> SS >> T;
    if(T.length()>SS.length())
    {
        cout << "UNRESTORABLE" << endl;
    }
    else if(T.length()==SS.length())
    {
        for(int i=0; i<T.length(); i=i+1)
        {
            if(SS[i]=='?' || T[i]==SS[i])
            {
                S+=T[i];
            }
            else
            {
                cout << "UNRESTORABLE" << endl;
                return 0;
            }    
        }
        cout << S << endl;
    }
    else
    {
        C="|";
        for(int j=0; j<(SS.length()-T.length()+1); j=j+1)
        {
            int satisfy=1;
            for(int i=0; i<T.length(); i=i+1)
            {
                if(SS[i+j]!=T[i] && SS[i+j]!='?')
                {
                    satisfy=0;
                }
            }
            if (satisfy == 1)
            {
                S="";
                for(int s=0; s<SS.length(); s=s+1)
                {
                    if(SS[s]!='?')
                    {
                        S+=SS[s];
                    }
                    else
                    {
                        S+='a';
                    }
                }
                for(int t=0; t<T.length(); t=t+1)
                {
                    S[j+t]=T[t];
                }
                if(S<C)
                {
                    C="";
                    for(int n=0; n<S.length(); n=n+1)
                    {
                        C+=S[n];
                    }
                }
            }
        }
        if(C=="|")
        {
            cout << "UNRESTORABLE" << endl; 
        }
        else
        {
            cout << C << endl;
        }              
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n,m;
  cin>>n>>m;
  set<int> solved;
  vector<int> wrong(n+1,0);
  for (int i = 0; i < m; ++i)
  {
    int p;
    string s;
    cin>>p>>s;
    if(solved.end()!=solved.find(p)) continue;
    if(s=="AC") solved.insert(p);
    else wrong[p]++;
  }
  cout<<solved.size();
  int point=0;
  for(auto&& e: solved) 
  {
    point+=wrong[e];
  }
  cout<<" "<<point;
}

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

int main () {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  
  vector<int> vec = {A1, A2, A3};
  sort (vec.begin(), vec.end());
  
  cout << vec.at(2) - vec.at(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define M 1000005
#define rint register int
int k,x;
int main() {
	scanf("%d%d",&k,&x);
	for(int i=max(-1000000,x-k+1); i<=min(1000000,x+k-1); ++i)printf("%d ",i);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	double a,b,ans=0,c=0;
	cin>>a>>b;
	vector<double> v(a);
	for(int i=0;i<a;++i){
		cin>>v[i];
		c += v[i];
	}
	sort(v.begin(),v.end());
	for(int i=0;i<a;++i){
		if(v[i] >= (c / (4 * b))) ans++;
	}
	if(ans >= b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>mochi(N);
  for(int i=0; i<N; i++)
    cin >> mochi.at(i);
  vector<int>kagami(N);
  int count = 0;
  for(int j=0; j<N; j++){
    mochi.at(0) = mochi.at(j);
    for(int l=j+1; l<N; l++){
      if(mochi.at(0) == mochi.at(l)){
        mochi.at(l) = 0;
        continue;
      }
      else
         continue;
    }
    kagami.at(j) = mochi.at(0);
  }
  for(int n=0; n<N; n++){
    if (kagami.at(n) == 0)
      continue;
    else{
      count++;
      continue;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
n=int(input())
a=map(int,input().split())
import statistics
t=1
b=10**15
c=-(10**15)
d=[]
for i in a:
    e=i-t
    d.append(e)
    t+=1
i=int(statistics.median(d))
k=0
for j in d:
    k+=abs(j-i)
print(k)

Measured memory_bytes: 27912
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priotity_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,m,a,b,c,d,e,li[114514];
string s,w;

int main(){
	cin >> s;
	
	if(s[0]==s[1] and s[1]==s[2]) cout << "Yes" << endl;
	else if(s[1]==s[2] and s[2]==s[3]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    map<ll, ll> cnt;
    rep(i, n) cnt[a[i]]++;
    vector<ll> l(2, -1);
    ll idx = 0;
    for(auto it = cnt.rbegin(); it != cnt.rend(); it++) {
        ll v = it->first;
        ll c = it->second;
        rep(i, 2) {
            if (c >= 2) {
                l[idx++] = v;
                c -= 2;
            }
            if (idx == 2) {
                cout << (l[0] * l[1]) << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main() {
string s;
cin>>s;
deque<char>q;
for(char c:s)q.push_back(c);
bool flip = false;
int Q;
cin >> Q;
rep(i,Q){
    ll y;
     cin>>y;
     if(y==1)flip=!flip;
     else{
         ll z; char c;
         cin>>z>>c;
         if(flip) z=3-z;
         if(z==1)q.push_front(c);
         else q.push_back(c);
     } 
}
if(flip)reverse(q.begin(),q.end());
string ans;
for(char c:q)ans+=c;
cout<<ans<<endl;
return 0;

}


Measured memory_bytes: 1412
N = gets.to_i
heights = gets.split.map(&:to_i)
longest = 0
current = 0
previous = heights.shift
heights.map.with_index { |num, i|
  if previous >= num
    current += 1
  else
    longest = [longest, current].max
    break if longest >= N - i
    current = 0
  end
  previous = num
}
longest = [longest, current].max
puts longest


Measured memory_bytes: 11908
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 
#define int ll
using namespace std;

const int N = 3e5 + 5 ;
const int mod = 998244353 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const long double eps = 1e-9 ;

using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

int n , s;
int dp[3001][3001] , a[3001] ;
int get_dp(int pos , int val){
    if(pos == n) return val == 0;
    int& res = dp[pos][val];
    if(~res) return res; 
    res = 0 ;
    if(val >= a[pos]) res = (res + get_dp(pos + 1, val - a[pos])) % mod ;
    res = (res + 2LL * get_dp(pos + 1 , val)) % mod ;
    // cout << pos << ' ' << val << ' ' << res << '\n';
    return res; 
}

void solve()
{
    cin >> n >> s ;
    rep(i , n) cin >> a[i];
    setval(dp , -1);
    int ans = get_dp(0 , s);
    // for(int i = 0 ; i <= n ; ++i){
    //     cout << get_dp(i , s) << '\n';
    //     ans = (ans + get_dp(i , s)) % mod ;
    // }
    cout << ans ;
}
     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


Measured memory_bytes: 74220
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    map<int,int> m;
    rep(i,n) {
        int a;
        cin >> a;
        m[a]++;
    }
    int ans = 0;
    for(auto p : m) if(p.second%2 == 1) ans++;
    cout << ans << endl;
}


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

int main()
{
  int n;cin>>n;
  vector<int> a(n-1);
  vector<int> b(n-1);
  vector<long long> c(n-1);
  int i;
  for(i=0;i<n-1;i++)cin>>a.at(i)>>b.at(i)>>c.at(i);
  for(i=0;i<n-1;i++)
  {
    a.at(i)--;
    b.at(i)--;
  }
  int q,k;cin>>q>>k;
  k--;
  vector<int> x(q);
  vector<int> y(q);
  for(i=0;i<q;i++)cin>>x.at(i)>>y.at(i);
  for(i=0;i<q;i++)
  {
    x.at(i)--;
    y.at(i)--;
  }
  vector<long long> tok(n);
  queue<int> que;
  queue<int> que2;
  vector<vector<int>> next(n,vector<int>(0));
  vector<bool> visit(n,false);
  for(i=0;i<n-1;i++)
  {
    next.at(a.at(i)).push_back(b.at(i));
    next.at(b.at(i)).push_back(a.at(i));
  }
  map<pair<int,int>, int> mp;
  for(i=0;i<n-1;i++)
  {
    mp.insert(make_pair(make_pair(a.at(i),b.at(i)),c.at(i)));
    mp.insert(make_pair(make_pair(b.at(i),a.at(i)),c.at(i)));
  }
  que.push(k);
  tok.at(k)=0;
  visit.at(k)=true;
  int num=1;
  while(!que.empty())
  {
    while(!que.empty())
    {
      int top=que.front();
      que.pop();
      for(i=0;i<next.at(top).size();i++)
      {
        if(!visit.at(next.at(top).at(i)))
        {
          que2.push(next.at(top).at(i));
          visit.at(next.at(top).at(i))=true;
          tok.at(next.at(top).at(i))=tok.at(top)+mp.at(make_pair(top,next.at(top).at(i)));
        }
      }
    }
    while(!que2.empty())
    {
      que.push(que2.front());
      que2.pop();
    }
    num++;
  }
  for(i=0;i<q;i++)
  {
    cout<<tok.at(x.at(i))+tok.at(y.at(i))<<endl;
  }
}


Measured memory_bytes: 23288
#include <stdio.h>

int main(void) {
	// your code goes here
	int a;
	int maxL = -1,sum = 0;
	scanf("%d",&a);
	int b[a];
	
	for(int i = 0;i<a;i++){
		
		scanf("%d",&b[i]);
		
		if(b[i]>maxL){
			maxL = b[i];
			
		}
		sum += b[i];
		
		
	}
	sum -= maxL;
	if(sum>maxL){
		printf("Yes");
	}else{
		printf("No");
	}
	
	
	return 0;
}

Measured memory_bytes: 128