akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,mn=0,mx=0;
    cin>>n;
    ll a[n];
    set<int>st;
    for(int i=0;i<n;i++)
    {
      cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
       if(a[i]>=1&&a[i]<=399)
       {
          st.insert(1);
       }
       else if(a[i]>=400&&a[i]<=799)
       {
           
        st.insert(2);
       }
       else if(a[i]>=800&&a[i]<=1199)
       {
          
            st.insert(3);
       }
       else if(a[i]>=1200&&a[i]<=1599)
       {
             
        st.insert(4);
       }
       else if(a[i]>=1600&&a[i]<=1999)
       {
            
        st.insert(5);
       }
       else if(a[i]>=2000&&a[i]<=2399)
       {
        st.insert(6);

       }
       else if(a[i]>=2400&&a[i]<=2799)
       {//mn++;mx++;
        st.insert(7);

       }
       else if(a[i]>=2800&&a[i]<=3199)
       {
          
        st.insert(8);
       }
       else
       {
          mx++;
       }
    }

    
      ll q=0;
      if(st.size()==0)
      {
            q=1;

      }
      else
      {
        q=st.size();
      }
      //ll q=max(1ll*st.size(),1*1ll);
    cout<<q<<" "<<st.size()+mx<<endl;
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

struct Node {
	int key;
	Node *prev, *next;
};

Node *nil;

