akhauriyash/Code-Regression huggingface dataset:
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

template <typename T>
struct SegTree {
  ll n, ofst;
  vector<T> arr;

  SegTree(const ll _n) {
    n = 1;
    while (n < 2 * _n) n <<= 1;
    arr.resize(n, 0);
    ofst = n >> 1;
  }

  void update(ll i, T x) {
    i += ofst;
    arr[i] = x;
    while (true) {
      i /= 2;
      if (i == 0) break;
      arr[i] = min(arr[2 * i], arr[2 * i + 1]);
    }
  }

  T get(ll l, ll r) {
    T ret = INF;
    l += ofst, r += ofst + 1;
    while (l < r) {
      if (l % 2 == 1) {
        chmin(ret, arr[l]);
        l++;
      }
      l /= 2;
      if (r % 2 == 1) {
        chmin(ret, arr[r - 1]);
        r--;
      }
      r /= 2;
    }
    return ret;
  }
};

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, x;
  cin >> n >> x;

  SegTree<ll> st(2*n);

  rep(i, n) {
    ll a;
    cin >> a;
    st.update(i, a);
    st.update(n + i, a);
  }

  ll ans = INF;
  rep(i, n) {
    ll tmp = 0;
    rep(j, n) {
      tmp += st.get(n + j - i, n + j);
    }
    chmin(ans, tmp + i*x);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int mat[100][100];

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

  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      cout << mat[i][j];
      if(j!=n-1){
        cout << " " ;
      }else{
        cout << endl ;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }else{
                for(int n = 0; n < W; n++){
                    System.out.print("#");
                }
                System.out.println("");
                for(int j = 0; j < H-2; j++){
                    System.out.print("#");
                    for(int k = 0; k < W-2;k++){
                        System.out.print(".");
                    }
                    System.out.println("#");
                }
                for(int n = 0; n < W; n++){
                    System.out.print("#");
                }
                System.out.println("");
                System.out.println("");
            }
        }
    }
}


Measured memory_bytes: 37008
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
long long a,b,c,d,e,f;
scanf("%lld %lld %lld",&c,&a,&b);
//if (abs(c-a)<=d || abs (b-a)<=d && abs (c-b)<=d)
/*if ((a*b)%2==0)
printf("Even");
else
printf("Odd");*/

if (c>=a) c=c-a;
printf("%lld",c%b);
//else printf("%lld",f);
}


Measured memory_bytes: 1700
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define vec(a,b) b-a
#define Reka ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int n;
int cost[999999];
int c[999999];
int x;
int jump(int ind)
{
    if(ind == n-1)
        return c[ind] = 0 ;
    if(c[ind]!=-1)
        return c[ind];

    int r=1e9,ans=1e9;

    for(int i = 1;i<=x;i++){
        if(ind+i < n ){
         r = jump(ind+i)+abs(cost[ind]-cost[ind+i]);
         ans = min(ans,r);
        }
        else
            break;
    }
    return c[ind] = ans;
}

int main()
{
    Reka
    memset(c,-1,sizeof(c));
   cin>>n>>x;
   for(int i=0;i<n;i++)
   {
       cin>>cost[i];
   }
cout<<jump(0);
   return 0;
}


