akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


const int INF=1e9;


const int MAX_N = 100010;
int dp[MAX_N];

int main(){
	int n;
	cin>>n;
	vi a(n, 0);
	rep(i, n) cin>>a[i];

	for(int i = 0; i <= n; i++){
		dp[i]=INF;
	}
	for(int i = 0; i < n; i++){
		*lower_bound(dp, dp+n,a[i]) = a[i];
	}

	cout<<lower_bound(dp, dp+ n, INF)-dp<<endl;
}

Measured memory_bytes: 1800
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

int main(){//Refering other editorials.
	int d,g;
	cin>>d>>g;
	
	vi p(d),c(d);
	REP(i,d) cin>>p[i]>>c[i];
	
	int ans=INF;
	REP(mask,(1<<d)){//p[i]点問題を全部選ぶ.
		int score=0,tmp=0,np=-1;//合計スコア, 問題数, 選ばなかった問題で最大点スコアの問題.
		REP(i,d){
			if((mask>>i)&1){
				score+=100*(i+1)*p[i]+c[i];
				tmp+=p[i];
			}else np=i;
		}
		
		if(score<g){//足りない場合.
			int hoge=100*(np+1);
			int need=(g-score+(hoge-1))/hoge;
			if(need>=p[np]) continue;//REP(mask).
			tmp+=need;
		}
		
		ans=min(ans,tmp);
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3620
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
//https://drken1215.hatenablog.com/entry/2019/05/12/004500
ll n;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    ll ans=0;
    for(ll i=1;i*i<=n;i++){
        if((n-i)%i==0&&(n-i)/i>i)ans+=(n-i)/i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<double> VD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#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 ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int f(int n)
{
	return 2 * (n / 3) + (n % 3 > 0);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	string s;
	cin >> s;
	
	int n = SZ(s);
	int ans  = 0;
	vector<int> x;
	int cnt = 1;
	FOR(i, 1, n)
		if (s[i] == s[i - 1])
			cnt++;
		else
		{
			x.PB(cnt);
			cnt = 1;
		}
	
	x.PB(cnt);
	
	FOR(i, 0, SZ(x) - 1)
	{
		if (x[i] % 3 == 2)
		{
			ans += f(x[i]) + 1;
			x[i + 1]--;
		}
		else
			ans += f(x[i]);
	}
	
	ans += f(x.back());			
	cout << ans << endl;		
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 1680
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

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

    vector<pair<int, int> > insert_arr(N);
    for(int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        insert_arr[i] = make_pair(a, b);
    }

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

    long second_sum = 0;
    int result = 0;
    for(int i = 0; i < N; i++){
if(second_sum + (long)insert_arr[i].second >= K){
             result = insert_arr[i].first;
             break;
         }
         second_sum += (long)insert_arr[i].second;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()

int main() {
  int N,Y;
  int d=-1;
  int e=-1;
  int f=-1;
 cin>>N>>Y;
  for(int a=0;a<=N;a++){
    for(int b=0;b<=N;b++){
      int c=N-a-b;
    if(Y==10000*a+5000*b+1000*c&&c>=0){
    d=a;
    e=b;
    f=c;
    }
   }
  }
  cout<<d<<" "<<e<<" "<<f<<endl;
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int W=in(),H=in(),N=in();
	int LX=0,LY=0,RX=W,RY=H;
	REP(i,N){
		int X=in(),Y=in(),A=in();
		if(A==1){
			LX=max(X,LX);
		}
		else if(A==2){
			RX=min(X,RX);
		}
		else if(A==3){
			LY=max(Y,LY);
		}
		else{
			RY=min(Y,RY);
		}
	}
	if(RX-LX<0 || RY-LY<0){
		out(0);
	}
	else out((RX-LX)*(RY-LY));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x,y,z;
  x=abs(b-a);
  y=abs(c-b);
  z=abs(c-a);
  bool te=false;
  if(x<=d && y<=d){
    te=true;
  }
  if(z<=d) te=true;
  
  if(te) cout << "Yes" << endl;
  else cout << "No" <<endl;
  

}

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

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

int a[200000];

int main() {
    int n;
    map<int, ll> mp;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        mp[a[i]]++;
    }
    ll sum = 0;
    for (auto t : mp) {
        sum += (t.second * (t.second - 1)) / 2;
    }
    for (int i = 0; i < n; ++i) {
        ll c = mp[a[i]];
        cout << sum - c * (c - 1) / 2 + (c - 1) * (c - 2) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 11776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N, Y; cin >> N >> Y;
  
  rep(i, N+1) rep(j, N+1) {
    int a = i, b = j, c = N-a-b;
    if(c < 0) continue;
    if(10000*a+5000*b+1000*c == Y) {
      cout << a << " " << b << " " << c << endl;
      return 0;
    }
  }
  cout << "-1 -1 -1" << endl;

}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

typedef long long lint;
typedef unsigned long long ulint;
#define MOD 1000000007

int main(){
    int N;
    lint A[50];
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    
    lint max=-1,cnt=0,cc=N+1;
    int mi;

    while(cc>N){
        cc=0;
        for(int i=0;i<N;i++){
            lint tmp=A[i]/N;
            cc+=tmp;
            cnt+=tmp;
            A[i]%=N;
            A[i]-=tmp;
        }
        for(int i=0;i<N;i++) A[i]+=cc;
    }
    
    for(int i=0;i<N;i++){
        if(max<A[i]){
            max=A[i];
            mi=i;
        }
    }
    while(max>=N){
        for(int i=0;i<N;i++) A[i]++;
        A[mi]-=N+1;
        max=-1;
        for(int i=0;i<N;i++){
            if(max<A[i]){
                max=A[i];
                mi=i;
            }
        }
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    ans = 0
    for i in range(N):
        if (i+1) % 2 == 1 and A[i] % 2 == 1:
            ans += 1
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9120
#include <cstdio>

using namespace std;

double n;
double a, b, c;

int main(int argc, char const *argv[]) {
  int x;
  scanf("%d", &x);

  n = (double)x;
  a = b = c = n / 3;
  if (x % 3 == 0) {
    printf("%.6f\n", a * b * c);
  } else if (x % 3 == 1) {
    printf("%.6f\n", (a + 0.000001) * b * c);
  } else {
    printf("%.6f\n", (a + 0.000001) * (b + 0.000001) * c);
  }

  return 0;
}


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



int main(){
  int n,d;
  cin >> n >> d;
  if( n%(2*d+1)==0 ){
    cout << n/(2*d+1) << endl;
  }else{
    cout << n/(2*d+1)+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std; 
 
void print_rectangle(int H, int W);

int main() 
{
	int H=1,W=1;
  
    while(H!=0&&W!=0){
      cin>>H>>W;
      print_rectangle(H,W);
    }
    return 0;
}

void print_rectangle(int H, int W){
  
  if(H==0&&W==0)
    return;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<"#";
    }
    cout<<endl;
  } 
  cout<<endl;
}




Measured memory_bytes: 3076
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<int, int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int, int>
#define mii         map<pii, int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
int mult(int a,int b, int p=MOD){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p=MOD){return (a + b + p)%p;}
int fpow(int n, int k, int p = MOD) {int r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

void solve() {
    ll x;
    cin>>x;
    rep(i, -1000, 1000) {
        rep(j, -1000, 1000) {
            if(pow(i, 5) - pow(j, 5) == x) {
                cout<<i<<" "<<j<<endl;
                return;
            }
        }
    }
}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 4088
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 2
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;

int main(void){
    ll n,m;
    cin>>n>>m;
    vl h(n),score(n,0);
    vl edges(n,0);
    rep(i,n) cin>>h[i];
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--,b--;
        if(h[a] < h[b]){
            score[b]++;
        }
        if(h[b] < h[a]){
            score[a]++;
        }
        edges[a]++;
        edges[b]++;
    }
    ll ans = 0;
    rep(i,n){
        if(edges[i] == score[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5556
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

// 動作環境 : C++14 AOJ
int main(){
    VL A;
    while(true){
        ll a;
        cin >> a;
        if(a == 0) break;
        A.pb(a);
    }

    rep(i, 0, A.size()) cout << "Case " << i + 1 << ": " << A[i] << endl;

    return 0;
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> mp(h);
  string s(w, '.');
  for (int i = 0; i < h; i++) {
    cin >> mp[i];
    if (mp[i] == s) {
      i--;
      h--;
    }
  }
  set<int> oks;
  for (int i = 0; i < w; i++) {
    bool ok = false;
    for (int j = 0; j < h; j++) if (mp[j][i] == '#') ok = true;
    if (ok) oks.insert(i);
  }
  for (int i = 0; i < h; i++) {
    for (auto &j : oks) cout << mp[i][j];
    cout << endl;
  }
  return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("serval");
            //3
            //例えば、serval → srvvl → svvv → vvv と変えればよいです
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("jackal");
            //2
            //例えば、jackal → aacaa → aaaa と変えればよいです
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("zzz");
            //0
            //最初からsが単一の文字のみからなっています
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("whbrjpjyhsrywlqjxdbrbaomnw");
            //8
            //8回の操作によって、sをrrrrrrrrrrrrrrrrrrへ変えることができます
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static string ms;
    static void Main()
    {
        List<string> InputList = GetInputList();
        ms = InputList[0];

        //最終文字の候補
        char[] KouhoArr = ms.Distinct().ToArray();

        int Answer = int.MaxValue;
        foreach (char EachKouho in KouhoArr) {
            int wkTesuu = DeriveTesuu(EachKouho);
            if (Answer > wkTesuu)
                Answer = wkTesuu;
        }
        Console.WriteLine(Answer);
    }

    //最後の文字を引数として、必要な手数を返す
    static int DeriveTesuu(char pKouho)
    {
        int WillReturn = 0;
        string CurrStr = ms;

        while (true) {
            if (CurrStr.Distinct().Count() == 1) {
                return WillReturn;
            }

            var sb = new System.Text.StringBuilder();
            for (int I = 0; I <= CurrStr.Length - 2; I++) {
                if (CurrStr[I] == pKouho || CurrStr[I + 1] == pKouho) {
                    sb.Append(pKouho);
                }
                else sb.Append(CurrStr[I]);
            }
            WillReturn++;
            CurrStr = sb.ToString();
        }
    }
}


Measured memory_bytes: 15316
n, k = map(int, input().split())
p = list(map(int, input().split()))
def expect(a):
  return 0.5 * (a+1)

total = 0
for i in range(k):
  total += expect(p[i])

r = [total]

for j in range(n-k):
  total = total-expect(p[j])+expect(p[j+k])
  r.append(total)

print(max(r))


Measured memory_bytes: 25604
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// 'A' = 0, 'G' = 1, 'C' = 2, 'X'(その他の文字) = 3 と対応させる

ll dp[110][4][4][4];  // dp[i+1][c1][c2][c3] : 長さiで末尾が「c1c2c3」で終わる条件を満たす文字列の個数

int main() {
    ll n;
    cin >> n;
    
    // ダメなのは 'XAGC', 'XGAC', 'XACG', 'AXGC', 'AGXC' の5パターン
    // つまり X012, X102, X021, 0X12, 01X2 (Xは0～3の数)が末尾にくるとダメ
    dp[0][3][3][3] = 1;
    rep(i, n) {
        rep(c1, 4) {
            rep(c2, 4) {
                rep(c3, 4) {
                    // i-1文字目時点で末尾がc1c2c3だとする
                    rep(x, 4) {  // i文字目にxを置くとする
                        if(c2 == 0 && c3 == 1 && x == 2) {
                            continue;
                        }
                        if(c2 == 1 && c3 == 0 && x == 2) {
                            continue;
                        }
                        if(c2 == 0 && c3 == 2 && x == 1) {
                            continue;
                        }
                        if(c1 == 0 && c3 == 1 && x == 2) {
                            continue;
                        }
                        if(c1 == 0 && c2 == 1 && x == 2) {
                            continue;
                        }
                        dp[i+1][c2][c3][x] += dp[i][c1][c2][c3];
                        dp[i+1][c2][c3][x] %= mod;
                    }
                }
            }
        }
    }

    ll ans = 0;
    rep(c1, 4) {
        rep(c2, 4) {
            rep(c3, 4) {
                ans += dp[n][c1][c2][c3];
                ans %= mod;
            }
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=2020,MAX=5005;
const ll INF=1LL<<62;
int sum[MAX][MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;cin>>N>>M;
    vector<int> zax(N),zay(N);
    vector<pair<int,int>> p(N);
    for(int i=0;i<N;i++){
        cin>>zax[i]>>zay[i];
        p[i]={zax[i],zay[i]};
    }
    
    sort(all(zax));
    sort(all(zay));
    
    map<int,int> Mx,My;
    
    for(int i=0;i<N;i++){
        int d=lower_bound(all(zax),p[i].first)-zax.begin(),d2=lower_bound(all(zay),p[i].second)-zay.begin();
        sum[d+1][d2+1]++;
    }
    
    for(int i=0;i<=N;i++){
        for(int j=1;j<=N;j++){
            sum[i][j]+=sum[i][j-1];
        }
    }
    
    for(int j=0;j<=N;j++){
        for(int i=1;i<=N;i++){
            sum[i][j]+=sum[i-1][j];
        }
    }
    
    while(M--){
        int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
        int dx1,dy1,dx2,dy2;
        dx1=lower_bound(all(zax),x1)-zax.begin();
        dx2=upper_bound(all(zax),x2)-zax.begin();
        
        dy1=lower_bound(all(zay),y1)-zay.begin();
        dy2=upper_bound(all(zay),y2)-zay.begin();
        
        cout<<sum[dx2][dy2]+sum[dx1][dy1]-sum[dx2][dy1]-sum[dx1][dy2]<<endl;
    }
}




Measured memory_bytes: 101072
import itertools

n = int(input())
l = []
for i in range(1, n + 1):
    l.append(i)

junList = list(itertools.permutations(l))

p = tuple([int(s) for s in input().split()])
q = tuple([int(t) for t in input().split()])

p_index = junList.index(p)
q_index = junList.index(q)

print(abs(p_index - q_index))


Measured memory_bytes: 8052
#include <stdio.h>

int main()
{
  int x, y, r;

  scanf("%d", &x);
  scanf("%d", &y);

  if (x >= y) {
    r = x % y;
    while (r != 0) {
      x = y;
      y = r;
      r = x % y;
    }
    printf("%d\n", y);
  } else {
    r = y % x;
    while (r != 0) {
      y = x;
      x = r;
      r = y % x;
    }
    printf("%d\n", x);
  }

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  queue<ll> x;
  rep(i, n){
    ll u;
    cin >> u;
    x.push(u);
  }
  ll ans = 0;
  ll current = x.front();
  x.pop();
  while(!x.empty()){
    ll next = x.front();
    x.pop();
    ans += min(a * (next - current),  b);
    current = next;
  }
  cout << ans <<endl;
  
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<cstring>
#define P pair<int,int>
#define MP make_pair
#define fi first
#define se second
#define N 200010
using namespace std;
int nxt[N<<2],to[N<<2],head[N],cnt;
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
int dfn[N],low[N],id[N],ids,totn;
stack<int>s;
void tarjan(int u)
{
	dfn[u]=low[u]=++ids;
	s.push(u);
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(!dfn[v])
		{
			int v=to[i];
			tarjan(v);
			low[u]=min(low[v],low[u]);
		}
		else if(!id[v]) low[u]=min(low[u],dfn[v]);
	}
	if(low[u]==dfn[u])
	{
		int iu=0;
		totn++;
		do
		{
			id[iu=s.top()]=totn;
			s.pop();
		}while(iu!=u);
	}
}
P num[N];
int tree[N],tids;
void build(int u,int l,int r)
{
	if(l==r){tree[u]=num[l].se;return;}
	int mid=(l+r)>>1;
	tree[u]=++tids;
	build(u<<1,l,mid);
	build(u<<1|1,mid+1,r);
	add(tree[u],tree[u<<1]);
	add(tree[u],tree[u<<1|1]);
}
void insert(int u,int l,int r,int L,int R,int id)
{
	if(L>r || R<l) return;
	if(L<=l && r<=R)
	{
		add(id,tree[u]);
		return ;
	}
	int mid=(l+r)>>1;
	if(L<=mid) insert(u<<1,l,mid,L,R,id);
	if(R>mid) insert(u<<1|1,mid+1,r,L,R,id);
}
int n;
int lim[2][N];
void clear()
{
	memset(head,0,sizeof(head));
	cnt=ids=totn=0;tids=2*n;
	memset(dfn,0,sizeof(dfn));
	memset(low,0,sizeof(low));
	memset(id,0,sizeof(id));
}
bool check(int x)
{
	clear();
	build(1,1,2*n);
	for(int i=1;i<=n;i++)
	{
		for(int o=0;o<=1;o++)
		{
			int l=lower_bound(num+1,num+2*n+1,MP(lim[o][i]-x+1,0))-num;
			int r=upper_bound(num+1,num+2*n+1,MP(lim[o][i]+x-1,2*n+1))-num-1;
			int u=lower_bound(num+1,num+2*n+1,MP(lim[o][i],(o^1)*n+i))-num;
			int ui=o*n+i;
            insert(1,1,2*n,l,u-1,ui);
            insert(1,1,2*n,u+1,r,ui);
		}
	}
	while(!s.empty()) s.pop();
	for(int i=1;i<=tids;i++)
	if(!dfn[i]) tarjan(i);
	for(int i=1;i<=n;i++)
	if(id[i]==id[i+n]) return false;
	return true;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&lim[0][i],&lim[1][i]);
	for(int i=1;i<=n;i++)
	{
		num[i*2-1]=MP(lim[0][i],i+n);
		num[i*2]=MP(lim[1][i],i);
	}
	sort(num+1,num+n*2+1);
	int l=0,r=1000000000;
	while(l<r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) l=mid+1;
		else r=mid-1;
	}
	if(!check(l)) l--;
	printf("%d\n",l);
	return 0;
}


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

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

using ll = long long;
using namespace std;

template <typename T>
auto
power (
    T   base,
    ll  exponent)
{
    decltype(base) result = 1;

    for (; exponent; exponent >>= 1) {
      if ( exponent & 1 ) {
        result *= base;
      }
      base *= base;
    }
    return result;
}

template <long long N>
class Modulo {
 public:
  using Type = decltype(N);
  Modulo (Type n = 0) : number_((N + n) % N) {}
  // unary operator
  auto operator - () const {
    return Modulo(-number_);
  }
  auto operator ~ () const {
    // Only if N is prime, and number_ and N are coprime
    return power(*this, N - 2);
  }
  // compound assign operator
  auto & operator += (const Modulo & m) {
    number_ = (number_ + m.number_) % N;
    return *this;
  }
  auto & operator -= (const Modulo & m) {
    return *this += -m;
  }
  auto & operator *= (const Modulo & m) {
    number_ = (number_ * m.number_) % N;
    return *this;
  }
  auto & operator /= (const Modulo & m) {
    return *this *= ~m;
  }
  // binary operator with type conversion
  friend auto operator + (Modulo lhs, const Modulo & rhs) {
    return lhs += rhs;
  }
  friend auto operator - (Modulo lhs, const Modulo & rhs) {
    return lhs -= rhs;
  }
  friend auto operator * (Modulo lhs, const Modulo & rhs) {
    return lhs *= rhs;
  }
  friend auto operator / (Modulo lhs, const Modulo & rhs) {
    return lhs /= rhs;
  }
  // stream operator
  friend auto & operator << (std::ostream & os, const Modulo & m) {
    return os << m.number_;
  }
  friend auto & operator >> (std::istream & is, Modulo & m) {
    // Note that number_ may be negative
    return is >> m.number_;
  }
 private:
  Type number_;
};

int
main ()
{
    ll n, a, b;
    cin >> n >> a >> b;

    using Number = Modulo<1'000'000'007ll>;

    // 2^n - c(n, 0) - c(n, a) - c(n, b)
    auto allsum = power(Number(2), n);

    auto nca = Number(1);
    rep(a, i) {
      nca *= (n - i);
    }
    rep(a, i) {
      nca /= (1 + i);
    }

    auto ncb = nca;
    rep(b - a, i) {
      nca *= ((n - a) - i);
    }
    rep(b - a, i) {
      nca /= ((1 + a) + i);
    }

    auto exclude = 1 + nca + ncb;
    cout << allsum - exclude << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <array>
#include <limits>
#include <queue>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>

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

using IntType = long long int;
const int MAX_SIZE = 100005;
const int X = 0;
const int Y = 1;
int sizes[2];
IntType costs[2][MAX_SIZE];

IntType greedy() {
	sort(costs[X], costs[X] + sizes[X]);
	sort(costs[Y], costs[Y] + sizes[Y]);
	int ixs[2] = { 0,0 };
	IntType cost = 0;
	while (ixs[X] < sizes[X] || ixs[Y] < sizes[Y]) {
		if (costs[X][ixs[X]] < costs[Y][ixs[Y]]) {
			cost += costs[X][ixs[X]] * (sizes[Y] + 1 - ixs[Y]);
			ixs[X]++;
		}
		else {
			cost += costs[Y][ixs[Y]] * (sizes[X] + 1 - ixs[X]);
			ixs[Y]++;
		}
	}
	return cost;
}
int main() {
	cin >> sizes[X] >> sizes[Y];

	fill(begin(costs[X]), end(costs[X]), 1000000000);
	fill(begin(costs[Y]), end(costs[Y]), 1000000000);
	REP(i, sizes[X]) {
		cin >> costs[X][i];
	}
	REP(j, sizes[Y]) {
		cin >> costs[Y][j];
	}
	IntType minCost = greedy();

	cout << minCost << endl;

	return 0;
}

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

int r,g,b,k;

int main()
{
	cin>>r>>g>>b>>k;

	while(g<=r) g*=2,k--;
	while(b<=g) b*=2,k--;
	if(k<0) cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int h,w,t[22][22],mn,sx,sy,turn;
void print(){
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<t[i][j];
    }
    cout<<endl;
  }
}
void dfs(int y,int x){
  if(turn==11){
  }else{
    turn++;
    if(t[y+1][x]==0||t[y+1][x]==3){
      for(int i=y+1;i<h;i++){
    if(t[i][x]==3&&turn<mn){
      mn=turn;
      //print();
      break;
    }
    if(t[i][x]==1){
      t[i][x]=0;
      dfs(i-1,x);
      t[i][x]=1;
      break;
    }
      }
    }
    if(t[y-1][x]==0||t[y-1][x]==3){
      for(int i=y-1;i>=0;i--){
    if(t[i][x]==3&&turn<mn){
      mn=turn;
      //print();
      break;
    }
    if(t[i][x]==1){
      t[i][x]=0;
      dfs(i+1,x);
      t[i][x]=1;
      break;
    }
      }
    }
    if(t[y][x+1]==0||t[y][x+1]==3){
      for(int i=x+1;i<w;i++){
    if(t[y][i]==3&&turn<mn){
      mn=turn;
      //print();
      break;
    }
    if(t[y][i]==1){
      t[y][i]=0;
      dfs(y,i-1);
      t[y][i]=1;
      break;
    }
      }
    }
    if(t[y][x-1]==0||t[y][x-1]==3){
      for(int i=x-1;i>=0;i--){
    if(t[y][i]==3&&turn<mn){
      mn=turn;
      //print();
      break;
    }
    if(t[y][i]==1){
      t[y][i]=0;
      dfs(y,i+1);
      t[y][i]=1;
      break;
    }
      }
    }
    turn--;
  }
   
}
void init(){
  mn=11;
}
int main(){
  while(1){
    cin>>w>>h;
    if(w==0&&h==0)break;
    init();
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
    cin>>t[i][j];
    if(t[i][j]==2){
      sx=j;
      sy=i;
      t[i][j]=0;
    }
      }
    }
    turn=0;
    dfs(sy,sx);
    if(mn==11)cout<<-1<<endl;
    else cout<<mn<<endl;
     
  }
  return 0;
}

Measured memory_bytes: 1164
import sys
from operator import itemgetter


def main():
    input = sys.stdin.readline
    N, T = map(int, input().strip().split())
    foods = sorted([list(map(int, input().strip().split())) for _ in range(N)], key=itemgetter(0))

    ans = 0
    dp = [[0] * (T+1) for _ in range(N+1)]
    for j, food in enumerate(foods):
        n_a, n_b = food
        for k in range(T+1):
            if k == T:
                dp[j+1][k] = max(dp[j][k], dp[j][k-1]+n_b)
            elif k < n_a:
                dp[j+1][k] = dp[j][k]
            else:
                dp[j+1][k] = max(dp[j][k], dp[j][k-n_a]+n_b)
        #print(dp[j+1])
    ans = dp[-1][-1]
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 113500
from sys import stdin
#N, M, C = (int(i) for i in input().split())
#B = [int(x) for x in stdin.readline().rstrip().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
S = input()
if S[2] == S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38256
//MD. HASNAIN ALI (UNSOLVED)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a<b? a:b)
#define SWAP(a,b) {       \
                    a=a+b;\
                    b=a-b;\
                    a=a-b;}
#define LL long long


int main()
{
    int a,b,c,k,s;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    if(a>=k) printf("%d\n",k);
    else
    {
        if(k-a<=b) printf("%d\n",a);
        else
        {
            s=a-(k-a-b);
            printf("%d\n",s);
        }
    }

    return 0;
}


Measured memory_bytes: 1728
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NPlusKPatterns #-}
module Main where

import Data.List (unfoldr)

import Control.Monad (replicateM, forM_)
import Data.Bool (bool)
import Data.Char (isSpace)
import Data.Function (on)
import qualified Data.Foldable as Foldable
import Data.List (unfoldr, foldl', sort, (\\), delete, nub)
import qualified Data.Map as Map
import qualified Data.Set as Set
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.ByteString.Char8 as C
import qualified Data.ByteString.Unsafe as B
import System.IO (hPutStr, hPutStrLn, stdin, stdout, withFile, IOMode(..))

type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

getInts :: IO [Int]
getInts = unfoldr parseInt <$> C.getLine

getIntVec :: Int -> IO (U.Vector Int)
getIntVec n = U.unfoldrN n parseInt <$> C.getLine

swap :: (a, b) -> (b, a)
swap (x, y) = (y, x)

lucky7 :: Int -> Bool
lucky7 n = 7 `elem` xs
  where xs = unfoldr f n
        f i | i == 0 = Nothing
            | otherwise = Just (swap (i `divMod` 10))

main :: IO ()
main = do
  n <- readLn :: IO Int
  if lucky7 n
    then putStrLn "Yes"
    else putStrLn "No"

Measured memory_bytes: 4080
N, T = map(int, input().split())
t = list(map(int, input().split()))
X = 0

for i in range(len(t)):
    if i == len(t) - 1:
        X += T
    else:
        if t[i+1] - t[i] < T:
            X += t[i+1] - t[i]
        else:
            X += T
print(X)

Measured memory_bytes: 26708
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vector<set<ll>> edge(n);
	vector<set<ll>> rev_edge(n);
	REP(i,m) {
		ll a,b;
		cin>>a>>b;
		a--;
		b--;
		edge[a].insert(b);
		rev_edge[b].insert(a);
	}
	bool d=false;
	queue<ll> q;
	REP(i,n) if((ll)rev_edge[i].size()==0) q.push(i);
	vector<ll> ret;
	while(!q.empty()) {
		if((ll)q.size()>1) d=true;
		ll p=q.front();
		q.pop();
		ret.pb(p);
		for(ll v : edge[p]) {
			rev_edge[v].erase(p);
			if((ll)rev_edge[v].size()==0) q.push(v);
		}
	}
	for(ll x : ret) cout<<x+1<<endl;
	if(d) cout<<1<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 13008
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(),x.end()
#define endl '\n'
#define INF 1e9+7
using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using pii=pair<int,int>;
using ppi=pair<pii,int>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

template<typename T>
void _print(vector<T> x) {for(auto e:x) cerr<<e<<",";}
template<typename T>
void _print(T x) {cerr<<x;}

void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
    _print(H);
    if(sizeof...(T)) cerr<<",";
    else cerr<<"\"]";
    dbg(T...);
}

#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]: [\"",dbg(__VA_ARGS__)

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    char x; cin>>x;
    if(x>='A' and x<='Z') cout<<"A"<<endl;
    else cout<<"a"<<endl;
}



Measured memory_bytes: 3620
//arif//c++//vjudge
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
int main()

{
int t,e,f,a,b,z,c,i,d;

cin>>t>>e;
int s[t];
int sum=0;
for( i=0;i<t;i++)
{
cin>>s[i];

}

for( i=0;i<e;i++)
{
sort(s,s+t);
sum=sum+s[i];

}

cout<<sum<<endl;
}

    

Measured memory_bytes: 3196
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define fi first
#define se second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define RFor(i,b,a) for(ll i = b;i>=a;i--)
#define sz size()
#define PQ priority_queue
#define len length()
#define mll map<ll,ll>
#define mpll map<pll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pair<ll,ll> >
#define mp(x,y)  make_pair(x,y)
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define ALL(v) v.begin(),v.end()
#define LAPAK ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

const ll MOD = 1e9 + 7;
const ll INF = 2e18;
const ll MAX = 405;


int main() {
    
    ll tc;
    tc = 1;
    //cin>>tc;
    while(tc--){
        ll n,d;
        cin>>n>>d;
        ll ans = 0;
        For(i,0,n){
            ld x,y;
            cin>>x>>y;
            ld di = sqrt(x*x + y*y);
            if(di<=d)ans++;
        }
        cout<<ans;
    }
    
    return 0;
}

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

#define ll       long long
#define LL       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(s)    (int) s.size()
#define all(s)   s.begin(), s.end()

template<typename T> inline void smin(T &a, T b) {
    a = a < b ? a : b;
}
template<typename T> inline void smax(T &a, T b) {
    a = a > b ? a : b;
}

template<typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n *= f;
}
template<typename T, typename TT> inline void Int(T &n, TT &m) {
    Int(n), Int(m);
}
template<typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) {
    Int(n), Int(m, l);
}

#define error(args...) { string _s = #args; replace(all(_s), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {
    cout << endl;
}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

const int mod = (int) 1e9 + 7;

int add(int a, int b) {
    a += b;
    if(a >= mod) a -= mod;
    return a;
}
int sub(int a, int b) {
    a -= b;
    if(a <= 0) a += mod;
    return a;
}
int mul(int a, int b) {
    return (ll) a * b % mod;
}

const int inf = (int) 1e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int   N = (int) 3e3 + 5;




int solve() {
    int n;
    Int(n);
    vector<double> dp(n + 2, 0);
    dp[0] = 1;
    for(int i = 1; i <= n; i++) {
        double p;
        scanf("%lf", &p);
        for(int j = n + 1; j >= 0; j--) {
            dp[j] = (j == 0 ? 0 : dp[j - 1]) * p + dp[j] * (1 - p);
        }
    }
    double ans = 0;
    for(int i = 1; i <= n; i++) {
        if(i >= n - i) ans += dp[i];
    }
    printf("%.10f\n", ans);
    return 0;
}

int main() {
    int test = 1, tc = 0;
    //Int(test);
    while(test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n;cin>>n;
	string s,t;cin>>s>>t;
	rep(i,n) cout<<s[i]<<t[i];
	cout<<endl;
}


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

//関数


//main関数
int main() {
    
    
    //入力
    long N;
    cin>>N;
    vector<long> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    
    //計算
    long ans=0;
    for(int i=0;i<N;i++){
        ans=__gcd(ans,A.at(i));
    }
    
 
    //出力
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, q;
    cin >> n >> q;
    vi a(n);
    rep(i, n) cin >> a[i];
    fenwick_tree<ll> f(n);
    rep(i, n) {
        f.add(i, a[i]);
    }
    rep(qi, q) {
        int t;
        cin >> t;
        if (t==0) {
            ll p, x;
            cin >> p >> x;
            f.add(p, x);
        }
        else {
            int l, r;
            cin >> l >> r;
            ll ans = f.sum(l, r);
            pr(ans);
        }
    }
    
    return 0;
}


Measured memory_bytes: 10108
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;
typedef  pair<LL,LL> P;


const LL INF=1<<30;
const LL MOD=1000000007;




int main(){
    set<int> a;
    int n;
    cin>>n;
    int d;
    for(int i=0;i<n;++i){
        cin>>d;
        a.insert(d);
    }
    cout<<a.size()<<endl;
}



Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    input.replace("2017", "2018")
}

#[test]
fn test() {
    let tests = vec![("2017/01/07", "2018/01/07")];
    for (i, (input, output)) in tests.into_iter().enumerate() {
        println!("test:{}", i);
        assert_eq!(run(input.to_string()), output.to_string());
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using SS = stringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + ( p ), ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

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

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );
	cout << setprecision( 12 ) << fixed;

	int N;
	scanf( "%d", &N );

	VI A( N );
	for_each( ALL( A ), []( int &a ){ scanf( "%d", &a ); } );

	VI B( A );
	sort( ALL( B ) );

	int cnt = 0;
	REP( i, N )
	{
		const int j = lower_bound( ALL( B ), A[i] ) - begin( B );
		cnt += i % 2 != j % 2;
	}

	printf( "%d\n", cnt / 2 );

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define modInv(a) binExp(a,mod-2)
#define mod 1000000007
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define os_find(k) find_by_order(k)
//#define os_order(k) order_of_key(k)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y);}
#define test int t;cin>>t;while(t--)

char mat[1001][1001];
int dp[1001][1001];

signed main()
{
    fast

    int h,w;
    cin>>h>>w;

    f1(i,1,h) f1(j,1,w) cin>>mat[i][j];

    f1(i,0,h) f1(j,0,w) dp[i][j] = 0;

    dp[1][1] = 1;
    f1(i,1,h) f1(j,1,w)
    {
        if(mat[i][j] == '#')
        {
            dp[i][j] = 0;
            continue;
        }

        dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;
        dp[i][j] = (dp[i][j] + dp[i-1][j])%mod;
    }

    cout<<dp[h][w];
}

Measured memory_bytes: 12348
s=input()
l_s=len(s)
b='0%db'%(l_s-1)
ans=0
for i in range(2**(l_s-1)):
  t=''
  for j in range(l_s-1):
    t+=s[j]+('+' if format(i,b)[j]=='1' else '')
  t+=s[l_s-1]
  ans+=eval(t)
print(ans)

Measured memory_bytes: 3064