akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <iostream>

using namespace std;

int main()
{
    long long a;
    string b;

    cin >> a >> b;

    long long b100 = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0') * 1;

    a *= b100;
    
    cout << a / 100 << endl;
}

Measured memory_bytes: 3624
n=int(raw_input())
x=map(int,raw_input().split())
ans=[-1]*(n**2+1)
for i in xrange(n):
    if ans[x[i]]!=-1:
        print("No")
        exit()
    ans[x[i]]=i+1
for i in xrange(1,n**2+1):
    if ans[i]!=-1:
        cnt=ans[i]-1
        for j in xrange(1,i):
            if cnt==0:break
            if ans[j]==-1:
                cnt-=1
                ans[j]=ans[i]
        if cnt>0:
            print("No")
            exit()

check=[False]*(n+1)
for i in xrange(n**2,0,-1):
    if ans[i]!=-1 and (not check[ans[i]]):
        cnt=n-ans[i]
        check[ans[i]]=True
        for j in xrange(n**2,i,-1):
            if cnt==0:break
            if ans[j]==-1:
                cnt-=1
                ans[j]=ans[i]
        if cnt>0:
            print("No")
            exit()
print("Yes")
print(" ".join(map(str,ans[1:])))


Measured memory_bytes: 24816
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=2005,mod=1e9+7;
int upt(int x){while(x>=mod)x-=mod;while(x<0)x+=mod;return x;}

