akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const int mm=1e6;
ll d[mm];
int main()
{
	ll n,m,i,j,k,kk,a,b,t,ss,z,p;
	cin>>n;
	ll s=0;
	for(i=1;i<=n;i++)
	for(j=1;j<=n;j++)
	for(z=1;z<=n;z++)
	{
		p=__gcd(i,j);
		s+=__gcd(p,z);
	}
	cout<<s<<endl;
 
}


Measured memory_bytes: 3632
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1, N):
        if (sum([(X[i][k] - X[j][k]) ** 2 for k in range(D)]) ** 0.5 ).is_integer():
            ans += 1
print(ans)


Measured memory_bytes: 62084
import sys,heapq,math,resource,bisect
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))

n = inn()
a = []
for i in range(n):
    a.append(inn())
b = [a[n-1]]
for i in range(n-2,-1,-1):
    if a[i]>=b[-1]:
        b.append(a[i])
    else:
        j = bisect.bisect_right(b,a[i])
        b[j] = a[i]
    #ddprint(b)
print(len(b))


Measured memory_bytes: 8320
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class RootedNode{
public:
	vector<ll> parent;
	ll depth,dist;
	RootedNode():depth(0),dist(0){}
};

class RootedTree{
	int parent_size;

	void DFS(ConnectNodeInfo& connection,ll child,ll parent,ll dep,ll dist){
		node[child].parent[0] = parent;
		node[child].depth = dep;
		node[child].dist = dist;

		for(int i = 0;i < connection[child].size();i++){
			if(connection[child][i].first != parent){
				DFS(connection,connection[child][i].first,child,dep+1,dist+connection[child][i].second);
			}
		}
	}
public:
	vector<RootedNode> node;

