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

using namespace std;

typedef long long ll;

// esdgfjasgdfasjdlf
//fasdkjfajsdgfjkasdf
//flaskjdgfkjasdgfjkas
//fasdlkfgsljdf

#define MAXN 100010

ll x[MAXN], dif[MAXN], dag[MAXN], d[MAXN], cc[MAXN];
vector<ll> dor[MAXN];
ll answer[MAXN];
ll n, m, k;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	cin >> m >> k;
	for (int i = 1; i < n; i++)
		dif[i] = i;
	for (int i = 0; i < m; i++) {
		int z; cin >> z;
		swap(dif[z], dif[z - 1]);
	}
	for (int i = 1; i < n; i++)
		dag[dif[i]] = i;
	for (int i = 1; i < n; i++) {
		int v = i, cnt = 0;
		while (!d[v]) {
			d[v] = i; cc[v] = cnt++;
			dor[i].push_back(v);
			v = dag[v];
		}
	}
	for (int i = 1; i < n; i++) 
		answer[dor[d[i]][(k + cc[i]) % (int)dor[d[i]].size()]] = i;
	answer[0] = x[0];
	for (int i = 1; i < n; i++)
		answer[i] = answer[i - 1] - x[answer[i] - 1] + x[answer[i]];
	for (int i = 0; i < n; i++)
		cout << answer[i] << '\n';
	//system("pause");
	return 0;
}

Measured memory_bytes: 11392
#include <iostream>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  while(true){
    string dreamOrErase = "";
    string eraser = "";
    string dreamer = "";
    if(str.size() == 0){
      cout << "YES";
      return 0;
    }
    if(str.size() >= 5){
      dreamOrErase = str.substr(str.size()-5, 5);
    }
    if(str.size() >= 6){
      eraser = str.substr(str.size()-6, 6);
    }
    if(str.size() >= 7){
      dreamer = str.substr(str.size()-7, 7);
    }
    if(dreamOrErase == "dream" || dreamOrErase == "erase"){
      for(int i=0; i<5; i++) str.pop_back();
    }else if(eraser == "eraser"){
      for(int i=0; i<6; i++) str.pop_back();
    }else if(dreamer == "dreamer"){
      for(int i=0; i<7; i++) str.pop_back();
    }else{
      cout << "NO";
      return 0;
    }
  }
}

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

