akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
typedef vector<pii> vp;
 
double to_rad(int angle){
    return angle*PI*2/360;
}
 
double dist(pii l,pii r){
    return sqrt(pow((double)l.second-r.second,2)+pow((double)l.first-r.first,2));
}
#define EQ(a,b) (abs((a)-(b))<EPS)
 
int main(){
    int n;
    while(cin>>n,n){
        vp coords;
        coords.push_back(make_pair(0,0));
        REP(i,n){
            int x,y;
            cin>>x>>y;
            coords.push_back(make_pair(x,y));
        }
 
        double res=0;
        int cur_index=0;
        double runner_angle=to_rad(90);
        while(coords.size()>1){
            pii cur=coords[cur_index];
            coords.erase(coords.begin()+cur_index,coords.begin()+cur_index+1);
            int best_index=0;
            double best_angle=1000;
			double best_abs_angle=0;
            REP(j,coords.size()){
				double abs_angle=atan2((double)(coords[j].second-cur.second),coords[j].first-cur.first);
				if(abs_angle<0){
					abs_angle+=to_rad(360);
				}
                double angle;
				if(EQ(runner_angle,abs_angle)){
					angle=0;
				}else{
					angle=runner_angle-abs_angle;
				}
				if(angle<0){
					angle+=to_rad(360);
				}
                if(best_angle>angle||(EQ(angle,best_angle)&&dist(cur,coords[best_index])>dist(cur,coords[j]))){
                    best_index=j;
                    best_angle=angle;
					best_abs_angle=abs_angle;
                }
            }
            res+=dist(cur,coords[best_index]);
            cur_index=best_index;
            runner_angle=best_abs_angle;
        }
 
        printf("%.1f\n",res);
    }
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

typedef long long ll;

ll n, k, m, ans, a[N], ne[N], fen[N], pre[N];
map < ll , int > h, hh;
map < ll , int > :: iterator it;

void up(int x, int y){
	for(; x <= m; x += x&-x)
		fen[x] += y;
}

int qu(int x){
	int top = 0;
	for(; x > 0; x -= x&-x)
		top += fen[x];
	return top;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("amk.txt", "w", stdout);
	scanf("%lld %lld",&n ,&k);
	for(int i = 1; i <= n; i++){
		scanf("%lld",a + i);
		pre[i] = pre[i - 1] + a[i];
	}
	for(int i = 0; i <= n; i++)
		h[i*k - pre[i]]++;
	for(it = h.begin(); it != h.end(); it++){
		ne[++m] = it->st;
		// cout << it->st << " " << m << endl;
		hh[it->st] = m;
	}
	// cout << "amk" << endl;
	up(hh[0], 1);
	for(int i = 1; i <= n; i++){
		int amk = hh[i*k - pre[i]];
		ans += qu(m) - qu(amk - 1);
		up(amk, 1);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 39040
package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	defer flush()

	N := readInt()
	X := readInt()
	Y := readInt()

	t := make([]int, N)

	for i := 1; i < N; i++ {
		for j := i + 1; j < N+1; j++ {
			t[min(j-i, abs(X-i)+1+abs(Y-j))]++
		}
	}

	for i := 1; i < N; i++ {
		println(t[i])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

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

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


Measured memory_bytes: 1844
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
//#define gcd __gcd
//#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

//OJ freopen Template
void OJF(const char* inp, const char* out) {
	if (strlen(inp) > 0) freopen(inp, "r", stdin);
	if (strlen(out) > 0) freopen(out, "w", stdout);
}

signed main()
{
    //OJF("TRAIGLE.inp", "TRIAGLE.out");
	fastio();

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

	int dp[n + 1];

	dp[0] = 0;
	dp[1] = dp[0] + abs(h[1] - h[0]);

	for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}

	cout << dp[n - 1];
}


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

int main() {
  map<int, int> h;
  int N, M, A, B, x = 0;
  long long H;
  cin >> N >> M;
  vector<int> m(N, 1);
  for (int i = 0;i < N;i++) {
    cin >> H;
    h[i] = H;
  }
  for (int i = 0;i < M;i++) {
    cin >> A >> B;
    if (h.at(A - 1) < h.at(B - 1)) {
      m[A - 1] = 0;
    } else if (h.at(A - 1) > h.at(B - 1)) {
      m[B - 1] = 0;
    } else {
      m[A - 1] = 0;
      m[B - 1] = 0;
    }
  }
  for (int i = 0;i < N;i++) {
    x = x + m[i];
  }
  cout << x << endl;
}





Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n, r;
	while (cin >> n >> r, n + r != 0) {
		vector<int> cards(n);
		for (int i = 0; i < n; i++) {
			cards[i] = i + 1;
		}
		for (int i = 0; i < r; i++) {
			int p, c;
			cin >> p >> c;
			for (int j = 0; j < c; j++) {
				cards.push_back(cards[n - (p - 1 + c)]);
				cards.erase(cards.end() - (p + c));
			}
		}
		cout << cards[n - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int minmp=intMAX;
int n,a,b,c;
void search(vector<int> l,int nowmp){
  int size=l.size();
  //cout<<"w";
  rep(i,size)rep(j,size)rep(k,size){
    if(i!=j && j!=k && k!=i){
      minmp=min(minmp,nowmp+(int)abs(a-l[i])+(int)abs(b-l[j])+(int)abs(c-l[k]));
    }
  }
  if(size>3){
    rep(i,size-1){
      for(int j=i+1;j<size;j++){
        int tmp = l[i];
        vi tmpv=l;
        l[j]+=tmp;
        l.erase(l.begin()+i);
        search(l,nowmp+10);
        l=tmpv;
      }
    }
  }
  return;
}
int main(void){
  cin>>n>>a>>b>>c;
  vi l(n);
  rep(i,n){
    cin>>l[i];
  }
  //sort(l.begin(),l.end());
  search(l,0);
  cout<<minmp<<endl;
  return 0;
}

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

int main() {
	map<string,int> data;
	string n;
	while (cin >> n) 
		data[n]++;
	
	//出現頻度が最も多い単語
	int max = 0;
	string maxt;
	map<string,int>::iterator it = data.begin();
	for ( ; it != data.end(); it++ ) {
		if ( (*it).second > max ){
			max = (*it).second;
			maxt = (*it).first;
		}
	}
	cout << maxt << " ";
		
	max = 0;
	//文字数が最も多い単語
	for ( it = data.begin(); it != data.end(); it++ ) {
		if ( (*it).first.size() > max ){
			max = (*it).first.size();
			maxt = (*it).first;
		}
	}
	cout << maxt << endl;
}

Measured memory_bytes: 1196
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 


int main(void){
    ll n,k;
    cin>>n>>k;
    vector<ll>x(n),pl,mi;
    for(ll i=0;i<n;i++){
        cin>>x[i];
        if(x[i]<0)mi.push_back(x[i]);
        if(x[i]>0)pl.push_back(x[i]);
        if(x[i]==0)k--,n--;
    }
    ll psize = pl.size();
    ll msize = mi.size();
    if(k==0){
        cout<<0<<endl;
        return 0;
    }
    if(psize==n){
        cout<<x[k-1]<<endl;
    }
    else{
        if(msize==n){
            cout<<-x[n-k]<<endl;
        }
        else{
            ll ans = (ll)INF;
            for(ll i=0;i<psize;i++){
                ll num = k-(i+1);
                if(msize<num)continue;
                else{
                    if(num<=0)continue;
                    ll d = 2*pl[i]-mi[msize-num];
                    ans = min(ans,d);
                }
            }
            for(ll i= msize-1;i>=0;i--){
                ll num = msize-i;
                if(k-num>psize)continue;
                else{
                    if(num<=0)continue;
                    ll d = -2*mi[i]+pl[k-num-1];
                    ans = min(ans,d);
                }
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}



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


int main() {
    string s1,s2,s3;
    locale loc;
    cin>>s1>>s2>>s3;
    cout<<toupper(s1[0],loc)<<toupper(s2[0],loc)<<toupper(s3[0],loc);
    return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s1 = buf.trim().chars().collect::<Vec<char>>().clone();
	let iter = s1.iter().rev();
	let mut s:Vec<char> = Vec::new();
	for c in iter {
		s.push(*c);
	}
	let mut ret = Vec::new();
	loop {
		match s.pop() {
			Some(c) => {
				if c == '0' {
					ret.push(c);
				}else if c == '1' {
					ret.push(c);
				}else{
					ret.pop();
				};
			},
			None => {
				break;
			},
		}
	}
	for c in ret {
		print!("{}", c);
	}
	println!("");
}

Measured memory_bytes: 4352
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;cin>>x;
    cout<<x*x*x+x*x+x<<"\n";
}


Measured memory_bytes: 3556
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int a = cin.nextInt();
		int b = cin.nextInt();
		int c = cin.nextInt();
		if (a == 5)
		{
			if ((b == 5 && c == 7) || (b == 7 && c == 5))
			{
				Console.WriteLine("YES");
			}
			else
			{
				Console.WriteLine("NO");
			}
		}
		else if (a == 7)
		{
			if (b == 5 && c == 5)
			{
				Console.WriteLine("YES");
			}
			else
			{
				Console.WriteLine("NO");
			}
		}
		else
		{
			Console.WriteLine("NO");
		}
	}

	int compare(Pair a, Pair b)
	{
		if (a.Value < b.Value) return 1;
		else if (a.Value > b.Value) return -1;
		else return 0;
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

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

int main(void)
{
  int a,b,c,x;
  cin >> a >> b >> c;
  if (a>b)
    {x=a;  a=b;  b=x;}
  if (b>c)
    {x=b;  b=c;  c=x;}
  if (a>b)
    {x=a;  a=b;  b=x;}
  cout << a << " " << b << " " << c << endl;
  return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"OK":"NG");
}
int main() {
  int k;cin>>k;
  int a,b;cin>>a>>b;
  int ans=(a+k-1)/k*k;
  cout<<outputYesNo(ans<=b)<<endl;
  return 0;
}


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


int main(){
 

 ll l,r,n;
 cin>>l>>r>>n;
 ll ans=r/n-l/n;
 if(l%n==0)
 ans++;

 cout<<ans;
 
    return 0;
}
    


Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define endl                         '\n'	
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define vi                    vector<int>
#define fr(x,y) for(int x=0; x<(y); ++x)
#define fr2(x,z,y) for(int x=z; x<(y); ++x)
#define Rabee_Adel          file();
const double PI = acos(-1), EPS = 1e-7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x%y); }
ll lcm(ll x, ll y) { return ((x / gcd(x, y))*y); }
ll mod = 998244353;
ll power(ll x, ll y){if (y == 0)return 1;if (y == 1)return x;ll r = power(x, y / 2) % mod;return r%mod*r%mod*power(x, y % 2) % mod;}
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
int main()
{
	
	Rabee_Adel
		int n, m;
	cin >> n >> m;
	if (m >= n)
		cout << "unsafe"; 
	else cout << "safe";
	 
}

Measured memory_bytes: 3644
import java.util.*;

class Main {
    int heap[];
    int pos;
    int size;

    public Main() {
        this.heap = new int[2000000];
        this.size = 2000000;
        this.pos = 0;
    }

    void heapify(int i) {
        int leftchild = (2*i) + 1;
        int rightchild = (2*i) + 2;
        int parent = i;

        if (leftchild < this.pos && heap[parent] < heap[leftchild]) {
            parent = leftchild;
        }
        if (rightchild < this.pos && heap[parent] < heap[rightchild]) {
            parent = rightchild;
        }
        if(parent != i) {
            int temp = heap[i];
            heap[i] = heap[parent];
            heap[parent] = temp;
            heapify(parent);
        }

    }

    void insert(int value) {
        this.heap[pos] = value;
        boolean isHeap = false;
        int i = pos;
        while(i > 0 && !isHeap) {
            int j = (i-1)/2;
            if (heap[i] > heap[j]) {
                int temp = heap[i];
                heap[i] = heap[j];
                heap[j] = temp;
            } else {
                isHeap = true;
            }
            i = j;
        }
        pos++;
    }

    int remove() {
        if (pos > 0) {
            int removed = heap[0];
            heap[0] = heap[pos-1];
            heapify(0);
            pos--;
            return removed;
        }
        return 0;
    }


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

            Main heap = new Main();

            String operation = in.next();

            while (!operation.equals("end")) {
                
                if (operation.charAt(0) == 'i') {
                    int number = in.nextInt();
                    heap.insert(number);
                } else {
                    int removed = heap.remove();
                    System.out.println(removed);
                }
                operation = in.next();
            }
        }
}



Measured memory_bytes: 555008
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int AB = 26;
	public static void main(String[] args) {
		long i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		long x = parseLong(sc.next());
		sc.close();
		long tmp = 0;
		for (i = 1; i <= x; i++) {
			tmp+=i;
			if(tmp>=x) {
				break;
			}
		}
		out.println(i);
	}
}


Measured memory_bytes: 23636
package main

import "fmt"

func main() {
  var a, b, c int
    fmt.Scanf("%d %d %d", &a, &b, &c)

    l := 100*a + 10*b + c

    if (l % 4 == 0) {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-

def main(N, H):
    count = 1
    max = H[0]
    for i in range(1, N):
        if(H[i]>=max):
            count += 1
            max = H[i]
            
    print(count)

if __name__ == '__main__':
    N = int(input())
    H = [int(h) for h in input().split()]
    
    main(N, H)

Measured memory_bytes: 3060
using System.Linq;
using static System.Math;
using System;

public class P
{
    public long a { get; set; }
    public int b { get; set; }
}

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var ps = new P[n];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            ps[i] = new P { a = long.Parse(line[0]), b = int.Parse(line[1]) };
        }
        var ps2 = ps.OrderBy(x => x.a).ToArray();
        var b = new long[n + 1];
        for (int i = 1; i <= n; i++)
            b[i] = ps2[i - 1].b + b[i - 1];
        var ans = getAns(ps2, b, n);
        Console.WriteLine(ans);
    }
    static long getAns(P[] ps, long[] b, int n)
    {
        var ans = 0L; var tmax = 0L; var tmin = long.MaxValue;
        for (int j = 0; j < n; j++)
        {
            tmin = Min(tmin, b[j] - ps[j].a);
            tmax = b[j + 1] - ps[j].a;
            ans = Max(ans, tmax - tmin);
        }
        return ans;
    }
}



Measured memory_bytes: 64628
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			char[] c=sc.next().toCharArray();
			int[] a=new int[c.length];
			for(int i=0;i<c.length;i++){
				a[i]=Integer.parseInt(c[i]+"");
			}
			System.out.println(bottom(a));
		}
	}
	static int bottom(int[] a){
		if(a.length-1==0){
			return a[0];
		}else{
			int[] b=new int[a.length-1];
			for(int i=0;i<a.length-1;i++){
				b[i]=a[i]+a[i+1]-(a[i]+a[i+1])/10*10;
			}
			return bottom(b);
		}
	}
}

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

