akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)

template <ll Mod>
class modint {
    public:
    ll n=0;
    modint(){}
    modint(ll n):n(n){}
    modint& operator = (modint const& a) = default;
    modint& operator = (int a) { n = a; clamp(); return *this; }
    modint operator - () { modint t = *this; t.n = -t.n; t.clamp(); return t; }
    modint& operator *= (modint const& a) { n *= a.n; clamp(); return *this; }
    modint& operator *= (ll const& a) { n *= a; clamp(); return *this; }
    modint& operator += (modint const& a) { n += a.n; clamp(); return *this; }
    modint& operator %= (modint const& a) { n %= a.n; clamp(); return *this; }
    friend modint operator * (modint a, modint b) { a.n *= b.n; a.clamp(); return a; }
    friend ostream& operator << (ostream& os, modint const& a) { os << a.n; return os; }
    friend bool operator == (modint const& a, int b) { return a.n == b; }
    void clamp() { n %= Mod; if (n < 0) n += Mod; }
    modint& inv() { return pow(Mod-2); }
    modint& pow(ll p) {
        ll a=1, e=n;
        while (p > 0) {
            if (p&1) { a *= e; a %= Mod; }
            e *= e; e %= Mod; p >>= 1;
        }
        n = a; clamp();
        return *this;
    }
};
using mint = modint<(ll)1e9+7>;

int main() {
    ll N, zeros = 0;
    cin >> N;
    map<pair<ll,ll>,pair<int,int>> unharms;
    rep(i,N) {
        ll a,b;
        cin >> a >> b;
        if (a == 0 && b == 0) {
            ++zeros;
            continue;
        }
        ll d = gcd(a,b);
        a /= d;
        b /= d;

        if (a < 0 && b < 0) {
            a = -a;
            b = -b;
        }
        if (a == 0) {
            b = 1;
        } else if (b == 0) {
            a = -1;
        }

        if (a < 0 || b < 0) {
            a = abs(a);
            b = abs(b);
            unharms[{b,a}].second++;
        } else {
            unharms[{a,b}].first++;
        }
    }
    mint ans=1;
    for (auto& [_,p] : unharms) {
        mint t(-1);
        t += mint(2).pow(p.first);
        t += mint(2).pow(p.second);
        ans *= t;
    }
    ans += zeros -1;
    cout << ans << endl;
}