int main() {
  int n;
  cin >> n;
  for(int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (i * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int p[6],q[6];
double f(double mm){
    double v=0;
    REP(i,6){
        v+=max(mm*p[i],(1-mm)*q[i]);
    }
    return v;
}
int main(){
    REP(i,6)RI(p[i]);
    REP(i,6)RI(q[i]);
    double ll=0,rr=1;
    REP(k,200){
        double mm1=ll*0.6+rr*0.4;
        double mm2=ll*0.4+rr*0.6;
        double v1=f(mm1);
        double v2=f(mm2);
        if(v1<v2)rr=mm2;
        else ll=mm1;
    }
    printf("%.12f\n",f((ll+rr)*0.5)*0.01);
    return 0;
}


Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;


//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

int main() {
	string S; cin >> S;
	ll N = S.size() - 1;
	if (S[N] == '3') cout << "bon" << endl;
	else if (S[N] == '0' || S[N] == '1' || S[N] == '6' || S[N] == '8') {
		cout << "pon" << endl;
	}
	else cout << "hon" << endl;
}

Measured memory_bytes: 10912
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
 
using namespace std;
 
int main()
{
  int n ,l;
  cin >> n >> l;
  vector <string> v;
  for(int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    v.push_back(s);
  }
  
  sort(v.begin(), v.end());
  for(int i = 0; i < n; i++)
  {
    cout << v[i];
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;

template<typename T>
class Heap
{
public:
  int H; // ??????????????§??????
  vector<T> A;
  Heap(int n)
  {
    H = n;
    A.resize(n+1);
    A[0] = 0;
  }
  ~Heap(){}
  T* operator[](int i)
  {
    return &A[i];
  }
  int parent(int i) {return i/2;}
  int left(int i) {return 2*i;}
  int right(int i) {return 2*i+1;}
  void printInfo(int i)
  {
    cout << "node " << i << ": key = " << A[i] << ", ";
    if(parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
    if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
    if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
    cout << endl;
  }
};

int main()
{
  int H; cin >> H;
  Heap<int> T(H);
  for(int i = 1; i <= H; i++) cin >> *T[i];//scanf("%d", T[i]);
  for(int i = 1; i <= H; i++) T.printInfo(i);
  return 0;
}

Measured memory_bytes: 1200
package main

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

func Min(a []int) (min int) {
	for i, v := range a {
		if i == 0 {
			min = v
			continue
		}
		if min > v {
			min = v
		}
	}
	return
}

func Max(a []int) (max int) {
	for i, v := range a {
		if i == 0 {
			max = v
			continue
		}
		if max < v {
			max = v
		}
	}
	return
}

func NextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, _ := NextInt(sc)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i],_ = NextInt(sc)
	}

	w := bufio.NewWriter(os.Stdout)

	q, _ := NextInt(sc)
	for i := 0; i < q; i++ {
		com, _ := NextInt(sc)
		b, _ := NextInt(sc)
		e, _ := NextInt(sc)
		switch com {
		case 0:
			fmt.Fprintln(w, Min(a[b:e]))
		case 1:
			fmt.Fprintln(w, Max(a[b:e]))
		default:
			panic("Unexpected command")
		}
	}

	w.Flush()
}



Measured memory_bytes: 1132
h, n =map(int, input().split())
dp = [float('inf')] * (h+1)
dp[0] = 0

magics = [list(map(int, input().split())) for i in range(n)]
magics.sort()

for i in range(h+1):
    a = dp[i]
    for attack, magic in magics:
        next_index = min(i+attack, h)
        dp[next_index] = min(dp[next_index], a + magic)

print(dp[h])


Measured memory_bytes: 44252
#!/usr/bin/env python3
import sys
import heapq


def solve(N: int, A: "List[int]"):
    A = sorted(A, reverse=True)

    queue = [-A[0]]
    heapq.heapify(queue)

    answer = 0
    for i, a in enumerate(A[1:]):
        max_val = heapq.heappop(queue)
        answer += -max_val

        heapq.heappush(queue, -a)
        heapq.heappush(queue, -a)
    print(answer)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 45000
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		if(n==1)
		{
			Console.WriteLine(1);
			return;
		}
		PrimeFactCalc pfc = new PrimeFactCalc(n);
		Dictionary<int, int> dict = new Dictionary<int, int>();
		long ans = 1;
		for(long i=2; i<=(long)n; i++)
		{
			dict = pfc.GetPrimeFactDictionary((int)i);
			int func = 1;
			foreach(var pair in dict)
			{
				func *= (pair.Value + 1);
			}
			ans += (long)func * i;
		}
		Console.WriteLine(ans);
	}
}

public class PrimeFactCalc
{
	private int _nMax;
	private long _mod;

	public int[] ArrSPF {get; set;}

	public PrimeFactCalc(int nMax = 1000000, long mod = 1)
	{
		_nMax = nMax;
		_mod = mod;
		InitArray();
	}

	public void InitArray()
	{
		ArrSPF = new int[_nMax+1];
		for(int i = 0; i <= _nMax; i++) ArrSPF[i] = i;
		for(int i = 2; i * i <= _nMax; i++)
		{
			if(ArrSPF[i]==i)
			{
				for(int j = i * i; j <= _nMax; j += i)
				{
					if(ArrSPF[j]==j) ArrSPF[j] = i;
				}
			}
		}
	}

	public Dictionary<int, int> GetPrimeFactDictionary(int n)
	{
		Dictionary<int, int> ret = new Dictionary<int, int>();
		while(n != 1)
		{
			int pf = ArrSPF[n];
			if(ret.ContainsKey(pf)) ret[pf]++;
			else ret.Add(pf, 1);
			n /= pf;
		}
		return ret;
	}


}





Measured memory_bytes: 86140
using System;
using System.Collections.Generic;
public class diverta2019PC2A {
    public static void Main() {
        int N, K;
        string[] str = Console.ReadLine().Split(' ');
        N = int.Parse(str[0]);
        K = int.Parse(str[1]);
        if (K != 1) System.Console.WriteLine(N - K);
        else System.Console.WriteLine(0);
    }
}


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

using namespace std;

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a,b;
    cin >> a >> b;

    if (b % a == 0)
    cout << a + b << endl;
    else 
    cout << b-a << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#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(int i = (n); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int d[10][10];

int main(){
	int n = 0;
	while(cin >> n, n){
		Rep(i, 10) Rep(j, 10) d[i][j] = inf;
		Rep(i, 10) d[i][i] = 0;
		int mi = 10, ma = 0;
		Rep(i, n){
			int a, b, c; cin >> a >> b >> c;
			d[a][b] = c; d[b][a] = c;
			mi = min(mi, min(a, b));
			ma = max(ma, max(a, b));
		}
		
		For(k, mi, ma + 1) For(i, mi, ma + 1) For(j, mi, ma + 1){
			d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
		}
		int ans = inf, p = 0;
		For(i, mi, ma + 1){
			int cnt = 0;
			For(j, mi, ma + 1){
				if(i == j) continue;
				cnt += d[i][j];
			}
			if(ans > cnt){
				ans = cnt; p = i;
			}
		}
		cout << p << " " << ans << endl;
	}
	return 0;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 55, M = 3e3, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int n, a[10];

vector<ll> v;

ll solve(int i){
    if(i == n){
        ll sum = 0;
        for(int i = 0;i < v.size();i++) sum += v[i];
        return sum;
    }

    ll ret = 0;

    v.push_back(a[i]);
    ret = solve(i + 1);
    v.pop_back();

    if(!v.empty()){
        ll last = v.back();    v.pop_back();
        v.push_back(last * 10 + a[i]);
        ret += solve(i + 1);
        v.pop_back(); v.push_back(last);
    }

    return ret;
}

int main(){
    init();


    string s;   cin >> s;   n = s.size();
    for(int i = 0;i < n;i++) a[i] = s[i] - '0';
    cout << solve(0);
}

Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
  // ????????????????????????
  var inputs = chunk.toString().trim().split('\n');
  var cols = inputs.filter(function(v) {
    return v !== '0 0';
  })
  .map(function(v) {
    return v.split(' ')
          .map(Number)
          .sort(function(a ,b) {
            return a - b;
          })
          .join(' ');
  })
  .join('\n');

  console.log(cols);

});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

