akhauriyash/Code-Regression huggingface dataset:
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     ll a=100;
     ll ans=0;
     ll x;cin>>x;
     while(a<x){

        a+=(a/100);
        ans++;
     }
     cout<<ans<<endl;
     return 0;

}
///Alhamdulillah


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;


int main() {
  int n; cin >> n;
  int tmp=n;
  int digit =0;
  while(tmp>0){
    ++digit;
    tmp/=10;
  }
  int cnt =0;
  for(int i=digit;i>0;--i){
    if(i%2==0) continue;
    if(i==1){
      cnt +=min(n,9);
    } else if(i==digit){
      cnt += n-(int)pow(10,i-1)+1;
    } else {
      cnt += 9*(int)pow(10,i-1);
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
-- Maximum Profit
main = getContents >>= putStrLn . solve

solve :: String -> String
solve = show .  maxProf 0 0 . map read . tail . lines

maxProf :: Int -> Int -> [Int] -> Int
maxProf maxx _ [] = maxx
maxProf 0 0 (x:xs) = maxProf (-1000000000) x xs
maxProf maxx minx (x:xs) = maxProf maxx' minx' xs
  where
    maxx' = max maxx (x - minx)
    minx' = min minx x

Measured memory_bytes: 5368
package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)

	flg := false
	count := 0
	for _, rune := range s {
		if rune == 'R' {
			if flg {
				count++
			} else {
				flg = true
				count = 1
			}
		} else {
			flg = false
		}
	}

	fmt.Print(count)
}

Measured memory_bytes: 1832
#include<iostream>
using namespace std; // 575

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(A, B) << " " << max(0, A + B - N);
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

最大はAとBの小さいほう
最小は、N-A人が全てBを買ったとすると残りより、0, B-(N-A)になる
*/

Measured memory_bytes: 256
#ifdef loc
    #include "codes/loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 200005;


int a[N], b[N], c[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    rep(i, 1, n + 1) {
        cin >> a[i];
        b[i] = max(b[i - 1], a[i]);
    }
    rep(i, n + 1, 1) {
        c[i] = max(c[i + 1], a[i]);
    }
    rep(i, 1, n + 1) {
        int ans = max(b[i - 1], c[i + 1]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3968
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#include "./Lib/Timer.hpp"
#include "./Lib/sample.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

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



signed main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << ((a == c) ? 0 : 1) << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e7;
ll n, m, ans;
vector<ll> edge[1100];
ll pre[1100];
stack<ll> path;

int bfs(int s) {
  bool done[1100] = {};
  queue<P> q;
  
  q.push(P(s, 0));
  
  while (q.size()) {
    P p = q.front();
    q.pop();
    int u = p.first;
    int dist = p.second + 1;
    for (int v: edge[u]) {
      if (done[v]) continue;
      pre[v] = u;
      if (v == s) return dist;
      q.push(P(v, dist));
      done[v] = true;
    }
  }
  return INF;
}

int main() {
  cin >> n >> m;  
  for (int i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    edge[a].push_back(b);
  }
  
  ll min_dist = INF, start;
  for (int i = 0; i < n; i++) {
    ll dist = bfs(i);
    if (dist < min_dist) {
      min_dist = dist;
      start = i;
    }
  }
  
  if (min_dist == INF) {
    cout << -1 << endl;
    return 0;
  }
  
  cout << min_dist << endl;
  
  bfs(start);
  path.push(pre[start]);
  while (path.top() != start) {
    path.push(pre[path.top()]);
  }
  while (path.size()) {
    cout << path.top() + 1 << endl;
    path.pop();
  }
  
  return 0;
}


Measured memory_bytes: 256
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n = int(input())
    as_ = [int(input()) for _ in range(n)]

    counter_a = collections.Counter(as_)
    ans = 0
    for key, count in counter_a.items():
        if count % 2 == 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 16604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String[] stringS = new String[4];

		try {
			scanner = new Scanner(System.in);
			stringS = scanner.next().split("");

			int res = 0;
			for (int i = 0; i < stringS.length; i++) {
				if (stringS[i].equals("+")) {
					res++;
				} else if (stringS[i].equals("-")) {
					res--;
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21844
N = int(input())
S = []

for i in range(N):
    s = int(input())
    S.append(s)

a = sum(S)
ans = 0

if a % 10 != 0:
    ans = a
else:
    T = [s for s in S if s%10!=0]
    if len(T) == 0:
       ans = 0
    else:
        ans = a-min(T)

print(ans)

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

int main()
{
    string s, t;
    cin >> s >> t;
    int len_s = s.length();
    int len_t = t.length();
    int mn = 2000;
    for(int i = 0; i <= len_s - len_t; i++) {
        int cnt = 0;
        for(int j = 0; j < len_t; j++) {
            cnt += s[i+j] != t[j];
        }
        mn = min(mn, cnt);
    }
    printf("%d\n", mn);
}


Measured memory_bytes: 3728
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int i, n;
  cin >> n;
  for(i=ceil(sqrt(n)); i<=n&&i<=9; i++)
    if(!(n%i)){
      cout << "Yes" << endl;
      return 0;
    }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
data = [0]*n
for i in range(n):
    data[i] = input().split()
ans = 0
if n == 1:
    print(len(data[0]) - 1)
else:
    for i in range(1,int(data[0][0]) + 1):
        bool = True
        for j in range(1,n):
            if data[0][i] not in data[j][1:]:
                bool = False
        if bool:
            ans += 1
    print(ans)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);
  sort(A.begin(), A.end());
  
  vector<int> slime(N+1);
  for( int i = 0; i < N; i++ ) slime.at(i+1) = slime.at(i)+A.at(i);
  
  int ans = 1;
  for( int i = N-1; i >= 0; i-- ){
    if( slime.at(i)*2 >= A.at(i) ) ans++;
    else break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(){
  int n,y,a,b,c;
  scanf("%d%d",&n,&y);
  for(a=0;a<=n;a++){
    for(b=0;b<=n-a;b++){
      for(c=0;c<=n-a-b;c++){
        //printf("%d %d %d\n",a,b,c);
        if(((10*a+5*b+c)==(y/1000))&&(a+b+c==n)){
          printf("%d %d %d",a,b,c);
          return 0;
        }
      }
    }
  }
  printf("-1 -1 -1");
}

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

using namespace std;

int N,K;

int main(){
    cin>>N>>K;
    
    int s=1;
    int d=N;
    for(int i=0;i<N;i++){
        if(s*2-s>=K){
            d=i;
            break;
        }
        s=s*2;
    }
    for(int i=d;i<N;i++){
        s=s+K;
    }
    cout<<s<<endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
int W[110];
int main(){
  cin>>N;
  rep(i,N) cin>>W[i];
  int sum[110];
  sum[0]=0;
  rep1(i,N) sum[i]=sum[i-1]+W[i-1];
  int min=INF;
  rep1(i,N-1){
    int temp=std::abs(2*sum[i]-sum[N]);
    min=std::min(min,temp);
  }
  prin(min);
  
  return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    println!(
        "{}",
        a.iter()
            .fold((0, 0), |(sum, curr), &x| (
                sum + if curr > x { curr - x } else { 0 },
                curr.max(x)
            ))
            .0
    );
}


Measured memory_bytes: 5556
import java.util.*;

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

		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int x = scanner.nextInt();
		int count = 0;

		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for (int k = 0; k <= c; k++) {
					if (x == i * 500 + j * 100 + k * 50) {
						count++;
					}
				}
			}
		}

		System.out.println(count);

		scanner.close();
	}
}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main()
{
  long long a,b,c,t;
  cin >> a >> b >> c;
  t=c-a-b;
  if(t<=0){
    cout << "No" << endl;
    return 0;
  }
  t=t*t-4*a*b;
  if(t<=0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = readline().decode().strip()
K = int(readline())
ans = 1
for i in range(K):
    if N[i] != '1':
        ans = N[i]
        break

print(ans)


Measured memory_bytes: 18360
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

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

        for(long A=0;; A++) for(long B=0; B<=A; B++){
            if(A*A*A*A*A-B*B*B*B*B==X){
                System.out.printf("%d %d\n", A, B);
                return;
            }
            if(A*A*A*A*A+B*B*B*B*B==X){
                System.out.printf("%d %d\n", A, -B);
                return;
            }
            if(-A*A*A*A*A-B*B*B*B*B==X){
                System.out.printf("%d %d\n", -A, B);
                return;
            }
            if(-A*A*A*A*A+B*B*B*B*B==X){
                System.out.printf("%d %d\n", -A, -B);
                return;
            }            
        }
    }
}


Measured memory_bytes: 35596
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s string

	fmt.Scanf("%d\n%s", &n, &s)

	ss := []rune(s)

	max := 0
	for i := 1; i < n; i++ {
		s1 := string(ss[0:i])
		s2 := string(ss[i:n])
		if current := count(s1, s2); current > max {
			max = current
		}
	}

	fmt.Println(max)
}

func count(s1, s2 string) int {
	result := 0
	for i := 'a' + 0; i < 'a'+26; i++ {
		if strings.Contains(s1, string(i)) && strings.Contains(s2, string(i)) {
			result++
		}
	}
	return result
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
  int r,d,x,a,i;
  scanf("%d%d%d",&r,&d,&x);
  for(i=0;i<10;i++){
    a=r*x-d;
    printf("%d\n",a);
     x=a;
  }
  return 0;
}

Measured memory_bytes: 128
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <algorithm>
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#include <math.h>
#define ld long double
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>

int main()
{

int x;
int y;
cin>>x>>y;

for (int i = 0; i <= x; ++i){
	for (int j = 0; j <= x; ++j){
		if(i+j==x)
			if(2*i+4*j==y)
		{
			cout<<"Yes"<<endl;
return 0;}}}
	cout<<"No"<<endl;
   return 0;}



// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 3632
void main()
{
    long[] tmp = rdRow;
    long n = tmp[0], m = tmp[1];
    Cake[] c = n.rdCol!Cake;

    long result;
    foreach (i; 0 .. 8)
    {
        long num = i;
        bool[] lists = new bool[3];
        foreach (j; 0 .. 3)
        {
            lists[j] = num & 1;
            num >>= 1;
        }
        c.sort!((x, y) => x.comp(lists) > y.comp(lists));
        Cake total;
        foreach (j; 0 .. m)
        {
            total += c[j];
        }
        result = max(result, total.value);
    }

    result.writeln;
}

struct Cake
{
    long x, y, z;

    Cake opBinary(string op)(Cake that)
    if (op == "+" || op == "-")
    {
        Cake result;
        result.x = mixin("this.x "~op~" that.x");
        result.y = mixin("this.y "~op~" that.y");
        result.z = mixin("this.z "~op~" that.z");
        return result;
    }

    Cake opOpAssign(string op)(Cake that)
    if (op == "+" || op == "-")
    {
        return mixin("this = this "~op~" that");
    }

    long comp(bool[] arr)
    {
        return this.x * (-1) ^^ arr[0] + this.y * (-1) ^^ arr[1] + this.z * (-1) ^^ arr[2];
    }

    long value()
    {
        return this.x.abs + this.y.abs + this.z.abs;
    }
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 508
n = int(input())

s, t = list(map(str, input().split()))

s = list(s)
t = list(t)
ans = ''
cs = 0
ct = 0

for i in range(n*2):
    if i % 2 == 0:
        ans += s[cs]
        cs += 1
    else:
        ans += t[ct]
        ct += 1
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int min2(int a, int b)
{
  return (a < b) ? a : b;
}

int main(void){
  int n;
  int h[100000];
  long dp[100000];

  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &h[i]);

  dp[1] = abs(h[1] - h[0]);
  for (int i = 1; i < n; i++) {
    dp[i + 1] = min2(dp[i] + abs(h[i + 1] - h[i]), dp[i - 1] + abs\
(h[i + 1] - h[i - 1]));
  }

  printf("%ld\n", dp[n - 1]);
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#define ll long long
using namespace std;

ll mod=1000000007;
ll modpow(ll a, ll b, ll m){
    ll res=1, p=0, now=a;
    for(int i=0; b>p; ++i){
        if(b&((ll) 1<<i)){
            res=(res*now)%m;
            p |= ((ll) 1<<i);
        }
        now=(now*now)%mod;
    }
    return res;
}
ll modinv(ll a, ll m){
    return modpow(a, m-2, m);
}
ll moddiv(ll a, ll b, ll m){
    return (a*modinv(b, m))%m;
}

int main() {
	int N;
	string S;
	cin >> N >> S;
	int p=S.size();
	vector<vector<ll>> dp(N+1);
	dp[0].assign(1, 1);
	for(int i=1; i<=N; ++i){
	    dp[i].assign(i+1, 0);
	    for(int j=0; j<i; ++j){
	        dp[i][j+1]=(dp[i-1][j]*2)%mod;
	        dp[i][max(j-1, 0)]=(dp[i][max(j-1, 0)]+dp[i-1][j])%mod;
	    }
	}
	cout << moddiv(dp[N][p], modpow(2, p, mod), mod) << endl;
	return 0;
}


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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)

typedef long long ll;

int main(void) {
    int n;
    cin >> n;
    int mi, ans=-1e9;
    cin >> mi;
    REP(i,n-1){
        int r;
        cin >> r;
        ans = max(ans,r-mi);
        mi = min(mi,r);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

long long N;
int digit;  // Nの桁数
int cnt = 0;

int ref(int depth, long long x, bool a, bool b, bool c){ // a, b, c は7, 5, 3がそれぞれ1つでもあるかを表す。  
    if(depth == digit){
        if(x<=N && a && b && c){
            cnt += 1;
            //cout << x << endl;  // テスト用
            return 0;
        }
        return 0;
    }
        
    ref(digit, x, a, b, c);
    ref(depth+1, x*10+7, true, b, c);
    ref(depth+1, x*10+5, a, true, c);
    ref(depth+1, x*10+3, a, b, true);
    
    return 0;
}

int main(){
    cin >> N;
    digit = log10(N)+1;
    ref(0, 0, false, false, false);
    cout << cnt << endl;
}

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

#define ll long long
#define mx  505
#define mod 1000000009
#define lim 10000000
#define inf 2000000000
#define N 18
#define eps 100000
#define PI acos(-1)

using namespace std;

int a[30];
map<int,int>mp;

int main()
{
    ios_base::sync_with_stdio(false);
    memset(a,0,sizeof(a));
    string s,t;cin>>s>>t;

    for(int i=0;i<s.size();i++)
    {
        int c=s[i]-'a';
        a[c]++;
    }

   for(int i=0;i<30;i++)
   {
       if(a[i])
          mp[a[i]]++;
   }
   memset(a,0,sizeof(a));

   for(int i=0;i<t.size();i++)
   {
       int c=t[i]-'a';
       a[c]++;
   }

   for(int i=0;i<30;i++)
   {
       if(a[i])
	   {
	   	   mp[a[i]]--;
	   }
   }

   for(auto it:mp)
   {
   	 if(it.first==0)continue;
   	 if(it.second)
	 {
	 	cout<<"No\n";return 0;
	 }
   }

   cout<<"Yes\n";
   return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define repo(i, n) for (__typeof(n) i = 1; i <= n; i++)
#define eps 1e-6
#define pi 3.141592653589793
#define c(a) cout << a << "\n";
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX = 2e5+6;
bool prime[10000009];
int main(){
   ll n,m;
   cin>>n>>m;
   cout<<(n*m)/__gcd(n,m);
    
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input 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)*} }; }
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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
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, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        mut A: [i64; N],
    }
    let mut ans = 0;
    A.sort_by_key(|x| -x);
    for i in 0..N{
        if i%2==0{
            ans += A[i];
        }else{
            ans -= A[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
"""
C - /\/\/\/
https://atcoder.jp/contests/abc111/tasks/arc103_a

"""
import sys


from collections import Counter

def solve(n, nums):
    e_cnt = Counter(nums[::2])
    o_cnt = Counter(nums[1::2])
    e = e_cnt.most_common()
    o = o_cnt.most_common()

    ans1 = len(nums)
    ans2 = len(nums)
    if e[0][0] == o[0][0]:
        ee = e[0][1]
        oo = o[1][1] if len(o) > 1 else 0
        ans1 -= (ee + oo)
        ee = e[1][1] if len(e) > 1 else 0
        oo = o[0][1]
        ans2 -= (ee + oo)
        return min(ans1, ans2)
    else:
        return len(nums) - (e[0][1] + o[0][1])

def main(args):
    n = int(input())
    nums = [int(i) for i in input().split()]
    ans = solve(n, nums)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 21176
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e9
#define max_n 200002
#define mod (7 * 17 * (1<<23) + 1)

ll add(ll x, ll y) {
	x += y;
	if(x >= mod) return x - mod;
	return x;
}

ll mul(ll x, ll y) {
	x *= y;
	if(x >= mod) return x % mod;
	return x;
}

ll power(ll x, ll y) {
	if(y == 0) return 1;
	ll p = power(x, y/2);
	p = mul(p, p);
	if(y&1) return mul(p, x);
	return p;
}

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

	int n, r;
	cin >> n >> r;
	if(n >= 10) {
		cout << r << endl;
	}
	else {
		cout << r + 100 * (10-n) << endl;
	}
	
	return 0;
}

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

int main(void){
    char w[10];
    char t[1000],T[1001];
    int count=0;
    int i=0,x=0;
    char E[12]="END_OF_TEXT";
    while(1){
        scanf("%c",&w[count]);
        if(isupper(w[count])){
            w[count]=tolower(w[count]);
        }
        else if(w[count]=='\n'){
            break;
        }
        count++;
    }
    int k = 0;
    for(i=0;i<1000;i++){
        scanf("%c",&t[i]);
        k=0;
        if(t[i]==E[11]){
             for(k=0;t[k+i-11]==E[k];k++){
                if(k==11){
                    break;
                }
             }
        }
        if(k==11){
            break;
        }
    }
    int v;
    T[0] = 0;
    for(v=1;v<i-10;v++){
         if(isupper(t[v-1])){
            T[v]=tolower(t[v-1]);
         }else{
            T[v]=t[v-1];
         }
    }
    int u=0;
    for(i=1;i<v+2;i++){
        u = 0;
        while(T[i+u] == w[u]){
            u++;
            if(u==count){
                if(T[i+u]=='\n' || T[i+u]==' ' || T[i+u]=='.'){
                    if(T[i-1]==0 || T[i-1]==' ' || T[i-1]=='\n'){
                        x++;
                    }
                }
            }
        }
    }
    printf("%d\n",x);
    return 0; /*0?????????*/
}

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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX

typedef long long ll;
typedef pair<int, int> ii;

/*
class Node {
public:
  int num;
  int index;
  bool operator<(const Node& b) const {
    if(num < b.num) return (num < b.num);
    else return index > b.index;
  }

  Node(){
    num=0; index=0;
  }
  Node(int n, int i) : num(n), index(i){
  }
};
*/

int main(){

  string s;
  cin >>s;
  cout << s.substr(0, 4) << " " << s.substr(4) <<endl;

  return 0;
}


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

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N; 
  cin >> N;
  
  int total = findSumOfDigits(N);
  
  if (N % total == 0) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())

a = list(map(int, input().split()))  # 複数数値入力(リスト格納)
b = list(map(int, input().split()))  # 複数数値入力(リスト格納)
c = list(map(int, input().split()))  # 複数数値入力(リスト格納)

ans = 0
last = -1
for i in range(n):
    ans += b[a[i]-1]

    if last == a[i]-1:
        ans += c[a[i]-2]
        
    last = a[i]

print(ans)

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }

int main(){
	ll a , b ; 
	cin >> a >> b ; 
	if( (a+b)&1 )cout <<"IMPOSSIBLE"<<endl; 
	else cout << (a+b)/2<<endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n;
double x, s;
string y;
int main() {
	cin>>n;
	while(n--) {
		cin>>x>>y;
		if(y=="JPY") s += x;
		else s += x * 380000;
	}
	printf("%.9f", s);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    long long q,h,s,d,n,ans=0;
    cin>>q>>h>>s>>d>>n;
    s=min(min(q*4,h*2),s);
    if(n%2){n--;ans+=s;}
    n/=2;
    d=min(d,s*2);
    ans+=d*n;
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e12
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
map<string, int> m;
int n;
vector<string> vs;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

ll calc(ll a) {
	if (a == 1)return 1;
	return calc(a / 2) * 2 + 1;
}

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

	cin >> n;

	REP(i, n) {
		string s;
		cin >> s;
		vs.push_back(s);
	}
	sort(All(vs));

	int mcnt = 0;
	vector<int> vi;
	int cnt = 1;
	REP(i, n) {
		if (i!=n-1&&vs[i + 1] == vs[i]) {
			cnt++;
			continue;
		}
		if (mcnt == cnt) {
			vi.push_back(i);
		}
		else if (mcnt < cnt) {
			vi.clear();
			mcnt = cnt;
			vi.push_back(i);
		}
		cnt = 1;
	}
	REP(i, vi.size()) {
		cout << vs[vi[i]] << endl;
	}
}

Measured memory_bytes: 14704
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int N, ma, mb, MAX_A=0, MAX_B=0;
    cin >> N >> ma >> mb;
    vector<int> a(N), b(N), c(N);
    for(int i=0; i<N; i++){
        cin >> a[i] >> b[i] >> c[i];
        MAX_A=max(MAX_A, a[i]);
        MAX_B=max(MAX_B, b[i]);
    }
    
    int dp[N+1][MAX_A*N+1][MAX_B*N+1];
    int inf=1000000000;
    for(int i=0; i<=N; i++){
        for(int j=0; j<=MAX_A*N; j++){
            for(int k=0; k<=MAX_B*N; k++){
                dp[i][j][k]=inf;
            }
        }
    }
    dp[0][0][0]=0;

    for(int i=0; i<N; i++){
        for(int ac=0; ac<=MAX_A*N; ac++){
            for(int bc=0; bc<=MAX_B*N; bc++){
                if(dp[i][ac][bc]!=inf){
                    dp[i+1][ac][bc]=min(dp[i][ac][bc], dp[i+1][ac][bc]);
                    dp[i+1][ac+a[i]][bc+b[i]]=min(dp[i][ac][bc]+c[i], dp[i+1][ac+a[i]][bc+b[i]]);
                }
            }
        }
    }
    int counter=1, ans=inf;
    while(ma*counter<=MAX_A*N && mb*counter<=MAX_B*N){
        ans=min(ans, dp[N][ma*counter][mb*counter]);
        counter++;
    }
    if(ans==inf){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 25984
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

vector<bool> Eratosthenes( const int N )
{
    vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }

    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
        }
    }
    is_prime[1] = false;
    is_prime[0] = false;
    return is_prime;
}

int main(){
    llong Q;
    llong l,r;
    cin >> Q;
    vector<pair<int, int> > Query(Q);
    vector<llong> A(100001, 0);
    vector<llong> S(100002, 0);
    vector<bool>  P;
    P = Eratosthenes(100001);

    for(int i=0; i<Q; i++){
        cin >> l >> r;
        Query[i].first = l;
        Query[i].second = r;
    }
    for(int i=0; i<A.size(); i++){
        if(P[i]){
            if((i+1)%2==0 && P[(i+1)/2]){
                A[i] = 1;
            }
        }
    }
    for(int i=0; i<S.size(); i++){
        S[i+1] = S[i] + A[i];
    }
    for(int i=0; i<Query.size(); i++){
        cout << S[Query[i].second+1]-S[Query[i].first] << endl;
    }
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int A;
  for (int i; i<N; i++){
    int x;
    cin >> x;
    if (x < K-x){
      A+=(x*2);
    }
    else {
      A+=((K-x)*2);
    }
  }
  cout << A << endl;
}


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

using namespace std;

int k, n;
int a[300005];

int main()
{
    scanf("%d%d", &k, &n);
    if(k % 2 == 0)
    {
        printf("%d ", k / 2);
        for(int i = 1; i < n; i++)printf("%d ", k);
        return 0;
    }
    for(int i = 0; i < n; i++)
    {
        a[i] = k / 2 + 1;
    }
    int now = n - 1;
    for(int i = 0; i < n / 2; i++)
    {
        a[now]--;
        if(a[now] == 0) a[now] = k, now--;
        else now = n - 1;
    }
    for(int i = 0; i <= now; i++)
    {
        printf("%d ", a[i]);
    }
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

using D = double;
const int MAX_N = 3010;
D dp[MAX_N][MAX_N];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<D> p(n);
    rep(i, n) cin >> p[i];
    dp[0][0] = 1.0;
    rep(i, n) rep(j, n) {
        dp[i+1][j+1] += dp[i][j] * p[i];
        dp[i+1][j] += dp[i][j] * (1-p[i]);
    }
    D ans = (D)0.0;
    REP(i, (n+1)/2, n+1) ans += dp[n][i];
    cout << fixed << setprecision(15);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   ll n,m,sum=0;
 
   cin>>n>>m;
   int a[m];
   for(ll i=0;i<m;i++)
   {
   cin>>a[i];
   sum+=a[i];
   }
   if(n>=sum)
   cout<<(n-sum)<<endl;
   else 
   cout<<-1<<endl;
   return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
using namespace std;

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

    int n, W;
    cin >> n >> W;
    vector<ll> dp(W + 1, 0);
    vector<int> weight(n + 1, 0), value(n + 1, 0);
    for(int i = 0; i < n; i++){
        cin >> weight[i] >> value[i];
    }
    ll ans = 0;
    for(int i = 0 ; i < n; i++){
        for(int j = W; j >= weight[i]; j--){
            dp[j] = max(dp[j], dp[j - weight[i]] + value[i]);
            ans = max(ans, dp[j]);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
const int n = 3;
struct no{
    int a[n][n];//棋盘
    int x, y;//0所在的位置
    string path;
    bool operator < (const no &p) const {
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(a[i][j] == p.a[i][j]) continue;
                return a[i][j] > p.a[i][j];
            }
        }
        return false;
    }
};
no s, g;
int isEqual(no x, no y){
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(x.a[i][j] != y.a[i][j]) return 0;
        }
    }
    return 1;
}
void bfs(){
    int dy[] = {-1, 0, 1, 0};//左，上，右，下
    int dx[] = {0, -1, 0, 1};
    string dr[] = {"l", "u", "r", "d"};
    queue<no> q;
    map<no, bool> used;
    s.path = "";
    q.push(s);
    while(!q.empty()){
        no t = q.front(); q.pop();
        used[t] = true;
        if(isEqual(t, g)){
            cout<<t.path.length()<<endl;
            break;
        }
        for(int i = 0; i < 4; i++){
            int nx = t.x + dx[i];
            int ny = t.y + dy[i];
            if(0 <= nx && nx < n && 0 <= ny && ny < n){
                no u;
                u.x = nx; u.y = ny;
                for(int k = 0; k < n; k++){
                    for(int j = 0; j < n; j++){
                        u.a[k][j] = t.a[k][j];
                    }
                }
                u.a[t.x][t.y] = u.a[nx][ny]; u.a[nx][ny] = 0;
                u.path = t.path;
                if(!used[u]){
                    u.path += dr[i];
                    q.push(u);
                }
            }
        }
    }
}
int main(){
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            scanf("%d", &s.a[i][j]);
            if(s.a[i][j] == 0) {s.x = i; s.y = j; }
            g.a[i][j] = n*i + (j+1);
        }
    }
    g.a[n-1][n-1] = 0;
    g.x = g.y = 2;
    bfs();
    return 0;
}


Measured memory_bytes: 41772
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int g[20][20];
int dp[1 << 15][20];

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int v,e;
    cin >> v >> e;
    rep(i, 1 << v){
      fill(dp[i], dp[i] + v, INF);
    }
    
    rep(i, v){
      fill(g[i], g[i] + v, -1);
    }

    rep(i, e){
      int s,t,d;
      cin >> s >> t >> d;
      g[s][t] = d;
    }

    dp[0][0] = 0;

    rep(bit, 1 << v){
      rep(now, v){
        rep(to, v){
          if((bit >> to & 1) == 0 && g[now][to] != -1){
            chmin(dp[bit | 1 << to][to], dp[bit][now] + g[now][to]);
          }
        }
      }
    }
    print(dp[(1<<v)-1][0] == INF ? -1 : dp[(1<<v)-1][0]);
}






Measured memory_bytes: 5708