akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::Ordering;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }
    let mut counts = vec![0; n];
    for (i, mut val) in a.into_iter().enumerate() {
        loop {
            let v = val / 2;
            if v * 2 == val {
                counts[i] += 1;
                val /= 2;
            } else {
                break;
            }
        }
    }
    counts.sort_by_key(|&x| x);
    println!("{}", counts[0]);
}


Measured memory_bytes: 4352
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from string import ascii_lowercase as letters, maketrans

table = maketrans(letters, letters[1:] + letters[:1])
for line in stdin:
    line = line.strip()
    while True:
        line = line.translate(table)
        if 'the ' in line or 'this ' in line or 'that ' in line:
            break
    print(line)

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

using namespace std;

#define int long long

int n, m;
int a[5120];
int b[5120][210];

int ans = -1e18;

int g[5010][5010];

void Add(int i, int j, int val)
{
    if (i >= 0 && j >= 0) g[i][j] += val;
}

void Add(int x1, int x2, int y1, int y2, int val)
{
    Add(x1 - 1, y1 - 1, val);
    Add(x2, y1 - 1, -val);
    Add(x1 - 1, y2, -val);
    Add(x2, y2, val);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i + 1 < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> b[i][j];
        }
    }
    for (int j = 0; j < m; j++)
    {
        vector<pair<int, int> > kek;
        for (int i = 0; i < n; i++) kek.push_back({b[i][j], i});
        sort(kek.begin(), kek.end());
        vector<int> L(n), R(n), Ac(n);
        for (int i = 0; i < n; i++) L[i] = i, R[i] = i;
        for (int ii = 0; ii < n; ii++)
        {
            int i = kek[ii].second;
            int val = kek[ii].first;
            if ((i == 0 || Ac[i - 1] == 0) && (i + 1 == n || Ac[i + 1] == 0))
            {
                Ac[i] = 1;
                Add(i, i, i, i, val);
                continue;
            }
            if ((i > 0 && Ac[i - 1] == 1) && (i + 1 == n || Ac[i + 1] == 0))
            {
                Ac[i] = 1;
                int LL = L[i - 1];
                R[LL] = i;
                L[i] = LL;
                Add(LL, i, i, i, val);
                continue;
            }
            if ((i == 0 || Ac[i - 1] == 0) && (i + 1 < n && Ac[i + 1] == 1))
            {
                Ac[i] = 1;
                int RR = R[i + 1];
                L[RR] = i;
                R[i] = RR;
                Add(i, i, i, RR, val);
                continue;
            }
            Ac[i] = 1;
            int LL = L[i - 1];
            int RR = R[i + 1];
            L[RR] = LL;
            R[LL] = RR;
            Add(LL, i, i, RR, val);
        }
    }
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = n - 1; j >= 0; j--)
        {
            g[i][j] = g[i][j] + g[i + 1][j] + g[i][j + 1] - g[i + 1][j + 1];
        }
    }
    for (int i = 0; i < n; i++)
    {
        int len = 0;
        for (int j = i; j < n; j++)
        {
            ans = max(ans, g[i][j] - len);
            len += a[j];
        }
    }
    cout << ans;
}


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

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

  bool result = false;
  for(int i=0; i<S.size(); i++){
    if(S[i] == '7'){
      result = true;
    }
  }
  if(result){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    ll n; cin >> n;
    
    ll ans = 0;
    for(ll i=1; i<=n; i++){
        ll z = floor(double(n) / double(i));
        ans += i * z * (z + 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll m; cin>>m;
	string s; cin>>s;
	ll ans=0;
	rep(N,s.sz-1){
		vector<ll> sit(26,0);
		rep(i,N+1){
			if(sit[s[i]-'a']==0) sit[s[i]-'a']=1;
		}
		for(int i=N+1;i<=s.sz-1;i++){
			if(sit[s[i]-'a']==1) sit[s[i]-'a']=2;
		}
		ll cnt=0;
		rep(i,26){
			if(sit[i]==2) cnt++;
		}
		if(ans<cnt) ans=cnt;
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
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; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
#define vecP vector<P>
// cout << setprecision(15) << std::fixed;

int main()
{
	ll n,ans=0;
	cin >> n;
	if (n % 2 == 1) {
		cout << 0;
		exit(0);
	}
	ll b = 2;
	while (n > b) {
		b *= 5;
		ans += n / b;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

// i番目にたどり着くための最小コスト
int dp[100010];

int main() {
    int n, h[100010], k;
    cin >> n >> k;
    int h_;
    rep(i, n) {
        scanf("%d", &h_);
        h[i] = h_;
    }
    dp[0] = 0;
    int mindp;
    for (int i = 1; i < n; i++) {
        mindp = INF;
        rep1(j, k) {
            if (i - j >= 0) {
                mindp = min(mindp, dp[i - j] + abs(h[i] - h[i - j]));
            }
        }
        dp[i] = mindp;
    }

    cout << dp[n - 1];

    /* ====================================== */
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<char,char> P;

int main(){
	int n;
	cin>>n;
	vector<int>x(n),v(n);
	REP(i,n)cin>>v[i];
	x=v;
	sort(ALL(v));
	int ans1=v[n/2-1];
	int ans2=v[n/2];
	REP(i,n){
		if(x[i]<=ans1){
			cout<<ans2<<endl;
		}else{
			cout<<ans1<<endl;
		}
	}
}


Measured memory_bytes: 3712
//PDF解説に倣ってDP
#include<bits/stdc++.h>
using namespace std;

int main(){
  int M=1e9+7,n,m;
  cin>> n >> m;
  vector<int> s(n),t(m);
  for (int i=0; i<n; i++) cin>> s[i];
  for (int i=0; i<m; i++) cin>> t[i];
  
  vector<vector<int>> dp(n+1,vector<int>(m+1));
  for (int i=0; i<n; i++){
    for (int j=0; j<m; j++){
      dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j];
      if (s[i]==t[j]) dp[i+1][j+1]++;
      else dp[i+1][j+1]-=dp[i][j];
      dp[i+1][j+1]%=M;
      if (dp[i+1][j+1]<0) dp[i+1][j+1]+=M;
    }
  }
  cout<< (dp[n][m]+1)%M <<endl;
}
//ついでに簡略化

Measured memory_bytes: 16000
#include<iostream>
using namespace std;
int main(){
    int a;
    int b;
    int c;
    int d;
    cin>>a>>b>>c;
    if(a>b){
        d=a;
        a=b;
        b=d;
    }
    if(b>c){
        d=b;
        b=c;
        c=d;
    }
    if(a>b){
        d=a;
        a=b;
        b=d;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace structured
{
    class Program
    {
        static void Main(string[] args)
        {
            String str = Console.ReadLine();
            var output = new StringBuilder();
            int x = int.Parse(str);
        
            for (int i = 3; i <= x; i++) {
                if (((i % 3) == 0) || (i.ToString().Contains("3"))) {
                    output.Append(" " + i.ToString());
                   
                  }
         }Console.WriteLine(output);
        }
    }
}

Measured memory_bytes: 6556
from collections import Counter
n = int(input())
li = list(map(int, input().split()))
counter = Counter(li)
dic = {}
for key, val in counter.items():
    if val >= 2:
        dic[key] = val

if len(dic) == 0:
    print(0)
elif len(dic) == 1:
    key, val = dic.popitem()
    if val >= 4:
        print(key*key)
    if val <= 3:
        print(0)
elif len(dic) >= 2:
    sort = sorted(dic.items(), key=lambda x:x[0], reverse=True)
    k1, v1 = sort[0]
    k2, v2 = sort[1]
    if v1 >= 4:
        print(k1*k1)
    elif v1 <= 3:
        print(k1*k2)

Measured memory_bytes: 18600
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int a[1000];
signed main(){
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a,a+3);
  cout<<a[0]+a[1]<<"\n";
 
  return(0);
}


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

int main(){
    
    int n,h;cin>>n>>h;
    vector<int> a(n);
    int ans=0;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        if(a[i]>=h)ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 640
object Main {
  def main (args: Array[String]) {
    val input =  scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val a:Int = input(0)
    val b:Int = input(1)

    a match{
      case i if i >  b => println("a > b")
      case i if i <  b => println("a < b")
      case i if i == b => println("a == b")
      case _ => println("????")
    }
  }
}

Measured memory_bytes: 43736
K,N = list(map(int,input().split()))
A = list(map(int,input().split()))
temp_ans = 0
ans = 0
for i in range(1,N):
    temp_ans = A[i] - A[i-1]
    ans = max(ans,abs(temp_ans))
ans = max(abs(A[N-1] - A[0]-K),ans)
print(K - ans)

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




int main(){
	
	long long n,w;cin>>n>>w;
	vector<long long> dp(w+1);
	
	for(int i=0;i<n;i++){
		long long weight,value;
		cin>>weight>>value;
		for(int j=w;j>=0;j--){
			if(j-weight>=0){
				dp[j] = max(dp[j],dp[j-weight]+value);
			}
		}
	}
	cout<<dp[w];
	
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int a, b;
	cin >> a >> b;

	if (a > b)
	{
		swap(a, b);
	}

	for(int i = 0; i < b; ++i)
	{
		cout << a;
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

const int nax = 2e5+1;
int arr[nax];

int main() {

	memset(arr, 0, sizeof(arr));
	int N; 
	std::cin >> N;

	int temp;
	for (int i=1; i<N; i++) {
		std::cin >> temp;
		arr[temp]++;
	}

	for (int i=1; i<=N; i++) {
		std::cout << arr[i] << "\n";
	}

	return 0;
}


Measured memory_bytes: 4412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

int main() {
	ll argN, argA, argB;
	cin >> argN >> argA >> argB;

	if (abs(argA - argB) % 2 == 0) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
}

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

double n, d, c = 0;

struct point {
    double x, y, distance;
    point(int a, int b) {
        x = a; y = b;
        distance = sqrt(x*x + y*y);
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> d;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        point p(x, y);
        p.distance <= d ? c++ : c += 0;
    }
    cout << c;
}

Measured memory_bytes: 3820
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
AA = Counter(A)
B = []
C = []
for k,v in AA.items():
    if v>=2:
        B.append(k)
    if v>=4:
        C.append(k)
B.sort(reverse=True)
C.sort(reverse=True)
if len(B)<=1 and len(C)==0:
    print(0)
else:
    if len(B)<=1:
        print(C[0]*C[0])
    elif len(C)==0:
        print(B[0]*B[1])
    else:
        print(max(B[0]*B[1],C[0]*C[0]))

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

int main() {
    ll ans, n;
    ans = 0;
    cin >> n;
    vector<int> a(n), b(n, 0);
    rep(i, n) cin >> a[i];
    for (int i = n - 1; i >= 0; i--) {
        int s = 0;
        rep(j, n/(i + 1)) {
            s += b[(j + 1)*(i + 1) -1];
        }
        if (s%2 != a[i]) {
            b[i] = 1;
            ans++;
        }
    }
    cout << ans << endl;
    rep(i, n) {
        if (b[i] == 1) {
            cout << i + 1 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4784
'use strict'
function Main(input) {
  const ar = input.split("\n").map(x => x.split(" "));
  const num = Number(ar[0]);

  const rep = 25 - num;
  console.log("Christmas" + " Eve".repeat(rep));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21320
import java.util.*;
import java.io.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		int n = sc.nextInt();
		int ta = 0, ha = 0;
		for(int i = 0; i < n; ++i){
			String TA = sc.next();
			String HA = sc.next();
			int res = TA.compareTo(HA);
			if(res > 0) ta += 3;
			else if(res == 0){
				++ta; ++ha;
			}else ha += 3;
		}
		System.out.printf("%d %d\n",ta, ha);
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 24896
#include<iostream>
using namespace std;
int main(){
	int m,n,i,j,c;
	cin>>m>>n>>c;
	int a[m][n];
	int b[n],sum,ans=0;
	for(i=0;i<n;i++) cin>>b[i];
	for(i=0;i<m;i++)
	for(j=0;j<n;j++)
		cin>>a[i][j];
	for(i=0;i<m;i++){
		sum=0;
		for(j=0;j<n;j++){
			sum+=a[i][j]*b[j];
		}
		if(sum+c>0) ans++;
	}
	cout<<ans;
	return 0;
}

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

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

  long long int a[n][3],dp[n][3],i,j,ma,sa=-1,k;
  ma=-1;

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

  for(j=0;j<3;j++)
  {
    dp[0][j]=a[0][j];
    ma=max(ma,dp[0][j]);
  }

  for(i=1;i<n;i++)
  {
    for(j=0;j<3;j++)
    {
      if(ma!=dp[i-1][j])
        dp[i][j]=ma+a[i][j];
      else
      {
        for(k=0;k<3;k++)
        {
          if(k!=j)
          {
            sa=max(sa,dp[i-1][k]);
          }
        }
        dp[i][j]=sa+a[i][j];
      }
    }
    ma=-1;
    sa=-1;
    for(j=0;j<3;j++)
      ma=max(ma,dp[i][j]);
  }

  for(j=0;j<3;j++)
    ma=max(ma,dp[n-1][j]);

  cout<<ma<<endl;

return 0;
}


Measured memory_bytes: 4864
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int v[20];
  int c[20];
  for(int i=0;i<n;i++){
    scanf("%d",&v[i]);
  }
  for(int i=0;i<n;i++){
    scanf("%d",c+i);
  }
  int sum = 0;
  for(int i=0;i<n;i++){
    if(v[i] > c[i]) sum += v[i] - c[i];
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 1e5 + 20;
vector<pii> pt, edge[MAXN];
vector<int> unq, res, vis, a;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, m;
	cin >> n >> m;
	rep (i, 1, n) {
		int x, y;
		cin >> x >> y;
		unq.pb(x);
		pt.pb(pii(x, y));
	}
	sort(all(pt));
	sort(all(unq));
	rep (i, 1, m) {
		int u, v;
		cin >> u >> v;
		u = lower_bound(all(unq), u) - unq.begin();
		v = upper_bound(all(unq), v) - unq.begin();
		if (u != v) {
			edge[u].emplace_back(v, i);
			edge[v].emplace_back(u, i);
		}
	}
	a.resize(n + 1, 0);
	vis.resize(n + 1, 0);
	rep (i, 0, n - 1) {
		a[i] ^= pt[i].sed;
		a[i + 1] ^= pt[i].sed;
	}
	function<void(const int &)> dfs;
	dfs = [&] (const int & u) {
		vis[u] = 1;
		for (auto & e : edge[u]) {
			int v = e.fst;
			int id = e.sed;
			if (!vis[v]) {
				dfs(v);
				if (a[v]) {
					a[u] ^= 1;
					a[v] ^= 1;
					res.pb(id);
				}
			}
		}
	};
	rep (i, 0, n) {
		if (!vis[i]) dfs(i);
		if (a[i] == 1) {
			cout << -1 << endl;
			return 0;
		}
	}
	sort(all(res));
	cout << SZ(res) << endl;
	for (auto e : res) {
		cout << e << ' ';
	}	cout << endl;
	return 0;
}

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

using namespace std;

//  g, f, e, d, c, b, a
int ss[10][7] = {
  { 0, 1, 1, 1, 1, 1, 1 },
  { 0, 0, 0, 0, 1, 1, 0 },
  { 1, 0, 1, 1, 0, 1, 1 },
  { 1, 0, 0, 1, 1, 1, 1 },
  { 1, 1, 0, 0, 1, 1, 0 },
  { 1, 1, 0, 1, 1, 0, 1 },
  { 1, 1, 1, 1, 1, 0, 1 },
  { 0, 1, 0, 0, 1, 1, 1 },
  { 1, 1, 1, 1, 1, 1, 1 },
  { 1, 1, 0, 1, 1, 1, 1 }
};

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == -1) return 0;
    int d[7];
    fill(d, d+7, 0);
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      for (int j = 0; j < 7; j++) {
        cout << (d[j] ^ ss[x][j]);
        d[j] = ss[x][j];
      }
      cout << endl;
    }
  }
}

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


int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
        int a,b;
    cin>>a>>b;
    vector<int>nish;

    for(int i=0;i<a;i++)
    {
      int first;
      cin>>first;
      nish.push_back(first);
    }
    sort(nish.begin(),nish.end());
    long long int ans=0;
    for(int i=0;i<b;i++)
    {
      ans+=nish[i];
    }


    cout<<ans<<endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	ll now = a[0];
	for( int i = 1; i < n; ++i ){
		if( i % 2 == 1 ) now -= a[i];
		else now += a[i];
	}
	now /= 2;
	vector<ll> ans;
	ans.push_back(now);
	for( int i = 0; i < n-1; ++i ){
		now = a[i]-now;
		ans.push_back(now);
	}
	for( int i = 0; i < n; ++i ){
		cout << ans[i]*2;
		if( i < n-1 ) cout << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
stack<int>st;
void conversion(int n)
{
    while(n)
    {
        st.push((n+1000000002)%-2);
        n=ceil(n/-2.0);
    }
    return;
}
main()
{
    int m,n;
    while(~scanf("%d",&n))
    {
        conversion(n);
        while(!st.empty())
        {
            printf("%d",st.top());
            st.pop();
        }
        n==0 ? puts("0") : puts("");
    }
    return 0;
}

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

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

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

namespace ABC132
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var r = s.OrderBy(x => x).ToArray();
            if (r[0] == r[1] && r[2] == r[3] && r[1] != r[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
long long a[88]={2,1};
int n;
int main() {
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
		a[i]=a[i-1]+a[i-2];
	printf("%lld\n",a[n]);
	return 0;
}

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

int main()
{  fast
cin>>n>>z>>w;
for(int i=1;i<=n;i++)
cin>>arr[i];
if(n==1)
{
	cout<<abs(arr[1]-w);
	return 0;
}
cout<<max(abs(arr[n-1]-arr[n]),abs(w-arr[n]));
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//前がxなら１　０なら２　はじめ、もしくは０xがきた後なら３
int main(){
	int n,s=3,ans=0;
	char c;
	cin>>n;
	for(int p=0;p<n;p++){
		cin>>c;
		//cout<<c<<endl;
		if(c=='O'){
			if(s==1){
				ans++;
				s=3;
			}else{
				s=2;
			}
		}else if(c=='X'){
			if(s==2){
				ans++;
				s=3;
			}else{
				s=1;
			}
		}
	}
	cout<<ans<<endl;
}


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

ll n,z,w,a[2009];

int main(){
    cin>>n>>z>>w;
    FOR(i,1,n+1)cin>>a[i];
    a[0]=w;
    cout<<max(abs(w-a[n]),abs(a[n]-a[n-1]));
}

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

int MinIndex(const unsigned long long int* const array, const int size);

int main() {
	unsigned long long int N;
	unsigned long long int board[5];

	cin >> N;

	for (int i = 0; i < 5; i++) cin >> board[i];

	int bottleNeckIndex = MinIndex(board, 5);

	unsigned long long int ans = (unsigned long long int)(N / board[bottleNeckIndex]) + 4;

	if ((N % board[bottleNeckIndex]) != 0) ans++;

	cout << ans;

	return 0;
}

int MinIndex(const unsigned long long int* const array, const int size){
	int minIndex = 0;
	unsigned long long int minValue = array[0];

	for (int i = 1; i < size; i++) {
		if (array[i] < minValue) {
			minIndex = i;
			minValue = array[i];
		}
	}

	return minIndex;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 1000000007
#define eps 1e-8
int n;
ll dp[3030],pre[3030],suf[3030];
char s[3030];

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*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	n=read();
	scanf("%s",s+2);
	dp[1]=1;pre[1]=1;suf[1]=1;
	rep(i,2,n)
	{
		if (s[i]=='<') rep(j,1,i) dp[j]=pre[j-1];
		else rep(j,1,i) dp[j]=suf[j];
		rep(j,1,i) pre[j]=(pre[j-1]+dp[j])%maxd;
		per(j,i,1) suf[j]=(suf[j+1]+dp[j])%maxd;
	}
	printf("%lld",pre[n]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}    


signed main()
{
    showoff;
    int n;
    cin >> n;
    int x = n/100,y = (n%100);
    if(y <= 5*x)cout << "1";
    else cout << 0;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define    nl     "\n"
#define    for0(i,n) for(int i=0;i<n;i++)
#define    for1(i,n) for(int i=1;i<n;i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    End    return 0
#define    gt     greater<int>()
#define    ll     long long int

int main()
{
    int n,m;
    ll s=0;
    cin>>n>>m;
    int a[n];
    for0(i,n)cin>>a[i];
    sort(a,a+n);
    for0(i,m){
        s+=a[i];
    }
    cout<<s;
}


Measured memory_bytes: 3636
def main():
    from sys import stdin, setrecursionlimit
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    #r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    #a,b,c,d = map(int, r.split())
    #a = list(map(int, r.split()))
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #a = [list(map(int, input().split())) for i in range(1,n+1)]
    #res = 0

    n= int(input())
    a= list(map(int, input().split()))
    if len(set(a)) == len(a):
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 100436
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,c,y;
	cin>>n>>y;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			c=10000*i+5000*j+1000*(n-i-j);
			if(c==y){
				cout<<i<<" "<<j<<" "<<n-i-j;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


int main() {
    ios_base::sync_with_stdio(false);

    int a,b,c; 
    cin >> a >> b >> c;
    bool flag=0;
    int now=a;
    rep(i,b) {
        if (now%b==c) flag=1;
        now+=a;
    }
    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    

    return 0;   
}


Measured memory_bytes: 892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		StringTokenizer st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(st.nextToken());
		}
		int q = Integer.parseInt(reader.readLine());
		st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < q; i++) {
			if (subsetSum(Integer.parseInt(st.nextToken()), a)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
		reader.close();
	}

	private boolean subsetSum(int s, int[] a) {
		int n = a.length;
		boolean[][] dp = new boolean[n+1][s+1];
		for (int i = 1; i <= n; i++) {
			int v = a[i-1];
			for (int j = 0; j <= s; j++) {
				if (v > j) {
					dp[i][j] = dp[i-1][j];
				} else if (v == j) {
					dp[i][j] = true;
				} else {
					dp[i][j] = dp[i-1][j] || dp[i-1][j-v];
				}
			}
		}
		return dp[n][s];
	}
}



Measured memory_bytes: 29372
#include <bits/stdc++.h>
#define pb push_back
#define Int int64_t
using namespace std;
const Int M=(Int)(1e9+7);

inline Int mmul(Int a,Int b){if(a>=M)a=a%M;if(b>=M)b=b%M;if(a*b>=M)return(a*b)%M;return(a*b);}
inline Int madd(Int a, Int b){if(a>=M)a=a%M;if(b>=M)b=b%M;if(a+b>=M)return(a+b)%M;return(a+b);}



int main()
{
    int N;cin>>N;
    vector<int64_t> A(N);
    for(auto &x:A) cin>>x;
    
    vector<int64_t> pref(N);
    int64_t ans=0;
    pref[0]=A[0];++ans;
    for(int i=1;i<N;++i){
        pref[i]=min(pref[i-1],A[i]);
        ans+=pref[i]==A[i];
    }
    
    cout<<ans<<"\n";
}

Measured memory_bytes: 6404
/** 
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 *  Institute : Pandit Deendayal Petroleum University
 **/
#include<bits/stdc++.h>

using namespace std; 

#define start_cooking int main()
#define food_is_ready return 0;
#define main_ingredient_added ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

start_cooking
{
    main_ingredient_added
    //start with your recipe
    long long a, b, n;
    cin>>a>>b>>n;
    long long k;
    k = min(n, b-1);
    cout<<(a*k)/b - a*(k/b);
    food_is_ready
}

Measured memory_bytes: 3568
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();

		int city[][] = new int[m + 1][4]; // id, pref, year, number
		for ( int id = 1; id <= m; id++ ) {
			city[id][0] = id;
			city[id][1] = in.nextInt();
			city[id][2] = in.nextInt();
		}
		Arrays.sort(city, (c1, c2) -> {
			if ( c1[1] != c2[1] ) return c1[1] - c2[1];	// 1.prefでソート
			else return c1[2] - c2[2];					// 2.yearでソート
		});

		DecimalFormat df = new DecimalFormat("000000");
		String result[] = new String[m];
		int pref = -1;
		int num = 0;
		for ( int i = 1; i <= m; i++ ) {
			pref = city[i][1];
			num = (pref == city[i - 1][1] ? num + 1 : 1);
			result[city[i][0] - 1] = df.format(pref) + df.format(num);
		}

		StringBuilder sb = new StringBuilder();
		for ( String s : result ) {
			sb.append(s).append("\n");
		}
		System.out.println(sb);
		in.close();
	}
}

Measured memory_bytes: 100420
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Integer n = Integer.parseInt(scan.next());
        Integer capa = Integer.parseInt(scan.next());

        int[] v = new int[n];
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = Integer.parseInt(scan.next());
            w[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        int[] dp = new int[capa + 1];
        for (int i = 1; i <= capa; i++) {
            int max = dp[i - 1];
            for (int j = 0; j < n; j++) {
                if (w[j] <= i && max < dp[i - w[j]] + v[j]) {
                    max = dp[i - w[j]] + v[j];
                }
            }
            dp[i] = max;
        }

        System.out.println(dp[capa]);
    }

}



Measured memory_bytes: 26736
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#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)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> 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 main(void){
	int a,b,h;
	cin >> a >> b >> h;
	
	cout << double(h*(a+b))/2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
def dist(a, b)
  Math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)
end

n = gets.to_i
xys = n.times.map { gets.split.map(&:to_i) }

routes = [*0..n - 1].permutation
ans = 0

routes.each do |r|
  r.each_cons(2) do |a, b|
    ans += dist(xys[a], xys[b])
  end
end

puts ans / 1.upto(n).inject(:*)


Measured memory_bytes: 2044
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    boolean flg = true;
    if(!(str[0].substring(str[0].length()-1,str[0].length()).equals(str[1].substring(0,1)))
      ||
      !(str[1].substring(str[1].length()-1,str[1].length()).equals(str[2].substring(0,1))))
      flg = false;
    System.out.println(flg == true?"YES":"NO");
  }
}

Measured memory_bytes: 32676
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

double prob[3000];
double dp[3001][3001];

int main () {
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>prob[i];
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<i;j++){
			dp[j][i-j]=dp[j-1][i-j]*prob[i]+dp[j][i-j-1]*(1-prob[i]);
		}
		dp[0][i]=dp[0][i-1]*(1-prob[i]);
		dp[i][0]=dp[i-1][0]*prob[i];
	}
	double rj=0;
	for(int i=0;i<=n/2;i++){
		rj+=dp[n-i][i];
	}
	cout<<setprecision(11)<<rj;



return 0;
}



Measured memory_bytes: 70016
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;
typedef pair<int, char> ICpair;

vector<int> A;
vector<char> C;
int N;

int ret;

int val[4000][2][4000];
int dp[4000][4000];

int memo(int i, int j) {
	if (i == N && j == N)
		return 0;
	
	int &ret = dp[i][j];
	if (ret != -1)
		return ret;
	ret = 1 << 30;
	if (i < N)
		ret = min(ret, memo(i + 1, j) + val[i][0][j]);
		
	if (j < N)
		ret = min(ret, memo(i, j + 1) + val[j][1][i]);
	return ret;
}

int pos[4000][2];

int main() {
	ios_base::sync_with_stdio(false);
	A.clear();
	C.clear();
	cin >> N;
	char ch;
	int a;
	FOR (i, 2 * N) {
		cin >> ch >> a;
		a--;
		C.pb(ch);
		A.pb(a);
		if (ch == 'W')
			pos[a][0] = i;
		else
			pos[a][1] = i;
	}
	ret = 0;
	FOR (i, A.sz) {
		ffor (j, i + 1, A.sz)
			if (A[j] < A[i] && C[j] == C[i])
				ret++;
	}
	
	SET(val, 0);
	FOR (i, N)
		FOR (c, 2)
			FOR (j, N) {
				int &v = val[i][c][j + 1];
				v = val[i][c][j];

				if (pos[i][c] < pos[j][1 - c])
					v++;
			}
	
	SET(dp, 255);
	ret += memo(0, 0);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 188032
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	ll x, a, b, ka, kb;

	scanf("%lld", &x);

	for (a = -1000; a <= 1000; a++) for (b = -1000; b < a; b++) {
		ka = a * a * a * a * a;
		kb = b * b * b * b * b;
		if (ka - kb == x) {
			printf("%lld %lld\n", a, b);
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3772
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using static System.Math;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		int[] a=sc.Ia;
		long ans=0,p=0;
		for(int i = n>>1;i>0;i--) {
			p=0;
			for(int j=i,k=n-1-i;j<n-i&&j!=k&&j!=k+i;j+=i,k-=i) {
				p+=a[j]+a[k];
				ans=Max(ans,p);
			}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public string Sz{get{return Console.ReadLine();}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2(int b){return Array.ConvertAll((((b&1)!=0?"0 ":"")+Console.ReadLine()+((b&2)!=0?" 0":"")).Split(),int.Parse);}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return (Console.ReadLine()+" 0").Split();}}
}

Measured memory_bytes: 28892
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
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);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll G=0,P=0,ans=0;
  string S;
  cin >> S;
  rep(i,S.size()){
    if(S[i]=='g'){
      if(G>P){
        P++;
        ans++;
      }
      else{
        G++;
      }
    }
    else{
      if(G>P){
        P++;
      }
      else{
        G++;
        ans--;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int ans=0;
    string S,T;
    cin>>S>>T;

    for(int i=0;i<3;i++){
        if(S[i]==T[i])ans++;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256