akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define prev _prev
#define y0 _y0
#define kill _kill

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int alf = 26;
const int two = 2;
const ld eps = 1e-8;
const ll INF = (ll)(1e18 + 239);
const int BIG = (int)(2e9 + 239);
const ll MOD = 1e9 + 7;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
#ifdef ONPC
mt19937_64 rnd(239);
#else
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

//constants
const int M = (int)(2e5 + 239);
const int N = (int)(2e3 + 239);
const int L = 20;
const int T = (1 << 20) + 239;
const int B = 500;
const int X = 30;

pair<int, int> read()
{
    string s;
    cin >> s;
    ll a = 0;
    for (int i = 0; i < (int)s.size(); i++)
        if (s[i] != '.')
            a = 10LL * a + (s[i] - '0');
    int cnt = 0;
    for (int i = 0; i < (int)s.size(); i++)
        if (s[i] == '.')
            cnt = (int)s.size() - i - 1;
    int x = -cnt;
    int y = -cnt;
    while (a % 2LL == 0)
    {
        a /= 2LL;
        x++;
    }
    while (a % 5LL == 0)
    {
        a /= 5LL;
        y++;
    }
    return make_pair(x, y);
}

int32_t main()
{
#ifdef ONPC
    freopen("input", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    map<pair<int, int>, int> cnt;
    for (int i = 0; i < n; i++)
        cnt[read()]++;
    vector<tuple<int, int, int>> v;
    for (const auto& t : cnt)
        v.push_back(make_tuple(t.first.first, t.first.second, t.second));
    ll ans = 0;
    for (int i = 0; i < (int)v.size(); i++)
        for (int j = i + 1; j < (int)v.size(); j++)
            if (get<0>(v[i]) + get<0>(v[j]) >= 0 && get<1>(v[i]) + get<1>(v[j]) >= 0)
                ans += (ll)get<2>(v[i]) * (ll)get<2>(v[j]);
    for (int i = 0; i < (int)v.size(); i++)
        if (get<0>(v[i]) >= 0 && get<1>(v[i]) >= 0)
            ans += ((ll)get<2>(v[i]) * (ll)(get<2>(v[i]) - 1)) / 2LL;
    cout << ans << "\n";
    return 0;
}

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





int main(){
  
 
  int n;
  cin>>n;
  
  vector<int> data(n);
  
  for (int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    data.at(i)=tmp;
  }
  
  map<int,int> howmany;
  
  for (int x:data){
    if (howmany.count(x)){
      howmany.at(x)++;
    }
    
    else {
      howmany[x]=1;
    }
  }
  
  int answer=0;
  
  for (auto onepair:howmany){
    if (onepair.first>onepair.second){
      answer+=onepair.second;
    }
    
    else if (onepair.first<onepair.second){
      answer+=(onepair.second-onepair.first);
    }
  }
  
  cout<<answer<<endl;
  
    

  
    
    
    

      
  
    

  
  
    
  
  
  
}

Measured memory_bytes: 5120
N = int(input())
B = list(map(int, input().split()))
A = list(map(lambda x: min(x, 20), B))
#A = list(map(lambda x: min(int(x), 20), input().split()))


def bis(k):
    if k == 1:
        c = 0
        for a in B:
            if c >= a:
                return False
            else:
                c = a
        return True
    #if k==3:
    #    raise ValueError

    C = [0] * 20
    for a in A:
        a -= 1
        b = a-1
        while b >= 0:
            if C[b] == 0:
                C[b] = 1
                b -= 1
            else:
                break

        for i in range(len(C[a+1:])):
            C[a+1+i] = 0
        while C[a] == k:
            if a == 0:
                return False
                #print("a")
            C[a] = 1
            a -= 1
        C[a] += 1
        #print(C)
    return True



mi, ma = 0, (1<<19)
while ma-mi!=1:
    c = (mi + ma) >> 1
    if bis(c):
        ma = c
    else:
        mi = c
if ma==3 and max(B) >= 10**5:
    print(ma-1)
else:
    print(ma)


Measured memory_bytes: 97488
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int A, B, C;
	cin >> A >> B >> C;

	int res = 0;
	if(C > A - B) res = C - (A - B);

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);


  int n;
  cin >> n;
  vector<int> a(n);
  unordered_map<int, int> map;

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

  ll sum = 0;
  for (auto p : map) {
    ll num = p.second;
    sum += (ll)num * (num - 1) / 2;
  }

  for (int i = 0; i < n; ++i) {
    int ball = a[i];
    int num = map[ball];
    int new_num = num - 1;
    ll conv_num = (ll)num * (num - 1) / 2;
    ll conv_new_num = (ll)new_num * (new_num - 1) / 2;
    cout << sum + conv_new_num - conv_num << endl;
  }

  return 0;
}


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

double ceil(double);

