akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  string s[h];
  int i,j;
  for(i=0;i<h;i++){
    cin >> s[i];
  }
  int max = 0;
  int tmp;
  int cur;


  int maxh=0;
  int maxw=0;
  int ww[h]={};
  int hh[w]={};
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(s[i][j]=='.'){
        ww[i]++;
        hh[j]++;
      }
    }
  }
  for(i=0;i<h;i++){
    if(ww[i]>maxw)maxw = ww[i];
  }
  for(i=0;i<w;i++){
    if(hh[i]>maxh)maxh = hh[i];
  }

  int chk = 0;
  int tmpL=0;
  int tmpR=0;
  int tmpU=0;
  int tmpD=0;
  for(i=0;i<h;i++){
    chk = 0;
    for(j=0;j<w;j++){
      if(s[i][j]=='#'){
        chk = 0;
        continue;
      }else{
        tmpU=i;
        tmpD=i;
        if(chk==0){
          tmpL=j;
          tmpR=j;


          while(tmpL>0&&s[i][tmpL-1]!='#')tmpL--;
          while(tmpR<w-1&&s[i][tmpR+1]!='#')tmpR++;
          chk = 1;
        }
        while(tmpU>0&&s[tmpU-1][j]!='#')tmpU--;
        while(tmpD<h-1&&s[tmpD+1][j]!='#')tmpD++;

        tmp = tmpR-tmpL+tmpD-tmpU+1;

        if(tmp>max)max = tmp;
        if(max == maxh+maxw-1)break;
      }
    }
    if(max == maxh+maxw-1)break;
  }

cout << max;
  
}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (auto& e : p) {
		cin >> e;
		e++;
	}

	// sort(p.rbegin(), p.rend());

	double cur = 0, ans = 0;
	for (int i = 0; i < k; i++) {
		cur += double(p[i])/double(2);
	}

	for (int i = k; i < n; i++) {
		cur -= double(p[i - k])/double(2);
		cur += double(p[i])/double(2);
		ans = max(ans, cur);
	}

	cout << setprecision(10) << max(cur, ans) << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int N;
	char s;
	bool contains_y = false;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> s;

		if (s == 'Y')
		{
			contains_y = true;
		}
	}

	if (contains_y)
	{
		cout << "Four" << endl;
	}
	else
	{
		cout << "Three" << endl;
	}
	
	return 0;
}

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

const int MAX_N = 1000005;
int N;
bool found_divisor[MAX_N];
int prime_counts[MAX_N];
int has_prime[MAX_N];
int vals[MAX_N];
int prime_chain[MAX_N];

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int v;
    scanf("%d", &v);
    vals[v]++;
  }

  for (int64_t i = 2; i < MAX_N; ++i) {
    if (found_divisor[i]) continue;
    found_divisor[i] = true;
    prime_chain[i] = i;
    for (int64_t j = i * i; j < MAX_N; j += i) {
      if (found_divisor[j] == 0) prime_chain[j] = i;
      found_divisor[j] = true;
    }
  }

  bool pairwise = true;
  bool setwise = true;
  for (int i = 0; i < MAX_N; ++i) {
    for (int k = 0; k < vals[i]; ++k) {
      int v = i;
      while (v > 1) {
        int p = prime_chain[v];
        if (has_prime[p] && v % p == 0) pairwise =  false;
        bool had_prime = false;
        while (v % p == 0) {
          v /= p;
          had_prime = true;
        }
        if (had_prime) {
          has_prime[p] = 1;
          prime_counts[p] += 1;
          if (prime_counts[p] == N) setwise = false;
        }
      }
    }
  }
  if (pairwise) printf("pairwise coprime\n");
  else if (setwise) printf("setwise coprime\n");
  else printf("not coprime\n");
}


Measured memory_bytes: 20320
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    998244353;


int main()
{  fast
ll  n;
cin>>n;
ll ans=0;
for(ll i=1;i<=n;i++)
{
	if(i%3)
	if(i%5)
	ans+=i;
}
cout<<ans;


}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;

const int NIL = -1;
const int MAX = 20001;
int root[510][510];
double w[510][510];
double e[510][510];

int main(void)
{
	int n;
	double P, Q, t;
	vector<double>p, q;
	cin >> n;
	p.push_back(0);
	for (int i = 0; i < n; i++) {
		cin >> P;
		p.push_back(P);
	}
	for (int i = 0; i < n + 1; i++) {
		cin >> Q;
		q.push_back(Q);
	}
	for (int i = 1; i <= n + 1; i++) {
		e[i][i - 1] = q[i - 1];
		w[i][i - 1] = q[i - 1];
	}
	for (int l = 1; l <= n; l++) {
		for (int i = 1; i <= n - l + 1; i++) {
			int j = i + l - 1;
			e[i][j] = MAX;
			w[i][j] = w[i][j - 1] + p[j] + q[j];
			for (int r = i; r <= j; r++) {
				t = e[i][r - 1] + e[r + 1][j] + w[i][j];
				if (t < e[i][j]) {
					e[i][j] = t;
					root[i][j] = r;
				}
			}
		}
	}
	printf("%.8lf\n", e[1][n]);
	return 0;
}


