akhauriyash/Code-Regression huggingface dataset:
#line 1 "main.cpp"

/**
 * @title Template
 */

#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>
#include <cassert>

#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/chmin_chmax.cpp"

template <class T, class U>
constexpr bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
constexpr bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

/**
 * @title Chmin/Chmax
 */
#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

#line 4 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

class range {
public:
  class iterator {
  private:
    int64_t M_position;

  public:
    constexpr iterator(int64_t position) noexcept: M_position(position) { }
    constexpr void operator ++ () noexcept { ++M_position; }
    constexpr bool operator != (iterator other) const noexcept { return M_position != other.M_position; }
    constexpr int64_t operator * () const noexcept { return M_position; }
  };

  class reverse_iterator {
  private:
    int64_t M_position;
  
  public:
    constexpr reverse_iterator(int64_t position) noexcept: M_position(position) { }
    constexpr void operator ++ () noexcept { --M_position; }
    constexpr bool operator != (reverse_iterator other) const noexcept { return M_position != other.M_position; }
    constexpr int64_t operator * () const noexcept { return M_position; }
  };
  
private:
  const iterator M_first, M_last;

public:
  constexpr range(int64_t first, int64_t last) noexcept: M_first(first), M_last(std::max(first, last)) { }
  constexpr iterator begin() const noexcept { return M_first; }
  constexpr iterator end() const noexcept { return M_last; }
  constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(*M_last - 1); } 
  constexpr reverse_iterator rend() const noexcept { return reverse_iterator(*M_first - 1); } 
};

/**
 * @title Range
 */
#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/rev.cpp"

#include <type_traits>
#include <iterator>
#line 6 "/Users/kodamankod/Desktop/cpp_programming/Library/other/rev.cpp"

template <class T>
class rev_impl {
public:
  using iterator = decltype(std::rbegin(std::declval<T>()));

private:
  const iterator M_begin;
  const iterator M_end;

public:
  constexpr rev_impl(T &&cont) noexcept: M_begin(std::rbegin(cont)), M_end(std::rend(cont)) { }
  constexpr iterator begin() const noexcept { return M_begin; }
  constexpr iterator end() const noexcept { return M_end; }
};

template <class T>
constexpr decltype(auto) rev(T &&cont) {
  return rev_impl<T>(std::forward<T>(cont));
}

/**
 * @title Reverser
 */
#line 17 "main.cpp"

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

int main() {
  i64 a, b, c, d;
  std::cin >> a >> b >> c >> d;
  std::cout << std::max({ a * c, a * d, b * c, b * d }) << '\n';
  return 0;
}


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

int main() {
  int A;
  int B;
  cin >> A >> B;
  int v = 0;
  for (int i = 0; A <= B; i++) {
    if (A / 10000 == A % 10){
      if (A % 10000 / 1000 == A % 100 / 10){
        v++;
      }
    }
    A++;
  }
  cout << v << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010];
int B[100010];
P p[100010];