int main() {
  int n; cin >> n;
  int x = 800 * n, y = n/15 * 200;
  cout << x-y << endl;
  return 0;

}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, S);
    IN(ll, Q);
    bool r = false;
    deque<char> q(ALL(S));
    REP(i, Q)
    {
        IN(ll, T);
        if (T == 1)
        {
            r = not r;
        }
        else
        {
            IN(ll, F);
            IN(char, C);
            if (F == 2 xor r)
            {
                q.push_back(C);
            }
            else
            {
                q.push_front(C);
            }
        }
    }
    string ans(ALL(q));
    if (r)
    {
        reverse(ALL(ans));
    }
    OUT(ans);
}

Measured memory_bytes: 1280
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

if sum(A) < sum(B):
    print(-1)
    exit()

isho = 0
tarinai = []
amari = []

for i in range(N):
    if A[i] == B[i]:
        isho += 1
    elif A[i] - B[i] > 0 :
        amari.append(A[i]-B[i])
    else:
        tarinai.append(B[i] - A[i])

if len(tarinai) == 0:
    print(0)
    exit()
elif len(amari) == 0:
    print(-1)
    exit()

amari = sorted(amari,reverse=True)

ind = 0
tmp = 0

sum_tari = sum(tarinai)

while sum_tari > tmp:
    tmp += amari[ind]
    ind += 1

ans = ind + len(tarinai)
print(ans)


Measured memory_bytes: 19188
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;

struct str{
	int a,b,c,d;
}s;
queue<str> Q;
bool v[505][505][505];

signed main()
{
	memset(v,0,sizeof(v));
	cin>>s.a>>s.b>>s.c;
	Q.push(s);
	while(!Q.empty())
	{
		str x=Q.front(); Q.pop();
		int a=x.a,b=x.b,c=x.c,d=x.d;
		if(a==b&&b==c) return cout<<d<<endl,0;
		if(v[a][b][c]) continue;
		v[a][b][c]=1;
		Q.push(str{a+1,b+1,c,d+1});
		Q.push(str{a+1,b,c+1,d+1});
		Q.push(str{a,b+1,c+1,d+1});
		Q.push(str{a+2,b,c,d+1});
		Q.push(str{a,b+2,c,d+1});
		Q.push(str{a,b,c+2,d+1});
	}
}

Measured memory_bytes: 126464
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

const int INF = 1e9;
const int MOD = 1000000007;

int main() {
  size_t N, K;
  cin >> N >> K;
  size_t d, a;
  set<size_t> S;
  for (size_t i = 0; i < N; ++i) {
    S.insert(i + 1);
  }
  for (size_t i = 0; i < K; ++i) {
    cin >> d;
    for (size_t j = 0; j < d; ++j) {
      cin >> a;
      S.erase(a);
    }
  }

  cout << S.size() << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
	int a,b,c,i,flag=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0)flag++;
	}
	printf("%d\n",flag);
	return 0;
}

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

class SegmentTree {
private:
    int n;
    vector<ll> node, lazy;
    ll INF = (1ll << 31) - 1;
public:
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2 * n - 1, 0);
        lazy.resize(2 * n - 1, 0);
    }

    void update(int i, int l, int r) {
        if (lazy[i] == 0) return;
        node[i] += lazy[i];
        if (r - l > 1) {
            lazy[2 * i + 1] += lazy[i] / 2;
            lazy[2 * i + 2] += lazy[i] / 2;
        }
        lazy[i] = 0;
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return;
        
        if (a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            update(k, l, r);
        } else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = node[2 * k + 1] + node[2 * k + 2];
        }
    }

    ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return 0;        
        if (a <= l && r <= b) return node[k];

        ll sum_l = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll sum_r = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return sum_l + sum_r;
    }

};


int main() {
    int N;
    ll D, A;
    cin >> N >> D >> A;
    vector<pair<ll, ll>> v(N);
    for (int i = 0; i < N; i++) {
        ll X, H;
        cin >> X >> H;
        v[i] = make_pair(X, H);
    }
    sort(v.begin(), v.end());
    SegmentTree st(N);
    int size = 1;
    while (N < size) size *= 2;
    ll f[N + 1][2]{};
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        int l = i - 1;
        int r = N;
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (v[m].first <= v[i].first + 2 * D) {
                l = m;
            } else {
                r = m;
            }
        }
        
        ll t = st.query(i, i + 1);
        if (v[i].second > t) {
            ll x = v[i].second - t;
            ll d = (x + A - 1) / A;
            ans += d;
            st.add(i, l + 1, d * A);
        }
    }
    cout << ans << "\n";
    return 0;
}


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

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	bool ans = true;

	for (int y : a)
	{
		if (y % 2 == 0)
		{
			if (y % 3 != 0 && y % 5 != 0)
			{
				ans = false;
				break;
			}
		}
		else
		{
			continue;
		}
	}

	if (ans)
	{
		cout << "APPROVED" << endl;
	}
	else
	{
		cout << "DENIED" << endl;
	}
}