#define int long long

int powmod(int a, int n, int mod){
	int r = 1;
	while(n){
		if(n & 1) (r *= a) %= mod;
		(a *= a) %= mod;
		n >>= 1;
	}
	return r;
}

signed main(){
	int n;
	cin >> n;
	int a[n], c[n] = {};
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(((a[i] & 1) == (n & 1)) || (++c[a[i]] > 2)){
			cout << 0 << endl;
			return 0;
		}
	}
	if(c[0] >= 2){
		cout << 0 << endl;
		return 0;
	}
	cout << powmod(2, n / 2, 1e9 + 7) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


int cnt[100100];
int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n){
    cin >>a[i];
    cnt[a[i]]++;
  }
  rep(i,n){
    if(cnt[i] == 2) continue;
    else if(cnt[i] == 0) continue;
    else if(cnt[i] == 1 && n%2 && i==0)continue;
    else{
      cout<<0<<endl;
      return 0;
    }
  }
  
  int m = (n/2);
  mint ans=1;
  rep(i,m) ans*=2;
  cout<<ans.x<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    int temp=n;
    int sum=0;
    while(temp>0){
    	sum+=temp%10;
    	temp/=10;
    }
    (n%sum==0)?cout<<"Yes":cout<<"No";
   return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
int main () {
    ll x ;
    cin >> x;
    ll t = 100;
    ll year = 0;
    while(t < x){
        t *= 1.01;
        year++ ;
    }
    cout << year << endl;

}

