akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 300010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
#define eps 1e-6
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll A, B;
char s1[SIZE], s2[SIZE], ch[SIZE];
int main() {
	io(); string s; cin >> s;
	rep(i, 0, (s.length() - 1)) cout << "x";
}

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

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

#define INF 100000000

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> wa_count(N, 0);
  vector<bool> ac(N, false);
  int result_ac = 0;
  int result_wa = 0;
  rep(i,M){
    int num;
    string s;
    cin >> num >> s;
    if(!ac.at(num-1)){
      if(s == "WA"){
        wa_count.at(num-1)++;
      }
      else{
        ac.at(num-1) = true;
        result_ac++;
        result_wa += wa_count.at(num-1);
      }
    }
  }
  cout << result_ac << " " << result_wa << endl;
  return 0;
}

Measured memory_bytes: 640
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int rui[555][555];
int n, m, q;

int main() {
	cin >> n >> m >> q;
	REP(i, m) {
		int l, r;
		cin >> l >> r;
		rui[l][r]++;
	}
	for (int i = 1; i <= 500; i++) {
		for (int j = 1; j <= 500; j++) {
			rui[i][j] += rui[i - 1][j] + rui[i][j - 1] - rui[i - 1][j - 1];
		}
	}
	REP(qqq, q) {
		int l, r;
		cin >> l >> r;
		cout << rui[r][r] - rui[l - 1][r] - rui[r][l - 1] + rui[l - 1][l - 1] << endl;
	}
}