Measured memory_bytes: 15968
import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map{it.toInt()}
    val S = readLine()!!.toCharArray()
    val safe = TreeSet<Int>()

    for (i in S.indices) {
        if (S[i] == '0') {
            safe.add(i)
        }
    }

    val steps = ArrayList<Int>()

    var p = N

    while (p > 0) {
        val q = safe.ceiling(p - M)!!
        if (p == q) {
            println(-1)
            return
        }
        steps.add(p - q)
        p = q
    }

    steps.reverse()
    println(steps.joinToString(" "))
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{ 
    ll h,w;
    cin >> h >> w;
    vs s(h);
    rep(i,h)cin >> s[i];

    rep(i,h){
        ll az=1;
        rep(j,w){
            ll counth=1,countw=1;
            rep(k,h-1){
                if(s[k][j] == s[k+1][j] && s[k][j] == '.')counth++;
            }
            rep(k,w-1){
                if(s[i][k] == s[i][k+1] && s[i][k] == '.')countw++;
            }

            if(counth != h && countw != w){
                cout << s[i][j];
                az=0;
            }
        }
        if(az == 0)cout << endl;
    }

    if(h == 1 && w == 1)cout << '#' << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

bool isLoop(int a){
  string s = "";
  int size = 0;
  while(a){
    char c = a%10 + int('0');
    s.push_back(c);
    a /= 10;
    size ++;
  }
  rep(i,size/2+1){
    if(s[i] != s[size-1-i]){
      return 0;
    }
  }
  return 1;
}

int main(){
  int a,b;
  cin >>a>>b;
  int ans = 0;
  for(int i=a;i<=b;i++){
    ans += isLoop(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <memory.h>
#include <math.h>

#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) > (b)) ? (b) : (a))
#define SWAP(t, a, b) do{t c = a; a = b; b = c;}while(0)

int main (int argc, char **argv)
{
  int64_t a = 0;
  int64_t b = 0;

  scanf("%lld %lld", &a, &b);

  printf("%lld\n", MAX(a + b, MAX(a - b, a * b)));

  return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		List<List<Character>> list = new ArrayList<>();
		//最初の列を囲う
		List<Character> zengolist = new ArrayList<>();
		for(int i = 0; i < W + 2; i++) {
			zengolist.add('.');
		}
		list.add(zengolist);
		//入力を受け付ける
		for(int i = 0; i < H; i++) {
			List<Character> clist = new ArrayList<>();
			clist.add('.');
			for(Character c : sc.next().toCharArray()) {
				clist.add(c);
			}
			clist.add('.');
			list.add(clist);
		}
		//最後の列を囲う
		list.add(zengolist);
		//判定
		List<List<Character>> anslist = new ArrayList<>(list);

		for(int i = 1; i < H + 1; i++) {
			for(int m = 1; m < W + 1; m++) {

				if(list.get(i).get(m) == '.') {
					int count = 0;
					for(int s = i - 1; s < i + 2; s++) {
						for(int t = m - 1; t < m + 2; t++) {
							if(list.get(s).get(t) == '#') {
								count++;
							}
						}
					}
					anslist.get(i).set(m, (char)('0' + count));
				}

			}
		}
		//出力
		for(int i = 1; i < H + 1; i++) {
			for(int m = 1; m < W + 1; m++) {
				System.out.print(anslist.get(i).get(m));
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 22356
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define pii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define MAXN 2097152
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)
#define inf (int)1e9

int dp[21][MAXN];
int arr[21][21];

int sol(int ind,int mask,int n){
	if(ind < 0 && mask == (1<<n)-1) return 1;

	if(dp[ind][mask] != -1) return dp[ind][mask];

	int ret = 0;
	for(int i = 0;i < n;i++){
		if(arr[ind][i] == 1 && (mask&(1<<i)) == 0){
			ret = (ret + sol(ind-1,mask|(1<<i),n))%mod;
		}
	}

	dp[ind][mask] = ret;
	return ret;
}


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

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


	memset(dp,-1,sizeof(dp));
	int ans = sol(n-1,0,n);

	cout << ans << endl;
	return 0;
 }	

Measured memory_bytes: 172288
#include<bits/extc++.h>
#ifdef _debug 
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#include<bits/stdc++.h>
#define dout(i) 0&&0
#endif
#pragma GCC optimize("unroll-loops,no-stack-protector,O3")
#define eout(i) {cout << (i) << '\n';exit(0);}
#define rout(i) {return cout << (i) << '\n', 0;}
#define priority_queue __gnu_pbds::priority_queue
#define unordered_map __gnu_pbds::gp_hash_table
#define rep(a, b) {for(int _i = a;_i > 0;--_i){b;}}
#define multe int _T;for(cin >> _T;_T--;)
using namespace std;
using ll = long long;using ull = unsigned long long;using ul = unsigned;using db = double;
using __gnu_pbds::null_type;
template<typename T> void read(int n, T s){while(n--)cin >> *s, ++s;}
template<typename T> void write(int n, T s){while(n--)cout << *s << " \n"[n==0], ++s;}
template<typename T> using rbtree = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T> inline ostream& operator << (ostream &ou, const vector<T> &a){for(auto it = a.begin();it != a.end();++it)ou << (it != a.begin() ? " " : "") << *it;return ou;}
template<typename T1, typename T2>inline istream& operator >> (istream &in, pair<T1, T2> &a){return in >> a.first >> a.second;}
template<typename T1, typename T2>inline ostream& operator << (ostream &ou, const pair<T1, T2> &b){return ou << b.first << ' ' << b.second;}
template<typename T> inline long long pow(long long v, long long t, const T &p){long long res = 1;for(;t;t >>= 1, v = v * v % p)if(t & 1)res = res * v % p;return res;}
const int maxn = 300010;
int n;
vector<vector<int>> e;
vector<int> route;
bool operator < (const vector<int> &a, const vector<int> &b){
	for(int i = 0;i < a.size();++i)
		if(a[i] > b[i])return false;
		else if(a[i] < b[i])return true;
	return false;
}
int f, d, t, b;
void dfs(int now = 1, int last = 0){
	static int dis = 0;
	++dis;
	if(dis > d)f = now, d = dis;
	for(int j : e[now])if(last != j)dfs(j, now);
	--dis;
}
void dfs2(int now , int last){
	static vector<int> step;
	step.emplace_back(now);
	for(int j : e[now])if(last != j)dfs2(j, now);
	if(step.size() > route.size())route = step;
	step.pop_back();
}
vector<int> gen(int now, vector<int> &r){
	vector<int> res(1, 1);
	for(int i = 1;i+1 < r.size();++i){
		int c = res.size()+1, v = c;
		rep(e[r[i]].size()-2, res.emplace_back(++v));
		res.emplace_back(c);
	}
	res.emplace_back(n);
	return res;	
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	e.resize(n+1);
	for(int a, b, i = 1;i < n;++i){
		cin >> a >> b;
		e[a].emplace_back(b);
		e[b].emplace_back(a);
	}
	dfs();
	dfs2(f, 0);
	auto v = gen(route.front(), route);
	reverse(route.begin(), route.end());
	auto s = gen(route.back(), route);
	if(min(v.size(), s.size()) < n)rout(-1);

	cout << min(v, s) << '\n';
}

Measured memory_bytes: 14200
#include <bits/stdc++.h>
    typedef long long ll;
    #define pb push_back
    #define f first
    #define s second
    #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define endl '\n'
    #define mem(a , v)  memset(a , v , sizeof(a))

using namespace std;
const int MAX=1e5+2;
const int inf = 1e9+77;
const int MOD = 1e9+7;
ll x[MAX];

char ALPH[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};


char ALPH_C[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char vowels[6]={'a','e','i','o','u','y'};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y%2==1)
         s*=x;
         return s;
}
void sortString(string &str)
{
   sort(str.begin(), str.end());
   //cout << str;
}
//ll const s=100;
ll dp[MAX];
int n;
ll solve(int i){
    if(i==n-1) return 0;
    ll &res=dp[i];
    if(res!=-1) return res;
     if(i<n-2){
        res=min(solve(i+1)+abs(x[i]-x[i+1]),solve(i+2)+abs(x[i]-x[i+2]));
     }
     else res=solve(i+1)+abs(x[i]-x[i+1]);

     return res;


}


int main()
{  IOS
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);

//    int n;
    cin>>n;
    for(int i=0;i<n;i++) {
        cin>>x[i];
    }
    /*for(int i=0;i<MAX;i++){
        //for(int j=0;j<100;j++)
        dp[i]=-1;
    }*/

    mem(dp,-1);
    cout<<solve(0);



    //cout << "Hello world!" << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

ll n,m,a,b,dp[100005];
bool usa[100005];
vector<vector<ll> >arr;

ll dfs(ll x){
    if(usa[x])return dp[x];
    usa[x]=true;
    ll res=0;
    if(arr[x].empty())return 0;
    for(ll i : arr[x])
        res=max(res,dfs(i));
    return dp[x]=res+1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    cin>>n>>m;
    arr.resize(n+2);
    for(ll i=0;i<m;i++){
        cin>>a>>b;
        arr[a].push_back(b);
    }
    for(ll i=1;i<=n;i++){
        if(!usa[i])dfs(i);
    }
    ll res=0;
    for(ll i=1;i<=n;i++)res=max(res,dp[i]);
    cout<<res;
}

Measured memory_bytes: 8704
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

const INF: i64 = 1 << 60;
#[fastout]
fn main() {
    input! {
    n:usize,k:usize,c:i64,
    s:Chars,
     }

    let mut left = Vec::new();
    let mut right = Vec::new();
    let mut prev = -INF;
    for (i, &now) in s.iter().enumerate() {
        let i = i as i64;
        if left.len() >= k {
            break;
        }
        if now == 'o' {
            if i - prev > c {
                prev = i;
                left.push(i);
            }
        }
    }
    let mut prev = INF;
    for (i, &now) in s.iter().enumerate().rev() {
        let i = i as i64;
        if right.len() >= k {
            break;
        }
        if now == 'o' {
            if prev - i > c {
                prev = i;
                right.push(i);
            }
        }
    }
    right.sort();
    for (i, &l) in left.iter().enumerate() {
        if right[i] == l {
            println!("{}", l + 1);
        }
    }
}


Measured memory_bytes: 6240
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,ii,jj;
ll n,m,sum,num=INF;
ll ans;
ll a,b,c,d,e;
ll x[100005],y[100005],z[100005];
ll xa[100005],ya[100005],za[100005];
ll dp[100005];
char s[100005];

int main(){
	cin>>n>>m;
    for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin>>s;
			if(s[0]=='s' && s[1]=='n' && s[2]=='u' && s[3]=='k' && s[4]=='e'){
				s[10]=j+65;
				cout<<s[10]<<i+1<<endl;
				return 0;
			}
		}
	}

}

Measured memory_bytes: 6400
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=50;
//templete
int main() {
	int N,M;
	cin>>N>>M;
	vint vec[SIZE];
	for(int i=0;i<M;i++){
		int k;
		cin>>k;
		for(int j=0;j<k;j++){
			int s;
			cin>>s;
			s--;
			vec[i].pb(s);
		}
	}
	vint P;
	for(int i=0;i<M;i++){
		int p;
		cin>>p;
		P.pb(p);
	}
	int ans=0;
	for(int state=0;state<(1<<N);state++){
		bool flag=1;
		for(int i=0;i<M;i++){
			int temp=0;
			for(int j:vec[i])
				if(state&(1<<j))
					temp++;
			if(temp%2!=P[i])
				flag=0;
		}
		if(flag)
			ans++;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  int w; cin >> w;
  FOR(i,0,n){
    if(i % w == 0){
      cout << s[i];
    }
  }
  cout << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9, M = 2 * N;
int h[N], w[M],o, q[M], f[N], c[N], v[N];
int get(int y)
{
    if(y==f[y]) return y ; 
    return f[y]=get(f[y]);
}
void dfs(int n, int m)
{
    c[n] = m;
    for (int i = h[n]; i; i = w[i])
        if (q[i]!= f[n])
        {
            f[q[i]] = n;
            dfs(q[i], -m);
            c[n] += c[q[i]];
        }
}
int a, b, qq = 1, ww = 1, ans = 0;
int qw , wq;
int main()
{
    for (int i = 1; i <= 100000; ++i)
    {
        f[i] = i;
    }
    cin>>a>>b;
    for (int i = 1; i <= b; ++i)
    {
        cin>>qw>>wq;
        if (get(qw) != get(wq))
        {
            f[f[qw]] = f[wq];
        }
        else
        {
            qq = qw;
             ww = wq;
            continue;
        }
        o++;
        w[o] = h[qw];
        q[o] = wq;
        h[qw]=o;
        o++;
        w[o] = h[wq];
        q[o] = qw;
        h[wq]=o;
    }
    f[qq] = 0;
    dfs(qq, 1);
    if (a == b)
    {
        long long u=0;
        for (int i = ww; i; i = f[i])
        {
            u++;
            v[u] = c[i];
        }
        if (u % 2)
        {
            if (c[qq] % 2)
            {
                cout<<"-1";
                return 0;
            }
            for (int i = ww; i; i = f[i])
            {
                c[i] -= c[qq] / 2;
            }
        }
        else
        {
            if (c[qq])
            {
                cout<<"-1";
                return 0;
            }
            sort(v + 1, v + u + 1);
            for (int i = ww; i; i = f[i])
            {
                c[i] -= v[u / 2];
            }
        }
    }
    else if (c[qq])
    {
        cout<<"-1";
        return 0;
    }
    for (int i = 1; i <= a; ++i)
    {
        ans += abs(c[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 14508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10|'0');
}
const int N=3000;
int n;
double p[N],f[N][N];
signed main(){
	n=read();
	for(int i=1;i<=n;i++) cin>>p[i];
	f[1][1]=p[1];f[1][0]=1-p[1];
	for(int i=2;i<=n;i++){
		for(int j=0;j<=i;j++)
		f[i][j]=f[i-1][j-1]*p[i]+f[i-1][j]*(1-p[i]);
	}
	double ans=0;
//	for(int i=1;i<=n;i++){
//		for(int j=0;j<=i;j++)cout<<f[i][j]<<" ";
//		cout<<endl;
//	}
	for(int i=n/2+1;i<=n;i++) ans+=f[n][i];
	printf("%.10lf",ans);
}
/*
设f[i][j]表示前i个有j个是正面朝上的；
f[i][j]=(f[i-1][j-1]*p[i]+f[i-1][j]*(1-p[i])
*/

Measured memory_bytes: 68864
N = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)


def calc_div(n):
    d = 1
    div = []
    while d * d <= n:
        if n % d == 0:
           div.append(d)
           if d != n // d:
               div.append(n // d)
        d += 1
    return div


b = []
parity = [0] * (N+1)
for i in range(N, 0, -1):
    if parity[i] != a[i]:
        b.append(i)
        div = calc_div(i)
        for d in div:
            parity[d] = (parity[d] + 1) % 2

print(len(b))
print(" ".join(map(str, b)))


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll N,K; cin >> N >> K;
    cout << min(N%K,K-N%K) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
bool f(string X){
  string Y=X;
  reverse(ALL(Y));
  return X==Y;
}
signed main(){
  string S; cin>>S;
  int N=S.size();
  string ans="No";
  if(f(S)&&f(S.substr(0,(N-1)/2))&&f(S.substr((N+3)/2-1))) ans="Yes";
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in)) {
      Task task = new Task();
      task.solve(sc, out);
      out.flush();

    } catch (Exception e) {
      // DO NOT USE
      e.printStackTrace();
    }
  }

  private static class Task {
    private void solve(Scanner sc, PrintWriter out) {
      // TODO
      int n = nint(sc);

      out.println(1110 - n);
    }

    // method
    private static int nint(Scanner sc) {
      return Integer.parseInt(sc.next());
    }

    private static long nlong(Scanner sc) {
      return Long.parseLong(sc.next());
    }

    private static double ndouble(Scanner sc) {
      return Double.parseDouble(sc.next());
    }

    private static float nfloat(Scanner sc) {
      return Float.parseFloat(sc.next());
    }

    private static String nstr(Scanner sc) {
      return sc.next();
    }

    private static long[] longLine(Scanner sc, int size) {
      long[] lLine = new long[size];
      for (int i = 0; i < size; i++) {
        lLine[i] = nlong(sc);
      }
      return lLine;
    }

    private static int[] intLine(Scanner sc, int size) {
      int[] iLine = new int[size];
      for (int i = 0; i < size; i++) {
        iLine[i] = nint(sc);
      }
      return iLine;
    }

    private static String[] strLine(Scanner sc, int size) {
      String[] strLine = new String[size];
      for (int i = 0; i < size; i++) {
        strLine[i] = nstr(sc);
      }
      return strLine;
    }

    private static long maxFromList(List<Long> longList) {
      return longList.stream().max(Comparator.naturalOrder()).get();
    }

    private static long minFromList(List<Long> longList) {
      return longList.stream().min(Comparator.naturalOrder()).get();
    }

    private static int sumDigits(int n) {
      int sum = 0;
      while (n != 0) {
        sum += n % 10;
        n /= 10;
      }
      return sum;
    }

    private static long sumDigits(long n) {
      long sum = 0;
      while (n != 0) {
        sum += n % 10;
        n /= 10;
      }
      return sum;
    }

    private static List<Integer> getIntegerList(Scanner sc, int size) {
      List<Integer> list = new ArrayList<>();
      for (int i = 0; i < size; i++) {
        list.add(nint(sc));
      }
      return list;
    }

    private static List<Long> getLongList(Scanner sc, int size) {
      List<Long> list = new ArrayList<>();
      for (int i = 0; i < size; i++) {
        list.add(nlong(sc));
      }
      return list;
    }

    private static long gcd(long m, long n) {
      if (m < n) return gcd(n, m);
      if (n == 0) return m;
      return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
      return m * n / gcd(m, n);
    }
  }
}


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

using namespace std;

long long n, a, b, c, d;

int main() {
    scanf("%d %d %d %d %d", &a, &b, &c, &d, &n);
    long long ans = 0;
    if (n >= 2 && d < 8*a && d < 4*b && d < 2*c) {
        ans += (n / 2) * d;
        n %= 2;
    }
    if (c < 4*a && c < 2*b) ans += n * c;
    else if (b < 2*a) ans += n * b * 2;
    else ans += n * a * 4;

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	vector<vector<int>> c(1e5 + 5);
	rep(i, n)
	{
		int a, b; cin >> a >> b;
		c[a].push_back(b);
	}
	priority_queue<int> q;
	ll res = 0;
	for (int i = 1; i <= m; ++i)
	{
		for (int x : c[i])q.push(x);
		if (q.empty())continue;
		res += q.top();
		q.pop();
	}
	cout << res << endl;
}

Measured memory_bytes: 8280
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;

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

ll maxSubArraySum(ll a[], ll size) 
{ 
    ll max_so_far = INT_MIN, max_ending_here = 0; 
  
    for (ll i = 0; i < size; i++) 
    { 
        max_ending_here = max_ending_here + a[i]; 
        if (max_so_far < max_ending_here) 
            max_so_far = max_ending_here; 
  
        if (max_ending_here < 0) 
            max_ending_here = 0; 
    } 
    return max_so_far; 
} 

ll findSubarraySum(ll arr[], ll n, ll sum = 0) 
{
    unordered_map<ll, ll> prevSum;
    ll res = 0;
    ll currsum = 0;
    for (ll i = 0; i < n; i++)
    {
        currsum += arr[i];
        if (currsum == sum) res++;
        if (prevSum.find(currsum - sum) != prevSum.end()) res += (prevSum[currsum - sum]);
        prevSum[currsum]++;
    }
    return res; 
} 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string s;cin>>s;
    if(s=="ARC") cout<<"ABC\n";
    else cout<<"ARC\n";
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll power(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
            res=(res*a);
        a=(a*a);
        b/=2;
    }
    return res;
}
signed main()
{   
      senky_bansal
      IIIT_ALLAHABAD
      
      ll n,k;
      cin>>n>>k;
      
      ll p = ((n-2)*(n-1))/2;
      if(k>p) cout<<"-1"<<endl;
      else
      {
          ll m = (n*(n-1))/2-k;
          cout<<m<<endl;
          for(int i=1;i<=n;i++){
          for(int j=i+1;j<=n;j++)
          {
              cout<<i<<" "<<j<<endl;
              m--;
              if(m==0)
              break;
          }
          if(m==0) break;}
      }
}







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

void mergeSort(unsigned long* arr, long l, long r);
void merge(long* arr, long l, long m, long r); 

int main()
{
    unsigned long i;
    unsigned long* H; //healths of mosters
    unsigned long N; //number of monsters
    unsigned long K; //number of special moves
    unsigned long sum=0;
    scanf("%lu %lu",&N, &K);
    H = (unsigned long*)malloc(N*sizeof(long));
    for(i=0; i<N ;i++)
    {
        scanf("%lu",&H[i]);
        sum += H[i];
    }
    if(K >= N)
    {
        sum=0;
    }
    else if(K > 0)
    {
        unsigned long sum_k=0;
        mergeSort(H,0,N-1);
        for(i=N-K;i<N;i++)
        {
            sum_k += H[i];
        }
        sum = sum - sum_k;
    }
    else
    {
        //do nothing
    }
    printf("%lu",sum);
    return 0;
}

void merge(long* arr, long l, long m, long r) 
{ 
    long i, j, k; 
    long n1 = m - l + 1; 
    long n2 =  r - m; 
  
    /* create temp arrays */
    long L[n1], R[n2]; 
  
    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++) 
        L[i] = arr[l + i]; 
    for (j = 0; j < n2; j++) 
        R[j] = arr[m + 1+ j]; 
  
    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray 
    j = 0; // Initial index of second subarray 
    k = l; // Initial index of merged subarray 
    while (i < n1 && j < n2) 
    { 
        if (L[i] <= R[j]) 
        { 
            arr[k] = L[i]; 
            i++; 
        } 
        else
        { 
            arr[k] = R[j]; 
            j++; 
        } 
        k++; 
    } 
  
    /* Copy the remaining elements of L[], if there 
       are any */
    while (i < n1) 
    { 
        arr[k] = L[i]; 
        i++; 
        k++; 
    } 
  
    /* Copy the remaining elements of R[], if there 
       are any */
    while (j < n2) 
    { 
        arr[k] = R[j]; 
        j++; 
        k++; 
    } 
} 
  
/* l is for left index and r is right index of the 
   sub-array of arr to be sorted */
void mergeSort(unsigned long* arr, long l, long r) 
{ 
    if (l < r) 
    { 
        // Same as (l+r)/2, but avoids overflow for 
        // large l and h 
        long m = l+(r-l)/2; 
  
        // Sort first and second halves 
        mergeSort(arr, l, m); 
        mergeSort(arr, m+1, r); 
  
        merge(arr, l, m, r); 
    } 
} 

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int t = sc.nextInt();
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int ci = sc.nextInt();
            int ti = sc.nextInt();
            if (ti > t) {
                continue;
            }
            if (ci < min) {
                min = ci;
            }
        }

        System.out.println(min == Integer.MAX_VALUE ? "TLE" : min);
    }
}


