akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define fi first
#define se second

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( reinterpret_cast<T*>(array),
             reinterpret_cast<T*>(array+N),
             val );
}

// binary search
ll BSearch(ll ok, ll ng, bool (*f)(ll)){
  ll mid;
  while(abs(ok - ng) > 1LL) {
    mid =  (ok + ng) / 2LL;
    if(f(mid)) {
      debug("BSearch: f(%d) == true\n", mid);
      ok = mid;
    }
    else
    {
      debug("BSearch: f(%d) == false\n", mid);
      ng = mid;
    }
  }
  return ok;
}

ll NUM_TEST_CASE = 1;

ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};
ll calcDigits(int x){
  int ret = 0;
  while(x){
    ret += x % 10;
    x /= 10;
  }
  return ret;
}
void solve(){
  // main algorithm
  ans = INT_MAX;
  for (int a = 1; a < N; ++a)
    {
      int b = N - a;
      ans = min(ans, calcDigits(a) + calcDigits(b));
    }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
void init(){
  // initialize for each test case
  // Fill(dp, -1);
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // cin >> NUM_TEST_CASE;

  for (int test_case = 0; test_case < NUM_TEST_CASE; ++test_case)
  {
    init();

    cin >> N;
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();
  }

  return 0;
}

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

class edge{
public:
	Int cost;
	size_t from, to;
	edge(Int c, size_t f, size_t t){
		cost = c;
		from = f;
		to = t;
	}
};
using edges = vector<edge>;
using graph = vector<edges>;
void readgraph(graph &g, size_t E, bool D, bool C, bool Z){ // E:num_of_edges, D:directed, C:costed, Z:already 0-indexed
	for(size_t i=0; i<E; ++i){
		edge e(1, 0, 0);
		if(!C) cin >> e.from >> e.to;
		else cin >> e.from >> e.to >> e.cost;
		if(!Z){
			--e.from;
			--e.to;
		}
		g[e.from].push_back(e);
		if(!D){
			swap(e.from, e.to);
			g[e.from].push_back(e);
		}
	}
}
Int n, Q;
vector<vector<Int>> c;
vector<Int> ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> Q;
	graph g(n);
	readgraph(g, n-1, false, false, false);
	c.resize(n);
	vector<bool> f(n, false);
	queue<Int> q;
	q.push(0);
	while(!q.empty()){
		Int p = q.front(); q.pop();
		f[p] = true;
		for(auto i:g[p]){
			Int t = i.to;
			if(f[t]) continue;
			c[p].push_back(t);
			q.push(t);
		}
	}
//	for(Int i=0; i<n; ++i)
//		for(size_t j=0; j<c[i].size(); ++j)
//			cout << c[i][j] << " \n"[j+1==c[i].size()];
	ans.resize(n, 0ll);
	for(Int i=0; i<Q; ++i){
		Int p, x; cin >> p >> x;
		ans[p-1] += x;
	}
	q.push(0);
	while(!q.empty()){
		Int p = q.front(); q.pop();
		for(auto i:c[p]){
			ans[i] += ans[p];
			q.push(i);
		}
	}
	for(Int i=0; i<n; ++i)
		cout << ans[i] << " \n"[i+1==n];
}