string r = "yuiophjklnm";
string l = "qwertasdfgzxcvb";

bool hand(char c){
  for(int i = 0; i < r.length(); i++){
    if(c == r[i])return true;
  }
  return false;
}

int main(){
  string str;
  while(cin >> str, str != "#"){
    bool now = hand(str[0]);//r = true, l = false;

    int cnt = 0;
    for(int i = 1; i < str.length(); i++){
      if(now != hand(str[i])){
        cnt++;
        now = !now;
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 3080
local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read"*n"end end return unpack(r)end 
local function istri(a,b,c)
if(a==b or b==c or c==a)then return false end
local max=math.max(a,b,c)
if(max==a)then return a<b+c end
if(max==b)then return b<a+c end
return c<a+b
end
N=io.read"*n"
L=reada(N)
c=0
for i=1,N do
for j=i+1,N do
for k=j+1,N do
if(istri(L[i],L[j],L[k]))then c=c+1 end
end end end
print(c)

Measured memory_bytes: 2772
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int K = Integer.parseInt(sc.get());
		int[] A = new int[N];
		Arrays.setAll(A, $ -> Integer.parseInt(sc.get()));
		for (int i = K; i < N; i++) {
			System.out.println(A[i - K] < A[i] ? "Yes" : "No");
		}
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 65796
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
#define ll long long
#define ld long double
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a, start) for (int i = start; i < (a).size(); ++i) cin >> (a)[i]
#define out(a) for (auto qwe : a) cout << qwe << " "
#define tests int test; cin >> test; while (test--)
#define fileio() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;

const int mxn = 200000;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    if (n == 1) {
        cout << 0;
        return 0;
    }

    int s = 0;

    for (int nm = 1; nm <= sqrt(n); ++nm) {
        int m = n / nm - 1;

        if (nm == n % m) s += m;
    }

    cout << s;
}



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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int k, a, b;
	cin>>k>>a>>b;
	int tmp = (b/k) - (a-1)/k;
	if(tmp){
		cout<<"OK";
	}else{
		cout<<"NG";
	}

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int w, a, b;
    cin >> w >> a >> b;

    if(a > b)
    	cout << max(0, a - b - w);
    else
    	cout << max(0, b - a - w);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 10;
ll a[N];

int main() {
	int n, x;
	cin >> n >> x;
	for(int i = 1; i <= n; ++i) {
		scanf("%lld", &a[i]);
	}
	ll pos = 0;
	for(int i = 2; i <= n; ++i) {
		ll gg = max(0ll, (a[i] + a[i - 1]) - x);
		a[i] -= min(a[i], gg);
		pos += gg;
	}
	printf("%lld\n", pos);
	return 0;
}

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

using namespace std;
struct Point {
    double x, y;
    bool operator < (const Point& p) const {
        if(x != p.x) return x < p.x;
        return y < p.y;
    }
};


double dist(double x, double y){
    return sqrt(x * x + y * y);
}
double dist(Point p, Point q){
    return dist(p.x - q.x, p.y - q.y);
}

int main(){
    int N;
    cin >> N;
    vector<Point> ps(N);
    //const double th = M_PI * (0.25 + 0.5 * rand() / RAND_MAX);
    const double th = 0;
    REP(i, N){
        double x, y;
        scanf("%lf %lf", &x, &y);
        ps[i].x = +cos(th) * x + sin(th) * y;
        ps[i].y = -sin(th) * x + cos(th) * y;
    }
    sort(ps.begin(), ps.end());
    double ans = dist(ps[0], ps[1]);
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N && ps[j].x - ps[i].x < ans; j++){
            ans = min(ans, dist(ps[i], ps[j]));
        }
    }
    printf("%.12f\n", ans);
    return 0;
}