Measured memory_bytes: 23764
def main():
    D = int(input())
    c = list(map(int,input().split()))
    s = []
    for d in range(D):
        s.append(list(map(int,input().split())))
    
    last = [0 for i in range(26)]
    
    v = 0
    
    for d in range(D):
        tmp_score = [0 for i in range(26)]
        tmp_v = [0 for i in range(26)]
        for I in range(26):
            tmp_last = last
            tmp_v[I] = s[d][I]
            tmp_last[I] = d+1
            for i in range(26):
                tmp_v[I] -= c[i]*(d+1-tmp_last[i])
            tmp_score[I] = tmp_v[I]
        ans_i = tmp_score.index(max(tmp_score))
        print(ans_i+1)
        tmp_last[ans_i] = d+1
        v += tmp_v[ans_i]
        #print(v)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9520
#include<bits/stdc++.h>
typedef  long long int ll;
typedef long double ld;
#define pb  push_back
#define vll vector<ll>
#define mll map<ll,ll>
const double PI = 2*acos(0.0);
#define gcd(a,b)   __gcd((a),(b))
#define lcm(a,b)   ((a)/(__gcd((a),(b)))*(b))
#define INF         LLONG_MAX
#define ln  INT_MAX
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
int main(){

ll a,b,c;
cin>>a>>b>>c;

if(a<=b*c){puts("Yes");}
else{puts("No");}


return 0;
}


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