Measured memory_bytes: 32128
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|e| e.parse().unwrap());
    let n: i64 = itr.next().unwrap();
    let m: i64 = itr.next().unwrap();

    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let itr = s.split_whitespace().map(|e| e.parse().unwrap());
    let mut v: Vec<i64> = itr.collect();
    let total: i64 = v.iter().sum();
    v.sort();
    let v: Vec<i64> = v.into_iter().rev().collect();
    let t = v.iter().filter(|&e| e * 4 * m >= total).count();

    if t as i64 >= m {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstdlib>
#include<cstring>

using namespace std;
int main()
{
	int n, m;
	scanf("%d", &n);
	if(n % 2 != 0){m = n / 2 + 1;}
	else{m = n / 2;}
	printf("%d", m);
	return 0;

}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

typedef long long ll;

const int MAX_N = 102;
ll a[MAX_N][MAX_N];
ll sum[MAX_N][MAX_N];
int n;

void solve()
{
    sum[0][0] = a[0][0];
    for (int i = 1; i < n; ++i) {
        sum[0][i] = sum[0][i - 1] + a[0][i];
        sum[i][0] = sum[i - 1][0] + a[i][0];
    }
    for (int i = 1; i < n; ++i)
        for (int j = 1; j < n; ++j)
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1]
                - sum[i - 1][j - 1] + a[i][j];

    // (i, j)-(k, m)
    ll ans = sum[0][0];
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            for (int k = i; k < n; ++k)
                for (int m = j; m < n; ++m) {
                    ll area = sum[k][m];

                    if (i != 0)
                        area -= sum[i - 1][m];
                    if (j != 0)
                        area -= sum[k][j - 1];
                    if (i != 0 && j != 0)
                        area += sum[i - 1][j - 1];
                    ans = max(ans, area);
                }
    cout << ans << endl;
}

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

    if (n == 1)
        cout << a[0][0] << endl;
    else
        solve();

    return 0;
}