	RootedTree(ConnectNodeInfo& connection){
		auto connection_size = connection.size();
		parent_size = 1;
		while((1LL<<parent_size)<connection_size) parent_size++;

		node.resize(connection_size);
		for(auto& x:node) x.parent.resize(parent_size,-1);
		DFS(connection,0,-1,0,0);
		for(int k=0;k<parent_size-1;k++){
			for(int v=0,ev=connection_size;v<ev;v++){
				if(node[v].parent[k] < 0) node[v].parent[k+1] = -1;
				else node[v].parent[k+1] = node[node[v].parent[k]].parent[k];
			}
		}
	}
	ll FindLCA(ll u,ll v){
		if(node[u].depth > node[v].depth) swap(u,v);
		for(int k=0;k<parent_size;k++){
			if((node[v].depth - node[u].depth) & (1LL<<k)){
				v = node[v].parent[k];
			}
		}
		if(u==v) return u;
		for(int k=parent_size-1;k>=0;k--){
			if(node[u].parent[k] != node[v].parent[k]){
				u = node[u].parent[k];
				v = node[v].parent[k];
			}
		}
		return node[u].parent[0];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	ConnectNodeInfo connect(N);
	REP(i,N-1){
		int u=in()-1,v=in()-1,w=in();
		connect.AddNonDirectionalConnection(u,v,w);
	}
	RootedTree tree(connect);

	for(auto& x:tree.node){
		if(x.dist%2) out(1);
		else out(0);
	}

	return 0;
}


Measured memory_bytes: 25856
#include<stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	long long sum = 0;
	for(int i = 1; i <= n; i++) if(i % 3 != 0 && i % 5 != 0) sum += i;
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 1736
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

int f(int w)
{
	int res=1150;
	
	if(w<10) return res;
	if(w<20) return (res+(w%10)*125);
	if(w<30) return (res+1250+(w%10)*140);
	if(w<40) return (res+1250+1400+(w%10)*160);
	else return (res+1250+1400+1600+(w-40)*160);

}

int main()
{
	int w;
	while(cin>>w)
	{
		if(w==-1) return 0;
		cout<<4280-f(w)<<endl;
	}
		return 0;
}

Measured memory_bytes: 1160
s=input()
n=len(s)
k=""
t=0
for i in range(n):
    if s[i]=="B" and t!=0:
        k=k[:-1]
        t=t-1
    if s[i]=="0":
        k=k+"0"
        t=t+1
    if s[i]=="1":
        k=k+"1"
        t=t+1
print(k)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
	int r,c;
	int dat[100][100];
	int sum=0;
	int ans[100];
	int i,j;
	scanf("%d %d",&r,&c);
	for(i=0 ; i<r ; i++){
		for(j=0 ; j<c ; j++){
			scanf("%d",&dat[i][j]);
		}
	}
	for(i=0 ; i<r ; i++){
		for(j=0 ; j<c+1 ; j++){
			if(j!=c){
				printf("%d",dat[i][j]);
				sum+=dat[i][j];
				ans[j]+=dat[i][j];
				printf(" ");
			}
			else{
				printf("%d\n",sum);
				ans[c]+=sum;
			}
		}
		sum=0;
	}
	for(i=0 ; i<c+1 ; i++){
		printf("%d",ans[i]);
		if(i!=c)printf(" ");
	}
	printf("\n");
	return 0;
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
#define PRINT_ENTER() cout << endl;

int main(){
    /* code */ 
    int a,b,c; cin >> a >> b >> c;
    bool is_kawaisou = false;
    if (a==b && b==c) {is_kawaisou = true;}
    if (a!=b && b!=c && c!=a) {is_kawaisou = true;}
    is_kawaisou ? (cout << "No") : (cout << "Yes");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, m, a, b;
bool lr[200008][2];

int main(){
	cin >> n >> m;
	for(ll i = 1; i <= m; i++){
		cin >> a >> b;
		if(a == 1){lr[b][0] = true;}
		if(b == 1){lr[a][0] = true;}
		if(a == n){lr[b][1] = true;}
		if(b == n){lr[a][1] = true;}
	}
	
	string ans = "IMPOSSIBLE";
	for(ll i = 2; i <= n-1; i++){
		if(lr[i][0] && lr[i][1]){
			ans = "POSSIBLE";
			break;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
          int n ;
          scanf("%d", &n) ;
          int fh;
          int f ;
          fh = (n/500) * 1000 ;
          n = n%500 ;
          f = (n/5)*5 ;
          int sum = fh + f ;
          printf("%d",sum) ;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int i,s=0,n,a[3001];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s+=a[i]-1;
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
using namespace atcoder;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return (int)(0);
}

int target = 0;

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> A(N);//memo(N+1);
    rep(i,N){
        cin >> A[i];
    }
    segtree<int, op, e> seg(int(600010));
    rep(i,N){
        ll tmp = seg.prod(max(A[i]-K, 0), A[i]+K+1);
        seg.set(A[i],tmp+1);
    }

    cout << seg.all_prod() << endl;
}

Measured memory_bytes: 14908
#include <cstdio>
#include <iostream>
#include <algorithm>
#define M 100005
using namespace std;
typedef long long llong;
int N,A[M],B[M],C[M];
llong ans=0,a,c;
int TANSAKU_AB(int i){
  int left=0,mid,right=N;
  while(left<right){
    mid=(left+right)/2;
    if(A[mid]>=B[i]) right=mid;
    else left=mid+1;
  }
  return left;
}
int TANSAKU_BC(int i){
  int left=0,mid,right=N;
  while(left<right){
    mid=(left+right)/2;
    if(B[i]<C[mid]) right=mid;
    else left=mid+1;
  }
  return N-left;
}
int main(){
  scanf("%d",&N);
  for(int i=0;i<N;i++) scanf("%d",&A[i]);
  for(int i=0;i<N;i++) scanf("%d",&B[i]);
  for(int i=0;i<N;i++) scanf("%d",&C[i]);
  sort(A,A+N);sort(B,B+N);sort(C,C+N);
  for(int i=0;i<N;i++){
    a=TANSAKU_AB(i);
    c=TANSAKU_BC(i);
    ans+=a*c;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;
const long long MOD = 1000000007;

long long dat[2 * MAX_N - 1];

//B
int main(void) {
	ll n;
	string s;
	cin >> n >> s;
	ll ans = 0;
	rep(i, 0, n) {
		if (i < n - 2 && s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
	}
	cout << ans << endl;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n;cin>>n && n;){
		string s,t; cin>>s>>t;
		int res=2*n;
		for(int i=0;i<=n;i++){
			string x=s+t.substr(i);
			if(x.substr(0,n)==s && x.substr(x.size()-n)==t)
				res=x.size();
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        if(a == b){
            System.out.println("EQUAL");
        }else if(a < b){
            System.out.println("LESS");
        }else{
            System.out.println("GREATER");
        }
    }
}

Measured memory_bytes: 25044
import sys
from bisect import bisect_right
from operator import itemgetter

read = sys.stdin.read

N, D, A, *XH = map(int, read().split())
XH = sorted(zip(*[iter(XH)] * 2), key=itemgetter(0))
D *= 2
X = [i for i, _ in XH]

damages = [0] * (N + 2)
answer = 0

for i, (x, h) in enumerate(XH, 1):
    damages[i] += damages[i - 1]
    if damages[i] >= h:
        continue

    h -= damages[i]
    cnt = (h + A - 1) // A
    answer += cnt
    damage = A * cnt
    damages[i] += damage
    damages[bisect_right(X, x + D) + 1] -= damage

print(answer)


Measured memory_bytes: 49364
#include <stdio.h>

int main() {
  int i, j;
  int pri[249612] = {};
  int n, p;

  for(i = 2; i < 249612; i++)
    pri[i] = 1;
  for(i = 2; i * i < 249612; i++) {
    if(pri[i] == 1) {
      for(j = (i * 2); j < 249612; j+=i){
        pri[j] = 0;
      }
    }
  }

  while(1) {
    p = 0;
    scanf("%d", &n);
    if(n == 0)
      break;
    else if (n < 0 || n > 123556)
      scanf("%d", &n);
    if(n != 1) {
      for(i = n + 1; i <= 2 * n; i++) {
        if(pri[i] == 1)
          p++;
      }
    }
    else 
      p = 1;

    printf("%d\n", p);
  }

  return 0;
}

Measured memory_bytes: 1580
#include"bits/stdc++.h"
using namespace std;
int a[100001],f[100001];
int n,k;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=2;i<=n;i++)
	{
		f[i]=f[i-1]+abs(a[i]-a[i-1]);
		for(int j=2;j<=min(i-1,k);j++)
			f[i]=min(f[i-j]+abs(a[i]-a[i-j]),f[i]);
	}
	printf("%d",f[n]);
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace test1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var list = new List<string>();
            for (int i = 0; i < N; i++)
            {
                list.Add(Console.ReadLine());
            }

            Console.WriteLine("AC x {0}", list.Where(x => string.Compare(x, "AC") == 0).Count());
            Console.WriteLine("WA x {0}", list.Where(x => string.Compare(x, "WA") == 0).Count());
            Console.WriteLine("TLE x {0}", list.Where(x => string.Compare(x, "TLE") == 0).Count());
            Console.WriteLine("RE x {0}", list.Where(x => string.Compare(x, "RE") == 0).Count());

            return;
        }
    }
}


Measured memory_bytes: 33464
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int vecnm[][] = new int[n][m];
		int i,j;
		int vec[] = new int[m];
		int veca[] = new int[n];
		
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				vecnm[i][j] = sc.nextInt();
			}
		}
		for(i=0;i<m;i++){
			vec[i] = sc.nextInt();
		}
		sc.close();
		
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				veca[i] += (vecnm[i][j]*vec[j]);
			}
		}
		for(i=0;i<n;i++){
			System.out.println(veca[i]);
		}
	}

}