int N; //参考書の数
int M; //アルゴリズムの数
int X; //目標値

int cost[12];
int shuukudo[12][12];

int shuuku_hante[12];

int konyu(int bit){

    for(int i = 0;i < 12;i++)shuuku_hante[i] = 0;
    int sum_cost =  0;

    int _bit;
    for(int i = 0;i < N;i++){
        _bit = 1 << i;
        if(( bit & _bit ) != 0){
            sum_cost += cost[i];
            for(int j = 0;j < M;j++){
                shuuku_hante[j] += shuukudo[i][j];
            }
        }
    }

    for(int i = 0;i < M;i++){
        if(shuuku_hante[i] < X){
            //printf("-1 -1 cost :%d\n",sum_cost);
            return -1;
        }
    }

    //printf("ok cost :%d\n",sum_cost);

    return sum_cost;
    
}

int main(void) {

    scanf("%d %d %d",&N,&M,&X);

    for(int i = 0;i < 12;i++)shuuku_hante[i] = 0;

    for(int i = 0;i < N;i++){
        
        scanf("%d",&cost[i]);
        //printf("%d cost:%d\n",i,cost[i]);

        for(int j = 0;j < M;j++){
            scanf("%d",&shuukudo[i][j]);
            //printf("shuukudo:%d\n",shuukudo[i][j]);
            shuuku_hante[j] += shuukudo[i][j];
        }
    }

    // 事前に習熟度が高くないとき
    for(int i = 0;i < M;i++){
        if(shuuku_hante[i] < X){
            printf("-1\n");
            return 0;
        }
    }

    // 教科書を買う通りは??
    int bit_Max = 1;
    for(int i = 0; i < N - 1; i++){
        bit_Max = bit_Max << 1;
        bit_Max++;
    }

    int minmin = 0;
    int a;
    for(int i = 0; i <= bit_Max;i ++){
        a = konyu(i);
        if(a != -1){
            if(a != 0 && minmin == 0){
                minmin = a;
            }else{
                if(a < minmin){
                    minmin = a;
                }
            }
        }
    }

    printf("%d\n",minmin);

    return 0;
}

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

