akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
#define int long long
using namespace std;

signed main(){

    int n;
    cin>>n;
    int total=0;
    
    int a[n];

    for(int i=0;i<n;i++){
        
        cin>>a[i];
        total+=a[i];
    }

    int left=0;
    int right=total;
    int tmp;
    int ans=10000000000000000;

    for(int i=0;i<n-1;i++){
        right-=a[i];
        left+=a[i];

        // cout<<"left right"<<endl;
        // cout<<left<<" "<<right<<endl;

        tmp=abs(right-left);
        ans=min(ans,tmp);

        // cout<<"abs  ans"<<endl;
        // cout<<tmp<<" "<<ans<<endl;
    }

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int N, M;
int A[3];
vector<int> G[51];
bool used[51];
int cnts[51];
bool dp[101][51][51];  // a step, b start, c goal
 
int main(){
 
  cin>>N>>M;
  for(int i=0;i<3;i++)cin>>A[i];
  for(int i=0;i<M;i++){
    int f,t;
    cin>>f>>t;
    f--;t--;
    G[f].push_back(t);
  }
  int ite = 0;
 
  for(int i=0;i<N;i++)
    dp[0][i][i] = true;
  for(int i=1;i<101;i++){
    for(int j=0;j<N;j++){
      // ??????step???§???°??????????????????´??????????????????, ????????????????????????´????????????
      for(int k=0;k<N;k++){
        if(dp[i-1][j][k]){
          // k??????????????????´???
          for(int to : G[k]){
            dp[i][j][to] = true;
          }
        }
      }
    }
  }
   
  used[N-1] = true;
  cnts[N-1] = 0;
  // N step???§????????????´????????????
  while(1){
    bool ok = false;
    vector<int> idx;
    for(int i=0;i<N;i++){
      // ???????????????´?????????1step???§????????????´???????????????????????????
      if(used[i])continue;
      // ???????????????????????????
      int cnt = 0;
      int max_step = -1;
      for(int j=0;j<3;j++){
        // ???????????????step???§, goal??????´?????????°??????§??????????????????
        int a = A[j];
        bool t = false;
        int min_step = 100000000;
        for(int k=0;k<N;k++){
          if(dp[a][i][k] && used[k]){
            // cnt++;
            min_step = min(min_step, cnts[k] + 1);
            t = true;
          }
        }
        if(t){
          cnt++;
          max_step=max(max_step, min_step);
        }
      }
      // OK
      if(cnt == 3){
        cnts[i] = max_step;
        // used[i]=true;
        ok=true;
        idx.push_back(i);
      }
    }
    if(ok){
      ite++;
      for(int i : idx){
        used[i]=true;
      }
      if(used[0]){
        cout<<ite<<endl;
        return 0;
      }
    }
    else{
      break;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
   
  return 0;
}

Measured memory_bytes: 3420
N = int(input())
W = ['']*N
ans = True
for i in range(N):
    W[i] = input()
    if i >= 1 and W[i-1][-1] != W[i][0]:
        ans = False
        
if len(set(W)) != len(W):
    ans = False

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000



int main(){
	
	int x;
	cin>>x;
	
	cout<<(x^1)<<endl;
	
	
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 3e18;
long long int mod = 4294967296;
double Pi = 3.1415926535897932384626;

//vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}

ll i,j,k,ii,jj;
ll n,m,num1,num2,sum;
ll ans;
ll a,b,c,e,g,h,w,ok,ng;
ll x[100005],y[100005];
bool flag,dame;
char s[1000005];


int main(){
    cin >> a >> b;
	p(a*b/2);
	return 0;
}

Measured memory_bytes: 256
from sys import stdin

def slove():
    S, T = stdin.readline().rstrip().split()
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    U = input()

    if S == U:
        print(A-1, B)
    elif T == U:
        print(A, B-1)
    else:
        print(A, B)


slove()


Measured memory_bytes: 38384
n = int(input())
a = list(map(int, input().split()))

up = down = 0

cur = a[0]
ans = 0
for x in a:
    if cur < x:
        up = 1
    elif cur > x:
        down = 1
    
    if up and down:
        ans += 1
        up = down = 0

    cur = x

print(ans+1)

Measured memory_bytes: 19948
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  double value = (v[0] + v[1]) / 2.0;
  for (int i = 2; i < N; ++i) {
    value = (value + v[i]) / 2.0;
  }
  cout << setprecision(20) << value << endl;
  
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
ll gcd(ll a , ll b){return b == 0 ? a : gcd(b , a % b);}
ll mod(ll x){return (x%MOD + MOD)% MOD;}
struct ikan{
    ll A , B;
    bool  operator < (const ikan &con)const{
        if (B == con.B)
            return A < con.A;
        return B < con.B;
    }
};
int pangkat(int num , int derajat){
    if (derajat == 0)
        return 1;
    if (derajat == 1)
        return num;
    int x = pangkat(num , derajat >> 1);
    x = x * (ll)x % MOD;
    if (derajat & 1)
        x = x * (ll)num % MOD;
    return x;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N , z_z = 0 , z_no = 0 , no_z = 0;
    cin >> N;
    map<ikan , int> mp;
    map<ikan , bool> used;
    for (int i = 0  ; i < N ; i++){
        ll a , b;
        cin >> a >> b;
        if (a == 0 && b == 0)
            z_z++;
        else if (a == 0)
            z_no++;
        else if (b == 0)
            no_z++;
        else{
            ll fpb = abs(gcd(a , b));
            a /= fpb , b /= fpb;
            if (a < 0 && b > 0)
                a = -a  , b = -b;
            else if (a < 0 && b < 0)
                a = -a , b = -b;
            mp[{a , b}]++;
        }
    }
    ll ans = 1;
    ans = ans * ((pangkat(2 , no_z) + pangkat(2 , z_no) - 1) % MOD) % MOD;
    for (auto &it : mp){
        if (!used[it.first]){
            ikan inv = {abs(it.first.B) , (it.first.B < 0 ? it.first.A : -it.first.A)};
            ans = ans * ((pangkat(2 , mp[it.first]) + pangkat(2 , mp[inv]) - 1) % MOD) % MOD;
            used[inv] = 1;
        }
    }
    cout << mod(ans - 1 + z_z) << endl;
}


Measured memory_bytes: 53600
#include <iostream>

using namespace std;

int main(){
 int w,h,x,y,r;
 cin>>w>>h>>x>>y>>r;
 if(x>=r&&y>=r&&x+r<=w&&y+r<=h){
  cout<<"Yes"<<endl;
 }else{
  cout<<"No"<<endl;
 }
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int k;
	cin>>k;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!='1')
		{
			cout<<s[i];
			return 0;
		}
		else if(i==k-1)
		{
			cout<<1;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#![allow(dead_code)]
#![allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{BufWriter, stdin, stdout, Write};
const BITS: usize = 19;

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

    let n: i32 = scan.next();
    let mut ac: i32 = 0;
    let mut wa: i32 = 0;
    let mut tle: i32 = 0;
    let mut re: i32 = 0;

    for _ in 0..n {
        let result = scan.next::<String>();
        match result.as_str() {
            "AC" => {
                ac += 1;
            },
            "WA" => {
                wa += 1;
            },
            "TLE" => {
                tle += 1;
            },
            "RE" => {
                re += 1;
            },
            _ => {},
        }
    }

    writeln!(out, "AC x {}", ac);
    writeln!(out, "WA x {}", wa);
    writeln!(out, "TLE x {}", tle);
    writeln!(out, "RE x {}", re);
}

Measured memory_bytes: 2120
N=int(input())
mx=int(input())
a=[mx]
for i in range(N-1):
    l=int(input())
    a.append(l)
    mx=max(mx,l)
num=a.index(mx)
a.remove(mx)
mx2=a[0]
for j in range(1,N-1):
    mx2=max(mx2,a[j])
for k in range(N):
    if k==num:
        print(mx2)
    else:
        print(mx)

Measured memory_bytes: 12528
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.StringBuilder;
public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int t = 0;
		do{
			String[] st = sc.readLine().split("");
			int[] x = new int[st.length];
			if(st[0].equals("0"))
				break;
			for(int i = 0;i < st.length;i++){
				x[i] = Integer.parseInt(st[i]);
			}
			for(int n:x){
				t += n;
			}
			sb.append(t).append("\n");
			t = 0;
		}while(true);
		System.out.print(sb);
	}
}

Measured memory_bytes: 25336
ans_list = []

def judge(array):
    res = 0
    cnt = 0
    st = [5,7,5,7,7,400]
    for a in array:
        res += len(a)
        if res > st[cnt]:
            return False
        if res == st[cnt]:
            cnt += 1
            res = 0
    if cnt == 5:
        return True

while True:
    n = int(input())
    if n == 0:
        break
    W = [input() for _ in range(n)]
    for i in range(n):
        part = W[i:]
        if judge(part):
            ans = i + 1
            break
    ans_list.append(ans)

for ans in ans_list:
    print(ans)


Measured memory_bytes: 5624
n=gets.chomp.to_i
s=n.times.map { gets.chomp.to_s  }.select { |i|  i[0]=="M" || i[0]=="A" || i[0]=="R" || i[0]=="C" || i[0]=="H" }.sort

n=s.length

string = Array.new(5,0)

n.times do |i|
  if s[i][0] == "M"
    string[0] += 1
  elsif s[i][0] == "A"
    string[1] += 1
  elsif s[i][0] == "R"
    string[2] += 1
  elsif s[i][0] == "C"
    string[3] += 1
  else
    string[4] += 1
  end
end

count = 0

for i in 0..2 do
  for j in i+1..3 do
    for k in j+1..4 do
      count += string[i]*string[j]*string[k]
    end
  end
end

puts count


Measured memory_bytes: 12152
//AtCoder ABC091 C - 2D Plane 2N Points
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
struct Pt{
    ll x,y;
    ll m_dstsq; //ユークリッド距離
    ll m_dstmh; //マンハッタン距離
    ll m_max;
    bool m_flag;
    void setup(){
        m_dstsq=x*x+y*y;
        m_dstmh=x+y;
        m_max=max(x,y);
        m_flag=false;
    }
};
int main() {
#if LOCAL&01
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N;
    cin>>N;
    vector<Pt> ab(N); //red
    vector<Pt> cd(N); //blue
    for(auto&& p:ab){
        cin>>p.x>>p.y;
        p.setup();        
    }
    for(auto&& p:cd){
        cin>>p.x>>p.y;
        p.setup();
    }
#if 1
    //青をsort,xで小さいものから
    sort(cd.begin(),cd.end(),[](const auto& a,const auto& b){
        return (a.x<b.x);
    });
    //赤は,y大きいものから
    sort(ab.begin(),ab.end(),[](const auto& a,const auto& b){
        return (a.y>b.y);
    });
    //青を回して入るやつをカウント
    ll ans=0;
    for(const auto& b:cd){
        for(auto&& r:ab){
            if(!r.m_flag && r.x<b.x&&r.y<b.y){
                ++ans;
                r.m_flag=true;
                break;
            }
        }
    }
    cout<<ans<<endl;
#else
    //赤をsort 
    sort(ab.begin(),ab.end(), [](const auto& a, const auto& b){
        if(a.m_dstsq==b.m_dstsq) return (a.m_max>b.m_max);
        return (a.m_dstsq>b.m_dstsq);
//        if(a.m_max==b.m_max) return(a.m_dstmh>b.m_dstmh);
//        return (a.m_max>b.m_max);
    });
    //青も
    sort(cd.begin(),cd.end(), [](const auto& a, const auto& b){
        if(a.m_dstsq==b.m_dstsq) return (a.m_max<b.m_max);
        return (a.m_dstsq<b.m_dstsq);
//        if(a.m_max==b.m_max) return(a.m_dstmh>b.m_dstmh);
//        return (a.m_max>b.m_max);
    });
    //赤を回して入るやつをカウント
    ll ans=0;
    for(const auto& r:ab){
        for(auto&& b:cd){
            if(!b.m_flag && r.x<b.x&&r.y<b.y){
                ++ans;
                b.m_flag=true;
                break;
            }
        }
    }
    cout<<ans<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

void trim(vector<int> a,vector<vector<int>> &g){
    int n=a.size();
    if(n==3){
        g.push_back(a);
        return;
    }
    vector<int> b;
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            b.push_back(a[i]+a[j]);
            rep(k,n){
                if(k!=i&&k!=j) b.push_back(a[k]);
            }
            trim(b,g);
            b.clear();
        }
    }
}

int main(){
    int n,A,B,C;
    cin>>n>>A>>B>>C;
    vector<int> length(n);
    rep(i,n) cin>>length[i];
    ll mp=INF;   
    for(int bit=0; bit<(1<<n);bit++){
        vector<int> a;
        vector<vector<int>> aa;
        rep(i,n){
            if(bit&(1<<i)) a.push_back(length[i]);
        }
        if(a.size()<=2) continue;
        else{
            trim(a,aa);
            rep(i,aa.size()){
                rep(j,3){
                    rep(k,3){
                        rep(l,3){
                            if((l!=j&& l!=k) && j!=k){
                            ll ans=10*(a.size()-3);
                            ans+=abs(aa[i][j]-A)+abs(aa[i][k]-B)+abs(aa[i][l]-C);
                            mp=min(mp,ans);
                            }
                        }
                    }
                }
            }

        }
    }

    cout<<mp<<endl;
}



Measured memory_bytes: 44048
#include<cstdio>
using namespace std;

int n,m,x;

int main()
{
	scanf("%d%d",&n,&m);
	int sum=0;
	for (int i=1 ; i<=m ; i++)
	{
		scanf("%d",&x);
		sum+=x;
	}
	if (n<sum) printf("-1\n");
	else printf("%d",n-sum);
	
	return 0;
}

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


public class Main {
    public static int maxOfArray(int[] a){
    	int ans = a[0];
    	for(int i=1;i<a.length;i++){
    		if(a[i]>ans) ans=a[i];
    	}
    	return ans;
    }
    public static int minOfArray(int[] a){
    	int ans = a[0];
    	for(int i=1;i<a.length;i++){
    		if(a[i]<ans) ans=a[i];
    	}
    	return ans;
    }
    
    public static long solve(int[] x){
        //dp[i][j]:use i cards, the sum is (j-2500)
        long[][] dp = new long[x.length+1][5001];
        dp[0][2500]=1;
        for(int i=1;i<=x.length;i++){
        	for(int j=0;j<=5000;j++){
        	    dp[i][j] = dp[i-1][j] + ((j-x[i-1]>=0&&j-x[i-1]<=5000)?dp[i-1][j-x[i-1]]:0);
        	}
        }
        return dp[x.length][2500]-1;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int[] x = new int[N];
        for(int n=0;n<N;n++) x[n]=sc.nextInt()-A;
        System.out.println(solve(x));
    }
}

Measured memory_bytes: 24660
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef pair<int,int> P;
int n,m,a[100000],b[100000];
vector<vector<int>> Graph;
int vis[100000],par[100000],flag[100000];
vector<P> Tree,ans;
vector<int> order;
set<P> st;

void dfs(int n){
  vis[n]=1;
  order.push_back(n);
  for(int i:Graph[n]){
    if(!vis[i]){
      st.insert(P(n,i));
      st.insert(P(i,n));
      Tree.push_back(P(n,i));
      par[i]=n;
      dfs(i);
    }
  }
}

int main(){
  cin >> n >> m;
  if(m&1){
    cout << -1 << endl; return 0;
  }
  Graph.assign(n,vector<int>());
  Tree.assign(0,P());
  ans.assign(0,P());
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i]; a[i]--; b[i]--;
    Graph[a[i]].push_back(b[i]);
    Graph[b[i]].push_back(a[i]);
  }
  dfs(0);
  for(int i=0;i<m;i++){
    if(!st.count(P(a[i],b[i]))){
      ans.push_back(P(a[i],b[i]));
      flag[a[i]]^=1;
    }
  }
  for(int i=n-1;i>=1;i--){
    if(flag[order[i]]){
      ans.push_back(P(order[i],par[order[i]]));
      flag[order[i]]^=1;
    }
    else{
      ans.push_back(P(par[order[i]],order[i]));
      flag[par[order[i]]]^=1;
    }
  }
  for(int i=0;i<m;i++){
    cout << ans[i].first+1 << ' ' << ans[i].second+1 << endl;
  }
}

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