Measured memory_bytes: 40808
fun main(args: Array<String>) {
    val N = nextInt()
    val S = Array(N) { next() }
    val Ch = Array(N) { IntArray(26) }
    val Co = IntArray(26)
    S.forEachIndexed { n, s ->
        s.forEach { ch -> Ch[n][ch - 'a'] += 1 }
    }
    for (n in Co.indices) {
        var min = Int.MAX_VALUE
        for (m in Ch.indices) min = Math.min(min, Ch[m][n])
        Co[n] = min
    }
    val ans = mutableListOf<String>()
    Co.forEachIndexed { offset, count ->
       if (count > 0) ans.add(("" + ('a' + offset)).repeat(count))
    }
    println(ans.joinToString(""))
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)


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

using namespace std;

int main() {
  int N, L;
  cin >> N >> L;

  vector<int> apples(N);
  for (int i = 0; i < N; i++) {
    apples[i] = L + i;
  }

  int a = abs(apples[0]);
  int t = 0;
  for (int i = 1; i < N; i++) {
    if (abs(apples[i]) < a) {
      a = abs(apples[i]);
      t = i;
    }
  }

  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (i != t) sum += apples[i];
  }

  cout << sum << endl;

  return 0;
}


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

int main() {
  int a;
  cin>>a;
  if(a%2==0) cout<<a*a/4<<endl;
  else cout<<(a-1)*(a+1)/4<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	/*int a, b, c;
	cin >> a >> b >> c;
	int ans;
	if (a - b > c)ans = 0; else ans = c - a + b;
	cout<<ans;*/


	/*int N;
	cin >> N;
	int ans = 0;
	int i;
	for (i = 1; i <=N;i++) {
		int j = 10;
		if (i >= j / 10 && i < j)ans++;
		else {
			i = 10 * i - 1;
			j *= 100;
		}
	}
	cout << ans;*/


	int N;
	cin >> N;
	vector<int>h(N + 1);
	rep(i, N)cin >> h[i + 1];
	rep(i, N) {
		if (h[i + 1] > h[i])h[i + 1]--;
		if (h[i + 1] < h[i]) {
			cout << "No"; return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 640
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

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

    
    if(n.find('A') != n.npos && n.find('B') != n.npos){
        cout<< "Yes";
    }else{
        cout<< "No";
    }


    return 0;
}

Measured memory_bytes: 256
n = int(input())
AB = list(list(map(int,input().split())) for _ in range(n))
CD = list(list(map(int,input().split())) for _ in range(n))

# print(*CD,sep='\n',end='\n---\n')
# print(*sorted(CD, key=lambda x: x[0]),sep='\n',end='\n---\n')
# CD.sort(key=lambda x: x[1])
# CD.sort(key=lambda x: x[0])
CD.sort()
# print(*CD,sep='\n',end='\n---\n')
# print(*AB,sep='\n',end='\n---\n')
AB.sort(key=lambda x: x[1], reverse=True)
# print(*AB,sep='\n',end='\n---\n')

dim_r = [[] for _ in range(n)]
dim_b = [[] for _ in range(n)]
# cnt_r = [0]*n
# cnt_b = [0]*n
for b in range(n):
    bx, by = CD[b]
    for r in range(n):
        rx, ry = AB[r]
        if rx < bx and ry < by:
            dim_r[r] += [b]
            dim_b[b] += [r]
            # cnt_b[b] += 1
            # cnt_r[r] += 1

# print(n)
# print(*AB,sep='\n',end='\n---\n')
# print(*CD,sep='\n',end='\n---\n')
# print(*dim_r,sep='\n',end='\n---\n')
# print(*dim_b,sep='\n',end='\n---\n')
# # print(cnt_b,end='\n---\n')

ans = 0

inf = 1000000000
vis_r = [False]*(n)
for b in range(n):
    bx, by = CD[b]
    # print('b,bx,by',b,bx,by)
    max_ry = -1
    max_r = -1
    for r in dim_b[b]:
        if vis_r[r]: continue
        # print('r,rx,ry',r,rx,ry)
        rx, ry = AB[r]
        if max_ry < ry:
            max_ry = ry
            max_r = r
    if max_r >= 0:
        # print('max_r,max_ry',max_r,max_ry)
        vis_r[max_r] = True
        ans += 1
    # print('---')
print(ans)


Measured memory_bytes: 3188
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!int;
  writeln(0.bitSet(n.bsr));
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
 int n[15]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  int a,b;
  scanf("%d%d",&a,&b);
  if(n[a]==n[b]) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	string s;
	cin >> s;
	ll ans = 0;
	for (int i = 0; i < s.size() - 1; i++) {
		if ((s[i] == 'B' && s[i + 1] == 'W') || (s[i] == 'W' && s[i + 1] == 'B')) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> ans;
  for (int i = 1; 5 * i + 1 <= 55555; i++) {
    bool P = true;
    for (int j = 2; j * j <= 5 * i + 1; j++) {
      if ((5 * i + 1) % j == 0) {
        P = false;
        break;
      }
    }
    if (P) ans.push_back(5 * i + 1);
    if (ans.size() == N) break;
  }
  for (int i = 0; i < N; i++) cout << ans.at(i) << " ";
  cout << endl;
}

Measured memory_bytes: 3592
#define pi 3.14159265358979323846

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

int main() {
	
	long double a,b,h,m;
	cin>>a>>b>>h>>m;
	
	long double hdeg=h*30;
	long double mdeg=m*6;
	hdeg+=mdeg/12;
	long double deg = abs(hdeg-mdeg);
	
	long double cosdeg = cos(deg *pi/180);
	long double asqr=a*a;
	long double bsqr=b*b;
	long double c = sqrt(asqr+bsqr-2*a*b*cosdeg);
	cout<< fixed << showpoint ;
	cout<< setprecision(20);
	cout<<c;
	
	return 0;
}

Measured memory_bytes: 4148
l = input().split()
A = int(l[0])

ans = 0
if A > 105 - 1:
    ans = ans + 1

if A > 135 - 1:
    ans = ans + 1

if A > 165 - 1:
    ans = ans + 1

if A > 189 - 1:
    ans = ans + 1

if A > 195 - 1:
    ans = ans + 1


print(ans)

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

int main(){
  int INF = 1000000000;
  int h, w;
  int sy, sx, gy, gx;
  cin >> h >> w >> sy >> sx >> gy >> gx;
  sx--; sy--; gx--; gy--;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vvi dis(h, vi(w, INF));
  dis[sy][sx] = 0;
  deque<pair<int, int>> que;
  que.push_front({sy, sx});
  vector<int> v = {1, 0, -1, 0, 1};
  while(!que.empty()){
    int cy = que.front().first;
    int cx = que.front().second;
    que.pop_front();
    rep(i,4){
      rep(j,4){
        int ny = cy + v[i];
        int nx = cx + v[i+1];
        if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
        if(s[ny][nx] == '#') continue;
        if(dis[cy][cx] < dis[ny][nx]){
          dis[ny][nx] = dis[cy][cx];
          que.push_front({ny, nx});
        }
      }
    }
    for(int i = -2; i<=2; i++){
      for(int j = -2; j<=2; j++){
        int ny = cy + i;
        int nx = cx + j;
        if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
        if(s[ny][nx] == '#') continue;
        if(dis[cy][cx] + 1 < dis[ny][nx]){
          dis[ny][nx] = dis[cy][cx] + 1;
          que.push_back({ny, nx});
        }
      }
    }
  }
  if(dis[gy][gx] == INF) dis[gy][gx] = -1;
  cout << dis[gy][gx] << endl;
}


Measured memory_bytes: 9544
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


int main() {
#ifdef _DEBUG
	printf( "debug\n" );
#endif
	for ( int i = 1; i < 10; i++ ) {
		for ( int j = 1; j < 10; j++ ) {
			printf( "%dx%d=%d\n", i, j, i * j );
		}
	}
	return 0;
}

Measured memory_bytes: 1096
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll n;
cin>>n;
ll v[n];
ll c[n];
for(int i=0;i<n;i++){
    cin>>v[i];
}
for(int i=0;i<n;i++){
    cin>>c[i];
}
ll sum=0;
for(int i=0;i<n;i++){
    sum+=seinomi(v[i]-c[i]);
}
cout<<sum<<endl;
}












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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

ll dp[101][2][5]; // dim, 確定フラグ, 0じゃない数の数

int main(){
    string s; cin>>s;
    int L = s.size();
    int K; cin>>K;
    
    REP(d,101) REP(flag,2) REP(k,5) dp[d][flag][k] = 0LL;
    dp[0][0][0] = 1;
    REP(d,L){
        REP(flag,2){
            REP(k,4){
                int x = ctoi(s[d]);
                REP(i,10){ // 注目している座を0から9で埋める
                    if(x < i && flag==0){ continue; } // 未確定かつ大きい場合はあり得ない
                    
                    ll flag2 = (i<x || flag); // 進む先の小ささは確定しているか
                    ll k2 = k; // 進む先の0じゃない数の数
                    if(i != 0){ ++k2; } //0じゃない場合k2は増える
                    
                    dp[d+1][flag2][k2] += dp[d][flag][k];
                }
            }
        }
    }
    ll ans = dp[L][0][K] + dp[L][1][K];
    cout << ans << "\n";
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; i<n; i++)
#define REP2(i, a, b) for(int i=a; i<b; i++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    long long N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    map<int, vector<int>> mp;
    REP(i, N) mp[A[i]].push_back(i);
    vector<int> v_nxt(N);
    REP(i, N){
        auto &v = mp[A[i]];
        auto itr = upper_bound(v.begin(), v.end(), i);
        if(itr != v.end()){
            v_nxt[i] = *itr;
        }else{
            v_nxt[i] = v[0];
        }
    }

    int cur = 0;
    long long KN = K*N;
    set<int> hoge;
    while(true){
        if(hoge.find(cur) != hoge.end()) break;
        hoge.insert(cur);
        int nxt = v_nxt[cur];
        if(nxt <= cur){
            if(N-(cur-nxt)+1>KN) break;
            KN -= N - (cur - nxt) + 1;
        }else if(nxt > cur){
            if(nxt-cur+1>KN) break;
            KN -= nxt - cur + 1;
        }
        cur = (nxt + 1) % N;
    }
    int curzero = cur;

    long long period = 0;
    while(true){
        int nxt = v_nxt[cur];
        if(nxt <= cur){
            period += N - (cur - nxt) + 1;
        }else if(nxt > cur){
            period += nxt - cur + 1;
        }
        cur = (nxt + 1) % N;
        if(cur == curzero) break;
    }

    KN %= period;

    while(true){
        int nxt = v_nxt[cur];
        if(nxt <= cur){
            if(N-(cur-nxt)+1>KN) break;
            KN -= N - (cur - nxt) + 1;
        }else if(nxt > cur){
            if(nxt-cur+1>KN) break;
            KN -= nxt - cur + 1;
        }
        cur = (nxt + 1) % N;
    }
    assert((cur+KN)%N==0);
    vector<int> ans;
    set<int> st;
    for(int i=0; i<KN; i++){
        int j = i+cur;
        if(st.find(A[j]) == st.end()){
            ans.push_back(A[j]);
            st.insert(A[j]);
        }else{
            while(true){
                int hog = ans.back();
                ans.pop_back();
                st.erase(hog);
                if(hog==A[j]){
                    break;
                }
            }
        }
    }
    for(auto x : ans)
        cout << x << " ";
    cout << endl;
    return 0;
}


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