using namespace std;

int main()
{
    double h,n,a;
    cin>>h>>n;
    while(n--)
    {
        cin>>a;
        h-=a;
    }
    if(h<=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.size() <= k)
    {
        cout << s;
    }
    else
    {
        cout << s.substr(0, k) << "...";
    }
}

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

int main() {

    int N;
    cin >> N;

    int ls[N + 1];
    ls[0] = 0;

    rep(i, N) cin >> ls[i+1];

    int ans = 0;

    for (int i = 1; i <= N; ++i)
    {
        for (int j = i+1; j <= N; ++j)
        {
            ans += ls[i] * ls[j];
        }
    }

cout << ans << endl;
    return 0;
}

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

int main()
{
    int a, b, n;

    while( cin >> a >> b >> n )
    {
        string c = "";
        for( int i = 0; i <= n; i++ )
        {
            c += ( a / b ) + '0';           //整数部分は無視。変な値が入っても問題ない。
            a = a % b * 10;
        }
        int sum = 0;
        for( int i = 1; i < c.size(); i++ )
            sum += c[i] - '0';
        cout << sum << endl;
    }

    return 0;
}


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

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

using namespace std;

int main(){
  int k,t;cin>>k>>t;
  int max_num=0;
  rep(i,t){
    int t;cin>>t;
    max_num = max(max_num, t);
  }

  cout<<max(0, max_num-1-(k-max_num));

  return 0;
}

