akhauriyash/Code-Regression huggingface dataset:
#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);
    int A, B; cin >> A >> B;
    int res = -1;  
    REP(i, 2000) {//適当
        if (floor(i*0.08) == A && floor(i*0.1) == B){
            res = i;
            break;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
int main(){
    long long N,count=0,count0=0;
    cin>>N;
    long long ans=0,m=10000000007;
    vector<long long> vec(N);
    for(int i=0;i<N;i++){
        cin>>vec.at(i);
        if(vec.at(i)==0){
            count0++;
        }
        if(vec.at(i)<0){
            count++;
        }
        long long M=nature(vec.at(i));
        ans+=M;
        m=min(m,M);
    }
    for(int i=0;i<N;i++){
    }
    if(count%2==0){
        cout<<ans<<endl;
    }
    else{
        cout<<ans-2*m<<endl;
    }
}

Measured memory_bytes: 3996
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))

def check(k):
    cnt = 0
    for a in A:
        cnt += math.ceil(a/k) - 1
    return cnt <= K

l, r = 0, 10**10
while r - l > 1:
    mid = (r + l) // 2
    if check(mid):
        r = mid
    else:
        l = mid

print(r)


Measured memory_bytes: 93676
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<H(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define pll				pair <ll,ll>
#define vii				vector <pll>
#define PI				double PPPPPP = 3.14159265358979323846;
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
void solve() {
	string s;
	cin >> s;
	cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
}
int main() {
	run();
	int t = 1;
	///cin>>t;
	while (t--)
		solve();
	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <cassert>
#include <string.h>
#include <tuple>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n-1;i>=0;i--)///n-1番目からn回
#define  REP(i,a,b) for(int i=a;i<=b;i++) ///a番目からb回
#define  RREP(i,a,b) for(int i=a;i<b;i--)
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pair_t;
#define MOD 1000000007

//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///*min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();
///(10-(n%10))%10  10-(1桁目)取得 12->8 20->0

#define Ru(n)  ( ((n)+9)/10*10  ) //切りあげ
#define Rd(n)  ( ((n)-10)/10*10 +10 )	切り捨て


int gcd(int a,int b);
size_t length(const std::string& str) {
	return str.length();
}
bool comp(const pair_t &a, const pair_t &b) {
	return a.first < b.first;
}

int main() {
	int x,a,out;
	cin>>x>>a;
	if(x<a)
		out=0;
	else
		out=10;

	cout<<out<<endl;

	return 0;

}


int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}


Measured memory_bytes: 256
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 n = Integer.parseInt(sc.next());
        Integer[] p = new Integer[n];
        Integer[] q = new Integer[n];
        for (int i = 0; i < n; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        for (int i = 0; i < n; i++) {
            q[i] = Integer.parseInt(sc.next());
        }
        Integer[] aa = new Integer[n];
        for (int i = 0; i < n; i++) {
            aa[i] = i + 1;
        }
        List<Integer[]> list = new ArrayList<>();
        Permutation perm = new Permutation();
        perm.rec(list, aa, new Integer[aa.length], 0);
        int a = 0;
        int b = 0;
        s: for (int i = 0; i < list.size(); i++) {
            for (int j = 0; j < n; j++) {
                if (list.get(i)[j] != p[j]) {
                    continue s;
                }
            }
            a = i;
            break;
        }
        s: for (int i = 0; i < list.size(); i++) {
            for (int j = 0; j < n; j++) {
                if (list.get(i)[j] != q[j]) {
                    continue s;
                }
            }
            b = i;
            break;
        }
        System.out.println(Math.abs(a - b));

    }

    private static class Permutation {

        public <T> void rec(List<T[]> list, T[] array, T[] ans, int index) {
            if (isEnd(array)) {
                list.add(ans.clone());
            } else {
                for (int i = 0; i < array.length; ++i) {
                    T o = array[i];
                    if (o == null) {
                        continue;
                    }
                    array[i] = null;
                    ans[index] = o;
                    rec(list, array, ans, index + 1);
                    ans[index] = null;
                    array[i] = o;
                }
            }
        }

        private <T> boolean isEnd(T[] array) {
            for (T o : array) {
                if (o != null) {
                    return false;
                }
            }
            return true;
        }
    }
}

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

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

  int N, M, Q;
  int grid[510][510];

  cin >> N >> M >> Q;

  int l, r;
  rep(i, M) {
    cin >> l >> r;
    grid[l-1][r-1]++;
  }

  rep(i, N) {
    rep(j, N) {
      grid[i][j+1] += grid[i][j];
    }
  }

//  cout << endl;
//  rep(i, N) {
//    rep(j, N) {
//      cout << grid[i][j] << " ";
//    }
//    cout << endl;
//  }
//  cout << endl;

  int p, q;
  rep(i, Q) {
    cin >> p >> q;
    int ans = 0;
    FOR(j, p-1, q) {
      if (p-2 < 0) ans += grid[j][q-1];
      else ans += grid[j][q-1] - grid[j][p-2];
    }
    cout << ans << endl;
  }
}

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

