akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  vector<double_t> P(N);
  for (auto& p : P) {
    cin >> p;
  }

  vector<vector<double_t>> dp(N+1, vector<double_t>(N+1));
  dp[0][0] = 1;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      dp[i][j] =
        dp[i-1][j] * (1 - P[i-1])
        + dp[i-1][j-1] * P[i-1];
    }
  }

  double_t ans{};
  for (int i = N/2 + 1; i <= N; ++i) {
    ans += dp[N][i];
  }
  cout 
    << std::setprecision(20)
    << std::setfill('0')
    << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
const int INF = 1e12;

struct UF{
   vector<int> par;
   vector<int> sz;
   UF(){}
   UF(int n){
       par.resize(n);
       sz.resize(n, 1);
       rep(i, 0, n) par[i] = i;
   }
   int find(int x){
       if(x == par[x]) return x;
       return par[x] = find(par[x]);
   }
   void unite(int x, int y){
       x = find(x); y = find(y);
       if(x == y) return;
       if(sz[x] < sz[y]) swap(x, y);
       sz[x] += sz[y];
       par[y] = x;
   }
   bool same(int x, int y){
       return find(x) == find(y);
   }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<PP> edge; 
    vector<int> x(n), y(n);
    vector<P> dx, dy; 
    rep(i, 0, n){
        cin >> x[i] >> y[i];
        dx.push_back(P(x[i], i));
        dy.push_back(P(y[i], i));
    }
    sort(all(dx));
    sort(all(dy));
    rep(i, 0, n - 1){
        int now = dx[i].second;
        int next = dx[i + 1].second;
        int cost = x[next] - x[now];
        edge.push_back(PP(cost, P(now, next)));
    }
    rep(i, 0, n - 1){
        int now = dy[i].second;
        int next = dy[i + 1].second;
        int cost = y[next] - y[now];
        edge.push_back(PP(cost, P(now, next)));
    }
    sort(all(edge));
    int ans = 0;
    UF uf(n);
    rep(i, 0, edge.size()){
        int u = edge[i].second.first;
        int v = edge[i].second.second;
        if(!uf.same(u, v)){
            ans += edge[i].first;
            uf.unite(u, v);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 14560
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

bool isneed(VL a, ll x, ll k){
    if (x >= k) return true;
    int n = a.size();
    VVL dp(n+1, VL(k+1));
    dp[0][0] = 1;
    REP(i,n){
        REP(j,k){
            dp[i+1][j] |= dp[i][j];
            if (j + a[i] <= k) dp[i+1][j+a[i]] |= dp[i][j];
        }
    }
    bool f = false;
    FOR(j,k-x,k-1) f |= dp[n][j];
    // printf("check %d, %d\n", x, f);
    // REP(i,n) cout << a[i] << " ";
    // cout << endl;
    // REP(j,k+1) cout << dp[n][j] << " ";
    // cout << endl;
    return f;
}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    VL a(n);
    REP(i,n) scanf("%lld", &a[i]);
    if (n == 1){
        int ans = 1;
        if (a[0] >= k) ans = 0;
        cout << ans << endl;
        return 0;
    }
    sort(ALL(a));
    int l = -1, h = n;
    while (h - l > 1){
        int m = (h+l)/2;
        VL b(a);
        b.erase(b.begin()+m);
        if (isneed(b, a[m], k)) h = m;
        else l = m;
    }
    cout << l+1 << endl;
    return 0;
}

Measured memory_bytes: 197872
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


map<string,int> MAP;

int main(){

	int num_query;
	scanf("%d",&num_query);

	int command,x;

	for(int loop = 0; loop < num_query; loop++){

		string tmp;
		scanf("%d",&command);

		if(command == 0){

			cin >> tmp >> x;
			MAP[tmp] = x;

		}else{

			cin >> tmp;
			printf("%d\n",MAP[tmp]);
		}
	}

	return 0;
}



Measured memory_bytes: 27976
s[50],i,j,p,q;
main(n){for(;n=atoi(gets(s)),n;printf("%d\n",i)){
for(i=0;i<n;s[i++]=strlen(gets(s+i)));
for(i=j=0;j<7;)for(p=i++,j=q=1;q>0;)for(q=j++>5?0:j-2&&j-4?8:6;q>1;q-=s[p++]);
}}

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

using namespace std;

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

  int H, N, a, sum = 0;
  cin >> H >> N;
  while (N--) {
    cin >> a;
    sum += a;
    if (sum >= H) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 256
a, b, c = map(int, input().split())
k = int(input())
counter = 0
while a >= b:
    b *= 2
    counter += 1
while b >= c:
    c *= 2
    counter += 1
#print(a, b, c)

if counter <= k:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61612
package main

import "fmt"

var (
	N int
	K int
	Q int
	A [1000*100 + 10]int
)

func contains(ss []rune, x rune) bool {
	for _, v := range ss {
		if v == x {
			return true
		}
	}
	return false
}

func main() {
	fmt.Scan(&N, &K, &Q)

	var a int
	for i := 1; i <= Q; i++ {
		fmt.Scan(&a)
		A[a]++
	}

	for i := 1; i <= N; i++ {
		if (K + A[i] - Q) > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 6656
from collections import defaultdict
import sys

ip = lambda : sys.stdin.readline()
ipl = lambda : sys.stdin.readline().split()

n, k = map(int, ipl())
snukes = [0 for i in range(n+1)]
for i in range(k):
	d = int(ip())
	snuke = list(map(int, ipl()))
	for s in snuke:
		snukes[s] = 1
c = 0
for i in snukes[1:]:
	if not i:
		c += 1
print(c)

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
#define All(a) a.begin(), a.end()
typedef pair<long long, long long> P;
long long INF = 1e18;
int main(){
    long long N, M, X;
    cin >> N >> M >> X;
    vector<long long> C(N);
    vector<vector<long long>> A(N, vector<long long> (M));
    for(int i = 0; i < N;  i++){
        cin >> C[i];
        for(int j = 0; j < M; j++) cin >> A[i][j];
    }
    long long ans = INF;
    for(int bit = 0; bit < (1 << N); bit++){
        vector<long long> ri(N, 0);
        long long res = 0;
        for(int i = 0; i < N; i++){
            if(bit & (1 << i)) {
                res += C[i];
                for(int j = 0; j < M; j++){
                    ri[j] += A[i][j];
                }
            }
        }
        int flag = 0;
        for(int i = 0; i < M; i++){
            if(ri[i] < X) {
                flag = 1;
                break;
            }
        }
        if(flag == 0) ans = min(ans, res);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3628
<?php
while ($line = fgets(STDIN)) {
    $data = explode(" ", rtrim($line));
    if ($data[0] == '0' and $data[1] == '0') exit;
    for ($i = 0; $i < $data[0]; $i++) {
        for ($j = 0; $j < $data[1]; $j++) {
            if (($i == 0 or $i == ($data[0] - 1)) or ($j == 0 or $j == ($data[1] -1))) {
                printf("#");
            } else {
                printf(".");
            }
        }
        printf("\n");
    }
    printf("\n");
}

Measured memory_bytes: 15312
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n,m;
int hotel[100010];
int d;
int main(){
	cin>>n>>m;
	hotel[0] = 0;
	hotel[1] = 0;
	for(int i = 1;i <= n-1;i++){
		cin>>d;
		hotel[i+1] =hotel[i]+d;
	}
	int pos = 1;
	long long sum = 0;
	for(int i =0 ;i < m;i++){
		cin>>d;
		sum +=abs(hotel[pos+d]-hotel[pos]);
		sum =sum%100000;
		pos = pos+d;
	}
	cout <<sum<<endl;
	return 0;
}

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

typedef long long int ll;

void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
#define fioe() fileioe()
#else
#define fioe() 1
#endif
//!

int main()
{
	GO
	//fioe();
	ll x;
	cin>>x;
	ll ans=0;
	ll val=(x/500);
	ans+=val*1000;
	x=x%500;
	x=x/5;
	ans+=x*5;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N, M; cin >> N >> M;
  priority_queue<ll> Q;
  for(int i=0; i<N; i++) {
    ll a;
    cin >> a;
    Q.push(a);
  }

  for(int m=0; m<M; m++){
    ll a = Q.top(); Q.pop();
    Q.push(a/2);
  }
  
  ll ans = 0;
  for(int i=0; i<N; i++){
    ll a = Q.top(); Q.pop();
    ans += a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t N;
    size_t count[9] = { 0,0,0,0,0,0,0,0,0 };

    scanf("%zu", &N);
    for (size_t i = 0; i < N; i++) {
        size_t a;
        scanf("%zu", &a);
        if (i < N - 1) {
            scanf(" ");
        }

        if (a < 3200) {
            count[a / 400]++;
        }
        else {
            count[8]++;
        }
    }

    size_t nonLegendCount = 0;
    for (size_t i = 0; i < 8; i++) {
        if (0 < count[i]) {
            nonLegendCount++;
        }
    }

    if (0 < nonLegendCount) {
        printf("%zu %zu\n", nonLegendCount, nonLegendCount + count[8]);
    }
    else {
        printf("%d %zu\n", 1, count[8]);
    }

    return 0;
}


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

using namespace std;

struct SuffixArray
{
  vector< int > SA;
  string s;

  void Build_SA(const string &str)
  {
    s = str;
    SA.resize(s.size());
    iota(begin(SA), end(SA), 0);
    sort(begin(SA), end(SA), [&](const int &a, const int &b)
    {
      if(s[a] == s[b]) return (a > b);
      return (s[a] < s[b]);
    });
    vector< int > classes(s.size()), c(s.size()), cnt(s.size());
    for(int i = 0; i < s.size(); i++) {
      c[i] = s[i];
    }
    for(int len = 1; len < s.size(); len <<= 1) {
      for(int i = 0; i < s.size(); i++) {
        if(i > 0 && c[SA[i - 1]] == c[SA[i]] && SA[i - 1] + len < s.size() && c[SA[i - 1] + len / 2] == c[SA[i] + len / 2]) {
          classes[SA[i]] = classes[SA[i - 1]];
        } else {
          classes[SA[i]] = i;
        }
      }
      iota(begin(cnt), end(cnt), 0);
      copy(begin(SA), end(SA), begin(c));
      for(int i = 0; i < s.size(); i++) {
        int s1 = c[i] - len;
        if(s1 >= 0) SA[cnt[classes[s1]]++] = s1;
      }
      classes.swap(c);
    }
  }

  int operator[](int k) const
  {
    return (SA[k]);
  }

  int size() const
  {
    return (s.size());
  }

  bool lt_substr(string &t, int si = 0, int ti = 0)
  {
    int sn = s.size(), tn = t.size();
    while(si < sn && ti < tn) {
      if(s[si] < t[ti]) return (true);
      if(s[si] > t[ti]) return (false);
      ++si, ++ti;
    }
    return (si >= sn && ti < tn);
  }

  int lower_bound(string &t)
  {
    int low = -1, high = SA.size();
    while(high - low > 1) {
      int mid = (low + high) >> 1;
      if(lt_substr(t, SA[mid])) low = mid;
      else high = mid;
    }
    return (high);
  }

  pair< int, int > lower_upper_bound(string t)
  {
    int idx = lower_bound(t);
    int low = idx - 1, high = SA.size();
    t.back()++;
    while(high - low > 1) {
      int mid = (low + high) >> 1;
      if(lt_substr(t, SA[mid])) low = mid;
      else high = mid;
    }
    t.back()--;
    return (make_pair(idx, high));
  }

  void output()
  {
    for(int i = 0; i < size(); i++) {
      cout << i << ": " << s.substr(SA[i]) << endl;
    }
  }
};


int main()
{
  char a[1000001], b[100001];
  scanf("%s", a);
  scanf("%s", b);

  SuffixArray sa;
  sa.Build_SA(string(a));

  auto get = sa.lower_upper_bound(string(b));
  bool v[1000000] = {};
  for(int i = get.first; i < get.second; i++) {
    v[sa[i]] = true;
  }
  for(int i = 0; i < sa.size(); i++) {
    if(v[i]) printf("%d\n", i);
  }
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);


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

  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n-1));
  rep(i, n) rep(j, n-1) {
    cin >> a[i][j];
    a[i][j]--;
  }
  rep(i, n) reverse(ALL(a[i]));

  ll ans = 0;
  set<int> s;   // 前日試合したリスト
  rep(i, n) s.insert(i);
  while (true) {
    set<pair<int, int>> m;  // ans+1 日目に試合する人たち
    for (auto itr = s.begin(); itr != s.end(); itr++) {
      if (a[*itr].empty()) continue;
      int e = a[*itr].back();
      if (a[e].empty()) continue;
      if (*itr == a[e].back()) m.insert({min(*itr, e), max(*itr, e)});
    }

    if (m.empty()) {  // 誰も試合しない
      rep(i, n) {
        if (!a[i].empty()) {   // 未消化の試合がある
          cout << -1 << endl;
          return 0;
        }
      }
      break;
    }

    s.clear();
    for (auto& p : m) {
      s.insert(p.first);
      s.insert(p.second);
      a[p.first].pop_back();
      a[p.second].pop_back();
    }
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    for (int  i = 0; i < n; i++)
    {
        cout << a.at(n - i - 1);
        if(i == n - 1){
            break;
        }
        cout << " ";
        /* code */
        /* code */
    }
    
    cout << endl;
}
    


Measured memory_bytes: 3088
#include<stdio.h>
int main()
{
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);
	printf("\n");
	{
	if((a==b && a!=c) || (a==c && a!=b) || (b==c && b!=a))
	{
		printf("Yes");
	}
	else
	printf("No");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int a,b,c,d;
 
  while(1){
    cin >> s;
    
    if(s=="#")break;

    int size=s.size();
    
    int t[10][10]={};
    
    cin >> a >> b >> c >> d;

    int count=0,num=0,w=0,h=0,ws=0;

    
    for(int i=0;i<size;i++){
      if(s[i]=='b'){
  ws++;
      }else if(s[i]-'0'>=1 && s[i]-'0'<=9){
  ws+=s[i]-'0';
      }else{
  h++;
  w=ws;
  ws=0;
      }
      
    }
    h++;
    
    
    for(int j=0;j<h;j++){
      for(int i=0;i<w;i++){
  if(s[count]=='/'){
    count++;
      }
      if(s[count]=='b'){
        t[j][i]=1;
        count++;
      }else{
    if(s[count]-'0'>=1 && s[count]-'0'<=9){
      num=s[count]-'0';
      for(int k=0;k<num;k++){
        t[j][i+k]=0;
      }
      i+=num-1;
      count++;
    }
      }
      num=0;
      }
    }
    // cout<<endl;
    // for(int j=0;j<2;j++){
      
    //   for(int i=0;i<w;i++){
    //  cout<<t[j][i]<<' ' ;
    //   }
    //   cout<<endl;
    // }


    t[a-1][b-1]=0;
    t[c-1][d-1]=1;
    
    for(int j=0;j<h;j++){

      for(int i=0;i<w;i++){
        if(i==0&&j!=0)cout<<'/';
        if(t[j][i]==0){
          num++;
          if(i==w-1){
          cout<<num;
          num=0;
          }
        }else if(num>0){
          cout<<num;
          num=0;
        }
      if(t[j][i]==1){
        cout<<'b';
      }
      }
  }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int i = 0; i <= N; i += R){
    for (int j = 0; j <= N; j += G){
      int k = N - i - j;
      if (k % B == 0 && k >= 0){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<stdio.h>
typedef long long ll;
using namespace std;

const ll mod = 998244353;
const ll inv2 = (mod + 1) >> 1;
ll poww(ll a, ll b){
	ll res = 1;
	while (b){
		if (b & 1) res = res * a % mod;
		a = a*a%mod;
		b >>= 1;
	}
	return res;
}

int n, s;
int a[3005];
ll c[3005];
int main(){
	cin >> n >> s;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		c[i] = 0;
	}
	c[0] = poww(2, n);
	for (int i = 1; i <= n; i++){
		for (int j = 3000 - a[i]; j >= 0; j--){
			c[j + a[i]] = (c[j + a[i]] + c[j]*inv2) % mod;
		}
		continue;
	}
	cout << c[s] << endl;
	return 0;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;


int main() {
    long long x, k, d;
    scanf("%lld%lld%lld", &x, &k, &d);
    if(x < 0) x = -x;
    long long t = (x / d);
    if(k <= t) {
        printf("%lld\n", x - k * d);
        return 0;
    }
    if((k - t) % 2 == 0) {
        printf("%lld\n", x % d);
    } else {
        printf("%lld\n", d - x % d);
    }

    return 0;
}


Measured memory_bytes: 3824
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int N;
	cin >> N;
	
	if (N % 3 == 0) {
		map< int, int > cnt;
		for_(i,0,N) {
			int a;
			cin >> a;
			cnt[a]++;
		}
		
		if (cnt.size() > 3) {
			puts("No");
			return 0;
		}
		
		Vec< int > v, t;
		for (auto it : cnt) {
			if (it.second > 0) {
				v.push_back(it.second);
				t.push_back(it.first);
			}
		}
		
		if (cnt.size() == 1) {
			if (t[0] == 0) puts("Yes");
			else puts("No");
		}
		else if (cnt.size() == 2) {
			if (v[0] == v[1] * 2 && t[1] == 0) puts("Yes");
			else if (v[1] == v[0] * 2 && t[0] == 0) puts("Yes");
			else puts("No");
		}
		else { // ==3
			if (v[0] == v[1] && v[1] == v[2]) {
				if ((t[0] ^ t[2]) == t[1] ||
					(t[1] ^ t[0]) == t[2] ||
					(t[2] ^ t[1]) == t[0]) puts("Yes");
				else puts("No");
			}
			else puts("No");
		}
	}
	else {
		bool isok = true;
		int a;
		cin >> a;
		for_(i,1,N) {
			int x;
			cin >> x;
			isok &= (x == a);
		}
		puts(isok ? "Yes" : "No");
	}
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 3840
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#define FOR(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
int N;
int main(void) {
	cin >> N;
	int res = N;
	FOR(i, 0, N+1) {
		int cc = 0;
		int t = i;
		while (t > 0)cc += t % 6, t /= 6;
		t = N - i;
		while (t > 0)cc += t % 9, t /= 9;
		if (res > cc)res = cc;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    while(1){
        int n, k;
        cin>> n>> k;
        if(n==0&&k==0) break;
        int a[n];
        for(int i=0; i<n; i++){
            scanf("%d", &a[i]);
        }

        long long s[n+1]={0};
        for(int i=0; i<n; i++){
            s[i+1]=s[i]+a[i];
        }
        long long ans=-100100100100100;
        for(int i=k; i<=n; i++){
            ans=max(ans, s[i]-s[i-k]);
        }

        cout<< ans<< endl;
    }

    return 0;
}

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

int main() {
  int n,a,amax,amin;
  cin >> n;
  cin >> a;
  amax = a;
  amin = a;
  for (int i=1; i < n; i++){
    cin >> a;
    if (amax < a) amax = a;
    if (amin > a) amin = a;
  }
  cout << amax - amin << endl; // 2
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())
 
int main()
{
    long x;
    cin >> x;

    long money = 100L;

    int cnt=0;
    while(money<x){
      money+=money*0.01L;
      cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    Book[] B;
    boolean[] isUse;
    int N,M,X;

    class Book{
        int C;
        int[] A;
        public Book(int C, int[] A){
            this.C = C;
            this.A = A;
        }
    }

    public Main() {
        Scanner scan = new Scanner(System.in);
        N = Integer.parseInt(scan.next());
        M = Integer.parseInt(scan.next());
        X = Integer.parseInt(scan.next());

        isUse = new boolean[N];
        B = new Book[N];

        for(int i=0;i<N;i++){
            int C = Integer.parseInt(scan.next());
            int[] A = new int[M];
            for (int j=0;j<M;j++){
                A[j] = Integer.parseInt(scan.next());
            }
            B[i] = new Book(C, A);
        }
        int minCost = search(0);
        if(minCost == Integer.MAX_VALUE){
            System.out.println(-1);
        } else {
            System.out.println(minCost);
        }
    }

    public int search(int index){
        if(index == N){
            int cost = 0;
            int[] temp = new int[M];
            for(int i=0;i<N;i++){
                if(isUse[i]) {
                     cost += B[i].C;
                    for (int j = 0; j < M; j++) {
                        temp[j] += B[i].A[j];
                    }
                }
            }

            for (int j = 0; j < M; j++) {
                if(temp[j] < X){
                    return Integer.MAX_VALUE;
                }
            }

            return cost;
        }
        isUse[index] = true;
        int use = search(index+1);
        isUse[index] = false;
        int noUse = search(index+1);

        return Math.min(use, noUse);
    }

    public static void main(String[] args) {
	    Main main = new Main();
    }
}


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

int main() {
  int a[3];
  for (int i = 0; i < 3; i++) cin >> a[i];
  sort(a, a+3);
  if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  
  return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
//const double EPS = 1e(-12);
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);
    int N, M;
    cin >> N >> M;

    cout << (int)pow(2, M) * (1900 * M + (N - M) * 100) << endl;
    return 0;
}

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

using namespace std;

using int64 = long long;
const int64 LINF = 1LL << 61;
const int INF = 1 << 30;

int main()
{
  int N, D[100];
  cin >> N;
  set< int > s;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    s.emplace(x);
  }

  cout << s.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    map<char,int> m;
    REP(i,n) {
        string s; cin >> s;
        map<char,int> m2;
        for(auto c:s) {
            m2[c]++;
        }
        if (i == 0) m = m2;
        else {
            for(auto c:m) {
                m[c.first] = min(m[c.first],m2[c.first]);
            }
        }
    }
    string ans = "";
    for(auto c: m) {
        string s(c.second,c.first);
        ans += s;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
int main(){
    long long h,i,logh,times=0,ans=0,two[40]={};
    scanf("%lld",&h);
    two[0]=1;
    for(i=1; i<40; i++){
        two[i]=2*two[i-1];
    }
    logh=h;
    while(logh>1){
        logh/=2;
        times++;
    }
    for(i=0; i<=times; i++){
        ans+=two[i];
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using lond = long double;

int main(){
	string s,ans;
	int k;
	cin >> k;
	cin >> s;
	
	if (s.size() <= k)
		cout << s << endl;
	else{
		ans = s.substr(0,k);
		ans += "...";
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
    int A;
    int B;
    int C;
    cin>>A>>B>>C;
    if (A+B+C<22){
        cout<<"win"<<endl;
        
     }else{
         cout<<"bust"<<endl;
     }


     
     
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
vector<vector<tuple<int,int,int>>> g;
ll dp[55][55*55];
int main(){
    int n, m, s;
    cin >> n >> m >> s;
    g.resize(n);
    s = min(s, (n - 1) * 50);
    rep(i,m){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;v--;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }
    vector<int>c(n);
    vector<int>d(n);
    rep(i,n)cin >> c[i] >> d[i];
    using P = tuple<ll,int,int>;
    priority_queue<P, vector<P>, greater<P>> pq;
    rep(i,n)rep(j,55*55)dp[i][j] = 1LL<<60;
    dp[0][s] = 0;
    pq.emplace(0,0,s);
    while(pq.size()){
        auto x = pq.top();
        pq.pop();
        int v = get<1>(x);
        int m = get<2>(x);
        if(dp[v][m] < get<0>(x))continue;
        for(auto y : g[v]){
            int to = get<0>(y);
            int pay = get<1>(y);
            int t = get<2>(y);
            if(m - pay >= 0 and dp[to][m - pay] > dp[v][m] + t){
                dp[to][m-pay] = dp[v][m] + t;
                pq.emplace(dp[to][m-pay], to, m-pay);
            }
        }
        if(dp[v][min(50*50,m + c[v])] > dp[v][m] + d[v]){
            dp[v][min(50*50,m + c[v])] = dp[v][m] + d[v];
            pq.emplace(dp[v][min(50*50,m + c[v])], v, min(50*50,m + c[v]));
        }
    }
    rep(i,n-1){
        cout << *min_element(dp[i+1], dp[i+1]+55*55) << endl;
    }
}


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

//戦闘回数
int64_t battle(int64_t x){
	if (x == 1){
    	return 1;
    }
    int64_t s = battle (x/2);
  	return 2*s + 1;
}

int main() {
  int64_t H;
  cin >> H;
  

  cout << battle(H) << endl;
  
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn dfs(v: &mut Vec<Vec<char>>, n: usize, c: usize, path: &mut Vec<char>) {
    let s = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
    if n == 0 {
        v.push(path.clone());
        return;
    }
    for i in 0..c {
        path.push(s[i]);
        dfs(v, n - 1, c, path);
        path.pop();
    }
    path.push(s[c]);
    dfs(v, n - 1, c + 1, path);
    path.pop();
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
    }
    let mut v = vec![];
    dfs(&mut v, n, 0, &mut vec![]);
    v.sort();
    for v in v {
        puts!("{}\n", v.into_iter().collect::<String>());
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 18812
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, A):
    for i, a in enumerate(A[K:]):
        if A[i] < a:
            print('Yes')
        else:
            print('No')


def main():
    N, K = read_int_n()
    A = read_int_n()
    (slv(N, K, A))


if __name__ == '__main__':
    main()


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

int main()
{
    int N, X;
    cin >> N >> X;
    int L[N];
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    int D[N + 1];
    D[0] = 0;
    int count = 1;
    for (int i = 1; i <= N; i++)
    {
        D[i] = D[i - 1] + L[i - 1];
        if (D[i] <= X)
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

ll gcd(ll x, ll y) {

	if (x % y == 0) {
		return y;
	}
	else {
		return gcd(y, x % y);
	}

}
int main()
{
	int k;
	cin >> k;
	ll ans = 0;
	fx(k) {
		fy(k) {
			ll f = gcd(x + 1, y + 1);
			fz(k) {
				ans += gcd(f,z+1);
			}
		}
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 3632
from bisect import bisect_left
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
a = list(map(int, input().split()))
G = [[] for _ in range(n)]
for i in range(n-1):
    u,v = map(lambda z:int(z)-1,input().split())
    G[u].append(v)
    G[v].append(u)

ans = [0 for i in range(n)]
dp = [10**10 for _ in range(n+1)]
check = [True for _ in range(n)]
def dfs(now):
    check[now] = False
    ite = bisect_left(dp, a[now])
    tmp = dp[ite]
    dp[ite] = a[now]
    ans[now] = bisect_left(dp, 10**10)
    #print(now,dp)
    for to in G[now]:
        if check[to]:
            dfs(to)
    dp[ite] = tmp

dfs(0)
print(*ans, sep="\n")

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>());
    int tmp;
    rep(i, 0, n - 1){
        cin >> tmp;
        a[tmp - 1].push_back(i);
    }
    rep(i, 0, n){
        cout << a[i].size() << endl;
    }
}


Measured memory_bytes: 14328
#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>;
using Graph = vector<vector<int>>;

int main() {
  int N,M;
  cin >> N >> M;
  vector <int> A(N);
  int cnt = 0;
  rep(i,N){
    cin >> A.at(i);
    cnt += A.at(i);
  }
  sort(A.begin(), A.end());
  if(A.at(N-M) >= (cnt+4*M-1)/(4*M)){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  return 0;
}


Measured memory_bytes: 256
let scan_int () = Scanf.scanf " %d" (fun x -> x)
let scan_array len read_func = Array.init len (fun _ -> read_func())

let () =
  let n = scan_int() in
  let h = scan_array n scan_int in
  let _ = h.(0) <- h.(0) - 1 in
  let rec for_loop i =
    if i >= n then true
    else
      if h.(i-1) > h.(i) then false
      else
        let _ = h.(i) <- max h.(i-1) (h.(i)-1) in
        for_loop (i+1) in
  if for_loop 1 then Printf.printf "Yes\n"
  else Printf.printf "No\n" 


Measured memory_bytes: 5248
N = int(input().strip())
i = 1
while i <= N:
    x = i
    if x % 3 == 0:
        print(" "+str(i),end="")
    else:
        while x > 0:
            if x%10 == 3:
                print(" "+str(i),end="")
                break
            x = x//10
    i += 1
print("")


Measured memory_bytes: 5872
import heapq
from collections import defaultdict

ans = 0
N, M = list(map(int, input().split()))
mlist = []
for i in range(M):
	mlist.append(list(map(int, input().split())))

for i in range(M):
	graph = defaultdict(list)
	for j in range(M):
		if j != i:
			a = mlist[j][0]
			b = mlist[j][1]
			graph[a - 1].append([b - 1, 1])
			graph[b - 1].append([a - 1, 1])
		dist_node = [float("inf") for i in range(N)]
		s = 0
		dist_node[s] = 0

		Q = []
		heapq.heappush(Q, (dist_node[s], s)) 

		while Q: 
			dis, v = heapq.heappop(Q)
			if dist_node[v] < dis:
				continue
			for u, w in graph[v]:
				alt = dis + w
				if dist_node[u] > alt:
					dist_node[u] = alt
					heapq.heappush(Q, (alt, u))
	if dist_node.count(float("inf")) != 0:
		ans += 1

print(ans)

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

#define ll long long

ll nc(ll a, ll b) {
  if (a == b || b == 0)
    return 1;
  else
    return nc(a-1, b-1) + nc(a-1, b);
}

int main() {
  ll N, P;
  cin >> N >> P;
  ll s = 0, t = 0;
  for (int i=0; i<N; i++) {
    int input;
    cin >> input;
    if (input % 2 == 0) s++;
    else t++;
  }

  ll ans = 0;
  if (P == 0) {
    for (int i=0; i<=t; i+=2)
      ans += pow(2, s) * nc(t, i);
  } else {
    for (int i=1; i<=t; i+=2)
      ans += pow(2, s) * nc(t, i);
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
    int A,B;
    cin >> A >> B;

    int c;
    
    if (A==B) c=2*A;
    else if (A>B) c=2*A-1;
    else c=2*B-1;
    
    cout << c << endl;
    
    
    
//    vector<int> a(M);
//    vector<int> b(M);
//    vector<int> n(N);
    
//    for (int i=0;i<M;i++) cin>>a.at(i)>>b.at(i);
//    for (int i=0;i<N;i++) {
//        n.at(i) = 0;
//        for (int j=0;j<M;j++){
//            if (a.at(j)==i+1) n.at(i)++;
//            if (b.at(j)==i+1) n.at(i)++;
//        }
//        cout << n.at(i) << endl;
//    }
}


Measured memory_bytes: 256
"""
AtCoder Educational DP Contest
https://atcoder.jp/contests/dp/tasks/dp_h

H - Grid

"""
import collections
import functools
import sys

DIVISOR = 1000000007


def get_adj_list(pairs):
    adj = collections.defaultdict(list)
    for (i, j) in pairs:
        adj[i].append(j)
    return adj


def solve(grid):
    dp = collections.defaultdict(int)
    dp[0, 0] = 1

    for hh in range(H):
        for ww in range(W):
            if (hh, ww) == (0, 0):
                continue
            if grid[hh][ww] == "#":
                dp[hh, ww] = 0
            else:
                dp[hh, ww] = (dp[hh - 1, ww] + dp[hh, ww - 1]) % DIVISOR
    return dp[H - 1, W - 1]



H, W = map(int, input().split())

grid = [input().strip() for _ in range(H)]
res = solve(grid)
print(res)


Measured memory_bytes: 172752
#include <iostream>

using namespace std;

int main(){
  int N,M,K; cin >> N >> M >> K;
  for(int n=0;n<=N;n++){
    for(int m=0;m<=M;m++){
      int ans=n*M+m*(N-2*n);
      if(ans==K){
        cout << "Yes" << endl;
        goto LABEL;
      }
    }
  }
  cout << "No" << endl;
  LABEL:
  return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b = LI()
    print(max(0,a-2*b))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n;
ll dp[200005], a[200005], b, ans = -1e15;
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%lld", a+i);
		dp[i] = (i>1?dp[i-2]:0) + a[i];
		if(i&1) dp[i] = max(dp[i], dp[i-1]);
	}
	if(n&1){
		for(int i=n-1; i>=0; i-=2){
			ans = max(ans, (i?dp[i-1]:0)+b);
			b += a[i];
		}
	}else ans = dp[n-1];
	printf("%lld\n", ans);
}

Measured memory_bytes: 6952
INF = float('inf')

N,M,RR = map(int,input().split(" "))
R = list(map(lambda x:int(x)-1,input().split(" ")))
G = [[] for i in range(N)]
sq = [[(x==y)-1 for x in range(RR)] for y in range(RR)]
for i in range(M):
    a,b,c = map(int,input().split(" "))
    a -= 1
    b -= 1
    G[a].append((b,c))
    G[b].append((a,c))

for i in range(RR):
    E = [INF for x in range(N)]
    F = [0 for x in range(N)]
    E[R[i]] = 0
    F[R[i]] = 1
    q = R[i]
    c = 1
    while c != N:
        for a,b in G[q]:
            if F[a]:
                continue
            if E[a] == -1:
                E[a] = E[q] + b
            else:
                E[a] = min(E[a],E[q] + b)
        a = [x for x in range(N) if not(F[x]) and E[x] != -1]
        q = min(a,key=lambda x:E[x])
        F[q] = 1
        c += 1
    for j in range(RR):
        sq[i][j] = E[R[j]]

q = [[[],0,0]]
s = []
while len(q):
    a,b,c = q.pop()
    if b == RR:
        s.append(c)
        continue
    for i in range(RR):
        if i in a:
            continue
        if b == 0:
            q.append([a+[i],b+1,0])
        else:
            q.append([a+[i],b+1,c+sq[a[-1]][i]])

print(min(s))


Measured memory_bytes: 8304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String hex1 = scanner.next();
		String hex2 = scanner.next();
		
		int num1 = Integer.parseInt(hex1, 16);
		int num2 = Integer.parseInt(hex2, 16);
		
		if (num1>num2) {
			System.out.println(">");
		}else if (num1==num2) {
			System.out.println("=");
		}else{
			System.out.println("<");
		}
		
		scanner.close();
	}
	
}

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

int main(void)
{
  int buf;
  while (true)
  {
    int n;
    cin >> n;
    if ( n == 0 ) break;
    int m = n / 4;
    int sum = 0;
    for (int i = 0; i < m; i++)
    {
      cin >> buf;
      sum += buf;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1160