Measured memory_bytes: 2580
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

signed main()
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int a = A * X + B * Y;
	int b = C * 2 * X + MAX(0, Y - X) * B;
	int c = C * 2 * Y + MAX(0, X - Y) * A;

	int ans = MIN(a, MIN(b, c));

	cout << ans << endl;
}







Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int n;
	long int sum=100000;
	scanf("%d", &n);
	for(i=0; i<n; i++) {
		sum*=1.05;
		if(sum%1000) {
			sum/=1000;
			sum*=1000;
			sum+=1000;
		}
	}
	printf("%ld\n", sum);
	return 0;
}


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

const int mod=1e9+7;
typedef long long ll;
ll sol, n, cat;
int comb(int n,int k)
{
    ll t1=1ll,t2=1ll;
    for(int i=k+1;i<=n;++i) t1=(1ll*i*t1)%mod;
    for(int i=2;i<=n-k;++i) t2=(1ll*i*t2)%mod;
    ll usu=1ll,p=1ll*mod-2;
    while(p)
    {
        if(p&1) usu=(1ll*usu*t2)%mod;
        p=p>>1;
        t2=(t2*t2)%mod;
    }
    ll sol=0;
    sol=t1*usu%mod;
    return sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin >> n;

    for(int i = 1; i * 3 <= n; ++i)
    {
        cat = n - i * 3;
        sol = (sol + comb(cat + i - 1, i - 1)) % mod;
    }

    cout << sol;
    return 0;
}


Measured memory_bytes: 3652
N = int(input())
A = []
for i in range(N):
    x,l = map(int,input().split())
    A.append([x,l])
A.sort()

t = -10**10
p = 0
for i,a in enumerate(A):
    if a[0]-a[1]>=t:
        t = a[0]+a[1]
        p += 1
    elif a[0]+a[1]<t:
        t = a[0]+a[1]

print(p)


Measured memory_bytes: 20104
def main():
    N,K = map(int,input().split())
    R,S,P = map(int,input().split())
    dic = {"r":P,"s":R,"p":S}
    T = list(input())
    ans = 0
    for i in range(K):   
        for j in range(i,N,K):
            if j == i:
                ans += dic[T[j]]
            else:
                if T[j-K]==T[j]:
                    T[j]="x"
                else:
                    ans += dic[T[j]]
    print(ans)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 49648
N, M, Q = map(int, input().split())
LR = [[0 for j in range(N+1)] for i in range(N+1)]
for m in range(M):
    l, r = map(int, input().split())
    LR[l][r] += 1
# cumsum R
for i in range(N+1):
    for j in range(1, N+1):
        LR[i][j] += LR[i][j-1]
# cunsun L
for i in range(N-1, -1, -1):
    for j in range(N+1):
        LR[i][j] += LR[i+1][j]

for i in range(Q):
    p, q = map(int, input().split())
    print(LR[p][q])


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

int  main()
{
  int N;
  cin >> N;
  vector<int> cards(N);
  for(auto&& card : cards) {
    cin >> card;
  }
  sort(cards.begin(), cards.end(), greater<int>());
  int alice = 0;
  int bob = 0;
  for(int i = 0; i < N; i++) {
    if(i%2 == 0) {
      alice += cards[i];
    } else {
      bob += cards[i];
    }
  }
   cout << alice - bob << endl;
  return 0;
}


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

typedef long long ll;

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

    string s;
    cin >> s;
    for(int i=0;i<4;i++) cout << s[i];
    cout << ' ';
    for(int i=4;i<12;i++) cout << s[i];
    cout << endl;
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a.begin(), a.end())