Measured memory_bytes: 8240
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define krep(n) for(ll k=0;k<(n);k++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } vector<ll> uniq(vector<ll> arr)
{vector<ll>brr;sort(all(arr));brr.append(arr[0]);
for(auto i:arr)if(brr.back()!=i)brr.append(i);return brr;}

void solve(){
    ll n; cin>>n; vector<ll> arr(n); rep(n) cin>>arr[i];
    n=arr.size(); ll tot=0;
    rep(n) jrep(n) krep(n)  if(i>j && j>k) {
        if(arr[i]!=arr[j] && arr[j]!=arr[k] && arr[k]!=arr[i]){
            if(max({arr[i],arr[j],arr[k]}) < arr[i]+arr[j]+arr[k]-max({arr[i],arr[j],arr[k]})) tot++;
            //if(max({arr[i],arr[j],arr[k]}) <= arr[i]+arr[j]+arr[k]-max({arr[i],arr[j],arr[k]})) cout<<i<<j<<k<<endl;;
        }
    } cout<<tot<<endl;
}
 
int main(){
    ffast
    ll t=1;
//    cin>>t;
    rep(t) solve();
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)


Measured memory_bytes: 3640
"""
~~ author : dokueki
~~ created : 10~05~2020
"""

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n, m = map(int, sys.stdin.readline().split())
    h = list(map(int, sys.stdin.readline().split()))
    ans = [True]*n
    for i in range(m):
        a, b = map(int, sys.stdin.readline().split())
        a -= 1
        b -= 1
        if h[a] < h[b]:
            ans[a] = False
        elif h[a] > h[b]:
            ans[b] = False
        else:
            ans[a], ans[b] = False, False
    print(sum(ans))


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


Measured memory_bytes: 84972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

    double curt=0;
    double curv=0;
    double ans=0;
    rep(i,2*t[n]){
        auto it=upper_bound(t.begin(),t.end(),curt);
        int next=(it-t.begin());
        bool flag=1;
        rep(j,next,n+1){
            if(curv-v[j]==t[j]-curt){
                flag=0;
                break;
            }
        }if(flag){
            if(v[--next]==curv){
                curt+=0.5;
                ans+=curv*0.5;
            }
            else{
                curt+=0.5;
                ans+=(2*curv+0.5)*0.25;
                curv+=0.5;
            }
        }
        else{
            curt+=0.5;
            ans+=(2*curv-0.5)*0.25;
            curv-=0.5;
        }
    }
    cout<<setprecision(9)<<ans<<endl;
}



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