using namespace std;
#define ll long long
#define f first
#define s second
ll n,k,ind,arr[105],m=1e9+7,dp[105][100005];

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

    for (int i=1; i<=n; i++)
       cin >> arr[i];

    for(int i=0; i<=k; i++)
    {
        if (arr[1] >= i) dp[1][i]=1;
        if (i && n!=1) dp[1][i] =((dp[1][i]%m)+(dp[1][i-1]%m))%m;
    }

    for(int i=2; i<=n; i++)
    {
        for(int j=0; j<=k; j++)
        {
            ind = j-arr[i]-1;
            if (ind<0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = (dp[i-1][j]-dp[i-1][ind])%m;
            if (dp[i][j] < 0) dp[i][j] += m;
            if (j && i!=n) dp[i][j] = ((dp[i][j]%m) + (dp[i][j-1]%m))%m;
        }
    }

    cout << dp[n][k] << "\n";

    return 0;
}


Measured memory_bytes: 79360
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
count = 0
ni = 0
iranai = 0
a.each do |i|
    if i % 4 == 0
        count += 1
    elsif i % 2 == 0
        ni += 1
    else
        iranai += 1
    end
end
if count >= iranai
    puts "Yes"
elsif count == iranai - 1 && ni == 0
    puts "Yes"
else
    puts "No"

end

Measured memory_bytes: 21832
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}






