akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
string T;
ll k;
ll r, s, p;
ll q;
char zya(char u)
{
    char c;
    if (u == 'r')
    {
        c = 'p';
    }
    if (u == 's')
    {
        c = 'r';
    }
    if (u == 'p')
    {
        c = 's';
    }
    return c;
}
int ten(char u)
{
    if (u == 'r')
    {
        return r;
    }
    if (u == 's')
    {
        return s;
    }
    else
    {
        return p;
    }
}
int memo[100005];
char mozi[10005];
int done[100005];

ll dp(int n) //dpは答えを返す。そして、別の配列で何を入れたかを整理していく。今回だと、n=0を今使おうとしている、返すのは最大値
{
    //
    //とりあえず、前の値を代入しましょう。
    if (n == -1)
    {
        return 0;//とりあえず前の値を使う
    }
    if (done[n] != 0)
    {
        return memo[n];
    }
    ll res = dp(n - 1);
    if (n == q)
    {
        return res;
    }
    if (n < k)
    {

        mozi[n] = zya(T[n]);
        res += ten(zya(T[n]));
        done[n] = 1;
        memo[n] = res;
        return res;
    }

    if (zya(T[n]) == mozi[n - k])
    { //T[n]を勝てるように設定した手とT[n-k]に対して取った手が一緒だったら、
        //あいこや負けは0点かよ
        if (mozi[n - k] == zya(T[n - k])) //n-kの手に得点が入っているならば、
        {

            if (ten(zya(T[n])) > ten(mozi[n - k]))
            {

                res += -ten(mozi[n - k]) + ten(zya(T[n])); //ここで、この時に確実に後の方で点数が入っているとは限らない。

                mozi[n] = zya(T[n]);
            }
            else
            {

                mozi[n] = T[n]; //t(n)のまま追加する
            }
        }
        else
        {
            res += ten(zya(T[n])); //この時は一緒だが、向こうの手を変化させることができるので追加しているのと同じ
            mozi[n] = zya(T[n]);
        }
    }
    else
    {
        res += ten(zya(T[n])); //この時は点数が上がるはず。
        mozi[n] = zya(T[n]);
    }
    done[n] = 1;
    memo[n] = res;
    return res;
}
int main()
{

    cin >> q >> k;
    cin >> r >> s >> p;
    cin >> T;
    cout << dp(T.size()) << endl;
}


Measured memory_bytes: 5888
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }

	int root(int x) {//根を出す
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {//同じ集合なのかを調べる
		return root(x) == root(y);
	}

	bool unite(int x, int y) {//xの根とyの根をつなげる
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	lint size(lint x) {
		return -par[root(x)];
	}
};

int main(void) {
	lint n; cin >> n;
	UnionFind d(n);
	lint m; cin >> m;
	for (int i = 0; i < m; i++) {
		lint x, y; cin >> x >> y;
		x--; y--;
		d.unite(x, y);
	}
	lint ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, d.size(i));
	}
	cout << ans << endl;

}

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