int main()
{
    int k, s, ans = 0;
    cin >> k >> s;
    for (int x = 0; x <= k; x++)
        for (int y = 0; y <= k; y++)
            if (s - x - y >= 0 && s - x - y <= k)
                ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int l, r;
    cin >> l >> r;
    if (r - l >= 2020) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1e9;
    for (int i = l; i <= r; i++) {
        for (int j = i + 1; j <= r; j++) {
            ans = min(ans, (int) (1ll * i * j % 2019));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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 MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	ll n;
	cin >> n;
	cout << n*(n-1)/2 << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
dp=[0]*(n+1)
dp[0]=1
dp[1]=1
if 1 in a:
    dp[1]=0
a=set(a)
for i in range(2,n+1):
    if i in a:
        continue
    dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%(10**9+7))

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

int main(){
    int64_t N;
    cin >> N;
    string C;
    cin >> C;

    int64_t start = -1;
    for(int64_t i=0;i<N;i++){
        if(C.at(i) == 'W'){
            start = i;
            break;
        }
    }
    int64_t end = -1;
    for(int64_t i=N-1;i>=0;i--){
        if(C.at(i) == 'R'){
            end = i;
            break;
        }
    }

    int64_t ans = 0;
    if(start != -1 && end != -1){
        string subC = C.substr(start, end-start+1);
        int64_t size = subC.size();
        int64_t countR = 0;
        int64_t countW = 0;
        int64_t countcountW = 0;
        for(int64_t i=0;i<size;i++){
            if(subC.at(i) == 'R'){
                countR++;
            }else{
                countW++;
            }
        }
        for(int64_t i=0;i<countR;i++){
            if(subC.at(i) == 'W'){
                countcountW++;
            }
        }

        ans = min(min(countR, countW), countcountW);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3864
#include <iostream>
using namespace std;
int main()
{
	int data[105],n,ans = 0,temp;
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> data[i];
	for(int i = 1; i <= n; ++i)
	{
		int minj = i;
		for(int j = i; j <= n; ++j)
		{
			if(data[minj] > data[j])
				minj = j;
		}
		temp = data[i];
		data[i] = data[minj];
		data[minj] = temp;
		ans += (minj == i) ? 0 : 1;
	}
	cout << data[1];
	for(int i = 2; i <= n; ++i)
		cout << ' ' << data[i];
	cout << endl << ans << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    if(n%3!=0){
        rep(i,0,n-1){
            if(a[i]!=0){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }else{
        
        unordered_map<ll,ll> mp;
        vector<ll> num;
        rep(i,0,n-1){
            if(mp.find(a[i])==mp.end()){
                num.pb(a[i]);
                mp[a[i]]=1;
                if(num.size()>3){
                    cout<<"No"<<endl;
                    return 0;
                }
            }else{
                mp[a[i]]++;
            }
        }
        if(num.size()==1){
            if(num[0]==0){
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else if(num.size()==2){
            if(mp[num[0]]==n/3 && mp[num[1]]==2*n/3){
                if(num[0]==0){
                    cout<<"Yes"<<endl;
                }else{
                    cout<<"No"<<endl;
                }
            }else if(mp[num[1]]==n/3 && mp[num[0]]==2*n/3){
                if(num[1]==0){
                    cout<<"Yes"<<endl;
                }else{
                    cout<<"No"<<endl;
                }
            }else{
                cout<<"No"<<endl;
            }
        }else if(num.size()==3){
            if(mp[num[0]]==n/3 && mp[num[1]]==n/3 && mp[num[2]]==n/3){
                if((num[0]^num[1])==num[2]){
                    cout<<"Yes"<<endl;
                }else{
                    cout<<"No"<<endl;
                }
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"No"<<endl;
        }
    }
    
    
    return 0;
}






Measured memory_bytes: 1024
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int x, y;
  readf("%s %s\n", &x, &y);
  int c;
  if (x <= 3) {
    c += 100_000 * (4 - x);
  }
  if (y <= 3) {
    c += 100_000 * (4 - y);
  }
  if (x == 1 && y == 1) {
    c += 400_000;
  }
  c.writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m); std::vector<int> a(n), b(m);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < m; i++) scanf("%d", &b[i]);
	
	const int MOD = 1e9 + 7;
	
	std::vector<i64> s(m + 1, 1); s[0] = 0;
	auto dp = make_v<i64>(n + 1, m + 1); dp[0][0] = 1;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(a[i] == b[j]) (dp[i + 1][j + 1] += s[j + 1]) %= MOD;
		}
		i64 tmp = 0;
		for(int j = 0; j <= m; j++) {
			(s[j] += tmp) %= MOD;
			(tmp += dp[i + 1][j]) %= MOD;
		}
	}
	
	i64 ans = 0;
	for(auto v: dp) for(auto w: v) (ans += w) %= MOD;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 31616
import bisect
from collections import deque
N = int(input())
A = [int(input()) for _ in range(N)]
c = deque()
c.append(A[0])
for i in range(1, N):
    j = bisect.bisect_right(c, A[i]-1)
    if j == 0:
        c.appendleft(A[i])
    else:
        c[j-1] = A[i]
print(len(c))


Measured memory_bytes: 53592
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vs S(N); REP(i, N) cin >> S[i];

    int ea = 0, sb = 0, ba = 0;
    int cnt = 0;
    REP(i,N) {
        int L = S[i].size();
        REP(j, L-1) {
            if (S[i][j] == 'A' && S[i][j + 1] == 'B') cnt++;
        }

        if (S[i][0]=='B' && S[i][L-1]=='A') {
            ba++;
        } else {
            if (S[i][L - 1] == 'A') ea++;
            if (S[i][0] == 'B') sb++;
        }
    }

    int ans = cnt;
    if (ba >= 2) {
        ans += ba - 1;
        ba = 1;
    }
    if (ba > 0) {
        if (ea >0 && sb>0) {
            ans+=2;
            ea--;
            sb--;
        } else if (ea>0) {
            ans++;
            ea--;
        } else if (sb>0) {
            ans++;
            sb--;
        }
    }
    ans += min(ea, sb);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define printArr(harry, tam) range(tam) cout << harry[i] << " \n"[i == tam -1];
#define range(n) for(int i = 0; i < n; i++)
#define forn(x, n) for(int x = 0; x < n; x++)
#define maxn "100000"
#define mod "1000000007"
#define md(x) ((((x) % mod) + mod) % mod)
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF INT_MAX
#define INFd 1e9

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;

//Trace dinamico
template<typename T>
void trace(T a) { cout << a << "\n"; }
template<typename T, typename... Args>
void trace(T a, Args... args) { cout << a << " "; trace(args...); }

//DP debug
int recNum = 0;
void prTabs() { range(recNum) cout << "    "; }
template<typename... Args>
void recInit(Args... args) { prTabs(); trace("rec(", args..., ")"); recNum++; }
template<typename T>
void recEnd(T a) { prTabs(); trace("->", a); recNum--;}
int n, k, a, b, c;
//vector<int> g[maxn]; 

int main(){
    sc("%d %d\n", &n, &k);
    pr("%d\n", (n-k+1));
	
 	return 0;
}


Measured memory_bytes: 256
import bisect
n=int(input())
ab=[[int(i) for i in input().split()] for j in range(n)]
cd=[[int(i) for i in input().split()] for j in range(n)]
ab.sort()
cd.sort()

ans=0

for c,d in cd:
    now_y=-1
    check=False
    for a,b in ab:
        if a>=c:
            break
        if b<d and b>now_y:
            now_id=bisect.bisect_left(ab,[a,b])
            now_y=b
            check=True

    if check:
        ans+=1
        ab.pop(now_id)
print(ans)
            
        


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

int main(void){
  int N;
  cin >> N;
	
	cout << 0 << endl;
	string current;
	cin >> current;

	if (current == "Vacant") {
		return 0;
	}
	
	int left=0, right=N, prev=0;;
	for(int i=0; i<20; i++) {
		int mid = (left+right)/2;
		
		// cout << "left " << left << " right " << right << " prev " << prev << " mid " << mid << endl;
		cout << mid << endl;
		string ans;
		cin >> ans;
		
		if (ans == "Vacant") return 0;
		else if (prev%2==mid%2) {
			if (prev < mid) {
				if (ans==current) left = mid;
				else right = mid;
			} else {
				if (ans==current) right = mid;
				else left = mid;
			}
		} else {
			if (prev < mid) {
				if (ans==current) right = mid;
				else left = mid;		
			} else {
				if (ans==current) left = mid;
				else right = mid;
			}

		}
		current = ans;
		prev = mid;
	}
  return 0;
}


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

int main() {
  double w,h,x,y;
  cin >>w >>h >>x >>y;
  double answer=(h*w)/2;
  
  if(x+x==w && y+y==h){
    cout <<answer <<" " <<1 <<endl;
  }
  else{
    cout <<answer <<" " <<0 <<endl;
  }
}





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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n, m, q;
    cin >> n >> m >> q;

    vector<vector<int>> ruiseki(n + 1, vector<int>(n + 1, 0));
    
    REP(i, m){
        int l, r;
        cin >> l >> r;
        ruiseki[l][r]++;
    }

    FOR(i, 1, n+1){
        FOR(j, 1, n+1){
            ruiseki[i][j] += ruiseki[i][j-1];
            ruiseki[i][j] += ruiseki[i-1][j];
            ruiseki[i][j] -= ruiseki[i-1][j-1];
        }
    }
    
    REP(i, q){
        int l, r;
        cin >> l >> r;
        cout << ruiseki[r][r] - ruiseki[r][l-1] - ruiseki[l-1][r] + ruiseki[l-1][l-1] << endl;
    }

}


Measured memory_bytes: 1920
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val A = listOfInt().sortedDescending()
    val total = A.sum()
    var good = A.subList(0, M).all { (it * 4 * M) >= total }
    val ans = if (good) "Yes" else "No"
    println(ans)
}


fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }
fun listOfLong(vararg offset: Long) = listOfString().map { java.lang.Long.parseLong(it) }.mapIndexed { index, long -> long + offset[index % offset.size] }
fun listOfDouble(delta: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + delta }
fun pairIntLong() = listOfLong().let { Pair(it[0].toInt(), it[1]) }
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun tripleIntLongLong() = listOfLong().let { Triple(it[0].toInt(), it[1], it[2]) }
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }
fun tripleIntIntLong(offset: Triple<Int, Int, Long> = Triple(0, 0, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1].toInt() + offset.second, it[2] + offset.third) }
fun tripleIntLongLong(offset: Triple<Int, Long, Long> = Triple(0, 0L, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1] + offset.second, it[2] + offset.third) }