int main(){
    while(1){
        int m,f,r;
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1)return 0;

        if(m == -1 || f == -1)printf("F\n");
        else if(m + f >= 80)printf("A\n");
        else if(m + f >= 65)printf("B\n");
        else if(m + f >= 50 || (m + f <  50 && m + f >= 30 && r >= 50))printf("C\n");
        else if(m + f >= 30)printf("D\n");
        else if(m + f <= 30)printf("F\n");
    }
    return 0;
}



Measured memory_bytes: 3016
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

#define MAXH 101
#define MAXW 101
bool done[MAXH][MAXW];
char table[MAXH][MAXW];
int W, H;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void dfs(int y, int x) {
    char mark = table[y][x];
    done[y][x] = true;
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (0 <= nx && nx < W && 0 <= ny && ny < H && table[ny][nx] == mark && !done[ny][nx]) {
            dfs(ny, nx);
        }
    }
    return;
}

int main(void) {
    while (1) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> table[i][j];
            }
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                done[i][j] = false;
            }
        }
        int ret = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (!done[i][j]) {
                    dfs(i, j);
                    ret++;
                }
            }
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 1644
#include <stdio.h>
int main(void){
    long long int n, m;
    scanf("%lld %lld", &n, &m);
    
    long long int ans;
    if(n==1 && m==1)ans=1;
    else if(n==1 && m>1)ans=m-2;
    else if(n>1 && m==1)ans=n-2;
    else ans=(n-2)*(m-2);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1724
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    a, op, b = LSS()
    a = int(a)
    b = int(b)

    if op == '+':
        print(a + b)
    else:
        print(a - b)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10100
import java.util.Scanner;
import java.util.Arrays;
class Main{
 public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int a[]=new int[3];
a[0]=sc.nextInt();
a[1]=sc.nextInt();
a[2]=sc.nextInt();
Arrays.sort(a);
System.out.println(a[0]+a[1]==a[2]? "Yes":"No");

 }
  }


Measured memory_bytes: 23508
<?php

fscanf(STDIN,"%d%d",$a,$b);

$ab = $a.$b;
$rsl = "No";

for ($i = 0; $i <=1000; $i++){
    $total = pow($i,2);
    if ($ab == $total){
        $rsl = "Yes";
    }
}
echo $rsl;