int main() {
	
	int N, M, L, R;
	int	max = 0, min = 100001;
	
	cin >> N >> M;
	
	for(int i = 0; i < M; i++){
		cin >> L >> R;
		
		if(max < L){
			max = L;
		}
		if(min > R){
			min = R;
		}
	}

	int ans = min - max + 1;
	
	if(ans > 0){
		cout << ans << endl;
	}
	else{
		cout << "0" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
N, X = map(int, input().split())
q = [1]*(N+1)
p = [1]*(N+1)
for i in range(1, N+1):
    q[i] = 2*q[i-1]+3
    p[i] = 2*p[i-1]+1

ans = 0
s = [(X, N)]
while s:
    x, n = s.pop()
    if n==0:
        if x:
            ans += 1
    if x:
        a = q[n-1] + 2
        b = p[n-1] + 1

        if x > a:
            ans += b
            s += [(x-a, n-1)]
        elif x == a:
            ans += b
        else:
            s += [(x-1, n-1)]

print(ans)

Measured memory_bytes: 3064
import numpy as np
import sys
input = sys.stdin.readline
[N,K]=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]
h=np.array(h)
dp=np.zeros(N,dtype=int)
 
for i in range(1,N):
  last=min(K,i)+N-i
  dp[N-i-1]=min(dp[N-i:last]+np.abs(h[N-i:last]-h[N-i-1]))
print(dp[0])

Measured memory_bytes: 38216
#include<iostream>
#include<iomanip>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,P> L;

class Q{
  ll u,d;
public:
  Q(ll a=0, ll b=1):u(a), d(b){}
  bool operator<(Q a){
    if(u/d != a.u/a.d) return u/d < a.u/a.d;
    ll uu = u%d, au = a.u%a.d;
    return uu*a.d < au*d;
  }
};

inline ll dot(P a, P b){
  return a.first*b.first + a.second*b.second;
}

inline ll cross(P a, P b){
  return a.first * b.second - a.second * b.first;
}

inline ll dis_p(P a, P b){
  ll dx = a.first-b.first, dy = a.second-b.second;
  return dx*dx+dy*dy;
}

inline Q dis_s(L l, P a){
  P vaf = P(a.first - l.first.first, a.second - l.first.second);
  P vbf = P(l.second.first - l.first.first, l.second.second - l.first.second);
  if(dot(vaf, vbf) < 0) return dis_p(a, l.first);

  P vas = P(a.first - l.second.first, a.second - l.second.second);
  P vbs = P(l.first.first - l.second.first, l.first.second - l.second.second);
  if(dot(vas, vbs) < 0) return dis_p(a, l.second);

  ll c = cross(vaf, vbf);
  Q res = Q( c*c, dis_p(l.first, l.second) );
  return res;
}

int main(){
  int n,m;
  cin >> n >> m;
  n++;

  vector<P> p(n);

  vector<Q> d_s(n);
  vector<int> d_p(n);
  for(int i=0;i<n;i++){
    cin >> p[i].first >> p[i].second;
    d_s[i] = dis_p(p[0], p[i]);
    d_p[i] = 0;
  }
  d_p[0] = -1;

  long double ans = 0;
  for(int k=1;k<=m;k++){
    //find closest feed
    int id = -1;
    for(int i=0;i<n;i++){
      if(d_p[i]<0)continue;
      if(id < 0 || d_s[i]<d_s[id]) id = i;
    }

    //update ans
    L seg = L(p[id], p[d_p[id]]);
    ll pdis = dis_p(p[id], p[d_p[id]]);
    d_p[id] = -1;
    ans += sqrt(pdis);

    //update distance
    for(int i=0;i<n;i++){
      if(d_p[i]<0)continue;
      
      Q sdis = dis_s(seg, p[i]);
      if(sdis < d_s[i]) d_s[i] = sdis;

      if(dis_p(p[id], p[i]) < dis_p(p[d_p[i]], p[i])) d_p[i] = id;
      else if(dis_p(p[id], p[i]) == dis_p(p[d_p[i]], p[i])) d_p[i] = min(d_p[i], id);
    }
  }

  cout << fixed << setprecision(9) << ans << endl;
}
    

Measured memory_bytes: 3404
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *x, const void *y) { return *(int *)y - *(int *)x; }
int main() {
	int n, h, a, aMax = 0, b[100000], ans = 0;
	scanf("%d%d", &n, &h);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		if (a > aMax) {
			aMax = a;
		}
		scanf("%d", &b[i]);
	}
	qsort(b, n, sizeof(int), cmpint);
	for (int i = 0; i < n; i++) {
		if (b[i] > aMax) {
			h -= b[i];
			ans++;
		} else {
			break;
		}
		if (h <= 0) break;
	}
	if (h > 0) {
		ans += h / aMax;
		if (h % aMax != 0) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 892
h, w = map(int, input().split())

t=".."
for _ in range(w):
  t += "."

s=[]
s.append(t)
for i in range(h):
  s.append("." + input() + ".")
s.append(t)
f=True
for i in range(1,h+1):
  for j in range(1,w+1):
    if s[i][j] == "#":
      if s[i-1][j] != "#" and \
        s[i+1][j] != "#" and \
        s[i][j-1] != "#" and \
        s[i][j+1] != "#" :
          f=False
if f:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	m := readInt()
	G := make([][]Edge, n)
	for i := 0; i < m; i++ {
		a := readInt() - 1
		b := readInt() - 1
		G[a] = append(G[a], Edge{b, 1})
		G[b] = append(G[b], Edge{a, 1})
	}

	cost, _ := Dijkstra(G, 0, false)
	if cost[n-1] == 2 {
		println("POSSIBLE")
	} else {
		println("IMPOSSIBLE")
	}

}

// -----------------------------------------------------------------------------

type Edge struct {
	to, cost int
}

type DijkstraPriorityQueue []Edge

func (pq DijkstraPriorityQueue) Len() int {
	return len(pq)
}

func (pq DijkstraPriorityQueue) Less(i, j int) bool {
	return pq[i].cost < pq[j].cost
}

func (pq DijkstraPriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *DijkstraPriorityQueue) Push(x interface{}) {
	old := *pq
	*pq = append(old, x.(Edge))
}

func (pq *DijkstraPriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old) - 1
	x := old[n]
	*pq = old[:n]
	return x
}