Measured memory_bytes: 256
/*
[abc133] E - Virus Tree 2
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;
const int MOD = 1e9 + 7;

class gf {
public:
    int n;
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(const gf x) const { return gf((n + x.n) % MOD); }
    gf operator*(const gf x) const { return gf((1LL * n * x.n) % MOD); }
    gf& operator+=(const gf x) { return *this = (*this + x); }
    gf& operator*=(const gf x) { return *this = (*this * x); }
};

int N, K;
vector<int> g[MAX_N];

gf dfs(int v, int par = -1) {
    if ((int)g[v].size() >= K) {
        return 0;
    }

    gf ret = 1;
    int k = (par == -1 ? K - 1 : K - 2);
    for (int to : g[v]) {
        if (to == par) {
            continue;
        }
        ret *= k;
        k--;
        ret *= dfs(to, v);
    }
    return ret;
}

ll solve() { return (dfs(0) * K).n; }

int main() {
    cin >> N >> K;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 11520
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}

int main()
{
	speed;
	
	ll arr[3];
	cin>>arr[0]>>arr[1]>>arr[2];
	sort(arr,arr+3);
	cout<<arr[2]-arr[0];

	return 0;
}

Measured memory_bytes: 256
#import<iostream>
using namespace std;
#define m int64_t
#define r(s,i,n) for(m i=s;i<n;i++)
m w[555][555],p[1234];
main(){m n;cin>>n;m t=0,k=555;r(2,i,1e4){bool a=1;r(2,j,i){if(i%j==0)a=0;}if(a)p[t]=i,t++;}r(0,i,k)r(0,j,k)if(i%2==j%2)w[i][j]=p[(i+j)/2]*p[(i+k*3-j)/2];r(0,i,k)r(0,j,k)if(w[i][j]==0&&i>0&&i<554)w[i][j]=w[i-1][j]*w[i+1][j]+1;r(0,i,n)r(0,j,n)cout<<w[i+1][j+1]<<" ";}

Measured memory_bytes: 6032
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    string s;cin>>s;
    if(s=="RRR")cout<<3<<endl;
    else if(s=="RRS")cout<<2<<endl;
    else if(s=="SRR")cout<<2<<endl;
    else if(s=="SSS")cout<<0<<endl;
    else cout<<1<<endl;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3816
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX_V 10000
#define MAX_E 10000

int par[MAX_V];
int rank_[MAX_V];

void init(int V) {
	for (int i = 0; i < V; i++) {
		par[i] = i;
		rank_[i] = 0;
	}
}

int root(int x) {
	if (par[x] == x) {
		return x;
	}
	return par[x] = root(par[x]);
}

void unite(int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y) {
		return;
	}
	if (rank_[x] < rank_[y]) {
		par[x] = y;
	}
	else if (rank_[x]==rank_[y]){
		par[y] = x;
		rank_[x]++;

	}
	else if (rank_[y] < rank_[x]) {
		par[y] = x;
	}
}

bool same(int x, int y) {
	return root(x) == root(y);
}

struct edge {
	int from, to, cost;
	bool operator<(const edge& other)const {
		return cost < other.cost;
	}
};

using edges = vector<edge>;


int kruskal(edges&  es,int V) {
	
	
	sort(es.begin(), es.end());
	int E = es.size();
	init(V);
	int res = 0;
	for (int i = 0; i < E; i++) {
		if (!same(es[i].from, es[i].to)) {
			unite(es[i].from, es[i].to);
			res += es[i].cost;
		}
	}
	return res;
}

int main() {
	int V, E;
	cin >> V >> E;
	edges es(E);
	for(int i=0;i<E;i++){
		cin >> es[i].from >> es[i].to >> es[i].cost;
	    
	}
	cout << kruskal(es, V) << endl;
	return 0;
}







Measured memory_bytes: 4152
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A = list(map(int, readline().split()))
    if sum(A) >= 22:
        print("bust")
    else:
        print("win")


if __name__ == '__main__':
    main()


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

int main() {
  char a, b, c;
  int ans = 0;
  cin >> a >> b >> c;
  if(a == '1') {
    ans++;
  }
  if(b == '1') {
    ans++;
  }
  if(c == '1') {
    ans++;
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<lli, lli> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int n, a, b;
vector<mp> p;

struct UF {
  int nn;
  vector<int> d;
  UF(int nn):nn(nn), d(nn, -1) {}
  void init(int m){
	  nn = m; d.assign(nn, -1);
  }
  int root(int v) {
	if (d[v] < 0) return v;
	return d[v] = root(d[v]);
  }
  bool unite(int x, int y) {
	x = root(x); y = root(y);
	if (x == y) return false;
	if (size(x) < size(y)) swap(x,y);
	d[x] += d[y];
	d[y] = x;
	return true;
  }
  int size(int v) { return -d[root(v)];}
};

struct MD{
	lli d; lli dd; int num;
	bool operator < (const MD& a) const{			
		return a.d!=d?a.d>d:(a.dd!=dd?a.dd>dd:a.num>num);
	}
};
 
MD MDD(lli d, lli dd, int num){
	MD ret = {d, dd, num};
	return ret;
} 

vector<MD> md[2];
vector<lli> usmd[2];
UF u(0);

struct SEGTREE{
	vector<int> v; int size; int ii;
	SEGTREE(int nn){
		size = 0;
		while((1<<size) < nn) size++;
		v.assign(1<<(size+1), -1);
	}
	void set(int i){
		ii = i;
	}
	void q(int l, int r, int nn){
		if(l > r) return;
		l += 1<<size; r += 1<<size;
		while(true){
			if(v[l]!=-1) u.unite(v[l], nn);
			if(v[r]!=-1) u.unite(v[r], nn);
			v[l] = nn;
			v[r] = nn;
			if(r-l<=1) break;
			l = l/2 + l%2;
			r = r/2 - !(r%2);
		}
		return;
	}
	void un(void){
		rep(i, n){
			int l = i + (1<<size);
			while(l!=0){
				if(v[l]!=-1) u.unite(v[l], md[ii][i].num);
				l/=2;
			}
		}
		return;
	}
};

int main(void){
	scanf("%d%d%d", &n, &a, &b); a--; b--;
	u.init(n);
	rep(i, n){
		lli x, y; scanf("%lld%lld", &x, &y);
		p.push_back(mp(x, y));
		usmd[0].push_back(x+y);
		usmd[1].push_back(x-y);
		rep(j, 2) md[j].push_back(MDD(usmd[j][i], usmd[(j+1)%2][i], i));
	}
	rep(i, 2) sort(md[i].begin(), md[i].end());
	lli d = abs(p[a].fir - p[b].fir) + abs(p[a].sec - p[b].sec);
	
	vector<int> v(n, 0);
	
	rep(i, 2){
		SEGTREE st(n);
		st.set(i);
		rep(j, n){
			int p = md[i][j].num;
			int l = lower_bound(md[i].begin(),md[i].end(),MDD(usmd[i][p]+d,usmd[(i+1)%2][p]-d+i,0))-md[i].begin();
			int r = upper_bound(md[i].begin(),md[i].end(),MDD(usmd[i][p]+d,usmd[(i+1)%2][p]+d-i,IINF))-md[i].begin()-1;
			v[p] += r-l+1;
			st.q(l, r, p);
		}
		st.un();
	}
	
	lli ans = 0;
	int r = u.root(a);
	rep(i, n) if(r == u.root(i)) ans += v[i];
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 12424
import math
a, b, c = map(float, input().split())
c = math.radians(c)

s = (1 / 2) * a * b * math.sin(c)
l = a + b + (a ** 2 + b ** 2 - 2 * a * b * math.cos(c)) ** (1 / 2)
h = b * math.sin(c)

print(s)
print(l)
print(h)


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

int main()
{
    int n;
    cin>>n;
    double t;
    cin>>t;
    double a;
    cin>>a;

    double h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    int ans=0;
    double diff = INT_MAX;
    for(int i=0;i<n;i++)
    {
        double temp = t-h[i] *0.006;
        double temp2 = abs( a- temp);

        if( temp2 < diff )
        {
            ans = i;
            diff= temp2;
        }
    }
    cout<<ans+1;
}

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

using namespace std;

int main() {
	int A,B,C;
	cin >> A >> B >> C;
	
	if ((A == B && A != C) || (A == C && A != B) || (B == C && B != A)) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	cout << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : d.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;

int main() {
	int n,q;cin>>n>>q;
	vector<int> a(n),b(n);
	vector<vector<int>> e(n);
	for(int i=0;i<n-1;i++){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
		e[a[i]].push_back(b[i]);
		e[b[i]].push_back(a[i]);
	}
	vector<int> c(n,0);
	for(int i=0;i<q;i++){
		int v,x;cin>>v>>x;
		v--;
		c[v]+=x;
	}
	vector<int> ans(n,-1);
	ans[0]=c[0];
	vector<int> vs;
	vs.push_back(0);
	while(vs.size()){
		int v=vs.back();
		vs.pop_back();
		for(int i=0;i<e[v].size();i++){
			int next=e[v][i];
			if(ans[next]!=-1)continue;
			ans[next]=ans[v]+c[next];
			vs.push_back(next);
		}
	}
	for(int i=0;i<n;i++){
		cout<<ans[i]<<' ';
	}cout<<endl;

	return 0;
}

Measured memory_bytes: 17908
H,W=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))

G=[[0 for _ in range(W)] for _ in range(H)]

a=0
ii=0
for i in range(H):
  for j in range(W):
    if a==0:
      a=A[ii]
      ii+=1
    G[i][j]=str(ii)
    a-=1

for i in range(H):
  if i%2==0:
    print(" ".join(G[i]))
  else:
    print(" ".join(G[i][::-1]))

Measured memory_bytes: 3700
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int A,B;
    cin >> A>>B;
    if (A * B % 2 == 0)
        cout << "No";
    else
        cout << "Yes";
}

Measured memory_bytes: 256
gets
ary = []
ARGF.each do |line|
  a = line.split.map(&:to_i)
  b = a.inject(:+)

  puts "#{a.join("\s")} #{b}"
  ary << a.push(b)
end
puts ary.transpose.collect{|row| row.inject(:+)}.join("\s")

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

void println(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i];
		if (i + 1 < n) cout << " ";
	}
	cout << endl;
}

void iterationSort(int a[], int n) {
	println(a, n);
	for (int i = 1; i < n; i++) {
		int key = a[i];
		/*insert a[i] into the sorted sequence a[0]..a[i-1]*/
		int j = i - 1;
		while (j >= 0 && a[j] > key) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = key;
		println(a, n);
	}
}

