akhauriyash/Code-Regression huggingface dataset:
use List::Util qw(max min sum);
use Time::HiRes qw(gettimeofday tv_interval);

my ($ssec, $smsec) = gettimeofday();

my ($d) = split(/\s+/, <>);
my (@c) = (-1, split(/\s+/, <>));

my @s = ();
for my $i (1..$d) {
    $s[$i] = [-1, split(/\s+/, <>)];
}

sub score {
    my (@contest) = @_;
    my $ret = 0;
    my @last = (-1); for (1..26) { push @last, 0; }
    my $j = 1;

    for my $i (@contest) {
	$ret += $s[$j][$i];
	$last[$i] = $j;
	for (1..26) {
	    $ret -= $c[$_] * ($j-$last[$_]);
	}
	$j++;
    }
    return $ret;
}

sub max_index {
    my (@list) = @_;
    my $maxi = 0;
    for (my $i=0; $i<scalar(@list); $i++) {
	$maxi = $i if $list[$maxi] < $list[$i];
    }
    return $maxi;
}

sub over_index {
    my ($val, @list) = @_;
    my @ret = ();
    for (my $i=0; $i<scalar(@list); $i++) {
	push @ret, $i if $list[$i] > $val;
    }
    return @ret;
}

my @last = (-1); for (1..26) { push @last, 0; }
my @cont = ();
for my $j (1..$d) {
    my $max = max(@{$s[$j]});
    my @can = (1..26);
    
    my $index = -1;
    my $maxre = 0;
    for my $i (@can) {
	my $re = $s[$j][$i] + $c[$i] * ($j-$last[$i]);
	if ($maxre < $re) { $maxre=$re; $index = $i; }
    }
    #push @cont, max_index(@{$s[$j]});
    push @cont, $index;
    $last[$index] = $j;
}

my $score = score(@cont);
while (1) {
    my ($sec, $msec) = gettimeofday();
    #print "$score : $sec $msec\n";
    last if ($sec+$msec/1000000 - $ssec-$smsec/1000000 > 1.9);
    my @new = @cont;
    $new[int(1+rand($d))] = int(1+rand(26));
    my $new_score = score(@new);
    if ($new_score > $score) {
	$score = $new_score;
	@cont = @new;
    }
}

print join("\n", @cont), "\n";


Measured memory_bytes: 7224
#include<iostream>
#include<queue>

struct data{
	int num;
	long long pri;
	long long cun;
};

struct ret{
	int num;
	long long sales;
};

int main(){
	while (1){
		int n;
		std::cin >> n;
		if (n == 0)break;
		std::queue<data> que;
		for (int i = 0; i < n; ++i){
			data person;
			std::cin >> person.num >> person.pri >> person.cun;
			que.push(person);
		}
		std::vector<ret> lis;
		while (!que.empty()){
			data perso = que.front();
			if (!lis.empty()){
				bool f = false;
				for (auto it = lis.begin(); it != lis.end(); ++it){
					ret pers = *it;
					if (perso.num == pers.num){
						f = true;
						//std::cout << "t" << std::endl;
						//std::cout << pers.sales << std::endl;
						pers.sales += perso.cun * perso.pri;
						//std::cout << pers.sales << std::endl;
						std::swap(pers, *it);
					}
				}
				if (!f){
					ret newperson;
					newperson.num = perso.num;
					newperson.sales = perso.cun * perso.pri;
					lis.push_back(newperson);
				}
			}
			else{
				ret newperson;
				newperson.num = perso.num;
				newperson.sales = perso.cun * perso.pri;
				lis.push_back(newperson);
			}
			que.pop();
		}
		bool exist = false;
		for (auto it = lis.begin(); it != lis.end(); ++it){
			ret per = *it;
			//std::cout << per.num << " " << per.sales << std::endl;
			if (per.sales >= 1000000)std::cout << per.num << std::endl, exist = true;
		}
		if (!exist)std::cout << "NA" << std::endl;
	}
	//std::system("pause");
	return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;
const double PI = acos(-1);

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
  vector<int> p;
  vector<int> s;
  void init(int n) {
    p.resize(n, -1);
    s.resize(n, 1);
  }
  int find(int n) {
    if(p[n] == -1) return n;
    else return find(p[n]);
  }
  int size(int n) {
    return s[find(n)];
  }
  void unite(int n, int m) {
    int pn = find(n);
    int pm = find(m);
    if(pn == pm) return;
    if(s[pn] > s[pm]) {
      s[pn] = s[pn] + s[pm];
      p[pm]= pn;
    } else {
      s[pm] = s[pm] + s[pn];
      p[pn] = pm;
    }
  }
};