Measured memory_bytes: 256
L = gets.to_i

ans = []
l = (L - 1).bit_length
if L != (1<<l) then
  l -= 1
  wk = 1 << l
  (0...l).each{|n|
    ans << [1, l - n + 1, L - 1] if L[n] == 1 && n == 0
    if L[n] == 1 && n > 0 then
      ans << [1, l - n + 1, wk]
      wk += (1 << n)
    end
  }
end
(1..l).each{|n|
  ans << [n, n + 1, 1 << (l-n)]
  ans << [n, n + 1, 0]
}

printf("%d %d\n", l + 1, ans.size)
ans.each{|f, t, c|
  printf("#{f} #{t} #{c}\n")
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c; cin >> a >> b >> c;
    string res = "NO";
    if(b - a == c - b){
        res = "YES";
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  REP2(i, 1, 2000)
  {
    if ((int)(i*0.08) == a && (int)(i*0.1) == b)
    {
      cout << i;
      return 0;
    }
  }
  cout << -1;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ball = [0 for i in range(n)]

for i in reversed(range(n)):
  if n//2 < i:
    ball[i] = a[i]
  else:
    if (sum(ball[i::(i+1)]) - a[i]) % 2 == 0:
      ball[i] = 0
    else:
      ball[i] = 1


num = [str(i+1) for i, x in enumerate(ball) if x == 1]

if len(num) == 0:
  print('0')
else:
  print(len(num))
  num = ' '.join(num)
  print(num)

Measured memory_bytes: 21860
from sys import stdin
from math import log2
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))
    