int main() {
	int n;
	int a[100];
	
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	iterationSort(a, n);
	return 0;
}

Measured memory_bytes: 3080
import java.util.Scanner;
import java.util.ArrayList;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer N = Integer.parseInt(scan.next());
        Integer D = Integer.parseInt(scan.next());

        Integer array[][] = new Integer[N][D];
        double distance[] = new double[N];
        ArrayList<Double> d = new ArrayList<Double>();

        for(int i=0;i<N;i++){
            for(int j=0;j<D;j++){
                array[i][j] = Integer.parseInt(scan.next());
            }
        }
    
        for(int i=0;i<N;i++){

            for(int k=i+1;k<N;k++){

                int sum = 0;
                for(int j=0;j<D;j++){
                    if(i != N-1){
                        sum += Math.abs((array[i][j] - array[k][j]) * (array[i][j] - array[k][j]));
                    }else{
                        sum += Math.abs(  (array[i][j] - array[0][j] ) * (array[i][j] - array[0][j] )  );
                    }
                }
                d.add(Math.sqrt(sum));

            }
        }

        int count = 0;
        for(int i=0;i<d.size();i++){
            double dd = d.get(i);
            if(d.get(i) == (int)dd){
                count++;
            }
        }

        System.out.println(count);
    }
    
    static int factorial(int n){
        if(n == 0){
          return 1;
        }
        return n * factorial(n-1);
      }
}