long long gcd(long long a, long long b) {
  if(a % b == 0) return b;
  else return gcd(b, a % b);
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> friends(n);
  UnionFind uf;
  uf.init(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;a--;b--;
    friends[a]++;friends[b]++;
    uf.unite(a, b);
  }
  vector<int> candidate(n);
  rep(i, n) {
    candidate[i] = uf.size(i) - friends[i] - 1;
  }
  rep(i, k) {
    int c,d;
    cin >> c >> d;c--;d--;
    if(uf.find(c) == uf.find(d)) {
      candidate[c]--;candidate[d]--;
    }
  }
  rep(i, n) {
    cout << candidate[i];
    if(i == n-1) cout << endl;
    else cout << " ";
  }
  return 0;
}


Measured memory_bytes: 2432
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}


signed main(){
	
	ll a,b,c,ans = 0,memo = 0;
	cin >> a >> b >> c;
	
	ans = c/a * b;
	
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, m, n) for(ll i = (ll)m; i < (ll)n; i++)
#define PER(i, m, n) for(ll i = (ll)m; i > (ll)n; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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;
}

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    REP(i, 0, n) cin >> v[i];
    ll len = v.size();
    ll ans = 1;
    ll sum = k;

    while(sum < len){
        ans++;
        sum += k-1;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3948
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> arr(N, 0);
    for(int i = 0; i < N; i++) {
        cin >> arr[i];
    }
    int ans = 1;
    int pos = 0;
    for(int i = 0; i < N; i++) {
        if (pos + arr[i] <= X) {
            pos += arr[i];
            ans += 1;
        } else {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
board = Array.new(6) { Array.new(6) { Array.new 4 } }
9.times do |i|
  ws = gets.chomp.each_char.map {|c| c == ?0 ? false : true }
  if i % 2 == 0
    ws.each_with_index do |w, j|
      board[i/2][j+1][3] = board[i/2+1][j+1][1] = true if w
    end
  else
    ws.each_with_index do |w, j|
      board[i/2+1][j][0] = board[i/2+1][j+1][2] = true if w
    end
  end
end
x, y, d = 1, 0, 0
until x == 0 && y == 1 && d == 2 || x == 0 && y == 0 && d == 1
  if board[y][x][(d+3)%4]
    if board[y][x][d]
      print %w[R U L D][d]
      d = (d + 1) % 4
    else
      dx, dy = [[1, 0], [0, -1], [-1, 0], [0, 1]][d]
      x += dx
      y += dy
      print %w[R U L D][d]
    end
  else
    d = (d - 1) % 4
    dx, dy = [[1, 0], [0, -1], [-1, 0], [0, 1]][d]
    x += dx
    y += dy
  end
end
puts

Measured memory_bytes: 8736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll MOD = 1000000007;
    int N;
    cin >> N;
    vector<string> A(N);
    for (int i = 0; i < N; i++) {
        ll x;
        cin >> x;
        bitset<60> a(x);
        A[i] = a.to_string();
    }
    
    ll ans = 0;
    for (int i = 0; i < 60; i++) {
        ll count[2] = {0, 0};
        for (int j = 0; j < N; j++) {
            if (A[j][i] == '0')
                count[0]++;
            else
                count[1]++;
        }
        ans += ((count[0]*count[1]%MOD) * ((ll)pow(2, (59-i)) % MOD))%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 30720
n, x, y = map(int, input().split())

ans = {i:0 for i in range(1, n)}

for i in range(1, n):
    for j in range(i + 1, n + 1):
        d = min(j - i, abs(i - x) + 1 + abs(j - y))
        ans[d] += 1

for k in range(1, n):
    print(ans[k])

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	int a[3];
	for (int i=0; i<3; i++) cin >> a[i];
	sort(a, a+3);
	cout << a[0] * a[1] / 2 << '\n'; 
	
	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);
		String word = sc.next();
		String[] array = word.split("");
		if(array[2].equals(array[3]) && array[4].equals(array[5])) {
			System.out.println("Yes");
		}
		else
			System.out.println("No");
	}

}


Measured memory_bytes: 21972
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end


N=gets.to_i
a=get_i.sort{|x,y| y<=>x}
ans=[]
(3*N).times do|i|
    if (i+1).even?
        ans.push(a[i])
        break if ans.size==N
    end
end
puts ans.inject(:+)

Measured memory_bytes: 30708
s = str(input())
k = int(input())

check = []
a = min(len(s),k)
for i in range(len(s)):
    for j in range(a):
        if i <= i+j <=len(s)+1:
            check.append(s[i:i+j+1])
            
print(sorted(set(check))[k-1])

Measured memory_bytes: 5068
Module Program
  Sub Main
    Dim s = GetInts()
    Dim a=s(0),b=s(1),c=s(2)
    Dim ans=If(a+b<c,"No","Yes")
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 
#define pb push_back
#define sz(a) (int)a.size()

const int INF=1e9+7;

void solve(){
	int n,k;
	cin >> n >> k;
	int h[n];
	for(int i=0;i<n;++i) cin >> h[i];
	vi dp(n,INF);
	dp[0]=0;
	for(int i=1;i<n;++i){
		for(int j=max(0,i-k);j<=i-1;++j){
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
		}
	}
	cout << dp[n-1] << nl;
}
			
		

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

	solve();
	
	return 0;
}