Measured memory_bytes: 38000
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef long long ll;
void main(void)
{
  int n;
  scanf("%d",&n);
  int *a,*d;
  a=malloc(sizeof(int)*n);
  d=malloc(sizeof(int)*n);
  for(int i=0;i<n;i++) d[i]=0;
  ll ans=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(i+1+a[i]<=(n-1)) d[i+1+a[i]]++;
    if(i+1-a[i]>=2) ans+=d[i+1-a[i]];
  }
  printf("%lld",ans);
}

Measured memory_bytes: 3292
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll h, w;
string buf, a[10];

int main(){
	cin >> h >> w;
	for(ll i = 0; i < h; i++){
		cin >> buf;
		a[i] = buf;
	}
	bool flg = true;
	ll at = 0;
	for(ll i = 0; i < h; i++){
		for(ll j = 0; j < at; j++){if(a[i][j] == '#'){flg = false; break;}}
		if(a[i][at] != '#'){flg = false; break;}
		while(at != w-1 && a[i][at+1] == '#'){at++;}
		for(ll j = at+1; j < w; j++){if(a[i][j] == '#'){flg = false; break;}}
	}
	if(at != w-1){flg = false;}
	
	if(flg){cout << "Possible" << endl;}
	else{cout << "Impossible" << endl;}
	return 0;
}