signed main(){
	cin>>N;
	REP(i,N+1){
		cin>>A[i];
	}
	REP(i,N){
		cin>>B[i];
	}
	int ans=0;
	REP(i,N){
		if(B[i]>=A[i]){
			B[i]-=A[i];
			ans+=A[i];
			A[i]=0;
		}
		else{
			A[i]-=B[i];
			ans+=B[i];
			continue;
		}
		if(B[i]>=A[i+1]){
			B[i]-=A[i+1];
			ans+=A[i+1];
			A[i+1]=0;
		}
		else{
			A[i+1]-=B[i];
			ans+=B[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
// AOJ Volume 0 Problem 0062

#include <stdio.h>
#include <string.h>

int main(void)
{
    char in_str[101];
	int n;
	int len;
	int flg;
	int i;
	
	n = 0;
	while (scanf("%s", &in_str) != EOF){
		len = strlen(in_str);

		flg = 1;
		for (i = 0; i < len; i++){
			if (in_str[i] != in_str[len - i - 1]){
				flg = 0;
				break;
			}
			if (i >= len - i - 1){
				break;
			}
		}
		
		n += flg;
	}

	printf("%d\n", n);
	
	return (0);
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const double DET = 0.00000000000001;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

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

	int idx = 0;

	vector<int> ans;
	for (int i = 0; i < N; i++) {
		int count = 1;
		for (int j = 1; i + j < N; j++) {
			if (A[i] == A[i + j]) {
				count++;
				if (i + j == N - 1) {
					ans.emplace_back(count);
					break;
				}
			}
			else {
				ans.emplace_back(count);
				break;
			}
		}

		i += count - 1;

		if (i == N - 1 && count == 1) {
			ans.emplace_back(1);
		}

	}

	sort(ans.begin(), ans.end(), greater<int>());
	for (int i = 1; i < ans.size(); i++) {
		ans[i] += ans[i - 1];
	}

	if (K < ans.size()) {
		cout << ans[ans.size() - 1] - ans[K - 1];
	}
	else {
		cout << 0;
	}
}




Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
 
int main() 
{
    string s1,s2;
    cin>>s1>>s2;
    int ans=0;
    if(s1==s2.substr(0,s1.length()))
    {
        ans=1;
    }
    if(ans)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    
        
        
    return 0;
}


Measured memory_bytes: 3580
<?php
list($A, $B, $Q) = explode(" ", trim(fgets(STDIN)));
$A = intval($A);
$B = intval($B);
$Q = intval($Q);
for($i = 0; $i < $A; $i++){
    $aArray[] = intval(fgets(STDIN));
}
array_unshift($aArray, -10**18);
$aArray[] = 10**18;
for($i = 0; $i < $B; $i++){
    $bArray[] = intval(fgets(STDIN));
}
array_unshift($bArray, -10**18);
$bArray[] = 10**18;

for($i = 0; $i < $Q; $i++){
    $qArray[] = intval(fgets(STDIN));
}

foreach($qArray as $q){
    $min = 10**18;
    $a = bsl($aArray, $q);
    $b = bsl($bArray, $q);
    foreach([$aArray[$a], $aArray[$a+1]] as $a1){
        $p3 = $bArray[$b];
        $p4 = $bArray[$b+1];
        $min = min($min, abs($q - $a1) + abs($a1 - $p3));
        $min = min($min, abs($q - $a1) + abs($a1 - $p4));
    }
    foreach([$bArray[$b], $bArray[$b+1]] as $b1){
        $p3 = $aArray[$a];
        $p4 = $aArray[$a+1];
        $min = min($min, abs($q - $b1) + abs($b1 - $p3));
        $min = min($min, abs($q - $b1) + abs($b1 - $p4));
    }
    printf("%d\n", $min);
}

//二分探索　target以下で最大の値の場所を返す
function bsl($nums, $target) {
    $size = count($nums);
    $min = 0; 
    $max = $size - 1;
    while(true){
        $center = floor(($min + $max) / 2);
        $centerValue = $nums[$center];
        if($target == $centerValue){
            return $center;
        }elseif($target > $centerValue){
            $min = $center + 1;
        }else{
            $max = $center;
        }
        if($min == $max){
            $center = floor(($min + $max) / 2);
            $centerValue = $nums[$center];
            if($centerValue == $target){
                return $center;
            }elseif($centerValue < $target){
                return $center;
            }else{
                return $center-1;
            }
        }
    }
}


Measured memory_bytes: 18928
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  string s1,s2; cin >> s1 >> s2;
  cout << s2+s1;

  

  return 0;
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  vector<pair<ll, ll>> a(n);
  for (auto& t : a) {
    cin >> t.second >> t.first;
  }
  sort(a.begin(), a.end());

  ll t = 0;
  for (int i = 0; i < n; i++) {
    t += a[i].second;
    if (t > a[i].first) {
      cout << "No\n";
      return;
    }
  }

  cout << "Yes\n";
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 

using namespace std;

char s[200010];

int main()
{
	scanf("%s", s);
	int len = strlen(s);
	
	long long BCCount = 0;
	long long count = 0;
	//倒序找A
	int pA = len - 1;
	
//	
//	while ((pA >= 0) && (s[pA] != 'A'))
//		pA--;
//		
//	if (pA < 0)
//	{
//		printf("%d\n", count);
//		return 0;
//	}
	
	BCCount = 0;
//	int pB = pA + 1;
//	while (((pB + 1) < len) && (s[pB] == 'B') && (s[pB] == 'C'))
//	{
//		pB = pB + 2;
//		BCCount++;
//	}
	
	while (pA >= 0)	//不用担心之前的找不到——肯定找不到 
	{
		if (s[pA] == 'A')
		{
			count = count + BCCount;
			pA--;
			continue;
		}
		
		if ((pA - 1 >= 0) && (s[pA - 1] == 'B') && (s[pA] == 'C')){
			BCCount++;
			pA = pA - 2;
			continue;
		}
		else
		{
			BCCount = 0;
			pA--;
		}
	}
	
	
	printf("%lld\n", count);
	
	return 0;
}


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

int main() {
	string s;
  	int ans = 0;
    
    cin >> s;
  
  for(int i = 0; i < 3;i++){
    if(s[i] == '1') ans++;
  }
  
  cout << ans << endl;
    
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;


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

  int n,m;
  cin >> n >> m;
  
  vector <ll>a[8]; 
  
  REP(i,n){
    ll x,y,z;
    cin >> x >> y >> z;
      a[0].push_back(x + y - z);
      a[1].push_back(-x + y - z);
      a[2].push_back(x + y + z);
      a[3].push_back(-x + y + z);
      a[4].push_back(x - y - z);
      a[5].push_back(-x - y - z);
      a[6].push_back(x - y + z);
      a[7].push_back(-x - y + z);
  }
  

 REP(i,8){
   sort(a[i].begin(),a[i].end());
 }
  
  ll ans = 0;

  REP(i,8){
    ll sum = 0;
    vector<ll> b;
    REP(j,m){
      sum += a[i][n-1-j];
    }
    ans = max(ans,sum);
}
  
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


string s, t;

void solve()
{
    cin >> s >> t;
    cout << t << s;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

int main() {
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if(U == S){
        A--;
    }
    else if(U == T){
        B--;
    }
    cout << A << " " << B;
}


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

long long div(long long i){
	return (i+1)/2;
}
int main() {
	int n;
	long long x;
	cin >> n >> x;
	long long incP[n+1],incA[n+1];
	incP[0] = 1;
	incA[0] = 1;
	for(int i=1;i<n+1;i++){
		incP[i] = incP[i-1]*2+1;
		incA[i] = incA[i-1]*2+3;
	}
	long long ate = 0;
	for(int i=n;i>0;i--){
		if(div(incA[i])==x){
			ate+=1+incP[i-1];
			x=0;
		}
		else if(div(incA[i])<x){
			ate+=1+incP[i-1];
			x-= div(incA[i]);
		}
		else{
			if(x>0)
				x--;
		}
	}
		if(div(incA[0])==x){
			ate+=1;
			x=0;
		}
		else if(div(incA[0])<x){
			ate+=1;
			x-= div(incA[0]);
		}
		else{
			x--;
		}
	cout << ate << endl;
	return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N, M, C;
	
	cin >> N >> M >> C;
	
	int A[N][M], B[M];
	
	rep(i, M)
		cin >> B[i];
		
	int ans = 0;
	rep(i, N){
		int count = C;
		rep(j, M){
			cin >> A[i][j];
			count += A[i][j] * B[j];
		}
		if(count > 0)
			ans++;
	}	
	
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    int k;
    cin>>n>>k;
    int a[n];
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int sum = 0;
    for(int i = 0;i<k;i++)
    {
        sum = sum+a[i];
    }
    cout<<sum;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
using namespace std;
const int INF=100000000;
typedef complex<double> P;
// e_ÔÌ£
double dist[22][22];
// e_ÌÀW
vector<P> points;
int n,hx,hy,dx,dy;
bool ok=false;
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

// »ÝÌê©çßÄÂ\ÈÅ¬ÊßbðÔ·
void dfs(int s,int cp,double passedSec){
    if(ok)
        return;
    else if(s==0){
        ok=true;
        return;
    }
    for(int i = 0; i < n; i++){
        // Ü¾rbgª1ÈçÎ
        if((s>>i)&1){
            // áCªB·éOÉTõÂ\©Ç¤©ð`FbN
            double dt=dist[cp][i];
            // ¤©çÚ®æÖÌ¼aðæ¾
            double r=dist[n+1][i];
            // àµ¼aªz¦Ä¢½ç,}ëè
            if(dt+passedSec>r||EQ(dt+passedSec,r))
                return;
        }
    }
    for(int i = 0; i < n; i++){
        // Ü¾rbgª1ÈçÎ
        if((s>>i)&1){
            // áCªB·éOÉTõÂ\©Ç¤©ð`FbN
            double dt=dist[cp][i];
            // ¤©çÚ®æÖÌ¼aðæ¾
            double r=dist[n+1][i];
            dfs((s&(~(1<<i))),i,dt+passedSec);
        }
    }
}


int main(){
    while(cin>>n>>hx>>hy>>dx>>dy&&!(n==0&&hx==0&&hy==0&&dx==0&&dy==0)){
        points.clear();
        ok=false;
        // EÒÌúÊu
        for(int i = 0; i < n; i++){
            int x,y;
            cin>>x>>y;
            P p=P(x,y);
            points.push_back(p);
        }
        points.push_back(P(hx,hy));
        points.push_back(P(dx,dy));
        for(int i = 0; i < points.size(); i++){
            for(int j = 0; j < points.size(); j++){
                //dist[i][j]=sqrt((double)(points[i].first-points[j].first)*(points[i].first-points[j].first)
                //    +(points[i].second-points[j].second)*(points[i].second-points[j].second));
                dist[i][j]=abs(points[i]-points[j]);
            }
        }
        dfs(((1<<n)-1),n,0.0);
        if(ok)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }

    return 0;
}

Measured memory_bytes: 0
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let x: isize = iterator.next().unwrap().parse().unwrap();

    let diffs: Vec<isize> = (0..n)
        .map(|_| (iterator.next().unwrap().parse::<isize>().unwrap() - x).abs())
        .collect::<Vec<isize>>();

    if diffs.len() == 1 {
        return diffs[0].to_string();
    }

    let mut ans: isize = gcd(diffs[0], diffs[1]);
    for i in 2..n {
        ans = gcd(ans, diffs[i]);
    }

    return ans.to_string();
}

fn gcd(m: isize, n: isize) -> isize {
    if n > m {
        gcd(n, m)
    } else if n == 0 {
        m
    } else {
        gcd(n, m % n)
    }
}


Measured memory_bytes: 6396
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int n, l;
  vector<string> s;
  cin >> n >> l;
  REP(i, n) {
    string in_s;
    cin >> in_s;
    s.push_back(in_s);
  }
  sort(s.begin(), s.end());
  string ans;
  REP(i, n) {
    ans += s[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define pb(x)                       push_back(x)
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const int MAXN = 3e3 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;
double p[MAXN];
double dp[MAXN][MAXN];
ll n;


int main()
{
    fast_io;
    cin >> n;
    for (int i = 1; i <= n;i++){
        cin >> p[i];
    }
    dp[0][0] = 1;
    for (int i = 1;i <= n;i++){
        dp[i][0] = dp[i - 1][0] * ((double)1 - p[i]);
        for (int j = 1; j <= i;j++){
            dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * ((double) 1 - p[i]);
        }
    }
    /*for (int i = 1; i <= n;i++){
        cout << ":: ";
        for (int j = 0;j <= n;j++){
            cout << dp[i][j] << tab;
        }
        cout << endl;
    }*/
    double ans = 0;
    for (int i = (n + 1) / 2; i <= n;i++){
        ans += dp[n][i];
    }
    cout << setprecision (15)<< ans << endl;
}


Measured memory_bytes: 69120
n,m = map(int, input().split())
AL = []
for i in range(n):
 ALI = list(map(int, input().split()))
 AL.append(ALI)

BL = []
for i in range(m):
 BL.append(int(input()))

for i  in AL:
 Ci = 0
 for (j, ai) in enumerate(i):
  Ci += ai * BL[j]
 print(Ci)

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll S, W;
    cin >> S >> W;
    cout << (S <= W ? "unsafe\n" : "safe\n");

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;


int main()
{
  fastio
    string s;
    cin >> s;
    if(count(all(s), '7')) cout << "Yes\n";
        else cout << "No\n";  


  return 0;
}




Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  if(S[S.size()-1]!='s') S += 's';
  else {
    S += 'e';
    S += 's';
  }
  cout<<S<<endl;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

struct UnionFind
{
	vector<int> par;
	UnionFind(int n) :par(n, -1) {}
	int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	void unite(int x, int y)
	{
		x = find(x); y = find(y);
		if (x == y) return;
		if (par[y] < par[x]) swap(x, y);
		if (par[x] == par[y]) par[x]--;
		par[y] = x;
		if (find(x) != find(y)) par[find(y)] = x;
	}
	int count()
	{
		int cnt = 0;
		REP(i, par.size()) if (par[i] < 0) cnt++;
		return cnt;
	}
	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};


int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m; cin >> n >> m;
	vector<vi> v(n);
	REP(i, m)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
	}
	for (auto &w : v) sort(ALL(w));
	int l = 0;
	int ans = 0;
	REP(i, n)
	{
		if (i < l) continue;
		if (v[l].empty())
		{
			l++;
			continue;
		}
		int t = v[l][0];
		FOR(j, i + 1, n)
		{
			if(!v[j].empty()) chmin(t, v[j][0]);
		}
		ans++;
		l = t;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
N, K = map(int, input().split())

num = [0] * K
for i in range(1, N + 1):
    num[i % K] += 1

ans = 0
for a in range(K):
    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K == 0:
        ans += num[a] * num[b] * num[c]
print(ans)


Measured memory_bytes: 10260
#include <cstdio>

int main(){
	int N, K, P;
	
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d %d", &K, &P);
		if(K % P == 0){
			printf("%d\n", P);
		}else {
			printf("%d\n", K % P);
		}
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int s1 = sc.nextInt();
   int s2 = sc.nextInt();
   if(s1%3==0||s2%3==0||(s1+s2)%3==0)System.out.println("Possible");
   else System.out.println("Impossible");
 }
}

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

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    for(int i = 1;i<=N;i++){
        if(i%3==0 || i%5==0) continue;
        ans+=i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main()
{
    char t;
    bool c = false,f = false;
    while(cin >> t)
    {
        if(t == 'C')
        {
            c = true;
            continue;
        }
        if(t == 'F' && c)
        {
            f = true;
        }
    }
    if(c && f)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String s = in.next();
		System.out.println(solve(s));
		in.close();
	}

	private static int solve(String s) {
		int r = 0;
		for (int i = 0; i < s.length(); i++)
			if (s.charAt(i) == '+')
				r++;
			else
				r--;
		return r;
	}
}

Measured memory_bytes: 20820
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc091_a.cpp
 * time   : Thu Apr 30 18:11:25 2020
 * quest  : A - Two Coins
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((a + b) >= c ? "Yes" : "No") << "\n";
  return 0;
}


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

#define int long long

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

using namespace std;

signed main()
{
    cout << fixed << setprecision(10);

    vector<vector<bool>> exist(4, vector<bool>(14, false));
    map<char, int> m;
    m['S'] = 0; m['H'] = 1; m['C'] = 2; m['D'] = 3;
    char mark[] = {'S', 'H', 'C', 'D'};
    int n; cin >> n;
    REP(i, n)
    {
        char c;
        int k;
        cin >> c >> k;
        exist[m[c]][k] = true;
    }
    vector<pair<int , int>> ans;
    REP(i, 4)
    {
        for(int j = 1; j <= 13; j++)
        {
            if(!exist[i][j]) ans.push_back(make_pair(i, j));
        }
    }
    sort(ans.begin(), ans.end());
    REP(i, ans.size()) cout << mark[ans[i].first] << " " << ans[i].second << endl;
}


Measured memory_bytes: 3020
// ITP2_1_A Vector

import java.util.Arrays;
import java.util.Scanner;

class Vector {
  int[] A;
  int length = 0;

  Vector(int n) {
    A = new int[n];
  }

  void add(int x) {
    if (length == A.length) {
      A = Arrays.copyOf(A, length * 2);
    }
    A[length] = x;
    length++;
  }

  // pre : i < length
  int get(int i) {
    return A[i];
  }

  // pre : length > 0
  void deleteBack() {
    length--;
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int q = sc.nextInt();
    Vector v = new Vector(20);
    for (int i = 0; i < q; ++i) {
      switch (sc.nextInt()) {
        case 0:
          v.add(sc.nextInt());
          break;
        case 1:
          System.out.println(v.get(sc.nextInt()));
          break;
        case 2:
          v.deleteBack();
          break;
      }
    }
  }
}



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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int A, B, M;
int a[110000], b[110000];
int x[110000], y[110000], c[110000];
signed main() {
    cin >> A >> B >> M;
    reps(i, A) { cin >> a[i]; }
    reps(i, B) { cin >> b[i]; }
    reps(i, M) { cin >> x[i] >> y[i] >> c[i]; }
    int a_min = LLONG_MAX, b_min = LLONG_MAX;
    reps(i, A) { chmin(a_min, a[i]); }
    reps(i, B) { chmin(b_min, b[i]); }
    int ans = a_min + b_min;
    reps(i, M) {
        chmin(ans, a[x[i]] + b[y[i]] - c[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4352
inpl = lambda: list(map(int,input().split()))
N = int(input())
L = inpl()
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i] == L[j]:
            continue
        for k in range(j+1,N):
            if L[j] == L[k]:
                continue
            if L[k] < L[i] + L[j]:
                ans += 1
print(ans)


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

vector<int> ans;

void solve(int n) {
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int res = 0;
    for (int i = n-1; i > 0; i--) {
        for (int j = 0; j < i; j++) {
            if (a[j] > a[j+1]) {
                swap(a[j], a[j+1]);
                res++;
            }
        }
    }
    ans.push_back(res);
    return ;
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        solve(n);
    }

    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3064
from math import factorial
 
N = int(input())
x = list(map(int, input().split()))
mod = 10**9 + 7
x_dis = [x[i+1] - x[i] for i in range(N-1)]
ans = 0
m = N-1
fac = factorial(m) % mod
tmp = fac
for i in range(m):
    ans += x_dis[i] * tmp
    ans %= mod
    tmp += (fac*pow((i+2),(mod-2), mod))%mod
print(ans)

Measured memory_bytes: 15020
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    long a,b,c;
    cin >> a >> b >> c;
   long ta,tb,tc; 
   long ans = 0;
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
        if(a == b && b == c){
            ans = -1;
            break;
            }
        ta = (b + c) / 2;
        tb = (a + c) / 2;
        tc = (a + b) / 2;
        a = ta;
        b = tb;
        c = tc;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

typedef struct {
  int par, sib, lch, rch, depth, height;
} node;

#define MAX_N 25

int n;
node T[MAX_N];

int max(int a, int b) {
  return a > b ? a : b;
}

int dfs(int u, int depth) {
  int hl = 0, hr = 0;
  T[u].depth = depth;
  if(T[u].lch != -1) hl = dfs(T[u].lch, depth+1) + 1;
  if(T[u].rch != -1) hr = dfs(T[u].rch, depth+1) + 1;
  return T[u].height = max(hl, hr);
}

int main() {
  int root = -1;
  int i;

  for(i = 0; i < MAX_N; i++) {
    T[i] = (node){-1, -1, -1, -1, -1, -1};
  }

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    int id, lch, rch;
    scanf("%d %d %d", &id, &lch, &rch);
    T[id].lch = lch;
    T[id].rch = rch;
    if(lch != -1) {
      T[lch].sib = rch;
      T[lch].par = id;
    }
    if(rch != -1) {
      T[rch].sib = lch;
      T[rch].par = id;
    }
  }

  for(i = 0; i < n; i++) {
    if(T[i].par == -1) root = i;
  }

  dfs(root, 0);

  for(i = 0; i < n; i++) {
    char type[256];
    int deg = 0;
    if(T[i].par == -1) strcpy(type, "root");
    else if(T[i].lch == -1 && T[i].rch == -1) strcpy(type, "leaf");
    else strcpy(type, "internal node");
    if(T[i].lch != -1) deg++;
    if(T[i].rch != -1) deg++;
    printf("node %d: ", i);
    printf("parent = %d, ", T[i].par);
    printf("sibling = %d, ", T[i].sib);
    printf("degree = %d, ", deg);
    printf("depth = %d, ", T[i].depth);
    printf("height = %d, ", T[i].height);
    puts(type);
  }

  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}

struct Edge {
    LL dst, sum;
};
typedef vector<Edge> Node;
typedef vector<Node> Graph;

Graph G;
const int MAX_N = 100010;
const LL INF = 1e18;
LL value[MAX_N];
int pos_value[MAX_N];
LL initial;
LL lower;
LL upper;
bool dfs(const Graph& G, int u, LL A, int positive) {
    if (value[u] != INF) {
        if (positive == pos_value[u]) {
            if (value[u] == A) {
                return false;
            } else {
                initial = -1; // TODO: OK?
                return true;
            }
        } else {
            LL D = (positive ? value[u] - A : A - value[u]);
            if (D >= 0 && D % 2 == 0) {
                initial = D / 2;
            } else {
                initial = -1;
            }
            return true;
        }
    } else {
        value[u] = A;
        pos_value[u] = positive;
        if (positive) {
            lower = max(lower, -A + 1);
        } else {
            upper = min(upper, A - 1);
        }

        for(auto e : G[u]) {
            if (dfs(G, e.dst, e.sum - A, !positive)) {
                return true;
            }
        }
    }
}

int main(){
    iostream_init();
    int N, M;
    cin >> N >> M;
    G = Graph(N);
    initial = INF;
    lower = 1;
    upper = 1e10;
    REP(i, N) value[i] = INF;
    memset(pos_value, -1, sizeof(pos_value));
    REP(i, M) {
        LL u, v, s;
        cin >> u >> v >> s;
        u--; v--;
        G[u].push_back({ v, s });
        G[v].push_back({ u, s });
    }
    dfs(G, 0, 0, true);
    if (initial == -1) {
        cout << 0 << endl;
    } else if(initial != INF) {
        // try put
        queue<int> que;
        que.push(0);
        vector<LL> vs(N, -INF);
        vs[0] = initial;
        bool ok = true;
        while(!que.empty()) {
            int u = que.front(); que.pop();
            if (vs[u] < 0) {
                ok = false;
            }
            for(auto e : G[u]) {
                if (vs[e.dst] == -INF) {
                    vs[e.dst] = e.sum - vs[u];
                    que.push(e.dst);
                }
            }
        }
        for(int i = 0; i < N; i++) assert(vs[i] != -INF);
        for(int i = 0; i < N; i++) {
            if (vs[i] < 0) ok = false;
            for(auto e : G[i]) {
                if (vs[i] + vs[e.dst] != e.sum) {
                    ok = false;
                }
            }
        }

        cout << (ok ? 1 : 0) << endl;
    } else {
        LL D = max(upper - lower + 1, 0LL);
        cout << D << endl;
    }
    return 0;
}


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

#define 	pi 				3.1415926536
#define 	mod 			1000000007
#define 	lli 			long long int
#define 	rep(i, n) 		for(int i = 0 ; i < n ; i++)
#define 	repn(i, n) 		for(int i = n - 1 ; i >= 0 ; i--)
#define 	loop(i, a, b)	for(int i = a ; i < b ; i++)
#define 	mod1 			1000003
#define 	hello 			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define 	F 				first
#define 	S 				second
#define 	pb 				push_back
#define 	mp				make_pair
#define 	B 				begin()
#define 	E 				end()
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define 	vi 				vector<int>
#define 	vs 				vector<string>
#define 	print(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

// fixed<<setprecision(9);
// max_element(mp.begin(), mp.end(), compare);
// __gcd(a, b);

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }

int n, m;

int main()
{
	int n, x, l;
	cin>>n;
	vector< pair < int , int > > vec(n);

	rep(i, n)
	{
		cin>>x>>l;
		vec[i].F = x - l;
		vec[i].S = x + l;
	}

	sort(all(vec));

	int end = vec[0].S, count = 0;

	loop(i, 1, n)
	{
		if(vec[i].F < end)
		{
			end = min(end, vec[i].S);
			count++;
		}
		else
			end = vec[i].S;
	}

	cout<<n - count<<nl;
}

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

int main()
{
  int N;
  int t[110000], x[110000], y[110000];
  cin >> N;
  t[0] = x[0] = y[0] = 0;
  for (int i = 0; i < N; i++)
  {
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  }
  
  bool can = true;
  for (int i = 0; i < N; i++)
  {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist)
      can = false;
    if (dist % 2 != dt % 2)
      can = false;
  }
  
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 1408
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

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

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

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

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    aa: [usize; n]
  }
  let mut dp = vec![vec![vec![0.0; n+1]; n+1]; n+1];
  let mut pop = vec![0usize; 4];
  for &a in aa.iter() {
    pop[a] += 1;
  }
  dp[pop[3]][pop[2]][pop[1]] = 1.0;
  let mut ans = 0.0;
  for three in (0..n+1).rev() {
    for two in (0..n+1).rev() {
      for one in (0..n+1).rev() {
        let dish = (one + two + three) as f64;
        if one + two + three > 0 {
          ans += dp[three][two][one] * n as f64 / dish;
        }
        if three > 0 && two + 1 <= n {
          dp[three-1][two+1][one] += dp[three][two][one] * (three as f64) / dish;
        }
        if two > 0 && one + 1 <= n {
          dp[three][two-1][one+1] += dp[three][two][one] * (two as f64) / dish;
        }
        if one > 0 {
          dp[three][two][one-1] += dp[three][two][one] * (one as f64) / dish;
        }
      }
    }
  }
  println!("{:.15}", ans);
}


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

#define db double
#define RG register
#define ll long long

inline int gi()
{
	RG int r=0; RG bool b=true; RG char c=getchar();
	while (c < '0' || c > '9')
		c == '-' ? b=false : 0, c=getchar();
	while (c >= '0' && c <= '9')
		r=(r<<1)+(r<<3)+c-'0', c=getchar();
	return b ? r : -r;
}

const int N=142857,inf=1<<30;

char s[200050];
int n,cnt[30];

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	int i,j,k;
	ll ans;
	for (i=ans=1; i<=n; ++i)
		{
			j=s[i]-'a';
			ans+=cnt[j];
			for (k=0; k<26; ++k)
				if (k != j)
					cnt[k]++;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int N;
    cin >> N;
    int count = 0;
    for(int i = 1; i <= N; i++) if(to_string(i).size() % 2) count++;
    cout << count << endl;
}


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

using namespace std;

typedef long long ll;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

    int n, m;
    cin >> n >> m;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] /= 2;
    }

    int lp2;
    for (int i = 0; i < n; i++) {
        int p2 = 0;
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            p2++;
        }

        if (i > 0 && p2 != lp2) {
            cout << 0 << endl;
            return 0;
        }

        lp2 = p2;
    }

    for (int i = 0; i < lp2; i++) {
        m /= 2;
    }

    ll lcm = 1;
    for (int i = 0; i < n; i++) {
        int g = gcd(lcm, a[i]);
        lcm = lcm * a[i] / g;
        if (lcm > m) {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << (m + lcm) / (2 * lcm) << endl;

    return 0;
}


Measured memory_bytes: 640
n = int(input())
s = [int(x) for x in input().split()]

cnt = 0
for i in range(n) :
    for j in range(n - 1, i, -1) :
        if s[j - 1] > s[j] :
            s[j - 1], s[j] = s[j], s[j - 1]
            cnt += 1     
print(" ".join(map(str, s)))
print(cnt)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    ll n,n2,ans = 1000000000000;
    cin >> n;
    n2 = n;
    ll a = 1,b = 1;
    map<ll,ll> mp;
    vector<ll> v;
    for (ll i = 1; i*i <= n; ++i) {
        if(n%i == 0){
            ans = min(ans,i+n/i-2);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <ctype.h>

using namespace std;

int main(void){
	char c;
	while((c = getchar()) != '\n'){
		if(islower(c)){
			printf("%c",'A' + c - 'a');
		}else{
			printf("%c",c);
		}
	}
	printf("\n");
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n;
int t[300001];

signed main() {
  cin >> n;
  rep(i, 0, n) cin >> t[i];

  int mx = 0;
  rep(i, 0, n) {
    if(i * 10 > mx) {
      cout << "no" << endl;
      return 0;
    }
    mx = max(mx, i * 10 + t[i]);
  }
  mx = 0;
  int cu = 0;
  dep(i, n - 1, 0) {
    if(cu * 10 > mx) {
      cout << "no" << endl;
      return 0;
    }
    mx = max(mx, cu * 10 + t[i]);
    cu++;
  }
  cout << "yes" << endl;
}



Measured memory_bytes: 5568
#include<stdio.h>

int main(){
    int i, j, k;
    int N, b[110];
    int ans=0, a[110];
    int tmp;

    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%d", &b[i]);
        if(b[i]>i+1){
            ans=1;
        }
    }

    if(ans==1){
        printf("-1");
    }else{
        for(i=N; i>0; i--){
            for(j=0; j<i; j++){
                if((j+1)==b[j]){
                    tmp=j+1;
                }
            }
            //printf("%d\n", tmp);
            if(tmp==0){
                ans=1;
            }else{
                a[i-1]=tmp;
                for(k=tmp; k<i; k++){
                    b[k-1] = b[k];
                }
            }
        }
        if(ans==1){
            printf("-1");
        }else{
            for(j=0; j<N; j++){
                printf("%d\n", a[j]);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

int main(void){
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> B;
    for(int i=0; i<m; i++){
        int b; cin >> b;
        B.push_back(b);
    }
    vector< vector<int> > A(n);
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            int a; cin >> a;
            A[i].push_back(a);
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        int flag = c;
        for(int j=0; j<m; j++){
            flag += A[i][j]*B[j];
        }
        if(flag > 0) ans += 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256