int main(){
    int n;
    int taroP = 0;
    int hanakoP = 0;
    string taro,hanako;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> taro;
        cin >> hanako;
        if (taro == hanako) {
            taroP += 1;
            hanakoP += 1;
        }else {
            if (taro > hanako){
                taroP += 3;
            }else {
                    hanakoP += 3;
                }
            }
        }
    cout << taroP << " " << hanakoP << endl;
    
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';

/////////////////////////////////////////////////////////////////////////////////

struct LinearSystemIncidence {
    struct Edge {
        int to,id;
        Edge() {}
        Edge(int to, int id) : to(to), id(id) {} 
    };
    int N,M;
    vector<vector<Edge>> G;
    vector<int> x,seen;

    LinearSystemIncidence() {}
    LinearSystemIncidence(int N) : N(N), M(0), G(N), seen(N) {}

    void add_edge(int u, int v, int id) {
        ++M;
        G[u].emplace_back(v,id);
        G[v].emplace_back(u,id);
        x.emplace_back(0);
    }

    int dfs(int v,const vector<int> &c) {
        seen[v] = true;
        int ret = c[v];
        for (const Edge &e : G[v]) {
            if (seen[e.to]) continue;
            int tmp = dfs(e.to,c);
            x[e.id] ^= tmp;
            ret ^= tmp;
        }
        return ret;
    }

