akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

signed main(void)
{
	int n, k, sum;
	cin >> n >> k;
	vector<int> l(n);

	sum = 0;
	rep(i, n) cin >> l[i];
	sort(l.rbegin(), l.rend());
	rep(i, k)
		sum += l[i];
	cout << sum << endl;
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<ll> l(n);
	rep(i,n) cin >> l[i];

	int count=0;
	for(int i = 0; i< n-2; i++){
		for(int j = i+1; j<n-1; j++){
			for(int k = j+1; k<n; k++){
				if(l[i] != l[j] && l[j] != l[k] && l[i] != l[k]){
					if((abs(l[i]-l[j]) < l[k])&&(l[i]+l[j] > l[k])){
						count++;
					}
				}
			}
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3624
// 23/01/20 // 11:34 AM //

#include <bits/stdc++.h>

using namespace std;

const int MAXN = (int)(3e3)+10;
const int INF  = 0x3f3f3f3f;

int n;
double p[MAXN], memo[MAXN][MAXN];

double solve(){

    for(int i=0; i<=n+1; i++)
        for(int j=0; j<=n+1; j++){
            if(2*(j+n-i+1)<n)
                memo[i][j] = 0;
            else if(i>n)
                memo[i][j] = 1;
        }

    for(int i=n; i>=1; i--){
        for(int j=n; j>=0; j--){
            memo[i][j] = p[i]*memo[i+1][j+1] + (1-p[i])*memo[i+1][j];
        }
    }

    return memo[1][0];
}


int main(){


    cin >> n;
    for(int i=1; i<=n; i++) cin >> p[i];

    cout.precision(10);
    cout.setf(ios::fixed);
    cout << solve() << endl;

    return 0;
}



Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    ll x;
    cin >> x;
    ll n = x / 100;
    if (n < 1) {
        cout << 0 << "\n";
    }
    else if (n < 100) {
        ll r = x % 100;
        if (n * 5 >= r) {
            cout << 1 << "\n";
        }
        else {
            cout << 0 << "\n";
        }
    }
    else if (n >= 100) {
        cout << 1 << "\n";
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  int now=1;
  
  for(int i=1;i*(i+1)<=2*n;i++){
    if(i*(i+1)==2*n){
      cout<<"Yes"<<endl;
      cout<<i+1<<endl;
      vector<int> ans[i+1];
      for(int j=0;j<=i;j++){
        for(int k=1;j+k<=i;k++){
          ans[j].push_back(now);
          ans[j+k].push_back(now);
          now++;
        }
      }
      for(int j=0;j<=i;j++){
        cout<<i<<" ";
        for(int k=0;k<i;k++) cout<<ans[j][k]<<" ";
        cout<<endl;
      }
      return 0;
    }
  }

  cout<<"No"<<endl;

  return 0;
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;

vector<ll> h;
ll n, a, b;

ll ceil_mod(ll a, ll b){
	ll ret = a/b;
	if(a%b!=0){++ret;}
	return ret;
}

bool check(ll mb){
    ll count = mb;
    for(int i = 0; i < n; ++i) {
    	ll tmp = h[i] - mb*b;
        if(tmp>0){
        	count -= ceil_mod(tmp, (a-b));
            if(count < 0){return false;}
        }
        else{
        	break;
        }
    }
    return true;
}

int main(){
    cin >> n >> a >> b;
    h.resize(n);
   ll hsum=0;
    for(int i = 0; i < n; ++i){
  	  cin >> h[i];
          hsum += h[i];
    }
    sort(h.begin(), h.end(), greater<ll>());
    
    ll lb=0, ub =ceil_mod(hsum , b);
    while(ub - lb > 1){
        ll mb = (lb + ub) / 2;
        if(check(mb)){
            ub = mb;
        }else{
            lb = mb;
        }
    }
    cout << ub << endl;
    
    return 0;
}


Measured memory_bytes: 1024
class Node
  attr_accessor :id, :parent, :children

  def initialize(id, children)
    @id = id
    @parent = nil
    @children = children
  end

  def depth
    d = 0
    target = self
    while !target.parent.nil? do
      d += 1
      target = target.parent
    end
    return d 
  end

  def type
    if depth == 0
      'root'
    elsif children.empty?
      'leaf'
    else
      'internal node'
    end
  end

  def parent_id
    if parent.nil?
      -1
    else
      parent.id
    end
  end
end

n = gets.to_i
nodes = Array.new(n)
n.times do
  id, k, *cs = gets.split.map(&:to_i)
  node = Node.new(id, cs)
  nodes[id] = node
end

nodes.each do |parent|
  parent.children.each do |child|
    nodes[child].parent = parent
  end
end

# puts nodes.inspect

nodes.each do |node|
  puts "node #{node.id}: parent = #{node.parent_id}, depth = #{node.depth}, #{node.type}, #{node.children.to_s}"
end


Measured memory_bytes: 23276
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		System.out.println(1 - sc.nextInt());
		
		pw.flush();
	}

	public static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] array = new Integer[n];
			for (int i = 0; i < n; i++)
				array[i] = new Integer(nextInt());
			return array;
		}

		public long[] nextLongArray(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		public double[] nextDoubleArray(int n) throws IOException {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		public static int[] shuffle(int[] a) {
			int n = a.length;
			Random rand = new Random();
			for (int i = 0; i < n; i++) {
				int tmpIdx = rand.nextInt(n);
				int tmp = a[i];
				a[i] = a[tmpIdx];
				a[tmpIdx] = tmp;
			}
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


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

int main() {
    long long int input; 
	long long int modulo;
    char nama[55];
    scanf("%lld", &input);
    int i = 0;
    while (input > 0) {
        modulo = (input - 1) % 26;
        nama[i++] = 'a' + modulo;
        input = (input - modulo) / 26;
    }
    nama[i] = '\0';
    int panjang = strlen(nama);
    for (panjang--; panjang >= 0; panjang--) {
        printf("%c", nama[panjang]);
    }
return 0;    
}


Measured memory_bytes: 1664
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int MN = 6005;

int N, Mod;
int _f[MN][2 * MN], *f[MN], Ans;

int main() {
	scanf("%d%d", &N, &Mod), N *= 3;
	for (int i = 0; i <= N; ++i) f[i] = _f[i] + MN;
	f[0][0] = 1;
	for (int i = 1; i <= N; ++i)
		for (int j = -N; j <= N; ++j)
			f[i][j] = (f[i - 1][j - 1] + (i >= 2 ? (LL)(i - 1) * f[i - 2][j + 1] : 0) + (i >= 3 ? (LL)(i - 1) * (i - 2) * f[i - 3][j] : 0)) % Mod;
	for (int j = 0; j <= N; ++j) Ans = (Ans + f[N][j]) % Mod;
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 281728
a=int(input())
b=int(input())
c=int(input())
n=int(input())

count = 0


for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == n:
                count += 1
print(count)

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

int main() {
    int n,k;cin>>n>>k;
    vector<int> sunuke(n);
    for(int i=0;i<n;i++){
        sunuke.at(i)=1;
    }
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        int a[d];
        for(int j=0;j<d;j++){
            cin>>a[j];
        }
        for(int j=0;j<d;j++){
            sunuke.at(a[j]-1)=0;
        }
    }
    int count=0;
    for(int i=0;i<n;i++){
        if(sunuke.at(i)==1) count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3628
import java.util.*;
import java.lang.*;

class Main {
  static int stacksize = 200;
  static int stackpointer = 0;
  static int [] stack = new int[stacksize];
//push
  static void push(int num){
    stack[stackpointer++] = num;
  }
  //pop
  static int pop(){
    return stack[--stackpointer];
  }
  //main
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String [] s = sc.nextLine().split("\\s");
    for(int i = 0; i<s.length; i++){

      if(s[i].equals("+")){
        push(pop()+pop());
      }else if(s[i].equals("-")){
        push(-(pop()-pop()));
      }else if(s[i].equals("*")){
        push(pop()*pop());
      }else{
        push(Integer.valueOf(s[i]));
      }
    }
    System.out.println(pop());
  }
}


Measured memory_bytes: 26164
#include<iostream>
using namespace std;
int main(){
    int x,y;
    while(1){
            cin >> x>>y;
            if(x == 0 && y == 0){
                break;
            }
            if(x<=y){
                cout << x<<" "<<y<<"\n";
            }
            else if(x>y){
                cout << y<<" "<<x<<"\n";
            }
    }
}

Measured memory_bytes: 3072
import sys
import collections

input = sys.stdin.readline


def main():
    N = int(input())
    A =list(map(int,input().split()))
    AD = collections.Counter(A)
    Q = int(input())
    ans =0
    for key, item in AD.items():
        ans += key * item


    for i in range(Q):
        b, c = map(int,input().split())
        if b not in AD.keys():
            print(ans)
        else:
            if c not in AD.keys():
                ans =ans +(c-b)*AD[b]
                AD[c] = AD[b]
                AD[b] =0
                print(ans)
            else:
                ans = ans + (c - b) * AD[b]
                AD[c] += AD[b]
                AD[b] = 0
                print(ans)






if __name__ == "__main__":
    main()

Measured memory_bytes: 21100
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b,c,k; cin >> a >> b >> c >> k;
    ll ans = min(a,k);
    if(a+b>=k){
        cout << ans << endl;
        return 0;
    } else{
        ans -= (k-a-b);
        cout << ans << endl;
    }
} 

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using f32 = float;
using f64 = double;
using f80 = __float80;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<LL>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    LL n, a, b,c, count=0;
    cin >> n;
    vector<LL> aa(n);
    vector<LL> side;
    REP(i, n){cin >> aa[i];
             }
    SORT(aa);
    for(int i=n-1;i>0;i--)
    {
        if (aa[i] == aa[i-1])
        {
            side.pb(aa[i]);
            i -= 1;
            count+=1;

        }
         if(count>=2){
            cout << side[0] * side[1];
            return 0;
        }
    }
    cout << '0' << endl;
    return 0;
}

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

using namespace std;

int main () {
	int a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0) {
		cout << "Zero";
		return 0;
	}
	int len = b - a + 1;
	if (a > 0) {
		cout << "Positive";
		return 0;
	}
	if (len & 1) {
		cout << "Negative";
	}
	else cout << "Positive";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a[] = new int[N];
    boolean isAlice = true;
    int alice =0;
    int bob = 0;
    for(int i=0;i<N;i++){
      a[i]=sc.nextInt();
    }
    Arrays.sort(a);
    for(int i=0;i<N;i++){
      if(isAlice){
        alice=alice+a[N-1-i];
      }else{
        bob=bob+a[N-1-i];
      }
      isAlice=!isAlice;
    }
    System.out.println(alice-bob);
  }
  

  
}

Measured memory_bytes: 23380
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k = Integer.parseInt(sc.next());
		
		int n = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			a[i] = Integer.parseInt(sc.next());
		
		}
	
		int max = k-a[n-1]+ a[0];
		for(int i = 1 ;i < n ;i++) {
			max= Math.max(a[i] -a[i-1],max);	
		}
		

		System.out.println(k - max);
	}		
	}