Measured memory_bytes: 256
from collections import deque
def bfs(maze,sy,sx):
  queue=deque([[sy,sx]])
  visited=[[0]*w for _ in range(h)]
  visited[sy][sx]=1
  mx=0
  while queue:
    y,x=queue.popleft()
    for j,k in ([1,0],[-1,0],[0,1],[0,-1]):
      n_y,n_x=y+j,x+k
      if not (0<=n_y<h and 0<=n_x<w):
        continue
      if maze[n_y][n_x]=='.' and visited[n_y][n_x]==0:
        visited[n_y][n_x]=visited[y][x]+1
        mx=max(mx,visited[n_y][n_x])
        queue.append([n_y,n_x])
  return mx

h,w=map(int,input().split())
s=[input() for _ in range(h)]
ans=0
for sy in range(h):
  for sx in range(w):
    if s[sy][sx]=='#':
      continue
    ans=max(ans,bfs(s,sy,sx)-1)
print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	cout << n + n*n + n*n*n;


	
	

	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int d, n;
	cin >> d >> n;
	if (d == 0) {
		if (n < 100) cout << n << endl;
		else cout << 101 << endl;
		return 0;
	}
	int ans;
	if (d == 1) {
		ans = 100;
		if (n < 100) cout << n * ans << endl;
		else cout << 10100 << endl;
	}
	else {
		ans = 10000;
		if (n < 100) cout << n * ans << endl;
		else cout << 101 * ans << endl;
	}


	return 0;
}

Measured memory_bytes: 256
def a(l):
  if len(l) == 0:
    return 0
  elif len(l) == 1:
    return l[0]
  else:
    m = min(l)
    for j in range(len(l)):
      if m == l[j]:
        return l[j] + a(map(lambda x: x-m,l[0:j])) + a(map(lambda x: x-m,l[j+1:]))
        

i = int(input())
l = raw_input().split()
l = map(lambda x: int(x),l)

print a(l)

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