int main(){
  string s;
  cin >> s;
  if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)) cout << "Yes" << endl;
  else if(s.at(1)==s.at(2)&&s.at(2)==s.at(3)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c) cout << 1 << endl;
    else if (a == b || b == c || c == a) cout << 2 << endl;
    else cout << 3 << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(map(int, input()))

ans = []

for i in range(10):
    if i in s:
        a = s.index(i)
        for j in range(10):
            if j in s[a + 1 :]:
                b = [x for x, y in enumerate(s) if x > a and y == j][0]
                for k in range(10):
                    if k in s[b + 1 :]:
                        ans.append(f"{i}{j}{k}")
print(len(ans))

Measured memory_bytes: 10212
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

  int n, k, a=1, b=1, ans;
  cin >> n >> k;

  for(int i=0; i<n; i++){
    a*=2;
    b+=k;
    if(a>=b){
      ans=b;
      a=ans;
    } else {
      ans=a;
      b=ans;
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int s;
    cin >> s;
    int mod = s % 10;

    if (mod == 3)
        cout << "bon";
    else if (mod == 0 || mod == 1 || mod == 6 || mod == 8)
        cout << "pon";
    else
        cout << "hon";
}

Measured memory_bytes: 3520
import bisect
n=int(input())
r=[]
b=[]
for i in range(n):
    r.append(list(map(int,input().split())))

for i in range(n):
    b.append(list(map(int,input().split())))

r.sort()
b.sort()

ans=0
for i in range(n):
    j=(n-1)-i
    bc,bd=list(zip(*b))
#    print(bc)
    bj_morethan_aj = bisect.bisect_left(bc, r[j][0])
    more_bi = b[bj_morethan_aj:]
    least_bd_k=-1
    least_bd=10000000
    for k in range(len(more_bi)):
        if(r[j][1] < more_bi[k][1] and more_bi[k][1] < least_bd):
            least_bd = more_bi[k][1]
            least_bd_k = k

    if(least_bd_k != -1):
        ans+=1
#        print(b[bj_morethan_aj+least_bd_k])
        del b[bj_morethan_aj+least_bd_k]
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(10, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 10; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'0'] = i;
    }
    return res;
}