Measured memory_bytes: 4604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int main(){
	int q, s, h, d;
	cin>>q>>h>>s>>d;
	int min_1l = min(min(q*4, h*2), s);
	int min_2l = min(2*min_1l, d);
	int n;
	cin>>n;
	long long cost = (n/2)*((long long) min_2l)+ (n%2) * ((long long) min_1l);
	cout<<cost;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
using namespace std;

int main(void){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  stack<int> b;
  queue<int> c;
  for(int i = 0; i < n; i++){
    if(i % 2 == n % 2){
      c.push(a[i]);
    }else{
      b.push(a[i]);
    }
  }
  while(!b.empty()){
    cout << b.top() << " ";
    b.pop();
  }
  while(!c.empty()){
    cout << c.front() << " ";
    c.pop();
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<string>

using namespace std;

int main(int argc, char const *argv[]) {
  int N,K;
  string S;
  cin >> N >> S >> K;
  char a = S[K-1];
  for (int i = 0; i < S.size(); i++) {
    cout << (S[i]==a ? a:'*');
  }
  cout << endl;
}


Measured memory_bytes: 256
package main

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

var swapCnt int
var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	return i
}

func printArray(arr []int) {
	for i := 0; i < len(arr); i++ {
		if i == 0 {
			fmt.Printf("%d", arr[i])
		} else {
			fmt.Printf(" %d", arr[i])
		}
	}
	fmt.Println()
}

func buddleSort(arr []int) {
	for i := 0; i < len(arr); i++ {
		for j := len(arr) - 1; i+1 <= j; j-- {
			if arr[j] < arr[j-1] {
				arr[j-1], arr[j] = arr[j], arr[j-1]
				swapCnt++
			}
		}
	}
	printArray(arr)
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = nextInt()
	}
	buddleSort(arr)
	fmt.Println(swapCnt)
}



Measured memory_bytes: 1124
using System;
using System.Linq;

class Program {
    static void Main() {
        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = n[0];
        int b = n[1];
        int c = n[2];
        if (a < b && b < c) {
            Console.WriteLine("Yes");
        } else {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 9320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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 (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    string s;
    cin >> n >> s;
    string ans = "";
    vector<int> v(n);
    int z = 0;
    rep(i, n) {
        if (i==0) {
            if (s[i]=='(') v[i] = 1;
            else v[i] = -1;
        }
        else {
            if (s[i]=='(') v[i] = v[i-1] + 1;
            else v[i] = v[i-1] - 1;
        }
        chmin(z, v[i]);
    }
    rep(i, abs(z)) cout << '(';
    cout << s;
    rep(i, v[n-1]+abs(z)) cout << ')';
    cout << endl;

    return 0;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int N,Q,K,s;
map<int,ll>C[100005];
map<int,ll>Cc[100005];

void bfs(int p,int pa,ll cost)
{
	for(auto i=C[p].begin();i!=C[p].end();i++)
	{
		int pp=i->first;
		if(pp==pa)continue;
		Cc[K][pp]=Cc[pp][K]=cost+C[p][pp];
		bfs(pp,p,cost+C[p][pp]);
	}
}

int main()
{
	scanf("%d",&N);
	for(int i=0;i<N-1;i++)
	{
		int a,b,c;
		P t;
		scanf("%d%d%d",&a,&b,&c);
		a--,b--;
		C[a][b]=C[b][a]=c;
	}
	scanf("%d%d",&Q,&K);K--;
	bfs(K,K,0);
	for(int i=0;i<Q;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--;y--;
		printf("%lld\n",Cc[x][K]+Cc[K][y]);
	}
	return 0;
}


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


int n,v,p;
long long a[100005];
long long m;

bool check(int mid){
  //  cout<<mid<<endl;
    long long minn=a[mid]+m;
    int k=0;
    long long rem=m*v-m;
    for(int i=n;i>mid;i--)
    {
        if(a[i]>minn){
            rem-=m;k++;
        }
        if(a[i]<=minn&&rem>0){
            if(k<p-1){
                rem-=m;k++;
            }
            else{
                rem-=(minn-a[i]);
            }
        }
       // cout<<rem<<" "<<k<<endl;
    }
    if(k>=p)return false;
    if(rem<=0)return true;
    for(int i=mid-1;i>=1;i--){
        rem-=m;
    }
    if(rem<=0)return true;
    else return false;
}

int erfen(int l,int r){
    if(l==r)return l;
    int mid=(l+r)/2;
    if(check(mid))return erfen(l,mid);
    else return erfen(mid+1,r);
}

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

    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+1+n);
    printf("%d\n",n-erfen(1,n)+1);
    return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    vector<string> AB(N);

    rep(i, N) cin >> AB.at(i);

    int count = 0;
    int front = 0, end = 0, same = 0;
    rep(i, N) {
        int loop = (int)AB.at(i).size();
        if (AB.at(i).at(0) == 'B') front++;
        if (AB.at(i).at(loop-1) == 'A') end++;
        if ((AB.at(i).at(0) == 'B') && (AB.at(i).at(loop-1) == 'A')) same++;
        rep(j, loop - 1) {
            if (AB.at(i).at(j) == 'A' && AB.at(i).at(j+1) == 'B') {
                count++;
            }
        }
    }
    //cout << front << ' ' << end << ' ' << N << endl;
    if (front == end && end == same && same > 0) count--;
    cout << count + min(front, end) << endl;
    return 0;
}

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

int main(void){
  int a,b,c,d,e,k,ans;
  ans=0;
  scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&k);
 int h[5]={a,b,c,d,e};
  for(int i=0;i<5;i+=1){
    for(int ii=0;ii<5;ii+=1){
      if(abs(h[i]-h[ii])>k){
      ans=ans+1;
       printf(":(");
      break;}
    }
       if(ans==1){
        break;}
  }
    
  
  
  if(ans==0){
    printf("Yay!");
  }
    return 0;
  }
  
  
  
  


Measured memory_bytes: 128
using static System.Console;
using System.Collections.Generic;

class Program
{
  static void Main(string[] args)
  {
    string[] s = ReadLine().Split(' ');
    string A = s[0],B = s[1], a = "",b = "";
    List<string> list = new List<string>();
    for(int i = 0;i < int.Parse(B);i++)a += A;
    list.Add(a);
    for(int i = 0;i < int.Parse(A);i++)b += B;
    list.Add(b);
    list.Sort();
    WriteLine(list[0]);
  }
}

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

int main(){
    int d;
    cin >> d;
    cout << "Christmas ";
    rep(i,25-d){
        cout << "Eve ";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a[5];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a,a+3);
  cout<<a[0]+a[1]<<"\n";

  return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var S = ReadText();
            for (int i = 0; i < S.Length; i++)
            {
                if ((i + 1) % 2 == 0)
                {
                    if (S[i] == 'R') return "No";
                }
                else
                {
                    if (S[i] == 'L') return "No";
                }
            }

            return "Yes";
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    long N, K;
    cin >> N >> K;
    map<long, long> m;
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        m[a] += b;
    }

    auto it = m.begin();
    --K;
    while (K > 0) {
        if (it->second > K)
            break;
        K -= it->second;
        ++it;
    }
    cout << it->first << '\n';
    return 0;
}


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

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    int A[n][m], B[m][l];
    long long C[n][l];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }

    for (int j = 0; j < m; j++) {
        for (int k = 0; k < l; k++) {
            cin >> B[j][k];
        }
    }

    for (int i = 0; i < n; i++) {
        for (int k = 0; k < l; k++) {
            C[i][k] = 0;



            for (int j = 0; j < m; j++) {
                C[i][k] += A[i][j] * B[j][k];
            }

            cout << C[i][k];

            if (k != l - 1) {
                cout << ' ';
            }
        }
        cout << endl;
    }

}