int main()
{
    int n,flag;
    cin>>n;
    bool con = true;
    for(int i = 1;i<=n;i++)
    {
        if(i*108/100 == n)
        {
            con = false;
            cout<<i<<"\n";
            break;
        }
    }
    if(con) 
        cout<<":(\n";
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main(void)
{
	int n;
	double siz;
	int i, j;
	int grade[6] = {0};
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%lf", &siz);
		if(siz >= 185.0){
			grade[5]++;
		}
		else if(siz >= 180.0){
			grade[4]++;
		}
		else if(siz >= 175.0){
			grade[3]++;
		}
		else if(siz >= 170.0){
			grade[2]++;
		}
		else if(siz >= 165.0){
			grade[1]++;
		}
		else {
			grade[0]++;
		}
	}
	
	for (i = 0; i < 6; i++){
		printf("%d:", i+1);
		
		for(j = 1; j <= grade[i]; j++){
			printf("*");
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int R = sc.nextInt();

        if(R < 1200){
            System.out.println("ABC");
        } else if(R < 2800){
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
        
        sc.close();
        
    }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int main()
{    priority_queue<unsigned long long int> q; 
	int  n,m;
    cin>>n>>m;
    unsigned long long int i, a[n];
    for(i=0;i<n;i++)
    { cin>>a[i]; q.push(a[i]);}
    unsigned long long int ans=0;
    while(m--)
    {
        long long int x=q.top();
    //cout<<x<<endl;
        q.pop();
        x=x/2;
        q.push(x);
        
    }
 
   while(!q.empty())
    {
        long long int x=q.top();
        //cout<<x<<endl;
        q.pop();
        ans+=x;}
    cout<<ans<<endl;
 
    
}


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

int main() {
	int N, Al = 0, Bo = 0;
	cin >> N;

	vector<int> v(N);
	for (int i = 0; i < N; i++) {

		cin >> v.at(i);
	}

	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	int Ans;

	int a = N % 2;

	for (int p = 0; p < N; p += 2) {

		Al += v.at(p);
	}

	for (int q = 1; q < N; q += 2) {

		Bo += v.at(q);
	}

	Ans = Al - Bo;

	cout << Ans << endl;

}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    long long ans = 0;
    for (int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            for (int c = 1; c <= K; ++c) {
                ans += __gcd(a, __gcd(b, c));
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;

    vector<bool> chr(26, true);
    for (int i = 0; i < static_cast<int>(s.size()); i++) {
        chr[s[i] - 'a'] = false;
    }

    bool flag = false;
    for (int i = 0; i < 26; i++) {
        if (chr[i]) {
            flag = true;
            cout << static_cast<char>(i + 'a') << endl;
            break;
        }
    }

    if (!flag) {
        cout << "None" << endl;
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
   int N, M;
   std::cin >> N >> M;
   std::vector<int> L(M), R(M);
   for(int i=0; i<M; ++i)
      std::cin >> L[i] >> R[i];
   std::sort(L.begin(),L.end());
   std::sort(R.begin(),R.end());
   std::cout << std::max(0, R[0] - L[M-1] + 1) << std::endl;
   return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
int arr[11];
int a[55];
int b[55];
int c[55];
int d[55];
int maxscore = 0;
void solve(){
	int score = 0;
	for(int i=0; i<q; i++){
		if(arr[b[i]]-arr[a[i]]==c[i]) score+=d[i];
	}
	maxscore = max(maxscore,score);
}
void dfs(int curr,int start){
	for(int i=start; i<=m; i++){
		arr[curr] = i;
		if(curr==n) solve();
		else dfs(curr+1,i);
	}
}
int main(){
	cin>>n>>m>>q;
	for(int i=0; i<q; i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	}
	dfs(1,1);
	cout<<maxscore;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
typedef pair<LL, LL> pll;
const int N = 200010;
int ch[N][2], ec[N];
vector<pll> t[N];
bool flag0;

void dfs(int x, LL k)
{
	if(!ch[x][0]) { t[x].push_back(mp(0, 0)); return; }
	dfs(ch[x][0], k); dfs(ch[x][1], k);
	Rep(w, 2){
		int l = ch[x][0], r = ch[x][1];
		int p = 0;
		if (t[l].size()){
			Rep0(i, t[l].size() - 1) {
			//	printf("%d ", t[l][i].first);
				bool flag = false;
				while (p < t[r].size() && -t[l][i].second + ec[l] + ec[r] + t[r][p].first <= k)
					p ++, flag = true;
				if (flag) t[x].push_back(mp(t[l][i].first + ec[l], t[r][p - 1].second - ec[r]));
			}
			//printf("\n");
		}
		swap(ch[x][0], ch[x][1]);
	}
	sort(t[x].begin(), t[x].end());
	if (!t[x].size()) flag0 = true;
}

int main()
{
	
	int n;
	scanf("%d", &n);
	for (int i = 2; i <= n; i ++) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (ch[x][0]) ch[x][1] = i;
		else ch[x][0] = i;
		ec[i] = y;
	}
	
	LL l = 0, r = 1e12;
	
	while(l != r) {
		LL mid = (l + r) >> 1;
		Rep(i, n) t[i].clear();
		flag0 = false;
		dfs(1, mid);
		if (flag0) l = mid + 1;
		else r = mid;
	}
	printf("%lld\n", l);
	
	return 0;
}


Measured memory_bytes: 28660
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

	ll N,M; cin >> N >> M;

	if (N == 1 && M == 1) {
		cout << 1 << endl;
		return 0;
	}

	if (N == 1 && M > 2) {
		cout << M - 2 << endl;
		return 0;
	}

	if (M == 1 && N > 2) {
		cout << N - 2 << endl;
		return 0;
	}

	ll a = max(0LL, N - 2LL);
	ll b = max(0LL, M - 2LL);

	cout << a * b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

const int MOD = 1000000007;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vector<int> vec(0);
  for (int i = 2; i * i <= m; ++i) {
    int temp = 0;
    while (m % i == 0) {
      ++temp;
      m /= i;
    }
    if (temp > 0) vec.push_back(temp);
  }
  if (m > 1) vec.push_back(1);

  vector<vector<long long> > pf(n+1, vector<long long>(31, 0));
  REP(i, n+1) pf[i][0] = 1;
  FOR(i, 1, n+1) FOR(j, 1, 31) pf[i][j] = (pf[i-1][j] + pf[i][j-1]) % MOD;

  long long ans = 1;
  for (auto aut : vec) {
    ans *= pf[n][aut];
    ans %= MOD;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 27648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N;
    cin >> N;
    int maxv = 0, seq = 0;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        if (a == b) {
            seq++;
        } else {
            maxv = max(maxv, seq);
            seq = 0;
        }
    }
    maxv = max(maxv, seq);
    // cout << maxv << endl;
    cout << (maxv >= 3 ? "Yes" : "No") << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define cs const 
#define fr first 
#define se second
#define ls (now<<1)
#define rs (now<<1|1)
#define mid ((l+r)>>1)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define low(i) (i&(-i))
#define par pair<int,int>
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define sep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
 
cs int G = 3;
cs int ff = 2e6 + 1;
cs int inf = 1e18 + 1;
cs int base = 2333;
cs int M = 1e9 + 7;

struct Node {int x, id;
}a[ff];
bool cmp(Node A, Node B) {return A.x < B.x;
} 
int n, b[ff], ans[ff], c[ff];
void init()
{
	cin >> n;
	rep(i, 1, n) scanf("%lld", &a[i].x), a[i].id = i;
	rep(i, 1, n) scanf("%lld", &b[i]);
	sort(a + 1, a + 1 + n, cmp);
	sort(b + 1, b + 1 + n);
	int tl = 1;
	rep(i, 1, n)
	{
		while(b[tl] == b[i] && tl < n) tl ++;
		if(a[i].x == b[i]) swap(b[tl], b[i]);
	}
	tl = n;
	sep(i, n, 1)
	{
		while(b[tl] == b[i] && tl > 1) tl --;
		if(a[i].x == b[i]) swap(b[tl], b[i]);
	}
	rep(i, 1, n)
	{
		if(a[i].x == b[i]) {cout << "No"; return;
		}
		c[a[i].id] = b[i];
	}
	cout <<"Yes\n";
	rep(i, 1, n) cout << c[i] <<" ";
}
signed main()
{
	int Ts = 1;
	while(Ts--)
		init();
}

Measured memory_bytes: 10024
n=int(input())
s=list(input())
l=s[:n]
r=s[n:][::-1]
d={}
e={}
for i in range(1<<n):
  s=t=u=v=''
  for j in range(n):
    if (i>>j)&1:
      s+=l[j]
      t+=r[j]
    else:
      u+=l[j]
      v+=r[j]
  d[(s,u)]=d.get((s,u),0)+1
  e[(t,v)]=e.get((t,v),0)+1
a=0
for i in d.keys():
  a+=d[i]*e.get(i,0)
print(a)

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int[] num=new int[a];
		for(int i=0;i<a;++i){
			num[i]=sc.nextInt();
		}
		int[] dp=new int[a];
		dp[0]=num[0];
		int length=1;
		for(int i=1;i<a;++i){
			if(dp[length-1]<num[i]){
				dp[length++]=num[i];
			} else {
				int len=Arrays.binarySearch(dp,0,length-1,num[i]);
				if(len<=0){
					if(len!=0){
						len=(-1*len)-1;
					}
					if(len==dp.length){
						if(length>1&&dp[length-2]==num[i]){
						} else {
							dp[length-1]=num[i];
						}
					} else {
						dp[len]=num[i];
					}
				}
			}
		}
		System.out.println(length);
	}
}

Measured memory_bytes: 70936
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("YES") if fl else print("NO")
import collections
import math
import itertools
import heapq as hq
def A_count():
    cnt = [0]*m
    for la in A:
        for a in la:
            if use[a]:
                cnt[a]+=1
                break
    heap = []
    for i in range(m):
        if use[i]:
            hq.heappush(heap,(-cnt[i],i))
    return heap

n,m = ma()
A = []
for i in range(n):
    A.append(list(map(lambda x:int(x)-1,input().split())))
ans = 10**9
use = [True]*m
#print(A)
for i in range(m):
    heap = A_count()
    mx,a = hq.heappop(heap)
    ans = min(ans,-mx)
    use[a]=False
print(ans)


Measured memory_bytes: 75892
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
double dp[3003][3003];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    std::vector<double> p;
    for (int i = 0; i < n; ++i)
    {
    	double x;
    	cin>>x;
    	p.pb(x);
    }
    dp[0][1]=p[0];
    dp[0][0]=1-p[0];
    for (int i = 1; i <n ; ++i)
    {
    	dp[i][0]=(1-p[i])*dp[i-1][0];
    	for (int j = 0; j <=n; ++j)
    	{
    		dp[i][j+1]=p[i]*dp[i-1][j]+(1-p[i])*dp[i-1][j+1];
    	}
    }
    double ans=0;
    for (int i = 0; i <=n; ++i)
    {
    	// cout<<dp[n-1][i]<<'\n';
    	if(i>n-i)
    	{
    		ans+=dp[n-1][i];
    	}
    }
    printf("%.10lf\n",ans );


}


Measured memory_bytes: 70656
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int x;

  for (int i = 0; i < 5; i++) {
    cin >> x;

    if (x == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3640
//Name : Rupa Dey
  //Date : 05 September 2020
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
#define ll long long
#define d double
#define ld long double
#define vi vector<int>
#define vul vector<ull>
#define vl vector<ll>
#define pb push_back
#define si set<int>
#define sl set<ll>
#define yes cout<<"YES\n"<<endl
#define no cout<<"NO\n"<<endl
#define ys cout<<"Yes\n"<<endl
#define n0 cout<<"No\n"<<endl
#define test cin>>t; while(t--)
#define for(i,a,n) for(i=a;i<n;i++)
#define mp make_pair
#define ft first
#define sc second
#define gp ' ';
#define MAX 9999999
#define MOD 1000000007
#define nd endl
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string a,b,c;
    cin>>a>>b;
    c = b+a;
    cout<<c<<nd;


}
//hare krishna...
//hey gobindo kripa koro......
//only gobindo exists..^..


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

int main(){
  set<int>s{1, 2, 3};

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

  s.erase(a);
  s.erase(b);

  for(int x : s){
    cout << x << endl;
  }
}


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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	int A, P;
	cin >> A >> P;
	A *= 3;
	cout << (A + P) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue() {
  int a;
  cin >> a;
  return a;
};
void inputVector(vector<int>* v) {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, int r, int c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}



int main(int argc, const char * argv[]) {
  int n;
  int t;
  int a;
  double teigen = 0.006;

  scanf("%d", &n);
  scanf("%d", &t);
  scanf("%d", &a);
  vector<int> h;
  vector<double> tmp;
  inputVector(&h);

  for (auto& val : h) {
    tmp.push_back(t - teigen*val);
  }
  double near = -1;
  double sa = 65536.0;
  for (size_t i = 0; i < tmp.size(); i++) {
    double tt = abs(a - tmp[i]);
    if (sa > tt) {
      sa = tt;
      near = i;
    }
  }
  cout << near + 1 << endl;
}

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

using namespace std;

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

    int n;
    int a[100];

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

    sort(begin(a), begin(a) + n);

    cout << a[n-1] - a[0] << "\n";

    return 0;
}

Measured memory_bytes: 256
##======================================python3
''' ===========================================
## null
##
##
=========================================== '''
import sys
from sys import stdin #read(), readline()
input = stdin.readline
import heapq #heappush(trgt, val) heappop(trgt) trgt[0] __lt__<
sys.setrecursionlimit(10**6)
INF = 1<<50

if __name__ == '__main__':
    n = int(input())
    
    chk = True;
    
    iip = list(map(int, input().split(' ')))
    for i in range(n):
        a = iip[i]
        if a&1 == 0:
            if a%3 == 0 or a%5 == 0:
                continue;
            else:
                chk = False;
                break;
        else:
            continue;
    
    if chk == True:
        print("APPROVED")
    else:
        print("DENIED")
    

Measured memory_bytes: 3064
l = list(input())
cnt = [0]
for i in range(len(l)-1):
  if (l[i] == 'R' and l[i+1] == 'L') or (l[i] == 'L' and l[i+1] == 'R'):
    cnt += [i,i+1]
cnt.append(len(l)-1)
ans = []
for i in range(len(cnt)//4):
  rr = cnt[4*i+1]-cnt[4*i]+1
  ll = cnt[4*i+3]-cnt[4*i+2]+1
  if (rr+ll)%2==0:
    ans += ([0]*(rr-1) + [(rr+ll)//2]*2 + [0]*(ll-1))
  else:
    if rr%2 == 1:
      ans += ([0]*(rr-1) + [(rr+ll+1)//2,(rr+ll-1)//2] + [0]*(ll-1))
    else:
      ans += ([0]*(rr-1) + [(rr+ll-1)//2,(rr+ll+1)//2] + [0]*(ll-1))
for i in range(len(ans)):
  if i != len(ans)-1:
    print(ans[i], end = ' ')
  else:
    print(ans[i])

Measured memory_bytes: 57232
P = int(input())
A = list(map(int, input().split()))

Q = [1 for _ in range(P)]

for i in range(P):
    if A[i]:
        for k in range(P):
            if i == k:
                continue
            Q[i] *= (i - k)
            Q[i] %= P
        Q[i] = pow(Q[i], P - 2, P)
    else:
        Q[i] = 0

F = [0 for _ in range(P + 1)]
F[0] = 1

for i in range(P):
    tmp = [0 for _ in range(P + 1)]
    for j in range(1, P + 1):
        tmp[j] += F[j - 1]
        tmp[j] %= P
    for j in range(P + 1):
        tmp[j] += F[j] * (-i)
        tmp[j] %= P
    F = tmp

res = [0 for _ in range(P)]

for i in range(P):
    G = [0 for _ in range(P)]
    G[P - 1] = F[P]
    res[P - 1] += Q[i] * G[P - 1]
    res[P - 1] %= P
    for j in range(P - 1)[::-1]:
        G[j] = F[j + 1] + i * G[j + 1]
        G[j] %= P
        res[j] += Q[i] * G[j]
        res[j] %= P

print(*res)

Measured memory_bytes: 80392