int A,B,c[N][N],s[N][N],ans;
void init()
{
  int lm=max(A,B);
  for(int i=0;i<=lm;i++)c[i][0]=1;
  for(int i=1;i<=lm;i++)
    for(int j=1;j<=i;j++)
      c[i][j]=upt(c[i-1][j-1]+c[i-1][j]);
  for(int i=0;i<=lm;i++)
    for(int j=0;j<=lm;j++)
      s[i][j]=c[i][j];
  for(int i=0;i<=lm;i++)
    for(int j=0;j<=lm;j++)
      s[i][j]=upt(s[i][j-1]+s[i][j]);
  for(int i=0;i<=lm;i++)
    for(int j=0;j<=lm;j++)
      s[i][j]=upt(s[i][j-1]+s[i][j]);
}
int main()
{
  scanf("%d%d",&A,&B); init();
  for(int i=0;i<=A;i++)
    for(int t=0;t<=A-i;t++)
      {
	int tp=0;
	if(t)tp=s[t-1][A-i-t];
	else tp=1;
	ans=(ans+(ll)tp*c[B-1][t])%mod;
      }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 31488
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// main
func main() {
	sc.Split(bufio.ScanWords)
	s := next()
	t := next()
	fmt.Println((t + s))
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
/*
どうすれば最大化できるか？
3個の時は2個になった時の合計値が高いものを作る
n個の時はn-1個になった時の合計値の最大化をすれば良い
a < b < cの時、c+((a+b)/2) > b+((c+a)/2) > a+((b+c)/2)
*/


int main() {
    int N;
    cin >> N;
    vector<double> V(N);
    
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    
    sort(V.begin(), V.end());
    double ans;
    ans = (V[0] + V[1]) / 2;
    for (int i = 2; i < N; i++) {
      ans = (ans + V[i]) / 2;
    }
    cout << ans << endl;
    return 0;
}
        

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

int main(){
    int k, x;
    cin >> k >> x;
    if(x<=500*k){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n"; 
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2==0){
        cout<<a-b<<endl;
    }
    else{
        cout<<b-a<<endl;
    }
}

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

int find(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  
  for (int i = 1; i <= N; i++) {
    int sum = find(i);
    if (A <= sum && sum <= B) {
      ans += i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a < b) swap(a, b);
  int ans = a;
  a--;
  if (a < b) swap(a, b);
  ans += a;
  cout << ans << endl;
}





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

int main(int, char**)
{
	std::vector<int> nums;
	nums.reserve(30);
	std::vector<bool> pegion;
	pegion.resize(1000000, false);
	pegion[2] = true;

	int buff;
	int max = 0;
	while (std::cin >> buff)
	{
		nums.emplace_back(buff);
		if (max < buff)
		{
			max = buff;
		}
	}

	for (int target = 3; max >= target; ++target)
	{
		if (0 == target % 2)
		{
			continue;
		}
		int count = 0;
		bool flag = true;
		for (count = 3; target >= count * count; ++count)
		{
			if (0 == target % count)
			{
				flag = false;
				break;
			}
		}
		pegion[target] = flag;
	}

	for (const int num : nums)
	{
		int count = 0;
		for (int index = 0; num >= index; ++index)
		{
			if (pegion[index])
			{
				count += 1;
			}
		}
		std::cout << count << std::endl;
	}
}


Measured memory_bytes: 3144
#include <iostream>
#include <vector>
using namespace std;
 
#define INF 1050000000
 
int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
  vector<int>c(N,INF);
  c[0]=0;
  for (int i=0;i<N;i++){
    for (int k=0;k<=min(i,K);k++){
      c[i]=min(c[i],c[i-k]+abs(h[i]-h[i-k]));
    }
  }
  cout<<c[N-1]<<endl;
}
  


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

int main() {
  long ans,a=0;
  string x;
  cin >> x;
  ans=x.size();
  for(long i=0;i<x.size();i++) {
    if(x[i]=='S') {
      a++;
    } else {
      if(a>0) {
        a--;
        ans-=2;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "begin", long, "end");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

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

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto a = aryread();
    long cost_odd, cost_even; // head one grater than 0
    long c_sum_odd, c_sum_even;
    foreach (i, e; a)
    {
        if (!(i % 2))
        {
            if (c_sum_odd + e > 0)
                c_sum_odd += e;
            else
            {
                cost_odd += 1 - (c_sum_odd + e);
                c_sum_odd = 1;
                // writefln("cost_odd = %s, i = %s", cost_odd, i);
            }
        }
        else
        {
            if(c_sum_odd + e < 0)
                c_sum_odd += e;
            else
            {
                cost_odd += 1 + c_sum_odd + e;
                c_sum_odd = -1;
                // writefln("cost_odd = %s, i = %s", cost_odd, i);
            }
        }
    }
    foreach (i, e; a)
    {
        if (!(i % 2))
        {
            if (c_sum_even + e < 0)
                c_sum_even += e;
            else
            {
                cost_even += 1 + c_sum_even + e;
                c_sum_even = -1;
                // writefln("cost_even = %s, i = %s", cost_even, i);
            }
        }
        else
        {
            if(c_sum_even + e > 0)
                c_sum_even += e;
            else
            {
                cost_even += 1 - (c_sum_even + e);
                c_sum_even = 1;
                // writefln("cost_even = %s, i = %s", cost_even, i);
            }
        }
    }
    min(cost_even, cost_odd).writeln();
}

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

ans = 0
a = N // K

if K % 2 != 0:
    ans = a**3
else:
    if N / K - N//K < 0.5:
        ans = 2 * a**3
    else:
        ans = a**3 + (a+1)**3

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> S;
  int ans = 0;
  int n = S.size();
  rep(i, 0, n / 2 - 1) {
    int j = n - 1 - i;
    if (S[i] != S[j]) {
      ans++;
    }
  }
  cout << ans << endl;
  ;
}
void solve() {
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
using pii = pair<int, int>;

#define rep(i,k,n) for(int i=(k); i != int(n); ++i)
#define sz(x) x.size()
#define all(x) x.begin(), x.end()

#define dbg(x) cout << #x << '=' << x << '\n'
#define dbg2(x, y) cout << #x << '=' << x << ' ' << #y << '=' << y << '\n' 

#define input() (*istream_iterator<lli>(cin))
#define strin() (*istream_iterator<string>(cin))
#define output(x) cout << x << '\n' 

int main(){
    ios::sync_with_stdio(false);
    lli a = input(), b = input(), n = input();
    if(n >= b-1) cout << floor((a*(b-1))/b);
    else cout << floor((a*n)/b);
}

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

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 1e6 + 10;
const int M = (int) 1e6 + 10;
const int K = (int) 500 + 10;
const int mod = (int) 1e9 + 7;

int n;

int get(int x) {
	int ans = 0;
	while (x) {
		ans += x % 10;
		x /= 10;
	}
	return ans;
}

int main() {
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	srand(time(0));
	cin >> n;
	int ans = mod;
	for (int i = 1; i < n; i++) {
		ans = min(ans, get(i) + get(n - i));
	}	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli ans=0;
    lli n;
    cin>>n;
    vi a(n-1);
    rep(i, n-1) {
        cin>>a[i];
    }
    ans+=a[0];
    ans+=a[n-2];
    for (lli i=0;i<n-2;i++) {
        ans+=min(a[i], a[i+1]);
    }
    out(ans);
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(){
    // Your code here!int i,n;
    int i,n;
    i=1;
    while(1){
        cin>>n;
        if(n==0)
            break;
        cout<<"Case "<<i<<": "<<n<<endl;
        i++;
        
    }
    return 0;
}


Measured memory_bytes: 3052
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>

using namespace std;
int main() {
    int a,b,ans=0;
    cin>>a>>b;
    int wa = a+b;
    int sa = a-b;
    int seki = a*b;
    int hako=0;
    if(wa>sa)hako=wa;
    else hako=sa;
    ans = max(hako,seki);
    cout<<ans<<endl;
    return 0;
}


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

signed main() {
  int N;
  cin >> N;
  
  deque<int> ans;
  int A;
  for( int i = 0; i < N; i++ ){
    cin >> A;
    if( (i+1) % 2 == N % 2 ){
      ans.push_front(A);
    }else{
      ans.push_back(A);
    }
  }
  
  for( int i = 0; i < N; i++ ) cout << ans.at(i) << " ";
  cout << endl;
    
  
}


Measured memory_bytes: 3840
import fractions

mod = 10**9 + 7;

N = int(input())
A = list(map(int, input().split()))

l = 1
for i in A:
  l = l * i // fractions.gcd(l, i)

sum = 0
for i in A:
  sum += l // i

print(int(sum % mod))


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

int main(){
    const long int MODULO = 1000000007;
    long long int N, NUM = 1;
    cin >> N;

    for(int i = 1; i <= N; i++){
        NUM = (NUM * i) % MODULO;
    }

    cout << NUM << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 1e9;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  REP(i, N) cin >> A[i] >> B[i] >> C[i];
  vector<vector<vector<int>>> dp(N+1, vector<vector<int>>(401, vector<int>(401, INF)));
  dp[0][0][0] = 0;
  REP(i, N) REP(j, 401) REP(k, 401) {
    dp[i+1][j][k] = dp[i][j][k];
    if(j-A[i] >= 0 && k-B[i] >= 0) dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j-A[i]][k-B[i]] + C[i]);
  }
  int ans = INF;
  int Mat = Ma;
  int Mbt = Mb;
  while(Mat <= 400 && Mbt <= 400) {
    ans = min(ans, dp[N][Mat][Mbt]);
    Mat += Ma; Mbt += Mb;
  }
  cout << (ans == INF ? -1 : ans) << endl;
}

Measured memory_bytes: 27264
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;



int main()
{
	int N;
	cin >> N;
	vector <int> a(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
		a[i]--;
	}

	vector <int> b(N, NG);
	for (int x : a)
	{
		if (x == 0)
		{
			b[0] = 0;
		}
		else
		{
			if (b[x - 1]==NG)
			{
				b[x] = x;
			}
			else
			{
				b[x] = b[x - 1];
			}
		}
	}

	int best = 0;
	for ( int i=0;i<N;++i)
	{
		// BEGIN CUT HERE
//		cerr << " i=" << i << " b[i]=" << b[i] << endl;
		// END CUT HERE

		amax(best, i - b[i] + 1);
	}

	cout << N - best << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	
	cin>>N;
	
	if(N == 1) {
		cout<<1<<endl;
		cout<<0<<endl;
	} else if(N == 2) {
		cout<<2<<endl;
		cout<<0<<endl;
		cout<<11<<endl;
	} else {
		cout<<N-1<<endl;
		for(int i = 0; i < N-1; i++){
			cout<<1;
			for(int j = 0; j < i; j++){
				cout<<0;
			}
			cout<<1<<endl;
		}
	}
	
	return 0;
}


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

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

ll nck(ll n, ll k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  if(k == 0 || k == n) return 1;
  ll nume = 1, deno = 1;
  for(int i=0; i<k; i++){
    nume *= (n-i);
    deno *= (i+1);
    ll g = gcd(nume, deno);
    nume /= g;
    deno /= g;
  }
  return (ll)(nume/deno);
}


int main(){
    ll N, P;
    cin >> N >> P;
    ll odd = 0, even = 0;
    rep(i, 0, N){
        ll a; cin >> a;
        if(a % 2 == 0) even++;
        else odd++;
    }
    if(P == 0){
        ll ans = 1;
        ll eans = 0, oans = 0;
        rep(i, 1, even+1){
            eans += nck(even, i);
        }
        for(ll i = 2; i <= odd; i += 2){
            oans += nck(odd, i);
        }
        ans += eans + oans + eans * oans;
        cout << ans << endl;
    }else{
        ll ans = 0, eans = 0, oans = 0;
        rep(i, 1, even+1){
            eans += nck(even, i);
        }
        for(ll i = 1; i <= odd; i += 2){
            oans += nck(odd, i);
        }
        cerr << "even " << even << endl;
        cerr << " odd " <<  odd << endl;

        ans += oans + oans * eans;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

vector<vector<ll>> child;
vector<ll> X;
bool j=true;

pll dfs(ll w){
    if(!j){return {0,0};}
    if(child[w].size()==0){
        return {X[w],X[w]};
    }
    ll sum=0;
    const int mx=5001;
    vector<bool> dp(mx,false);
    dp[0]=true;
    ll S=0;
    for(auto &i:child[w]){
        pll ret=dfs(i);
        sum+=ret.F;
        if(!j){return {0,0};}
        S+=min(ret.S,ret.F-ret.S);
        ret.S=max(ret.S,ret.F-ret.S)-min(ret.S,ret.F-ret.S);
        for(int i=mx-1;i>=0;i--){
            if(dp[i] && i+ret.S<mx){dp[i+ret.S]=true;}
        }
    }
    for(ll i=X[w]-S;i>=0;i--){
        if(dp[i]){return {sum+X[w]-S-i,X[w]};}
    }
    j=false;
    return {0,0};
}


int main(){
    ll n;
    cin>>n;
    child.resize(n);
    X.resize(n);
    for(int i=1;i<n;i++){
        ll p;
        cin>>p;
        child[p-1].push_back(i);
    }
    for(auto &i:X){cin>>i;}
    dfs(0);
    cout<<(j?"POSSIBLE":"IMPOSSIBLE")<<endl;
    
    
    return 0;
}


Measured memory_bytes: 640
#!/usr/local/gnu/bin/bash
read n a b
c=0
for i in `seq 1 $n`
do
    d=$((i/10000+i%10000/1000+i%1000/100+i%100/10+i%10))
    ((a<=d&&d<=b)) && c=$((c+i))
done
echo $c


Measured memory_bytes: 2436
k = int(input())
a = list(map(int,input().split()))
def cal(x):
    for i in range(k):
        x -= (x%a[i])
    return x
top = 3+ k*max(a)
bot = 0
while top - bot > 1:
    mid = (top+bot)//2
    if cal(mid) >= 2:top = mid
    else:bot = mid
mini = top
top = 3+ k*max(a)
bot = 0
while top - bot > 1:
    mid = (top+bot)//2
    if cal(mid) > 2:top = mid
    else:bot = mid
maxi = bot
if mini > maxi:print(-1)
    
else:print(mini,maxi)


Measured memory_bytes: 63984
#include<stdio.h>

int main() {
    int N;
    scanf("%d", &N);

    if(N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9) {
        printf("hon");
    }
    else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
        printf("pon");
    }
    else {
        printf("bon");
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 1712
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();
        int[] x = {a, b, c, d, e};
        int count = 0;
        
        limit:		
        for (int i = 0; i < x.length; i++) {
        	for (int j = i + 1; j < x.length; j++) {
        		if (x[j] - x[i] > k) {
        			count++;
        			break limit;
        		}
        	}
        }
        
        System.out.println(count == 1 ? ":(" : "Yay!");
	}	
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main() {
    int n;
    cin >> n;
    int sum = 0;
    int maxl = 0;
    for(int i = 0; i < n; i++){
        int l;
        cin >> l;
        maxl = max(maxl, l);
        sum += l;
    }
    if(maxl < sum-maxl){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	double ans = 0;
	for (int i = 1; i <= N; i++) {
		double temp = 1.0 / N;
		int now = i;
		while (now < K) {
			now *= 2;
			temp /= 2;
		}
		ans += temp;
	}
	cout << fixed << setprecision(9) << ans << endl;

	return 0;
}

Measured memory_bytes: 3732
x1,y1,x2,y2 = gets.chomp.split.map(&:to_i)
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (x2 - x1)
y4 = y3 - (y2 - y1)
puts "#{x3} #{y3} #{x4} #{y4}"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> next(n);
  rep(i, n){
    ll num;
    cin >> num; num--;
    next[i] = num;
  }
  vector<ll> point(n);
  rep(i, n) cin >> point[i];
  ll biggest = -1000000000000000001;
  rep(i, n){
    vector<ll> tmp;
    ll c = i;
    ll sbiggest = -1000000000000000001;
    ll sum = 0;
    while(next[c] != i){
      c = next[c];
      sum += point[c];
      sbiggest = max(sbiggest, sum);
      tmp.push_back(c);
    }
    sum += point[i];
    sbiggest = max(sbiggest, sum);
    tmp.push_back(i);
    if(sum <= 0){
      if(k <= (ll)tmp.size()){
        ll b = -1000000000000000001;
        ll csum = 0;
        rep(j, k){
          csum += point[tmp[j]];
          b = max(b, csum);
        }
        biggest = max(biggest, b);
      }else{
        ll b = -1000000000000000001;
        ll csum = 0;
        rep(j, (ll)tmp.size()){
          csum += point[tmp[j]];
          b = max(b, csum);
        }
        biggest = max(biggest, b);
      }
    }else{
      if(k <= (ll)tmp.size()){
        ll b = -1000000000000000001;
        ll csum = 0;
        rep(j, k){
          csum += point[tmp[j]];
          b = max(b, csum);
        }
        biggest = max(biggest, b);
      }else{
        ll b1 = 0;
        ll csum1 = 0;
        rep(j, k%tmp.size()){
          csum1 += point[tmp[j]];
          b1 = max(b1, csum1);
        }
        ll b2 = 0;
        ll csum2 = 0;
        rep(j, k%tmp.size(), tmp.size()){
          csum2 += point[tmp[j]];
          b2 = max(b2, csum2);
        }
        biggest = max(biggest, (ll)(b1+sum*(k/tmp.size())));
        biggest = max(biggest, (ll)(b2+sum*(k/tmp.size()-1)));
      }
    }
  }
  cout << biggest << endl;
  return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
vector<int> prime_factorize(long long N) {
    vector<int> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            res.push_back(a);
            N /= a;
        }

    }

    // 最後に残った数について
    if (N != 1) res.push_back(N);
    return res;
}

int main() {
    int n;cin>>n;
    cout<<n<<":";
    vector<int> ans=prime_factorize(n);
    for(int i=0;i<ans.size();i++){
        cout<<" "<<ans[i];
    }
    cout<<endl;
}


Measured memory_bytes: 3140
text = input()
target = input()


def get_diff(t1, t2):
    _diff = 0
    for pos in range(len(t1)):
        if t1[pos] != t2[pos]:
            _diff += 1
    return _diff


min_diff = len(target)
for i in range(len(text) - len(target) + 1):
    print()
    diff = get_diff(text[i:i + len(target)], target)
    min_diff = min(min_diff, diff)

print(min_diff)


Measured memory_bytes: 9124
package main

import (
	"fmt"
)

func main() {
	var n int
	var result uint64
	fmt.Scanf("%d", &n)
	arr := make([]uint64, n)
	for i:=0; i<n; i++ {
		fmt.Scanf("%d", &arr[i])
	}
	result = 1
	toobig := false
	for _,value := range arr {
		if value == 0 {
			fmt.Printf("%d", 0)
			return
		}
		if result > 1e18/value {
			toobig = true
		}
		result *= value
	}
	if toobig || result > 1e18 {
		fmt.Printf("-1")
	} else {
		fmt.Printf("%d", result)
	}
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x,y;cin >> x >> y;
	ll ans=0;
	for(ll i=x;i<=y;i*=2) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
#total = 0
books = 0
#i = 0
A,B = [0],[0]
for i in range(n):
    A.append(A[i]+a[i])
for j in range(m):
    B.append(B[j]+b[j])

l = m

for i in range(n+1):
    if A[i]>k:
        break
    while B[l]>k-A[i]:
        l -= 1
    books = max(books,i+l)

print(books)

Measured memory_bytes: 47680
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <time.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>

#define FOR(i, a) for(i = 0; i < (a); i++)
#define FORM(i, a) for(i = (a) i >= 0; i--)
using namespace std;

vector<int> E[5050];
int indeg[5050];
queue<int> q;

void bfs(int s){
int i, j;

   FOR(i, E[s].size()){
	  indeg[E[s][i]]--;
	  if(indeg[E[s][i]] == 0){
		  q.push(E[s][i]);
	  }
   }

}

void ranking(int N){
int i, j, k, l, flag = 0;



   FOR(i, N){
	   if(indeg[i+1] == 0){
		   q.push(i+1);
		   indeg[i+1]--;
	   }
   }
 
     if(q.size() > 1)
		 flag = 1;

    while(q.size() != 0){
	   cout << q.front() << endl;
       bfs(q.front());
	   q.pop();
       if(q.size() > 1){
		   flag = 1;
	   }
	}

	 cout << flag << endl;

}

int main(){
int i, j, N, K, m, n;

 cin >> n >> m;


  FOR(K, m){
    cin >> i >> j;
	E[i].push_back(j);
	indeg[j]++;
  }

 ranking(n);

return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  ans = max(a*b, max(a + b, a - b));
  cout << ans << endl;

}


Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list(map(int,input().split()))

ans = 0

for i in range(n):
    a = list(map(int,input().split()))
    ar = [a[i] * b[i] for i in range(m)]

    if(sum(ar) + c > 0):
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n,k;
ll a[1000000];
ll ans;
int dp[300][300][300];

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

  rep(i,n){
    cin>>a[i+1];
  }


  dp[0][0][0]=1;

  FOR(i,1,n+1){
    rep(j,n+1){
      rep(l,270){
        int nk = l^a[i];
        dp[i][nk][j+1]+=dp[i-1][l][j];
        dp[i][l][j]+=dp[i-1][l][j];
        dp[i][nk][j+1]%=M;
        dp[i][l][j]%=M;
      }
    }
  }

  ll c = 1;
  FOR(i,1,n+1){
    c*=i;
    c%=M;
    ans+=c*(ll)dp[n][k][i]%M;
    ans%=M;
  }

  cout<<ans<<endl;

  return 0;

}

Measured memory_bytes: 38656
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int X, Y, n, m,bx=-100,by=100;
	cin >> n >> m >> X >> Y;
	vector<int>x(n);
	vector<int>y(m);

	for (int i = 0; i < n; i++) {
		cin >> x[i];
		bx = max(x[i], bx); 
	}
	for (int j = 0; j < m; j++) {
		cin >> y[j];
		by = min(y[j], by);
		
	}
	//cout << bx << endl;
	//cout << by << endl;
	for (int z = X+1; z <= Y; z++) {
		if (z > bx&&z <= by) {
			cout << "No War" << endl;
			exit(0);
		}
	}
	cout << "War" << endl;


	
}

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

int a[510][510] = {};

void solve(int left, int right, int level){
    if(left == right) return;
    if(left == right-1){
        a[left][right] = level;
        a[right][left] = level;
        return;
    }
    int mid = (left+right+1)/2;
    for(int l=left;l<mid;l++){
        for(int r=mid;r<=right;r++){
            a[l][r] = level;
            a[r][l] = level;
        }
    }
    solve(left, mid-1, level+1);
    solve(mid, right, level+1);
    return;
}

int main(){
    int N;

    cin >> N;
    solve(1, N, 1);
    for(int i=1;i<=N-1;i++){
        for(int j=1;j<=N;j++){
            if(j>i) cout << a[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

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

int main(){
    int a,b;
    cin>>a >> b;
    cout << max(0,a-b-b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    ll n,k,i,j,d,e;
    ll ans=0;
    cin>>n>>k;
    vector<ll> a(n,1);
    for(i=0;i<k;i++){
        cin>>d;
        for(j=0;j<d;j++){
            cin>>e;
            if(a[e-1]>0) a[e-1]--;
        }
    }
    for(i=0;i<n;i++){
        if(a[i]>0) ans++;
    }
    cout<<ans;

    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define ll_1e9 (ll)1e9
using namespace std;

int main(){
  ll s;
  cin >> s;
  
  ll y3 = (s-1) / ll_1e9 + 1,x3 = y3*ll_1e9 - s;
 
  cout << 0 << " " << 0 << " " << ll_1e9 << " " << 1 << " " << x3 << " " << y3 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();//100
		int m = sc.nextInt();//5
		int a,b,x,y;
		double num = Math.pow(2, m);//32
		int ans;
		
		a=n-m;//95
		x=a*100;//9500
		y=m*1900;//9500
		ans=(int) ((x+y)*num);
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e13
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se-a.fi < b.se-b.fi) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
} 

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;

    // if(a > b) swap(a, b);

    ll ans = 0;

    if(k > a)
    {
        cout << 0;
        k -= a;

        if(k > b) cout << " " << 0 << "\n";
        else cout << " " << b-k << "\n";
    }
    else
    {
        cout << a-k << " " << b << "\n";
    }
} 
    

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
	

	private static int getCost(int i,int arr[],int dp[]){
		if(i >= arr.length)
			return Integer.MAX_VALUE;

		if(i== arr.length - 1)
			return 0;
		if(dp[i] != -1)
			return dp[i];
		int oneStep =0;
		int twoStep = 0;
		if(i+1 < arr.length)
			oneStep = Math.abs(arr[i] - arr[i+1]);
		if(i+2 < arr.length)
			twoStep = Math.abs(arr[i]-arr[i+2]);
		dp[i]= Math.min(oneStep + getCost(i+1,arr,dp),twoStep + getCost(i+2,arr,dp));
		return dp[i];
	}
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int arr[]=new int[n];
		String in[]=br.readLine().split(" ");
		for(int i=0;i<n;i++){
			arr[i]=Integer.parseInt(in[i]);
		}
		int dp[]=new int[n];
		Arrays.fill(dp,-1);
		int minCost = getCost(0,arr,dp);
		System.out.println(minCost);
	}
}


Measured memory_bytes: 59640
# coding: utf-8
# Your code here!
N=int(input())


cand=[]
def saiki(num,arc):
    if "3" in arc and "5" in arc and "7" in arc:
        cand.append(arc)
    if num==len(str(N)):
        return 0
    else:
        for item in ["3","5","7"]:
            saiki(num+1,arc+[item])
    return 0


saiki(0,[])

ans=0
for item in cand:
    if N>=((int("".join(item)))):
        ans+=1
        
print(ans)
    
    

Measured memory_bytes: 6884
#include <bits/stdc++.h>
#define ll long long

using namespace std;


pair<int,int> slide(string a,int l){
    map<char,int>ma;
    for(int i=0;i<l;i++){
        ma[a[i]]++;
        if(ma[a[i]]>(l/2))
            return {1,i+1};
    }
    for(int i=l;i<a.length();i++){
        ma[a[i-l]]--;
        ma[a[i]]++;
        if(ma[a[i]]>(l/2))
            return {i-l+2,i+1};
    }
    return {-1,-1};
}
int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    string a;
    cin>>a;
    if(a.length()==2 && a[0]==a[1]){
        cout<<1<<' '<<2;
        exit(0);
    }
    int s=2,e=a.length();
    while(s<e){
        int mid=(s+e)/2;
        pair<int,int>ans=slide(a,mid);
        if(ans.first==-1){
            e=mid;
        }
        else{
            cout<<ans.first<<' '<<ans.second<<endl;
            exit(0);
        }
    }
    cout<<-1<<' '<<-1;
}

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

#ifdef _DEBUG
#define debug(x) cout << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define debug(x)
#define INFILE
#endif

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL9_MOD = 1000000009LL;
static constexpr ll LL7_MOD = 1000000007LL;
static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

ll dp[110][100010];

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

  ll n;
  cin >> n;

  vector<ll> v(n);
  scan(v);

  sort(ALL(v));

  double result = v[0];
  REP(i, 1, n) {
    result += v[i];
    result /= 2.0;
  }

  cout << fixed << setprecision(10) << result << endl;

  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
/*-*/

inline lnt ceildiv(lnt a, lnt b) { return (a+b-1)/b; }


struct P
{
	lnt a,b;
	P(lnt a, lnt b) : a(a),b(b) {}
};

int main() {
	int n;
	std::cin >> n;
	std::vector<P> ps;
	rep(i,n) {
		lnt a,b;
		std::cin >> a >> b;
		ps.emplace_back(a,b);
	}
	std::vector<lnt> l,r;
	rep(i,n) {
		l.emplace_back(ps[i].a);
		r.emplace_back(ps[i].b);
	}
	std::sort(all(l));
	std::sort(r.rbegin(),r.rend());
	if(n&1) {
		print(r[n/2]-l[n/2]+1);
	} else {
		lnt a,b,c,d;
		a=r[n/2];b=l[n/2-1];
		c=r[n/2-1];d=l[n/2];
		debug(a,b,c,d);
		print(a-b+c-d+1);
	}
}


Measured memory_bytes: 11324
N,M = list(map(int,input().split()))
flag = True
ans = [-1]*N
for i in range(M):
    s,c = list(map(int,input().split()))
    if ans[s-1] == -1:
        ans[s-1] = c
    elif ans[s-1] != c:
        flag = False
if N >= 2 and ans[0] == 0:
    flag = False
if flag == False:
    print(-1)
else:
    if N >= 2 and ans[0] == -1:
        ans[0] = 1
    for i in range(N):
        if ans[i] == -1:
            ans[i] = 0
    print(''.join(list(map(str,ans))))

Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.trim().split(' ').map { it.toLong() }
    val dic = Array (100005) { 0L }
    for (i in 0 until n) {
        val (a, b) = readLine()!!.trim().split(' ').map { it.toLong() }
        dic[a.toInt()] += b
    }
    var m = 0L
    for (i in 1 until 100005) {
        if (m + dic[i] < k) {
            m += dic[i]
        } else {
            println(i)
            break
        }
    }
}


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

typedef long long ll;

void merge(ll a[], ll l, ll r, ll m) {
    ll nl = m - l + 1;
    ll nr = r - (m + 1) + 1;

    ll L[nl], R[nr];

    for (ll i = 0; i < nl; i++) {
        L[i] = a[l + i];
    }

    for (ll i = 0; i < nr; i++) {
        R[i] = a[m + 1 + i];
    }

    ll i = 0;
    ll j = 0;
    ll k = l;

    while (i < nl && j < nr) {
        if (L[i] < R[j]) {
            a[k] = L[i];
            i++;
        } else {
            a[k] = R[j];
            j++;
        }
        k++;
    }

    while (i < nl) {
        a[k] = L[i];
        i++;
        k++;
    }

    while (j < nr) {
        a[k] = R[j];
        j++;
        k++;
    }

}

void mergesort(ll a[], ll l, ll r) {
    if (l == r) {
        return;
    }
    ll m = l + (r - l)/2;
    mergesort(a, l, m);
    mergesort(a, m + 1, r);
    merge(a, l, r, m);
}

ll arr[100000];
ll num[100000];
ll counter[100000];
ll n;

int main() {
    cin >> n;

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

    mergesort(arr, 0, n - 1);

    ll last = arr[0];
    num[0] = last;
    ll c = 0;

    for (ll i = 0; i < n; i++) {
        ll curr = arr[i];

        if (curr == last) {
            counter[c]++;
        } else {
            c++;
            num[c] = arr[i];
            counter[c]++;
        }

        last = curr;
    }

    // for (ll i = 0; i <= c; i++) {
    //     cout << num[i] << " ";
    // }
    // cout << endl;

    // for (ll i = 0; i <= c; i++) {
    //     cout << counter[i] << " ";
    // }
    // cout << endl;

    ll max1 = -1;
    for (ll i = 0; i <= c; i++) {
        if (num[i] > max1 && counter[i] >= 2) {
            max1 = num[i];
        }
    }

    for (ll i = 0; i <= c; i++) {
        if (num[i] == max1) {
            counter[i] -= 2;
        }
    }

    ll max2 = -1;
    for (ll i = 0; i <= c; i++) {
        if (num[i] > max2 && counter[i] >= 2) {
            max2 = num[i];
        }
    }
    
    if (max1 != -1 && max2 != -1) {
        cout << max1 * max2 << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3328
n = gets.to_i
t = {}

n.times do |i|
  s = gets
  if t[s] == nil
    t[s] = 0
  else
    t[s] += 1
  end
end

t1 = t.sort_by{|_,v|-v}
m = t1[0][1]
ans = []
t1.each do |tt|
  if tt[1] == m
    ans.push(tt[0])
  else
    break
  end
end

ans.sort!
ans.each do |d|
  puts d
end



Measured memory_bytes: 38980
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int i=a;i<b;i++)
#define modulo 1000000007

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int a;
		int b;
		int c=0;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		if(b>=a) {
			c=a;
		}else {
			c=a-1;
		}
		System.out.println(c);
	}

}


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

using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  int k=0,l=0,m=0;
  
  if(a==2) m++;
  else if(a==4 || a==6 || a==9 || a==11) l++;//4,6,9,11
  else k++;
  
  if(b==2) m++;
  else if(b==4 || b==6 || b==9 || b==11) l++;//4,6,9,11
  else k++;
  
  if(k==2 || l==2 || m==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}

Measured memory_bytes: 256