Measured memory_bytes: 4048
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int x = sc.nextInt();
        int n = sc.nextInt();
        int min = 300;
        int ans = 0;
        List<Integer> array = new ArrayList<>(n);
        for(int i=0; i<n; i++) array.add(sc.nextInt());
        for(int i=-100; i <= 200; i++){
            if(array.contains(i)) continue;
            int abs = Math.abs(x - i);
            if(abs < min){
                min = abs;
                ans = i;
            }
        }
        out.println(ans);

        out.flush();

    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int x, a, b; cin >> x >> a >> b;
    if(abs(x-a) < abs(x-b)) cout << "A" << endl;
    else cout << "B" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int main() {
    string N;

    cin >> N;

    if ( ((N[0] == N[1]) && (N[1] == N[2])) || ((N[1] == N[2]) && (N[2] == N[3]))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main() {
	int a;
	cin >> a;
	if (a == 1) {
		cout << "Hello World" << endl;
		return 0;
	}

	int b, c;
	cin >> b >> c;
	cout << b + c << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; map<string, int> M; 
	map<string, bool> checked; 
	cin >> N; 
	string S[200010];
	int mx = 0; 
	for(int i = 0; i < N; i++){
		cin >> S[i]; M[S[i]] ++; 
		mx = max(mx, M[S[i]]); 
	}
	vector<string> ans; 
	for(int i = 0; i < N; i++){
		if(checked[S[i]]) continue; 
		checked[S[i]] = true; 
		if(M[S[i]] == mx) ans.push_back(S[i]); 
	}
	sort(ans.begin(), ans.end()); 
	for(int i = 0; i < ans.size(); i++){
		cout << ans.at(i) << endl; 
	}
}

Measured memory_bytes: 40816
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
  
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll n , i, j;
    cin >> n;
    vector<string> s = {"AC", "WA", "TLE", "RE"};
    map<string,ll> m;
    for(i = 0; i < n; i++)
    {
        string ss;
        cin >> ss;
        m[ss]++;
    }
    for(i = 0; i <4; i++)
    {
        cout << s[i] << " x " << m[s[i]] << "\n";
    }

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL); 
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int cnt=0;
    while (b<=a) {
        b*=2;
        cnt++;
    }
    while (c<=b) {
        c*=2;
        cnt++;
    }
    if (cnt<=k) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

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

int main() {
	long long n, x;

	std::cin >> n >> x;

	std::vector<long long> v(n);

	for (long long i = 0; i < n; i++)
	{
		std::cin >> v[i];
		v[i] = std::abs(x - v[i]);
	}

	if (n == 1) {
		std::cout << v[0] << std::endl;
		return 0;
	}

	long long ans = gcd(v[0], v[1]);

	for (long long i = 2; i < n; i++)
	{
		ans = gcd(ans, v[i]);
	}

	std::cout << ans << std::endl;


	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

int main(){

	int n;cin>>n;
	vi h(n);

	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int dp[n+7];
	mem(dp,0);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
		// trace2(i,dp[i])
	} 
	cout<<dp[n-1];
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 1024
<?php
  $str = trim(fgets(STDIN));
  $result = "";
  while (true) {
    $ary = explode(" ", trim(fgets(STDIN)));
    $result = "  " . $result . join("  ", $ary) . "  ";
    if (join("", $ary) == "END_OF_TEXT") {
      $result = strtolower($result);
      $str = (' ' . strtolower($str) . ' ');
      print(substr_count($result, $str) . "\n");
      return;
    }
  }
?>

Measured memory_bytes: 6572
#include<cstdio>
#include<queue>
#include<algorithm>
#define ld long double
#define MN 210000
using namespace std;

int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
struct na{int y,ne;}b[MN];
int n,m,l[MN],num=0,x,y,s[MN];
inline void in(int x,int y){
	b[++num].y=y;b[num].ne=l[x];l[x]=num;
}
void dfs(int x,int f){
	int u=0;s[x]=0;
	for (int i=l[x];i;i=b[i].ne)
	if (b[i].y!=f){
		dfs(b[i].y,x);u^=s[b[i].y]+1;
	}
	
	s[x]=u;
	/*for (int i=l[x];i;i=b[i].ne)
	if (b[i].y!=f){
		if ((u^s[b[i].y])==0) s[x]=1;
	}*/
	//printf("%d %d\n",x,s[x]);
}
int main(){
	n=read();
	for (int i=1;i<n;i++) x=read(),y=read(),in(x,y),in(y,x); 
	
	dfs(1,0);
	puts(s[1]?"Alice":"Bob");
}

Measured memory_bytes: 7168
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a;
	cin >> a;
	cout << a + sq(a) + (a * a * a) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3644
#include <stdio.h>

int main()
{
	int i, N, P[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(P[i]));
	
	int min = P[1], count = 1;
	for (i = 2; i <= N; i++) {
		if (P[i] < min) {
			min = P[i];
			count++;
		}
	}
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	vector<int> a(N), b(N), c(N);
	a.at(0) = 0;
	for (int i = 1; i < N; i++) {
		if (S.at(i-1) == 'W') {
			a.at(i) = a.at(i-1) + 1;
		}
		else {
			a.at(i) = a.at(i-1);
		}
	}
	b.at(N-1) = 0;
	for (int i = N-2; i > -1; i--) {
		if (S.at(i+1) == 'E') {
			b.at(i) = b.at(i+1) + 1;
		}
		else {
			b.at(i) = b.at(i+1);
		}
	}
	for (int i = 0; i < N; i++) {
		c.at(i) = a.at(i) + b.at(i);
	}
	int ans = c.at(0);
	for (int i = 1; i < N; i++) {
		ans = min(ans, c.at(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 4228
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main(){
int a,b,x;
cin>>x>>a>>b;

if(b-a>x)
{
cout<<"dangerous"<<endl;
}
else if(a>=b)
{
cout<<"delicious"<<endl;
}
else {
cout<<"safe"<<endl;
}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k,c;cin>>n>>k>>c;
    string s;cin>>s;
    vector<ll> gr0(n,-1), gr1(n,-1);
    ll prev = -INF;
    ll idx = 0;
    for(int i=0; i<n&&idx<k; i++){
        if(s[i]=='x'||i-prev<=c)continue;
        else {gr0[i]=idx;idx++;prev=i;}
    }
    prev=INF;
    idx = k-1;
    for(int i=n-1; i>=0&&idx>=0; i--){
        if(s[i]=='x'||prev-i<=c)continue;
        else {gr1[i]=idx;idx--;prev=i;}
    }
    for(int i=0; i<n; i++){
        if(gr0[i]==gr1[i]&&gr1[i]!=-1)cout<<i+1<<endl;
    }
/*
    for(ll x:gr0)cout<<x<<",";
    cout<<endl;
    for(ll x:gr1)cout<<x<<",";*/

    return 0;
}

Measured memory_bytes: 5012
import bisect
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
 
#C[i]=パワーがi以下の人数
C=[0]*(10**5*2+1)
for a in A:
    C[a]+=1
for i in range(1,len(C)):
    C[i]+=C[i-1]
 
#和がx以上になる組み合わせの総数を求める関数
def pattern_num_ge_x(x):
    p=0
    for a in A:
        p+=(N-(C[x-a-1] if x-a-1>=0 else 0))
    return(p)
 
#pattern_num_ge_x(x)がM未満になる最小のxを探す(=r)
#lはM以上になる最大のx
l=-1
r=10**5*2+1
while r-l>1:
    m=(r+l)//2
    if pattern_num_ge_x(m)<M:
        r=m
    else:
        l=m
 
#和がr以上になる組み合わせの総和を求める(累積和を使用)
S=[0]+list(reversed(A[:]))
for i in range(1,N+1):
    S[i]+=S[i-1]
ans=0
for a in A:
    idx=bisect.bisect_left(A,r-a)
    ans+=a*(N-idx) + S[N-idx]
    M-=(N-idx)
 
#回数のあまり分lを足す
ans+=l*M
 
print(ans)

Measured memory_bytes: 57564
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld\n",x)
#define print2(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 333333

ll a[MAX];

int main(void) {
  string t;
  cin >> s;
  cin >> t;
  rep(i, 33) a[i] = -1;

  rep(i, s.length()) {
	tmp = s[i] - 'a';
	if (a[tmp] == -1) a[tmp] = t[i] - 'a';
	else if (a[tmp] != t[i] - 'a') ok = false;
  }

  rep(i, 33) {
	if (a[i] == -1) continue;
	rep(j, 33) {
	  if (a[j] == -1 || i == j)continue;
	  if (a[i] == a[j]) ok = false;
	}
  }

  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct anss{int a,b,c,d;};
int H,W;
int A[505][505];

int main()
{
	cin >> H >> W;
	rep(i,0,H) rep(j,0,W) cin >> A[i][j];
	vector<anss> ans;

	rep(i,0,H) rep(j,0,W-1) {
		if(A[i][j]%2 == 1){
			ans.push_back((anss){i,j,i,j+1});
			A[i][j+1]++;
		}
	}

	rep(i,0,H-1) {
		if(A[i][W-1]%2 == 1){
			ans.push_back((anss){i,W-1,i+1,W-1});
			A[i+1][W-1]++;
		}
	}

	cout << ans.size() << endl;
	rep(i,0,ans.size()) {
		cout << ans[i].a+1 << " " << ans[i].b+1
			<< " " << ans[i].c+1 << " " << ans[i].d+1 << endl;
	}

	return 0;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
   if(s[0]==s[1] && s[0]==s[2]&& s[0]==s[3]&&s[1]==s[2]&& s[1]==s[3]&&s[2]==s[3]){
       cout << "No";
   }
   
   else if(s[0]==s[1] && s[2]==s[3]){
       cout << "Yes";
   }
    else if(s[0]==s[2]&& s[1]==s[3]){
       cout <<"Yes";
   }
   else if (s[0]==s[3]&&s[1]==s[2]){
       cout <<"Yes";
   }
   
   else cout <<"No";
}

Measured memory_bytes: 256
/**
 *   author: Shubham Srivastava
 *   created: 26 January 2020  21:23:32
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 0x7fffffff
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.rbegin(),v.rend())
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
ll parent[2000005];

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n;cin>>n;
    ll count = 1;
    ll ans = 0;
    while(n != 1){
    	ans += pow(2,count);
    	count++;
    	n = n/2;
    }
    cout<<ans+1;
   	return 0;
}

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

int r, c;
int s[10][10000];

int rec(int step)
{

    int ret = 0;
    if(step == r) {
        for(int j = 0; j < c; j++) {
            int t = 0;
            for(int i = 0; i < r; i++) 
                t += s[i][j];
            ret += max(t, r - t);
        }
    } else {
        ret = max(ret, rec(step + 1));
        for(int j = 0; j < c; j++)
            s[step][j] = (s[step][j] + 1) % 2;
        ret = max(ret, rec(step + 1));
        
        for(int j = 0; j < c; j++)
            s[step][j] = (s[step][j] + 1) % 2;
    }

    return ret;
}

int main()
{
    while(cin >> r >> c && r && c) {
        for(int i = 0; i < r; i++) 
            for(int j = 0; j < c; j++) 
                cin >> s[i][j];

        cout << rec(0) << endl;
    }
}

Measured memory_bytes: 1252
#include<iostream>

using namespace std;

int main() {
  int n;
  while(cin>>n) {
    int ans = 0;
    for(int a=0; a<10; a++) {
      for(int b=0; b<10; b++) {
	for(int c=0; c<10; c++) {
	  for(int d=0; d<10; d++) {
	    if(a+b+c+d == n)
	      ans++;
	  }
	}
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <queue>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n, m;
    cin >> n >> m;
    vector<priority_queue<long long int>> job(100000);
    long long int tmpa, tmpb;
    REP(i,n){
        scanf("%lld %lld", &tmpa, &tmpb);
        job[tmpa].push(tmpb);
    }

    long long int result = 0,loop;
    priority_queue<long long int> jobs;
    REP(i,m+1){
        loop = 0;
        while(loop<=m&&!job[i].empty()){
            jobs.push(job[i].top());
            job[i].pop();
        }
        if(!jobs.empty()){
            result += jobs.top();
            jobs.pop();
        }
    }
    

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int f(int n){
  int res = 0;
  for(int i = 1; i <= n; i++){
    if(n%i == 0) res++;
  }
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i += 2){
    if(f(i) == 8) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1000000007;

ll add(ll x, ll y){
    return (x+y)%mod;
}

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

ll powll(ll x, ll y){
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    return (x * powll(y,mod-2)) % mod;
}

map<int, int> zip;
VI unzip;
void compress_coordinate(VI x){
    x.push_back(0);
    int n = x.size();
    REP(i,n) unzip.push_back(x[i]);
    sort(ALL(unzip));
    unzip.erase(unique(ALL(unzip)), unzip.end());
    REP(i,unzip.size()) zip[unzip[i]] = i;
}

const int N = 105;
ll dp[N][N];

int main() {
    int n;
    cin >> n;
    VI h(n);
    REP(i,n) h[i] = in();
    compress_coordinate(h);
    int m = unzip.size();

    REP(j,m){
        if (j == 0) dp[0][0] = powll(2, h[0]);
        else if (h[0] >= unzip[j]) dp[0][j] = powll(2, h[0] - unzip[j] + 1);
    }
    REP(j,m-1){
        dp[0][j] = (dp[0][j] - dp[0][j+1] + mod) % mod;
    }

    REP(i,n-1) REP(j,m){
        if (h[i] >= h[i+1]){
            if (unzip[j] < h[i+1]){
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
            }else{
                int x = zip[h[i+1]];
                dp[i+1][x] = (dp[i+1][x] + 2 * dp[i][j]) % mod;
            }
        }else{
            if (j < zip[h[i]]){
                dp[i+1][j] = (dp[i+1][j] + dp[i][j] * powll(2, h[i+1] - h[i])) % mod;
            }else{
                FOR(k,zip[h[i]],zip[h[i+1]]){
                    ll tmp = powll(2, h[i+1] - unzip[k]);
                    if (k < zip[h[i+1]]) tmp = (tmp + mod - powll(2, h[i+1] - unzip[k+1])) % mod;
                    dp[i+1][k] = (dp[i+1][k] + 2 * dp[i][j] * tmp) % mod;
                }
            }
        }
    }

    // REP(i,n-1){
    //     REP(j,m) cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    ll ans = 0;
    REP(j,m) ans = (ans + dp[n-1][j]) % mod;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[][] matrix = new int[n][n];
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			int u = Integer.parseInt(st.nextToken());
			int k = Integer.parseInt(st.nextToken());
			for (int j = 0; j < k; j++) {
				int v = Integer.parseInt(st.nextToken());
				matrix[u-1][v-1] = 1;
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.print(matrix[i][0]);
			for (int j = 1; j < n; j++) {
				System.out.print(" " + matrix[i][j]);
			}
			System.out.println("");
		}
		reader.close();
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
}



Measured memory_bytes: 31292
#include<bits/stdc++.h>
#define int long long int
#define ull unsigned long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 1200005
#define MOD 1000000007
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define precise cout<<fixed<<setprecision(6)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=100000000000000003;
const int32_t LOG=21;
const int BIG=pow(2,20);
int32_t main(){
         getFaster;
         int n;
         cin>>n;
         int ans=INF;
         for(int i=1;i*i<=n;i++)
         {
            if(n%i==0)
            {
               int x=i;
               int y=n/i;
               ans=min(ans,x+y-2); 
            }  
         }
         cout<<ans<<endl; 
        return 0;
}

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

ulong N;
vector<ulong> a;

int main(void) {

    cin >> N; a.resize(N);
    ulong A = 0;
    for (ulong i = 0; i < N; i++) {
        cin >> a[i];
        A = A ^ a[i];
    }

    for (ulong i = 0; i < N; i++) {
        ulong tmp = A ^ a[i];
        cout << tmp << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4752
#include <algorithm>
#include <cstdio>
typedef long long LL;
const int N=5005,M=205;
LL a[N],sum[N],ans=0;
int p[M][N],v[M][N],t[M],n,m;
int main(){
	scanf("%d%d\n",&n,&m);
	for (int i=2;i<=n;i++) scanf("%lld",&a[i]),a[i]+=a[i-1];
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			int x;
			scanf("%d",&x);
			for (;t[j] && v[j][t[j]]<=x;t[j]--){
				sum[p[j][t[j]]]-=v[j][t[j]];
				sum[p[j][t[j]-1]]+=v[j][t[j]];
			}
			sum[p[j][t[j]]]-=x;
			v[j][++t[j]]=x;p[j][t[j]]=i;
			sum[i]+=x;
		}
		LL s=0;
		for (int j=i;j;j--){
			s+=sum[j];
			ans=std::max(ans,s-a[i]+a[j]);
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 5120
using System;

namespace ABC074_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var sss = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var a = sss[0];
            var b = sss[1];
            var c = sss[2];
            var d = sss[3];
            var e = sss[4];
            var f = sss[5];
            var water = 0;
            var sugar = 0;
            for (var i = 0; (a * i) * 100 <= f; i++)
            {
                for (var j = 0; (a * i + b * j) <= f; j++)
                {
                    var w = a * i + b * j;
                    for (var k = 0; c * k <= e * w; k++)
                    {
                        for (var l = 0; (c * k + d * l) <= e * w; l++)
                        {
                            var s = c * k + d * l;
                            if (f < w * 100 + s)
                                break;
                            if (p(sugar, water * 100) <= p(s, w * 100))
                            {
                                water = w;
                                sugar = s;
                            }
                        }
                    }
                }
            }
            Console.WriteLine("{0} {1}", water*100+sugar, sugar);
        }
        static double p(double s, double w)
        {
            if (s + w == 0) return 0;
            else return 100 * s / (s + w);
        }
    }

}


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

// ABCテンプレート

#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;


int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> alist(N);
  rep(i,N) {
    ll A;
    cin >> A;
    alist.at(i) = A;
  }
  for(int i=K; i<N; i++) {
    if(alist.at(i)>alist.at(i-K)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 4836
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		double mindif;
		vector<int> ids,hs,ws;
		for(int i=0,id,h,w;i<n;++i){
			cin>>id>>h>>w;
			ids.push_back(id);
			hs.push_back(h);
			ws.push_back(w);
		}
		int ans;
		for(int i=n-1;i>=0;--i){
			double bmi=(double)ws[i]*10000/(double)(hs[i]*hs[i]);
			if(i==n-1||mindif>abs(22.0-bmi)){
				mindif=abs(22.0-bmi);
				ans=ids[i];
			}
		}
		cout<<ans<<"\n";
	}
}

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

int main(){
	int grid[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++)cin>>grid[i][j];
	}


	int a[3], b[3];		a[0]=0;

	for(int i=0;i<3;i++){
		b[i]=grid[0][i]-a[0];
	}
	for(int i=1;i<3;i++){
		a[i]=grid[i][0]-b[0];
	}

	string ans="Yes";
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			if(grid[i][j]!=a[i]+b[j]){
				ans="No";
				break;
			}
		}
		if(ans=="No") break;
	}

	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


using namespace std;
using namespace __gnu_pbds;


#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
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(NULL);
	
	int t=1;
	//cin>>t;
	while(t--){
		double a1,a2,b1,b2;
		double a,b;
		cin>>a>>b;
		a1=(a*12.5);
		a2=((a+1)*12.5);
		b1=(b*10);
		b2=(b+1)*10;
		if(a1<=b1 && b1<a2)
		{
			cout<<ceil(b1)<<'\n';
		}
		else if(b1<=a1 && a1<b2)
			{
				cout<<ceil(a1)<<'\n';
			}
		else
			cout<<-1;
	}



return 0;
}

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

#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

static long long a[5005];
int n;
static long long dp[5005][5005];

long long solve(int last1,int last2){
	if(max(last1,last2) == n + 1){
		return abs(a[last1]-a[last2]);
	}
	if(dp[last1][last2] != -1){
		return dp[last1][last2];
	}

	assert(last1 != last2);

	if(last1 < last2){	//	X's turn.
		long long score = 0ll;
		for(int i=last2+1;i<n+2;i++){
			score = max(score,solve(i,last2));
		}
		dp[last1][last2] = score;
	} else {
		long long score = 1e18;
		for(int i=last1+1;i<n+2;i++){
			score = min(score,solve(last1,i));
		}
		dp[last1][last2] = score;
	}
	return dp[last1][last2];

}

int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	for(int i=0;i<5005;i++){
		for(int j=0;j<5005;j++){
			dp[i][j] = -1;
		}
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		long long A,B;
		scanf("%lld %lld",&A,&B);
		for(int i=0;i<n;i++){
			scanf("%lld",&a[i]);
		}
		long long now = 0;
		if( n > 1 ){
			now = abs(a[n-1]-a[n-2]);
		}
		printf("%lld\n",max(abs(a[n-1]-B),now));
	}
	return 0;	
}

Measured memory_bytes: 195968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,int> P;

int main() {
    int N,M;
    cin >> N >> M;
    vector<tuple<ll,ll,ll>> vec(N);
    for(int i = 0;i < N;i++) {
        ll A,B,C;
        cin >> A >> B >> C;
        vec.at(i) = make_tuple(A,B,C);
    }
    ll ret = 0;
    for(int i = 0;i < 2;i++) {
        for(int j = 0;j < 2;j++) {
            for(int k = 0;k < 2;k++) {
                ll A,B,C;
                if(i == 0) {
                    A = 1;
                }
                else {
                    A = -1;
                }
                if(j == 0) {
                    B = 1;
                }
                else {
                    B = -1;
                }
                if(k == 0) {
                    C = 1;
                }
                else {
                    C = -1;
                }
                vector<P> cnt(N);
                for(int l = 0;l < N;l++) {
                    cnt.at(l) = P(A * get<0>(vec.at(l)) + B * get<1>(vec.at(l)) + C * get<2>(vec.at(l)),l);
                }
                sort(cnt.begin(),cnt.end());
                reverse(cnt.begin(),cnt.end());
                ll a = 0;
                ll b = 0;
                ll c = 0;
                for(int l = 0;l < M;l++) {
                    a += get<0>(vec.at(cnt.at(l).second));
                    b += get<1>(vec.at(cnt.at(l).second));
                    c += get<2>(vec.at(cnt.at(l).second));
                }
                if(a <= 0) {
                    a = -a;
                }
                if(b <= 0) {
                    b = -b;
                }
                if(c <= 0) {
                    c = -c;
                }
                ret = max(ret,a + b + c);
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s_int, first, second, third, total;
  cin >> s_int;
  // cout << s_int << endl;
  first = s_int / 100;
  second = (s_int / 10) % 2;
  third = s_int % 2;
  total = first + second + third;
  cout << total << endl;
}

Measured memory_bytes: 256