    vector<int> solve(const vector<int> &c) {
        fill(x.begin(),x.end(),0);
        fill(seen.begin(),seen.end(),0);
        for (int v = 0; v < N; ++v) {
            if (seen[v]) continue;
            if (dfs(v,c)) return vector<int> {};
        }
        return move(x);
    }
};

//////////////////////////////////////////////////////////////////////////////////

void ABC155F() {
    int N,M; cin >> N >> M;
    vector<pii> A(N);
    vector<int> L(M),R(M);
    rep(i,N) cin >> A[i].first >> A[i].second;
    rep(i,M) cin >> L[i] >> R[i];

    sort(all(A));
    vector<int> LL(M),RR(M);
    rep(i,M) {
        LL[i] = lower_bound(all(A),pii(L[i],-1)) - A.begin();
        RR[i] = upper_bound(all(A),pii(R[i],2)) - A.begin();
    }
    vector<int> B(N+1);
    rep(i,N+1) {
        if (i==0) B[i] = A[i].second;
        else if (i==N) B[i] = A[i-1].second;
        else B[i] = A[i].second^A[i-1].second;
    }
    LinearSystemIncidence LSI(N+1);
    rep(i,M) LSI.add_edge(LL[i],RR[i],i);
    auto ans = LSI.solve(B);
    if (ans.empty()) {
        cout << -1 << ln;
    } else {
        cout << accumulate(all(ans),0) << ln;
        rep(i,M) {
            if (ans[i]) cout << i+1 << " ";
        }
        cout << ln;
    }
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ABC155F();
}