Measured memory_bytes: 3256
N = input()

if N[len(N)-1] == "3":
    print("bon")
elif N[len(N)-1] == "0" or N[len(N)-1] == "1" or N[len(N)-1] == "6" or N[len(N)-1] == "8":
    print("pon")
else:
    print("hon")

Measured memory_bytes: 9120
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt() - 1
	c, s, f := make([]int, n), make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		c[i], s[i], f[i] = scanInt(), scanInt(), scanInt()
	}

	for i := 0; i < n; i++ {
		t := s[i]
		for j := i; j < n; j++ {
			t = s[j] + (max(0,t-s[j])+f[j]-1)/f[j]*f[j] + c[j]
		}
		fmt.Fprintln(wr, t)
	}
	fmt.Fprintln(wr, 0)
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    int cnt = 0;
	int n = sc.nextInt();
    boolean[] used = new boolean[n];
    int [][] red = new int [n][2];
    int [][] blue = new int [n][2];
    
    for(int i=0;i<n;i++){
      red[i][0] = sc.nextInt();
      red[i][1] = sc.nextInt();
    }
    
    for(int j=0;j<n;j++){
      blue[j][0] = sc.nextInt();
      blue[j][1] = sc.nextInt();
    }
    
    Arrays.sort(red, (x,y) -> Integer.compare(x[1],y[1]));
    Arrays.sort(blue, (x,y) -> Integer.compare(x[0],y[0]));
		for(int k=0; k<n; k++) {
			for(int l=n-1; l>=0; l--) {
				if(blue[k][0]>red[l][0]&&blue[k][1]>red[l][1]&&!used[l]) {
					cnt += 1;
					used[l] = true;
					break;
				}
			}
		}
	System.out.println(cnt);
  }
}


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


int main(){
  bool flag[1000001];
  int s;
  cin >> s;
  for(int i=0;i<1000001;i++) flag[i] = true;
  for(int i=1;;i++){
    if(!flag[s]){
      cout << i << endl;
      return 0;
    }
    flag[s] = false;
    if(s%2==0) s/=2;
    else s = 3*s+1;
  }
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    
    string ans;
    for(int i=0; i<ty-sy; i++) {
        ans += 'U';
    }
    for(int i=0; i<tx-sx; i++) {
        ans += 'R';
    }
    // cout << ans << endl;

    if(tx-sx!=0 && ty-sy!=0) {
        for(int i=0; i<ty-sy; i++) {
            ans += 'D';
        }
        for(int i=0; i<tx-sx; i++) {
            ans += 'L';
        }

        ans += 'L';
        for(int i=0; i<ty-sy+1; i++) {
            ans += 'U';
        }
        for(int i=0; i<tx-sx+1; i++) {
            ans += 'R';
        }
        ans += 'D';
        
        ans += 'R';
        for(int i=0; i<ty-sy+1; i++) {
            ans += 'D';
        }
        for(int i=0; i<tx-sx+1; i++) {
            ans += 'L';
        }
        ans += 'U';
    }

    cout << ans << endl;

    return 0;
    
}

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

class Dice{
private:
  int tmp;
public:
  int q[6];
  void roll(char d){
    if(d=='N'){
      tmp = q[4];
      q[4] = q[0];
      q[0] = q[1];
      q[1] = q[5];
      q[5] = tmp;
    } else if(d=='E'){
      tmp = q[2];
      q[2] = q[0];
      q[0] = q[3];
      q[3] = q[5];
      q[5] = tmp;
    } else if(d=='W'){
      tmp = q[3];
      q[3] = q[0];
      q[0] = q[2];
      q[2] = q[5];
      q[5] = tmp;
    } else if(d=='S'){
      tmp = q[1];
      q[1] = q[0];
      q[0] = q[4];
      q[4] = q[5];
      q[5] = tmp;
    }
  }
};