Measured memory_bytes: 3596
#include<stdio.h>
int main(){
int ary[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  scanf("%d",&K);
  printf("%d\n",ary[K-1]);
  return 0;
}

Measured memory_bytes: 128
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

ll N;
ll A, B;
vector<int> X(100010);

int main(){
  cin >> N >> A >> B;
  X.resize(N);
  rep(i, N){
    cin >> X[i];
  }
  ll ans = 0;
  rep(i, N-1){
    ans += min(B, A * (X[i+1] - X[i]));
  }
  cout << ans << endl;

}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	string S;
	cin >> S;

	for (int i = 0; i <= S.length() - 1; i++) {
		if (i % 2 == 0 && S[i] == 'R');
		else if (i % 2 == 0 && S[i] == 'U');
		else if (i % 2 == 0 && S[i] == 'D');
		else if (i % 2 == 1 && S[i] == 'L');
		else if (i % 2 == 1 && S[i] == 'U');
		else if (i % 2 == 1 && S[i] == 'D');
		else { cout << "No"; return 0; }
	}
	cout << "Yes";
}


Measured memory_bytes: 256
// Phoenix

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=1e5+10,mod=1e9+7;
const ll inf=1e18;

map<pll,ll> mp;

ll f(ll y,ll x){
    if(mp.count({x,y})) return mp[{x,y}];
    if(x%(y-x)==0) return mp[{x,y}]=2*x;
    return mp[{x,y}]=(y-x)*(2*(x/(y-x))+1)+(y%(y-x))+f(y-x,y-x-(y%(y-x)));
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll y,x;cin>>y>>x;
    cout<<x+f(y,x)<<endl;
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main(){
    string S;
    cin >> S;
    if(S == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, W; cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(N+1, vector<ll>(1e6+1, INF*2));
    dp[0][0] = 0;
    rep(i, N) {
        rep(j, 1e6+1) {
            // i番目までの品物で，価値の総和がj以下となる時の重さの総和の最小値
            // if (j+v[i]<=W)
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
        }
    }
    int ans = 0;
    rep(i, N+1) rep(j, 1e6) {
        if (dp[i][j] > W) continue;
        chmax(ans, j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 797440
#include "bits/stdc++.h"
using namespace std;


/* macro */
//#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */



signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    
    string t = raw_input();

    if(t[0] == '9' || t[1] == '9'){
        print("Yes");
    }else{
        print("No");
    }

    

    
    




    
    



    
    

    







   




    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

int main(){
  int a,b;
  cin >> a >> b;
  double ret=0;
  rep(i,a){
    double tmp=1.0/a;
    int now=i+1;
    while(now<b){
      now*=2;
      tmp/=2;
    }
    ret+=tmp;
  }
  printf("%.12f\n",ret);
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args){
	try{
	    BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
	    double x=0.0, y=0.0;
	    int t = 0;
	    while(true){
		String st = sc.readLine();
		if(st.equals("0,0"))
		    break;
		String[] s = st.split(",");
		int d = Integer.valueOf(s[0]);
		double deg = Math.toRadians(t);
		x += d*Math.sin(deg);
		y += d*Math.cos(deg);
		t += Integer.valueOf(s[1]);
	    }
	    System.out.printf("%d\n%d\n",(int)x,(int)y);
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
ll m, a, r, c, h;
int main(){
    int n;
    cin >> n;
    rep(i, n){
        string s;
        cin >> s;
        if(s[0]=='M'){
		    m++;
        }
		if(s[0]=='A'){
            a++;
        }
		if(s[0]=='R'){
		    r++;
        }
        if(s[0]=='C'){
		    c++;
        }
		if(s[0]=='H'){
		    h++;
        }
    }
    cout << m * a * h + m * a * c + m * a * r + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <sstream>
#include <string>
#include <time.h>
#include <math.h>
#include <set>

using namespace std;

int main() {
  int n;
  set<int> st;
  cin >> n;
  int a;
  for(int i=0;i<n;i++) {
    cin >> a;
    st.insert(a);
  }
  a = st.size();
  if(a%2==1) {
    cout << a << endl;
  }else{
    cout << a-1 << endl;
  }
}

Measured memory_bytes: 4864
#include<stdio.h>
int main(){
  int K,N,i,min;
  scanf("%d%d",&K,&N);
  int A[N+1];
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);
  min=A[N-1]-A[0];
  for(i=0;i<N-1;i++)
    if(K-A[i+1]+A[i]<min)
      min=K-A[i+1]+A[i];
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

int main() {
	int i, a[1000000], k,n , cnt = 0;

	scanf("%d %d", &n, &k);

	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	for (i = 0; i <n; i++) {
		if (a[i] >= k) {
			cnt++;
		}
	}

	printf("%d\n", cnt);

	return 0;
}

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

N = int(input())
tak, aok = 1, 1
for _ in range(N):
    T, A = map(int, input().split())
    if T == A:
        tak = aok = max(tak, aok)
    else:
        f = (tak + T - 1) // T
        t = f * T
        a = f * A
        if a >= aok:
            tak = t
            aok = a
        else:
            f = (aok + A - 1) // A
            tak = f * T
            aok = f * A
print(tak + aok)


Measured memory_bytes: 38576
#include <iostream>

using namespace std;

int main() {
    int a,b,x,y,z;
    cin>>a>>b;
    x=a+b;
    y=a-b;
    z=a*b;
    if(x>y && x>z){
        cout<<x;
    }else if(y>z){
        cout<<y;
    }else{
        cout<<z;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    n, m, x = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(m):
        if a[i] > x:
            ans = min(i, len(a) - i)
            break
    else:
        ans = 0
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9116
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;



int max(int a,int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int a, b, c;
	int x;
	cin >> a >> b >> c >> x;

	int count = 0;

	rep(i, a+1) {
		rep(j, b+1) {
			rep(k, c+1) {
				int res = 500 * i + 100 * j + 50 * k;
				if (res == x) {
					++count;
				}
			}
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 256
from collections import Counter

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


if N % 2 == 0:
    for key, value in A.items():
        if key % 2 != 1:
            print(0)
            exit()
    for i in range(1, N, 2):
        if A[i] != 2:
            print(0)
            exit()
    print(pow(2, N//2, mod))
else:
    if A[0] != 1:
        print(0)
        exit()
    for key, value in A.items():
        if key % 2 != 0:
            print(0)
            exit()
    for i in range(2, N, 2):
        if A[i] != 2:
            print(0)
            exit()
    print(pow(2, N // 2, mod))



Measured memory_bytes: 55532
#include<iostream>
#include<vector>
#include <queue>
#include<algorithm>
#define rep(i,n) for(int i(0);i<n;++i)
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        if(a>m) continue;
        jobs[m-a].push_back(b);
    }
    priority_queue<int> q;
    ll ans = 0;
    for(int i(m-1); i >=0; --i){
        for(int b : jobs[i]){
            q.push(b);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
const int maxn = 55;
char s[maxn];
int n;
const char c[] = {"ABC"};
int main() {
	scanf("%d" , &n);
	scanf("%s" , s + 1);
	int cnt = 0;
	for(register int i = 1; i <= n - 2; ++i) {
		int ok = 1;
		for(register int j = 0; j < 3; ++j)
			if(s[i + j] != c[j]) {
				ok = 0;
				break;
			}
		cnt += ok;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;


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

	deque<int>b;
	rep(i, 0, n) {
		int x;
		cin >> x;
		if (i%2==0) {
			b.push_back(x);
		}
		else {
			b.push_front(x);
		}
	}


	
	if (n % 2 == 0) {
		cout << b[0];
		for (int i = 1; i < n; i++) {
			cout << " " << b[i];
		}
	}
	else {
		cout << b[n - 1];
		for (int i = n - 2; i >= 0; i--) {
			cout << " " << b[i];
		}
	}
	cout << endl;





	return 0;
}


Measured memory_bytes: 2944
#include<iostream>

using namespace std;

int main(){
    int N,D,ans;
    cin >> N >> D ;
    
    if (N%(D*2+1)==0){
        cout << N/(D*2+1) << endl;
    }
    else{
        cout << N/(D*2+1) + 1 << endl;
    }
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll H,N,A[101010];
ll i, j, k;
int main(){
    scanf("%lld%lld", &H, &N);

    fornum(i,0,N){
        scanf("%lld", &A[i]);
        H -= A[i];
    }
    if(H<=0){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a,b,n;
signed main(){
	cin>>a>>b>>n;
	int c=min(n,b-1);
	cout<<(a*c/b);
	return 0;
}


Measured memory_bytes: 3604
# coding: utf-8


def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    A = sorted(A, reverse=True)

    if A[m-1] >= sum(A) / (4*m):
        return "Yes"
    else:
        return "No"


print(main())


Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);

struct UnionFind {
    vector<int> par;
    vector<int> siz;
    UnionFind(int N) : par(N), siz(N, 1) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }

    bool issame(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return siz[root(x)];
    }
};


int main() {
    ios_base::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;
    UnionFind tree(n);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        tree.unite(a-1,b-1);
    }
    set<int> st;
    rep(i,n) st.insert(tree.root(i));
    cout << st.size()-1 << endl;

    return 0;
}


Measured memory_bytes: 7772
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {
    def main(args: Array[String]): Unit = { 
        digit(readLine.split(" ").map(_.toInt).sum)
    }
    
    @tailrec
    def digit(n: Int): Unit = {
       println(n.toString.length)
       val next: String = readLine
       if(next == null) Unit else digit(next.split(" ").map(_.toInt).sum)
    }
}

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

int main() {
	int n,x; cin >> n >> x;
	vint l(n);
	int d=0,ans=1;
	rep(i,n) {
		cin >> l[i];
		d+=l[i];
		if(d<=x) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mxsize (int)1e6
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
void yn(bool check){
    if(check)	cout<<"YES\n";
    else		cout<<"NO\n";
}
void fun(){
    int n;
    cin>>n;
    if(n>=30)
        cout<<"Yes\n";
    else cout<<"No\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
typedef vector<ll> vecll;
const ll inf =1000000007;

void solve(){
    string s;
    cin >> s;
    ll n=s.size();
    ll d0[n],d1[n];
    d0[0]=min((s[0]-'0'),1+10-(s[0]-'0'));
    d1[0]=min(1+9-(s[0]-'0'),s[0]-'0'+1);

    for(ll i=1;i<n-1;i++){
        d0[i]=min(d0[i-1]+(s[i]-'0'),d1[i-1]+10-(s[i]-'0'));
        d1[i]=min(d1[i-1]+9-(s[i]-'0'),d0[i-1]+1+(s[i]-'0'));
    }
    if(n>=2){
        d0[n-1]=min(d0[n-2]+(s[n-1]-'0'),d1[n-2]+10-(s[n-1]-'0'));
    }
    kaku(d0[n-1]);
}

int main(){
    solve();
}

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

int main(){
int a,b,angle;
  cin>>a>>b>>angle;
  double s,l,h;
  s=a*b*sin(angle*2*M_PI/360)/2;
 double c;
  c=sqrt(a*a+b*b-2*a*b*cos(angle*2*M_PI/360));
  l=a+b+c;
  h=b*sin(angle*2*M_PI/360);
   cout << fixed << setprecision(10);
  cout<<s<<endl<<l<<endl<<h<<endl;
}


Measured memory_bytes: 3636
s=int(input())
ans=[]
ans.append(s)
temp=0
while temp==0:
  if s%2==0:
    s=int(s/2)
    ans.append(s)
  else:
    s=s*3+1
    ans.append(s)
  for i in range(0,len(ans)-1):
    if ans[i]==ans[len(ans)-1]:
      print(len(ans))
      temp=1
      break

Measured memory_bytes: 3064