Measured memory_bytes: 11136
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int a, b, n;
    cin >> a >> b >> n;
    
    cout << a*min(n, b-1)/b << "\n";
    
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string S,T;
	cin>>S>>T;
	string ans="";
	fx(S.size()){
		ans+=S.at(x);
		if(x<T.size()){
			ans+=T.at(x);
		}
	}
	ce(ans)
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	while (true)
	{
		int N;
		cin >> N;
		if (N == 0)break;

		int M;
		cin >> M;

		vector<pair<int, int>> V(M);
		for (int i = 0; i < M; i++)
		{
			int x, y;
			cin >> x >> y;
			V[i] = make_pair(x, y);
		}
		vector<int> S(M - 1);
		for (int i = 0; i < M - 1; i++)
		{
			S[i] = V[i + 1].first + V[i + 1].second - V[i].first - V[i].second;
			//cout << " " << S[i];
		}
		//cout << endl;

		bool B = (V[0].first == V[1].first);
		int ans = 0;

		for (int i = 0; i < N; i++)
		{
			int m;
			cin >> m;
			vector<pair<int, int>> v(m);
			for (int j = 0; j < m; j++)
			{
				int x, y;
				cin >> x >> y;
				v[j] = make_pair(x, y);
			}
			if (m != M)continue;
			vector<int> s(m - 1);
			for (int j = 0; j < m - 1; j++)
			{
				s[j] = v[j + 1].first + v[j + 1].second - v[j].first - v[j].second;
				//cout << " " << s[j];
			}
			//cout << endl;

			bool ans = false;
			for (int k = 0; k < 2; k++)
			{
				bool b = (v[0].first == v[1].first);
				if (B == b)
				{
					int dx[] = { 1,-1 };
					int dy[] = { 1,-1 };
					bool flag = true;
					for (int r = 0; r < 2; r++)
					{
						flag = true;
						for (int j = 0; j < M - 1; j++)
						{
							if (j % 2 == 0 && S[j] != s[j] * dx[r])
							{
								flag = false;
								break;
							}
							else if (j % 2 == 1 && S[j] != s[j] * dy[r])
							{
								flag = false;
								break;
							}
						}
						if (flag)
						{
							ans = true;
						}
					}
				}
				else
				{
					int dx[] = { 1,-1 };
					int dy[] = { -1,1 };
					bool flag = true;
					for (int r = 0; r < 2; r++)
					{
						flag = true;
						for (int j = 0; j < M - 1; j++)
						{
							if (j % 2 == 0 && S[j] != s[j] * dx[r])
							{
								flag = false;
								break;
							}
							else if (j % 2 == 1 && S[j] != s[j] * dy[r])
							{
								flag = false;
								break;
							}
						}
						if (flag)
						{
							ans = true;
						}
					}
				}

				reverse(all(s));
				reverse(all(v));
			}
			
			if (ans)cout << (i + 1) << endl;

		}

		cout << "+++++" << endl;

	}
}

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


