akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <cstring>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 3e5 + 4;
const double EPS = 1e-7;
const int mod = 163577857;
const int hashpow = 2;
const int inf = 2e9;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int x;

void read() {
    cin >> x;
}

void solve() {
    int tmp = 100;
    int ans = 0;
    while (tmp < x) {
        tmp += tmp / 100;
        ++ans;
    }
    cout << ans << "\n";
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Measured memory_bytes: 3656
function Main(input) {
    var num = input.split('\n')[0];
    var field = input.split('\n')[1];
    var array = field.split(' ');
    var alice =[];
    var bob =[];
    array.sort(function(a, b) {
        return b - a;
    });
    var aliceNum = num/2;
    var bobNum = 0;
    if(num%2===0){
        bobNum=num/2;
    }else{
         bobNum=Math.round(num/2)-1;
    }
    for(var i =0; i<array.length; i++){
        if(i%2===0){
            alice.push(array[i]);
        }else{
             bob.push(array[i]);
        }
    }
    var aliceTotal =0;
    for(var j =0; j<alice.length; j++){
        aliceTotal+=Number(alice[j]);
    }
        var bobTotal =0;
    for(var k =0; k<bob.length; k++){
        bobTotal+=Number(bob[k]);
    }
    console.log(aliceTotal-bobTotal)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
import java.util.*

data class T(val from: Long, val to: Long) : Comparable<T> {
    override fun compareTo(other: T): Int {
        return if (from == other.from) return to.compareTo(other.to)
        else from.compareTo(other.from)
    }
}

fun main(args: Array<String>) {
    val list = ArrayList<T>()
    val n = readLine()!!.toInt()
    repeat(n) {
        val (a, b) = readLine()!!.split(" ").map { it.toLong() }
        list.add(T(a - b, a + b))
    }
    list.sort()

    var r = 1
    var prev = list[0]
    list.drop(1).forEach { now ->
        if (prev.to > now.from) {
            if (prev.to > now.to) prev = now
        } else {
            r++
            prev = now
        }
    }
    println(r)
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e6+5;
string s;
vector<ll> v[N];
ll n,d;
ll a[N];

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> d;
  cout << (n-1)/(2*d+1) + 1 << endl;
}


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

#define F first
#define S second

using namespace std;

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

const int N = 1010, M = 20010;

int n, m;
int a[N], b[N];
int f[M];

int main()
{
	scanf("%d%d", &m, &n);
	for (int i = 1; i <= n; i ++ ) scanf("%d%d", &a[i], &b[i]);

	memset(f, 0x3f, sizeof f);
	f[0] = 0;

	for (int i = 1; i <= n; i ++ )
		for (int j = a[i]; j <= m + a[i]; j ++ )
			f[j] = min(f[j], f[j - a[i]] + b[i]);
	
	int res = 0x3f3f3f3f;
	for (int i = m; i < M; i ++ ) res = min(res, f[i]);
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 1e9+7;

signed main(){
  lint n; cin >> n ;
  vector<lint> a(n), b(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];
  vector<pair<bool, int> > data1(n), data2(n);
  data1[0] = make_pair(true, a[0]);
  data2[n - 1] = make_pair(true, b[n - 1]);
  for(int i = 1; i < n; i++){
    if(a[i] == a[i - 1]) data1[i] = make_pair(false, a[i]);
    else data1[i] = make_pair(true, a[i]);
  }
  for(int i = n -2; i >= 0; i--){
    if(b[i] == b[i + 1]) data2[i] = make_pair(false, b[i]);
    else data2[i] = make_pair(true, b[i]);
  }
  bool ok = true;
  lint ans = 1;
  if(a[n - 1] != b[0]) ok = false;
  for(int i = 0; i < n; i++){
    bool a = data1[i].first, b = data2[i].first;
    lint c = data1[i].second, d = data2[i].second;
    if(a && b) if(c != d) ok = false;
    if(a && !b) if(c > d) ok = false;  
    if(!a && b) if(c < d) ok = false;
    if(!a && !b) ans *= min(c, d), ans %= MOD;
  }
  //for(int i = 0; i < n; i++) cout << data1[i].first << " " << data1[i].second << endl;
  if(ok) cout << ans << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(size_t i = 0; i<n; ++i)
using namespace std;
vector<bool> IsPrime;
vector<size_t> primes;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
    rep(i,max + 1){
        if(IsPrime[i]) primes.push_back(i);
    }
}

int main(){
    size_t n;
    cin >> n;
    vector<size_t> l(n), r(n);
    rep(i,n){
        cin >> l[i] >> r[i];
    }
    auto max = *max_element(r.begin(), r.end());
    sieve(max);
    rep(i,n){
        size_t ans = 0;
        for(auto itr = lower_bound(primes.begin(), primes.end(), l[i]); itr != primes.end() && *itr <= r[i]; ++itr){
            if(IsPrime[(*itr + 1)/2]) ++ans;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2432
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: int, B: int, C: int, s: "List[int]"):
    v = [A, B, C]
    ans = []
    if sum(v) == 0:
        return None
    if sum(v) == 1:
        for l, r in s:
            if v[l] + v[r] == 0:
                return None
            if v[l] == 0:
                ans.append(l)
            else:
                ans.append(r)
            v[l], v[r] = v[r], v[l]
        return ans
    if sum(v) > 1:
        for i in range(N):
            l, r = s[i]
            if v[l] + v[r] == 0:
                return None
            if v[r] == 1 and v[l] == 1 and i != N - 1:
                if r in s[i + 1]:
                    ans.append(r)
                    v[l] -= 1
                    v[r] += 1
                else:
                    ans.append(l)
                    v[l] += 1
                    v[r] -= 1
            elif v[r] == 0 or v[l] > v[r]:
                ans.append(r)
                v[l] -= 1
                v[r] += 1
            else:
                ans.append(l)
                v[l] += 1
                v[r] -= 1
        return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    def s2i(s: str):
        return ord(s[0])-ord('A'), ord(s[1])-ord('A')

    def i2s(i: int):
        return chr(i + ord('A'))

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [s2i(next(tokens)) for _ in range(N)]  # type: "List[int]"
    ans = solve(N, A, B, C, s)
    if ans == None:
        print(NO)
    else:
        print(YES)
        print("\n".join(list(map(i2s, ans))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 89720
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	char st[105];
	vector<string> x;
	int n, len;
	scanf("%d %d", &n, &len);
	for (auto i = 0; i < n; i++)
	{
		scanf("%s", st);
		x.push_back(st);
	}
	sort(x.begin(), x.end());
	for (auto s : x)
		printf("%s", s.c_str());
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
a, b, n = gets.chomp.split.map(&:to_i)
arr = []
1.upto(n){|i|
    1.upto(n){|j|
        arr << (Rational(i, j) * b - a).abs
    }
}
arr.sort!
arr.uniq!
arr.select!{|x| x.numerator % x.denominator == 0}
puts arr[0].to_i



Measured memory_bytes: 8912
n, m = map(int, input().split())
ikeru = [[] for _ in range(n)]
for i in range(m):
	a, b = map(int, input().split())
	ikeru[a-1].append(b-1)
	ikeru[b-1].append(a-1)

fukasa = [0 for _ in range(n)]
fukasamoto = [0 for _ in range(n)]
kaisuu = 0
settansaku = set([])
setmada = {0}
kouho = 1

while kouho != 0:
	kaisuu += 1
	for i in list(setmada):
		settansaku.add(i)
		setmada.remove(i)
		kouho -= 1
		for k in ikeru[i]:
			if not k in setmada:
				if not k in settansaku:
					setmada.add(k)
					kouho += 1
					fukasa[k] = kaisuu
					fukasamoto[k] = i+1

print("Yes")
for i in range(1, n):
	print(fukasamoto[i])

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

int main(){
  int n;
  int p;
  while(cin>>n>>p && n+p){
    vector<int> vec(n);
    int stone=p;
    int pos = 0;
    while(true){
      int i=pos%n;
      pos++;
      if(stone == 0 && vec[i] == p){
	cout<<i<<endl;
	break;
      } 
      if(stone <= 0){
	stone = vec[i];
	vec[i]=0;
      }
      else{
	stone--;
	vec[i]++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1196
n=int(input())
a=[0]*(10**5)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            a[i**2+j**2+k**2+i*j+j*k+k*i]+=1
for i in range(n):
    print(a[i+1])

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

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

  if (A + B < X || A > X){
    cout << "NO" << endl;
  }
  else
  {
    cout << "YES" << endl;
  }
  
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int h, w;
  scanf("%d %d", &h, &w);
  vector<string> board(h);
  int white = 0;
  for (int i = 0; i < h; ++i) {
    string s;
    cin >> s;
    board[i] = s;
    white += count(s.begin(), s.end(), '.');
  }
  queue<pair<int, int> > que;
  que.push(make_pair(0, 0));
  vector<vector<int> > dist(h, vector<int>(w, INF));
  dist[0][0] = 1;
  while (!que.empty()) {
    pair<int, int> p = que.front(); que.pop();
    int r = p.first, c = p.second;
    if (r == h - 1 and c == w - 1) {
      break;
    }
    for (int dr = -1; dr <= 1; ++dr) {
      for (int dc = -1; dc <= 1; ++dc) {
        if (abs(dr) + abs(dc) != 1) { continue; }
        int nr = r + dr, nc = c + dc;
        if (nr < 0 or nr >= h or nc < 0 or nc >= w) { continue; }
        if (dist[nr][nc] != INF or board[nr][nc] == '#') { continue; }
        dist[nr][nc] = dist[r][c] + 1;
        que.push(make_pair(nr, nc));
      }
    }
  }

  int ans = dist[h - 1][w - 1] == INF ? -1 : white - dist[h - 1][w - 1];
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort( unsigned short *A,unsigned short *B, int n);

int main(){
  unsigned short *A, *B;
  int n,i;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
  }

  CountingSort(A, B, n);

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  free(A);
  free(B);

  return 0;
}

void CountingSort(unsigned short *A,unsigned short *B, int n){
  int i,j;
  int C[VMAX+1];

  for(i = 0 ; i <= VMAX ; i++)  C[i] = 0;

  // C[i] に i の出現数を記録する 
  for(j = 1 ; j <= n ; j++) C[A[j]]++;

  // C[i] に i 以下の数の出現数を記録する
  for(i = 1 ; i <= VMAX ; i++) C[i] = C[i] + C[i-1];

   for(j = n ; j >= 1 ; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
    }
}

Measured memory_bytes: 8408
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M;
        cin >> N >> M;
        vll H(N+1);
        rep(i, 1, N+1) cin >> H[i];
        vector<priority_queue<ll>> pqs(N+1);

        rep(i, 0, M) {
            ll a, b;
            cin >> a >> b;
            pqs[a].push(H[b]);
            pqs[b].push(H[a]);
        }



        ll ans = 0;
        rep(i, 1, N+1) {
            ll x = 0;
            if (! pqs[i].empty()) x = pqs[i].top();
            if (H[i] > x) {
                ans++;
            }
        }
        cout << ans << endl;
}



Measured memory_bytes: 10556
#include<stdio.h>
int main(void)
{
    long long int n,x,k,d,i;
    scanf("%lld %lld %lld",&x,&k,&d);
    if(x != 0)
    {
        if(x < 0)
        {
            x = -1 * x;
        }
        if(x / k >= d  )
        {
            printf("%lld\n",x - d * k);
            return 0;
        }
        else
        {
            long long int a;
            a = x / d;
            x = x - d * a;
            if(x < 0)
            {
                x = -1 * x;
            }
            if((k - a) % 2 == 0)
            {
                printf("%lld\n",x);
                return 0;
            }
            else
            {
                printf("%lld\n",d - x);
                return 0;
            }
        }
    }
    else
    {
        if(k % 2 == 0)
        {
            printf("0\n");
            return 0;
        }
        else
        {
            printf("%lld\n",d);
            return 0;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 1728
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
total = t.count('r')*p+t.count('s')*r+t.count('p')*s
for i in range(k,n):
  if t[i-k]==t[i]:
    if t[i]=='r':
      total-=p
      t[i]='x'
    elif t[i]=='s':
      total-=r
      t[i]='x'      
    elif t[i]=='p':
      total-=s
      t[i]='x'
print(total)

Measured memory_bytes: 4084
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 998244353;
const double eps = DBL_EPSILON;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL_DEBUG
    freopen("input.txt", "r", stdin);
#endif
    int k;
    cin >> k;
    if (k < 10) {
        cout << k << endl;
        return 0;
    }
    vector<ll> res = { 1,2,3,4,5,6,7,8,9 };
    vector<ll> cur = { 1,2,3,4,5,6,7,8,9 };
    while (res.size() < k) {
        vector<ll> cur2;
        for (ll& i : cur) {
            if (i % 10 == 0) {
                cur2.push_back(i * 10);
                cur2.push_back(i * 10 + 1);
            }
            else if (i % 10 == 9) {
                cur2.push_back(i * 10 + 8);
                cur2.push_back(i * 10 + 9);
            }
            else {
                cur2.push_back(i * 10 + i % 10 - 1);
                cur2.push_back(i * 10 + i % 10);
                cur2.push_back(i * 10 + i % 10 + 1);
            }
        }
        //sort(all(cur2));
        for (ll& i : cur2) {
            res.push_back(i);
            if (res.size() == k) break;
        }
        cur = cur2;
    }
    cout << res.back() << endl;
    return 0;
}

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

int main()
{
  int a[3][3];
  int n;

  int i=0,j;
  for(i=0;i<3;i++)
  	for(j=0;j<3;j++)
      cin>>a[i][j];

  cin>>n;
  int b[n];
  for(i=0;i<n;i++)
  	cin>>b[i];
  //diagonal
  int k=0;
  for(i=0;i<3;i++)
  {
      for(j=0;j<3;j++)
      {
          while(k<n)
          {
              if(a[i][j]==b[k])
              {
                  a[i][j]=0;


              }
              k++;
          }
          k=0;
      }
  }
  int flag3=0,flag4=0;

  for(i=0;i<3;i++)
  {
      if(a[i][0]==0&&a[i][1]==0&&a[i][2]==0)
      {
          cout<<"Yes";
          return 0;
      }
      if(a[0][i]==0&&a[1][i]==0&&a[2][i]==0)
      {
          cout<<"Yes";
          return 0;
      }
      for(j=0;j<3;j++)
      {
          if((i==j)&&a[i][j]!=0)
            flag3=1;
          if((i+j)==2&&a[i][j]!=0)
            flag4=1;
      }
  }
  if(flag3==0||flag4==0)
  {
      cout<<"Yes";
      return 0;
  }
  cout<<"No";
  return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int R,G,B,N,ans=0;
    cin>>R>>G>>B>>N;
    for(int i=0;i<=3000;i++)
    {
        for(int j=0;j<=3000;j++)
        {
            int v=(i*R)+(j*G);
            if(N>=v&&(N-v)%B==0)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int h, n, a;
   string ans = "Yes";
   cin >> h >> n;
   FOR(i, 0, n)
   {
      cin >> a;
      h -= a;
   }
   if(h>0)
      ans = "No";
   cout << ans << endl;
   return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	if(n==2){
		cout<<"Borys"<<endl;
	}else if((a%2==0 && b%2==0) || (a%2==1 && b%2==1)){
		cout<<"Alice"<<endl;
	}else{
		cout<<"Borys"<<endl;
	}
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;

const int N = 110; 
char s[N][N]; 
int n, m; 
int dp[N][N]; 

int main() {
  scanf("%d %d", &n, &m);
  for(int i = 1; i <= n; ++i) 
    scanf("%s", s[i] + 1); 

  dp[1][1] = s[1][1] == '#';
  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= m; ++j) {
      if(i == 1 && j == 1) continue; 
      dp[i][j] = 1e9; 
      if(s[i][j] == '#') {
        if(i > 1) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (s[i - 1][j] != '#')); 
        if(j > 1) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (s[i][j - 1] != '#')); 
      } else {
        if(i > 1) dp[i][j] = min(dp[i][j], dp[i - 1][j]); 
        if(j > 1) dp[i][j] = min(dp[i][j], dp[i][j - 1]); 
      }
    }
  }

  printf("%d\n", dp[n][m]); 
  return 0;
}

Measured memory_bytes: 256
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	
	public void solve(InputReader in, PrintWriter out) {
		int[] a = new int[3];
		
		for (int i=0; i<3; ++i)
			a[i] = in.nextInt();
		Arrays.sort(a);
		
		if (a[1]-a[0] == a[2]-a[1])
			out.println("YES");
		else
			out.println("NO");
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}
	
	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
} 

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

int main(){
	int c;
	cin>>c;

	int ans=0;

	for (int i = 1; i <=c; i+=2){
		int cnt=0;
		for (int j = 1; j <=c; j++){
			if(i%j==0){
				cnt++;
			}
		}
		if(cnt==8){
			ans++;
		}
	}


	cout<<ans<<endl;

}

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

typedef long long ll;

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void)
{
	int N, M;
	cin >> N >> M;
	ll ans = 1;
	const ll MD = 1000000007;
	if(abs(N - M) <= 1){
		if(abs(N - M) == 0) ans = 2;
		Rep(i, N){
			ans *= (i + 1);
			ans %= MD;
		}
		Rep(i, M){
			ans *= (i + 1);
			ans %= MD;
		}
	}else{
		ans = 0;
	}
	PrintLn(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define sz(x) (int)x.size()
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ins insert
#define y second
#define x first
#define endl "\n"
#define MOD (int)1e9+7
#define N (int)2e5+123

int a,b,c,d,i =0;
 
int main(){_
cin >> a >> b >> c >>d;
    while(a > 0 && c > 0){
    	if(i%2==0){
    		c-=b;

		}else{
			a-=d;
		}
		i++;
	}
	if(a <= 0){
		cout << "No" << endl;
	}else if (c <= 0){
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 3588
X,Y,A,B,C = map(int, input().split())
P = [int(p) for p in input().split()]
Q = [int(q) for q in input().split()]
R = [int(r) for r in input().split()]

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

import heapq
h1 = []
h2 = []
for i in range(X):
    heapq.heappush(h1, P[i])
for i in range(Y):
    heapq.heappush(h2, Q[i])

for i in range(C):
    if h1[0] < R[i] and h1[0] <= h2[0]:
        heapq.heappop(h1)
        heapq.heappush(h1, R[i])
    elif h2[0] < R[i] and h2[0] <= h1[0]:
        heapq.heappop(h2)
        heapq.heappush(h2, R[i])
    else:
        break
print(sum(h1)+sum(h2))

Measured memory_bytes: 113872
#include<iostream>
#include<map>
using namespace std;
int main(){
	int x;
	map<int,int>rec;
  	for(int i=0;i<5;++i){
  		cin>>x;
  		++rec[x];
	}
	for(int i=1;i<6;++i){
		if(!rec[i])cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 3196
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int C[3][3];
    rep(i,3) rep(j,3) cin >> C[i][j];
    int tate[2],yoko[2];
    rep(i,2) yoko[i]=C[0][i+1]-C[0][i];
    rep(i,2) tate[i]=C[i+1][0]-C[i][0];
    bool ans=true;
    rep(i,3) rep(j,2) if(C[i][j+1]-C[i][j]!=yoko[j]) ans=false;
    rep(i,3) rep(j,2) if (C[j+1][i]-C[j][i]!=tate[j]) ans=false;
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int n=s.length();
    rep(i,n){
        if(s[i]==',')s[i]=' ';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int N,M;
    int total = 0;
    int ans = 0,pna = 0;
    int mm[100000]={0};
    cin >> N >> M;
    
    rep(i,M){
        int p;
        string s;
        cin >> p >> s;
        if(s == "WA"){
            if(mm[p]!=-1){
                mm[p]++;
            }
        }if(s == "AC" && mm[p]>-1){
            ans ++;
            pna += mm[p];
            mm[p] = -1;
        }
    }
    cout << ans << " "<<pna << endl;
    // if(ans){
    //     cout << "Good" << endl; 
    // }else{
    //     cout << "Bad" << endl;
    // }
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int a, b, c, area;
		Scanner scanner = new Scanner(System.in);
		a = scanner.nextInt();
		b = scanner.nextInt();
		c = scanner.nextInt();
		area = a * b / 2;
		System.out.println(area);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int A,B;
	cin>>A>>B;
	if(A > 9 || B > 9)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<A*B<<endl;
	}
}

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

#define scan(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define FASTER std::ios::sync_with_stdio(false)
#define DEBUG(x) cout<<#x<<" = "<<x<<endl

#define pb push_back
#define mk make_pair
#define vp vector<pair<ll,ll> >
#define se second
#define fi first
#define vi vector<ll>
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define fab(i,a,b) for(ll i=a;i<=b;i++)
#define inp(n,a) for(ll i=0;i<n;i++){cin>>a[i];}
#define strToInt(x,z) istringstream y(x);y>>z  //(string,integer)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b / __gcd(a,b);
#define MOD 1000000007
#define pi 3.14159265
using namespace std;
long double a[100010], b[100010],n,p;

int main() 
{
	//FASTER;
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	string ans = "";
	//DEBUG(toupper(s1[0]));
	//ans = toupper(s1[0]) + toupper(s2[0]) + toupper(s3[0]);
	cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) <<endl;
	return 0;
}		

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
struct P{
	long long x,h;
	bool operator <(const P yy) const {
		return x<yy.x;
	}
}a[600005];
long long n,d,A,c[200005],ans=0,to[200005];
signed main(){
	scanf("%lld%lld%lld",&n,&d,&A);
	for(long long i=1;i<=n;i++)scanf("%lld%lld",&a[i].x,&a[i].h);
	sort(a+1,a+n+1);
	for(long long i=1,j=1;i<=n;i++){
		//cout<<i<<endl;
		while(j<=n&&a[j].x<=a[i].x+2*d)j++;
		to[i]=j;
	}
	for(long long i=1;i<=n;i++){
		//cout<<i<<' '<<c[i]<<endl;
		c[i]+=c[i-1];
		a[i].h-=c[i];
		if(a[i].h<=0)continue;
		long long t;
		if(a[i].h%A)t=a[i].h/A*A+A;
		else t=a[i].h;
		ans+=t/A;
		if(to[i]-1>i)c[i+1]+=t,c[to[i]]-=t;
	}
	cout<<ans;
}


Measured memory_bytes: 8448
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <bitset>
#include <functional>
#include <tuple>
#include <complex>
#include <chrono>
#include <climits>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned int uint;
typedef unsigned long long ull;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
// default_random_engine generator;
// mt19937 rnd(1);

const int MAXN = 555;

ll a[MAXN][MAXN];
ll dp[MAXN][MAXN];

ll u[MAXN][MAXN];
ll v[MAXN][MAXN];

ll f[MAXN][MAXN];

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    ll sum = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i == j) {
                continue;
            }
            cin >> a[i][j];
            sum += a[i][j];
        }
    }

    for (int i = n - 1; i >= 0; --i) {
        for (int j = i; j < n - 1; ++j) {
            u[j][i] = u[j][i + 1];
        }

        for (int j = i + 1; j < n; ++j) { 
            for (int k = i; k < j; ++k) {
                u[k][i] += a[i][j];
            }
        }
    }

    for (int i = n - 1; i >= 0; --i) {
        for (int j = i + 1; j < n; ++j) {
            v[i][j] = v[i + 1][j];
        }
        ll x = 0;
        for (int j = i + 1; j < n; ++j) {
            x += a[j][i];
            v[i][j] += x;
        }
    }

    for (int i = n - 1; i >= 0; --i) {
        for (int j = n - 1; j >= i; --j)  {
            dp[i][j] = max(dp[i][j], dp[i][j + 1] + v[i][j + 1] - v[i][j]);
            for (int k = j + 1; k < n; ++k) {
                dp[i][j] = max(dp[i][j], dp[j + 1][k] + v[i][k] - v[i][j] + u[j][i]);
            }
        }
    }

    cout << sum - dp[0][0] << endl;


}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
int main() {
  string S,T;
  cin >> S;
  cin >> T;
  int diff_size = S.size() - T.size();
  if(diff_size < 0) cout << "UNRESTORABLE" << endl;
  else{
    int start_point = S.size()-1,point = S.size()-1,now = T.size()-1;
    while(now >= 0 && point >= 0){
      if(S[point] == T[now] || S[point] == '?'){
        --now;
        --point;
      }
      else{
        now = T.size()-1;
        --start_point;
        point = start_point;
      }
    }
    if(now >= 0) cout << "UNRESTORABLE" << endl;
    else{
      string temp = "";
      for(int i = S.size()-1; i > start_point;--i){
        if(S[i] == '?') temp = 'a' + temp; 
        else temp = S[i] + temp;
      } 
      temp = T + temp;
      for(int i = start_point - T.size(); i >= 0; --i){
        if(S[i] == '?') temp = 'a' + temp; 
        else temp = S[i] + temp;
      }
      cout << temp << endl;
    }
  }
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define pii pair<int,int>
#define vp vector<pair<int,int > >
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define gsz(x) ((int)(x).size())
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

int main()
{
	fastio;
	ll n,m,i,res=0;
	cin>>n>>m;
	
	res+= (n)*(n-1)/2;
	res+= (m)*(m-1)/2;
	cout<<res<<endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include "algorithm"
#include "bits/stdc++.h"
using namespace std ;
long long n;
long long a[200050];
long long m;
int main(){
    cin>>n;
    for(int i=0;i<n;i++) {
        cin >> a[i];
        m ^= a[i];
    }
    m^=a[0];
    cout<<m<<" ";
    for(int i=1;i<n;i++){
        m^=a[i-1];
        m^=a[i];
        cout<<m<<" ";

    }
    return 0;
}

Measured memory_bytes: 5088
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int n;
    string str;
    cin>>n>>str;
    if(str.length() <= n)
        cout<<str;
    else
        cout<<str.substr(0, n)<<"...";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3644
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
bool sortbysecdesc(const pair<string,ll> &a,const pair<string,ll> &b)
{
       return a.second>b.second;
}
int main() {
	int n,num=1,z=10;cin>>n;
	ll cnt=0;
	loop(n+1,i,1){
		if(i==z)num++,z*=10;
		if(num%2)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long[] ab = {sc.nextInt(),sc.nextInt()};
		long[] cd = {sc.nextInt(),sc.nextInt()};
		long ans = -Long.MAX_VALUE;
		for(long x : ab)
			for(long y : cd)
				ans = Math.max(ans, x * y);
		System.out.println(ans);
	}

}


Measured memory_bytes: 35652
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

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


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

    int max = 0;
    int a;
    for (int i = 0; i < N; ++i) {
        std::cin >> a;
        if (i == 0) {
            max = a;
        } else {
            max = gcd(max, a);
        }
    }

    std::cout << max << std::endl;

    return 0;
}

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

const int M = 3e3;
int n, m, mat[M][M];
long long memo[M][M][4];

long long solve(int i, int j, int cnt) {
    if (i == n || j == m)
        return 0;
    long long &r = memo[i][j][cnt];
    if (r == -1) {
        r = max(solve(i + 1, j, 0), solve(i, j + 1, cnt));
        if (cnt < 3 && mat[i][j])
            r = max(r, mat[i][j] + max(solve(i + 1, j, 0), solve(i, j + 1, cnt + 1)));
    }
    return r;
}

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

    memset(memo, -1, sizeof memo);
    int k;
    cin >> n >> m >> k;
    while (k--) {
        int i, j, x;
        cin >> i >> j >> x;
        mat[i - 1][j - 1] = x;
    }
    cout << solve(0, 0, 0) << '\n';
}

Measured memory_bytes: 320444
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<list>
#include<algorithm>
 
#define NMAX 2000000+10
using namespace std;
  
 
  
int main(void){
    
    std::ios_base::sync_with_stdio(false);

    int n;
    string inp;
    int x;
    list<int> data;
    list<int>::iterator iter;
 
    cin>>n;
  
    for(int i=0;i<n;i++){
        cin>>inp;
  
        if(inp=="deleteFirst"){
            data.pop_front();
        }
        else if(inp=="deleteLast"){
            data.pop_back();
        }
        else{
            cin>>x;
  
            if(inp=="insert"){
                data.push_front(x);
            }
            else if(inp=="delete"){
                if(find(data.begin(),data.end(),x)!=data.end()) data.erase(find(data.begin(),data.end(),x));
            }
        }
    }
  
    iter=data.begin();
    while(iter!=data.end()){
        if(iter!=data.begin()) cout<<" ";
        cout<<*iter;
        iter++;
    }
    cout<<endl;
 
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> vec(N);
  for(int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  int sum = 0;
  for(int i = 0; i < N; i++) {
    sum += vec.at(i);
  }
  
  int x;
  if(sum % (4 * M) == 0)
    x = sum / (4 * M);
  else
    x = sum / (4 * M) + 1;
  int y = 0;
  
  for(int i = 0; i < N; i++) {
    if(vec.at(i) >= x)
      y++;
  }
  
  if(y >= M)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

const int N = 1e5 + 5;
vector<pair<int, int> > g[N];
int col[N];

void dfs(int node, int par, int wt){
  
   col[node] = wt % 2;
   for(auto c : g[node]){
      if(c.second == par)
         continue;
      dfs(c.second, node, wt + c.first);
   }
}

int32_t main() 
{
  
  ios::sync_with_stdio(0); 
  cin.tie(0); cout.tie(0);
 
  int n;
  cin >> n;
  
  for(int i = 1; i < n; i++){
      int u, v, w;
      cin >> u >> v >> w;
      g[u].push_back({w, v});
      g[v].push_back({w, u});
  }

  dfs(1, 0, 0);

  for(int i = 1; i <= n; i++)
     cout << col[i] << '\n';

  return 0;
}

Measured memory_bytes: 13392
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A;
  B = N % 500;
  if(A > B){
    cout << "Yes" <<endl;
  }
  else if( A == B ){
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto & in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int N, A, B, C, D;
std::string S;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> A >> B >> C >> D; --A; --B; --C; --D;
	in >> S;
	S.push_back('#');
	S.push_back('#');
	S.push_back('#');
	N += 3;

	int a_l = N, a_r = 0;
	int b_l = N, b_r = 0;
	int now_l = -1;
	bool flag_a = false;
	bool flag_b = false;
	for (int i = 0; i < N-1; i++)
	{
		if (now_l == -1 && S[i] != '#') {
			now_l = i;
		}
		if (i == A) {
			a_l = i;
			flag_a = true;
		}
		if (i == B) {
			b_l = i;
			flag_b = true;
		}
		if (S[i] == '#' && S[i + 1] == '#') {
			if (flag_a) {
				a_r = i;
				flag_a = false;
			}
			if (flag_b) {
				b_r = i;
				flag_b = false;
			}

			now_l = i + 2;
		}
	}

	if ((!(a_l <= C && C < a_r)) ||
		!(b_l <= D && D < b_r)) {
		out << "No" << endl;
		return 0;
	}

	if (D < C) {
		bool ok = false;
		for (int i = B; i <= D; i++)
		{
			if (S[i - 1] == '.' && S[i] == '.' && S[i+1] == '.') {
				ok = true;
				break;
			}
		}
		if (!ok) {
			out << "No" << endl;
			return 0;
		}
	}


	out << "Yes" << endl;
	return 0;
}
#endif


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()


ll H, W, bl = 0, s[60][60], v1[4] = { 0,0,1,-1 }, v2[4] = { 1,-1,0,0 };
char in[60][60];
int main() {
	REP(i, 60)REP(j, 60) s[i][j] = INF;
	s[1][1] = 1;
	cin >> H >> W;
	REPO(i, H) {
		REPO(j, W) {
			cin >> in[i][j];
			if (in[i][j] == '#')bl++;
		}
	}
	REP(k, 3000) {
		REPO(i, H) {
			REPO(j, W) {
				if (in[i][j] == '.') {
					REP(l, 4) {
						if(in[i + v1[l]][j + v2[l]] == '.') s[i + v1[l]][j + v2[l]] = min(s[i + v1[l]][j + v2[l]], s[i][j] + 1);
					}
				}
			}
		}
	}
	if (s[H][W] == INF)cout << -1 << endl;
	else cout << H * W - bl - s[H][W] << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = (ll)1e9 + 7;

int main() {
	int H, W; cin >> H >> W;
	vector<string> grid(H);
	vector<vector<ll>> ways(H);
	for (auto &x : grid) { cin >> x; }
	for (auto &x : ways) { x.resize(W); }
	ways[0][0] = 0;
	for (int j = 1; j < W; j++) {
		if (grid[0][j] == '#') { break; }
		ways[0][j] = 1;
	}
	for (int i = 1; i < H; i++) {
		if (grid[i][0] == '#') { break; }
		ways[i][0] = 1;
	}

	for (int i = 1; i < H; i++) {
		for (int j = 1; j < W; j++) {
			if (grid[i][j] == '#') { continue; }
			ways[i][j] = ways[i - 1][j] + ways[i][j - 1];
			ways[i][j] %= mod;
		}
	}

	cout << ways[H - 1][W - 1] << endl;
}

Measured memory_bytes: 9216
/*
????°??????????????£? = ??????????????????
while(?????? == false){
    ????°??????????????£?++;
}

?????????:1 2 3 4 5 6 
???  ???:X X X O O O
X???1???????????????O???????°??????????

????°????O??¨?????§???X?????????????????????
??????????????????????????°??????
*/
//--- --- --- debug function --- --- ---
// #define DEBUG // switch this macro
#ifdef DEBUG
#include <cstdio>
typedef int (*printf_t)(const char* format, ...);
printf_t printfd = std::printf;
#else
int printfd(const char* format, ...){return 0;}
#endif
//--- --- --- debug function --- --- ---
#include <cassert>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

bool Check(const std::vector<int> Wi, int k, int P)
{
    int p = 0;
    --k;
    for(int i = 0; i < Wi.size(); ++i){
        if(P - p >= Wi[i]){
            p += Wi[i];
        }else{
            p = Wi[i];
            --k;
        }
    }
    return k >= 0;
}
int main()
{
    int n,k;
    std::cin >> n >> k;
    std::vector<int> Wi(n);
    for(int i = 0; i < n; ++i){
        std::cin >> Wi[i];
    }

    int MaxValue = *std::max_element(Wi.begin(), Wi.end());
    int MaxBad  = std::accumulate(Wi.begin(), Wi.end(), 0) / k - 1;
    int MinGood = std::ceil(((double)n / k)) * MaxValue;
    int P = (MaxBad + MinGood) / 2;
    printfd("Max:%d, Min:%d, P:%d\n", MaxBad, MinGood, P);
    while(MaxBad + 1 != MinGood){
        if(MaxValue <= P && Check(Wi, k, P)){
            MinGood = P;
        }else{
            MaxBad = P;
        }
        P = (MaxBad + MinGood) / 2;
        printfd("Max:%d, Min:%d, P:%d\n", MaxBad, MinGood, P);
    }
    std::cout << MinGood << std::endl;
    return 0;
}

Measured memory_bytes: 1796
# coding: utf-8
N = int(input())
A = {}
AA = []
for i in range(N):
    a = int(input())
    if a not in A.keys():
        A[a] = 1
    else:
        A[a] += 1
    AA.append(a)
key = list(A.keys())
key.sort(reverse=True)
ans = []
for i in range(N):
    if AA[i] != key[0]:
        print(key[0])
    else:
        if A[key[0]] < 2:
            print(key[1])
        else:
            print(key[0])

Measured memory_bytes: 19588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
 
using namespace std;
 
typedef long long ll;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int n;
	cin >> n;
 
	vector<int> v(n);
	rep(i, n) cin >> v[i];
 
	sort(v.begin(), v.end());
 
	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			int l = v[i] + v[j];
 
			auto itr = lower_bound(v.begin(), v.end(), l);
			int num = distance(v.begin(), itr) - j - 1;
 
			// cout << i << "," << j << "," << l << "," << num << endl;
			ans += num;
		}
	}
 
	cout << ans << endl;
}

Measured memory_bytes: 256