int main(){
  int n;
  cin >> n;
  int a[n+1];
  rep (i,n) {
    cin >> a[i];
  }
  ll cnt = 0,sum = 1000;

  rep (i,n-1){
    cnt = 0;
    if (a[i]<a[i+1]) {
      cnt = sum / a[i];
      sum -= a[i] * cnt;
      sum += a[i+1] * cnt;
    }
    if (a[i]>=a[i+1]) continue;
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 3624
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modPow(ll x,ll n,ll mod){if(n==0)return 1; if(n%2==0)return modPow(x*x,n/2,mod)%mod; return x%mod*modPow(x,n-1,mod)%mod;}


/*--------------------------------------------------------------------------*/

//main関数
int main() {
    st s; cin >> s;
    bool flag = false;
    rep(i,3){
        if(s[i] == '7') flag = true;
    }
    Yes(flag);
}



Measured memory_bytes: 3608
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Mix Juice
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

/* global variables */

int ps[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) scanf("%d", ps + i);
  sort(ps, ps + n);

  int sum = 0;
  for (int i = 0; i < k; i++) sum += ps[i];

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


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

using namespace std;

int n,k,r,s,p;
string t, cur;
char m[] = {'r', 's', 'p'};
int v[3];
long long dp[100010][3];

int main() {
    auto win = [] (char x, char y) {
        if(x == 'r' and y == 's') return 1;
        if(x == 's' and y == 'p') return 1;
        if(x == 'p' and y == 'r') return 1;
        return 0;
    };

    auto f = [&win]() {

        for (int i = 0; i <= (int)cur.size(); ++i)
            dp[i][0] = dp[i][1] = dp[i][2] = 0;

        for (int i = cur.size() - 1; i >= 0; i--) {
            for (int k = 0; k < 3; ++k) {
                for (int j = 0; j < 3; ++j) {
                    if(k == j) continue;
                    if(win(m[j], cur[i])) dp[i][k] = max(dp[i][k], dp[i + 1][j] + v[j]);
                    else dp[i][k] = max(dp[i][k], dp[i + 1][j]);
                }
            }
        }
        return max({dp[0][0], dp[0][1], dp[0][2]});
    };

    cin >> n >> k >> v[0] >> v[1] >> v[2] >> t;

    long long ans = 0;
    for (int i = 0; i < k; ++i) {
        cur = "";
        for (int j = i; j < (int)t.size(); j += k) 
            cur += t[j];
        ans += f();
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2944
s_l = list(input())
n = len(s_l)+1
num_l = [0] * n

for i in range(n-1):
    if s_l[i] == '<':
        num_l[i+1] = num_l[i] + 1

for j in range(n-1):
    if s_l[n-2-j] == '>':
        num_l[n-2-j] = max(num_l[n-2-j], num_l[n-2-j+1]+1)

total = 0
for k in num_l:
    total += k

print(total)

Measured memory_bytes: 26860
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> vt(n);
    for(int i=0; i<n; i++){
        cin >> vt[i];
    }
    sort(vt.begin(), vt.end());
    reverse(vt.begin(), vt.end());
    int ali=0, bob=0;
    for(int i=0; i<n/2; i++){
        ali+=vt[i*2];
        bob+=vt[i*2+1];
    }
    if(n%2==0){
        cout << ali-bob;
    }else{
        cout << ali+vt[n-1]-bob;
    }

    return 0;
}

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

int n, a[200200], order[200200];
long long k;
vector<int> id[200200];

int getMove(long long step)
{
  int curId = step % n, val = a[curId], curOrder = order[curId];
  if (curOrder + 1 == id[val].size())
    return id[val][0] + n - curId;
  return id[val][curOrder + 1] - curId;
}

void solve(long long from, long long to)
{
  long long step = from;
  while (step < to)
  {
    int move = getMove(step);
    if (step + move < to) step = step + move + 1;
    else
    {
      cout << a[step % n] << ' ';
      step++;
    }
  }
  cout << endl;
  exit(0);
}

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


  cin >> n >> k;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    order[i] = id[a[i]].size();
    id[a[i]].push_back(i);
  }

  vector<int> seen(n, -1);
  long long step = 0;
  while (step < k * n)
  {
    seen[step % n] = step;
    int move = getMove(step);
    if (step + move + 1 >= k * n) solve(step, k * n);
    else
    {
      step += move + 1;
      if (seen[step % n] >= 0)
      {
        long long  cycle = step - seen[step % n], startCycle = seen[step % n];
        solve(startCycle, startCycle + (k * n - startCycle) % cycle);
      }
    }
  }
}


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

#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ll long long int
 
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	int a[n];
	int cnt=0;
	for(int i=0;i<n;i++)
	{
	     cin>>a[i];
	     if(a[i]>=k)
	     cnt++;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 4028
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll N, K;
    cin >> N >> K;

    // dp[i番目まで][oddness=j][k個保留]
    vv<vector<ll>> dp = vvec(N + 1, 2 * N * N + 1, vector<ll>(N + 1, 0LL));
    dp[0][0][0] = 1;

    rep(i, N) {
        rep(j, N * i + 1) {
            rep(k, i + 1) {
                if (dp[i][j][k] == 0) continue;

                // 数字iをインデックスiに入れる 保留したk個はoddness確定値が1増える
                // 数字iは保留 インデックスiに保留した数字を入れる
                // 数字iを保留したインデックスに入れる インデックスiは保留
                dp[i + 1][j + 2 * k][k] = (dp[i + 1][j + 2 * k][k] + (2 * k + 1) * dp[i][j][k]) % MOD;
                if (k > 0) {
                    // 数字iを保留したインデックスに インデックスiに保留した数字を入れる
                    dp[i + 1][j + 2 * (k - 1)][k - 1] = (dp[i + 1][j + 2 * (k - 1)][k - 1] + k * k * dp[i][j][k]) % MOD;
                }
                // 数字iとインデックスi両方保留
                dp[i + 1][j + 2 * (k + 1)][k + 1] = (dp[i + 1][j + 2 * (k + 1)][k + 1] + dp[i][j][k]) % MOD;
            }
        }
    }

    write(dp[N][K][0]);
}

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

/**
 * https://beta.atcoder.jp/contests/abc073/tasks/abc073_d
 */
public class Main {
	
	static int[][] dp;
	static int[] r;
	static int R;
	static long ans = Long.MAX_VALUE;

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		R = sc.nextInt();
		r = new int[R];
		for(int i=0; i<R; i++) r[i] = sc.nextInt()-1;
		dp = new int[N][N];
		for(int i=0; i<N; i++){
			for(int j=0; j<N; j++){
				dp[i][j] = i==j ? 0 : Integer.MAX_VALUE/2;
			}
		}
		for(int i=0; i<M; i++){
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			dp[a][b] = dp[b][a] = sc.nextInt();
		}
		sc.close();
		
		for(int k=0; k<N; k++){
			for(int i=0; i<N; i++){
				for(int j=0; j<N; j++){
					dp[i][j] = Math.min(dp[i][j], dp[i][k]+dp[k][j]);
				}
			}
		}
		
		dfs(new ArrayList<Integer>(), 0);
		
		System.out.println(ans);
		
	}

	private static void dfs(List<Integer> list, int current) {
		if(list.size()==R){
			ans = Math.min(ans, current);
			return;
		}
		
		for(int next:r){
			if(list.contains(next)) continue;
			List<Integer> newList = new ArrayList<>();
			for(int l:list) newList.add(l);
			int nextCost = current;
			if(list.size()>0){
				nextCost += dp[list.get(list.size()-1)][next];
			}
			newList.add(next);
			dfs(newList, nextCost);
		}
		
	}


}


Measured memory_bytes: 49556
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

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

using namespace std;

struct Team
{
	int point;
	int num;
	string name;

	bool operator< (const Team& t)const
	{
		return point == t.point ?  num < t.num : point < t.point;
 	}

};