Measured memory_bytes: 3036
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int counter = sc.nextInt();
    int[] member = new int[counter];
    char[] memchar = sc.next().toCharArray();
    
    int start = 0;
    for(int i = 0;i<counter;i++){
      member[i] = (memchar[i] == 'E')?0:1;
      if(member[i] == 0)start ++;
    }
    
    int answer = 300000;
    for(int i = 0;i<counter;i++){
      if(member[i] == 0) start--;
      if(i!=0){
        if(member[i-1] == 1)start ++;
      }
      if(start < answer) answer = start;
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 31108
package main

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

func nextLine(r *bufio.Reader) string {
	var buf []byte
	for {
		line, isPrefix, err := r.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func nextStr(s *bufio.Scanner) string {
	s.Scan()
	ref := s.Bytes()
	cp := make([]byte, len(ref))
	copy(cp, ref)
	return string(cp)
}

func nextInt(s *bufio.Scanner) int {
	n, err := strconv.Atoi(nextStr(s))
	if err != nil {
		panic(err)
	}
	return n
}

func nextInt64(s *bufio.Scanner) int64 {
	n, err := strconv.ParseInt(nextStr(s), 0, 64)
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	// r := bufio.NewReader(os.Stdin)
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	N := nextInt(s)
	K := nextInt(s)
	nums := make([]int, N)
	for i := 0; i < N; i++ {
		nums[i] = nextInt(s)
	}
	sort.Ints(nums)
	sum := 0
	for i := 0; i < K; i++ {
		sum += nums[i]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
// Author : Pham Ngoc Minh - 12 Tin - CTB
// The Way To Progress Is To Constantly Try
using namespace std;
#define f first
#define s second
#define ll long long
#define fl float
#define db double
#define mp make_pair
#define pb push_back
#define sz size()
#define len length()
#define ii pair<ll,ll>
#define pii pair<ii,ii>
#define ford(i,a,b) for(ll i=a;i<=b;i++)
#define foru(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,a,b) for(int i=a;i<b;i++)
#define oo 10000000000001
#define ooo -1000000000001
#define bost  ios_base::sync_with_stdio(false); cin.tie(0);
int const maxn=1e5+5;
int const maxp=200005;
ii a[maxn];
ll lt[maxp],nlt[maxp],dp[maxn];
int n,m,k;
ll mod=1e9+7;
bool check(const ii& u,const ii& v)
{
    if(u.f>=v.f && u.s>=v.s)
        return true;
    return false;
}
void tinh(ll& x, ll y)
{
    x-=y;
    if(x>=mod)
        x-=mod;
    if(x<0)
        x+=mod;
}
ll luythua(ll a,ll n)
{
    if(n==0)
        return 1;
    if(n&1)
        return a*luythua(a,n-1)%mod;
    else
    {
        ll x=luythua(a,n>>1);
        x=(x*x)%mod;
        return x;
    }
}
ll nCk(int n, int k)
{
    return (lt[n]*nlt[k]%mod)*nlt[n - k]%mod;
}
int main()
{
    bost
    cin>>m>>n>>k;
    ford(i,1,k)
    {
        cin>>a[i].f>>a[i].s;
    }
    k++;
    a[k].f=m;
    a[k].s=n;
    sort(a+1,a+k+1);
    lt[0]=lt[1]=nlt[0]=nlt[1]=1;
    ford(i,2,200000)
    {
        lt[i]=(1ll*lt[i-1]*i)%mod;
        nlt[i]=luythua(lt[i],mod-2);
    }
    ford(i,1,k)
    {
        dp[i]=nCk(a[i].f+a[i].s-2,a[i].f-1);
        ford(j,1,i-1)
        {
            if(check(a[i],a[j]))
                tinh(dp[i],dp[j]*nCk(a[i].f+a[i].s-a[j].f-a[j].s,a[i].f-a[j].f)%mod);
        }
    }
    cout<<dp[k];
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

bool comp(pair<int,int> a,pair<int,int> b){
	if(a.first != b.first)return a.first < b.first;
	else return a.second < b.second;
}

int main(){
	int n,m;
	cin >> n >> m;
	vector<vector<pair<int,int>>> y(n);
	vector<string> num(m);
	for(int i=0;i<m;++i){
		int p,yy;
		cin >> p >> yy;
		y[p-1].push_back(make_pair(yy,i));
	}
	for(int i=0;i<n;++i){
		sort(y[i].begin(),y[i].end(),comp);
		for(int j=0;j<y[i].size();++j){
			string f = to_string(i+1);
			string s = to_string(j+1);
			for(int k=0;k<6-f.length();++k)num[y[i][j].second] += '0';
			num[y[i][j].second] += f;
			for(int k=0;k<6-s.length();++k)num[y[i][j].second] += '0';
			num[y[i][j].second] += s;
		}
	}
	
	for(int i=0;i<m;++i){
		cout << num[i] << endl;
	}
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

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

    int X = N;
    int sum = 0;
    while(N/10 != 0){
        sum+=N%10;
        N/=10;
    }
    sum+=N;

    if(X%sum == 0) cout <<"Yes"<< endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main() {
  int x, num[100] = {0};

  while(scanf("%d", &x) != EOF) {
    num[x - 1] += 1;
  }

  int i, max = 100, flg = 0;
  while(flg == 0) {
    for(i = 0; i < 100; i ++) {
      if(max == num[i]) {
	printf("%d\n", i + 1);
	flg = 1;
      }
    }

    max --;
  }

  return 0;
}

Measured memory_bytes: 0
import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline

MOD = 1000000007

I = lambda : int(input())
M = lambda : map(int, input().split())
Ms = lambda : map(str, input().split()) 
ARR = lambda : list(map(int, input().split()))

def distance(a, b):
    return a**2 + b**2

def main():
    n, d = M()
    d *= d
    ans = 0
    for _ in range(n):
        x, y = M()
        if distance(x, y) <= d:
            ans += 1
    print(ans)


# testcases
tc = 1
for _ in range(tc):
    main()

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

int main() {
   int D;
   cin >> D;
   switch (D) {
      case 22:
         cout << "Christmas Eve Eve Eve";
         break;
      case 23:
         cout << "Christmas Eve Eve";
         break;
      case 24:
         cout << "Christmas Eve";
         break;
      case 25:
         cout << "Christmas";
         break;
   }
   cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){

    string s[] = {"the","this","that"};
    string in;
    while(true){
	getline(cin,in);
	if(cin.eof()) break;
	bool f = false;
	int d = 1;
	REP(i,30){

	    f = true;
	    REP(i,in.size()){
		if(in[i] == '.' || in[i] == ' ' || in[i] == '\n') continue;
		in[i]= (char)( 'a' + ( (int)(in[i] - 'a') + d) % 26);
	    }
	    vector<bool> flgs(3,false);
	    REP(j,3){
		if(in.substr(0,s[j].size()) == s[j] && in[s[j].size()] == ' ') flgs[j] = true;
	    }
	    for(int i=0;i<in.size();i++){
		if(in[i] == ' '){
		    REP(j,3){
			if(in.substr(i+1,s[j].size()) == s[j] && in[i + s[j].size() + 1] == ' ') flgs[j] = true;
		    }
		}
	    }
	    if(flgs[0] || flgs[1] || flgs[2]) break;
	}
	cout << in << endl;
    }

    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

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

    vector<double> E(n+1, 0);
    double ans = -1;
    rep(i, 0, n)
    {
        double p;
        cin >> p;
        double exp = (p + 1.0) / 2.0;
        E[i] += exp;
        if (i+k <= n) E[i+k] -= exp; 
    }

    rep(i, 0, n)
    {
        E[i+1] += E[i];
    }

    sort(E.begin(), E.end());
    reverse(E.begin(), E.end());

    cout << fixed<<setprecision(10)<<E[0] << endl;
}


Measured memory_bytes: 1792
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "Yes";
const string NO = "No";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(std::string s){
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes\n";
    else
        cout << "No\n";
}


signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;
int a[100100], b[100100], c[100100];
ll g[100100], f[100100], h[100100];
int main(){
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", a + i);
	for(int i = 1; i <= n; i++) scanf("%d", b + i);
	for(int i = 1; i <= n; i++) scanf("%d", c + i);	 
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + n);
	sort(c + 1, c + 1 + n);
	for(int i = 1; i <= n; i++) g[i] = 1;
	for(int i = 1; i <= n; i++) g[i] += g[i - 1];
	for(int i = 1; i <= n; i++)	{
		int p = lower_bound(a + 1, a + 1 + n, b[i]) - a; f[i] = g[p - 1];
	}
	for(int i = 1; i <= n; i++) f[i] += f[i - 1];
	for(int i = 1; i <= n; i++) {
		int p = lower_bound(b + 1, b + 1 + n, c[i]) - b; h[i] = f[p - 1];
	}
	for(int i = 1; i <= n ; i++) h[i] += h[i - 1];
	printf("%lld\n", h[n]);
}


Measured memory_bytes: 3712
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 日  8/20 20:01:46 2017
 *Ended  Time*  : 日  8/20 20:11:09 2017
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const int MaxN = 1e5;
int n;
int a[MaxN + 5];
LL ans = 0;
LL Max1, Max2;

int main()
{
    while(~scanf("%d", &n)){
        for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
        sort(a + 1, a + 1 + n);
        for(int i = n; i >= 1; i--){
            int cnt = 1;
            while(a[i - 1] == a[i] && i >= 1){
                cnt++;
                i--;
            }
            if(cnt >= 4) ans = max(ans, (LL)a[i] * a[i]);
            if(cnt >= 2){
                if(Max1 == 0) Max1 = a[i];
                else Max2 = a[i];
            }
            if(Max1 && Max2) break;
        }
        printf("%lld\n", max(ans, Max1 * Max2));
    }
    
    return 0;
}


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

using namespace std;

int frog2dp(int h[], int n, int k){
    int dp[n+1];
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    //int min = 0;
    for(int i = 3; i <= n; i++){
        int min = INT_MAX;
        for(int j = 1; j <= k && i-j >= 1; j++){
            if((dp[i-j] + abs(h[i] - h[i-j])) < min) min = dp[i-j] + abs(h[i] - h[i-j]);
        }
        dp[i] = min;
    }
    return dp[n];
}


int main(){
    int n, k;
    scanf("%d %d\n", &n, &k);
    int h[n+1];
    h[0] = 0;
    for(int i = 1; i <= n; i++){
        scanf("%d", &h[i]);
    }
    printf("%d", frog2dp(h, n, k));
}



Measured memory_bytes: 4560
ans = []

while true
	points = gets.split(" ").map{ |e| e.to_i }
	break if points[0] == -1 && points[1] == -1 && points[2] == -1
	if points[0] == -1 || points[1] == -1
		ans.push "F"
	elsif points[0] + points[1] >= 80
		ans.push "A"
	elsif points[0] + points[1] >= 65
		ans.push "B"
	elsif points[0] + points[1] >= 50
		ans.push "C"
	elsif points[0] + points[1] >= 30
		if points[2] >= 50
			ans.push "C"
		else
			ans.push "D"
		end
	elsif points[0] + points[1] < 30
		ans.push "F"
	end
end

ans.each{ |e| puts e }

Measured memory_bytes: 8612
N = int(input())
a = list(map(int,input().split()))

a.sort(reverse=True)

ans = 0
ans2 = 0
for i in range(len(a)):
    if i % 2 == 0:
        ans += a[i]
    else:
        ans2 += a[i]

print(ans - ans2)

Measured memory_bytes: 9024
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

const int MAX_LHM = 1;
const ll MUL[2] = {72727, 51419};
const ll RHMOD[2] = {765876961, 727272727};
struct RollingHash{
  vector<ll> h[MAX_LHM];
  vector<ll> e[MAX_LHM];
  int n;
  void init(const string &s){
    n = s.length();
    for(int i = 0; i < MAX_LHM; i++){
      h[i] = vector<ll>(n+1 , 0);
      e[i] = vector<ll>(n+1 , 1);
      for(int j = 0; j < n; j++){
        h[i][j+1] = (h[i][j]*MUL[i] + s[j]) % RHMOD[i];
        e[i][j+1] = e[i][j]*MUL[i]%RHMOD[i];
      }
    }
  }
  RollingHash(){}
  RollingHash(const string &s){
    init(s);
  }
  ll get(int s, int t){
    s = min(s, n);
    s = max(s, 0);
    t = min(t, n);
    t = max(t, 0);
    ll res = (h[0][t] - h[0][s]*e[0][t-s]%RHMOD[0] + RHMOD[0]) % RHMOD[0];
    // res += ((h[1][t] - h[1][s]*e[1][t-s]%RHMOD[1] + RHMOD[1]) % RHMOD[1]) * RHMOD[0];
    return res;
  }
};

int n;
string s[310];
string t[610];

RollingHash rhs[310];
RollingHash rht[310];

int main(){

  n = in();
  REP(i, n){
    s[i] = stin();
    t[i] = s[i];
    s[i] += s[i];
  }

  REP(i, n){
    REP(j, n){
      if(i < j){
        swap(t[i][j], t[j][i]);
      }
    }
  }
  REP(i, n){
    t[i] += t[i];
  }
  
  REP(i, n){
    rhs[i].init(s[i]);
    rht[i].init(t[i]);
  }

  ll ans = 0;
  REP(i, n){
    REP(j, n){
      bool ok = true;
      REP(k, n){
        int si = (i+k)%n;
        int tj = (j+k)%n;
        if(rhs[si].get(j, j+n) != rht[tj].get(i, i+n)){
          ok = false;
          break;
        }
      }
      if(ok){
        ans++;
      }
    }
  }

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


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

int main() {
  int k, s;
  cin >> k >> s;
  
  int ans = 0;
  int x, y;
  for(int x = 0; x <= k; x++) {
    for(int y = 0; y <= k; y++) {
      int z = s - x - y;
      if(z < 0 || z > k) continue;
      ans++;
    }
  }
  cout << ans << endl;
}  
      


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

using namespace std;

int n;
long long a, b, c;

int main(){
    cin >> n;
    a = 2;
    b = 1;
    if (n == 0) c = 2;
    else if (n == 1) c = 1;
    else
    for (int i = 2; i <= n; i++)
        {
            c = a + b;
            a = b;
            b = c;
        }
    cout << c;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main () {
  int H , W ;
  cin >> H >> W ;
  int pre = 0 ;
  for(int i = 0 ; i < H ; i++ ){
    for(int j = 0 ; j < W ; j++ ){
      char ch ;
      cin >> ch ;
      if(ch=='#') pre ++ ;
    }
  }
  if(pre == H + W -1 ) cout << "Possible" << endl ;
  else cout << "Impossible" << endl ;
}

Measured memory_bytes: 256
n=gets.to_i
if n < 10
  puts n
elsif n < 100
  puts 9
elsif n < 1000
  puts 9 + n-99
elsif n < 10000
  puts 9 + 900 
elsif n < 100000
  puts 9 + 900 + n - 9999
else
  puts 9 + 900 + 90000
end


Measured memory_bytes: 3836
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 100005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   map<string,int>mp;
   for(int i=0;i<n;i++)
   {
       string s;
       cin>>s;
       mp[s]++;
   }
   cout<<"AC x"<<" "<<mp["AC"]<<endl;
   cout<<"WA x"<<" "<<mp["WA"]<<endl;
   cout<<"TLE x"<<" "<<mp["TLE"]<<endl;
   cout<<"RE x"<<" "<<mp["RE"]<<endl;
}


Measured memory_bytes: 3664
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long sum = 0;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] > a[i]) {
			sum += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}
	cout << sum << endl;
}

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

void push(int);
int pop();
int top;
int s[1000];


int main(){
  int i,j,a,b;
  char S[100];
  top = 0;

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

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

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

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  lli h, w, n;
  while (cin >> h >> w >> n) {
    map<int, lli> cnt;
    set<pair<int, int>> s;
    s.clear();
    for (int i = 0; i < n; ++i) {
      int a, b;
      cin >> a >> b;
      s.insert(make_pair(a - 1, b - 1));
    }

    vector<pair<int, int>> v;
    each (p, s) {
      for (int i = -2; i < 3; ++i) {
        for (int j = -2; j < 3; ++j) {
          int I = p.first + i;
          int J = p.second + j;
          unless (0 <= I && I + 2 < h) continue;
          unless (0 <= J && J + 2 < w) continue;
          v.push_back(make_pair(I, J));
        }
      }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
   
    each (p, v) {
      int x = 0;
      for (int i = 0; i <= 2; ++i) {
        for (int j = 0; j <= 2; ++j) {
          x += s.count(make_pair(p.first + i, p.second + j));
        }
      }
      ++cnt[x];
    }


    lli sum = 0;
    for (int i = 1; i <= 9; ++i) {
      sum += cnt[i];
    }

    cnt[0] = (h - 2LL) * (w - 2LL) - sum;
    for (int i = 0; i <= 9; ++i) {
      cout << cnt[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 37860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define PUTS(x) cout << (x) << endl;
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define F first
#define S second
#define perm(c)   \
    sort(ALL(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))
#define IntsIn(v, n)                                 \
    auto v = vector<Int>(0);                         \
    for (int v##_i = 0; v##_i < (int)(n); v##_i++) { \
        Int v##_a;                                   \
        cin >> v##_a;                                \
        v.push_back(v##_a);                          \
    }
void setPrecision(int num = 20) {
    std::cout << std::fixed << std::setprecision(num);
}
template <typename T>
T Max(T a) {
    return a;
}
template <typename T, typename... Args>
T Max(T a, Args... args) {
    return std::max(Max(args...), a);
}
template <typename T>
T Min(T a) {
    return a;
}
template <typename T, typename... Args>
T Min(T a, Args... args) {
    return std::min(Min(args...), a);
}
template <typename T>
bool vector_contains(std::vector<T> vec, T value) {
    return (std::distance(vec.begin(), std::find(vec.begin(), vec.end(), value)) != vec.size());
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
int main() {
    int h, w;
    cin >> h >> w;
    auto v = vector<pair<int, int>>(0);
    rep(i, h) {
        rep(j, w) {
            char a;
            cin >> a;
            if (a == '#') v.PB(MP(i, j));
        }
    }
    auto v2 = v;
    sort(ALL(v), [](const pair<int, int> &a, const pair<int, int> b) {
        return (a.F < b.F);
    });
    sort(ALL(v2), [](const pair<int, int> &a, const pair<int, int> b) {
        return (a.S < b.S);
    });
    puts(v == v2 ? "Possible" : "Impossible");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
int M;
int h, j;
cin>>N>>M;
vector<int> vec(N);
for(int i=0;i<M;i++)
{
  cin>>h>>j;
  vec.at(h-1)=1+vec.at(h-1);
  vec.at(j-1)=1+vec.at(j-1);
}
for(int i=0;i<N;i++)
{
  cout<<vec.at(i)<<endl;
}
}

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

#define INF 1 << 29

using namespace std;

int c,n,m,s,d;
int cost[101][101];

class S{
public:
    int node;
    int tick;
    int cost;

    S(int node,int tick,int cost):
        node(node),tick(tick),cost(cost){}
    S(){}
    bool operator <(const S arg) const{
        return cost > arg.cost;
    }
};

int dijkstra(int src,int dst){
    priority_queue<S> q;
    int memo[n+1][c+1];
    S tmp;
    fill((int *)memo, (int *)memo+(n+1)*(c+1), INF);
    memo[src][c] = 0;
    q.push(S(src,c,0));

    while(!q.empty()){
        tmp = q.top();
        q.pop();
        for(int i=0;i<=n;i++){
            if(cost[tmp.node][i] != INF){
                if(cost[tmp.node][i] + tmp.cost < memo[i][tmp.tick]){
                    q.push(S(i,tmp.tick,cost[tmp.node][i] + tmp.cost));
                    memo[i][tmp.tick] = cost[tmp.node][i] + tmp.cost;
                }
                if(tmp.tick && cost[tmp.node][i]/2 + tmp.cost < memo[i][tmp.tick-1]){
                    q.push(S(i,tmp.tick-1,cost[tmp.node][i]/2 + tmp.cost));
                    memo[i][tmp.tick-1] = cost[tmp.node][i]/2 + tmp.cost;
                }
            }
        }
    }
    int ret = 1<<29;
    for(int i=0;i<=c;i++){
        ret = min(ret, memo[dst][i]);
    }
    return ret;
}

int main(){
    while(cin >> c >> n >> m >> s >> d){
        if((c|n|m|s|d) == 0) break;
        int src,dst,c;
        fill((int *)cost, (int *)cost+101*101, INF);
        for(int i=0;i<m;i++){
            cin >> src >> dst >> c;
            cost[src][dst] = c;
            cost[dst][src] = c;
        }

        cout << dijkstra(s,d) << endl;
    }
}

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int n, m;
    cin >> n >> m;
    cout << (n * (n - 1)) / 2 + (m * (m - 1) / 2) << endl;

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 256
// Create by JJL
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <set>
#include <queue>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;

const int N=2010,Mod=1e9+7;
char s[N*2];
int a[N*2];
int B[N*2][N],R[N*2][N],f[N*2][N];
int pb[N],pr[N];
inline int calc(int pos,int p1,int p2)
{
    return pos-B[pos][p1]-R[pos][p2]-1;
}
int main(){
    IOS;
    /* START CODE */
    int n;
    cin>>n;
    for(int i=1;i<=n*2;++i){
        cin>>s[i]>>a[i];
    }
    for(int i=1;i<=2*n;++i){
        if(s[i]=='B') pb[a[i]]=i;
        else pr[a[i]]=i;
    }
    for(int i=1;i<=n*2;i++)
        for (int j=1;j<=i-1;j++)
            if (s[j]=='B') B[i][a[j]]++; else R[i][a[j]]++;
    for(int i=1;i<=2*n;++i){
        for(int j=1;j<=n;++j){
            B[i][j]+=B[i][j-1];
            R[i][j]+=R[i][j-1];
        }
    }
    memset(f,0x3f,sizeof f);
    f[0][0]=0;
    for(int i=0;i<=n;++i){
        for(int j=0;j<=n;++j){
            if(i)
                //f[i][j]=min(f[i][j],f[i-1][j]+pb[i]-B[pb[i]][i-1]-R[pb[i]][j]-1);
                f[i][j]=min(f[i][j],f[i-1][j]+calc(pb[i],i-1,j));
            if(j)
                f[i][j]=min(f[i][j],f[i][j-1]+calc(pr[j],i,j-1));
        }
    }
    cout<<f[n][n]<<endl;
    return 0;
}


Measured memory_bytes: 97608
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

int LIS(std::vector<int> a) {
	const int INF = 1e9;
	std::vector<int> dp(a.size()+1,INF);
	for(auto i:a) {
		auto lb = std::upper_bound(all(dp),i);
		if(*lb>i) *lb = i;
	}
	int len = 0;
	while(dp[len]!=INF) len++;
	return len;
}


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a;
	rep(i,n) {
		int x;
		std::cin >> x;
		a.emplace_back(-x);
	}
	print(LIS(a));
	return 0;
}


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

int main(){
    int w, h, n;
    cin >> w >> h >> n;
    int wmin[]={0, 0}, wmax[]={w, h};
    for(int i = 0; i < n; i++)
    {
        int x, y, a;
        cin >> x >> y >> a;
        if(a==1){
            wmin[0]= max(wmin[0], x);
        }
        else if(a==3){
            wmin[1] = max(wmin[1], y);
        }
        else if(a==2){
            wmax[0] = min(wmax[0], x);
        }
        else if(a==4){
            wmax[1] = min(wmax[1], y);
        }
    }
    int ans = max(wmax[0]-wmin[0], 0) * max(wmax[1]-wmin[1], 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int S, h, m, s;
	scanf("%d", &S);
	0<=S<86400;
	h = S / 3600;
	m = (S - 3600 * h) / 60;
	s = S - 3600 * h - 60 * m;
	printf("%d:%d:%d\n", h, m, s );
	return 0;
}


Measured memory_bytes: 2736
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    int a[5] ;
    int c=0 ;
    for(int i=0 ;i<5;i++)
{    cin >>a[i] ;
    if(a[i]==0){c=i+1 ;}

}
cout << c ;
    return 0 ;
}



Measured memory_bytes: 3528
import java.util.*;

class Main {
    //
    static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n==0){
            System.out.println("0");
            return;
        }
        if(n==1){
            System.out.println("1");
            return;
        }
        if(n==2){
            System.out.println("2");
            return;
        }
        int max = 0;
        long[] sum = new long[n];
        sum[0] = 0;
        for(int i = 1;i < n;i++){
            sum[i] = i + sum[i-1];
        }
        while(n > 0){
            for(int i = 0;i <= n;i++){
                if(max == 0&&sum[i] >= n){
                    max = i;
                    break;
                }
            }
            if(max == 0)break;
            System.out.println(max);
            n -= max;
            max = 0;
        }
    }
}

Measured memory_bytes: 102100
#include<bits/stdc++.h> 
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define ull unsigned long long
#define ll long long
void codeforces()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.in", "w", stdout);
    #endif
}

int32_t main()
{
    codeforces();
    // int t;cin>>t;
    // while(t--){
       
    // }

    int n,m;cin>>n>>m;
    if(m>=n)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX_N=200000;
static const int MAX_R=1000000000;

int main(void){
    int n;
    int R[MAX_N];
    cin>>n;
    for(int i=0;i<n;i++) cin>>R[i];
    int minv=R[0];
    int maxv= -2*MAX_R-1;
    for(int i=1;i<n;i++){
        int r=R[i];
        maxv=max(maxv,r-minv);
        minv=min(minv,r);
    }
    cout<<maxv<<endl;
}



Measured memory_bytes: 3864
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>
using namespace std;

int main() {
    long k,x;
    cin >> k >> x;
    for (long i = x-k+1; i < x+k; i++) {
        cout << i << " ";
    }
}


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

#define int long long
int n;
string s;
signed main(){
	cin >> n;
	cin >> s;
	char prev = '@';
	int cnt = 0;
	for(char c: s){
		if(c != prev){
			cnt ++;
			prev = c;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
  }
  int bounds = 1;
  int distance = 0;
  for (int i = 0; i < n; ++i) {
    distance += l[i];
    if (distance <= x) {
      bounds++ ;
    }
  }
  cout << bounds << endl;
  return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;

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 (a>b) { a=b; return 1; } return 0; }


void solve(long long N, std::string S){
  int res=0;
  rep(i,N-2){
    (S[i]=='A' and S[i+1]=='B' and S[i+2]=='C')?res++:1;
  }
  cout<<res<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
      cout << fixed << setprecision(6);
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, k = LI()
    p = LI()
    p.sort()
    print(sum(p[:k]))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 67376
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define ll long long

using namespace std;
int mod = 1000000007;

int N;
vector<P> X;
vector<P> Y;
vector<P> graph[100005];

int main() {

  cin >> N;

  rep(i, N) {
    int x, y;
    cin >> x >> y;
    X.emplace_back(x, i);
    Y.emplace_back(y, i);
  }

  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());

  rep(i, N-1) {
    int len = X.at(i+1).first - X.at(i).first;
    int u = X.at(i+1).second;
    int v = X.at(i).second;
    graph[u].emplace_back(v, len);
    graph[v].emplace_back(u, len);

    len = Y.at(i+1).first - Y.at(i).first;
    u = Y.at(i+1).second;
    v = Y.at(i).second;
    graph[u].emplace_back(v, len);
    graph[v].emplace_back(u, len);
  }

  ll ans = 0;
  priority_queue<P, vector<P>, greater<>> que;
  vector<bool> used(N);
  vector<int> len(N);
  rep(i, N) {
    len.at(i) = INT_MAX;
  }
  que.emplace(0, 0);

  while (!que.empty()) {
    P pair = que.top(); que.pop();
    int u = pair.second;
    if (used.at(u)) continue;
    used.at(u) = true;
    len.at(u) = pair.first;
    ans += pair.first;
    for (auto &e : graph[u]) {
      if (!used.at(e.first) && e.second < len.at(e.first)) {
        que.emplace(e.second, e.first);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 11372