func Dijkstra(G [][]Edge, start int, needPrev bool) ([]int, []int) {

	pq := new(DijkstraPriorityQueue)
	push := func(to, cost int) {
		heap.Push(pq, Edge{to, cost})
	}
	pop := func() (int, int) {
		x := heap.Pop(pq).(Edge)
		return x.to, x.cost
	}
	empty := func() bool {
		return pq.Len() == 0
	}

	N := len(G)
	costs := make([]int, N)
	for i := range costs {
		costs[i] = math.MaxInt32
	}
	costs[start] = 0

	var prev []int
	if needPrev {
		prev = make([]int, N)
		for i := range prev {
			prev[i] = -1
		}
		prev[start] = start
	}

	push(start, 0)

	for !empty() {
		v, d := pop()
		if costs[v] < d {
			continue
		}
		for _, e := range G[v] {
			u, nd := e.to, e.cost+costs[v]
			if costs[u] < nd {
				continue
			}
			costs[u] = nd
			if needPrev {
				prev[u] = v
			}
			push(u, nd)
		}
	}

	return costs, prev
}


Measured memory_bytes: 27264
n,*s=map(int,open(0).read().split());s,t,f,g=[s[i*n:i*n+n]for i in range(4)];r=range(n);a=[n*[0]for _ in r];e=enumerate
for b in range(64):
 y=1<<b;u=[k&y for k in f];v=[k&y for k in g];l=[0]*n;m=l[:]
 for i in r:
  for j in r:
   if(u[i]&v[j])|((s[i]^1)*u[i])|((t[j]^1)*v[j]):a[i][j]|=y;l[i]+=1;m[j]+=1
 for i in r:
  if(l[i]==0)*s[i]*u[i]:
   for j in r:
    if(t[j]^1)*(n-m[j]>1):a[i][j]|=y;m[j]+=1;break
  if(m[i]==0)*t[i]*v[i]:
   for j in r:
    if(s[j]^1)*(n-l[j]>1):a[j][i]|=y;l[j]+=1;break
h=a[0][:];w=[i[0]for i in a]
for i,k in e(a):
 for j,l in e(k):w[i]=(l|w[i]if s[i]else w[i]&l);h[j]=(l|h[j]if t[j]else h[j]&l)
if(g!=h)|(f!=w):print(-1);exit() 
for i in a:print(*i)

Measured memory_bytes: 99212
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

ll dif(ll a, ll b, ll k) {

	if (a < b) return b -a;

	return k - a + b;
}
void testcase() {
    ll k, n;
    cin >> k >> n;

    vector<ll> v(2*n);
    rep (i, 0, n-1)  { 
    	cin >> v[i];
    	v[n+i] = v[i];
    }

    ll ans = 0;
    ll res = INT_MAX;

    rep (i, 0, n-2) {
    	ans += dif(v[i], v[i+1], k);
    }

   // db1(ans);
    int cur = 0;
    rep (i, n-1, 2*n-2) {
    	ans -= dif(v[cur], v[cur+1], k);
    	ans += dif(v[i], v[i+1], k);
    	cur++;
    	if (ans < res) res=  ans;
    	//db3(i, ans, res);
    }

    cout << res;

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c; cin >> a >> b >> c;
	if (a & 1 || b & 1 || c & 1) {
		cout << 0 << endl;
		return 0;
	}
	set<tuple<int, int, int>>s;
	int ans(0);
	while (1) {
		s.insert(make_tuple(a, b, c));
		ans++;

		int x = b / 2 + c / 2;
		int y = a / 2 + c / 2;
		int z = a / 2 + b / 2;

		if (x & 1 || y & 1 || z & 1)break;

		a = x;
		b = y;
		c = z;

		if (s.find(make_tuple(a, b, c)) != s.end()) {
			ans = 0;
			break;
		}

	}
	cout << (ans == 0 ? -1 : ans) << endl;
	return 0;
}

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

// B - 1%
int main() {
    long long X;
    cin >> X;

    long long result = 100;
    long long year = 0;
    for (year; ; year++) {
        if (result >= X) {
            break;
        }
        result *= 1.01;
    }

    cout << year;
}


Measured memory_bytes: 3592
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  long long int x,ans=0;
  scanf("%lld\n",&x);
  ans=x/500*1000;
  x=x%500;
  ans+=(x/5)*5;
  printf("%lld\n",ans);
  return 0;
}

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

int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2 - x1;
  int dy = y2 - y1;
  cout << x2 - dy << ' ' << y2 + dx << ' ' <<
  x1 - dy << ' ' << y1 + dx << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

#define NMAX 100000


using namespace std;

int box[NMAX];
int N,x;

void initialize(){
  cin >> N >> x;
  for(int i = 0; i < N; i++){
    cin >> box[i];
  }
}

void solve(){
  int eat;
  int eat_sum = 0;
  long long eat_quo = 0;

  for(int i = 1; i < N; i++){
    //should eat
    if(box[i - 1] + box[i] > x){
      //how many eat
      eat = box[i - 1] + box[i] - x;
      //processing
      box[i] = (box[i] - eat >= 0) ? (box[i] - eat) : 0;
      eat_sum += eat;

      if(eat_sum >= 1e9){
        eat_quo += eat_sum / int(1e9);
        eat_sum = eat_sum % int(1e9);
      }
    }
  }

  cout << int(1e9) * eat_quo + eat_sum << endl;

  return;

}