/*
  verified on 2020/07/17
*/

Measured memory_bytes: 20600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    string c;
    cin>>n>>c;
    int cntR=count(all(c),'R');
    int cntW=count(all(c),'W');
    int ans=count(c.begin(),c.begin()+cntR,'W');
    chmin(ans,(int)count(c.begin()+n-cntW,c.end(),'R'));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (1 << 22);

struct pt
{
	int x, y;
	pt() { }
};

int H[maxn], F[maxn], used[maxn];

struct hash_table
{
	hash_table() { }

	int getpos(int h) const
	{
		int i = h % maxn;
		for (; used[i] && H[i] != h; ++i) if (i + 1 == maxn) i = -1;
		return i;
	}

	int& operator[](int h)
	{
		int i = getpos(h);
		H[i] = h;
		used[i] = 1;
		return F[i];
	}
};

struct fenwick
{
	int n;
	hash_table F;

	fenwick() { n = inf; }

	void upd(int i, int x)
	{
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	}

	int get(int i)
	{
		int res = 0;

		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);

		return res;
	}
};

int n;
pt s, f;
pt p[maxn];

bool read()
{
	if (scanf("%d %d %d %d %d", &s.x, &s.y, &f.x, &f.y, &n) != 5)
		return false;

	forn (i, n)
		scanf("%d %d", &p[i].x, &p[i].y);

	return true;
}