Measured memory_bytes: 57380
n,m = map(int,input().split())
ls = set()
for i in range(m):
    ls.add(int(input()))
dp = [0]*(n+1)
dp[0]=1
if 1 in ls:
    dp[1]= 0
else:
    dp[1]= 1
for i in range(2,n+1):
    if i in ls :
        continue
    dp[i] = dp[i-1]+dp[i-2]
print(dp[n]%(10**9+7))

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

using namespace std;

int main(){

	int a, b, c, m=0;

	cin>> a >> b >> c;

	if (a == b) m++;
	if (a == c) m++;
	if (b == c) m++;

	if (m == 1) cout << "Yes" << endl;
	else cout << "No" << endl;
 
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    REP(i, M) cin >> X[i];

    SORT(X);
    vector<int> A(M - 1);
    REP(i, M - 1) { A[i] = X[i + 1] - X[i]; }
    SORT(A);

    ll ans = 0;
    REP(i, M - N) ans += A[i];

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  if (k <= a) {
    ans += k;
    k = 0;
  } else {
    ans += a;
    k -= a;
  }
  if (k <= b) {
    k = 0;
  } else {
    k -= b;
  }
  if (k != 0) {
    ans -= k;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<math.h>
int main(void)
{
	int number=0;
	int sum=0;
	scanf("%d",&number);
	char ch=getchar();
	char shilaimu[number];
	for(int i=0;i<number;i++)
	{
		shilaimu[i]=0;
	}
	for(int i=0;i<number;i++)
	{
		shilaimu[i]=getchar();
	}
	char thisvalue=shilaimu[0];
	int counter=1;
	for(int i=1;i<number;i++)
	{
		
		
		if(shilaimu[i]!=thisvalue)
		{
			counter++;
		}
		 thisvalue=shilaimu[i];
	}
	printf("%d",counter);
	return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  ll n,cnt[5]={0};
  string s[100010];
  cin>>n;
  rep(i,n)cin>>s[i];

  rep(i,n){
    if(s[i][0]=='M')cnt[0]++;
    if(s[i][0]=='A')cnt[1]++;
    if(s[i][0]=='R')cnt[2]++;
    if(s[i][0]=='C')cnt[3]++;
    if(s[i][0]=='H')cnt[4]++;
  }
  ll ans=cnt[0]*cnt[1]*cnt[2]+cnt[0]*cnt[1]*cnt[3]+cnt[0]*cnt[1]*cnt[4]+cnt[0]*cnt[2]*cnt[3]+cnt[0]*cnt[2]*cnt[4]+
  cnt[0]*cnt[3]*cnt[4]+cnt[1]*cnt[2]*cnt[3]+cnt[1]*cnt[2]*cnt[4]+cnt[1]*cnt[3]*cnt[4]+cnt[2]*cnt[3]*cnt[4];
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 6728
#include <iostream>
using namespace std;
int main()
{
	int a,b,c;

	cin >> a >> b >> c;

	// if (a<b<c){
	if (a < b && b < c)
	{
		cout << "Yes\n";
	}

	else {
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    lli n, H;
    cin>>n>>H;
    lli a[n];
    lli b[n];
    vector<pair<lli, lli> > v, v2;
    for(int i = 0; i < n; i ++) {
        cin>>a[i]>>b[i];
        v.push_back({a[i], i});
        v2.push_back({b[i], i});
    }
    sort(v.rbegin(), v.rend());
    sort(v2.rbegin(), v2.rend());
    sort(b, b + n);
    reverse(b, b + n);
    lli ans = 0;
    for(int i = 0 ; i < n; i ++) {
        if(H <= 0)
            break ;
        if(b[i] > v[0].ff) {
            H -= b[i];
            ans ++;
        }
    }
    H = max(H, 0LL);
    ans += ceil((ld)H / v[0].ff);
    cout<<ans;
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int mod=998244353;
const int maxn=2e5+5;
int n,m;
int sum[maxn<<2],l[25],r[25];
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
void push_up(int rt){
	sum[rt]=(sum[rt<<1]+sum[rt<<1|1])%mod;
}
//单点修改
void update(int x,int c,int l,int r,int rt){
	if(l==r){
		sum[rt]=(sum[rt]+c)%mod;
		return ;
	}
	int m=(l+r)>>1;
	if(x<=m) update(x,c,l,m,rt<<1);
	else update(x,c,m+1,r,rt<<1|1);
	push_up(rt);
}
int query(int a,int b,int l,int r,int rt){
	if(a<=l&&b>=r) return sum[rt];
	int m=(l+r)>>1;
	ll ans=0;
	if(a<=m) ans=(ans+query(a,b,l,m,rt<<1))%mod;
	if(b>m) ans=(ans+query(a,b,m+1,r,rt<<1|1))%mod;
	return ans;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		l[i]=read(),r[i]=read();
	}
	update(1,1,1,n,1);
	for(int i=2;i<=n;i++){
		int tmp=0;
		for(int j=1;j<=m;j++){
			if(i-l[j]<1) continue;
			tmp=(tmp+query(max(i-r[j],1),i-l[j],1,n,1))%mod;
		}
		update(i,tmp,1,n,1);
	}
	printf("%d\n",query(n,n,1,n,1));
	return 0;
}

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

int main() {
    int n;
    string s; cin >> n >> s;

    int out = 0;
    for (int i = 0; i < n - 2; i++) {
        if (s[i] != 'A') continue;
        if (s[i + 1] == 'B' && s[i + 2] == 'C') ++out;
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(" ".join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


n, m = sp()
h = l()
graph = dd(set)
for i in range(m):
    u, v = sp()
    graph[u].add(v)
    graph[v].add(u)
answer = 0
for i in range(1, n+1):
    result = True
    for j in graph[i]:
        if h[j-1] >= h[i-1]:
            result = False
            break
    if result:
        answer += 1
out(answer)


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

int main(){
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);

  if( abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d) ){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

ans = {}
for t in s:
    if t in ans:
        ans[t] += 1
    else:
        ans[t] = 1

max_cnt = max(ans.values())

for t in sorted(ans):
    if ans[t] == max_cnt:
        print(t)


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

int DP[MAX];

//
int main(){
	int n,k;cin >> n >> k;
	V h(n);
	REP(i,n)cin>>h[i];

	for(int i=n-1;i>0;--i){
		int tmp=INF;
		REPS(j,1,k+1){
			if((i+j-1)>=n)break;
			tmp = min(tmp,DP[i+j]+abs(h[i-1]-h[i+j-1]));
		}
		DP[i] = tmp;
	}

	cout << DP[1] << endl;

	return 0;
}




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

template <typename T>
class ModCalc{
public:
    ModCalc(T MOD){
        mod = MOD;
    }

    T add(T a, T b){
        return (a + b) % mod;
    }

    T sub(T a, T b){
        return (mod + a - b) % mod;
    }

    T multi(T a, T b){
        return ((a % mod) * (b % mod)) % mod;
    }

    T power(T a, T n){
        T res = 1;
        while(n){
            if(n&1) res = multi(res, a);
            a = multi(a, a);
            n >>= 1;
        }
        return res;
    }

    T div(T a, T b){
        return multi(a, power(b, mod-2));
    }

    T comb(T n, T k){
        T res = 1;
        if(k>n-k) k=n-k;
        for(T i=0; i<k; i++){
            res = multi(res, n-i);
            res = div  (res, i+1);
        }
        return res;
    }

    T multicomb(T n, T k){
        return comb(n+k-1, k);
    }
private:
    T mod;
};

int main()
{
    unsigned long long n, a, b;
    cin >> n >> a >> b;
    ModCalc<unsigned long long> mc(1000000007);
    auto res = mc.power(2, n);
    res = mc.sub(res, 1);
    res = mc.sub(res, mc.comb(n, a));
    res = mc.sub(res, mc.comb(n, b));
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
		string s;
		cin>>s;

		cout<<s;
		if(s[sz(s)-1] == 's'){
			cout<<"es"<<endl;
		}     
		else{
			cout<<"s"<<endl;
		}

        //printf("Case %d: ",++te);
    }

    //cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}






Measured memory_bytes: 3600
//Aaryan Jagetia
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define sc(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test cin>>t;while(t--)
int main()
{    
    fast
ll n;
cin>>n;
ll arr[n];
ll ans=1;

ll f=1;
for(ll i=0;i<n;i++){
    cin>>arr[i];
}
sort(arr,arr+n);
if(arr[0]==0){
    cout<<0;
    return 0;
}
for(ll i=0;i<n;i++){
     if(arr[i]<=1000000000000000000/ans){
         ans*=arr[i];
     }
     else{
         f=0;
         break;
     }
}
if(f==0){
    cout<<-1<<endl;
}
else{
    cout<<ans<<endl;
}
return 0;
}


Measured memory_bytes: 4436
import sys

def check(i,j):
    delta = [(-1,0), (1,0), (0,1), (0,-1)]
    for d in delta:
        ni = i + d[0]
        nj = j + d[1]
        if (ni >= 0 and ni < H and nj >= 0 and nj < W):
            if (m[ni][nj] == '#'):
                return True
        else:
            continue
    return False
        
H,W = list(map(int, input().split()))
m = []
for i in range(H):
    l = str(input())
    m.append(l)

for i in range(H):
    for j in range(W):
        if m[i][j] == '#' and check(i,j) == False:
            print('No')
            sys.exit()
print('Yes')


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

ll dp[1000100][2][2];
ll mod = 1000000007LL;

void solve() {

}

int main() {
  int n;
  cin >> n;
  dp[0][0][0] = 1;
  rep(i,n) {
    rep(v0,2) {
      rep(v9,2) {
	if( dp[i][v0][v9] == 0 ) continue;
	rep(v,10) {
	  int nv0 = v0;
	  int nv9 = v9;
	  if( v == 0 ) nv0 = 1;
	  if( v == 9 ) nv9 = 1;
	  ( dp[i+1][nv0][nv9] += dp[i][v0][v9] ) %= mod;
	}
      }
    }
  }
  cout << dp[n][1][1] <<endl;
  return 0;
}


Measured memory_bytes: 34728
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
struct dta{
  int x;
  int y;
  int s;
};
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
char mp[20][20];
bool lck[20][20];
void init(){
  for(int i = 0; 20 > i; i++){
    for(int j = 0; 20 > j; j++){
      lck[i][j] = false;
    }
  }
}
int main() { 
  int H,W;cin>>H>>W;
  for(int i = 0; H > i; i++){
    for(int j = 0; W > j; j++){
      cin>>mp[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; H > i; i++){
    for(int j = 0; W > j; j++){
      if(mp[i][j] == '#')continue;
      init();
      int tmp = 0;
      //mp[i][j]から一番遠いとこ
      queue<dta> A;
      A.push({i,j,0});
      lck[i][j] = true;
      while(!A.empty()){
        dta Z = A.front();
        tmp = max(tmp,Z.s);

        A.pop();
        if(0 <= Z.x-1 && mp[Z.x-1][Z.y] == '.'&& !lck[Z.x-1][Z.y]){
          lck[Z.x-1][Z.y] = true;
          A.push({Z.x-1,Z.y,Z.s+1});
        }
        if(H > Z.x+1 && mp[Z.x+1][Z.y] == '.'&& !lck[Z.x+1][Z.y]){
          lck[Z.x+1][Z.y] = true;
          A.push({Z.x+1,Z.y,Z.s+1});
        }
        if(0 <= Z.y-1 && mp[Z.x][Z.y-1] == '.'&& !lck[Z.x][Z.y-1]){
          lck[Z.x][Z.y-1] = true;
          A.push({Z.x,Z.y-1,Z.s+1});
        }
        if(W > Z.y+1 && mp[Z.x][Z.y+1] == '.'&& !lck[Z.x][Z.y+1]){
          lck[Z.x][Z.y+1] = true;
          A.push({Z.x,Z.y+1,Z.s+1});
        }
      }
      ans = max(ans,tmp);
    }
  }
  cout << ans << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#define LL long long

using namespace std;

int main()
{
	ios :: sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	int n,m;
	cin>>n>>m;
	priority_queue <int> q;
	int x;
	for(int i=0;i<n;i++){
		cin>>x;
		q.push(x); 
	}
	for(int i=1;i<=m;i++){
		x=q.top() ;
		q.pop() ;
		q.push(x/2);
		if(q.top() ==0) break; 
	}
	LL sum=0;
	while(!q.empty() ){
		sum+=q.top() ;
		q.pop() ;
	}
	cout<<sum<<endl;
	return 0;
 } 

Measured memory_bytes: 892
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y) {
	return y == 0 ? x : gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}

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

	int N;
	ll M;
	cin >> N >> M;
	vector<ll> a(N);
	REP(i, N) cin >> a[i];
	ll l = 1;
	
	REP(i, N) l = lcm(l, a[i]);
	if (l > 2 * M) {
		cout << 0 << endl;
		return 0;
	}
	REP(i, N) {
		if (l / a[i] % 2 == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << 1 + (M - l / 2) / l << endl;


	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define REP(i,a,b) for(int i=int(a);i<=int(b);i++)
#define MOD 1000000007
#define INF 2000000000
#define DESPACITO 1000000000000000000
#define PI acos(-1);
#define E 998244353
#define pb push_back
#define mp make_pair
#define ll long long

using namespace std;


int main()
{
	IOS;
	double W,H,x,y;
	cin >> W >> H >> x >> y;
	double ans = (W*H)/2;
	char ch = '0';
	if( x==  W/2 && y == H/2)
		ch = '1';
	cout << std::fixed;
	cout << setprecision(9) << ans << " ";
	cout << ch;
}	


Measured memory_bytes: 256
///not today

#include<bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair< int, pair<int, int> >
#define plpll pair< ll, pair<ll, ll> >

using namespace std;

int32_t main(){
      string s;
      cin >>s;
      for(int i = 0; i < 4; i ++){
            int cn = 0;
            for(int j = 0; j < 4; j ++){
                  if(s[i] == s[j])
                        cn ++;
            }
            if(cn != 2)
                  return cout <<"No" <<endl, false;
      }
      cout <<"Yes" <<endl;
      return false;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
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(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

template <typename T>
struct li_chao_tree {
    const T INF = numeric_limits<T>::max();
    struct line {
        T a, b;
        line(T a, T b) : a(a), b(b) {}
        T operator()(T x) const { return a*x + b;}
    };
    int n;
    vector<line> fs;
    vector<T> xs;
    
    li_chao_tree(const vector<T>& xs_) : xs(xs_) {
        sort(xs.begin(), xs.end());
        xs.erase(unique(xs.begin(), xs.end()), xs.end());
        n = xs.size();
        fs.assign(n<<1, line(T(0), INF));
    }
    
    int index(T x) const { return lower_bound(xs.begin(), xs.end(), x) - xs.begin();}

    void add_line(T a, T b) { update(a, b, 0, n);}
    
    void add_line(T a, T b, T xl, T xr) {
        int l = index(xl), r = index(xr);
        update(a, b, l, r+1);
    }

    void update(T a, T b, int l, int r) {
        line g(a, b);
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) descend(g, l++);
            if (r & 1) descend(g, --r);
        }
    }
    
    void descend(line g, int i) {
        int l = i, r = i+1;
        while (l < n) l <<= 1, r <<= 1;
        while (l < r) {
            int c = (l+r) >> 1;
            T xl = xs[l-n], xr = xs[r-1-n], xc = xs[c-n];
            line& f = fs[i];
            if (f(xl) <= g(xl) && f(xr) <= g(xr)) return;
            if (f(xl) >= g(xl) && f(xr) >= g(xr)) { f = g; return;}
            if (f(xc) > g(xc)) swap(f, g);
            if (f(xl) >= g(xl)) i = i<<1|0, r = c;
            else i = i<<1|1, l = c;
        }
    }
    
    T get_min(T x) const {
        int i = index(x);
        T res = INF;
        for (i += n; i; i >>= 1) res = min(res, fs[i](x));
        return res;
    }
};

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

    int n; ll c;
    cin >> n >> c;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    vector<ll> xs(n);
    rep(i, n) xs[i] = -2 * h[i];
    li_chao_tree<ll> seg(xs);
    
    vector<ll> dp(n);
    for (int i = 1; i < n; ++i) {
        seg.add_line(h[i-1], dp[i-1] + h[i-1] * h[i-1]);
        dp[i] = seg.get_min(-2 * h[i]) + h[i] * h[i] + c;
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 15868
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<unordered_map>
#include<string>
#define LL long long
#define li i<<1
#define ri i<<1|1
using namespace std;
inline LL read()
{
    char c=getchar();LL x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
LL n; 
int main()
{
	n=read();
	int ans=0;
	if(n<600)
		ans=8;
	else if(n<800)
		ans=7;
	else if(n<1000)
		ans=6;
	else if(n<1200)
		ans=5;
	else if(n<1400)
		ans=4;
	else if(n<1600)
		ans=3;
	else if(n<1800)
		ans=2;
	else if(n<2000)
		ans=1;
	printf("%d\n",ans);
	return 0;
}


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

int main() {

	string s; cin >> s;

	int ans = 0;
	int tmp = 0;
	for (int i = 0; i < s.size(); i++) {		
		if (i != s.size() - 1) {
			if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
				tmp++;
			}
			else {
				ans = max(ans, tmp);
				tmp = 0;
			}
		}
		else { // i == s.size() - 1
			if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
				tmp++;
				ans = max(ans, tmp);
			}
			else {
				ans = max(ans, tmp);
			}
		}
	}

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

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
)

func main() {
	log.SetFlags(log.Lshortfile)
	N := nextInt()
	L := nextInts(N * 2)
	sort.Ints(L)
	var ans int
	log.Println(L)
	for i := 0; i < N*2; i += 2 {
		ans += L[i]
		log.Println(ans)
	}
	fmt.Println(ans)
}
func Max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func Min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func Sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int k=n%1000;
  if(n<1000){
    cout << 1000-n << endl;
  }else if(k>=1){
    cout << 1000-k << endl;
  }else{
    cout << k << endl;
  }
}


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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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 <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int a, b, c;
  cin >> a >> b >> c;

  if (a == b and b == c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int h, w, n;
    cin >> h >> w >> n;
    int L = 0, R = w + 1, U = 0, D = h + 1;
    int x, y;
    cin >> x >> y;
    string s, t;
    cin >> s >> t;
    FORR(i, n) {
        if(t[i] == 'L' && R <= w) R++;
        if(t[i] == 'R' && L >= 1) L--;
        if(t[i] == 'U' && D <= h) D++;
        if(t[i] == 'D' && U >= 1) U--;
        if(s[i] == 'L') L++;
        if(s[i] == 'R') R--;
        if(s[i] == 'U') U++;
        if(s[i] == 'D') D--;
        if(L >= w || R <= 1 || U >= h || D <= 1) {
            puts("NO");
            return 0;
        }
    }
    puts(L < y && y < R && U < x && x < D ? "YES" : "NO");

    return 0;
}

Measured memory_bytes: 920
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    s = ns()

    if s[2] == s[3] and s[4] == s[5]:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

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

int main(){
    int N;
    // int x[100001];
    // int y[100001];
    // int t[100001];
    bool flag = 0;

    cin >> N;

    int x[N];
    int y[N];
    int t[N];
    for (int i = 0; i < N; i++){
        cin >> t[i] >> x[i] >> y[i];
        // cin >> x[i];
        // cin >> y[i];
    }

    for (int i = 0; i < N; i++){
        if (i != 0){
            t[i] = t[i] - t[i-1];
            x[i] = x[i] - x[i-1];
            y[i] = y[i] - y[i-1];
        }
        if(x[i] < 0) x[i] = -1 * x[i];
        if(y[i] < 0) y[i] = -1 * y[i];
        if(t[i] % 2 == 0){
            // t = even
            // if ((x[i] + y[i]) % 2 == 0 && x[i] + y[i] <= t[i]) ;
            // else flag = 1;
            if ((x[i] + y[i]) % 2 != 0 || x[i] + y[i] > t[i]) flag = 1;
        }else
        {
            // t = odd
            // if ((x[i] + y[i]) % 2 == 1 && x[i] + y[i] <= t[i]) ;
            // else flag = 1;
            if ((x[i] + y[i]) % 2 != 1 || x[i] + y[i] > t[i]) flag = 1;
        }
    }
    if (flag == 0) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1408