int main(void){
  int min;

  initialize();
  solve();

  return 0;
}


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

int main() {
    long long int n, k, total = 0;
    cin >> n >> k;
    for(long long int i = k; i <= n + 1; i++){
        total += i * (n - i + 1) + 1;
    }
    total = total % (1000000000 + 7);
    cout << total << endl;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	for (int i = 0; i < B; i++) {
		if (i * A - i + 1 >= B) {
			cout << i << endl;
			return 0;
		}
	}

}

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

int main() {
	int a[3];
	int cost = 0;
	for (int i = 0; i < 3; i++)
		cin >> a[i];
	sort(a, a+3);
	for (int i = 1; i < 3; i++)
		cost +=  abs(a[i]-a[i-1]);
	cout <<  cost << endl;
}


Measured memory_bytes: 256
import math

def volume(a,b,x):
  if a**2*b//2 <= x:
  	k = 2*(b*a**2-x)/(a**3)
  	print(math.degrees(math.atan(k)))
  else:
    k = a*b**2/(2*x)
    print(math.degrees(math.atan(k)))
    
a,b,x = map(int,input().split())
volume(a,b,x)

Measured memory_bytes: 3060
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int n,a[N];
#define no return puts("No"),0
bool check (int l,int r)
{
	int mi=oo,ma=0,ma1=0;
	for (int i=l; i<=r; i++)
		chkmin (mi,a[i]),chkmax (ma,a[i]);
	if (mi!=l||ma!=r) return 0;
	ma=0;
	for (int i=l; i<=r; i+=2)
	{
		if (ma< a[i]) ma=a[i];
		else if (ma1< a[i]) ma1=a[i];
		else return 0;
	}
	return 1;
}
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n);
	for (int i=1; i<=n; i++)
		sc(a[i]);
	for (int i=1,j; i<=n; i++) if (a[i]!=i)
	{
		j=i;
		while (j<=n-2&&a[j+1]==j+1&&a[j+2]!=j+2) j+=2;
		if (!check (i,j)) no;
		i=j;
	}
	puts("Yes");

    return 0;
}


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

int main() {
string O,E;
cin >> O >> E;

// vector <char> V(O.size()+E.size()-1);
vector <char> V{};
for (int i = 0; i < E.size(); i++)
{
  V.push_back(O[i]);
  V.push_back(E[i]);

}

if (O.size()-E.size() == 1) V.push_back(O[O.size()-1]);

for (char vi :V) cout << vi;
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>

using namespace std;



int main(int argc, char *argv[])
{
	int n;
	int a, b, c;
	vector<int> l;


	//input
	cin >> n >> a >> b >> c;

	for (int i = 0; i < n; i++){
		int li;

		cin >> li;
		l.push_back(li);
	}






	//calc
	//keta a=1, b=2, c=3, no using=0
	vector<int> ans;
	for (int bunrui = 0; bunrui < pow(4 ,n); bunrui++){
		int length[4] = { 0, 0, 0, 0 };//a,b,c,no using
		int mp = 0;
		
		int tmp = bunrui;
		for (int i = 0; i < n; i++){
			int keta = tmp % 4;
			tmp /= 4;

			if (keta == 0){
				;//nothing
			}
			else{
				if (length[keta] == 0){
					length[keta] += l[i];
				}
				else{
					length[keta] += l[i];
					mp += 10;
				}
			}

		}

		if (length[1] == 0 || length[2] == 0 || length[3] == 0){
			continue;
		}

		//calc mp
		mp += abs(a - length[1]);
		mp += abs(b - length[2]);
		mp += abs(c - length[3]);

		ans.push_back(mp);
	}

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

	//ans
	cout << ans[0] << endl;


	return 0;
}


Measured memory_bytes: 768
import sys
input = sys.stdin.readline

import bisect

def main():
    n = int(input())
    s = []

    for i in range(n):
        a = int(input())
        i = bisect.bisect_left(s, a)
        if len(s) > i and s[i] == a:
            s.remove(a)
        else:
            s.insert(i, a)


    print(len(s))


main()


Measured memory_bytes: 46812
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			if (s[j] == 'c') {
				cout << 0;
			}
			else {
				bool b = true;
				for (int k = 1; k <= j; k++) {
					if (s[j - k] == 'c') {
						cout << k;
						b = false;
						break;
					}
				}
				if (b == true) {
					cout << -1;
				}
			}
			if (j != w - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}
}



Measured memory_bytes: 3184
s = raw_input()
sentence = s.split(" ")
stack = []