Measured memory_bytes: 21972
import java.io.*;

public class Main{

    public static void main(String[]args)throws IOException{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
                  
        while((str = br.readLine()) != null){
            int num = Integer.parseInt(str);
            int count = 0;

            for(int i=0; i<=9; i++){
                for(int k=0; k<=9; k++){
                    for(int w=0; w<=9; w++){
                        for(int j=0; j<=9; j++){
                            if((i+k+w+j)==num)count++;
                        }
                    }
                }
            }
            
            System.out.println(count);          
        }
    }   
}

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

using namespace std;

int main(){
	
	long n, o;
	o = 0;
	do{
		cin >> n;
	}
	while(n < 1 || n > 1000000);

	for (int i = 1; i < n+1; i++){
		if(i % 3 != 0 && i %5 != 0)	
			o+=i;
	}
	cout << o << "\n";
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
using ll = long long;
using P = pair<ll, ll>;
vector<int> to[100005];
int cost[100005];
double PI = acos(-1);
int x[10];
int y[10];

double dist(ll i, ll j) {
    int xx = (x[i]-x[j])*(x[i]-x[j]);
    int yy = (y[i]-y[j])*(y[i]-y[j]);
    return sqrt(xx+yy);
}

signed main(){
    double a, b, x;
    cin >> a >> b >> x;

    double s = x/a;
    double rad;
    double lim = b*a/2.0;
    if(lim>s) {
        double h = 2*s/b;
        rad = atan2(b, h);
    } else {
        double h = 2*(a*b-s)/a;
        rad = atan2(h,a);
    }

    double ans = rad/(2.0*PI)*360;

    cout << setprecision(10)<< ans << endl;

    return 0;
}



Measured memory_bytes: 2688
from collections import defaultdict
from copy import deepcopy

from bisect import bisect_left as bl

N,M=map(int,input().split())
n=N
A=list(map(int,input().split()))
dic={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
dict=defaultdict(int)
list=[]
L=[]
for key in range(9,0,-1):
    if key in A:
        if dic[key] in dict.values():
            continue
        dict[key]=dic[key]
        list.append([key,dic[key]])
        L.append(key)
list.sort(key=lambda x:x[0],reverse=True)
cost=[]
for i in list:
    cost.append(i[1])
num=len(dict.keys())

dp=[[-1 for i in range(num+1)] for j in range(N+1)]
dp[0]=[0]*(num+1)
#dp[i] N=iでの最大値
Non=[-1]*(num+1)
for i in range(N):
    ini=[]
    for j in range(num):
        if i+1-cost[j]>=0 and dp[i+1-cost[j]]!=Non:
            a=dp[i+1-cost[j]][:]
            a[j+1]+=1
            a[0]+=1
            ini.append(a)
    if ini:
        dp[i+1]=max(ini)
s=""


for l in L:
    for i in range(num):
        key,cost=list[i]
        if l==key:
            s+=str(key)*dp[N][i+1]

print(s)


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

#define ll long long

inline ll read() {
    ll x = 0, f = 1; char ch = getchar();
    for(; ch < '0' || ch>'9'; ch = getchar())
        if(ch == '-') f = -f;
    for(; ch >= '0' && ch <= '9'; ch = getchar())
        x = x * 10 + ch - '0';
    return x * f;
}

inline void chkmin( int &a, int b ) { if(a > b) a = b; }

inline void chkmax( int &a, int b ) { if(a < b) a = b; }

#define _ read()

#define ln endl

map<string, int> a;
char s[105];

int main()
{
	a["SUN"] = 7;
	a["MON"] = 6;
	a["TUE"] = 5;
	a["WED"] = 4;
	a["THU"] = 3;
	a["FRI"] = 2;
	a["SAT"] = 1;
	scanf("%s", s);
	cout << a[s] << ln;
}

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

vector<string> split(string s){
	vector<string> ret;
	string t="";
	for(int i=0;i<s.size();i++){
		if(s[i]=='"'){
			ret.push_back(t);	
			t="";
		}
		else t+=s[i];
	}
	ret.push_back(t);
	return ret;
}

int main (){
    string s,t;
	while(cin>>s && s!="."){
		cin>>t;
		if(s==t){
			cout<<"IDENTICAL"<<endl;
			continue;
		}
		vector<string> spl_s=split(s);
		vector<string> spl_t=split(t);
		if(spl_s.size()!=spl_t.size()){
			cout<<"DIFFERENT"<<endl;
			continue;
		}
		int count=0;
		for(int i=0;i<min(spl_s.size(),spl_t.size());i++){
			if(i%2==1){ //文字列定数
				if(spl_s[i]!=spl_t[i])count++;
			}else { //文字列定数でない
				if(spl_s[i]!=spl_t[i])count+=2;
			}
		}
		if(count==1)cout<<"CLOSE"<<endl;
		else cout<<"DIFFERENT"<<endl;
	}
}



Measured memory_bytes: 3184
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);
    private static long MOD = 1000_000_007;

    public static void main(String[] args) {
	int H = Integer.parseInt(scan.next());
	int W = Integer.parseInt(scan.next());
	int A = Integer.parseInt(scan.next());
	int B = Integer.parseInt(scan.next());

	long ans = 0;
	long comb1 = comb(H-A-1+B-1, B-1);
	long comb2 = comb(A-1+W-B, W-B);
	for (int i = 1; i <= W-B; i++) {
	    comb1 = comb1 * (H-A-1+B-1+i) % MOD * inverse(B-1+i) % MOD;
	    comb2 = comb2 * (W-B-i+1) % MOD * inverse(A-1+W-B-i+1) % MOD;
	    ans = (ans + comb1 * comb2 % MOD) % MOD;
	}

	System.out.println(ans);
	scan.close();
    }

    private static long pow(long x, long y) {
	if(y == 0) return 1;
	
	long x2 = pow(x, y/2);
	long ans = x2 * x2 % MOD;
	if(y%2 != 0) ans = ans * x % MOD;
	return ans;
    }

    private static long fact(long n) {
	if(n == 0) return 1;
	
	long ans = 1;
	for (int i = 2; i <= n; i++) {
	    ans = ans * i % MOD;
	}
	return ans;
    }

    private static long inverse(long x) {
	return pow(x, MOD-2);
    }


    private static long infact(long n) {
	return inverse(fact(n));
    }

    private static long comb(long n, long m) {
	return fact(n) * infact(m) % MOD * infact(n-m) % MOD;
    }
}