int main(){
  Dice d;
  for(int i=0; i<6; i++){
    cin >> d.q[i];
  }
  int n;
  int a, b;
  int r;
  int ans;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a >> b;
    for(int i=0; i<=6;i++){//上の面をaにする
      //cout << "a";
      if(i==5){
        d.roll('E');
      } else if(i==6) {
        d.roll('E');
        d.roll('E');
      } else d.roll('N');
      //cout << d.q[0] << " " << d.q[1] << endl;
      if(d.q[0]==a)break;
    }
    for(int i=0; i<=4;i++){//上の面を固定したまま、横の面をぐるっと一周
      //cout << "b";
      d.roll('E');
      d.roll('N');
      d.roll('W');
      //cout << d.q[0] << " " << d.q[1] << endl;
      if(d.q[0]==a&&d.q[1]==b)break;
    }
    cout << d.q[2] << endl;
    //cout << ans << endl;
  }
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define siz 			105
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
int main()
{
	ll n,k,i,j;
	cin>>n>>k;
	ld ans = 0.0,curr= 0.0;
	ld values[n];
	for(i = 0;i<n;i++)
	{
		cin>>values[i];
		values[i]++;
		values[i] /= 2.0;
	}
	for(i = 0;i<k;i++)
	{
		curr += values[i];
	}
	ans = curr;
	for(i = k;i<n;i++)
	{
		curr += values[i] - values[i-k];
		ans = max(ans,curr);
	}
	
	cout<<fixed<<setprecision(6)<<ans;
	
	
}

Measured memory_bytes: 3328
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map (fun x -> int x)

let a, b, c = readStringArray() |> fun x -> (x.[0], x.[1], x.[2])

if (a |> Seq.last) = b.[0] && (b |> Seq.last) = c.[0] then "YES" else "NO"
|> printfn "%s"

Measured memory_bytes: 11996
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
#define MAX 100
#define INF 800000000

int main(){
  ll N;
  cin>>N;
  ll ans=0;
  for(ll i=1;i<=sqrt(N);i++){
    if(N%i==0){
      ll m=N/i-1;
      if(m==0){
        continue;
      }
      if(N/m==N%m){
        ans+=m;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(0);
    
    lli h;
    cin >> h;
    lli cnt = 0;

    while(h > 1){
        cnt++;
        h = floor(h/2.0);
    }
    cout << pow(2, cnt+1)-1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a;
    scanf("%d", &a);
    if (a > 81) {
        printf("No");
        return 0;
    }
    for (int i = 1; i <= 9; i++) {
        int rem = a % i;
        if (rem == 0 && a / i < 10) {
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    string s; cin >> s;
    int count1 = 0;
    for(char i = 'a'; i <= 'z'; i++){
        int count = 0;
        rep(j,s.size()){
            if(s[j]==i){
                count += 1;
            }
        }
        if(count == 0){
            cout << i << endl;
            count1 += 1;
            break;
        }
    }
    if(count1 == 0){
        cout << "None" << endl;
    }

    return 0;
}

Measured memory_bytes: 512
N = int(input())

num = 3505

for i in range(1, num):
    if N / 4 < i:
        for j in range(1, num):
            if N / 4 < (i * j) / (i + j):
                w = (N * i * j) / (4 * i * j - i * N - j * N)
                if w.is_integer():
                    print(i, j, int(w))
                    exit()

Measured memory_bytes: 3060
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-03-01 21:20:31
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

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

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> s(m), c(m);
    for (int i = 0; i < m; i++) {
        cin >> s[i] >> c[i];
    }

    int bot, top;
    if (n == 1) {
        bot = 0; top = 9;
    } else {
        bot = pow(10, n-1);
        top = pow(10, n) - 1;
    }

    int ans;
    for (ans = bot; ans <= top+1; ans++) {
        if (ans == top+1) {
            ans = -1;
            break;
        }
        vector<int> dig(n);
        int temp = ans;
        for (int i = 0; i < n; i++) {
            dig[i] = temp % 10;
            temp /= 10;
        }
        reverse(all(dig));

        int ok = 1;
        for (int i = 0; i < m; i++) {
            if (dig[s[i]-1] != c[i]) {
                ok = 0;
            }
        }

        if (ok) {
            break;
        }
    }

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


Measured memory_bytes: 256