for factor in sentence:
	if factor == "+":
		b = stack.pop()
		a = stack.pop()
		c = a + b
		stack.append(c)
	elif factor == "-":
		b = stack.pop()
		a = stack.pop()
		c = a - b
		stack.append(c)
	elif factor == "*":
		b = stack.pop()
		a = stack.pop()
		c = a * b
		stack.append(c)
	else:
		stack.append(int(factor))
print stack[0]

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

int main(){
  int N, X;
  cin >> N >> X;
  int s = 0;
  int a = 1000;
  for (int i = 0; i < N; i++){
    int m;
    cin >> m;
    s += m;
    a = min(a,m);
  }
  cout << N + (X - s) / a << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;
 
int main(){
    int N;
    cin >> N;
 
    int sum = 0;
    unordered_map<int, int> data;
    for(int i = 0; i < N; ++i){
        int a;
        cin >> a;
        data[a]++;
        sum++;
        if(data[a] == a){
            sum -= a;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 4260
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%lld", name[i][j]); \
    }\
    printf("\n");\
  }\

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

static const int MAX = 1000005;
static const int MOD = 1000000007;

ll ans;
ll N, K;
ll A[MAX];

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

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

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

int main(void) {
    scanf("%lld %lld", &N, &K);
    for(ll i=0; i<N; i++) scanf("%lld", &A[i]);
    
    sort(A, A+N);
    comb_init();
    
    ll s = 0, t = 0;
    
    for(ll i=0; i<N; i++) {
      ll n1 = N-i-1, n2 = i;
      s += (A[i]*combination(n1, K-1))%MOD;
      t += (A[i]*combination(n2, K-1))%MOD;
      s %= MOD;
      t %= MOD;
    }
    
    ans = (t-s)%MOD;
    if (ans<0) ans += MOD;
 
    printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 24832
#include<stdio.h>
int main()
{
    int i;
    char a=',',s[19];
    gets(s);
    for(i=0;s[i]!='\0';i++)
    {
        if(s[i]==',')
            s[i]=' ';
    }
    printf("%s\n",s);
    return 0;
}


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

int main()
{
	int n,m,xx;
	cin>>n>>m>>xx;
	int arr[n][m];
	int cost[n];
	int i,j,k,l;
	for(i=0;i<n;i++)
	{
	cin>>cost[i];
	for(j=0;j<m;j++)
	cin>>arr[i][j];
    }
	int ans=INT_MAX;
	int kk=-1;
	int mask;
	for(mask=0;mask<(1<<n);mask++)
	{   int bb[m]={0};
	int cc=0;
		for(i=0;i<n;i++)
		{
			if(mask&(1<<i))
			{   cc+=cost[i];
				int x;
				for(x=0;x<m;x++)
				bb[x]+=arr[i][x];
			}
		}
		int tt=1;
    for(i=0;i<m;i++)
    {
    	if(bb[i]<xx)
    	{
    		tt=0;
    		break;
		}
	}
	if(tt)
	{
		ans=min(ans,cc);
		kk=1;
	}
}
if(kk==1)
cout<<ans;
else cout<<-1;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>

#define int ll
//#define double long double
//#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.14159265358979

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 7e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/

template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}

template <class T>
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}

template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}

inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
}

struct node
{
    int val;
    int vl, vr;
    node *l = 0, *r = 0;
    node() {}
    node(int tl, int tr, vector <int> &a)
    {
        vl = tl, vr = tr;
        if (vr - vl == 1)
        {
            val = a[vl];
            return;
        }
        int vm = (vl + vr) >> 1;
        l = new node(vl, vm, a), r = new node(vm, vr, a);
        val = min(l->val, r->val);
    }
    int get(int ql, int qr)
    {
        if (vl == ql && vr == qr)
            return val;
        int vm = (vl + vr) >> 1;
        if (qr <= vm)
            return l->get(ql, qr);
        if (ql >= vm)
            return r->get(ql, qr);
        return min(l->get(ql, vm), r->get(vm, qr));
    }
    void change(int pos, int x)
    {
        if (vr - vl == 1)
        {
            val = x;
            return;
        }
        int vm = (vl + vr) >> 1;
        if (pos < vm)
            l->change(pos, x);
        else
            r->change(pos, x);
        val = min(l->val, r->val);
    }
};

signed main()
{
    Start();
    int n, m;
    cin >> n >> m;
#define x first
#define y second
    vector <pair <pii, int>> a(m);
    for (int i = 0; i < m; ++i)
    {
        int l, r, c;
        cin >> l >> r >> c, --l, --r;
        a[i].x.x = r;
        a[i].x.y = l;
        a[i].y = c;
    }
    sort(all(a));
    const int INF = 1e18;
    vector <int> d(n, INF);
    d[0] = 0;
    node *t = new node(0, n, d);
    for (auto rlc : a)
    {
        int r = rlc.x.x, l = rlc.x.y, c = rlc.y;
        int val = t->get(l, r + 1);
        val += c;
        if (d[r] > val)
            d[r] = val, t->change(r, val);
    }
    if (d[n - 1] == INF)
        cout << -1;
    else
        cout << d[n - 1];
    return 0;
}



Measured memory_bytes: 12544
#include<bits/stdc++.h>
#include<algorithm>
#include<map>
#include<cmath>
#define int long long
#include<string>
#include <vector>


using namespace std;
signed main()
{

	string s,t;
	cin>>s>>t;
	int n = s.length();
	int m = t.length();
	
		int mn= INT_MAX;
		for(int i=0;i<n-m+1;i++)
		{
			int cnt=0;
			for(int j=0;j<m;j++)
			{
				if(s[i+j]!=t[j])
				cnt++;
				
			}
			mn = min(mn,cnt);
		}
		cout<<mn<<endl;
	
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
    int x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
    return x*f;
}
inline ll readll(){
    ll x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
    return x*f;
}
const int maxn=1e5+10;
int mp1[maxn],mp2[maxn];
int main(){
	int n=read();
	REP(i,1,n){
		int x=read();
		if(i&1) mp1[x]++;
		else mp2[x]++;
	}
	int Max1=0,Max2=0,Sec1=0,Sec2=0;
	REP(i,1,1e5){
		if(mp1[Max1]<mp1[i]) Sec1=mp1[Max1],Max1=i;
		else chkmax(Sec1,mp1[i]);
		if(mp2[Max2]<mp2[i]) Sec2=mp2[Max2],Max2=i;
		else chkmax(Sec2,mp2[i]);
	}
	if(Max1!=Max2) printf("%d\n",n-mp1[Max1]-mp2[Max2]);
	else printf("%d\n",n-max(mp1[Max1]+Sec2,mp2[Max2]+Sec1));
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int top, stack[100]; 

void push(int x){
    stack[++top] = x;
}

int pop(){
    top--;
    return stack[top+1];
}

int main(){
    int x, a, b;
    top = 0;
    char s[100];
    while (scanf("%s",s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        } else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        } else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        } else {
            x = atoi(s);
            push(x);
        }
    }
    printf("%d\n",pop());
    
    return 0;
}



Measured memory_bytes: 2104
// https://atcoder.jp/contests/abc063/tasks/arc075_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, A, B;
  cin >> N >> A >> B;

  VL hs(N);
  rep(i, N) cin >> hs[i];

  sort(all(hs));

  ll res_max = 0;
  rep(i, N) { res_max += (hs[i] + A - 1) / A; }

  ll ng = 0;
  ll ok = res_max;

  auto is_ok = [&](ll ct) -> bool {
    ll rest_i = upper_bound(all(hs), ct * B) - hs.begin();

    ll can = ct;
    ll diff = A - B;

    while (rest_i < N) {
      ll rest = hs[rest_i] - ct * B;

      can -= (rest + diff - 1) / diff;

      if (can < 0) return false;
      rest_i++;
    }

    return true;
  };

  while (ok - ng > 1) {
    ll mid = (ok + ng) / 2;

    if (is_ok(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << ok << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1024
#include <cstring>
#include <algorithm>
#include <cstdio>
#define int long long
#define ri register int
#define N 100005
using namespace std;
int n,m,v,p,t=0,ans,a[N]= {0};
template <typename T> inline void read(T &x) {
    T c=getchar(),f=0;
    for (; c<48||57<c; c=getchar()) if (c=='-') f=1;
    for (x=0; 48<=c&&c<=57; c=getchar()) x=(x<<3)+(x<<1)+(c^48);
    if (f) x=-x;
}
template <typename T> inline void print(T x) {
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
signed main() {
	read(n),read(m),read(v),read(p),ans=p;
	for (ri i=1; i<=n; i++) read(a[i]);
	sort(a+1,a+1+n),reverse(a+1,a+1+n);
	for (ri i=p+1; i<=n; i++) {
		if (a[i]+m<a[p]) break;
		if (v<=(p-1)+(n-i+1)) ans++;
		else if ((v-p-n+i)*m<=t) ans++;
		else if (((v-p-n+i)*m-t-1)/(i-p)+1+a[p]<=a[i]+m) ans++;
		t+=a[p]-a[i];
	}
	print(ans),putchar('\n');
    return 0;
}

Measured memory_bytes: 2316
#-swank
(unless (member :child-sbcl *features*)
  (quit
    :unix-status
    (process-exit-code
      (run-program *runtime-pathname*
                   `("--control-stack-size" "128MB"
                     "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                     "--eval" "(push :child-sbcl *features*)"
                     "--script" ,(namestring *load-pathname*))
                   :output t :error t :input t))))


(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(defparameter *factorial-dp* (make-array 400001 :initial-element nil))
(defparameter *factorial-inv-dp* (make-array 400001 :initial-element nil))

(defparameter *mod* (+ (expt 10 9) 7))

(defun factorial (x)
  (if (<= x 1) 1
    (if (aref *factorial-dp* x)
      (aref *factorial-dp* x)
      (setf (aref *factorial-dp* x) (mod* x (factorial (1- x)))))))

(defun mod+ (&rest body)
  (reduce (lambda (a b) (mod (+ a b) *mod*)) body))
(defun mod- (&rest body)
  (reduce (lambda (a b) (mod (- a b) *mod*)) body))
(defun mod* (&rest body)
  (reduce (lambda (a b) (mod (* a b) *mod*)) body))
(defun modpow (x y)
  (if (zerop y) 1
    (mod* (if (oddp y) x 1)
          (modpow (mod* x x) (ash y -1)))))

(defun factorial-inv (x)
  (let ((res (aref *factorial-inv-dp* x)))
    (if res
      res
      (setf (aref *factorial-inv-dp* x) (modinv (factorial x))))))


(defun modinv (x)
  (modpow x (- *mod* 2)))

(defun mod/ (&rest body)
  (reduce (lambda (a b) (mod* a (modinv b))) body))

(defun combination (a b)
  (mod* (factorial a) (factorial-inv b) (factorial-inv (- a b))))


(factorial-inv 400000)
(loop for i downfrom 400000 to 1
      do
      (setf (aref *factorial-inv-dp* (1- i))
            (mod* (aref *factorial-inv-dp* i) i)))

(let* ((n (read))
       (k (read))
       (ans (combination (1- (* n 2)) n)))
  (loop for zeros from (1+ k) below n
        do
        (setf ans (mod- ans 
                        (mod* 
                          (combination n zeros) 
                          (combination (1- n) (- n zeros 1))))))
  (princ ans))




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

#define int long long

using namespace std;

const int N = 200005;
const int mod = 1e9 + 7;

int fact[N], inv_fact[N];

int binPow (int x, int y) {
    int ans = 1;
    while (y) {
        if (y & 1) ans = (ans * x) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }

    return ans;
}

int C (int n, int k) {
    if (k > n) return 0;
    int ans = 1;
    ans *= fact[n]; ans %= mod;
    ans *= inv_fact[k]; ans %= mod;
    ans *= inv_fact[n - k]; ans %= mod;

    return ans;
}

signed main(){
    int n, m, a, b;
    scanf("%lld %lld %lld %lld", &n, &m, &a, &b);

    fact[0] = inv_fact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = (i * fact[i - 1]) % mod;
        inv_fact[i] = binPow(fact[i], mod - 2);
    }

    int ans = 0;
    for (int i = 1; i <= n - a; i++) ans = (ans + C(i + b - 2, i - 1) * C(n - i + m - b - 1, n - i)) % mod;

    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'

//DP法
template <class T>
inline bool chmin(T &a, T b) //change minimum
{
        if (a > b)
        {
                a = b;
                return true;
        }
        return false;
}
template <class T>
inline bool chmax(T &a, T b) //change max
{
        if (a < b)
        {
                a = b;
                return true;
        }
        return false;
}

typedef long long ll; //64bit型

using namespace std;

// const long long INF = 1LL << 60; //無限大の値
int INF = 1000000;

int main()
{
        int N;
        cin >> N;
        vector<pair<int, int>> tasks(N);
        REP(i, N)
        {
                cin >> tasks[i].second >> tasks[i].first;
        }
        sort(tasks.begin(), tasks.end());

        ll ans = 0;
        REP(i, N)
        {
                ans += tasks[i].second;
                if (ans > tasks[i].first)
                {
                        puts("No");
                        return 0;
                }
        }

        puts("Yes");

        return 0;
}


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

int main() {
	string s;
	cin >> s;
	int a = 0, b = 0;
	for(int i = 0; i <= 2; ++i) {
		if(s[i] == 'A') a = 1;
		if(s[i] == 'B') b = 1;
	}
	if(a == 1 && b == 1) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/

int main(){
    int n; cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    int count = 0;
    rep(i, n){
        _rep(j, i + 1, n){
            auto it = lower_bound(l.begin(), l.end(), l[i] + l[j]);
            int k = it - l.begin();
            count += max(k - (j + 1), 0LL);
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
def solve():
    list_of_txy = read()
    result = think(list_of_txy)
    write(result)


def read():
    n = read_int(1)[0]
    list_of_txy = [[0, 0, 0]]
    for _ in range(n):
        list_of_txy.append(read_int(3))
    return list_of_txy


def read_int(n):
    return list(map(int, read_line().split()[:n]))


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(list_of_txy):
    for i in range(len(list_of_txy) - 1):
        t, x, y = list_of_txy[i]
        nt, nx, ny = list_of_txy[i + 1]
        dx, dy, dt = abs(nx - x), abs(ny - y), abs(nt - t)
        if dx + dy > dt:
            return False
        if (dt - dx - dy) % 2 != 0:
            return False
    return True


def write(result):
    if result:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()

Measured memory_bytes: 64984
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif


bool solve()
{
    int n;
    cin >> n;

    vector<int> v = fetch_vec<int>(n);
    
    int sum = std::accumulate(v.begin(), v.end(), 0);
    int minDiff = sum;
    int partialSum = 0;

    for (int i = 0; i < n; ++i)
    {
        partialSum += v[i];
        minDiff = std::min(minDiff, std::abs(partialSum * 2 - sum));
    }

    cout << minDiff << endl;

    return false;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long l = sc.nextLong();
        long r = sc.nextLong();

        if (l >= r) {
            System.out.print(0);
        } else if (r - l > 2019) {
            System.out.print(0);
        } else {
            l = l % 2019;
            r = r % 2019;

            long min = 2018;
            for (long i = l; i < r; i++) {
                for (long j = i + 1; j <= r; j++) {
                    if ((i * j) % 2019 < min) {
                        min = (i * j) % 2019;
                    }
                }
            }
            System.out.print(min);
        }
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <climits>
using namespace std;

#define rep(i,beg,end)   for (int i=(beg);i<(end);i++)
#define rrep(i,beg,end)   for (int i=(beg);i>=(end);i--)
#define all(cont)           begin(cont), end(cont)
#define INFMAX                   LLONG_MAX
#define INFMIN                   LLONG_MIN
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef list<ll> li;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vi a(n);
    rep(i, 0, n) { cin >> a[i]; }
    ll cnt = 0;
    rep(i, 1, n - 1)
    {
        if (a[i] != max({a[i - 1], a[i], a[i + 1]}) && a[i] != min({a[i - 1],a[i],a[i + 1]})) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main (void){

	int input_number = 0;
	int i = 0;
	int a = 0;
	int b = 0;
	int a_result = 0;
	int b_result = 0;

	while (1){

		scanf("%d",&input_number);

		if(input_number == 0){
			return 0;
		}

		for (i=0; i < input_number; i++){
			scanf("%d",&a);
			scanf("%d",&b);

			if ( a > b ){
				a_result += a;
				a_result += b;
			}
			else if ( a < b ){
				b_result += a;
				b_result += b;
			}
			else {
				a_result += a;
				b_result += b;
			}

		}
		printf("%d %d\n",a_result,b_result );
		a_result=0;
		b_result=0;
	}

		

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
		using namespace std;
		typedef long long ll;
		#define PRINT(x,y) cout<<"Case #"<<(int)x<<": "<<(int)(y)<<endl;
		ll exp(ll x, ll y) {
			if(y==0) return 1;
			if(y==1) return x;
			if(y%2==0) return exp(x,y/2)*exp(x,y/2);
			else return x*exp(x,y/2)*exp(x,y/2);
		}
		ll gcd(ll a , ll b) {
			if(b==0) return a;
			return gcd(b , a%b);
		}
		ll lcm(ll a , ll b) {
			return (a*b)/gcd(a,b);
		}
		#define vec(n) vector<int> v((int)(n),0);
		#define vecl(n) vector<ll> v((ll)(n),0);
		#define sq(a) ((int)(a))*((int)(a));
		#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
		int l;
		ll fact(ll x) {
			if(x==1) return 1;
			else return x*fact(x-1);
		}
		bool isPrime(int x) {
			int ans  = 0;
			for(int i=2;i<=sqrt(x);++i) {
				if(x%i==0) {
					ans = 1; i=x;
				}  
			}
			if(ans==0) return true;
			else return false;
		}
		ll isPerfect(ll x) {
			double y = sqrt(x);
			return (floor(y)==ceil(y));
		} 

		int z = 0;
		void ask(int x, int y) {
			cout<<"? "<<x<<" "<<y<<endl;
			}

		void solve() {
		string s; cin>>s;
		ll ans = 0;
		for(ll i = 0;i<s.length();++i) {
			ans+=s[i]-'0';
		}
		if(ans%9==0) cout<<"Yes";
		else cout<<"No";


		}			



		int main() {
			io
			 solve();
		}
		    
		

Measured memory_bytes: 3664
#include <iostream>
#include <math.h>

using namespace std;

int main() {
  int a, b, C;
  cin >> a >> b >> C;
  double rad = C * M_PI / 180.0;
  double S = a * b * sin(rad) / 2;
  double L = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(rad));
  double h = b * sin(rad);
  cout << fixed << S << endl << fixed << L << endl << fixed << h << endl;
  return 0;
}

Measured memory_bytes: 1240