n = I()
a = LI()

ans = int(log2(a[0]))
for i in a: 
    if i%2: 
        print(0)
        exit()
    else:
        for j in range(1,ans+1):
            if i&(1<<j):
                if not ans:
                    ans = j
                elif j<ans:
                    ans = j
                break

print(ans)

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

lli n;

int main(void){
	cin >> n;
	vector<lli> x(n);
	vector<lli> y(n);
	rep(i, n){
		cin >> x[i];
		y[i] = x[i];
	}
	sort(y.begin(), y.end());
	rep(i, n){
		if(x[i] <= y[n/2-1]) cout << y[n/2] << endl;
		else cout << y[n/2-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 6324
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;

int main()
{
    int a,b;
    string str;
    std::cin >> a >> b;
    if(a+b>16 || a>8 || b>8){
        str = ":(";
    }
    else {
        str = "Yay!";
    }
    std::cout << str << std::endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://msdn.microsoft.com/library/3bstk3k5.aspx
//   http://www.cplusplus.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   http://www.boost.org/doc/


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

int EPS = 1e-10;

int add(int a,int b)
{
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;
	return a+b;
}

struct P
{
	int x,y;
	P() {};
	P(int x,int y):x(x),y(y){}
	P operator + (P p){return P(add(x,p.x),add(y,p.y));}
	P operator - (P p){return P(add(x,-p.x),add(y,-p.y));}
	P operator * (int d){return P(x*d,y*d);}
	int dot(P p)
	{
		return add(x*p.x,y*p.y);
	}
	int det(P p)
	{
		return add(x*p.y, -y*p.x);
	}

};

bool cmp(const P& p,const P& q)
{
	if(p.y!=q.y)return p.y < q.y;
	return p.x<q.x;
}

P ps[100000];

int main()
{
	int n;
	cin >> n;
	for(int i = 0;i<n;i++)
	{
		int x,y;
		cin >> x >> y;
		ps[i] = P(x,y);
	}
	sort(ps,ps+n,cmp);
	int k = 0;
	vector<P> qs(n*2);
	for(int i = 0;i<n;i++)
	{
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<0)k--;
		qs[k++] = ps[i];
	}
	for(int i = n-2,t=k;i>=0;i--)
	{
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<0)k--;
		qs[k++] = ps[i];
	}
	cout<<k-1<<endl;
	for(int i = 0;i<k-1;i++)
	{
		cout<<qs[i].x<<' '<<qs[i].y<<endl;
	}
	
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string S; cin >> S;
    int Q; cin >> Q;
    string S1 = "";
    string S2 = "";
    int numT1 = 0;
    REP(i, Q) {
        int t1; cin >> t1;
        if (t1 == 1) {
            numT1++;
            continue;
        }
        else {
            int f;
            char c;
            cin >> f >> c;
            if (numT1%2 == 0 && f == 1) S1.push_back(c);
            else if (numT1%2 == 0 && f == 2) S2.push_back(c);
            else if (numT1%2 == 1 && f == 1) S2.push_back(c);
            else if (numT1%2 == 1 && f == 2) S1.push_back(c);
         }
    }
    // cerr <<"S1:" << S1 << endl;
    // cerr <<"S2:" << S2 << endl;
    if (numT1%2) {
        reverse(S2.begin(), S2.end());
        reverse(S.begin(), S.end());
        cout << S2 << S << S1 << endl;
    }
    else {
        reverse(S1.begin(), S1.end());
        cout << S1 << S << S2 << endl;
    }
    return 0;
}


Measured memory_bytes: 1040