bool cmp(pt a, pt b) { return make_pair(a.x, a.y) < make_pair(b.x, b.y); }

void solve()
{
	if (s.x > f.x)
		swap(s, f);

	if (s.y > f.y)
	{
		f.y = 2 * s.y - f.y;

		forn (i, n)
			p[i].y = 2 * s.y - p[i].y;
	}

	vector<pt> pp;

	forn (i, n)
		if (s.x <= p[i].x && p[i].x <= f.x && s.y <= p[i].y && p[i].y <= f.y)
			pp.push_back(p[i]);

	sort(pp.begin(), pp.end(), cmp);
	fenwick dp;

	forn (i, size(pp))
		dp.upd(pp[i].y, dp.get(pp[i].y) + 1);

	int lis = dp.get(inf);
	long double ans = 0;

	if (lis != min(f.y - s.y, f.x - s.x) + 1)
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * lis;
	else
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * (lis - 1) + 10 * M_PI;

	printf("%.15f\n", (double) ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 52848
#include<bits/stdc++.h>
#define LL long long
#define SZ(x) (int)x.size()-1
#define F(i,a,b) for (int i=a;i<=b;++i)
#define DF(i,a,b) for (int i=a;i>=b;--i)
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
int read(){
    char ch=getchar(); int w=1,c=0;
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
    for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
    return w*c;
}
const int M=5050;
LL dp[M][M];
int n,A,B,a[M],pos[M];
int val(int x,int d){
	if (2*pos[x]<d) return A;
	if (2*pos[x]>d) return B;
	return 0;
}
int main(){
	n=read(); A=read(); B=read();
	F(i,1,n) a[i]=read(),pos[a[i]]=i;
	ms(dp,1); dp[0][0]=0;
	F(i,0,n){
		F(j,0,n){
			if (i) dp[i][j]=min(dp[i][j],dp[i-1][j]);
			if (j) dp[i][j]=min(dp[i][j],dp[i][j-1]+val(j,2*i+1));
			if (i&&j) dp[i][j]=min(dp[i][j],dp[i-1][j-1]+val(j,2*i));
//			cout<<i<<" "<<j<<" "<<dp[i][j]<<"   ouoh\n";
		}
	}
	cout<<dp[n][n]<<"\n";
    return 0;
}



Measured memory_bytes: 199552
N=int(input())
C=[] #i駅からi+1駅までC[i]秒で到着
S=[] #i駅からS[i]秒後に出発、それ以降はF[i]秒おき
F=[]

for _ in range(N-1):
    c,s,f=map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(N-1):
    t=S[i]+C[i]
    for j in range(i+1,N-1):
        if t<=S[j]:
            t=S[j]
        elif t%F[j]!=0:
            t+=F[j]-t%F[j]
        t+=C[j]
    print(t)
print(0)

Measured memory_bytes: 3064
import kotlin.comparisons.compareBy
fun main(args: Array<String>) {
    val N = nextInt()
    val S = Array(N) { next() }
    val M = S.groupBy { it }.map { it.key to it.value.size }
    val max = M.maxBy { it.second }!!.second
    println(M.filter { it.second == max }.map { it.first }.sorted().joinToString(separator="\n"))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun printErr(value: Any) = System.err.println(value)


Measured memory_bytes: 112188
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

long long int gcd(long long int a, long long int b){
	while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main(){
	long long int n;
	vector<pair<long long int, long long int>> v;
	long long int a, b;

	cin >> n;

	long long int i;

	for(i = 0; i < n; i++){
		cin >> a >> b;
		v.push_back(make_pair(b, a));
	}

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

	long long int t = 0;
	int flag = 1;
	for(i = 0; i < n; i++){
		t += v[i].second;
		if(v[i].first < t){
			flag = 0;
			break;
		}
	}

	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}
	


Measured memory_bytes: 6384
#include<iostream>
int main() {
  int a[4],b[4];
  std::cin>>a[0]>>a[1]>>a[2]>>a[3];
  std::cin>>b[0]>>b[1]>>b[2]>>b[3];
  int i,j;
  if((i=a[0]+a[1]+a[2]+a[3]) >= (j=b[0]+b[1]+b[2]+b[3])) {
    std::cout<<i<<std::endl;
  }else{
    std::cout<<j<<std::endl;
  }
}

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

int main(){
  int n,m;
  cin >> n >> m;
  pair<int ,int> a[n]={};
  int ans1=0,ans2=0;
  for(int i=0;i<m;i++){
    int b;
    cin >> b;
    string s;
    cin >> s;
    if(s=="WA" && a[b-1].first==0){a[b-1].second++;}
    if(s=="AC" && a[b-1].first==0){a[b-1].first++;
                                  ans1++;
                                  ans2+=a[b-1].second;}
    
  }
  cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int P,Q,R;
  vector<int> sum;
  cin >> P;
  cin >> Q;
  cin >> R;
  sum.push_back(P+Q);
  sum.push_back(Q+R);
  sum.push_back(R+P);
  sort(sum.begin(), sum.end());
  cout << sum[0] << endl;
  return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Decayed Bridges
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_M = 100000;

/* typedef */

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

struct UFT {
  int links[MAX_N], ranks[MAX_N], sizes[MAX_N];
  UFT() {}

  void clear(int n) {
    for (int i = 0; i < n; i++) links[i] = i, ranks[i] = sizes[i] = 1;
  }

  int root(int i) {
    int i0 = i;
    while (links[i0] != i0) i0 = links[i0];
    return (links[i] = i0);
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  bool same(int i, int j) { return root(i) == root(j); }

  int merge(int i0, int i1) {
    int r0 = root(i0), r1 = root(i1), mr;
    if (r0 == r1) return r0;
    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      mr = r0;
    }
    else {
      links[r0] = r1;
      sizes[r1] += sizes[r0];
      mr = r1;
    }
    return mr;
  }
};

/* global variables */

pii es[MAX_M];
ll cs[MAX_M];
UFT uft;

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    es[i] = pii(a, b);
  }

  uft.clear(n);
  ll gc = (ll)n * (n - 1) / 2;

  for (int i = m - 1; i >= 0; i--) {
    cs[i] = gc;

    int &a = es[i].first, &b = es[i].second;
    if (! uft.same(a, b)) {
      gc -= (ll)uft.size(a) * uft.size(b);
      uft.merge(a, b);
    }
  }

  for (int i = 0; i < m; i++) printf("%lld\n", cs[i]);
  return 0;
}


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

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

    if(N%10 == 3) cout << "bon" << endl;
    else if(N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8){
        cout << "pon" << endl;
    }
    else cout << "hon" << endl;
}

Measured memory_bytes: 3640