Measured memory_bytes: 2048
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
ll gcd(ll a,ll b);
ll lcm(ll a,ll b);
ll modularExponentiation(ll x,ll n,ll M);
void dsp(vector<ll> &V);
void dsp2(vector<pair<ll,ll>>&V);
void dsp3(map<ll,ll>&M);
double fact(double n);
ll nPr(ll n,ll r);
ll nCr(ll n,ll r);
ll r[40001];
ll c[40001];
void solve()
{
  ld e,t;cin>>e>>t;
  ll i;
  
  for(i=1;i<=10000;i++)
  {
      if(((i*8/100)==e)&&(i*10/100)==t)break;
  }
  if(i==1e4+1)cout<<"-1\n";
  else cout<<i<<"\n";
}
int main()
{
   fastio
    solve();
  return 0;
}
ll gcd(ll a,ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
          
} 
ll lcm(ll a,ll b)  
{  
    return (a*b)/gcd(a, b);  
}  
ll modularExponentiation(ll x,ll n,ll M)
{   
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
        result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
        return result;
}
void dsp(vector<ll> &V)
{
    ull j;
    for(j=0;j<V.size();j++)
    {
        cout<<V[j]<<" ";
    }
    cout<<endl;
}
void dsp2(vector<pair<ll,ll>>&V)
{
    ull j;
    for(j=0;j<V.size();j++)
    {
        cout<<V[j].first<<" "<<V[j].second<<" ";
    }
    cout<<endl;
}
void dsp3(map<ll,ll>&M)
{
      map<ll,ll>::iterator it=M.begin();
      while(it!=M.end())
      {
        cout<<it->first<<" "<<it->second<<endl;
        it++;
      }
}
double fact(double n)
{
    double i=1;
    double res=1;
    
    if(n==0)
        return 1.00;
    
    while(i<=n)
    {
        res*=i;
        i++;
    }
    
    return res;
}
ll nPr(ll n,ll r)
{
    return (fact(n)/fact(n-r));
}
ll nCr(ll n,ll r)
{
    return (fact(n)/(fact(r)*fact(n-r)));
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>

Measured memory_bytes: 256
#include<iostream>

int main() {
	int a, b, c, d;

	std::cin >> a >> b >> c;

	d = b / a;

	if (d >= c) {
  		std::cout << c << std::endl;
	} else {
  		std::cout << d << std::endl;
	}

	return 0;
}

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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

using namespace std;
#define MAX 60000;

int main(void){
	int N;
	cin >> N;
	long a[60];
	long sosuu[60];
	long tmp = 11;
	for(int i=0;i<N;++i){
		for(int j=tmp;j<55555;j+=5){
			if(IsPrime(j)){
				sosuu[i] = j;
				tmp = j+5;
				break;
			}
		}
	}
	for(int i=0;i<N;++i){
		cout << sosuu[i] << " ";
	}

	return 0;
}

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

int main(){
    int x,y;
    scanf("%d %d",&x,&y);
    int z = y;
    while(x%y != 0)
    {
        z = x%y;
        x = y;
        y = z;
    }
    printf("%d\n",z);
    
    
    
    return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
double x[100],y[100];
int main(){
    int n;
    while(1){
        scanf("%d",&n);
        if(n==0)    break;
        for(int i=0;i<n;i++)
            scanf("%lf,%lf\n",&x[i],&y[i]);
        int ans=0;
        for(double a=0;a<=10.1;a+=0.01)
            for(double b=0;b<=10.1;b+=0.01){
                int t=0;
                for(int i=0;i<n;i++)
                    if((a-x[i])*(a-x[i])+(b-y[i])*(b-y[i])<=1.001)
                        t++;
                ans=max(ans,t);
            }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3168
H, W = map(int, input().split())
S = [input() for i in range(H)]
B = []
B.append('.' * (W + 2))
for i in range(H):
    B.append('.' + S[i] + '.')
B.append('.' * (W + 2))
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if B[i][j] == '#':
            print('#', end='')
            continue
        c = 0
        if B[i - 1][j - 1] == '#':
            c += 1
        if B[i - 1][j + 1] == '#':
            c += 1
        if B[i + 1][j - 1] == '#':
            c += 1
        if B[i + 1][j + 1] == '#':
            c += 1
        if B[i][j - 1] == '#':
            c += 1
        if B[i][j + 1] == '#':
            c += 1
        if B[i + 1][j] == '#':
            c += 1
        if B[i - 1][j] == '#':
            c += 1
        print(c, end='')
    print('')


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

signed main() {
	constexpr int INF = 1<<30;

	string S;
	cin>>S;
	int N=S.size();

	vector<int> hash(N,0);
	int h=0;
	for(int i=0; i<N; i++){
		h=h ^ (1<<(S[i]-'a'));
		hash[i]=h;
	}

	if(__builtin_popcount(hash.back()) <= 1){
		cout << 1 << endl;
		return 0;
	}

	vector<int> dp(1<<26, INF);
	dp[0]=0;
	for(int i=0; i<N; i++){
		int palindromehash=0;
		int subtractedhash=palindromehash ^ hash[i];
		int minval=INF;
		minval = min(minval, dp[subtractedhash]+1);
		for(int j=0; j<26 ;j++){
			int palindromehash = 1<<j;
			int subtractedhash=palindromehash ^ hash[i];
			minval = min(minval, dp[subtractedhash]+1);
		}
		dp[hash[i]]=min(minval, dp[hash[i]]);
	}

	cout << dp[hash.back()] << endl;
	return 0;
}


Measured memory_bytes: 263556
B,W=map(int,input().split())
mod=10**9+7
kaijo={0:1}
Xdiv={0:1}
two=pow(2,mod-2,mod)
for i in range(1,1+B+W):
    kaijo[i]=(kaijo[i-1]*i)%mod
    Xdiv[i]=(Xdiv[i-1]*two)%mod
gyaku={B+W:pow(kaijo[B+W],mod-2,mod)}
for i in range(B+W,0,-1):
    gyaku[i-1]=(gyaku[i]*i)%mod
def conb(a,b):
    if a<b:return 0
    return (kaijo[a]*gyaku[a-b]*gyaku[b])%mod
Blost,Wlost=0,0
for k in range(1,B+W):
    print(((1+Wlost-Blost)*two)%mod)
    Blost=(Blost+conb(k-1,B-1)*Xdiv[k])%mod
    Wlost=(Wlost+conb(k-1,W-1)*Xdiv[k])%mod
print(((1+Wlost-Blost)*two)%mod)

Measured memory_bytes: 82312
#include <bits/stdc++.h>
struct fastio{fastio(){std::ios::sync_with_stdio(false);std::cin.tie(nullptr);}}_fast_io_;
template<class T> bool chmin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> bool chmax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

constexpr long long INF = (1 << 30);

int main() {
	std::size_t n;
	long long k;
	std::cin >> n >> k;
	std::vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	
	auto f = [&] (long long x) -> bool {
		long long cnt = 0;
		for (const int &e : a) {
			if (e <= x) continue;
			cnt += e / x;
		}
		return (cnt <= k);
	};
	
	long long ng = 0, ok = INF;
	while (std::abs(ok - ng) > 1) {
		long long mid = (ok + ng) >> 1;
		if (f(mid)) ok = mid;
		else ng = mid;
	}
	
	std::cout << ok << '\n';
	
	return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e5 + 7;
int n;
int a[maxx];

int main() {
	while(cin >> n) {
		memset(a, 0, sizeof(a));
		int cnt = 0, cnt0 = 0;
		for(int i = 1; i <= n; i++) cin >> a[i];
		for(int i = 1; i <= n; i++) if(a[i] % 4 == 0) cnt++;
		if(cnt >= n / 2) puts("Yes");
		else {
			for(int i = 1; i <= n; i++) if(a[i] % 2 == 0 && a[i] % 4 != 0) cnt0++;
			n -= cnt0;
			if(n & 1) {
				if(cnt > n / 2) puts("Yes");
				else puts("No");
			}
			else {
				if(cnt >= n / 2) puts("Yes");
				else puts("No");
			}
		}
	}
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int N;
int A[2<<17],B[2<<17];
main()
{
	cin>>N;
	for(int i=0;i++<N;)cin>>A[i];
	int ans=0;
	for(int i=N;i;i--)
	{
		int cnt=0;
		for(int j=i;j<=N;j+=i)cnt+=B[j];
		if(cnt%2!=A[i]%2)
		{
			B[i]++;
			ans++;
		}
	}
	cout<<ans<<endl;
	for(int i=0;i++<N;)if(B[i])cout<<i<<" ";
	cout<<endl;
}


Measured memory_bytes: 2432
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  attr_accessor :dp
  def initialize
    @n,@m = gets.split.map(&:to_i)
    @w,@v = Array.new(n){ gets.split.map(&:to_i) }.transpose
    @dp = Array.new(n+1){ Array.new(n+1){ Array.new(3*n+1,0) } }
  end

  def rec
    1.upto(n) do |i|
      dw = w[i-1] - w[0]
      1.upto(n) do |j|
        0.upto(3*n) do |k|
          cnt = dp[i-1][j][k]
          if dw <= k
            take = dp[i-1][j-1][k - dw] + v[i-1]
            cnt = take if cnt < take
          end
          dp[i][j][k] = cnt
        end
      end
    end
  end

  def solve
    rec
    ans = 0
    0.upto(n) do |j|
      0.upto(3*n) do |k|
        next if m < k + w[0] * j
        v = dp[n][j][k]
        ans = v if ans < v
      end
    end
    ans
  end

  def show(ans)
    puts ans
  end

  def debug
    @dp.each_with_index do |grid, i|
      puts "---- #{i}"
      grid.each do |row|
        pp row
      end
    end
  end

end

Problem.new.instance_eval do
  show(solve)
  # rec
  # debug
end

Measured memory_bytes: 38464
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

typedef long long ll;

#define min(a, b) (((a) < (b))? (a):(b))
#define max(a, b) (((a) > (b))? (a):(b))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define rep(i, n) REP(i, 0, (n))
#define square(a) (a)*(a)
#define pb push_back

int N;
set<pair<int, int>> red;
set<pair<int, int>> blue;

int main() {
    cin >> N;
    rep(i, N) {
        pair<int, int> p;
        cin >> p.first >> p.second;
        red.insert(p);
    }
    rep(i, N) {
        pair<int, int> p;
        cin >> p.first >> p.second;
        blue.insert(p);
    }
    for(auto b=blue.begin(); b!=blue.end(); b++) {
        pair<int, int> p = {-1, -1};
        for(auto r=red.begin(); r!=red.end(); r++) {
            if(r->first < b->first && r->second < b->second) {
                if(r->second > p.second) p = *r;
            }
        }
        if(p.second >= 0) red.erase(p);
    }
    cout << N-red.size() << endl;
}

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

for n10000 in range(n+1):
    for n5000 in range(n - n10000 + 1):
        n1000 = n - n5000 - n10000
        money_total = n10000 * 10000 + n5000 * 5000 + n1000 * 1000
        if money_total == y:
            print(n10000, n5000, n1000)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 3060
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    b:usize,
    c:usize,
    d:usize,
    }
    println!("{}",(a-c)*(b-d))
}

Measured memory_bytes: 2164
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
    ll n,w,h,ans;
    cin>>n>>h>>w;
    ans=(n-w+1)*(n-h+1);
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int N;cin>>N;
    int a[N];
    for(int i=0;i<N;i++)cin>>a[i];
    int count4=0,count2=0;
    for(int i=0;i<N;i++){
        if(a[i]%4==0)count4++;
        else if(a[i]%2==0)count2++;
    }
    if(count4>=int(N/2))cout<<"Yes"<<endl;
    else{
        N-=2*count4;
        if(N==1)cout<<"Yes"<<endl;
        else if(count2>=N)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

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

public class Main {
    static int n = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        List<Integer> list = new ArrayList<Integer>();

        for (int i = 0; i < n; i++) {
            list.add(0);
        }

        for (int i = 0; i < a; i++) {
            int b = sc.nextInt();
            for (int j = 0; j < b; j++) {
                int tmp = sc.nextInt();
                list.set(tmp - 1, 1);
            }
        }

        int ans = 0;
        for (int x : list) {
            ans += x;
        }

        System.out.println(n - ans);
    }
}

Measured memory_bytes: 46380
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;     

const int MAXN = 228;

const ll MOD = 1e9 + 7;
const ll REV2 = (MOD + 1) / 2;

using Vec = vector<ll>;

ll p2(ll a) {
    if (!a) {
        return 1;
    }

    ll v = p2(a / 2);
    v = (v * v) % MOD;

    if (a & 1) {
        v = (v * 2) % MOD;
    }

    return v;
}


const ll INF = (1ll << 60);

ll eval(const Vec& a) {
    assert(a.size());

    ll mn = INF;
    for (ll x : a) {
        mn = min(mn, x);
    }

    ll cn = p2(mn) - 1;
    Vec na(a);
    for (ll& x : na) {
        x -= mn;
    }

    ll pv = 0;
    ll p = 0;

    na.push_back(0);

    for (ll x : na) {
        p += max<ll>(x - pv, 0ll);
        pv = x;
    }

    ll ans = p2(p) * cn % MOD;
    Vec cur;
    
    ll ansgood = REV2 * REV2 % MOD;

    for (ll x : na) {
        if (!x) {
            ansgood = (ansgood * 2) % MOD;
            if (!cur.empty()) {
                ansgood = ansgood * eval(cur) * 2 % MOD;
                cur.clear();
            }
        } else {
            cur.push_back(x);
        }
    }
    
    return (ans + ansgood) % MOD;
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n;
    cin >> n;
    Vec a(n);
    for (ll& x : a) {
        cin >> x;
        --x;
    }

    ll ans = eval(a);
    cout << (ans * 2) % MOD << "\n";
}

Measured memory_bytes: 384
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<20;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  const int TOWN = 10;

  int n;
  while(cin>>n,n){

    int cost[TOWN][TOWN];
    REP(i,TOWN){
      fill( cost[i], cost[i]+TOWN, INF );
      cost[i][i]=0;
    }

    int tnum = 0;
    REP(_t,n){
      int a,b,c;
      cin >>a>>b>>c;
      cost[a][b] = cost[b][a] =  c;
      tnum = max( tnum, max(a,b) );
    }
    tnum++;

    REP(k,tnum){
      REP(i,tnum)
	REP(j,tnum)
	cost[i][j] = min( cost[i][j], cost[i][k] + cost[k][j] );
    }

    int res=INF;
    int num=0;
    REP(i,tnum){
      int tmp=0;
      REP(j,tnum){
	tmp += cost[i][j];
      }
      if( res > tmp ){
	res = tmp;
	num = i;
      }
    }

    cout << num << " " << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int s = 0;
	rep(i, n) s += a[i];
	int cnt = 0;
	rep(i,n){
		if (a[i] * (4 * m) >= s) cnt++;
	}
	if (cnt >= m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

#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 FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vi cnt(n, 0);
	REP(i, m) {
		int a, b; cin >> a >> b;
		a--; b--;
		cnt[a]++;
		cnt[b]++;
	}
	bool ok = true;
	REP(i, n) {
		if (cnt[i] & 1)ok = false;
	}
	if (ok)cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 640
N,M,X = map(int,input().split())
m = list(map(int,input().split()))
count0 = 0
countN = 0
for i in range(M):
    if m[i] < X:
        count0 += 1
    else:
        countN += 1

print(count0 if count0 < countN else countN)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int                 long long   
#define double              long double
#define endl                "\n"
#define pb                  push_back
#define PI                  3.1415926535897932384626433832795l
#define F                   first
#define S                   second
#define mp                  make_pair
#define f(i,n)              for(int i=0;i<n;++i)
#define loop(i,a,b)         for (int i=a ; i<b ;++i)
#define fastio              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define gcd(a,b)            __gcd((a),(b))
#define fill(a,value)       memset(a,value,sizeof(a));
#define minn(v)             *min_element(v.begin(), v.end());
#define maxx(v)             *max_element(v.begin(), v.end());
#define print(x)            cout<<(x)<<endl;
#define sum(v)+x            accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    vi a(n);
    f(i,n)cin>>a[i];
    int ans=0;
    
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[i]!=a[j] and a[i]!=a[k] and a[j]!=a[k] and (a[i]+a[j]>a[k] and a[k]+a[j]>a[i] and a[i]+a[k]>a[j]))
                {
                    ans++;
                }
            }
        }
    }
    print(ans)
    return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n,m,l;
    int a[100][100],b[100][100];
    long cij;
    int i,j,k;
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++)for(j=0;j<m;j++)scanf("%d",&a[i][j]);
    for(i=0;i<m;i++)for(j=0;j<l;j++)scanf("%d",&b[i][j]);
    for(i=0;i<n;i++)for(j=0;j<l;j++){
        cij = 0;
        for(k=0;k<m;k++)cij += a[i][k]*b[k][j];
        printf("%ld",cij);
        printf(j==l-1 ? "\n" : " ");
    }
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll x;
    cin >> x;
    ll sum = 0;
    ll cnt = 0;
    while(sum < x){
        cnt++;
        sum += cnt;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
#define f first
#define s second
#define pb push_back

int a, b;

int main() {
	cin >> a >> b;
	FOR(i, 1, 10000) {
		if ((8*i)/100 == a and i/10 == b) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=1<<18, L=1e5+1, B=512;
int v[N], w[N];
long long f[B][L];
long long solve(int u, int l) {
	if(l<=0) return 0;
	if(u<B) return f[u][l];
	long long ans=solve(u/2, l);
	if(l>=w[u]) ans=std::max(ans, solve(u/2, l-w[u])+v[u]);
	return ans;
}
int main() {
	int n, q;
	scanf("%d", &n);
	for(int i=1; i<=n; ++i) scanf("%d%d", v+i, w+i);
	for(int i=1; i<B; ++i) {
		memcpy(f[i], f[i/2], sizeof(f[i]));
		for(int j=L; j-->w[i]; )
			f[i][j]=std::max(f[i][j-w[i]]+v[i], f[i][j]);
	}
	scanf("%d", &q);
	while(q--) {
		int u, l;
		scanf("%d%d", &u, &l);
		printf("%lld\n", solve(u, l));
	}
	return 0;
}

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

int main(){
    ll n,k; cin >> n >> k;
    vector<pair<int,int>> a(n);
    for(int ix=0;ix<n;ix++){
        int x,y;
        cin >> x >> y;
        a.at(ix) = make_pair(x,y);
    }
    sort(a.begin(),a.end());
    ll cnt=0,ans = -1;
    int i=0;
    while(cnt < k){
        cnt += a.at(i).second;
        if(cnt >= k) ans = a.at(i).first;
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int>a,b,c;
  int x,y,z;
  while(1){
    cin >> x >> y >> z;
    if(x==0&&y==0&&z==0)break;
    a.push_back(x-1);
    b.push_back(y-1);
    c.push_back(z);
  }
  int l;
  cin >> l;
  vector<int>d(m);
  for(int i=0;i<l;i++){
    vector<int>co(n,0);
    for(int j=0;j<m;j++){
      int bu;
      cin >> bu;
      d[j]=bu;
    }
    for(int j=0;j<a.size();j++){
      co[a[j]]+=d[b[j]]*c[j];
    }
    for(int j=0;j<n;j++){
      cout << co[j] ;
      if(j+1!=n){
	cout << ' ';
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3776
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;

string l, r;

ll dp[65][2][2][2][2][2];

string to_bin(ll val) {
    string s = "";
    while(val) {
        s += '0' + (val & 1);
        val >>= 1;
    }
    reverse(all(s));
    return s;
}

void upd(ll &x, ll y) {
    x = (x + y) % mod;
}

signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, (a * b)});
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int n;
	vector<pair<i64, pair<i64, i64>>> items;

	scanf("%d", &n);
	items.resize(n);
	for(int i = 0; i < n; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		items.push_back({a + b, {a, b}});
	}

	sort(items.rbegin(), items.rend());

	i64 ap = 0, bp = 0;

	for(int i = 0; i < n; ++i) {
		if(i % 2 == 0) {
			ap += items[i].second.first;
		} else {
			bp += items[i].second.second;
		}
	}

	printf("%lld\n", ap - bp);

	return 0;
}

/* waffle */


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int64_t> v(N);
  for(int i=0;i<N;i++){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  int64_t ans=0;
  for(int i=0;i<N-K;i++){
    ans+=v.at(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
x=[]
for i in range(n-k+1):
    y=a[i+k-1]-a[i]+min(abs(a[i+k-1]),abs(a[i]))
    x.append(y)        
print(min(x))


Measured memory_bytes: 14224
import bisect
N = int(input())
a = sorted(list(map(int,input().split())))
ans = []
for i in range(1,N):
    candind = bisect.bisect_left(a,a[i]/2)
    if candind == i:
        candind -= 1
        cand = a[candind]
    elif candind == 0:
        cand = a[candind]
    else:
        if a[candind]-a[i]/2 <= a[i]/2-a[candind-1]:
            cand = a[candind]
        else:
            cand = a[candind-1]
    ans.append([a[i],cand])
ans.sort()
print(*ans[-1])

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

int main(void){
    ll n;
    cin >> n;

    map<ll, ll> a;
    rep(i, n){
        ll tmp;
        cin >> tmp;
        a[tmp]++;
    }

    ll ans = 1;
    if(n % 2 == 0){
        rep(i, n){
            if(i % 2 == 1){
                if(!a.count(i)){
                    cout << 0 << endl;
                    return 0;
                }else if(a[i] != 2){
                    cout << 0 << endl;
                    return 0;
                }
                ans *= 2;
                ans %= 1000000007;
            }
        }
    }

    if(n % 2 == 1){
        rep(i, n){
            if(i % 2 == 0){
                if(!a.count(i)){
                    cout << 0 << endl;
                    return 0;
                }else if(i == 0 && a[i] != 1){
                    cout << 0 << endl;
                    return 0;
                }else if(i != 0 && a[i] != 2){
                    cout << 0 << endl;
                    return 0;
                }
                ans *= 2;
                ans %= 1000000007;
            }
        }
        ans /= 2;
    }

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


Measured memory_bytes: 4224
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>

using namespace std;
typedef long long ll;

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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j;
    ll aa[5];
    ll k;
  
    ll Q,N;
    string S;
    cin>>aa[0]>>aa[1]>>aa[2]>>aa[3]>>aa[4];
    ll min=10;
    ll flag=0;

    for(i = 0;i<5;i++){
                if(aa[i]%10<min && aa[i]%10!=0){
            min=aa[i]%10;
            flag=1;
        }
        if(aa[i]%10!=0){
        ans=ans+aa[i]+(10-aa[i]%10);
        }else{
            ans=ans+aa[i];
        }
        //cout<<ans<<endl;
    }
    if(flag==1){
    cout<<ans-(10-min)<<endl;
    }else{
        cout<<ans<<endl;
    }
    // for(i=0;i<5;i++){
    //     for(j=1;j=4-i;j++){
    //         if(abs(aa[i]-aa[i+j])>k){
    //             cout<<":("<<endl;
    //             return 0;
    //         }
    //     }
    // }

// for(i=0;i<Q;i++){
//     cin>>a[i]>>b[i];
//     scanf("%d", &a);
//     scanf("%d", &b);
//     printf("%d\n",a[i]);
// }
// if(aa[4]-aa[0]>k){
//     cout<<":("<<endl;
// }else{
//     cout << "Yay!" << endl;
// }
// return 0;
}

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

using namespace std;


void solve() {
    int N, M; cin >> N >> M;
    vector<pair<int, int>> order(M);
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        order[i] = make_pair(b, a);
    }

    sort(order.begin(), order.end());

    int ans = 1;
    int cut = 0;
    for (int i = 1; i < M; i++) {
        if (order[i].second < order[cut].first) continue;
        cut = i;
        ans++;
    }

    cout << ans << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
using namespace std;

int main()
{
	char S[4];
	int i;
	gets(S);
	for(i=0;i<=2;i++)
	{
		if(S[i]==S[i+1])
		{
			printf("Bad");
			return 0;
		}
		else
		{
			continue;
		}
	}
	printf("Good");
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair

int main() {
    string s; cin>>s;
    int n = s.size();
    bool C=0, F=0;
    rep(i,n) {
        if(!F and s[i] == 'C') C = true;
        if(C and s[i] == 'F') F = true;
    }

    if(C and F)
        puts("Yes");
    else
        puts("No");

    return 0;
}


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

//imos法を用いました。

int record[30][101010];

int main() {

    int n,C;

    cin >> n >> C;

    int s,t;
    int c;

    for(int i=0;i<n;i++){
        cin >> s >> t >> c;
        c--;
        record[c][s-1]++;
        record[c][t]--;
    }

    for(int i=0; i<C; i++) {
        for (int j = 1; j < 101010; j++) {
            record[i][j] += record[i][j-1];
        }
    }

    for(int i=0; i<C; i++) {
        for (int j = 0; j < 101010; j++) {
            if(record[i][j]>1){//同じチャンネルで同時放送はないため用いている録画機は常に1である。
                record[i][j] = 1;
            }
        }
    }

    int ans = 0;

    for(int i=0; i<101010;i++){
        int tmp_ans = 0;
        for(int j=0; j<C; j++){
            tmp_ans += record[j][i];
        }
        ans = max(ans,tmp_ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
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<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

int main()
{
  int N;
  cin>>N;
  int inf =0;
  VI A(100001);
  VI B(100001);
  VI C(100001);
  VVI h(100001,vector<int>(3));
  REP(i,N)
  {
    cin>>A[i]>>B[i]>>C[i];
    REP(j,3)
    {
      h[i][j]=inf;
    }
  }
  REP(i,3)
  {
    h[0][i]=0;
  }
  REP(i,N)
  {
      h[i+1][0]=max(h[i][1]+A[i],h[i][2]+A[i]);
      h[i+1][1]=max(h[i][2]+B[i],h[i][0]+B[i]);
      h[i+1][2]=max(h[i][0]+C[i],h[i][1]+C[i]);
  }
cout<<max({h[N][0],h[N][1],h[N][2]})<<endl;

}

Measured memory_bytes: 7040
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let s: Vec<char> = lines.next().unwrap().unwrap().chars().collect();
    let k: i64 = lines.next().unwrap().unwrap().parse().unwrap();

    let (prefix, middle, suffix) = split_string(&s);

    let ans =
        if prefix.len() == s.len() {
            // same string
            let len = s.len() as i64 * k;
            if len % 2 == 0 { len / 2 } else { (len - 1) / 2 }
        } else if s[0] == s[s.len() - 1] {
            let len0 = prefix.len() as i64;
            let len0 = if len0 % 2 == 0 { len0 / 2 } else { (len0 - 1) / 2 };
            let len1 = suffix.len() as i64;
            let len1 = if len1 % 2 == 0 { len1 / 2 } else { (len1 - 1) / 2 };
            let len_middle = prefix.len() as i64 + suffix.len() as i64;
            let len_middle = if len_middle % 2 == 0 { len_middle / 2 } else { (len_middle - 1) / 2 };
            min_tr(middle) * k + len_middle * (k - 1) + len0 + len1
        } else {
            min_tr(&s) * k
        };


    writeln!(&mut writer, "{}", ans).unwrap();
}

fn min_tr(s: &[char]) -> i64 {
    let mut ret: i64 = 0;
    let mut prev = '*';
    let mut len: i64 = 0;

    for &c in s {
        if c != prev {
            ret += if len % 2 == 0 { len / 2 } else { (len - 1) / 2 };
            len = 0;
        }

        len += 1;
        prev = c;
    }

    if len > 0 {
        ret += if len % 2 == 0 { len / 2 } else { (len - 1) / 2 };
    }

    ret
}

fn split_string(s: &[char]) -> (&[char], &[char], &[char]) {
    let mut prefix_len = 0;
    for i in 0..s.len() {
        if s[i] != s[0] {
            break;
        }
        prefix_len += 1;
    }

    if prefix_len == s.len() {
        return (s, &[], &[])
    }

    let mut suffix_len = 0;
    for i in 0..s.len() {
        if s[s.len() - i - 1] != s[s.len() - 1] {
            break;
        }
        suffix_len += 1;
    }

    (
        &s[0..prefix_len],
        &s[prefix_len..s.len() - suffix_len],
        &s[s.len() - suffix_len..s.len()],
    )
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"issii
2", br"4
",
        ),
        (
            br"qq
81", br"81
",
        ),
        (
            br"cooooooooonteeeeeeeeeest
999993333", br"8999939997
",
        ),
        (
            br"i
1", br"0
",
        ),
        (
            br"i
3", br"1
",
        ),
        (
            br"aaabbbaaa
3", br"11
",
        ),
    ];

    #[test]
    fn test_a() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    double p = (double)((N + 1) / 2) / (double)N;
    cout << p << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n; cin >> n;
    vector<pair<ll,ll>> pairs(n);
    rep(i,0,n) cin >> pairs[i].second >> pairs[i].first;
    sort(ALL(pairs));
    
    ll time = 0;
    for(ll i=0;i<n;i++){
        time += pairs[i].second;
        if(time > pairs[i].first){cout << "No" << endl; return 0;}
    }

    cout << "Yes" << endl;
    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int total_score = 0;
    for (int i=0;i<N;i++){
        cin >> A.at(i);
        total_score += A.at(i);
    }
    vector<int> divide = {1, total_score};
    int big = total_score;
    for(int i=2;i<total_score;i++){
        if(i>=big){
            break;
        }
        if(total_score % i == 0){
            divide.push_back(i);
            big = total_score / i;
            divide.push_back(big);
        }
    }
    sort(divide.begin(), divide.end());
    reverse(divide.begin(), divide.end());
    // Kがたりるか
    // 約数の倍数との差%の小さいほうからリストをとる．
    // 小さいほうをpop, 大きいほうをpop
    for(int i=0;i<divide.size();i++){
        int divide_number = divide.at(i);
        vector<int> remains(N);
        for(int j=0;j<N;j++){
            remains.at(j) = A.at(j) % divide_number;
        }
        sort(remains.begin(), remains.end());
        int counter = 0;
        int remain_big = 0;
        int remain_small = 0;
        while(!remains.empty()){
            if(remain_small == 0) {
                remain_small = remains.at(0);
                remains.erase(remains.begin());
            }

            if(remain_big == 0){
                if(remains.empty()){
                    break;
                }
                remain_big = remains.at(remains.size()-1);
                remains.erase(remains.begin()+remains.size()-1);
            }
            if(remain_small > (divide_number - remain_big)){
                remain_small -= divide_number - remain_big;
                counter += divide_number - remain_big;
                remain_big = 0;
            }else{
                remain_big = (remain_big + remain_small) % divide_number;
                counter += remain_small;
                remain_small = 0;
            }
            if(counter>K){
                break;
            }
        }
        if(remains.empty() && counter <= K && remain_big == 0 && remain_small == 0){
            cout << divide.at(i) << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a, b;
    char op;
    while(scanf("%d %c %d", &a, &op, &b))
	{
		if(op == '?')
		{
			break;
		}
		switch(op)
		{
			case '+':
				printf("%d\n", a + b);
				break;
			case '-':
				printf("%d\n", a - b);
				break;
			case '*':
				printf("%d\n", a * b);
				break;
			case '/':
				printf("%d\n", a / b);
				break;
		}
	} 
	return 0;
} 


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
int n, x, y;
vector<int> a[100020];
int dfs(int x, int y) {
	int c = 0, d = 0, p = 0;
	for (int i: a[x]) {
		if (i != y) {
			int u = dfs(i, x);
			d |= c & u;
			c |= u;
		}
	}
	while (1 << p < d || c >> p & 1) {
		p++;
	}
	return (c >> p | 1) << p;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d", &x, &y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	printf("%d\n", 31 - __builtin_clz(dfs(1, 0)));
	return 0;
}

Measured memory_bytes: 10240
#include <vector>
#include <iostream>
#include <queue>
#include <algorithm>

struct Tour {
	std::size_t id = 0;
	Tour* lost = NULL;
	std::size_t depth = 0;
	std::size_t tour_max_depth = 0;
	std::vector<Tour*> children;
};

struct TourLessOp {
	bool operator()(const Tour* a, const Tour* b) {
		return a->tour_max_depth < b->tour_max_depth;
	}
};

size_t calc_depth(Tour& t);
size_t traverse(Tour& t);

int main() {
	std::size_t N;
	std::cin >> N;

	std::vector<Tour> v;
	v.resize(N);

	v[0].lost = 0;
	for (std::size_t i = 1; i < N; ++i) {
		std::size_t lost_id;
		std::cin >> lost_id;

		Tour& now = v[i];
		now.id = i;
		Tour& lost = v[lost_id - 1];
		lost.children.emplace_back(&now);
		now.lost = &lost;
		now.depth = 0;
	}

	for (std::size_t i = 0; i < N; ++i) {
		calc_depth(v[i]);
	}

	std::cout << traverse(v[0]) << std::endl;
}

size_t calc_depth(Tour& t) {
	if (t.depth != 0) {
		return t.depth;
	} else if (t.lost == NULL) {
		t.depth = 1; // [1]
		return 1;
	} else {
		size_t parent_depth = calc_depth(*t.lost);
		return t.depth = parent_depth + 1;
	}
}

size_t traverse(Tour& t) {
	if (t.children.size() == 0) {
		return 0;
	} else if (t.tour_max_depth != 0) {
		return t.tour_max_depth;
	}

	for (Tour* c : t.children) {
		traverse(*c);
	}

	std::sort(t.children.begin(), t.children.end(), TourLessOp{});
	size_t required_depth = 0;
	for (Tour* c : t.children) {
		//fprintf(stderr, "< %zu: %zu\n", c->id, c->tour_max_depth);
		required_depth = std::max(required_depth + 1, c->tour_max_depth + 1);
	}

//	fprintf(stderr, "%zu: %zu\n", t.id, required_depth);
	return t.tour_max_depth = required_depth;
}


Measured memory_bytes: 13568
/*
 * kadai0002.cpp
 * Digit Number
 * ??????????????????????????´??° a ??¨ b ??????????????°???????????????????????????????????°?????????
 * ?????°???????????????????????????????????????????????????????????????????????????????????????????????????
 * ???????????????????????????????????´??° a ??¨ b ??????????????????????????§????????????????????????????????????
 * ??\????????????????????§????????????????????????a ??¨ b ??????????????´??°??¨????????????
 *
 *  Created on: 2016/05/23
 *      Author: Moniwa
 */

#include<iostream>
using namespace std;

/* ??¢??°???
 * @return ?????°x????????°
 */
int digit_num(int x){
	int count = 1;
	while(true){
		if((x = x / 10) == 0)	break;
		else	count++;
	}
	return count;
}

int main(){
    int a,b;
	while(	cin >> a >> b ){	// cin ??????????????????????????§!0??????????????±?????§0????????????
	cout << digit_num(a+b) << endl;
	}

    return 0;
}

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

#define ll long long

int main() {
    int n;
    vector<int> v;

    cin >> n;
    // Load
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        v.push_back(x);
    }
    // Sort
    sort(v.begin(), v.end());

    int h1 = 0, h2 = 0;
    bool f1 = false;
    for (int i = v.size() - 1; i >= 0; i--) {
        if (v[i] == v[i-1]) {
            if (!f1) {
                h1 = v[i];
                f1 = true;
                i--;
            } else {
                h2 = v[i];
                break;
            }
        }
    }
    printf("%lld\n", (ll)h1 * h2);
}

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

int main(){
  int A, B;
  cin >> A >> B;
  vector<int> V(5);
  int cnt=0;
  for (int i = A; i <= B; i++) {
    int t=i;
    for (int j = 0; j < 5; j++) {
      V.at(j) = t%10;
      t /= 10;
    }
    if(V.at(0)==V.at(4) && V.at(1)==V.at(3)) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
ary1 = gets.chomp.split(" ").map(&:to_i)
index = 1
count = 0
ary1.each{|elem|
  if elem == index
    index += 1   
  else
    count += 1
  end
  }

if count == n
  puts -1
else
  puts count
end


Measured memory_bytes: 16772
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn pow(base: u64, mut exp: usize) -> u64 {
    let mut acc = 1;
    while exp > 0 {
        acc = acc * base;
        exp -= 1;
    }
    return acc
}

fn main() {
    let mut n: u64 = read();
    let k: u64 = read();

    if k < 10 {
        let mut i = 1;
        while n >= pow(k, i) {
            i += 1;
        }
    
        println!("{}", i);
    } else {
        println!("{}", n.to_string().len());
    }
}


Measured memory_bytes: 4352