Measured memory_bytes: 1324
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
main()
{
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(A.begin(),A.end());
  if(unique(A.begin(),A.end())!=A.end())cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
#pragma GCC opimize (3, "Ofast", "inline")
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
const int maxn = 2e5 + 5;
int n, k;
ll f[maxn], finv[maxn];
inline ll ksm(int x, int k) {
	ll ret = 1, base = x;
	while(k) {
		if(k & 1) ret = ret * base % mod;
		base = base * base % mod, k >>= 1;
	}
	return ret;
}
inline ll C(int n, int m) {
	return f[n] * (finv[n-m] * finv[m] % mod) % mod;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> n >> k;
	f[0] = f[1] = 1;
	for(int i = 2; i <= n + 1; ++i) f[i] = f[i - 1] * i % mod;
	finv[n + 1] = ksm(f[n + 1], mod - 2); 
	for(int i = n; i >= 0; --i) finv[i] = finv[i + 1] * (i + 1) % mod;
	ll ans = 0;
	for(int i = 0; i <= min(n-1, k); ++i) {
		ans = (ans + C(n, i) * C(n-1, n-i-1)) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define MAX 1000000
#define INF 1000000 
#define M 1000000007
#define PI 2 * acos(0.0)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main(){
    fast_io
    ll n;
    cin>>n;
    if(n >= 30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

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

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    string c = a + b;
    int n = 0;
    REP(i, c.length()){
        n *= 10;
        n += c[i] - '0';
    }
    REP(i, 400){
        if(n == i * i){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
using LL = long long;
using PII = pair<int, int>;
#define F first
#define S second

PII p[200010];
int n;

const int maxn = 200010;
struct Segment {
  int n, t[maxn * 2];
  void build() {
    for (int i = n - 1; i; --i)
      t[i] = t[i<<1] + t[i<<1|1];
  }
  void modify(int p, int v) {
    p += n;
    t[p] = max(t[p], v);
    for (; p > 1; p >>= 1)
      t[p >> 1] = max(t[p], t[p ^ 1]);
  }
  int query(int l, int r) {
    r += 1;
    int sum = 0;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l&1) sum = max(sum, t[l++]);
      if (r&1) sum = max(sum, t[--r]);
    }
    return sum;
  }
} seg;

vector<int> a;

int solve() {
  vector<int> b = a;
  sort(ALL(b));
  b.erase(unique(ALL(b)), b.end());
  seg.n = b.size() + 5;
  int ret = 0;
  for (int x : a) {
    x = lower_bound(ALL(b), x) - b.begin();
    int t = seg.query(0, x) + 1;
    ret = max(ret, t);
    seg.modify(x, t);
  }
  return ret;
}
const long double pi = acos(-1);
int main() {
  const long double arc = pi * 5;
  int x1, y1, x2, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  scanf("%d", &n);
  REP(i, n) scanf("%d%d", &p[i].F, &p[i].S);
  if (x1 > x2) {
    x1 = -x1;
    x2 = -x2;
    REP(i, n) p[i].F = -p[i].F;
  }
  if (y1 > y2) {
    y1 = -y1;
    y2 = -y2;
    REP(i, n) p[i].S = -p[i].S;
  }
  long double ans = 100.0 * (fabs(x1 - x2) + fabs(y1 - y2));
  sort(p, p + n);
  stack<int> s;
  REP(i, n) {
    if (p[i].F < x1 || p[i].F > x2 || p[i].S < y1 || p[i].S > y2) continue;
    a.PB(p[i].S);
  }
  int m = solve();
  ans += m * (arc - 20);
  if (m == abs(x1 - x2) + 1 || m == abs(y1 - y2) + 1)
    ans += arc;
  printf("%.20Lf\n", ans);
  return 0;
}



Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N, K;
    cin >> N >> K;
    double ans = max(0.0,(N-K+1) / (double)N);

    for(int i=1;i<=min(N,K-1);i++){
        ll cnt = 0;
        ll p = i;
        while(p<K){
            cnt++;
            p *= 2;
        }

        ans += pow(0.5,cnt) * (1/(double)N);
    }
    cout << Double(ans) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

void solve()
{
    int w, a, b;
    cin >> w >> a >> b;
    
    if(b >= a + w)
    {
        cout << b - a - w;
    }
    else if(a >= b + w)
    {
        cout << a - b - w;
    }
    else
    {
        cout << 0;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    //freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll n,m,i;
  vector<ll> x;
  cin >> n >> m;
  for(i=1;i*i<=m;i++){
    if(m%i==0){
      x.push_back(i);
      if(i!=(m/i)){
        x.push_back(m/i);
      }
    }
  }
  ll ans=0;
  for(i=0;i<x.size();i++){
    if(ans<x[i] && n<=m/x[i]){
      ans=x[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





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

  int sum=0;
  for(int i=0;i<N;i++){
    sum+=a[i]-1;
  }
  cout<<sum<<endl;

  



}


  
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> V(n + 1), W(n + 1);
	for (int i = 1; i <= n; ++i) scanf("%d%d", &V[i], &W[i]);
	const int MX = 100000;
	vector<vector<int>> dp(512);
	dp[0].resize(MX + 1);
	for (int i = 1; i <= min(511, n); ++i) {
		int p = i / 2;
		dp[i] = dp[p];
		for (int j = W[i]; j <= MX; ++j)
			dp[i][j] = max(dp[i][j], dp[p][j - W[i]] + V[i]);
	}
	int q;
	scanf("%d", &q);
	while (q--) {
		int v, L;
		scanf("%d%d", &v, &L);
		vector<int> pars;
		while (v > 511) {
			pars.push_back(v);
			v >>= 1;
		}
		int ans = 0;
		int s = pars.size();
		function<void(int, int, int)> go = [&](int i, int w, int val) {
			if (w > L) return;
			if (i == s) {
				ans = max(ans, dp[v][L - w] + val);
				return;
			}
			go(i + 1, w, val);
			go(i + 1, w + W[pars[i]], val + V[pars[i]]);
		};
		go(0, 0, 0);
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 205996
#include<stdio.h>

int main(){
	int W, a, b;
	scanf("%d %d %d", &W, &a, &b);
	if(a + W < b){
		printf("%d\n", b - a - W);
	}else if(a > b + W){
		printf("%d\n", a - b - W);
	}else{
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		int count = 0;
		for(String value : s.split("")) {
			if(value.equals("1")) count++;
		}

		System.out.println(count);

	}

	public static void print(Object o) {
		System.out.print(o);
	}

	public static void println(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll mod = 1e9+7;
int main(){ 
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  auto make = [&](string s) {
    string tmp = "";
    int prev = 0;
    s += "#";
    for (int i = 0; i < s.size(); i++) {
      if (s[prev] != s[i]) {
        tmp += s[prev];
        prev = i;
      }
    }
    return tmp;
  };
  s = make(s);
  t = make(t);
  n = s.size();
  ll res = (s[0] == t[0] ? 3 : 6);
 
  for (int i = 1; i < n; i++) {
    if (s[i] == t[i]) {
      if (s[i - 1] == t[i - 1]) res *= 2;
      else res *= 1;
    } else {
      if (s[i - 1] == t[i - 1]) res *= 2;
      else res *= 3;
    }
    res %= mod;
  }
  cout << res << endl;
  return 0; 
} 

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

double H[1010];

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int N; cin>>N;
  double T,A; cin>>T>>A;
  rep(i,N) cin>>H[i];
  int ans=0;
  for(int i=1;i<N;i++){
    double tmp=T-H[i]*0.006;
    double a=T-H[ans]*0.006;
    if(abs(A-tmp)<abs(A-a)) ans=i;
  }
  cout<<ans+1<<endl;
  return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 1010;

int main()
{
    int sum = 0, maxa = -1, n;

    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        maxa = max(maxa, x);
        sum += x;
    }

    sum -= maxa / 2;
    cout << sum << endl;
    return 0;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(k), r(k);
  rep(i,k) cin >> l[i] >> r[i];
  vector<mint> dp(n+1);
  vector<mint> dpsum(n+1);
  dp[1] = 1;
  dpsum[1] = 1;
  for (int i = 2; i <= n; ++i) {
    rep(j,k) {
      // [l[i], r[i]]
      int li = i-r[j];
      int ri = i-l[j];
      if (ri < 0) continue;
      li = max(li,1);
      dp[i] += dpsum[ri]-dpsum[li-1]; //dp[li]~dp[ri];
    }
    dpsum[i] = dpsum[i-1]+dp[i];
  }
  cout << dp[n] << endl;
  return 0;
}


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

int main(){
    string s;
    cin >>s;
    int N = s.size();
    for(int i =1; i < N; i +=2){
        if(s[i]  !='L'&&s[i]  !='U' &&s[i] !='D'){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = 0; i < N; i +=2){
        if(s[i]  !='R'&& s[i]  !='U' &&s[i] !='D'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

/*int ter_search(int l,int r)
{
    while((r-l)>0)
    {
        int m1=l+(r-l)/3;
        int m2=r-(r-l)/3;
        int f1=f(m1);
        int f2=f(m2);
        if(f1>f2)
         l=m1+1;
         else
          r=m2-1;
    }
    return f(l);
}*/



int32_t main()
{
    fast;
    int n,m,k;
    cin>>n>>m>>k;
    int a[n+1],b[m+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
     for(int i=1;i<=m;i++)
     {
        cin>>b[i];
     }
     int prefa[n+1],prefb[m+1];
     prefa[0]=prefb[0]=0;
     for(int i=1;i<=n;i++)
     {
         prefa[i]=prefa[i-1]+a[i];
     }
     for(int i=1;i<=m;i++)
     {
         prefb[i]=prefb[i-1]+b[i];
     }
     int r=m;
     int res=0;
     for(int l=0;l<=n;l++)
     {
        if(prefa[l]>k)
         break;
        while((k-prefa[l])<prefb[r])
         r--;
        res=max(res,l+r); 
     }
     cout<<res<<"\n";
    return 0;
}


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

int n, m;
int ans = 0;

int main(){
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> k(m);
  rep(i, m){
    cin >> k[i];
    rep(j, k[i]){
      int tmp;
      cin >> tmp;
      s[i].push_back(tmp);
    }
  }
  vector<int> p(m);
  rep(i, m) cin >> p[i];
  vector<int> on(n);

  for(int bit = 0; bit < (1<<n); bit++){
    for(int sn = 0; sn < n; sn++){
      if(bit & (1<<sn)) on[sn] = 1;
      else on[sn] = 0;
    }
    bool can = true;
    rep(i, m){
      int onnum = 0;
      rep(j, k[i]){
        if(on[s[i][j]-1]) onnum++;
      }
      if(p[i] == (onnum%2)) continue;
      else{
        can = false;
        break;
      }
    }
    if(can) ans++;
  }
  
  cout << ans << endl;
  
  
  
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

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

const int mod = INF+7;
int main(){
    int n;cin>>n;
    string a,b,c;cin>>a>>b>>c;
    int res = 0;
    rep(i,n){
        int cnt = 1;
        if(a[i]==b[i])cnt++;
        if(b[i]==c[i])cnt++;
        if(c[i]==a[i])cnt++;
        if(cnt>3)cnt--;
        res += 3-cnt;
    }
    cout<<res<<endl;
}



Measured memory_bytes: 256
s=input();n=len(s)
def f(i,t,k):
 if k>n-i:return 0
 a=max(t,int(s[i]));i+=1
 if a==0:z=f(i,t,k)
 elif k==1:z=a+(n-i)*9
 else: z=f(i,9,k)+(a-1)*f(i,9,k-1)+f(i,t,k-1)
 return z
print(f(0,0,int(input())))

Measured memory_bytes: 41448
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int h, w; readV(h, w);
  string[] s; readC(h, s);

  auto b = new int[][](h+2, w+2);
  foreach (i; 0..h)
    foreach (j; 0..w)
      b[i+1][j+1] = s[i][j] == '#';

  foreach (i; 1..h+1)
    foreach (j; 1..w+1) {
      if (!b[i][j]) continue;
      auto r = b[i-1][j]+b[i+1][j]+b[i][j-1]+b[i][j+1];
      if (r == 0) {
        writeln("No");
        return;
      }
    }

  writeln("Yes");
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60
/* http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A&lang=jp */
/*
??????
?????¢???c1, c2,..., cm????????????m????¨????????????????????????£??????
n ?????????????????¨?????????????????????????°?????????°????±???????????????????
????????¢???????????????????????§????????¨???????????¨?????§????????????

??????
????????????????°??????°???????????????????????????????????????
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll n, m; cin >> n >> m;
	vector<ll> c(m);
	vector<ll> dp(50010, INF);
	for (int i = 0; i < m;i++) {
		cin >> c[i];
		dp[c[i]] = 1;
	}
	for (int i = 0; i < n;i++) {
		if (dp[i] == INF)continue;
		for (int j = 0; j < m;j++) {
			if (i + c[j] > n)continue;
			dp[i + c[j]] = min(dp[i + c[j]], dp[i] + 1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 3380
#include <iostream>
#include <cstring>

using namespace std;

const int maxn = 110;

int n,m,x,state;
int a[maxn][maxn],c[maxn];

int ans = 99999999;
void dfs(int y){
    if (y
    == n){
        /*
        for (int i = 0; i < n; i++)
            if (state >> i & 1) cout << i + 1 << " ";
        cout << endl;
        */
        int cnt[110];
        memset(cnt,0,sizeof cnt);
        int w = 0;
        for (int i = 0; i < n; i++){
            if (state >> i & 1){
                w += c[i];
                for (int j = 0; j < m; j++){
                    cnt[j] += a[i][j];
                }
            }
        }
        bool flag = true;
        for (int i = 0; i < m; i++){
            if (cnt[i] < x){
                flag = false;
                //cout << "cnt: " << cnt[i] << endl;
            } 
        }
        
        if (flag){
            /*
            for (int i = 0; i < m; i++){
                cout << cnt[i] << " ";
            }
            */
            //cout << w;
            //cout << endl;
            ans = min(ans,w);
        }
        return;
    }
    state += 1 << y;
    dfs(y + 1);
    state -= 1 << y;
    dfs(y + 1);
    
}

int main(){
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++){
        cin >> c[i];
        for (int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    dfs(0);
    if (ans != 99999999){
        cout << ans;
    }else{
        cout << -1;
    }
    return 0;
}

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

int main(){
    int N;  cin>>N;
    ll ans=0;
    vector<ll> A(N,0);
    bool can=false;
    int count=0,minimum=100001;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(A[i]==0)true;
        if(A[i]<0)count++;
        A[i]=abs(A[i]);
        ans+=abs(A[i]);
    }
    sort(A.begin(),A.end());
    if(can||count%2==0){
        cout<<ans;
    }
    else{
        cout<<ans-(2*A[0]);
    }
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int l = s.size();
  string ans;
  for(int i = 0; i < l; ++i){
    if(s.at(i) == '0') ans.push_back('0');
    if(s.at(i) == '1') ans.push_back('1');
    if(s.at(i) == 'B'){
      if(ans.size() > 0) ans.pop_back();
    }
  }
  
  cout << ans << endl;
}

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

int main(void){
	string s;
	cin >> s;
	int count = 0;
	int a[4];
	string b[4];
	//for(int i = 0; i < s.size(); ++i){
	int i = 0;
		for(int j = i+1; j < s.size(); ++j){
			for(int k = j+1; k < s.size(); ++k){
				for(int l = k+1; l < s.size(); ++l){
					b[0] = s.substr(i,j-i);
					b[1] = s.substr(j,k-j);
					b[2] = s.substr(k,l-k);
					b[3] = s.substr(l,s.size());
					bool fl = true;
					for(int p = 0; p < 4; ++p){
						a[p] = stoi(b[p]);
						if(a[p]<0 || a[p] > 255) fl = false;
						if(a[p]==0){
							if(b[p]!="0") fl = false;
						}
						if(a[p]!=0){
							if(b[p][0]=='0') fl = false;
						}
					}
					if(fl){
						count++;
						//cout << a[0] << " "<<  a[1] << " "<< a[2] << " "<< a[3] << " "<< endl;
					}
				}
			}
		}
	//}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3208
canmake = [False for _ in range(2001)]
n = int(input())
A = [int(s) for s in input().split()]
q = int(input())
M = [int(s) for s in input().split()]
for a in A:
	for num in range(2000-a,0,-1):
		if canmake[num]: canmake[a+num] = True
	canmake[a] = True
for m in M:
	if canmake[m]: print('yes')
	else: print('no')


Measured memory_bytes: 7736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ____Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            string ans = "" ;

            for (int i = 0; i < s.Length; i++)
            {
                if (i % 2 == 0)
                {
                    ans += s[i];
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 34772
import sys

N=int(input())
A=list(map(int,input().split()))
mod=10**9+7

V=sorted(A)

if N%2==0:
    for i in range(N):
        if V[i]!=i//2*2+1:
            print(0)
            sys.exit()

else:
    for i in range(N):
        if V[i]!=(i+1)//2*2:
            print(0)
            sys.exit()    

print(pow(2,N//2,mod))

Measured memory_bytes: 13812
time_list = []
loss_time_list = []
for i in range(5):
  time_list.append(int(input()))
  loss_time_list.append((10-time_list[i]%10)%10)
#print(loss_time_list)
print(sum(time_list)+sum(loss_time_list)-max(loss_time_list))


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;

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

    int a,b;
    int ans = 0;
    cin >> a >> b;
    for(int i = a; i <= b; i ++){
        if(((i%10)-(i/10000)) == 0 && (((i/10)%10) - ((i/1000)%10)) == 0){
            ans ++;
        }
    }
    cout << ans;
    return 0;
}









Measured memory_bytes: 3624
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

#define MAXN 200005

class CAttackSurvival {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, k, q;
		in >> n >> k >> q;

		int a[MAXN];
		int questionAnswered[MAXN];
		memset(questionAnswered, 0, sizeof(questionAnswered));
		for (int i = 0; i < q; i++)
			in >> a[i], questionAnswered[a[i]-1]++;

		int points[MAXN];
		fill(points, points+n, k);
		for (int i = 0; i < n; i++)
			points[i] -= (q-questionAnswered[i]), out << (points[i] > 0? "Yes\n" : "No\n");


	}
};

int main() {
	CAttackSurvival solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

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

const int MAX_N=2*100000;
ll bit[MAX_N+10], a[MAX_N+1],s[MAX_N+1];
P p[MAX_N+1];

ll sum(ll i){
    ll s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}

void add(ll i, int x){
    while(i<=MAX_N){
        bit[i]+=x;
        i+=i&-i;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,K;
    cin>>N>>K;
    rep(i,0,N){
        cin>>a[i];
        a[i]-=K;
    }
    s[0]=0;
    p[0]=P(0,0);
    rep(i,0,N){
        s[i+1]=s[i]+a[i];
        p[i+1]=P(s[i+1],i+1);
    }
    sort(p,p+N+1);
    int temp=1;
    a[p[0].second]=temp;
    rep(i,1,N+1){
        if (p[i].first!=p[i-1].first){
            temp++;
        }
        a[p[i].second]=temp;
    }
    ll ans=0;
    rep(i,0,N+1){
        ans+=sum(a[i]);
        add(a[i],1);
    }
    cout << ans<<"\n";
}

Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}
/*
 Atcoder 100~200点代
 アな問題が多いので,まとめる
*/
// https://abc042.contest.atcoder.jp/tasks/abc042_a
//void solve(){ ll A,B,C; cin >> A >> B >> C; if(A == 5 && B == 5 && C == 7){ cout << "YES" << endl; return;} if(A == 5 && B == 7 && C == 5){ cout << "YES" << endl; return;} if(A == 7 && B == 5 && C == 5){ cout << "YES" << endl; return;} cout << "NO" << endl; return ; }
// https://abc043.contest.atcoder.jp/tasks/abc043_a
//void solve(){ ll N; cin >> N; cout << N*(N+1)/2 << endl; }
// https://abc044.contest.atcoder.jp/tasks/abc044_a
//void solve(){ll N,K,X,Y;cin>>N>>K>>X>>Y; cout<<X*min(N,K)+Y*max(0LL,N-K)<<endl;}
// https://abc045.contest.atcoder.jp/tasks/abc045_a
void solve(){ll a,b,h;cin>>a>>b>>h;cout<<(a+b)*h/2<<endl;}
// https://abc046.contest.atcoder.jp/tasks/abc046_a
//void solve(){ ll a,b,c; cin >> a >> b >> c; set<ll> s; s.insert(a); s.insert(b); s.insert(c); cout << s.size() << endl; }
// https://abc047.contest.atcoder.jp/tasks/abc047_a
//void solve(){}
// https://abc048.contest.atcoder.jp/tasks/abc048_a
//void solve(){string s1,s2,s3;cin>>s1>>s2>>s3;cout<<"A"<<s2[0]<<"C"<<endl;}
// https://abc049.contest.atcoder.jp/tasks/abc049_a
//void solve(){}
// https://abc050.contest.atcoder.jp/tasks/abc050_a
//void solve(){}
// https://abc051.contest.atcoder.jp/tasks/abc051_a
//void solve(){}
// https://abc052.contest.atcoder.jp/tasks/abc052_a
//void solve(){}
// https://abc053.contest.atcoder.jp/tasks/abc053_a
//void solve(){}
// https://abc054.contest.atcoder.jp/tasks/abc054_a
//void solve(){}

// Main function
int main(void) {cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }


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

int main() {
    string S;
    bool b = true;
    cin >> S;
    int N = S.size();
    for (int i = 0; i < (N - 1) / 2; i++) {
        if (S[i] != S[N - 1 - i]) {
            b = false;
            break;
        }
    }
    if (b) {
        for (int i = 0; i < (N + 1) / 4; i++) {
            if (S[i] != S[(N + 1) / 2 + i]) {
                b = false;
                break;
            }
        }
    }
    if (b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//Li Chao Segment Tree - trial
//dp(@)-Z
#include<stdio.h>
#define llinf 4154118101919364364

long long llmin(long long a,long long b){if(a<b){return a;}return b;}

//f(x) = (x-vertex)^2 + cv
typedef struct{
  long long vertex;
  long long cv;
}func;

long long fcalc(long long x,func f){
  return (x-f.vertex)*(x-f.vertex)+f.cv;
}

func li_chao[2097152];
long long ssize=1048576;

void sinit(){
  long long i;
  for(i=0;i<2097152;i++){
    li_chao[i].vertex=0;
    li_chao[i].cv=llinf;
  }
}

//add func f
//call:k=0,st=0,fi=0
void add(func f,long long k,long long st,long long fi){
  long long nst=fcalc(st,f),nfi=fcalc(fi-1,f);
  long long pst=fcalc(st,li_chao[k]),pfi=fcalc(fi-1,li_chao[k]);
  if(nst>=pst && nfi>=pfi){return;}
  if(nst<=pst && nfi<=pfi){
    li_chao[k]=f;
    return;
  }
  long long mid=(st+fi)/2;
  add(f,2*k+1,st,mid);  
  add(f,2*k+2,mid,fi);  
}

//get min f(x)
long long get(long long x){
  long long p=x+ssize-1,res=llinf;
  while(p>=0){
    res=llmin(fcalc(x,li_chao[p]),res);
    if(p==0){break;}
    p=(p-1)/2;
  }
  return res;
}

int main(){
  sinit();
  long long n,c,h[262144],i;
  func f;
  scanf("%lld%lld",&n,&c);
  for(i=0;i<n;i++){
    scanf("%lld",&h[i]);
    f.vertex=h[i];
    if(i==0){
      f.cv=c;
    }
    else{
      f.cv=get(h[i])+c;
    }
    add(f,0,0,ssize);
  }
  printf("%lld\n",get(h[n-1]));
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int C = A * N;

  if (B <= C) {
    cout << B << endl;
  }
  else if (B > C) {
      cout << C << endl;
  }
}


Measured memory_bytes: 256
import sys
from bisect import bisect_left

def solve():
    input = sys.stdin.readline
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    for _ in range(Q):
        x = int(input())
        si = bisect_left(S, x)
        ti = bisect_left(T, x)
        minLength = 10 **20
        both_left = 10 ** 20
        both_right = 10 ** 20
        s_t = 10 ** 20
        t_s = 10 ** 20
        if si > 0 and ti > 0: both_left = max(x - S[si-1], x - T[ti - 1])
        if si <= A - 1 and ti <= B - 1: both_right = max(S[si] - x, T[ti] - x)
        if si > 0 and ti <= B - 1: s_t = T[ti] - S[si-1] + min(x - S[si-1], T[ti] - x)
        if ti > 0 and si <= A - 1: t_s = S[si] - T[ti-1] + min(x - T[ti-1], S[si] - x)
        minLength = min([both_left, both_right, s_t, t_s])
        print(minLength)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 12220
import numpy as np

n, k = map(int, input().split())

nx = np.arange(1, n+1)

ans = 0
ed = n
coin = 0

while (ed > 0):
    ct = 0
    for i in range(ed-1, -1, -1):
        if (nx[i] >= k):
            ct += 1
            ed = i
        else:
            break
    ans += ct*(1/2**(coin))

    # print(nx)
    nx *= 2
    coin += 1

print(ans/n)


Measured memory_bytes: 13128
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	string S;
	cin >> S;
	int tmp = 0;
	char p;
	for (int i = 0;i<S.length(); i++) {
		if(i==0) p = S[i];
		else {
			if (S[i] != p) {
				tmp++;
				p = S[i];
			}
		}
	}
	cout << tmp << endl;
	
	return 0;
	
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');

            int ans = 0;
            int prev = 0;

            for (int i = 0; i < N; i++)
            {
                int val = int.Parse(s[i]);

                if ( val < prev)
                {
                    ans += prev - val;
                }

                prev = val;
            }

            ans += int.Parse(s[N - 1]);

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140