int main()
{
	int n;
	bool fisrt = true;
	while(cin >> n && n)
	{

		if(fisrt)
		{
			fisrt = false;
		}
		else
		{
			cout << endl;
		}
		priority_queue<Team> q;
		string s;
		int a,b,c;
		rep(i,n)
		{
			cin >> s >> a >> b >> c;
			Team t;
			t.point = 3*a + c;
			t.num = n-i;
			t.name = s;
			
			q.push(t);
		}

		rep(i,n)
		{
			cout << q.top().name << "," << q.top().point << endl;
			q.pop();
			
		}
		
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll N, M, L, K, X, Y, Z;
ll ans = 0;
int main() {
	cin >> N >> X;
	vector<ll> humb(N + 1);
	vector<ll> p(N + 1);
	humb[0] = 1;
	p[0] = 1;
	for (ll i = 1; i <= N; i++)
	{
		humb[i] = humb[i - 1] * 2 + 3;
		p[i] = p[i - 1] * 2 + 1;
	}
	for (ll i = N-1; i >= 0; i--) {
		if (X == 0)break;
		X--;
		if (X / (humb[i]+1) ==1) {
			ans += (p[i] + 1);
			X -= (humb[i] + 1);
		}
		else if (X / (humb[i] + 1) == 2) {
			ans += 2 * p[i] + 1;
		}
	}
	if (X == 1)ans++;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using ld = long double;
const int MM = 602;

int n, m, USE;
vector<int> adj[MM];
//dest, index
ld ans = 1e16, dis[MM];

ld dfs(int cur){
    if(dis[cur] != -1)
        return dis[cur];
    
    ld ret = 0, mx = 0;
    int cnt = 0;
    for(int u: adj[cur]){
        ret += dfs(u)+1;
        mx = max(mx, dfs(u)+1);
        cnt++;
    }
    
    if(USE == cur && cnt){
        cnt--;
        ret -= mx;
    }
    //cout << cur << ' ' << ret/cnt << '\n';
    return dis[cur] = ret/cnt;
}

void run(){
    for(int i = 1; i < n; i++)
        dis[i] = -1;
    ld v = dfs(1);
        ans = min(ans, v);
}

int main(){
    
    scan(n, m);
    
    for(int i = 0,a,b; i < m; i++){
        scan(a, b);
        adj[a].push_back(b);
    }
    
    cout << fixed;
    cout << setprecision(10);
    
    dis[n] = 0;
    for(int i = 0; i <= n; i++){
        USE = i;
        run();
    }
    
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 1408
/*

Author: @karngyan
Team: BlundersPride

*/

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll M = 42;
const ll N = 1e5+10;
bitset<M> p(0);

bitset<M> a[N];

inline ll val()
{
	return p.to_ulong();
}
inline ll vala(bitset<M> a)
{
	return a.to_ulong();
}

signed main()
{
	fast;
////////////////////////////////////////////////////////////////////////////////////////////
		
	ll n, k;
	cin >> n >> k;
	rep(i,0,n)
	{
		ll e;
		cin >> e;
		bitset<M> t(e);
		a[i] = t;
	}


	ll x[M];
	ll mxi = -1;
	for(ll i = 0 ; i<M ; ++i)
	{
		x[i] = 0;
		for(ll j = 0 ; j<n ; ++j)
		{
			if(a[j][i] == 0)
				x[i]+=1;
		}
	}

	bitset<M> kk(k);
	rep(i,0,M)
	{
		if(kk[i] == 1)
		{
			mxi = max(mxi , i);
		}
	}

	if(mxi == -1)
	{
		ll ans = 0;
		for(auto it : a)
			ans+=vala(it);
		cout<<ans<<endl;
		exit(0);
	}

	bool alread_small = false;
	rrep(i,mxi , -1)
	{
		if(x[i] > (n - x[i]))
		{
			if(kk[i] == 1)
			{
				p[i] = 1;
			}
			else
			{
				if(alread_small)
					p[i] = 1;
				else
					p[i] = 0;
			}

		}
		else
		{
			if(kk[i] == 1)
				alread_small = true;
			p[i] = 0;
		}
	}

	ll ans = 0;
	rep(i,0,n)
	{
		ans+=vala(p^a[i]);
	}
	cout<<ans<<endl;

	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define UM unordered_map
#define MP map
#define ST set
#define US unordered_set
#define V vector
#define S string
#define D deque
#define L list
#define Q queue
#define PQ priority_queue
#define D deque
#define PII pair<int, int>
#define P pair
#define DB double
#define LDB long double
#define FOR(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define FFOR(i, n) for (int(i) = 0; (i) <= (n); ++(i))
#define RFOR(i, n) for (int(i) = (n)-1; (i) >= 0; --(i))
#define all(grid) (grid).begin(), (grid).end()
#define rall(grid) (grid).rbegin(), (grid).rend()

const int dr[] = {0, 1, 0, -1};
const int dc[] = {1, 0, -1, 0};

template <typename T>
void read(T& a) {
  a = 0;
  char c;
  while ((c = cin.peek()) < 48 or c > 57) cin.get();
  while ((c = cin.get()) > 47 and c < 58) a = (a << 3) + (a << 1) + c - 48;
}

template <typename T, typename... Args>
void read(T& a, Args&&... args) {
  read(a);
  read(forward<Args>(args...)...);
}

template <typename T>
void write(const S& sep, const S& end, T n) {
  char c[128] = {0};
  int i = 0;
  for (; n; ++i, n /= 10) c[i] = n % 10;

  for (--i; i >= 0; --i) cout.put(c[i] + 48);

  cout.write(end.c_str(), end.size() * sizeof(char));
}

template <typename T, typename... Args>
void write(const S& sep, const S& end, T n, Args&&... args) {
  char c[128] = {0};
  int i = 0;
  for (; n; ++i, n /= 10) c[i] = n % 10;

  for (--i; i >= 0; --i) cout.put(c[i] + 48);

  cout.write(sep.c_str(), sep.size() * sizeof(char));
  write(sep, end, forward<Args>(args...)...);
}
void solve() {
  int n, x, y;
  cin >> n >> x >> y;
  if (x > y) swap(x, y);
  VI v(n);
  for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
          int dist = min(j - i, abs(x - i) + 1 + abs(y - j));
          ++v[dist];
      }
  }
  for (int k = 1; k < n; ++k) {
      cout << v[k] << "\n";
  }
}

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


Measured memory_bytes: 3648
loop do
  h, w = gets.split.map(&:to_i)
  break if h == 0 && w == 0
  
  evenChess = (0...w).map { |i| i.even? ? "#" : "." }.join
  oddChess = (0...w).map { |i| i.even? ? "." : "#" }.join
  
  h.times do |i|
      chess = i.even? ? evenChess : oddChess
      puts chess
  end
  puts
end

Measured memory_bytes: 8652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    set<char> s;
    for(int i=0;i<N;i++){
        char c;
        cin >> c;
        s.insert(c);
    }
    cout << ((int) s.size()==3? "Three\n":"Four\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<map>
#include<algorithm>
#include<iomanip>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;



int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int t = max(x, y);
	ll ans = 1e9 + 2;
	rep(i, 2*t + 1) {
		int v, w, cost;
		v = x - (i / 2);
		w = y - (i / 2);
		cost = max(0, v) * a + max(0, w) * b + i * c;
		ans = min((ll)cost, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a, b;
	scanf("%d %d", &a, &b);
	if(a < b) printf("a < b\n");
	if(a > b) printf("a > b\n");
	if(a == b) printf("a == b\n");
	
	return 0;
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll a, b;

	cin >> a >> b;

	if (a <= 8 && b <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 256
package main

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

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func main() {
	sc := NewScanner()
	K, T := sc.NextInt(), sc.NextInt()
	A := sc.NextIntArray()

	if T == 1 {
		fmt.Println(K - 1)
		return
	}

	mx := 0
	for _, v := range A {
		mx = max(mx, v)
	}
	if mx > (K + 1) / 2 {
		if K % 2 == 0 {
			fmt.Println(2 * (mx - (K + 1) / 2) - 1)
		} else {
			fmt.Println(2 * (mx - (K + 1) / 2))
		}
	} else {
		fmt.Println(0)
	}

}

func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}


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

int main(){
    string k="keyence";
    int np=0;
    int use=0;
    string s;
    cin>>s;
    rep(i,k.size()){
        string hk=k.substr(0,i);
        string tk=k.substr(i);
        int hind=s.find(hk);
        int tind=s.rfind(tk);
    
        if(hind<tind and ((hind!=0 and hind+i==tind) or (tind!=0 and hind==0 and hind+i==tind) or (hind==0 and tind+k.size()-i==s.size()))) {
            cout<<"YES"<<endl;
            return 0;
            }
    }
    cout<<"NO"<<endl;
 
    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
	for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
		s << v[i];
  }
  s << "]";
  return s;
}

vector<pair<char, int>> RLE(vector<char> xs) {
  vector<pair<char, int>> es;

  char current = xs[0];
  int current_count = 1;
  for (int i = 1; i < xs.size(); i++) {
    if (xs[i] == current) {
      current_count++;
    } else {
      es.push_back(make_pair(current, current_count));
      current = xs[i];
      current_count = 1;
    }
  }
  es.push_back(make_pair(current, current_count));
  return es;
}

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

  string s;
  cin >> s;

  vector<char> cs(s.begin(), s.end());
  auto es = RLE(cs);

  int64 sum = 0;
  for (int i = 0; i < es.size(); i++) {
    if (i + 1 < es.size() && es[i].first == '<' && es[i + 1].first == '>') {
      int64 x1 = get<1>(es[i]);
      int64 x2 = get<1>(es[i + 1]);
      if (x1 >= x2) x2--;
      else x1--;
      sum += x1 * (x1 + 1) / 2;
      sum += x2 * (x2 + 1) / 2;
      i++;
      // cout << "sum (path 1): " << sum << endl;
    } else {
      int64 x = get<1>(es[i]);
      sum += x * (x + 1) / 2;
    }
  }
  cout << sum << endl;
}

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

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(100005);


int main() {

  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());

  mint ans(0);
  for (int i = K - 1; i < N; i++) {
    mint res =  comb(i, K - 1);
    ans += A[i] * res.x;
  }

  reverse(A.begin(), A.end());
  for (int i = K - 1; i < N; i++) {
    mint res =  comb(i, K - 1);
    ans -= A[i] * res.x;
  }

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <cstdio>
#include <stdio.h>
#include <string.h>

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

    if(n%4==0||n%7==0){
        printf("Yes\n");
        return 0;
    }

    int i,j;
    for (i = 0; i < 101;i++){
        for (j = 0; j < 101;j++){
            int ans = i * 4 + j * 7;
            if(n==ans){
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}

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

int main(){

    int N, A, B;
    cin >> N >> A >> B;

    int ans = 0;
    for(int i = 1; i <= N; i++){
        string num = to_string(i);
        int sum = 0;
        for(int j = 0; j < num.length(); j++){
            sum += (num[j] - '0');
        }
        if(A <= sum && sum <= B) ans += i;
    }
    cout << ans << endl;

    return 0;
}

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

int main(void){
  int a,b,k;
  scanf("%d",&k);
  scanf("%d %d",&a, &b);
 int i;
  for(i=a; i<=b; i++){
    if(i % k == 0){
      printf("OK");
      return 0;
    }
  }
  printf("NG");
  return 0;
}
 

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

int main(){
  int x, y;
  cin >> x >> y;

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

}


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

int main(){
	int a,b;
	cin>>a>>b;
	if(a==1)a=14;
	if(b==1)b=14;
	if(a>b)cout<<"Alice"<<endl;
	else if(a==b)cout<<"Draw"<<endl;
	else cout<<"Bob"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s, t;
    cin >> s >> t;
    map<char, vector<ll>> mp;
    ll sn = s.size(), tn = t.size();
    rep(i, sn){
        mp[s[i]].push_back(i);
    }
    rep(i, tn){
        if (mp.find(t[i]) == mp.end()){
            cout << -1 << endl;
            return 0;        
        }
    }

    int left = 0;
    ll ans = 0;
    while(left < tn){
        ll a = -1;
        vector<int> pos(26);
        while(left < tn){
            char c = t[left];
            int pi = pos[c-'a'];
            int si = upper_bound(mp[c].begin()+pi, mp[c].end(), a) - mp[c].begin();
            if (si == mp[c].size()) break;
            else{
                a = mp[c][si];
                pos[c-'a'] = si + 1;
                left++;
            }
        }
        if (left == tn){
            ans += a + 1LL;
        }else{
            ans += sn;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4632
#include<cstdio>
main(){int A,B,C,D,i;scanf("%1d%1d%1d%1d",&A,&B,&C,&D);for(i=0;i<8;i++)if(A+(i/4%2?-B:B)+(i/2%2?-C:C)+(i%2?-D:D)==7){char p[]={'+','-'};printf("%d%c%d%c%d%c%d=7\n",A,p[i/4%2],B,p[i/2%2],C,p[i%2],D);return 0;}}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define SIZE 100333
#define MOD 1000
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef vector<vector<long long> > mat;
 
ll n,a,b, dc[111][111];
ll v[111], d[111][111];
 
ll dp(int layer, int canChoose) {
	if(canChoose == 0)	return 0;
	if(layer == n)		return -INF;
	if(d[layer][canChoose] != -1)	return d[layer][canChoose];
	ll ret = 0;
	if(canChoose >= 1)	ret = max(ret, v[layer] + dp(layer+1, canChoose-1));
	ret = max(ret, dp(layer+1, canChoose));
	return d[layer][canChoose] = ret;
}
 
ll cnt(int layer, int canChoose) {
	// printf("cnt %d %d\n",layer,canChoose);
	if(canChoose == 0)			return 1;
	if(layer == n)				return 0;
	if(dc[layer][canChoose] != -1)	return dc[layer][canChoose];
	ll chk = d[layer][canChoose];
	ll ret = 0;
	if(canChoose >= 1 && v[layer] + dp(layer+1,canChoose-1) == chk)	ret += cnt(layer+1, canChoose-1);
	if(dp(layer+1, canChoose) == chk)							ret += cnt(layer+1, canChoose);
	// printf("ret %lld\n",ret);
	return dc[layer][canChoose] = ret;
}
 
int main () {
	for(int i=0;i<111;i++)	for(int j=0;j<111;j++)	d[i][j] = -1;
	memset(dc,-1,sizeof(d));
	scanf("%lld%lld%lld",&n,&a,&b);
	for(int i=0;i<n;i++)	scanf("%lld",v+i);
 
	ll retVal = 0, retIdx = -1;
	ll retCnt = 0;
	for(int i=a;i<=b;i++) {
		ll cand = dp(0,i);
		if(retIdx == -1)	retVal = cand, retIdx = i, retCnt = cnt(0,i);
		else if(cand * retIdx > retVal * i) {
			retVal = cand;
			retIdx = i;
			retCnt = cnt(0,i);
		}
		else if(cand * retIdx == retVal * i)
			retCnt += cnt(0,i);
	}
	db ans = (db)retVal / (db)retIdx;
	printf("%.6lf\n",ans);
	printf("%lld\n",retCnt);
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

int main(){
   int n,k;
   cin>>n>>k;
   int ans=1;
   if(n%k==0)ans=0;
   cout<<ans<<endl;
}

   


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

#define x first
#define y second

#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cerr << #x << ": " << x << endl;
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

#define x1 xx1
#define y1 yy1
#define x2 xx2
#define y2 yy2

int x1,y1,x2,y2;
bool nx,ny;
int N;

template<class T>
struct SegmentTree {
	T I,t[4]; int N;
	vector<T> A;

	SegmentTree(int N, T I=T()): I(I), N(N), A(2*N,I) {}
	SegmentTree(const vector<T>& data, T I=T()): I(I), N(data.size()), A(2*N,I)
	{
		copy(data.begin(),data.end(),A.begin()+N);
		for (int i=N-1;i;i--) A[i].op(A[2*i],A[2*i+1]);
	}

	void update(int i,T v) {
		for (A[i+=N]=v;i/=2;) A[i].op(A[2*i],A[2*i+1]);
	}

	T query(int l,int r) {
		t[0]=t[2]=I;
		int i=0,j=2;
		for (l+=N,r+=N;l<r;l/=2,r/=2) {
			if (l&1) t[i^1].op(t[i],A[l++]), i^=1;
			if (r&1) t[j^1].op(A[--r],t[j]), j^=1;
		}
		t[i^1].op(t[i],t[j]);
		return t[i^1];
	}

	template<class...Ts>
	pair<int,T> queryRight(int l,Ts...args) {
		int r=l,w=1,p=0;
		t[0]=I;

		for (l+=N;r+2*w<=N && (t[1-p].op(t[p],A[l]),t[1-p].b(args...));)
			if (l&1) l++,r+=w,p^=1;
			else l/=2,w*=2;
		for (;w;l*=2,w/=2) if (r+w<=N && (t[1-p].op(t[p],A[l]),t[1-p].b(args...)))
			l++,r+=w,p^=1;

		return {r,t[p]};
	}

	template<class...Ts>
	pair<int,T> queryLeft(int r,Ts...args) {
		int l=r,w=1,p=0;
		t[0]=I;

		for (r+=N;l>=2*w && (t[1-p].op(A[r-1],t[p]),t[1-p].b(args...));)
			if (r&1) r--,l-=w,p^=1;
			else r/=2,w*=2;
		for (;w;r*=2,w/=2) if (l>=w && (t[1-p].op(A[r-1],t[p]),t[1-p].b(args...)))
			r--,l-=w,p^=1;

		return {l,t[p]};
	}
};

struct RangeMax {
		int a=0;
		void op(RangeMax& b,RangeMax& c) {a=max(b.a,c.a);}
		//bool b(int v) {return a>=v;}
	};

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

	cin >> x1 >> y1 >> x2 >> y2;
	x2-=x1;y2-=y1;
	nx=x2<0;ny=y2<0;
	x2=abs(x2);y2=abs(y2);

	vector<ii> pts;
	vi yvals;

	cin >> N;
	for (int i=0;i<N;i++) {
		int x,y;cin >> x >> y;
		x-=x1;y-=y1;
		if (nx) x=-x;
		if (ny) y=-y;
		if (0<=x && x<=x2 && 0<=y && y<=y2) {
			pts.emplace_back(x,y);
			yvals.push_back(y);
		}
	}

	sort(pts.begin(),pts.end());
	sort(yvals.begin(),yvals.end());

	N=pts.size();

	SegmentTree<RangeMax> st(N);

	for (int i=N-1;i>=0;i--) {
		int idx=lower_bound(yvals.begin(),yvals.end(),pts[i].y)-yvals.begin();
		int val=st.query(idx+1,N).a;
		RangeMax u;
		u.a=val+1;
		st.update(idx,u);
	}

	int numhit = st.query(0,N).a;

	const double pi = acos(-1);
	double ans=100.0*(x2+y2)-10.0*numhit*(2-pi/2);

	if (numhit>min(x2,y2)) ans+=10*(pi/2);

	cout << fixed << setprecision(20) << ans << endl;


}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int h,w;
    cin>>h>>w;
    char a[h][w];
    rep(i,h)rep(j,w) cin>>a[i][j];
    //偶数、偶数→全登場文字が4の倍数であればよい
    int cnt[26]={};
    rep(i,h)rep(j,w) cnt[a[i][j]-'a']++;
    if(h%2==0&&w%2==0){
        bool f=true;
        for(auto x:cnt) if(x%4!=0) f=false;
        cout<<(f?"Yes":"No")<<endl;
    }
    if(h%2==1&&w%2==0){
        //2の倍数でも許されるのがw/2個ある
        int c2=0;
        for(auto x:cnt){
            if(x%4==0) continue;
            if(x%4!=0&&x%2==0) c2++;
            else if(x%4!=0&&x%2!=0){
                cout<<"No"<<endl;return 0;
            } 
        }
        if(c2>w/2) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    if(w%2==1&&h%2==0){
        //2の倍数でも許されるのがw/2個ある
        int c2=0;
        for(auto x:cnt){
            if(x%4==0) continue;
            if(x%4!=0&&x%2==0) c2++;
            else if(x%4!=0&&x%2!=0){
                cout<<"No"<<endl;return 0;
            } 
        }
        if(c2>h/2) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    if(w%2==1&&h%2==1){
        //1個なんでも許される
        int y2=(h-1)/2+(w-1)/2,y1=1;
        for(auto x:cnt){
            if(x%4==0) continue;
            if(x%4!=0&&x%2==0) y2--;
            else y1--;
        }
        cout<<(y2>=0&&y1>=0?"Yes":"No")<<endl;
    }
    return 0;
}


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

int n,m;
vector<int> G[100001];
vector<int> mdfG[100001];
bool useless[100001];
int cutted[100001];
bool used[100001];
vector<int> route;
int cmp[100001];
int all=0;
int ans=0;

set<deque<int> > se;

void dfs(int v,int p){
	used[v]=true;
	route.push_back(v);
	for(int i=0;i<mdfG[v].size();i++){
		int next=mdfG[v][i];
		if(p!=next){
			if(!used[next]){
				dfs(next,v);
			}else{
				deque<int> tmp;
				int si=route.size()-1;
				while(route[si]!=next){
					tmp.push_back(route[si]);
					si--;
				}
				tmp.push_back(next);
				int best=next;
				for(int j=0;j<tmp.size();j++){
					best=min(best,tmp[j]);
				}
				while(best!=tmp[0]){
					int tp=tmp.front();
					tmp.pop_front();
					tmp.push_back(tp);
				}
				se.insert(tmp);
			}
		}
	}
	used[v]=false;
	route.pop_back();
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if(m==n-1){
		printf("0\n");
	}else if(m==n){
		printf("1\n");
	}else{
		queue<int> que;
		memset(cmp,-1,sizeof(cmp));
		for(int i=0;i<n;i++){
			if(G[i].size()==1){
				que.push(i);
				useless[i]=true;
			}
		}
		while(que.size()){
			int v=que.front();
			que.pop();
			for(int i=0;i<G[v].size();i++){
				int next=G[v][i];
				cutted[next]++;
				if(!useless[next] && G[next].size()==cutted[next]+1){
					useless[next]=true;
					que.push(next);
				}
			}
		}
		for(int i=0;i<n;i++){
			if(G[i].size()-cutted[i]>=3){
				cmp[i]=all++;
				for(int j=0;j<G[i].size();j++){
					int next=G[i][j];
					if(useless[next])continue;
					if(G[next].size()-cutted[next]<=2){
						if(cmp[next]==-1){
							cmp[next]=all++;
							que.push(next);
						}
					}
				}
			}
		}
		if(que.size()==0){
			for(int i=0;i<n;i++){
				if(!useless[i]){
					que.push(i);
					cmp[i]=0;
					all++;
					break;
				}
			}
		}
		while(que.size()){
			int v=que.front();
			que.pop();
			for(int i=0;i<G[v].size();i++){
				if(cmp[G[v][i]]==-1 && !useless[G[v][i]]){
					cmp[G[v][i]]=cmp[v];
					que.push(G[v][i]);
				}
			}
		}
		for(int i=0;i<n;i++){
			if(useless[i])continue;
			for(int j=0;j<G[i].size();j++){
				if(cmp[i]!=cmp[G[i][j]] && !useless[G[i][j]])mdfG[cmp[i]].push_back(cmp[G[i][j]]);
			}
		}
		for(int i=0;i<all;i++){
			sort(mdfG[i].begin(),mdfG[i].end());
			mdfG[i].erase(unique(mdfG[i].begin(),mdfG[i].end()),mdfG[i].end());
		}
		dfs(0,-1);
		printf("%d\n",se.size()/2);
	}
	return 0;
}

Measured memory_bytes: 70944