Measured memory_bytes: 22996
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
    int n, a;
    int maxa, mina;
    long long sum;
    maxa = -1000001;
    mina = 1000001;
    sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(maxa < a){
            maxa = a;
        }
        if(mina > a){
            mina = a;
        }
        sum += a;
    }
    printf("%d %d %lld\n", mina, maxa, sum);
    return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;
using namespace std;

int main() {
	ll K, N;
	cin >> K >> N;
	vector<ll> A(N);
	for (ll i = 0; i < N; i++) {
		cin >> A.at(i);
	}

	ll lmax = A.at(0) + (K - A.at(N - 1));
	for (ll i = 0; i < N - 1; i++) {
		if (A.at(i + 1) - A.at(i) > lmax) lmax = A.at(i + 1) - A.at(i);
	}

	ll ans = K - lmax;
	cout << ans << endl;

	return 0;
}

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

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator &itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator &begin() {return i;}
  Iterator &end() {return n;}
};

template<class T> T at(vector<T> v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> x1(n), y1(n), z1(n), x2(n), y2(n), z2(n);
  for (int i : range(n)) cin >> x1[i] >> y1[i] >> z1[i] >> x2[i] >> y2[i] >> z2[i];
  long long res = 0;
  vector<long long> x = x1, y = y1, z = z1;
  copy(x2.begin(), x2.end(), back_inserter(x));
  copy(y2.begin(), y2.end(), back_inserter(y));
  copy(z2.begin(), z2.end(), back_inserter(z));
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  sort(z.begin(), z.end());
  for (int xi : range(x.size() - 1)) {
    for (int yi : range(y.size() - 1)) {
      for (int zi : range(z.size() - 1)) {
        int xx = x[xi], yy = y[yi], zz = z[zi], c = 0;
        for (int i : range(n)) {
          if (xx < x1[i] || x2[i] <= xx) continue;
          if (yy < y1[i] || y2[i] <= yy) continue;
          if (zz < z1[i] || z2[i] <= zz) continue;
          ++c;
        }
        if (c >= k) res += (x[xi + 1] - xx) * (y[yi + 1] - yy) * (z[zi + 1] - zz);
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 1228
n = int(input())
a = [int(i) for i in input().split()]
a_max = max(a)
a_min = min(a)

abs_max = a_min if abs(a_min) > abs(a_max) else a_max
abs_max_index = a.index(abs_max)


print(2*n-1)

total = 0

for i in range(n):

    print(abs_max_index+1, i+1)
    a[i] += abs_max

my_range, next_index_diff = (
    list(range(n-1)), 1) if abs_max > 0 else (list(range(n-1, 0, -1)), -1)


while my_range:

    index = my_range.pop(0)

    print(index+1, index+1+next_index_diff)
    a[index+next_index_diff] += a[index]


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define P 998244353
#define MAX_N 1000000
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
lnt fac[MAX_N+5], inv[MAX_N+5], ans;
void init(int n) {
	fac[0] = inv[0] = inv[1] = 1;
	for (int i = 1; i <= n; i++) fac[i] = fac[i-1]*i%P;
	for (int i = 2; i <= n; i++) inv[i] = (P-P/i*inv[P%i]%P)%P;
	for (int i = 2; i <= n; i++) inv[i] = inv[i-1]*inv[i]%P;
}
lnt C(int n, int m) {return n >= m ? fac[n]*inv[m]%P*inv[n-m]%P : 0;}
lnt calc(int X, int Y, int T) {
	if (Y-X >= T || T <= 0) return 0;
	return (C(X+Y, X)-C(X+Y, X+T)+P)%P;
}
int main() {
	int n, m; read(n), read(m), init(m<<1);
	for (int R = m, B = 0; R >= B; R--, B++)
		if (R ^ B) ans = (ans+calc(R, B, R-n+1))%P;
		else ans = (ans+calc(R, B-1, B-n+1))%P;
	return printf("%lld\n", ans), 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    int x,d;
    cin >> x >> d;
    d = d * 2 + 1;
//    cout << x << " " << d<< endl;
    int ans = (int)ceil(float(x) / float(d));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;


int main() {
  while (true){
    ll a;
    cin >> a;
    if (a==0) return 0;
    ll b=a;
    ll ans=1;
    for (ll i=2;i<inf;i++){
      if (i*i>a) break;
      ll aa=1,m=1;
      while (true){
        if (b%i==0) aa+=pow(i,m);
        else break;
        b=b/i;
        m++; 
      }
      ans=ans*aa;
    }
    if (b!=1) ans=ans*(1+b);
    //cout << "88888" << " " << ans << endl;
    if (ans-a==a) cout << "perfect number" << endl;
    if (ans-a>a) cout << "abundant number" << endl;
    if (ans-a<a) cout << "deficient number" << endl;
  }
}



Measured memory_bytes: 3128
N=int(input())
S=input()
l,r=[0]*N,[0]*N
for i in range(N-1):
    l[i+1]+=l[i]+(S[i]=='W')
for i in range(N-1,0,-1):
    r[i-1]+=r[i]+(S[i]=='E')
ans=3*10**5
for i in range(N):
    ans=min(ans,l[i]+r[i])
print(ans)


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

using namespace std;

int main(){
    string dance; cin >> dance;
    bool flag = true;
    for(int i=0; i< (int)dance.size() ; i++){
        if(i%2==1 && dance.at(i)=='R') flag = false; 
        if(i%2!=1 && dance.at(i)=='L') flag = false;
    }
    string a = flag?"Yes":"No";
    cout << a << endl;
        
     
}



Measured memory_bytes: 256
N = int(input())
j = 0
z = 0
r = 'No'
for i in range(N):
    n, m = map(int, input().split())
    if n == m:
        j += 1
    else:
        j = 0
    if j == 3:
        r = 'Yes'
        break
print(r)

Measured memory_bytes: 9096
/*input
5
0.42 0.01 0.42 0.99 0.42
*/
 
 
#include <bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define INTMAX  2147483647
#define INTMIN  -2147483648
#define LLMAX 9223372036854775807
#define LLMIN -9223372036854775808
#define MOD 1000000007
typedef map<long long int, long long int> mpi;
typedef set<long long int> seti;
typedef multiset<long long int> mseti;
typedef priority_queue<long long int> pq;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define PI 3.1415926535
#define dbg(x) cerr << "\n" << (#x) << " = " << (x) << endl ;
//#define cerr if(false)cerr

// cout<<fixed<<setprecision(10)<<(v1+v2+v3)<<endl;
  
struct node{
    ll val;
};
struct Interval {int start, end;};
bool compare(struct node n1, struct node n2) {
    return (n1.val < n2.val);
}




long double dp[3000][3000];

int main(){
	ll n; cin>>n;
	vector <long double> p(n,0);
	rep(i,n)cin>>p[i];
	dp[0][1] = 1-p[0];
	dp[1][1] = p[0];
	for(int j=2;j<=n;j++){
		for(int i=0;i<=j;i++){
			if(i==j)
				dp[i][j] = dp[i-1][j-1]*p[j-1];
			else if(i==0)
				dp[i][j] = dp[i][j-1]*(1-p[j-1]);
			else
				dp[i][j] = dp[i-1][j-1]*p[j-1] + dp[i][j-1]*(1-p[j-1]);
		}
	}
	// for(int j=1;j<=n;j++){
	// 	for(int i=0;i<=j;i++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	long double ans = 0.0;
	for(int i=(n/2+ 1);i<=n;i++){
		ans+=dp[i][n];
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;	
}















 

Measured memory_bytes: 85536
#include<iostream>
#include<sstream>
#include<iomanip>
#include<bitset>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  ou(min(min(a+b,a+c),b+c));
}

Measured memory_bytes: 256
array=[]
ary=[]
STDIN.each_line {|line|
array.push(line.chomp)
}
array
array.each{|v|
ary.push(v.split(" "))
}
ary.each{|v| v.map!(&:to_i)}
nn = ary[0][0]
tt = ary[0][1]
ary.shift
ary.delete_if{|a|a[1] > tt}
if ary.empty?
  puts 'TLE'
else
  ary.sort!{|a,b|a[0]<=>b[0]}
  puts ary[0][0]
end


Measured memory_bytes: 1788
#dfs実装したい
S=input()
#s[0]は左サイド
show=""
def dfs(op):
    if len(op)==3:#+++とか揃ったらそれで計算する
        count=int(S[0])
        for i in range(3):
            if op[i]=='+':
                count+=int(S[i+1])#b c d
            elif op[i]=='-':
                count-=int(S[i+1])
        if count==7:
            show=S[0]
            for i in range(3):
                show+=op[i]+S[i+1]
            show+="=7"
            return show
        else:
            return ""
    s1=dfs(op+'+')
    s2=dfs(op+'-')
    if len(s1)>len(s2):
        return s1#""とshowの長い方のshowを返すよう選ぶ
    else:
        return s2

print(dfs(""))

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

int M, D, ans=0;

int main()
{
    cin>>M>>D;
    for(int i = 1; i<=D; i++){
        int x = i %10;
        int y = i /10;
        if(x <= 1 || y <= 1) continue;
        if(x*y<=M) ans++;
    }
    cout<<ans<<endl;
}


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

int main() {
    string str;
    cin >> str;
    int len = str.length();
    if(str[len-1] == '3') cout << "bon" << endl;
    else if(str[len-1] == '0' || str[len-1] == '1' || str[len-1] == '6' || str[len-1] == '8') cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N, P;
  cin >> N >> P;
  string S;
  cin >> S;
  if(P == 2 || P == 5) {
    i64 ans = 0;
    for(i64 i = N; i --> 0;) {
      if((S[i] - '0') % P == 0) {
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }
  vector<i64> dp(N + 1, 0);
  i64 now = 1;
  for(i64 i = N; i --> 0; ) {
    dp[i] = (dp[i + 1] + (S[i] - '0') * now) % P;
    now = (now * 10) % P;
  }
  map<i64, i64> mp;
  mp[0] = 1;
  i64 ans = 0;
  for(i64 i = N; i --> 0; ){
    ans += mp[dp[i]];
    mp[dp[i]]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2564
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val A = readLine().split(" ").map(_.toInt)

  def solve() = {
    val maxAndSum = (0L,0L)
    A.foldLeft(maxAndSum) { case ((max, sum), a) =>
      val add = if(max > a) max - a else 0
      (Math.max(max, a), sum + add)
    }._2
  }

  println(solve())

}



Measured memory_bytes: 86040
def fact2( n ):
    ans = 0
    while n > 0:
        if n % 2 == 0:
            n = n // 2
            ans += 1
        else:
            break
    return ans

N = int(input())
Data = list(map(int,input().split()))
ans = 0
for d in Data:
    ans += fact2(d)
print(ans)

Measured memory_bytes: 4148
#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
#include <algorithm>
#define INF 0x3f3f3f3f
#define SI(a) scanf("%d",&a)
#define ms(a,x) memset(a,x,sizeof(a))
typedef long long ll;
const int mod = 998244353;
const int maxn = 110;
using namespace std;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
ll quick_pow(ll x,ll n,ll mod){
	ll res = 1;
	while(n > 0){
		if(n & 1)	res = res * x % mod;
		x = x * x % mod;
		n >>= 1;//相当于n=n/2.详情请参考位移运算符。
	}
	return res;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string str[maxn];
    int n,m;
    cin>>n>>m;
    for(int i = 0;i < n;i++)cin>>str[i];
    sort(str,str+n);
    for(int i = 0;i < n;i++)cout<<str[i];
    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <iostream>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

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

    int offset;
    cin >> offset;  // 1番目だけ保留
    int prev = offset, next = 0, len = 0;
    rep(i, 1, n) {
        cin >> next;
        len  = max(len, next - prev);
        prev = next;
    }
    len = max(len, offset + k - next);

    cout << k - len << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define sz 100010
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

int const mod = 1e9;

int main()
{
    BeatMeScanf;
    ll n, x;
    cin>>n>>x;
    vector<ll>arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];

    sort(arr.begin(), arr.end());
    ll sum = 0;
    for(int i=0;i<x;i++) sum += arr[i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3628