int main(){
    int N;
    string S;
    cin >> N >> S;
    ll cnt=0;
    vector<vector<int> > next = calcNext(S);
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                int a=next[0][i];
                //cerr << "a=" << a << "\t";
                if(a<N){
                    int b=next[a+1][j];
                    //cerr << "b=" << b <<"\t";
                    if(b<N){
                        int c=next[b+1][k];
                        //cerr << "c=" << c<< "\t";
                        if(c<N){
                            //cerr << i<<j<<k << endl;
                            cnt++;
                        }
                    }
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
ll beki(ll m){
	if(m==0) return 1;
	else return 2*beki(m-1);
}
ll sum(ll n){
	return beki(n+1)-1;
}
int main(){
  	ll H;
  	cin >> H;

  	ll cnt = 0;
  	while(H){
  		H /=2;
  		cnt++;
  	}
  	cout << sum(cnt-1) << endl;

  	return 0;
}





Measured memory_bytes: 256
N=int(input())
lst = [int(s) for s in input().split()]
def suc(ls):
  val_ls=ls
  i=0
  while(i<N and val_ls[i]==0):
    i+=1
  if i==N:
    return []
  else:
    while(i<N and val_ls[i]!=0):
      val_ls[i]-=1
      i+=1
    return val_ls
ans=0
while(lst!=[]):
  ans+=1
  lst=suc(lst)
print(ans-1)

Measured memory_bytes: 3064
import numpy as np

k,q = map(int,input().split())
d = np.array(list(map(int,input().split())))
n = [0]*q
x = n.copy()
m = n.copy()
for i in range(q):
    n[i],x[i],m[i] = map(int,input().split())
    
for i in range(q):
    d_ = d%m[i]
    j = np.sum(d_ * ((n[i]-1)//k)) + np.sum(d_[:(n[i]-1)%k])
    s = np.sum(np.sum(d_==0) * ((n[i]-1)//k)) + np.sum(d_[:(n[i]-1)%k]==0)
    count = n[i] - 1 - (j+x[i]%m[i])//m[i] - s
    print(count)

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

int main(void) {

  char s[1001];
  scanf("%s", s);
  int hasN = 0;
  int hasW = 0;
  int hasS = 0;
  int hasE = 0;
  for (int i = 0; i < strlen(s); i++) {
    if (s[i] == 'N') {
      hasN = 1;
    }
    if (s[i] == 'W') {
      hasW = 1;
    }
    if (s[i] == 'S') {
      hasS = 1;
    }
    if (s[i] == 'E') {
      hasE = 1;
    }
  }
  if (hasN-hasS == 0 && hasW-hasE == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N,A,B;
	cin>>N>>A>>B;
	if((B-A)%2==0) puts("Alice");
	else puts("Borys");
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define DBG(v) REP(i, LEN((v))) cout<<(v)[i]<<(i==LEN((v))-1 ? '\n' : ' ')
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<vector<int>> vii;
typedef vector<vector<lint>> vll;

class ARedOrNot {
public:
    int A;
    string S;

    void input(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in>>A>>S;
    }

    void solve(std::istream& in, std::ostream& out) {
        input(in, out);
        if(A>=3200) out<<S<<'\n';
        else out<<"red\n";
    }
};


int main() {
	ARedOrNot solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
    int h,w;
    cin >> h >> w; 
    char s[h+2][w+2];
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> s[i][j];
        }
    }

    int ans=0;

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#'&&s[i-1][j]!='#'&&s[i+1][j]!='#'&&s[i][j-1]!='#'&&s[i][j+1]!='#'){
                ans=1;
            }
        }
    }

    if(ans==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

template<class Abel> struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n = 1, Abel SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}

	void init(int n = 1, Abel SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

	Abel weight(int x) {
		root(x);
		return diff_weight[x];
	}

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

	bool merge(int x, int y, Abel w) {//xのほうがyよりw大きい
		w += weight(x); w -= weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	Abel diff(int x, int y) {
		return weight(y) - weight(x);
	}
};
int main() {
	UnionFind<int> tree(100100);
	int n, m; cin >> n >> m;
	REP(i, m) {
		int l, r, d;
		cin >> l >> r >> d;
		if (tree.issame(l, r)) {
			if (tree.diff(l, r) != d) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			tree.merge(l, r, d);
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

using namespace std;

int main(){

	int t,n,s[10],f[10],sum;

	while(cin>>t,t){
		cin>>n;
		sum=0;
		for(int i=0;i<n;i++){
			cin>>s[i]>>f[i];
			sum=sum+(f[i]-s[i]);
		}
		if(sum>=t){
			cout<<"OK"<<endl;
		}
		else{
			cout<<t-sum<<endl;
		}
	}
}

Measured memory_bytes: 3088
def grade(m, f, r)
	return 'F' if m == -1 or f == -1

	m_f = m + f

	return case
	when 80 <= m_f; 'A'
	when 65 <= m_f; 'B'
	when 50 <= m_f; 'C'
	when 30 <= m_f; 50 <= r ? 'C' : 'D'
	else 'F'
	end
end

$<.each_line do |line|
	m, f, r = line.split.map(&:to_i)
	break if m == -1 and f == -1 and r == -1

	puts grade(m, f, r)
end

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int b2(int n, int a){
	return (n>>a)%2;
}
int main(void)
{
	int n, m, k[10], s[10][10], p[10], ans = 0;
	cin >> n >> m;
	rep(i, m){
		cin >> k[i];
		rep(j, k[i]){
			cin >> s[i][j];
		}
	}
	rep(i, m) cin >> p[i];
	/* rep(i,1 << n){
		rep(j,n)cout<<b2(i,j);
		cout<<endl;
	} */
	rep(i, 1<<n){
		bool ok = true;
		rep(j, m){
			int tmp = 0;
			rep(x, k[j]){
				tmp += b2(i, s[j][x]-1);
				// cout<< b2(i, s[j][x]-1);
			}
			if(tmp % 2 != p[j]) ok = false;
			// cout<<endl;
		}
		// cout<<endl;
		if(ok) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let mut route: Vec<(i32, i32, i32)> = (0..n).map(|_| {
        (read(), read(), read())
    }).collect();
    route.insert(0, (0,0,0));
    let ans = route[..].windows(2).all(|w| {
        let (t, x, y) = w[0];
        let (nt, nx, ny) = w[1];
        let dt = nt - t;
        let dist = (nx - x).abs() + (ny - y).abs();
        dt >= dist && dt % 2 == dist % 2
    });

    println!("{}", if ans {"Yes"} else {"No"});
}

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

int main() {
	int N; 
	cin >> N;
	vector <tuple<string, int, int>> A;
	for (int i=1; i<=N; i++){
	    string name;
	    int P;
	    cin >> name >> P;
	    P=-P;
	    A.push_back(tie(name, P, i));
	}
	sort(A.begin(), A.end());
	for (int i=0; i<N; i++){
	    cout << get<2>(A[i]) << endl;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;

    vector<ll> Ps(N);
    REP(n, N) cin >> Ps[n];

    double val = 0.0;
    REP(k, K) {
        ll p = Ps[k];
        val += (1.0 + p) / 2.0;
    }
    double ans = val;

    FOR(k, K, N) {
        ll p = Ps[k];
        val += (1.0 + p) / 2.0;
        val -= (1.0 + Ps[k - K]) / 2.0;
        ans = max(ans, val);
    }
    printf("%.20f\n", ans);

    return 0;
}


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

using namespace std;

#define intt long long

const int N = 100005;

int n, m, a, b, c;

int p[N], q[N], r[N];

int main() {

	cin >> n >> m >> a >> b >> c;

	for (int i = 1; i <= a; i ++) {
		cin >> p[i];
	}
	for (int i = 1; i <= b; i ++) {
		cin >> q[i];
	}
	for (int i = 1; i <= c; i ++) {
		cin >> r[i];
	}

	sort(p + 1, p + a + 1);
	reverse(p + 1, p + a + 1);
	sort(q + 1, q + b + 1);
	reverse(q + 1, q + b + 1);
	sort(r + 1, r + c + 1);
	reverse(r + 1, r + c + 1);

	multiset <int> bag;

	for (int i = 1; i <= n; i ++) {
		bag.insert(p[i]);
	}
	for (int i = 1; i <= m; i ++) {
		bag.insert(q[i]);
	}

	for (int i = 1; i <= c; i ++) {
		if (*(bag.begin()) < r[i]) {
			bag.erase(bag.begin());
			bag.insert(r[i]);
		}
	}

	intt ans = 0;
	for (int i : bag) {
		ans += i;
	}

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 9856
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n = int(input())
ans = 0
c = defaultdict(lambda: 0)
for _ in range(n):
    s = input()
    if(s not in c):
        ans += 1
        c[s] += 1
print(ans)


Measured memory_bytes: 129908
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >>a;
  if(a%10==7||a/100==7||(a-(a/100)*100-a%10)/10==7){
    cout <<"Yes" << endl;
  }
  else
    cout <<"No" << endl;
}


Measured memory_bytes: 3640
#ifdef loc
    #include "codes/loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 200005;

int a[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    rep(i, 1, n + 1) {
        cin >> a[i];
    }
    multiset<int> b;
    int res = 0;
    rep(i, 1, n + 1) {
        auto it = b.lower_bound(a[i]);
        if(it == b.begin()) {
            res++;
        } else {
            it--;
            b.erase(it);
        }
        b.insert(a[i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 5376
#
# abc065 a
#
import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    r, b, g = map(int, input().split())
    if (100*r+10*b+g) % 4 == 0:
        print("YES")
    else:
        print("NO")


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4 3 2"""
        output = """YES"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 3 4"""
        output = """NO"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 5620
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,M;
  cin>>N>>M;
  map<int,int> mp;
  mp[0]=1;
  int n=0;
  while(N--){
    int a;
    cin>>a;
    n=(n+a)%M;
    mp[n]++;
  }
  int ans=0;
  for(pair<int,int> p:mp)ans+=p.second*(p.second-1)/2;
  cout<<ans<<endl;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N, X;
vector<int> x;

int euclid(int a, int b) {
    int temp;

    if ( a < b ) {temp = a; a = b; b = temp;}
    if ( b < 1 ) return -1;

    if (a % b == 0) return b;
    return euclid(b, a % b);
}

int main(void) {

    cin >> N >> X;
    rep(i, N) {
        int a;
        cin >> a;
        x.push_back(abs(a - X));
    } 

    sort(ALLOF(x));

    int gcd = x[0];

    for (int i = 0; i < N; ++i) {
        gcd = euclid(gcd, x[i]);
    }

    cout << gcd << endl;


    return 0;
}

Measured memory_bytes: 892
import bisect

N = int(input())
L = list(map(int,input().split()))
L.sort()
count = 0
for i in range(0,N-1,1):
    for j in range(i+1,N,1):
        left = max(L[i]-L[j],L[j]-L[i])
        right = L[i]+L[j]
        count += -bisect.bisect_right(L,left)+bisect.bisect_left(L,right)
        if L[i] > left and L[i] < right:
            count-=1
        if L[j] > left and L[j] < right:
            count-=1
print(count//3)

Measured memory_bytes: 50028
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

f cs@[c1,c2,c3] = cond "YES" "NO" $ (>=4) $ length $ filter (<=20) $ map (+my) remain
  where
    remain = [x | x <- [1..10], x `notElem` cs]
    my = c1+c2

main = do
    input <- lines <$> getContents
    let (list, (_:remain)) = break (=="0,0") input
    let rank = zip [1..] $ map (map head) $ groupBy (on (==) (!!1)) $ sortBy (on (flip compare) (!!1)) $ map (map readInt . wordsBy (==',')) list 
    forM_ (map readInt remain) $ \i -> print $ fst $ fromJust $ find (elem i . snd) rank

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

#define ll long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0)
#define infl 1e18+9
#define sz(a) ((int)a.size())
ll mod=1e9+7;

ll val_at(pair<ll,ll> line, ll x){
  ll m=line.first, c=line.second; 
  return m*x+c; 
}
bool before(pair<ll,ll> line1, pair<ll,ll> line2, pair<ll,ll> line3){
  if( (line1.second-line2.second)*(line3.first-line2.first) <= (line2.second-line3.second)*(line2.first-line1.first)){
    return 1; 
  }
  return 0; 
}
void solve(){
  ll n,cc;  cin>>n>>cc; 
  vector<ll> h(n); 
  vector<ll> dp(n); 
  deque<pair<ll,ll>> lines; 
  for(int i=0;i<n;i++){
    cin>>h[i]; 
    if(i==0){
      dp[i]=0; 
      lines.push_back({-2*h[i],dp[i]+h[i]*h[i]}); 
    }
    else {
      while(sz(lines)>1 && val_at(lines[0],h[i]) >= val_at(lines[1],h[i])){
        lines.pop_front(); 
      }
      dp[i]=cc+h[i]*h[i]+val_at(lines[0],h[i]); 
      pair<ll,ll> cur={-2*h[i],dp[i]+h[i]*h[i]}; 
      while(sz(lines)>1 && before(cur, lines.back(), lines[sz(lines)-2])){
        lines.pop_back();  
      }
      lines.push_back(cur); 
    }
  }
  cout<<dp[n-1]<<endl; 
}

int main(){
	fast_io;
	clock_t beg=clock();
  int t;
  t=1;
  while(t--){
	  solve();
  }
	clock_t end=clock();
	fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <functional>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;
int kaijo(int n){
	int ans = 1;
	if (n != 0){
		for (int i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

int main(){
	int n, x, y;
	int a, b, c, d,e;
	int ans = 0;
	int flag = 0;
	cin >> n>>x>>y;
	//keta = log10(n) + 1;
	a = 0; b = 0; c = 0; d = 0; e = 0;
	
	


		while (10000*e+1000 * a + 100 * b + 10 * c + d <= n){

			//for (int i = x; i <= y; i++){
			/*	if (1000 * a + 100 * b + 10 * c + (i - a - b - c)>n){
					break;
					flag = 1;
					}*/
			if (a + b + c + d+e >= x&&a + b + c + d+e <= y){
				ans +=10000*e+ 1000 * a + 100 * b + 10 * c + d;
				//cout << 1000 * a + 100 * b + 10 * c + d << endl;
			}
			//}
			d++;
			if (d == 10){
				d = 0;
				c++;
			}
			if (c == 10){
				c = 0;
				b++;
			}
			if (b == 10){
				b = 0;
				a++;
			}
			if (a == 10){
				a = 0;
				e++;
			}

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

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
x.sort()

cnt = 0
for i in range(n):
   for j in range(i+1, n):
      if x[i] == x[j]:
         continue
      for k in range(j+1, n):
         if x[i] != x[k] and x[j] != x[k]:
            y = [x[i], x[j], x[k]]
            y.sort()
            if y[0] + y[1] > y[2]:
               cnt += 1
print(cnt)


Measured memory_bytes: 9196
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
long int dp[100005],h[100005];
/*long int min(long int a,long int b)
{
    if(a>=b)
        return b;
    else
        return a;
}*/
void rec(long int n,int k)
{
    if(n==1)
        dp[1]=0;
    else if(n<=k)
    {
        long int min=1e9;
        for(int j=n-1;j>=1;j--)
        {
            if(dp[j]==-1)
                rec(j,k);
            if(min>dp[j]+labs(h[n]-h[j]))
                min=dp[j]+labs(h[n]-h[j]);
        }
        dp[n]=min;
    }
    else
    {
        long int min=1e9;
        for(int j=n-1;j>=n-k;j--)
        {
            if(dp[j]==-1)
                rec(j,k);
            if(min>dp[j]+labs(h[n]-h[j]))
                min=dp[j]+labs(h[n]-h[j]);
        }
        dp[n]=min;
    }
}
int main()
{
    memset(dp,-1,100005*sizeof(long int));
    long int n;
    int k;
    scanf("%ld %d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%ld",&h[i]);
    }
    rec(n,k);
    printf("%ld\n",dp[n]);
    return 0;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll dp[1024][1024];

int main(){
    int H,W; cin >> H >> W;
    vector<string> s(H);
    rep(i,H) cin >> s[i];

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

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


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=200;
char s[maxn][maxn];
int f[2][maxn][maxn][maxn],g[2][maxn][maxn][maxn];
int s1[maxn][maxn],s2[maxn][maxn];
inline int check(int l1,int l2,int r1,int r2){
	if(s1[r1][r2]-s1[l1-1][r2]-s1[r1][l2-1]+s1[l1-1][l2-1]==0) return 1;
	if(s2[r1][r2]-s2[l1-1][r2]-s2[r1][l2-1]+s2[l1-1][l2-1]==0) return 1;
	return 0;
}
int main(){
	int n=read(),m=read();
	REP(i,1,n) scanf("%s",s[i]+1);
	REP(i,1,n) REP(j,1,m)
		if(s[i][j]=='#') s1[i][j]++;
		else s2[i][j]++;
	REP(i,1,n) REP(j,1,m){
		s1[i][j]+=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1];
		s2[i][j]+=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1];
	}
	DREP(i,n,1) REP(j,1,m) REP(k,j,m)
		if(check(i,j,i,k)){
			if(i==n) f[0][i][j][k]=n+1;
			else if(s[i][j]==s[i+1][j]) f[0][i][j][k]=f[0][i+1][j][k];
			else f[0][i][j][k]=i+1;
		}
		else g[0][i][j][k]=i;
	DREP(i,m,1) REP(j,1,n) REP(k,j,n)
		if(check(j,i,k,i)){
			if(i==m) g[0][i][j][k]=m+1;
			else if(s[j][i]==s[j][i+1]) g[0][i][j][k]=g[0][i+1][j][k];
			else g[0][i][j][k]=i+1;
		}
		else g[0][i][j][k]=i;
	for(int ans=1;;++ans){
		int x=(ans&1),y=(x^1);
		if(f[y][1][1][m]==n+1) return printf("%d\n",ans-1),0;
		REP(i,1,n) REP(j,1,m) REP(k,j,m)
			if(f[y][i][j][k]==n+1) f[x][i][j][k]=n+1;
			else f[x][i][j][k]=f[y][f[y][i][j][k]][j][k];
		REP(i,1,m) REP(j,1,n) REP(k,j,n)
			if(g[y][i][j][k]==m+1) g[x][i][j][k]=m+1;
			else g[x][i][j][k]=g[y][g[y][i][j][k]][j][k];
		REP(i,1,n) REP(j,1,m){
			int cur=i;
			DREP(k,m,j){
				while(cur<=n && g[x][j][i][cur]>k) ++cur;
				chkmax(f[x][i][j][k],cur);
			}
			cur=j;
			DREP(k,n,i){
				while(cur<=m && f[x][i][j][cur]>k) ++cur;
				chkmax(g[x][j][i][k],cur);
			}
		}
	}
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i = 2; i <= n;i++) {
   	int tmp = i;
    while(tmp % 2 == 0) {
    	tmp /= 2;
      	a[2]++;
    }
    for(int j = 3; j <= tmp;j+=2) {
    	while(tmp % j == 0) {
          	a[j]++;
       		tmp /= j;
        }
    }
  }
  long cnt = 1;
  for(int i = 2; i <= n; i++) {
    cnt *= (long)(a[i] + 1);
  	cnt %= (long)(1E9+7);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
num_list=list(map(int,input().split()))
ans = 0
for i in range(num_list[0]+1):
    str_target = str(i)
    p=0
    for n in str_target:
      p += int(n)
    if num_list[1]<= p and p<=num_list[2]:
        ans += i

print(ans)

Measured memory_bytes: 2940