void init() {
	nil = (Node *) malloc (sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void insert(int key) {
	Node *x = (Node *) malloc (sizeof(Node));
	x->key = key;
	x->next = nil->next;
	x->prev = nil;
	nil->next->prev = x;
	nil->next = x;
}

Node * listSearch(int key) {
	Node *cur = nil->next;
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void deleteNode(Node *t) {
	if (t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void printList() {
	Node *cur = nil->next;
	int isFirst = 1;
	while (cur != nil) {
		if (!isFirst) {
			printf(" ");
		}
		isFirst = 0;
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

int main() {
	int n, key;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);

	init();

	for (int i = 0; i < n; i++) {
		scanf("%s", com);
		if (com[0] == 'i') {
			scanf("%d", &key);
			insert(key);
			size++;
			np++;
		} else if (com[0] == 'd') {
			if (com[6] == 'F') {
				deleteFirst();
			} else if (com[6] == 'L') {
				deleteLast();
			} else {
				scanf("%d", &key);
				deleteKey(key);
				nd++;
			}
			size--;
		}
	}

	printList();

	return 0;
}

Measured memory_bytes: 34308
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    string s, t;
    cin >> s >> t;
    ll ans = INT_MAX;
    for(ll i = 0; i <= s.size(); i++){
        string sb = s.substr(i, t.size());
        if(sb.size() != t.size()){
            break;
        }
        // cout << sb << " ";
        ll count = 0;
        for(ll j = 0; j < sb.size(); j++){
            if(sb[j] != t[j]){
                count++;
            }
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
}

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

int main()
{
	int a, b, i;
	int sum;
	
	while(cin >> a)
	{
		cin >> b;
	
		sum = a + b;
	
		i = 0;
		while(sum != 0)
		{
			sum = sum / 10;
			
			i = i + 1;
		}
		
		cout << i << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#define fs first
#define sc second
using namespace std;
const int maxn = 1e5+10;
using pii = pair<int,int>;

int N;
int main(){
    cin>>N;
    cout<<(N+2-1)/2<<endl;


    return 0;
}

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

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

using namespace std;

int main(){
	int m1,m2; scanf("%d%*d%d%*d",&m1,&m2);
	printf("%d\n",m1!=m2);
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
table = [[int(i) for i in input().split()] for _ in range(M)]

ans = [table[0][0], table[0][1]]
cnt = 0

for i in table[1:]:
    if ans[0] <= i[0] <= ans[1]:
        ans[0] = i[0]
    if ans[0] <= i[1] <= ans[1]:
        ans[1] = i[1]
    if ans[1] < i[0] or i[1] < ans[0]:
        cnt += 1
        break

if cnt != 0:
    print(0)
else:
    print(ans[1] - ans[0] + 1)


Measured memory_bytes: 21948
#include <iostream>
using namespace std;
int main() {
    int n,k;
    cin>>n>>k;

    int moves[n],i,j;

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

    bool  dp[k+1];

    for(i=0;i<moves[0];i++) 
    dp[i]=false;
    
    for(i=moves[0];i<=k;i++)
    {
        dp[i]=false;
        for(j=0;j<n;j++)
        {
            if(i-moves[j]>=0)
            {
                if(dp[i-moves[j]]==0){
                dp[i]=true;
                break;}
                
            }
        }
    }
    
    if(dp[k]==1) 
    cout<<"First";
    else
    cout<<"Second";
    cout<<endl;


}


Measured memory_bytes: 3704
#ifndef ___Class_BIT
#define ___Class_BIT

// ------ Includes ------ //
#include <vector>
#pragma warning(disable : 4146)

// ------ Class ------ //
template <typename Type>
class BIT {
private:
	unsigned size_; std::vector<Type> v;
	Type sum(unsigned r) {
		Type ret = 0;
		while (r > 0) {
			ret += v[r];
			r -= r & (-r);
		}
		return ret;
	}
public:
	BIT() {};
	BIT(unsigned size__) {
		for (size_ = 1; size_ < size__;) size_ <<= 1;
		v.resize(size_ + 1, 0);
	}
	inline void add(unsigned i, Type x) {
		i++;
		while (i <= size_) {
			v[i] += x;
			i += i & -i;
		}
	}
	inline Type sum(unsigned l, unsigned r) {
		return sum(r) - sum(l);
	}
	bool operator[](unsigned x) {
		return sum(x, x + 1);
	}
};

#endif

#include <map>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int A, B, M;
int main() {
	while (cin >> A >> B >> M, A) {
		vector<string> v(B - A + 1);
		for (int i = A; i <= B; i++) v[i - A] = to_string(i);
		sort(v.begin(), v.end());
		map<int, int> pos;
		for (int i = 0; i < v.size(); i++) pos[stoi(v[i])] = i;
		BIT<long long> Q(B - A + 1);
		for (int i = A; i <= B; i++) Q.add(pos[i], (Q.sum(0, pos[i]) + 1) % M);
		cout << Q.sum(0, B - A + 1) % M << endl;
	}
}

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

int main(){
	string s;
	cin >> s;
	int cnt[26] = {};
	for(int i = 0;i < s.length();i++) cnt[s[i] - 'a']++;
	for(int i = 0;i < 26;i++){
		if(cnt[i] >= 2){
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/2
Solved on 2019/3/
@author: shinjisu
"""


# Educational Dynamic Programming
# import math
import numpy as np


def getInt(): return int(input())


# def getIntList(): return [int(x) for x in input().split()]
def getIntList(): return np.array(input().split(), dtype='int')


# def zeros(n): return [0]*n
def zeros(n): return np.zeros(n, dtype='int')


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**12


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def prob_A():  # Frog 1
    N = getInt()
    H = getIntList()
    dmp((N, H), 'N, H')
    c = zeros(N)
    c[1] = abs(H[1]-H[0])
    for i in range(2, N):
        c[i] = min(c[i-1] + abs(H[i]-H[i-1]),
                   c[i-2] + abs(H[i]-H[i-2]))
    dmp(c, 'c')
    return c[N-1]


def prob_B_TLE():  # Frog 2 3/16 TLE
    N, K = getIntList()
    H = getIntList()
    dmp((N, K, H), 'N, K, H')
    c = np.zeros(N)
    c[0] = 0
    for i in range(1, N):
        #c[i] = INF
        for j in range(max(0, i-K), i):
            c[i] = min(c[i], c[j] + abs(H[i]-H[j]))
    dmp(c, 'c')
    return c[N-1]


def prob_B():  # Frog 2
    N, K = getIntList()
    H = np.array(input().split(), dtype='int')
    dmp((N, K, H), 'N, K, H')
    c = np.zeros(N, dtype='int')
    c[0] = 0
    for i in range(1, N):
        c[i] = np.min(c[max(0, i-K):i] + np.abs(H[max(0, i-K):i] - H[i]))
    dmp(c, 'c')
    return c[N-1]


def prob_C():  # Vacation
    N = getInt()
    a = zeros(N)
    b = zeros(N)
    c = zeros(N)
    for i in range(N):
        a[i], b[i], c[i] = getIntList()
    dmp(N, 'N')
    dmp(a, 'a')
    dmp(b, 'b')
    dmp(c, 'c')
    dpa = zeros(N)
    dpb = zeros(N)
    dpc = zeros(N)
    dpa[0] = a[0]
    dpb[0] = b[0]
    dpc[0] = c[0]
    for i in range(1, N):
        dpa[i] += max(dpb[i-1], dpc[i-1]) + a[i]
        dpb[i] += max(dpc[i-1], dpa[i-1]) + b[i]
        dpc[i] += max(dpa[i-1], dpb[i-1]) + c[i]
    dmp(dpa, 'dpa')
    dmp(dpb, 'dpb')
    dmp(dpc, 'dpc')
    return max(dpa[N-1], dpb[N-1], dpc[N-1])


debug = False  # True False
ans = prob_C()
print(ans)
#for row in ans:
#    print(row)


Measured memory_bytes: 19208
#include<iostream>
    #include<algorithm>
    #include<vector>
    #include<queue>
    #include<cmath>
    #include<tuple>
    #include<string>
    typedef unsigned long long ll;
    #define rep(i,a,b) for(int i=(a);i<(b);i++)
    #define F first
    #define S second
    using namespace std;
    const ll INF = 1e12;
    const int i_INF = 2147483647;
     
    int main() {
      int a,b,c;
      cin>>a>>b>>c;
      cout<<min({b/a,c})<<endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int x;
    cin >> x;
    if (x >= 30) cout << "Yes\n";
    else cout << "No\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
char a[1001][1001];
unsigned long long h, w, f[1001][1001];
int main()
{
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
    cin>>h>>w;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++) cin>>a[i][j];
    f[0][1]=1;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
            if(a[i][j]!='#') f[i][j]=(f[i-1][j]+f[i][j-1])%1000000007;
    }
    cout<<f[h][w];
    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))

int main(){
	//ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n,k,x,cnt=0;
	cin>>n>>k;
	repeat(i,0,n){
		cin>>x;
		cnt+=(x>=k);
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if (n+m == 15) System.out.println("+");
        else if (n*m == 15) System.out.println("*");
        else System.out.println("x");
    }
}

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

using namespace std;


int main() {
	int p, q, r, s = 0, f = 0;
	cin >> p >> q >> r;
	int m = max(max(q, p), r);

	if (m != p) {
		s += p;
	}
	else {
		f = 1;
	}
	if (m != q || f == 1) {
		s += q;
	}
	else {
		f = 1;
	}
	if (m != r || f == 1) {
		s += r;
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll h[n+1],dp[n+1];
    rep(i,1,n+1)
    cin>>h[i];
    dp[n]=0;
    sep(i,n-1,1)
    	dp[i]=min(abs(h[i+1]-h[i])+dp[i+1],(i+2<=n?abs(h[i+2]-h[i])+dp[i+2]:LLONG_MAX));
    cout<<dp[1];
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	long X; cin >> X;

	//for (int i = 0; i <= X; i++) {
	//	int A = pow(i,5);

	//	bool br1 = false;
	//	if (br1 == false) {
	//    	for (int j = 0; j <= X; j++) {
	//			if (A < X) {
	//				br1 = true;	
	//				break;
	//			}
	//    		int B = pow(j,5);
	//    		if (A < B) break;
	//			if (A < X + B) break;
	//    		if (A == X + B) {
	//    			cout << i << " " << j << endl;	
	//    		}
	//    	}
	//	}

	//	for (int j = 0; j <= X; j++) {
	//		if (A > X) {
	//			br = true;
	//			break;
	//		}
	//		int mj = -1 * j;
	//		int B = pow(mj,5);
	//		if (A > X or (-1 * B) > X) break;
	//    	if (A == X + B) {
	//			cout << i << " " << mj << endl;		
	//			return 0;
	//		}
	//	}
	//	if (
	//}

	for (int i = -120; i <= 120; i++) {
		for (int j = -120; j <= 120; j++) {
			if (pow(i,5) - pow(j,5) == X) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}


	return 0;
}


Measured memory_bytes: 4096
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊

    let (n,m) = (io.read::<usize>(),io.read::<usize>());
    let mut A = Vec::new();
    let mut B = Vec::new();
    for _ in 0..n {
        let s = io.chars();
        A.push(s);
    }
    for _ in 0..m {
        let s = io.chars();
        B.push(s);}

    for i in 0..n-m+1 {
        for j in 0..n-m+1 {
            let mut ok = true;
            for ii in 0..m {
                for jj in 0..m {
                    if A[i+ii][j+jj] != B[ii][jj]{
                        ok=false;break;
                    }
                }
            }
            if ok {
                io.writeln("Yes");
                return;
            }
        }}
    
        io.writeln("No");

}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i=0,j,N,M;
  cin>>N>>M;
  pvec a(N+1);
  rep1(i,N+1){
    cin>>a[i].first>>a[i].second;
  }
  mat dp(N+1,vec(M+1,0));
  rep1(i,N+1){
    rep(j,a[i].first)dp[i][j]=dp[i-1][j];
    For(j,a[i].first,M+1){
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i].first]+a[i].second);
    }
  }
  rep(j,M)dp[N][M]=max(dp[N][M],dp[N][j]);
  cout<<dp[N][M]<<endl;
  return 0;
}

Measured memory_bytes: 80256
from fractions import Fraction
N = int(input())
A =list(map(int,input().split()))
A_list = []
for x in A:
    A_list.append(Fraction(1,x))
sum = Fraction(0)
for x in A_list:
    sum += x
result = 1/sum
result_f = float(result)
print(result_f)

Measured memory_bytes: 5052
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll cnt[10][10];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        int tail = i % 10;
        int head = i;
        while(head/10 > 0){
            head /= 10;
        }
        ++cnt[head][tail];
    }
    ll ans = 0;
    rep(i,10)rep(j,10){
        ans += cnt[i][j] * cnt[j][i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( void )
{
	int W, H, x, y, r;
	
	scanf( "%d %d %d %d %d", &W, &H, &x, &y, &r );
	
	if( x < 0 || y < 0 ){
		printf( "No\n" );
	}else if( W - ( x + r ) >= 0 && W - ( x - r ) >= 0 && H - ( y + r ) >= 0 && H - ( y - r ) >= 0 ){
		printf( "Yes\n" );
	}else{
		printf( "No\n" );
	}
	
	return 0;
}

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

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, sol = 0; cin >> n;
  string s;
  map<string, int> check;
  for (int i = 0; i < n; i++) {
    cin >> s;
    check[s]++;
    sol = max(sol, check[s]);
  }  
  set<string> ans;
  for (auto& x: check) {
    if (x.second == sol)
      ans.insert(x.first);
  }
  for (auto& x: ans) cout << x << '\n';
  return 0;  
}

Measured memory_bytes: 33280
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;

int main()
{
    int P, Q, R;
    std::cin >> P >> Q >> R;
    std::cout << std::min<int>({P + Q, Q + R, R + P}) << std::endl;
    return 0;
}

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

int main(){
   //ios_base::sync_with_stdio(0);
   //cin.tie(0);
   int l;
   int n; cin >> n >> l;
	vector<string> v(n);
	for(int i = 0; i<n; ++i) cin >> v[i];
	sort(v.begin(), v.end());
	for(auto s : v) cout << s;
	cout << endl;

   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    for (int i = 0;; i++) {
      n = sc.nextInt();
      x = sc.nextInt();
      if (n == 0 && x == 0) break;
      func(n, x);
    }

    sc.close();
  }

  private static void func(int n, int x) {// 1~n から3つ足して x を作るパターン数
    int ans = 0;
    if (x > 5 && x < 3*n - 2) {// x_min = 1+2+3 = 6, x_max = n+(n-1)+(n-2) = 3n-3
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          for (int k = j + 1; k <= n; k++) {
            if (i + j + k == x) {
              ans++;
              break;
            }
          }
        }
      }
    }
    System.out.println(ans);
  }
}



Measured memory_bytes: 26648
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def cmb(n, k):
    if n < k: return 0
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

N, K = lr()
MOD = 10 ** 9 + 7
U = 2010 # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)
red = N-K
for i in range(1, K+1):
    # (red+1)Ci
    answer = cmb(red+1, i)
    #print(answer)
    remain = K - i
    # remainをiの中に自由にいれる、i-1の壁を用意
    # (remain+(i-1)) C remain
    answer *= cmb(remain+i-1, remain)
    print(answer%MOD)

# 15


Measured memory_bytes: 21644
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

inline int getint(){
    int n;
    scanf("%d",&n);
    return n;
}

inline vector<int> getints(int n){
    vector<int> a(n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    return a;
}

inline string getstr(){
  string s;
  cin>>s;
  return s;
}

void dumpints(vector<int> a){
  cout<<"[";
  for(int i=0;i<a.size()-1;i++){
    cout<<a[i]<<",";
  }
  cout<<a[a.size()-1]<<"]"<<endl;
}

template<class T> bool ifinclude(vector<T> a,T x){
    auto itr=find(a.begin(),a.end(),x);
    return distance(a.begin(),itr)!=a.size();
}

int main(void){
  string S=getstr();
  bool ifN=false,ifW=false,ifS=false,ifE=false;
  FOR(i,S.size()){
    if(S[i]=='N')ifN=true;
    if(S[i]=='W')ifW=true;
    if(S[i]=='S')ifS=true;
    if(S[i]=='E')ifE=true;
  }
  cout<<(((ifN^ifS)||(ifW^ifE))?"No":"Yes")<<endl;
  return 0;
}


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

int main(){
  int N,A;
  cin>>N;
  cin>>A;
  
  int s;
  s=N%500;
  
  if(s>A){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
    int key;
    Node *next, *prev;
};

Node *nil;

Node *listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }

    return cur;
}

void init() {
    nil = (Node *) malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while (true) {
        if (cur == nil) {
            break;
        }

        if (isf++ > 0) {
            printf(" ");
        }

        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t) {
    if (t == nil) { return; }

    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main() {
    int key, n;
    char com[20];
    scanf("%d", &n);
    init();
    for (int i = 0; i < n; ++i) {
        scanf("%s %d", com, &key);
        if (com[0] == 'i') {
            insert(key);
        } else if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if (com[6] == 'F') {
                    deleteFirst();
                } else if (com[6] == 'L') {
                    deleteLast();
                }
            } else {
                deleteKey(key);
            }
        }
    }

    printList();

    return 0;
}



Measured memory_bytes: 33832
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vi h(n);
	REP(i, n) {
		cin >> h[i];
	}
	vi good(n, 1);
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		if (h[a] <= h[b]) {
			good[a] = false;
		}
		if (h[b] <= h[a]) {
			good[b] = false;
		}
	}
	int res =0 ;
	REP(i, n) res += good[i];
	cout << res << endl;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    vector<string> v;
    string now;
    for (int i = 0; i < s.size(); i++) {
        if (i < s.size() - 1 && s[i] == 'B' && s[i + 1] == 'C') {
            i++;
            now += 'Y';
        } else if (s[i] == 'A') now += 'X';
        else {
            v.push_back(now);
            now = "";
        }
    }
    v.push_back(now);

    long long ret = 0;
    for (auto x:v) {
        int count = 0;
        for (int i = 0; i < x.size(); i++) {
            if (x[i] == 'Y') {
                ret += i - count;
                count++;
            }
        }
    }

    cout << ret << endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    string ans = s;
    vector<bool> used(n);
    for(int i = 0; s[i]; i++)
    {
        if (s[i] == '(')
        {
            bool found = 0;
            for(int j = i+1; s[j]; j++)
            {
                if(s[j] == ')' && !used[j])
                {
                    used[j] = 1;
                    found = 1;
                    break;
                }
            }
            if(!found)
            {
                ans += ")";
            }
        }
    }

    for(int i = n-1; i >= 0; i--)
    {
        if(s[i] == ')')
        {
            bool found = 0;
            for(int j = i-1; j >= 0; j--)
            {
                if(s[j] == '(' && !used[j])
                {
                    used[j] = 1;
                    found = 1;
                    break;
                }
            }
            if(!found)
            {
                string temp = ans;
                ans = "(" + temp;
            }
        }
    }

    cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

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

    vector<long long> num(K, 0);
    for (int i = 1; i <= N; i++) num[i % K]++;

    long long ans = 0;
    for (int a = 0; a < K; a++) {
        int b = (K - a) % K;
        int c = (K - a) % K;
        if ((b + c) % K != 0) continue;
        ans += num[a] * num[b] * num[c];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll dp[2500];
void init(){
    for(int i=3; i<=2000; i++){
        if(i-3<3)dp[i]=1;
        else {
            dp[i]=1;
            for(int j=3; j<=i-3; j++){
                dp[i]=(dp[i]+dp[j])%mod;
            }
        }
    }
}
int main()
{
    init();
    int n;cin>>n;
    if(n<=2)return cout<<0<<endl,0;
    cout<<dp[n]<<endl;
    return 0;
}


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

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

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

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

	bool flag = false;
	for (int i = 0; i <= 25; i++) {
		for (int j = 0; j <=14; j++) {
			if (i * 4 + j * 7 == n) flag = true;
		}
	}

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;

 	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void masatoy(int,int,int);
int n,m,m1[501][501],m2[501];
int main(){
    while(1){
        memset(m1,0,sizeof(m1));
        memset(m2,0,sizeof(m2));
        cin>>n>>m;
        if(n==0&&m==0)return 0;
        for(int i=0;i<m;i++){
            int x,y;
            cin>>x>>y;
            m1[x][y]=1;
            m1[y][x]=1;
        }
        for(int i=2;i<=n;i++){
            if(m1[1][i]==1)m2[i]=1;
        }
        for(int i=2;i<=n;i++){
            if(m1[1][i]==1){
                for(int j=1;j<=n;j++){
                    if(m1[i][j]==1)m2[j]=1;
                }
            }
        }
        int sum=0;
        for(int i=2;i<=n;i++){
            if(m2[i]==1)sum++;
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 3956
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 998244353
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (n,m,k) = scan "%d %d %d" Tuple3.make

module CombMemo = struct
  let prime = 998244353
  let size = 2*1_00_000+1

  let memo = let arr = Array.make size None in
    arr.(0) <- Some 1;
    arr

  let ( *% ) a b = a * b mod prime
  let (-%) a b = (a+prime - b) mod prime
  let (+%) a b = (a + b) mod prime

  let rec pow n m =
    if m = 0 then 1
    else if m mod 2 = 0 then pow (n*%n) (m/2)
    else n *% pow (n*%n) (m/2)

  let rec fact n =
    match memo.(n) with
    | None ->
      let m = n *% fact (n-1) in
      memo.(n) <- Some m;
      m
    | Some a -> a

  let comb n k =
    if n <= 0 || k <= 0 then 1
    else
      fact n *% (pow (fact k) (prime-2)) *% (pow (fact (n - k)) (prime-2))
end

let () =
  let open ModOp in
  ListL.map (0++k) ~f:(fun k ->
      let bin = CombMemo.comb (n-1) k in
      m*bin*pow (m-1) (n-1-k))
  |> ListL.fold_left  ~init:0 ~f:(+)
  |> Printf.printf "%d\n"


Measured memory_bytes: 25008
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;

int main(){
	int k;
	cin >> k;
	priority_queue<int64, vector<int64>, greater<int64> > q;
	for(int64 i = 1; i < 10; ++i) q.push(i);
	for(int i = 0; i < k; ++i){
		int64 now = q.top(); q.pop();
		// cout << now << endl;
		if(i == k - 1){
			cout << now << endl;
			return 0;
		}
		int64 r = now % 10;
		q.push(now * 10 + r);
		if(r != 0LL) q.push(now * 10 + r - 1);
		if(r != 9LL) q.push(now * 10 + r + 1);
	}
}

Measured memory_bytes: 2420
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0]*(n + 1)

    def root(self, x):
        if self.par[x] == x:
            return x
        r = self.root(self.par[x])
        self.par[x] = r
        return r

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        if self.rank[rx] < self.rank[ry]:
            self.par[x] = ry
            self.par[rx] = ry
        else:
            self.par[y] = rx
            self.par[ry] = rx
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

def main():
    N, M, *AB = map(int, open(0).read().split())
    uf = UnionFind(N)
    elems = [1] * (N + 1)
    ans = N * (N - 1) // 2
    ANS = [0]*M
    for i in range(M):
        # print(ans)
        ANS[M - i - 1] = ans
        a = AB[2 * M - i * 2 - 2 + 0]
        b = AB[2 * M - i * 2 - 2 + 1]
        ra = uf.root(a)
        rb = uf.root(b)
        uf.unite(ra, rb)
        r = uf.root(ra)
        if ra != rb:
            era = elems[ra]
            erb = elems[rb]
            ans -= era * erb
            elems[r] = era + erb
    for ans in ANS:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25332
function Main(s){
  var k = +s;
  var a = [];
  var l = 0;
  var r = 1;
  while(a.length < k){
    var t = l + r;
    if(t / digitsum(t) <= (t + r) / digitsum(t + r)){
      a.push(t);
      l = t;
    }else r *= 10;
  }
  console.log(a.join("\n"));
}
function digitsum(n){return n<10?n:n%10+digitsum(Math.floor(n/10));}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 8012
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

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

    vector<vector<double>> dp(n+10, vector<double>(n+10,0));
    dp[0][0] = 1;
    rep(i,n){
        rep(j,n+1){
            dp[i+1][j] = dp[i][j] * (1-p[i]) + (j!=0? dp[i][j-1] * (p[i]) : 0);
        }
    }
    double ans = 0;
    rep(i,n+1){
        if(i > n - i) ans += dp[n][i];
    }
    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 71168
n,m = map(int,input().split())
a = 1
b = n
for i in range(m):
    l,r = map(int,input().split())
    if ( a < l and b < l ) or ( a > r and b > r):
        a = 1
        b = 0
        break
    a = max(a,l)
    b = min(b,r)
print(b-a+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a[1005], n, k;
  cin >> n >> k;
  for(int i = 0 ; i < n ; i++)
    cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  for(int i = 0 ; i < k ; i++)
    ans += a[i];
  cout << ans << endl;
  return(0);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long int;
using namespace std;
ll mod=1e9+7;


int main() {
  int n;
  cin >> n;
  ll ans=0;
  ll q=0,r=0;
  rep(i,n){
    ll a,b;
    cin >> a>> b;
    if(q<a){
      q=a;
      r=b;
    };
  }
  cout << q+r << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
char s1[10000],s2[10000];
int dp[5000][5000];
int main(){
    while(scanf("%s%s",s1,s2) != EOF){
        int n = strlen(s1);
        int m = strlen(s2);

        REP(i,m){
            dp[0][i] = (s1[0] == s2[i]);
        }

        FOR(i,1,n){
            REP(j,m){
                if(j == 0){
                    dp[i][j] = (s1[i] == s2[j]);
                    continue;
                }
                if(s1[i] == s2[j]){
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    continue;
                }
                dp[i][j] = 0;
            }
        }
        int maxi = 0;
        REP(i,n){
            REP(j,m){
                maxi = max(dp[i][j],maxi);
            }
        }
        printf("%d\n", maxi);
    }
    return 0;
}

Measured memory_bytes: 81304
#include <bits/stdc++.h>
#define inf (long long)(1e18)
using namespace std;



int main(void){
    int M;
    scanf("%d", &M);
    long long ans = -1;
    long long sum = 0;
    long long csum = 0;
    for(int i=0;i<M;i++){
        long long d;
        long long c;
        scanf("%lld%lld", &d, &c);
        sum += d*c;
        csum += c;
        }
    ans += csum;
    if(sum%9!=0)ans += sum / 9;
    else ans += (sum / 9 - 1);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
struct Istream {
	template <class T> 
	Istream &operator >>(T &x) {
		static char ch;static bool neg;
		for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
		for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
		x=neg?-x:x;
		return *this;
	}
	template <class T>
	operator T() {
		static T x;
		*this>>x;
		return x;
	}
}is;
struct Ostream {
	template <class T>
	Ostream &operator <<(T x) {
		x<0 && (putchar('-'),x=-x);
		static char stack[233];static int top;
		for(top=0;x;stack[++top]=x%10+'0',x/=10);
		for(top==0 && (stack[top=1]='0');top;putchar(stack[top--]));
		return *this;
	}
	Ostream &operator <<(char ch) {
		putchar(ch);
		return *this;
	}
}os;
const int MAXN=200000+11;
int main() {
	static int a[MAXN];
	int n=is,Q=is;
	for(int i=1;i<=n;++i)
		is>>a[i];
	static int cnt[MAXN],cvc[MAXN];
	int Ans=0;
	for(int i=1;i<=n;++i)
		cnt[a[i]]++;
	for(int i=1;i<=n;++i)
		for(int j=std::max(i-cnt[i],0);j<=i-1;++j)
			cvc[j]++;
	for(int i=0;i<=n-1;++i)
		Ans+=cvc[i]==0;
	for(int loop=1;loop<=Q;++loop) {
		int x=is,y=is;
		if(a[x]-cnt[a[x]]>=0 && --cvc[a[x]-cnt[a[x]]]==0)
			Ans++;
		cnt[a[x]]--;
		a[x]=y;
		cnt[a[x]]++;
		if(a[x]-cnt[a[x]]>=0 && ++cvc[a[x]-cnt[a[x]]]==1)
			Ans--;
		os<<Ans<<'\n';
	}
	return 0;
}


Measured memory_bytes: 3712
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let s = input!(String);
    println!(
        "{}",
        s.chars().fold(0, |i, v| match v {
            '+' => i + 1,
            '-' => i - 1,
            _ => i,
        })
    );
}


Measured memory_bytes: 4352
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();


		if( a < b ) {
			System.out.println("a < b");
		}else if( a > b ) {
			System.out.println("a > b");
		}else if( a == b ) {
			System.out.println("a == b");
		}
	}
}



Measured memory_bytes: 26060
import math

prime = [2]
max = 10 ** 5
limit = int(math.sqrt(max))
data = [i + 1 for i in range(2, max, 2)]

# エラストテネスの篩
while limit > data[0]:
    prime.append(data[0])
    data = [j for j in data if j % data[0] != 0]
prime = prime + data

# if (i + 1) / 2 in primeのにぶたん
def binary_search_loop(data, target):
    imin = 0
    imax = len(data) - 1
    while imin <= imax:
        imid = imin + (imax - imin) // 2
        if target == data[imid]:
            return True
        elif target < data[imid]:
            imax = imid - 1
        else:
            imin = imid + 1
    return False

# 累積和
lista = [0] * max
for i in prime:
    if binary_search_loop(prime, (i + 1) / 2):
        lista[i - 1] = 1
listb = [0]
for i in range(max):
    listb.append(lista[i] + listb[i])

# rまでの累積 - l - 1までの累積
q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(listb[r] - listb[l - 1])

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
 for (int i=0; i<N; i++){
   cin >>vec.at(i);
}
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int a=0;
  for(int i=0; 2*i<N; i++){
    a+=vec.at(2*i);
  }
  int b=0;
  for(int i=0; 2*i+1<N; i++){
    b+=vec.at(2*i+1);
  }
  cout << a-b << endl;
}
    


Measured memory_bytes: 3580